new_his_api_controller.go 452KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360
  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/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func NewHisManagerApiRegistRouters() {
  31. //挂号
  32. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  33. //上传就诊信息-上传明细-结算
  34. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  35. //查询
  36. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  37. //对总账
  38. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  39. //对明细
  40. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  41. //退费,退明细
  42. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  43. //退号
  44. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  45. //退明细
  46. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  47. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  48. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  49. //beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  52. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  53. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  63. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  64. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  66. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  67. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  68. beego.Router("/api/check", &HisApiController{}, "get:Check")
  69. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  70. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  71. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  72. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  73. beego.Router("/9002", &HisApiController{}, "get:Get9002")
  74. beego.Router("/2505", &HisApiController{}, "get:Get2505")
  75. beego.Router("/2503", &HisApiController{}, "get:Get2503")
  76. beego.Router("/5301", &HisApiController{}, "get:Get5301")
  77. beego.Router("/2504", &HisApiController{}, "get:Get2504")
  78. beego.Router("/1160", &HisApiController{}, "get:Get1160")
  79. beego.Router("/2001", &HisApiController{}, "get:Get2001")
  80. // beego.Router("/api/gzpatient/get", &HisApiController{}, "get:GetGZPatientInfo")
  81. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. }
  83. // func (c *HisApiController) GetGZPatientInfo() {
  84. // id_card_no := c.GetString("id_card_no")
  85. // admin_user_id, _ := c.GetInt64("admin_user_id")
  86. // patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  87. // if patient.ID == 0 {
  88. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  89. // return
  90. // }
  91. // role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  92. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  93. // config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  94. // var result string
  95. // var request_log string
  96. // var result_log string
  97. // result, request_log, result_log = service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig. MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, patient.Name)
  98. // var dat map[string]interface{}
  99. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  100. // fmt.Println(dat)
  101. // } else {
  102. // fmt.Println(err)
  103. // }
  104. // userJSONBytes, _ := json.Marshal(dat)
  105. // var res ResultTwo
  106. // var resTwo10265 ResultTwo10265
  107. // if miConfig.Code == "H15049901371" {
  108. // if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  109. // utils.ErrorLog("解析失败:%v", err)
  110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  111. // return
  112. // }
  113. // Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  114. // res.Infcode = Infcode
  115. // res.ErrMsg = resTwo10265.ErrMsg
  116. // res.Output = resTwo10265.Output
  117. // res.InfRefmsgid = resTwo10265.InfRefmsgid
  118. // res.RespondTime = resTwo10265.RespondTime
  119. // res.WarnInfo = resTwo10265.WarnInfo
  120. // } else {
  121. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  122. // utils.ErrorLog("解析失败:%v", err)
  123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  124. // return
  125. // }
  126. // }
  127. // var insutypes []string
  128. // var insutype string
  129. // var is390 int = 0
  130. // var is310 int = 0
  131. // for _, item := range res.Output.Iinfo {
  132. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  133. // insutypes = append(insutypes, item.Insutype)
  134. // }
  135. // }
  136. // if len(insutypes) == 1 {
  137. // insutype = insutypes[0]
  138. // } else {
  139. // for _, i := range insutypes {
  140. // if i == "390" {
  141. // is390 = 1
  142. // }
  143. // if i == "310" {
  144. // is310 = 1
  145. // }
  146. // }
  147. // }
  148. // if is390 == 1 {
  149. // insutype = "390"
  150. // }
  151. // if is310 == 1 {
  152. // insutype = "310"
  153. // }
  154. // if len(insutypes) == 0 {
  155. // insutype = "310"
  156. // }
  157. // if res.Infcode != 0 {
  158. // c.ServeSuccessJSON(map[string]interface{}{
  159. // "failed_code": -10,
  160. // "msg": res.ErrMsg,
  161. // })
  162. // } else {
  163. // c.ServeSuccessJSON(map[string]interface{}{
  164. // "failed_code": 0,
  165. // "info": res,
  166. // "insutype": insutype,
  167. // })
  168. // }
  169. // }
  170. func (c *HisApiController) Get9002() {
  171. adminUser := c.GetAdminUserInfo()
  172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  173. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  174. service.Gdyb9002(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  175. }
  176. func (c *HisApiController) Get2001() {
  177. adminUser := c.GetAdminUserInfo()
  178. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  179. baseParams := models.BaseParams{
  180. SecretKey: "h1hEqxQm12ryULCgPKolkid8S9hZFu6M",
  181. FixmedinsCode: miConfig.Code,
  182. InsuplcAdmdvs: "441599",
  183. MdtrtareaAdmvs: "440100",
  184. OrgName: miConfig.OrgName,
  185. Doctor: "1111",
  186. }
  187. service.Gdyb2001(baseParams, "441500CS000000301426", "310", "11")
  188. }
  189. func (c *HisApiController) Get1160() {
  190. adminUser := c.GetAdminUserInfo()
  191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  192. baseParams := models.BaseParams{
  193. SecretKey: "h1hEqxQm12ryULCgPKolkid8S9hZFu6M",
  194. FixmedinsCode: miConfig.Code,
  195. InsuplcAdmdvs: "440100",
  196. MdtrtareaAdmvs: "440100",
  197. OrgName: miConfig.OrgName,
  198. Doctor: "1111",
  199. }
  200. service.Gdyb1160(baseParams, "441500CS000000301426", "310", "14")
  201. }
  202. func (c *HisApiController) Get2504() {
  203. adminUser := c.GetAdminUserInfo()
  204. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  205. result := service.Gdyb2504("441500CS000000301426", miConfig.OrgName, "admin", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "20220629626617")
  206. fmt.Println(result)
  207. }
  208. func (c *HisApiController) Get5301() {
  209. adminUser := c.GetAdminUserInfo()
  210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  211. result := service.Gdyb5301("44010000003501822495", miConfig.OrgName, "admin", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  212. fmt.Println(result)
  213. }
  214. func (c *HisApiController) Get2505() {
  215. adminUser := c.GetAdminUserInfo()
  216. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  217. result := service.Gdyb2505("44010000003501822495", "admin", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-01-01 12:35:39", "2022-12-30 12:35:39")
  218. fmt.Println(result)
  219. }
  220. func (c *HisApiController) Get2503() {
  221. adminUser := c.GetAdminUserInfo()
  222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  223. result := service.Gdyb2503ForGz("441500CS000000301426", "310", miConfig.OrgName, "方军", miConfig.Code, "1", "441599", miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "慢性肾功能不全(血液治疗)", "M07803", "2022-01-01 12:35:39", "2022-12-30 12:35:39", "2022-06-28 00:00:00")
  224. fmt.Println(result)
  225. }
  226. func (c *HisApiController) Get9001() {
  227. adminUser := c.GetAdminUserInfo()
  228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  229. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  230. result, inputLog := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  231. var dat map[string]interface{}
  232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  233. fmt.Println(dat)
  234. } else {
  235. fmt.Println(err)
  236. }
  237. userJSONBytes, _ := json.Marshal(dat)
  238. var res models.Result9001
  239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  240. utils.ErrorLog("解析失败:%v", err)
  241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  242. return
  243. }
  244. if res.Infcode == 0 {
  245. sign := models.HisSignIn{
  246. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  247. SignNo: res.Output.Result.SignNo,
  248. SignTime: res.Output.Result.SignTime,
  249. Ctime: time.Now().Unix(),
  250. Mtime: time.Now().Unix(),
  251. Status: 1,
  252. InputLog: inputLog,
  253. OutputLog: result,
  254. FixmedinsCode: miConfig.Code,
  255. }
  256. err := service.CreateSignIn(&sign)
  257. if err == nil {
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "msg": "签到成功",
  260. })
  261. }
  262. }
  263. }
  264. func (c *HisApiController) Check3101() {
  265. patient_id, _ := c.GetInt64("patient_id")
  266. his_patient_id, _ := c.GetInt64("his_patient_id")
  267. admin_user_id, _ := c.GetInt64("admin_user_id")
  268. adminUser := c.GetAdminUserInfo()
  269. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  270. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  272. record_time := c.GetString("record_time")
  273. trig_scen := c.GetString("trig_scen")
  274. timeLayout := "2006-01-02"
  275. loc, _ := time.LoadLocation("Local")
  276. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  277. if err != nil {
  278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  279. return
  280. }
  281. recordDateTime := theTime.Unix()
  282. var patientPrescription models.HisPrescriptionInfo
  283. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  284. if patientPrescription.ID == 0 {
  285. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  286. }
  287. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  288. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  289. //
  290. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  291. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  292. var pp models.PublicParams
  293. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  294. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  295. pp.FixmedinsName = miConfig.OrgName
  296. pp.FixmedinsCode = miConfig.Code
  297. pp.RequestUrl = miConfig.Url
  298. pp.Cainfo = miConfig.Cainfo
  299. pp.SecretKey = miConfig.SecretKey
  300. pp.AccessKey = miConfig.AccessKey
  301. pp.OpterName = roles.UserName
  302. var config []*models.HisXtDiagnoseConfig
  303. for _, item := range diagnosis_ids {
  304. id, _ := strconv.ParseInt(item, 10, 64)
  305. diagnosisConfig, _ := service.FindDiagnoseById(id)
  306. config = append(config, &diagnosisConfig)
  307. }
  308. var pd models.PatientDtos
  309. pd.PatnID = his.PsnNo
  310. pd.PatnName = his.Name
  311. pd.Gend = his.Gend
  312. pd.Brdy = his.Brdy
  313. pd.Poolarea = his.InsuplcAdmdvs
  314. pd.CurrMdtrtID = his.Number
  315. var fed models.FsiEncounterDtos
  316. fed.MdtrtID = his.Number
  317. fed.MedinsID = miConfig.Code
  318. fed.MedinsName = miConfig.OrgName
  319. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  320. fed.MedMdtrtType = "1"
  321. fed.MedinsType = "1"
  322. fed.MedinsLv = "11"
  323. tm := time.Unix(his.RecordDate, 0)
  324. s_tm := tm.Format("2006-01-02 15:04:05")
  325. fed.AdmDate = s_tm
  326. fed.DscgDate = s_tm
  327. fed.DscgMainDiseCodg = config[0].CountryCode
  328. fed.DscgMainDiseName = config[0].CountryContentName
  329. //诊断信息
  330. var fdds []*models.FsiDiagnoseDtos
  331. for index, item := range config {
  332. if index == 0 {
  333. var fdd models.FsiDiagnoseDtos
  334. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  335. fdd.InoutDiseType = "1"
  336. fdd.MaindiseFlag = "1"
  337. fdd.DiseDate = s_tm
  338. fdd.DiasSrtNo = "1"
  339. fdd.DiseName = item.CountryContentName
  340. fdd.DiseCodg = item.CountryCode
  341. fdds = append(fdds, &fdd)
  342. } else {
  343. var fdd models.FsiDiagnoseDtos
  344. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  345. fdd.InoutDiseType = "1"
  346. fdd.MaindiseFlag = "1"
  347. fdd.DiseDate = s_tm
  348. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  349. fdd.DiseName = item.CountryContentName
  350. fdd.DiseCodg = item.CountryCode
  351. fdds = append(fdds, &fdd)
  352. }
  353. }
  354. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  355. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  356. fed.AdmDeptName = department.Name
  357. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  358. fed.DscgDeptName = department.Name
  359. fed.MedMdtrtType = "1"
  360. fed.MedType = "11"
  361. //if his.Insutype == "390" {
  362. // fed.MedType = "1402"
  363. //} else {
  364. // fed.MedType = "9933"
  365. //}
  366. var orders []*models.FsiOrderDtos
  367. if trig_scen == "2" {
  368. //处方医嘱信息
  369. for _, item := range prescriptions {
  370. for _, subItem := range item.HisDoctorAdviceInfo {
  371. var order models.FsiOrderDtos
  372. order.RxID = strconv.FormatInt(item.ID, 10)
  373. order.Rxno = strconv.FormatInt(item.ID, 10)
  374. order.LongDrordFlag = "0"
  375. order.HilistType = "1"
  376. order.ChrgType = "1"
  377. order.DrordBhvr = "-"
  378. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  379. order.HosplistName = subItem.BaseDrugLib.DrugName
  380. order.HilistLv = "1"
  381. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  382. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  383. order.HosplistName = subItem.BaseDrugLib.DrugName
  384. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  385. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  386. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  387. order.OwnpayAmt = ""
  388. order.SelfpayAmt = ""
  389. order.Spec = ""
  390. order.SpecUnt = ""
  391. order.DrordBegnDate = s_tm
  392. order.DrordStopDate = ""
  393. order.DrordDrCodg = "1"
  394. order.DrordDeptName = department.Name
  395. order.DrordDrCodg = "1"
  396. order.DrordDrName = doctor_info.UserName
  397. order.DrordDrProfttl = ""
  398. order.CurrDrordFlag = "1"
  399. orders = append(orders, &order)
  400. }
  401. for _, subItem := range item.HisPrescriptionProject {
  402. if subItem.Type == 2 {
  403. var order models.FsiOrderDtos
  404. order.RxID = strconv.FormatInt(item.ID, 10)
  405. order.Rxno = strconv.FormatInt(item.ID, 10)
  406. order.LongDrordFlag = "0"
  407. order.HilistType = "1"
  408. order.ChrgType = "1"
  409. order.DrordBhvr = "-"
  410. order.HilistCode = subItem.HisProject.MedicalCode
  411. order.HosplistName = subItem.HisProject.ProjectName
  412. order.HilistLv = "1"
  413. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  414. order.HosplistCode = subItem.HisProject.MedicalCode
  415. order.HosplistName = subItem.HisProject.ProjectName
  416. order.Cnt = subItem.Count
  417. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  418. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  419. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  420. order.OwnpayAmt = ""
  421. order.SelfpayAmt = ""
  422. order.Spec = ""
  423. order.SpecUnt = ""
  424. order.DrordBegnDate = s_tm
  425. order.DrordStopDate = ""
  426. order.DrordDrCodg = "1"
  427. order.DrordDeptName = department.Name
  428. order.DrordDrCodg = "1"
  429. order.DrordDrName = doctor_info.UserName
  430. order.DrordDrProfttl = ""
  431. order.CurrDrordFlag = "1"
  432. orders = append(orders, &order)
  433. }
  434. if subItem.Type == 3 {
  435. var order models.FsiOrderDtos
  436. order.RxID = strconv.FormatInt(item.ID, 10)
  437. order.Rxno = strconv.FormatInt(item.ID, 10)
  438. order.LongDrordFlag = "0"
  439. order.HilistType = "1"
  440. order.ChrgType = "1"
  441. order.DrordBhvr = "-"
  442. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  443. order.HosplistName = subItem.GoodInfo.GoodName
  444. order.HilistLv = "1"
  445. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  446. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  447. order.HosplistName = subItem.GoodInfo.GoodName
  448. order.Cnt = subItem.Count
  449. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  450. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  451. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  452. order.OwnpayAmt = ""
  453. order.SelfpayAmt = ""
  454. order.Spec = ""
  455. order.SpecUnt = ""
  456. order.DrordBegnDate = s_tm
  457. order.DrordStopDate = ""
  458. order.DrordDrCodg = "1"
  459. order.DrordDeptName = department.Name
  460. order.DrordDrCodg = "1"
  461. order.DrordDrName = doctor_info.UserName
  462. order.DrordDrProfttl = ""
  463. order.CurrDrordFlag = "1"
  464. orders = append(orders, &order)
  465. }
  466. }
  467. }
  468. //处方医嘱信息
  469. }
  470. fed.MatnStas = "0"
  471. fed.MedfeeSumamt = "0"
  472. fed.OwnpayAmt = "0"
  473. fed.SelfpayAmt = "0"
  474. fed.AcctPayamt = "0"
  475. fed.MaAmt = "0"
  476. fed.HifpPayamt = "0"
  477. fed.SetlTotlnum = "1"
  478. fed.Insutype = his.Insutype
  479. fed.ReimFlag = "0"
  480. fed.OutSetlFlag = "0"
  481. var fopd []*models.FsiOperationDtosData
  482. data := make(map[string]interface{})
  483. data["fed"] = fed
  484. data["fdd"] = fdds
  485. data["fod"] = orders
  486. data["pd"] = pd
  487. data["pp"] = pp
  488. data["fopd"] = fopd
  489. data["trig_scen"] = trig_scen
  490. fmt.Println(data)
  491. fmt.Println(fed)
  492. fmt.Println(fdds)
  493. fmt.Println(orders)
  494. fmt.Println(pd)
  495. fmt.Println(pp)
  496. fmt.Println(fopd)
  497. client := &http.Client{}
  498. bytesData, _ := json.Marshal(data)
  499. var req *http.Request
  500. if miConfig.MdtrtareaAdmvs == "320921" {
  501. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  502. } else {
  503. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  504. }
  505. resp, _ := client.Do(req)
  506. defer resp.Body.Close()
  507. body, ioErr := ioutil.ReadAll(resp.Body)
  508. if ioErr != nil {
  509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  511. return
  512. }
  513. var respJSON map[string]interface{}
  514. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  517. return
  518. }
  519. //手术操作集合
  520. //手术操作集合
  521. }
  522. func (c *HisApiController) Check3102() {
  523. patient_id, _ := c.GetInt64("patient_id")
  524. order_id, _ := c.GetInt64("order_id")
  525. his_patient_id, _ := c.GetInt64("his_patient_id")
  526. admin_user_id, _ := c.GetInt64("admin_user_id")
  527. trig_scen := c.GetString("trig_scen")
  528. adminUser := c.GetAdminUserInfo()
  529. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  530. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  531. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  532. record_time := c.GetString("record_time")
  533. order, _ := service.GetHisOrderByID(order_id)
  534. timeLayout := "2006-01-02"
  535. loc, _ := time.LoadLocation("Local")
  536. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  537. if err != nil {
  538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  539. return
  540. }
  541. recordDateTime := theTime.Unix()
  542. var patientPrescription models.HisPrescriptionInfo
  543. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  544. if patientPrescription.ID == 0 {
  545. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  546. }
  547. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  548. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  549. //
  550. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  551. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  552. var pp models.PublicParams
  553. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  554. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  555. pp.FixmedinsName = miConfig.OrgName
  556. pp.FixmedinsCode = miConfig.Code
  557. pp.RequestUrl = miConfig.Url
  558. pp.Cainfo = miConfig.Cainfo
  559. pp.SecretKey = miConfig.SecretKey
  560. pp.AccessKey = miConfig.AccessKey
  561. pp.OpterName = roles.UserName
  562. var config []*models.HisXtDiagnoseConfig
  563. for _, item := range diagnosis_ids {
  564. id, _ := strconv.ParseInt(item, 10, 64)
  565. diagnosisConfig, _ := service.FindDiagnoseById(id)
  566. config = append(config, &diagnosisConfig)
  567. }
  568. var pd models.PatientDtos
  569. pd.PatnID = his.PsnNo
  570. pd.PatnName = his.Name
  571. pd.Gend = his.Gend
  572. pd.Brdy = his.Brdy
  573. pd.Poolarea = his.InsuplcAdmdvs
  574. pd.CurrMdtrtID = his.Number
  575. var fed models.FsiEncounterDtos
  576. fed.MdtrtID = his.Number
  577. fed.MedinsID = miConfig.Code
  578. fed.MedinsName = miConfig.OrgName
  579. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  580. fed.MedMdtrtType = "1"
  581. fed.MedinsType = "1"
  582. fed.MedinsLv = "11"
  583. tm := time.Unix(his.RecordDate, 0)
  584. s_tm := tm.Format("2006-01-02 15:04:05")
  585. fed.AdmDate = s_tm
  586. fed.DscgDate = s_tm
  587. fed.DscgMainDiseCodg = config[0].CountryCode
  588. fed.DscgMainDiseName = config[0].CountryContentName
  589. //诊断信息
  590. var fdds []*models.FsiDiagnoseDtos
  591. for index, item := range config {
  592. if index == 0 {
  593. var fdd models.FsiDiagnoseDtos
  594. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  595. fdd.InoutDiseType = "1"
  596. fdd.MaindiseFlag = "1"
  597. fdd.DiseDate = s_tm
  598. fdd.DiasSrtNo = "1"
  599. fdd.DiseName = item.CountryContentName
  600. fdd.DiseCodg = item.CountryCode
  601. fdds = append(fdds, &fdd)
  602. } else {
  603. var fdd models.FsiDiagnoseDtos
  604. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  605. fdd.InoutDiseType = "1"
  606. fdd.MaindiseFlag = "1"
  607. fdd.DiseDate = s_tm
  608. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  609. fdd.DiseName = item.CountryContentName
  610. fdd.DiseCodg = item.CountryCode
  611. fdds = append(fdds, &fdd)
  612. }
  613. }
  614. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  615. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  616. fed.AdmDeptName = department.Name
  617. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  618. fed.DscgDeptName = department.Name
  619. fed.MedType = order.MedType
  620. //处方医嘱信息
  621. var orders []*models.FsiOrderDtos
  622. //for _, item := range prescriptions {
  623. // for _, subItem := range item.HisDoctorAdviceInfo {
  624. // var order models.FsiOrderDtos
  625. // order.RxID = strconv.FormatInt(item.ID, 10)
  626. // order.Rxno = strconv.FormatInt(item.ID, 10)
  627. // order.LongDrordFlag = "0"
  628. // order.HilistType = "1"
  629. // order.ChrgType = "1"
  630. // order.DrordBhvr = "-"
  631. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  632. // order.HosplistName = subItem.BaseDrugLib.DrugName
  633. // order.HilistLv = "1"
  634. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  635. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  636. // order.HosplistName = subItem.BaseDrugLib.DrugName
  637. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  638. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  639. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  640. // order.OwnpayAmt = ""
  641. // order.SelfpayAmt = ""
  642. // order.Spec = ""
  643. // order.SpecUnt = ""
  644. // order.DrordBegnDate = s_tm
  645. // order.DrordStopDate = ""
  646. // order.DrordDrCodg = "1"
  647. // order.DrordDeptName = department.Name
  648. // order.DrordDrCodg = "1"
  649. // order.DrordDrName = doctor_info.UserName
  650. // order.DrordDrProfttl = ""
  651. // order.CurrDrordFlag = "1"
  652. // orders = append(orders, &order)
  653. // }
  654. // for _, subItem := range item.HisPrescriptionProject {
  655. // if subItem.Type == 2 {
  656. // var order models.FsiOrderDtos
  657. // order.RxID = strconv.FormatInt(item.ID, 10)
  658. // order.Rxno = strconv.FormatInt(item.ID, 10)
  659. // order.LongDrordFlag = "0"
  660. // order.HilistType = "1"
  661. // order.ChrgType = "1"
  662. // order.DrordBhvr = "-"
  663. // order.HilistCode = subItem.HisProject.MedicalCode
  664. // order.HosplistName = subItem.HisProject.ProjectName
  665. // order.HilistLv = "1"
  666. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  667. // order.HosplistCode = subItem.HisProject.MedicalCode
  668. // order.HosplistName = subItem.HisProject.ProjectName
  669. // order.Cnt = subItem.Count
  670. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  671. //
  672. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  673. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  674. // order.OwnpayAmt = ""
  675. // order.SelfpayAmt = ""
  676. // order.Spec = ""
  677. // order.SpecUnt = ""
  678. // order.DrordBegnDate = s_tm
  679. // order.DrordStopDate = ""
  680. // order.DrordDrCodg = "1"
  681. // order.DrordDeptName = department.Name
  682. // order.DrordDrCodg = "1"
  683. // order.DrordDrName = doctor_info.UserName
  684. // order.DrordDrProfttl = ""
  685. // order.CurrDrordFlag = "1"
  686. // orders = append(orders, &order)
  687. //
  688. // }
  689. // if subItem.Type == 3 {
  690. //
  691. // var order models.FsiOrderDtos
  692. // order.RxID = strconv.FormatInt(item.ID, 10)
  693. // order.Rxno = strconv.FormatInt(item.ID, 10)
  694. // order.LongDrordFlag = "0"
  695. // order.HilistType = "1"
  696. // order.ChrgType = "1"
  697. // order.DrordBhvr = "-"
  698. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  699. // order.HosplistName = subItem.GoodInfo.GoodName
  700. // order.HilistLv = "1"
  701. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  702. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  703. // order.HosplistName = subItem.GoodInfo.GoodName
  704. // order.Cnt = subItem.Count
  705. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  706. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  707. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  708. // order.OwnpayAmt = ""
  709. // order.SelfpayAmt = ""
  710. // order.Spec = ""
  711. // order.SpecUnt = ""
  712. // order.DrordBegnDate = s_tm
  713. // order.DrordStopDate = ""
  714. // order.DrordDrCodg = "1"
  715. // order.DrordDeptName = department.Name
  716. // order.DrordDrCodg = "1"
  717. // order.DrordDrName = doctor_info.UserName
  718. // order.DrordDrProfttl = ""
  719. // order.CurrDrordFlag = "1"
  720. // orders = append(orders, &order)
  721. //
  722. // }
  723. // }
  724. //}
  725. for _, item := range prescriptions {
  726. for _, subItem := range item.HisDoctorAdviceInfo {
  727. var order models.FsiOrderDtos
  728. order.RxID = strconv.FormatInt(item.ID, 10)
  729. order.Rxno = strconv.FormatInt(item.ID, 10)
  730. order.LongDrordFlag = "0"
  731. order.HilistType = "1"
  732. order.ChrgType = "1"
  733. order.DrordBhvr = "-"
  734. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  735. order.HosplistName = subItem.BaseDrugLib.DrugName
  736. order.HilistLv = "1"
  737. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  738. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  739. order.HosplistName = subItem.BaseDrugLib.DrugName
  740. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  741. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  742. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  743. order.OwnpayAmt = ""
  744. order.SelfpayAmt = ""
  745. order.Spec = ""
  746. order.SpecUnt = ""
  747. order.DrordBegnDate = s_tm
  748. order.DrordStopDate = ""
  749. order.DrordDrCodg = "1"
  750. order.DrordDeptName = department.Name
  751. order.DrordDrCodg = "1"
  752. order.DrordDrName = doctor_info.UserName
  753. order.DrordDrProfttl = ""
  754. order.CurrDrordFlag = "1"
  755. orders = append(orders, &order)
  756. }
  757. for _, subItem := range item.HisPrescriptionProject {
  758. if subItem.Type == 2 {
  759. var order models.FsiOrderDtos
  760. order.RxID = strconv.FormatInt(item.ID, 10)
  761. order.Rxno = strconv.FormatInt(item.ID, 10)
  762. order.LongDrordFlag = "0"
  763. order.HilistType = "1"
  764. order.ChrgType = "1"
  765. order.DrordBhvr = "-"
  766. order.HilistCode = subItem.HisProject.MedicalCode
  767. order.HosplistName = subItem.HisProject.ProjectName
  768. order.HilistLv = "1"
  769. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  770. order.HosplistCode = subItem.HisProject.MedicalCode
  771. order.HosplistName = subItem.HisProject.ProjectName
  772. order.Cnt = subItem.Count
  773. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  774. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  775. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  776. order.OwnpayAmt = ""
  777. order.SelfpayAmt = ""
  778. order.Spec = ""
  779. order.SpecUnt = ""
  780. order.DrordBegnDate = s_tm
  781. order.DrordStopDate = ""
  782. order.DrordDrCodg = "1"
  783. order.DrordDeptName = department.Name
  784. order.DrordDrCodg = "1"
  785. order.DrordDrName = doctor_info.UserName
  786. order.DrordDrProfttl = ""
  787. order.CurrDrordFlag = "1"
  788. orders = append(orders, &order)
  789. }
  790. if subItem.Type == 3 {
  791. var order models.FsiOrderDtos
  792. order.RxID = strconv.FormatInt(item.ID, 10)
  793. order.Rxno = strconv.FormatInt(item.ID, 10)
  794. order.LongDrordFlag = "0"
  795. order.HilistType = "1"
  796. order.ChrgType = "1"
  797. order.DrordBhvr = "-"
  798. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  799. order.HosplistName = subItem.GoodInfo.GoodName
  800. order.HilistLv = "1"
  801. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  802. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  803. order.HosplistName = subItem.GoodInfo.GoodName
  804. order.Cnt = subItem.Count
  805. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  806. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  807. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  808. order.OwnpayAmt = ""
  809. order.SelfpayAmt = ""
  810. order.Spec = ""
  811. order.SpecUnt = ""
  812. order.DrordBegnDate = s_tm
  813. order.DrordStopDate = ""
  814. order.DrordDrCodg = "1"
  815. order.DrordDeptName = department.Name
  816. order.DrordDrCodg = "1"
  817. order.DrordDrName = doctor_info.UserName
  818. order.DrordDrProfttl = ""
  819. order.CurrDrordFlag = "1"
  820. orders = append(orders, &order)
  821. }
  822. }
  823. }
  824. //处方医嘱信息
  825. fed.MatnStas = "0"
  826. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  827. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  828. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  829. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  830. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  831. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  832. fed.SetlTotlnum = "1"
  833. fed.Insutype = his.Insutype
  834. fed.ReimFlag = "0"
  835. fed.OutSetlFlag = "0"
  836. var fopd []*models.FsiOperationDtosData
  837. data := make(map[string]interface{})
  838. data["fed"] = fed
  839. data["fdd"] = fdds
  840. data["fod"] = orders
  841. data["pd"] = pd
  842. data["pp"] = pp
  843. data["fopd"] = fopd
  844. data["trig_scen"] = trig_scen
  845. client := &http.Client{}
  846. bytesData, _ := json.Marshal(data)
  847. var req *http.Request
  848. if miConfig.MdtrtareaAdmvs == "320921" {
  849. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  850. } else {
  851. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  852. }
  853. resp, _ := client.Do(req)
  854. defer resp.Body.Close()
  855. body, ioErr := ioutil.ReadAll(resp.Body)
  856. if ioErr != nil {
  857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  859. return
  860. }
  861. var respJSON map[string]interface{}
  862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. //手术操作集合
  868. //手术操作集合
  869. }
  870. func (c *HisApiController) Check() {
  871. psn_no := c.GetString("psn_no")
  872. in := c.GetString("in")
  873. mt := c.GetString("mt")
  874. baseParams := models.BaseParams{
  875. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  876. FixmedinsCode: "H15049901371",
  877. InsuplcAdmdvs: "150499",
  878. MdtrtareaAdmvs: "150499",
  879. OrgName: "赤峰费森血液透析中心",
  880. Doctor: "1111",
  881. }
  882. service.Gdyb2001(baseParams, psn_no, in, mt)
  883. }
  884. func (c *HisApiController) GetPsnNcdsInfo() {
  885. admin_user_id, _ := c.GetInt64("admin_user_id")
  886. patient_id, _ := c.GetInt64("patient_id")
  887. id, _ := c.GetInt64("id")
  888. adminUser := c.GetAdminUserInfo()
  889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  890. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  891. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  892. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  893. psn_record, _ := service.GetPsnNCDSRecordById(id)
  894. //
  895. //if psn_record.ID == 0 {
  896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  897. // return
  898. //}
  899. var res Result5301
  900. var res10265 Result5301For10265
  901. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  902. psn_info, _ := service.GetPsnByPatientId(patient_id)
  903. var api string
  904. if miConfig.MdtrtareaAdmvs == "320921" {
  905. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  906. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  907. } else {
  908. 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 +
  909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  910. }
  911. resp, requestErr := http.Get(api)
  912. if requestErr != nil {
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. body, ioErr := ioutil.ReadAll(resp.Body)
  917. if ioErr != nil {
  918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. var respJSON map[string]interface{}
  923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  926. return
  927. }
  928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  929. result, _ := json.Marshal(respJSON)
  930. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  931. utils.ErrorLog("解析失败:%v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. res.ErrMsg = res10265.ErrMsg
  936. res.Output = res10265.Output
  937. res.InfRefmsgid = res10265.InfRefmsgid
  938. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  939. res.Infcode = infocode
  940. } else {
  941. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  942. var dat map[string]interface{}
  943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  944. fmt.Println(dat)
  945. } else {
  946. fmt.Println(err)
  947. }
  948. userJSONBytes, _ := json.Marshal(dat)
  949. if miConfig.Code == "H15049901371" {
  950. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  951. utils.ErrorLog("解析失败:%v", err)
  952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  953. return
  954. }
  955. res.InfRefmsgid = res10265.InfRefmsgid
  956. res.Output = res10265.Output
  957. res.ErrMsg = res10265.ErrMsg
  958. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  959. res.Infcode = infocode
  960. } else {
  961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  962. utils.ErrorLog("解析失败:%v", err)
  963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  964. return
  965. }
  966. }
  967. }
  968. if res.Infcode == 0 {
  969. c.ServeSuccessJSON(map[string]interface{}{
  970. "result": res.Output.Result,
  971. })
  972. }
  973. }
  974. func (c *HisApiController) CheckInsutype() {
  975. his_patient_id, _ := c.GetInt64("his_patient_id")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  981. var dat map[string]interface{}
  982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  983. fmt.Println(dat)
  984. } else {
  985. fmt.Println(err)
  986. }
  987. userJSONBytes, _ := json.Marshal(dat)
  988. var res Result90100
  989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  990. utils.ErrorLog("解析失败:%v", err)
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. if res.Infcode != 0 {
  995. c.ServeSuccessJSON(map[string]interface{}{
  996. "failed_code": -10,
  997. "msg": res.ErrMsg,
  998. })
  999. return
  1000. } else {
  1001. fmt.Println(res)
  1002. }
  1003. }
  1004. func (c *HisApiController) CheckCardPWD() {
  1005. card_pwd := c.GetString("card_pwd")
  1006. his_patient_id, _ := c.GetInt64("his_patient_id")
  1007. admin_user_id, _ := c.GetInt64("admin_user_id")
  1008. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1009. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1010. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1011. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1012. bas := strings.Split(psn.CardInfo, "|")
  1013. basNumber := bas[2]
  1014. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1015. var dat map[string]interface{}
  1016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1017. fmt.Println(dat)
  1018. } else {
  1019. fmt.Println(err)
  1020. }
  1021. userJSONBytes, _ := json.Marshal(dat)
  1022. var res Result90991
  1023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1024. utils.ErrorLog("解析失败:%v", err)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1026. return
  1027. }
  1028. if res.Infcode != 0 {
  1029. c.ServeSuccessJSON(map[string]interface{}{
  1030. "failed_code": -10,
  1031. "msg": res.ErrMsg,
  1032. })
  1033. return
  1034. } else {
  1035. fmt.Println(res.Output.Result.CardStat)
  1036. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  1037. var msg string
  1038. switch res.Output.Result.CardStat {
  1039. case "00":
  1040. msg = "未激活"
  1041. break
  1042. case "10":
  1043. msg = "激活"
  1044. break
  1045. case "20":
  1046. msg = "窗口挂失"
  1047. break
  1048. case "21":
  1049. msg = "电话挂失"
  1050. break
  1051. case "22":
  1052. msg = "单位网上申报挂失"
  1053. break
  1054. case "23":
  1055. msg = "保健办挂失"
  1056. break
  1057. case "24":
  1058. msg = "个人网上挂失"
  1059. break
  1060. case "25":
  1061. msg = "网上服务大厅挂失"
  1062. break
  1063. case "30":
  1064. msg = "注销"
  1065. break
  1066. case "40":
  1067. msg = "回收"
  1068. break
  1069. case "99":
  1070. msg = "制卡中(无效卡)"
  1071. break
  1072. }
  1073. c.ServeSuccessJSON(map[string]interface{}{
  1074. "failed_code": -10,
  1075. "msg": msg,
  1076. })
  1077. return
  1078. } else {
  1079. c.ServeSuccessJSON(map[string]interface{}{
  1080. "msg": "校验成功",
  1081. })
  1082. return
  1083. }
  1084. }
  1085. }
  1086. func (c *HisApiController) CheckCardPWDTwo() {
  1087. //card_pwd := c.GetString("card_pwd")
  1088. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1089. admin_user_id, _ := c.GetInt64("admin_user_id")
  1090. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1091. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1092. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1093. var dat map[string]interface{}
  1094. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1095. fmt.Println(dat)
  1096. } else {
  1097. fmt.Println(err)
  1098. }
  1099. userJSONBytes, _ := json.Marshal(dat)
  1100. var res Result90991
  1101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1102. utils.ErrorLog("解析失败:%v", err)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. return
  1105. }
  1106. if res.Infcode != 0 {
  1107. c.ServeSuccessJSON(map[string]interface{}{
  1108. "failed_code": -10,
  1109. "msg": res.ErrMsg,
  1110. })
  1111. return
  1112. } else {
  1113. if res.Output.Result.SscnoCheckStat == "0" {
  1114. var msg string
  1115. switch res.Output.Result.CardStat {
  1116. case "00":
  1117. msg = "未激活"
  1118. break
  1119. case "10":
  1120. msg = "激活"
  1121. break
  1122. case "20":
  1123. msg = "窗口挂失"
  1124. break
  1125. case "21":
  1126. msg = "电话挂失"
  1127. break
  1128. case "22":
  1129. msg = "单位网上申报挂失"
  1130. break
  1131. case "23":
  1132. msg = "保健办挂失"
  1133. break
  1134. case "24":
  1135. msg = "个人网上挂失"
  1136. break
  1137. case "25":
  1138. msg = "网上服务大厅挂失"
  1139. break
  1140. case "30":
  1141. msg = "注销"
  1142. break
  1143. case "40":
  1144. msg = "回收"
  1145. break
  1146. case "99":
  1147. msg = "制卡中(无效卡)"
  1148. break
  1149. }
  1150. c.ServeSuccessJSON(map[string]interface{}{
  1151. "failed_code": -10,
  1152. "msg": msg,
  1153. })
  1154. return
  1155. } else {
  1156. c.ServeSuccessJSON(map[string]interface{}{
  1157. "msg": "校验成功",
  1158. })
  1159. return
  1160. }
  1161. }
  1162. }
  1163. //func (c *HisApiController) ReadCard() {
  1164. // id_card_type, _ := c.GetInt64("id_card_type")
  1165. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1166. // certificates, _ := c.GetInt64("certificates")
  1167. // fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1168. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1169. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1170. //
  1171. // switch id_card_type {
  1172. // case 1:
  1173. // if miConfig.MdtrtareaAdmvs == "421300" {
  1174. // var res ResultTwo
  1175. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1176. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1177. // "&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)
  1178. //
  1179. // resp, requestErr := http.Get(api)
  1180. // if requestErr != nil {
  1181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. // return
  1183. // }
  1184. //
  1185. // body, ioErr := ioutil.ReadAll(resp.Body)
  1186. // if ioErr != nil {
  1187. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1189. // return
  1190. // }
  1191. // var respJSON map[string]interface{}
  1192. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. // return
  1196. // }
  1197. //
  1198. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1199. // result, _ := json.Marshal(respJSON)
  1200. // fmt.Println("log")
  1201. // fmt.Println(string(result))
  1202. //
  1203. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  1204. // utils.ErrorLog("解析失败:%v", err)
  1205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. // return
  1207. // }
  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. //
  1218. // } else {
  1219. //
  1220. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1221. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1222. // infoStr := string(Iinfos)
  1223. // idetinfoStr := string(Idetinfos)
  1224. // psn := &models.HisPsn{
  1225. // PsnNo: res.Output.Baseinfo.PsnNo,
  1226. // Age: res.Output.Baseinfo.Age,
  1227. // PatientId: patient.ID,
  1228. // Certno: res.Output.Baseinfo.Certno,
  1229. // Brdy: res.Output.Baseinfo.Brdy,
  1230. // Gend: res.Output.Baseinfo.Gend,
  1231. // Naty: res.Output.Baseinfo.Naty,
  1232. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1233. // PsnName: res.Output.Baseinfo.PsnName,
  1234. // Idetinfo: idetinfoStr,
  1235. // Insuinfo: infoStr,
  1236. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1237. // }
  1238. // service.CreateHisPsn(psn)
  1239. //
  1240. // c.ServeSuccessJSON(map[string]interface{}{
  1241. // "patient": patient,
  1242. // "number": res.Output.Baseinfo.Certno,
  1243. // })
  1244. // }
  1245. // } else {
  1246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1247. // return
  1248. // }
  1249. //
  1250. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1251. // var api string
  1252. // if miConfig.MdtrtareaAdmvs == "320921" {
  1253. // api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1254. // "&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
  1255. // fmt.Println(api)
  1256. // } else {
  1257. // 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 +
  1258. // "&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)
  1259. // }
  1260. //
  1261. // resp, requestErr := http.Get(api)
  1262. // if requestErr != nil {
  1263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1264. // return
  1265. // }
  1266. //
  1267. // body, ioErr := ioutil.ReadAll(resp.Body)
  1268. // if ioErr != nil {
  1269. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1271. // return
  1272. // }
  1273. // var respJSON map[string]interface{}
  1274. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1277. // return
  1278. // }
  1279. // var status string
  1280. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1281. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1282. // //console.log()
  1283. // fmt.Println("type===")
  1284. //
  1285. // fmt.Println(card_type)
  1286. //
  1287. // var token string
  1288. // var res ResultTwo //1101结果
  1289. // var res10265 ResultTwo10265 //1101结果
  1290. // var card_info string //卡信息
  1291. // var busi_card_info string
  1292. //
  1293. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1294. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1295. //
  1296. // if status == "0" { //读卡成功
  1297. // if card_type == "1" {
  1298. //
  1299. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1300. // result, _ := json.Marshal(respJSON)
  1301. //
  1302. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1303. // utils.ErrorLog("解析失败:%v", err)
  1304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1305. // return
  1306. // }
  1307. // res.ErrMsg = res10265.ErrMsg
  1308. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1309. // res.Infcode = infocode
  1310. // res.Output = res10265.Output
  1311. // res.InfRefmsgid = res10265.InfRefmsgid
  1312. //
  1313. // } else {
  1314. // //var card_info string //卡信息
  1315. // //var busi_card_info string
  1316. //
  1317. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1318. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1319. //
  1320. // //fmt.Println(card_info)
  1321. // //fmt.Println(busi_card_info)
  1322. //
  1323. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1324. // result, _ := json.Marshal(respJSON)
  1325. //
  1326. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1327. // utils.ErrorLog("解析失败:%v", err)
  1328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. // return
  1330. // }
  1331. // res.ErrMsg = res10265.ErrMsg
  1332. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1333. // res.Infcode = infocode
  1334. // res.Output = res10265.Output
  1335. // res.InfRefmsgid = res10265.InfRefmsgid
  1336. //
  1337. // }
  1338. //
  1339. // if res.Infcode == 0 {
  1340. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1341. // if err == gorm.ErrRecordNotFound {
  1342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1343. // return
  1344. // } else if err != nil {
  1345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1346. // return
  1347. //
  1348. // } else {
  1349. //
  1350. // if card_type == "1" {
  1351. // bas := strings.Split(card_info, "|")
  1352. // basNumber := bas[2]
  1353. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1354. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1355. // infoStr := string(Iinfos)
  1356. // idetinfoStr := string(Idetinfos)
  1357. // psn := &models.HisPsn{
  1358. // PsnNo: res.Output.Baseinfo.PsnNo,
  1359. // Age: res.Output.Baseinfo.Age,
  1360. // PatientId: patient.ID,
  1361. // Certno: res.Output.Baseinfo.Certno,
  1362. // Brdy: res.Output.Baseinfo.Brdy,
  1363. // Gend: res.Output.Baseinfo.Gend,
  1364. // Naty: res.Output.Baseinfo.Naty,
  1365. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1366. // PsnName: res.Output.Baseinfo.PsnName,
  1367. // Idetinfo: idetinfoStr,
  1368. // Insuinfo: infoStr,
  1369. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1370. // CardInfo: card_info,
  1371. // VerifyNumber: busi_card_info,
  1372. // }
  1373. // service.CreateHisPsn(psn)
  1374. //
  1375. // var rf []*ResultFive
  1376. // json.Unmarshal([]byte(infoStr), &rf)
  1377. //
  1378. // var insutypes []*ResultFive
  1379. // var insutype string
  1380. // var is390 int = 0
  1381. // var is310 int = 0
  1382. //
  1383. // for _, item := range rf {
  1384. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1385. // insutypes = append(insutypes, item)
  1386. // }
  1387. // }
  1388. //
  1389. // if len(insutypes) == 1 {
  1390. // insutype = insutypes[0].Insutype
  1391. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1392. // } else {
  1393. // for _, i := range insutypes {
  1394. // if i.Insutype == "390" {
  1395. // is390 = 1
  1396. // }
  1397. //
  1398. // if i.Insutype == "310" {
  1399. // is310 = 1
  1400. // }
  1401. // }
  1402. // }
  1403. // if is390 == 1 {
  1404. // insutype = "390"
  1405. // }
  1406. //
  1407. // if is310 == 1 {
  1408. // insutype = "310"
  1409. // }
  1410. //
  1411. // if len(insutypes) == 0 {
  1412. // insutype = "310"
  1413. // }
  1414. //
  1415. // c.ServeSuccessJSON(map[string]interface{}{
  1416. // "patient": patient,
  1417. // "number": basNumber,
  1418. // "insutype": insutype,
  1419. // })
  1420. // } else {
  1421. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1422. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1423. // infoStr := string(Iinfos)
  1424. // idetinfoStr := string(Idetinfos)
  1425. // psn := &models.HisPsn{
  1426. // PsnNo: res.Output.Baseinfo.PsnNo,
  1427. // Age: res.Output.Baseinfo.Age,
  1428. // PatientId: patient.ID,
  1429. // Certno: res.Output.Baseinfo.Certno,
  1430. // Brdy: res.Output.Baseinfo.Brdy,
  1431. // Gend: res.Output.Baseinfo.Gend,
  1432. // Naty: res.Output.Baseinfo.Naty,
  1433. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1434. // PsnName: res.Output.Baseinfo.PsnName,
  1435. // Idetinfo: idetinfoStr,
  1436. // Insuinfo: infoStr,
  1437. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1438. // CardInfo: card_info,
  1439. // VerifyNumber: token,
  1440. // }
  1441. // service.CreateHisPsn(psn)
  1442. // c.ServeSuccessJSON(map[string]interface{}{
  1443. // "patient": patient,
  1444. // "number": token,
  1445. // })
  1446. // }
  1447. // }
  1448. // } else {
  1449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1450. // return
  1451. // }
  1452. // } else { //读卡失败
  1453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1454. // return
  1455. //
  1456. // }
  1457. //
  1458. // } else {
  1459. // if initFlag == 0 {
  1460. // c.TestGetBasBaseInit()
  1461. // }
  1462. // basStr := c.GetBasBaseInfo()
  1463. // if len(basStr) == 0 {
  1464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1465. // return
  1466. // }
  1467. // fmt.Println(basStr)
  1468. // bas := strings.Split(basStr, "|")
  1469. // basNumber := bas[1]
  1470. // fmt.Println(basNumber)
  1471. // card_sn := bas[3]
  1472. // fmt.Println(card_sn)
  1473. // result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1474. // var dat map[string]interface{}
  1475. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1476. // fmt.Println(dat)
  1477. // } else {
  1478. // fmt.Println(err)
  1479. // }
  1480. //
  1481. // userJSONBytes, _ := json.Marshal(dat)
  1482. // var res ResultTwo
  1483. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1484. // utils.ErrorLog("解析失败:%v", err)
  1485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1486. // return
  1487. // }
  1488. //
  1489. // if res.Infcode == 0 {
  1490. // patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1491. // if err == gorm.ErrRecordNotFound {
  1492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1493. // return
  1494. // } else if err != nil {
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1496. // return
  1497. //
  1498. // } else {
  1499. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1500. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1501. // infoStr := string(Iinfos)
  1502. // idetinfoStr := string(Idetinfos)
  1503. // psn := &models.HisPsn{
  1504. // PsnNo: res.Output.Baseinfo.PsnNo,
  1505. // Age: res.Output.Baseinfo.Age,
  1506. // PatientId: patient.ID,
  1507. // Certno: res.Output.Baseinfo.Certno,
  1508. // Brdy: res.Output.Baseinfo.Brdy,
  1509. // Gend: res.Output.Baseinfo.Gend,
  1510. // Naty: res.Output.Baseinfo.Naty,
  1511. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1512. // PsnName: res.Output.Baseinfo.PsnName,
  1513. // Idetinfo: idetinfoStr,
  1514. // Insuinfo: infoStr,
  1515. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1516. // CardInfo: basStr,
  1517. // VerifyNumber: "",
  1518. // }
  1519. // service.CreateHisPsn(psn)
  1520. //
  1521. // c.ServeSuccessJSON(map[string]interface{}{
  1522. // "patient": patient,
  1523. // "number": basNumber,
  1524. // })
  1525. // }
  1526. // } else {
  1527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1528. // return
  1529. // }
  1530. // break
  1531. // }
  1532. // case 2:
  1533. // SFZStr := c.GetSFZBaseInfo()
  1534. // id_card_str := strings.Split(SFZStr, "^")
  1535. // id_card_number := id_card_str[0]
  1536. // card_sn := ""
  1537. // result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1538. // var dat map[string]interface{}
  1539. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1540. // fmt.Println(dat)
  1541. // } else {
  1542. // fmt.Println(err)
  1543. // }
  1544. //
  1545. // userJSONBytes, _ := json.Marshal(dat)
  1546. // var res ResultTwo
  1547. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1548. // utils.ErrorLog("解析失败:%v", err)
  1549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. // return
  1551. // }
  1552. //
  1553. // if res.Infcode == 0 {
  1554. // patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1555. // if err == gorm.ErrRecordNotFound {
  1556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1557. // return
  1558. // } else if err != nil {
  1559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1560. // return
  1561. //
  1562. // } else {
  1563. // c.ServeSuccessJSON(map[string]interface{}{
  1564. // "patient": patient,
  1565. // "number": id_card_number,
  1566. // })
  1567. // }
  1568. // } else {
  1569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1570. // return
  1571. // }
  1572. //
  1573. // break
  1574. // case 3:
  1575. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1576. // var api string
  1577. // if miConfig.MdtrtareaAdmvs == "320921" {
  1578. // api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1579. // "&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
  1580. // fmt.Println(api)
  1581. //
  1582. // } else {
  1583. // 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 +
  1584. // "&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)
  1585. // }
  1586. //
  1587. // resp, requestErr := http.Get(api)
  1588. // if requestErr != nil {
  1589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. // return
  1591. // }
  1592. //
  1593. // body, ioErr := ioutil.ReadAll(resp.Body)
  1594. // if ioErr != nil {
  1595. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1597. // return
  1598. // }
  1599. // var respJSON map[string]interface{}
  1600. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1601. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1603. // return
  1604. // }
  1605. // var status string
  1606. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1607. // card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1608. //
  1609. // var token string
  1610. // var res ResultTwo //1101结果
  1611. // var res10265 ResultTwo10265 //1101结果
  1612. // var card_info string //卡信息
  1613. // var busi_card_info string
  1614. //
  1615. // //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1616. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1617. //
  1618. // if status == "0" { //读卡成功
  1619. // if card_type == "1" {
  1620. //
  1621. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1622. // result, _ := json.Marshal(respJSON)
  1623. //
  1624. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1625. // utils.ErrorLog("解析失败:%v", err)
  1626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1627. // return
  1628. // }
  1629. // res.ErrMsg = res10265.ErrMsg
  1630. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1631. // res.Infcode = infocode
  1632. // res.Output = res10265.Output
  1633. // res.InfRefmsgid = res10265.InfRefmsgid
  1634. //
  1635. // } else {
  1636. // //var card_info string //卡信息
  1637. // //var busi_card_info string
  1638. //
  1639. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1640. // //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1641. //
  1642. // //fmt.Println(card_info)
  1643. // //fmt.Println(busi_card_info)
  1644. //
  1645. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1646. // result, _ := json.Marshal(respJSON)
  1647. //
  1648. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1649. // utils.ErrorLog("解析失败:%v", err)
  1650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. // return
  1652. // }
  1653. // res.ErrMsg = res10265.ErrMsg
  1654. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1655. // res.Infcode = infocode
  1656. // res.Output = res10265.Output
  1657. // res.InfRefmsgid = res10265.InfRefmsgid
  1658. //
  1659. // }
  1660. //
  1661. // if res.Infcode == 0 {
  1662. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1663. // if err == gorm.ErrRecordNotFound {
  1664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1665. // return
  1666. // } else if err != nil {
  1667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1668. // return
  1669. //
  1670. // } else {
  1671. //
  1672. // if card_type == "1" {
  1673. // bas := strings.Split(card_info, "|")
  1674. // basNumber := bas[2]
  1675. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1676. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1677. // infoStr := string(Iinfos)
  1678. // idetinfoStr := string(Idetinfos)
  1679. // psn := &models.HisPsn{
  1680. // PsnNo: res.Output.Baseinfo.PsnNo,
  1681. // Age: res.Output.Baseinfo.Age,
  1682. // PatientId: patient.ID,
  1683. // Certno: res.Output.Baseinfo.Certno,
  1684. // Brdy: res.Output.Baseinfo.Brdy,
  1685. // Gend: res.Output.Baseinfo.Gend,
  1686. // Naty: res.Output.Baseinfo.Naty,
  1687. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1688. // PsnName: res.Output.Baseinfo.PsnName,
  1689. // Idetinfo: idetinfoStr,
  1690. // Insuinfo: infoStr,
  1691. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1692. // CardInfo: card_info,
  1693. // VerifyNumber: busi_card_info,
  1694. // }
  1695. //
  1696. // service.CreateHisPsn(psn)
  1697. // c.ServeSuccessJSON(map[string]interface{}{
  1698. // "patient": patient,
  1699. // "number": basNumber,
  1700. // })
  1701. // } else {
  1702. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1703. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1704. // infoStr := string(Iinfos)
  1705. // idetinfoStr := string(Idetinfos)
  1706. // psn := &models.HisPsn{
  1707. // PsnNo: res.Output.Baseinfo.PsnNo,
  1708. // Age: res.Output.Baseinfo.Age,
  1709. // PatientId: patient.ID,
  1710. // Certno: res.Output.Baseinfo.Certno,
  1711. // Brdy: res.Output.Baseinfo.Brdy,
  1712. // Gend: res.Output.Baseinfo.Gend,
  1713. // Naty: res.Output.Baseinfo.Naty,
  1714. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1715. // PsnName: res.Output.Baseinfo.PsnName,
  1716. // Idetinfo: idetinfoStr,
  1717. // Insuinfo: infoStr,
  1718. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1719. // CardInfo: card_info,
  1720. // VerifyNumber: token,
  1721. // }
  1722. // service.CreateHisPsn(psn)
  1723. // var rf []*ResultFive
  1724. // json.Unmarshal([]byte(infoStr), &rf)
  1725. // var insutypes []*ResultFive
  1726. // var insutype string
  1727. // var is390 int = 0
  1728. // var is310 int = 0
  1729. //
  1730. // for _, item := range rf {
  1731. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1732. // insutypes = append(insutypes, item)
  1733. // }
  1734. // }
  1735. //
  1736. // if len(insutypes) == 1 {
  1737. // insutype = insutypes[0].Insutype
  1738. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1739. // } else {
  1740. // for _, i := range insutypes {
  1741. // if i.Insutype == "390" {
  1742. // is390 = 1
  1743. // }
  1744. //
  1745. // if i.Insutype == "310" {
  1746. // is310 = 1
  1747. // }
  1748. // }
  1749. // }
  1750. //
  1751. // if is390 == 1 {
  1752. // insutype = "390"
  1753. // }
  1754. //
  1755. // if is310 == 1 {
  1756. // insutype = "310"
  1757. // }
  1758. //
  1759. // if len(insutypes) == 0 {
  1760. // insutype = "310"
  1761. // }
  1762. // c.ServeSuccessJSON(map[string]interface{}{
  1763. // "patient": patient,
  1764. // "number": token,
  1765. // "insutype": insutype,
  1766. // })
  1767. // }
  1768. // }
  1769. // } else {
  1770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1771. // return
  1772. // }
  1773. // } else { //读卡失败
  1774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1775. // return
  1776. //
  1777. // }
  1778. //
  1779. // }
  1780. //
  1781. // break
  1782. // case 4:
  1783. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1784. // var api string
  1785. // if miConfig.MdtrtareaAdmvs == "320921" {
  1786. // api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1787. // "&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
  1788. // fmt.Println(api)
  1789. //
  1790. // } else {
  1791. // 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 +
  1792. // "&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)
  1793. // }
  1794. //
  1795. // resp, requestErr := http.Get(api)
  1796. // if requestErr != nil {
  1797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1798. // return
  1799. // }
  1800. //
  1801. // body, ioErr := ioutil.ReadAll(resp.Body)
  1802. // if ioErr != nil {
  1803. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1805. // return
  1806. // }
  1807. // var respJSON map[string]interface{}
  1808. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1809. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. // return
  1812. // }
  1813. // var status string
  1814. // status = respJSON["data"].(map[string]interface{})["status"].(string)
  1815. // //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1816. //
  1817. // var token string
  1818. // var res ResultTwo //1101结果
  1819. // var res10265 ResultTwo10265 //1101结果
  1820. //
  1821. // if status == "0" { //读卡成功
  1822. // var card_info string //卡信息
  1823. // var busi_card_info string
  1824. //
  1825. // token = respJSON["data"].(map[string]interface{})["token"].(string)
  1826. // busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1827. // card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1828. //
  1829. // fmt.Println(card_info)
  1830. // fmt.Println(busi_card_info)
  1831. //
  1832. // respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1833. // result, _ := json.Marshal(respJSON)
  1834. //
  1835. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1836. // utils.ErrorLog("解析失败:%v", err)
  1837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. // return
  1839. // }
  1840. // res.ErrMsg = res10265.ErrMsg
  1841. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1842. // res.Infcode = infocode
  1843. // res.Output = res10265.Output
  1844. // res.InfRefmsgid = res10265.InfRefmsgid
  1845. //
  1846. // if res.Infcode == 0 {
  1847. // patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1848. // if err == gorm.ErrRecordNotFound {
  1849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1850. // return
  1851. // } else if err != nil {
  1852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1853. // return
  1854. //
  1855. // } else {
  1856. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1857. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1858. // infoStr := string(Iinfos)
  1859. // idetinfoStr := string(Idetinfos)
  1860. // psn := &models.HisPsn{
  1861. // PsnNo: res.Output.Baseinfo.PsnNo,
  1862. // Age: res.Output.Baseinfo.Age,
  1863. // PatientId: patient.ID,
  1864. // Certno: res.Output.Baseinfo.Certno,
  1865. // Brdy: res.Output.Baseinfo.Brdy,
  1866. // Gend: res.Output.Baseinfo.Gend,
  1867. // Naty: res.Output.Baseinfo.Naty,
  1868. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  1869. // PsnName: res.Output.Baseinfo.PsnName,
  1870. // Idetinfo: idetinfoStr,
  1871. // Insuinfo: infoStr,
  1872. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1873. // CardInfo: card_info,
  1874. // VerifyNumber: token,
  1875. // }
  1876. // service.CreateHisPsn(psn)
  1877. // c.ServeSuccessJSON(map[string]interface{}{
  1878. // "patient": patient,
  1879. // "number": token,
  1880. // })
  1881. // }
  1882. // } else {
  1883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1884. // return
  1885. // }
  1886. // } else { //读卡失败
  1887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1888. // return
  1889. // }
  1890. // }
  1891. // break
  1892. // }
  1893. //}
  1894. var initFlag int64 = 0
  1895. //func (c *HisApiController) TestGetBasBaseInit() {
  1896. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1897. // Iinit := DllDef.MustFindProc("Init")
  1898. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1899. //
  1900. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1901. // if ret != 0 {
  1902. // fmt.Println("SSCard的报错原因:", err)
  1903. // fmt.Println("SSCard的运算结果为:", ret)
  1904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1905. // return
  1906. // }
  1907. //
  1908. // result := int(ret)
  1909. // fmt.Println("SSCard的运算结果为1:", result)
  1910. // initFlag = 1
  1911. // return
  1912. //}
  1913. //func (c *HisApiController) GetSFZBaseInfo() string {
  1914. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1915. // readCard := DllDef.MustFindProc("ReadSFZ")
  1916. // if readCard == nil {
  1917. // fmt.Println("readcard is nil")
  1918. // readCard = DllDef.MustFindProc("ReadSFZ")
  1919. // }
  1920. //
  1921. // str := make([]byte, 256)
  1922. // str1 := make([]byte, 256)
  1923. // r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1924. //
  1925. // fmt.Println(r)
  1926. // return string(str)
  1927. //}
  1928. //func (c *HisApiController) GetBasBaseInfo() string {
  1929. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1930. // readCard := DllDef.MustFindProc("ReadCardBas")
  1931. // if readCard == nil {
  1932. // fmt.Println("readcard is nil")
  1933. // readCard = DllDef.MustFindProc("ReadCardBas")
  1934. // }
  1935. // str := make([]byte, 1024)
  1936. // str1 := make([]byte, 1024)
  1937. // ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1938. // fmt.Println(string(str1))
  1939. // fmt.Println(string(str))
  1940. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1941. // fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1942. // if ret2 != 0 {
  1943. // return ""
  1944. // }
  1945. // return string(str)
  1946. //}
  1947. type CustomFundPay struct {
  1948. FundPayType string `json:"fund_pay_type"`
  1949. FundPayamt float64 `json:"fund_payamt"`
  1950. }
  1951. func (c *HisApiController) GetSettleList() {
  1952. order_id, _ := c.GetInt64("order_id")
  1953. admin_user_id, _ := c.GetInt64("admin_user_id")
  1954. order, _ := service.GetHisOrderByIDTwo(order_id)
  1955. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1956. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1957. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1958. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1959. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1960. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1961. if order.ID == 0 {
  1962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1963. return
  1964. }
  1965. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1966. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1967. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1968. fmt.Println(count)
  1969. var zero string
  1970. number := count + 1
  1971. if number >= 1000 {
  1972. zero = "0000" + strconv.FormatInt(number, 10)
  1973. } else if number >= 10000 {
  1974. zero = "000" + strconv.FormatInt(number, 10)
  1975. } else if number >= 100000 {
  1976. zero = "00" + strconv.FormatInt(number, 10)
  1977. } else if number >= 1000000 {
  1978. zero = "0" + strconv.FormatInt(number, 10)
  1979. } else {
  1980. zero = strconv.FormatInt(number, 10)
  1981. }
  1982. fmt.Println(zero)
  1983. struct4101 := service.Struct4101{
  1984. PsnNo: order.PsnNo,
  1985. MdtrtId: order.MdtrtId,
  1986. SetlId: order.SetlId,
  1987. PsnName: order.PsnName,
  1988. Gend: order.Gend,
  1989. Brdy: his.Brdy,
  1990. Age: his.Age,
  1991. Naty: order.Naty,
  1992. PatnCertType: "01",
  1993. Certno: order.Certno,
  1994. Prfs: "90",
  1995. ConerName: roles[0].UserName,
  1996. PatnRlts: "99",
  1997. ConerAddr: miConfig.OrgName,
  1998. ConerTel: admin.Mobile,
  1999. HiType: order.Insutype,
  2000. Insuplc: miConfig.InsuplcAdmdvs,
  2001. MaindiagFlag: "1",
  2002. BillCode: last_order.FaPiaoCode,
  2003. BillNo: zero,
  2004. BizSn: order.Number,
  2005. PsnSelfPay: order.PsnPartAmt,
  2006. PsnOwnPay: order.PsnPartAmt,
  2007. AcctPay: order.AcctPay,
  2008. PsnCashpay: order.PsnCashPay,
  2009. HiPaymtd: "1",
  2010. Hsorg: miConfig.InsuplcAdmdvs,
  2011. HsorgOpter: miConfig.InsuplcAdmdvs,
  2012. MedinsFillPsn: curRoles.UserName,
  2013. MedinsFillDept: depart.Name,
  2014. IptMedType: "2",
  2015. }
  2016. struct4101.SetlBegnDate = order.SetlTime
  2017. struct4101.SetlEndDate = order.SetlTime
  2018. time_arr := strings.Split(order.SetlTime, " ")
  2019. struct4101.AdmTime = time_arr[0]
  2020. struct4101.AdmEndTime = time_arr[0]
  2021. var rf []CustomFundPay
  2022. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2023. var tempFunPays []service.CustomStruct
  2024. for _, item := range rf {
  2025. var tempFunPay service.CustomStruct
  2026. // v1, _ := strconv.ParseFloat(item.FundPayamt, 64)
  2027. tempFunPay.FundPayamt = item.FundPayamt
  2028. tempFunPay.FundPayType = item.FundPayType
  2029. tempFunPays = append(tempFunPays, tempFunPay)
  2030. }
  2031. struct4101.CustomStruct = tempFunPays
  2032. fmt.Println("111111111")
  2033. fmt.Println(tempFunPays)
  2034. fmt.Println(struct4101.CustomStruct)
  2035. var tempDiaginfos []service.DiaginfoStructTwo
  2036. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2037. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2038. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2039. var config []*models.HisXtDiagnoseConfig
  2040. for _, item := range diagnosis_ids {
  2041. id, _ := strconv.ParseInt(item, 10, 64)
  2042. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2043. config = append(config, &diagnosisConfig)
  2044. }
  2045. for index, item := range config {
  2046. if index == 0 {
  2047. var tempDiaginfo service.DiaginfoStructTwo
  2048. tempDiaginfo.DiagCode = item.CountryCode
  2049. tempDiaginfo.DiagName = item.CountryContentName
  2050. tempDiaginfo.DiagType = "1"
  2051. tempDiaginfo.MaindiagFlag = "1"
  2052. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2053. } else {
  2054. var tempDiaginfo service.DiaginfoStructTwo
  2055. tempDiaginfo.DiagCode = item.CountryCode
  2056. tempDiaginfo.DiagName = item.CountryContentName
  2057. tempDiaginfo.DiagType = "2"
  2058. tempDiaginfo.MaindiagFlag = "0"
  2059. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2060. }
  2061. }
  2062. struct4101.Diseinfo = tempDiaginfos
  2063. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2064. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2065. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2066. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2067. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2068. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2069. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2070. var iteminfo service.IteminfoStruct
  2071. var bedCostTotal float64 = 0 //床位总费
  2072. var bedCostSelfTotal float64 = 0 //床位自费
  2073. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2074. var operationCostTotal float64 = 0 //手术费
  2075. var operationCostSelfTotal float64 = 0 //手术费
  2076. var operationCostPartSelfTotal float64 = 0 //手术费
  2077. var otherCostTotal float64 = 0 //其他费用
  2078. var otherCostSelfTotal float64 = 0 //其他费用
  2079. var otherCostPartSelfTotal float64 = 0 //其他费用
  2080. var materialCostTotal float64 = 0 //材料费
  2081. var materialCostSelfTotal float64 = 0 //材料费
  2082. var materialCostPartSelfTotal float64 = 0 //材料费
  2083. var westernMedicineCostTotal float64 = 0 //西药费
  2084. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2085. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2086. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2087. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2088. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2089. var checkCostTotal float64 = 0 //检查费
  2090. var checkCostSelfTotal float64 = 0 //检查费
  2091. var checkCostPartSelfTotal float64 = 0 //检查费
  2092. var laboratoryCostTotal float64 = 0 //化验费
  2093. var laboratoryCostSelfTotal float64 = 0 //化验费
  2094. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2095. var treatCostTotal float64 = 0 //治疗费用
  2096. var treatCostSelfTotal float64 = 0 //治疗费用
  2097. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2098. decimal.DivisionPrecision = 2
  2099. var bed_fulamt_ownpay_amt float64 = 0
  2100. var operation_fulamt_ownpay_amt float64 = 0
  2101. var other_fulamt_ownpay_amt float64 = 0
  2102. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2103. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2104. var check_fulamt_ownpay_amt float64 = 0
  2105. var material_fulamt_ownpay_amt float64 = 0
  2106. var laboratory_fulamt_ownpay_amt float64 = 0
  2107. var treat_fulamt_ownpay_amt float64 = 0
  2108. var bed_claa_sunmfee float64 = 0
  2109. var bed_clab_amt float64 = 0
  2110. var bed_other_amt float64 = 0
  2111. var operation_claa_sunmfee float64 = 0
  2112. var operation_clab_amt float64 = 0
  2113. var operation_other_amt float64 = 0
  2114. var other_claa_sunmfee float64 = 0
  2115. var other_clab_amt float64 = 0
  2116. var other_other_amt float64 = 0
  2117. var westernMedicine_claa_sunmfee float64 = 0
  2118. var westernMedicine_clab_amt float64 = 0
  2119. var westernMedicine_other_amt float64 = 0
  2120. var chineseTraditional_claa_sunmfee float64 = 0
  2121. var chineseTraditional_clab_amt float64 = 0
  2122. var chineseTraditional_other_amt float64 = 0
  2123. var check_claa_sunmfee float64 = 0
  2124. var check_clab_amt float64 = 0
  2125. var check_other_amt float64 = 0
  2126. var material_claa_sunmfee float64 = 0
  2127. var material_clab_amt float64 = 0
  2128. var material_other_amt float64 = 0
  2129. var laboratory_claa_sunmfee float64 = 0
  2130. var laboratory_clab_amt float64 = 0
  2131. var laboratory_other_amt float64 = 0
  2132. var treat_claa_sunmfee float64 = 0
  2133. var treat_clab_amt float64 = 0
  2134. var treat_other_amt float64 = 0
  2135. for _, item := range order.HisOrderInfo {
  2136. if item.MedChrgitmType == "01" { //床位费
  2137. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2138. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2139. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2141. if item.ChrgitmLv == "1" {
  2142. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2143. }
  2144. if item.ChrgitmLv == "2" {
  2145. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2146. }
  2147. if item.ChrgitmLv == "3" {
  2148. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2149. }
  2150. }
  2151. if item.MedChrgitmType == "03" { //检查费
  2152. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2153. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2154. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2155. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2156. if item.ChrgitmLv == "1" {
  2157. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2158. }
  2159. if item.ChrgitmLv == "2" {
  2160. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2161. }
  2162. if item.ChrgitmLv == "3" {
  2163. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2164. }
  2165. }
  2166. if item.MedChrgitmType == "04" { //化验费
  2167. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2168. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2169. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2171. if item.ChrgitmLv == "1" {
  2172. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2173. }
  2174. if item.ChrgitmLv == "2" {
  2175. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2176. }
  2177. if item.ChrgitmLv == "3" {
  2178. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2179. }
  2180. }
  2181. if item.MedChrgitmType == "05" { //治疗费
  2182. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2183. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2184. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2186. if item.ChrgitmLv == "1" {
  2187. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2188. }
  2189. if item.ChrgitmLv == "2" {
  2190. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2191. }
  2192. if item.ChrgitmLv == "3" {
  2193. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2194. }
  2195. }
  2196. if item.MedChrgitmType == "06" { //手术费
  2197. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2198. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2199. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2200. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2201. if item.ChrgitmLv == "1" {
  2202. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2203. }
  2204. if item.ChrgitmLv == "2" {
  2205. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2206. }
  2207. if item.ChrgitmLv == "3" {
  2208. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2209. }
  2210. }
  2211. if item.MedChrgitmType == "08" { //材料费
  2212. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2213. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2214. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2215. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2216. if item.ChrgitmLv == "1" {
  2217. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2218. }
  2219. if item.ChrgitmLv == "2" {
  2220. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2221. }
  2222. if item.ChrgitmLv == "3" {
  2223. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2224. }
  2225. }
  2226. if item.MedChrgitmType == "09" { //西药费
  2227. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2228. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2229. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2230. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2231. if item.ChrgitmLv == "1" {
  2232. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2233. }
  2234. if item.ChrgitmLv == "2" {
  2235. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2236. }
  2237. if item.ChrgitmLv == "3" {
  2238. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2239. }
  2240. }
  2241. if item.MedChrgitmType == "11" { //中成费
  2242. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2243. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2244. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2245. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2246. if item.ChrgitmLv == "1" {
  2247. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2248. }
  2249. if item.ChrgitmLv == "2" {
  2250. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2251. }
  2252. if item.ChrgitmLv == "3" {
  2253. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2254. }
  2255. }
  2256. if item.MedChrgitmType == "14" { //其他费
  2257. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2258. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2259. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2260. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2261. if item.ChrgitmLv == "1" {
  2262. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2263. }
  2264. if item.ChrgitmLv == "2" {
  2265. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2266. }
  2267. if item.ChrgitmLv == "3" {
  2268. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2269. }
  2270. }
  2271. }
  2272. var iteminfoStructs []service.IteminfoStruct
  2273. if bedCostTotal != 0 {
  2274. iteminfo.MedChrgitm = "01"
  2275. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2276. iteminfo.Amt = bedCostTotal
  2277. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2278. iteminfo.ClabAmt = bed_clab_amt
  2279. iteminfo.OthAmt = bed_other_amt
  2280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2281. }
  2282. if checkCostTotal != 0 {
  2283. iteminfo.MedChrgitm = "03"
  2284. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2285. iteminfo.Amt = checkCostTotal
  2286. iteminfo.ClaaSumfee = check_claa_sunmfee
  2287. iteminfo.ClabAmt = check_clab_amt
  2288. iteminfo.OthAmt = check_other_amt
  2289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2290. }
  2291. if laboratoryCostTotal != 0 {
  2292. iteminfo.MedChrgitm = "04"
  2293. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2294. iteminfo.Amt = laboratoryCostTotal
  2295. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2296. iteminfo.ClabAmt = laboratory_clab_amt
  2297. iteminfo.OthAmt = laboratory_other_amt
  2298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2299. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2300. }
  2301. if treatCostTotal != 0 {
  2302. iteminfo.MedChrgitm = "05"
  2303. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2304. iteminfo.Amt = treatCostTotal
  2305. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2306. iteminfo.ClabAmt = treat_clab_amt
  2307. iteminfo.OthAmt = treat_other_amt
  2308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2309. //(struct4101.IteminfoStruct, iteminfo)
  2310. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2311. }
  2312. if operationCostTotal != 0 {
  2313. iteminfo.MedChrgitm = "06"
  2314. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2315. iteminfo.Amt = operationCostTotal
  2316. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2317. iteminfo.ClabAmt = operation_clab_amt
  2318. iteminfo.OthAmt = operation_other_amt
  2319. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2321. }
  2322. if materialCostTotal != 0 {
  2323. iteminfo.MedChrgitm = "08"
  2324. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2325. iteminfo.Amt = materialCostTotal
  2326. iteminfo.ClaaSumfee = material_claa_sunmfee
  2327. iteminfo.ClabAmt = material_clab_amt
  2328. iteminfo.OthAmt = material_other_amt
  2329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2331. }
  2332. if westernMedicineCostTotal != 0 {
  2333. iteminfo.MedChrgitm = "09"
  2334. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2335. iteminfo.Amt = westernMedicineCostTotal
  2336. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2337. iteminfo.ClabAmt = westernMedicine_clab_amt
  2338. iteminfo.OthAmt = westernMedicine_other_amt
  2339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2340. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2341. }
  2342. if chineseTraditionalMedicineCostTotal != 0 {
  2343. iteminfo.MedChrgitm = "11"
  2344. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2345. iteminfo.Amt = westernMedicineCostTotal
  2346. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2347. iteminfo.ClabAmt = westernMedicine_clab_amt
  2348. iteminfo.OthAmt = westernMedicine_other_amt
  2349. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2351. }
  2352. if otherCostTotal != 0 {
  2353. iteminfo.MedChrgitm = "14"
  2354. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2355. iteminfo.Amt = otherCostTotal
  2356. iteminfo.ClaaSumfee = other_claa_sunmfee
  2357. iteminfo.ClabAmt = other_clab_amt
  2358. iteminfo.OthAmt = other_other_amt
  2359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2361. }
  2362. struct4101.IteminfoStruct = iteminfoStructs
  2363. struct4101.Ntly = "中国"
  2364. struct4101.AdmCaty = "A03.06"
  2365. var res ResultSeventeen
  2366. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2367. var resOther ResultSeventeenOther
  2368. var pp models.PublicParams
  2369. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2370. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2371. pp.FixmedinsName = miConfig.OrgName
  2372. pp.FixmedinsCode = miConfig.Code
  2373. pp.RequestUrl = miConfig.Url
  2374. pp.Cainfo = miConfig.Cainfo
  2375. pp.SecretKey = miConfig.SecretKey
  2376. pp.AccessKey = miConfig.AccessKey
  2377. pp.OpterName = curRoles.UserName
  2378. client := &http.Client{}
  2379. var req *http.Request
  2380. data := make(map[string]interface{})
  2381. data["struct4101"] = struct4101
  2382. data["pp"] = pp
  2383. bytesData, _ := json.Marshal(data)
  2384. if miConfig.MdtrtareaAdmvs == "320921" {
  2385. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2386. } else {
  2387. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2388. }
  2389. resp, _ := client.Do(req)
  2390. defer resp.Body.Close()
  2391. body, ioErr := ioutil.ReadAll(resp.Body)
  2392. if ioErr != nil {
  2393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. var respJSON map[string]interface{}
  2398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2401. return
  2402. }
  2403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2404. userJSONBytes, _ := json.Marshal(respJSON)
  2405. fmt.Println("log")
  2406. fmt.Println(string(userJSONBytes))
  2407. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2408. utils.ErrorLog("解析失败:%v", err)
  2409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2410. return
  2411. }
  2412. res.InfRefmsgid = resOther.InfRefmsgid
  2413. res.Output = resOther.Output
  2414. res.ErrMsg = resOther.ErrMsg
  2415. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2416. res.Infcode = infocode
  2417. } else {
  2418. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2419. var dat map[string]interface{}
  2420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2421. fmt.Println(dat)
  2422. } else {
  2423. fmt.Println(err)
  2424. }
  2425. userJSONBytes, _ := json.Marshal(dat)
  2426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2427. utils.ErrorLog("解析失败:%v", err)
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2429. return
  2430. }
  2431. }
  2432. if res.Infcode != 0 {
  2433. c.ServeSuccessJSON(map[string]interface{}{
  2434. "failed_code": -10,
  2435. "msg": res.ErrMsg,
  2436. })
  2437. return
  2438. } else {
  2439. order.FaPiaoNumber = zero
  2440. order.FaPiaoCode = last_order.FaPiaoCode
  2441. service.UpdateOrder(order)
  2442. hisFundSettleListResult := &models.HisFundSettleListResult{
  2443. Number: res.Output.SetlListId,
  2444. Status: 1,
  2445. Ctime: time.Now().Unix(),
  2446. Mtime: time.Now().Unix(),
  2447. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2448. IsUpload: 1,
  2449. OrderId: order_id,
  2450. }
  2451. service.CreateUploadRecord(hisFundSettleListResult)
  2452. c.ServeSuccessJSON(map[string]interface{}{
  2453. "msg": "上传成功",
  2454. "result": hisFundSettleListResult,
  2455. })
  2456. return
  2457. }
  2458. }
  2459. func (c *HisApiController) GetSettleListHospital() {
  2460. order_id, _ := c.GetInt64("order_id")
  2461. admin_user_id, _ := c.GetInt64("admin_user_id")
  2462. order, _ := service.GetHisOrderByIDTwo(order_id)
  2463. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2464. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2465. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2466. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2467. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2469. if order.ID == 0 {
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2471. return
  2472. }
  2473. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2474. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2475. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2476. fmt.Println(count)
  2477. var zero string
  2478. number := count + 1
  2479. if number >= 1000 {
  2480. zero = "0000" + strconv.FormatInt(number, 10)
  2481. } else if number >= 10000 {
  2482. zero = "000" + strconv.FormatInt(number, 10)
  2483. } else if number >= 100000 {
  2484. zero = "00" + strconv.FormatInt(number, 10)
  2485. } else if number >= 1000000 {
  2486. zero = "0" + strconv.FormatInt(number, 10)
  2487. } else {
  2488. zero = strconv.FormatInt(number, 10)
  2489. }
  2490. fmt.Println(zero)
  2491. struct4101 := service.Struct4101{
  2492. PsnNo: order.PsnNo,
  2493. MdtrtId: order.MdtrtId,
  2494. SetlId: order.SetlId,
  2495. PsnName: order.PsnName,
  2496. Gend: order.Gend,
  2497. Brdy: his.Brdy,
  2498. Age: int64(order.Age),
  2499. Naty: order.Naty,
  2500. PatnCertType: "01",
  2501. Certno: order.Certno,
  2502. Prfs: "90",
  2503. ConerName: roles[0].UserName,
  2504. PatnRlts: "99",
  2505. ConerAddr: miConfig.OrgName,
  2506. ConerTel: admin.Mobile,
  2507. HiType: order.Insutype,
  2508. Insuplc: miConfig.InsuplcAdmdvs,
  2509. MaindiagFlag: "1",
  2510. BillCode: last_order.FaPiaoCode,
  2511. BillNo: zero,
  2512. BizSn: order.Number,
  2513. PsnSelfPay: order.PsnPartAmt,
  2514. PsnOwnPay: order.PsnPartAmt,
  2515. AcctPay: order.AcctPay,
  2516. PsnCashpay: order.PsnCashPay,
  2517. HiPaymtd: "1",
  2518. Hsorg: miConfig.InsuplcAdmdvs,
  2519. HsorgOpter: miConfig.InsuplcAdmdvs,
  2520. MedinsFillPsn: curRoles.UserName,
  2521. MedinsFillDept: depart.Name,
  2522. IptMedType: "2",
  2523. AdmTime: his.InHosptialTime,
  2524. AdmEndTime: his.OutHosptialTime,
  2525. }
  2526. struct4101.SetlBegnDate = order.SetlTime
  2527. struct4101.SetlEndDate = order.SetlTime
  2528. var rf []CustomFundPay
  2529. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2530. var tempFunPays []service.CustomStruct
  2531. for _, item := range rf {
  2532. var tempFunPay service.CustomStruct
  2533. tempFunPay.FundPayamt = item.FundPayamt
  2534. tempFunPay.FundPayType = item.FundPayType
  2535. tempFunPays = append(tempFunPays, tempFunPay)
  2536. }
  2537. fmt.Println("111111111")
  2538. fmt.Println(tempFunPays)
  2539. struct4101.CustomStruct = tempFunPays
  2540. fmt.Println(struct4101.CustomStruct)
  2541. var tempDiaginfos []service.DiaginfoStructTwo
  2542. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2543. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2544. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2545. var config []*models.HisXtDiagnoseConfig
  2546. for _, item := range diagnosis_ids {
  2547. id, _ := strconv.ParseInt(item, 10, 64)
  2548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2549. config = append(config, &diagnosisConfig)
  2550. }
  2551. for index, item := range config {
  2552. if index == 0 {
  2553. var tempDiaginfo service.DiaginfoStructTwo
  2554. tempDiaginfo.DiagCode = item.CountryCode
  2555. tempDiaginfo.DiagName = item.CountryContentName
  2556. tempDiaginfo.DiagType = "1"
  2557. tempDiaginfo.MaindiagFlag = "1"
  2558. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2559. } else {
  2560. var tempDiaginfo service.DiaginfoStructTwo
  2561. tempDiaginfo.DiagCode = item.CountryCode
  2562. tempDiaginfo.DiagName = item.CountryContentName
  2563. tempDiaginfo.DiagType = "2"
  2564. tempDiaginfo.MaindiagFlag = "0"
  2565. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2566. }
  2567. }
  2568. struct4101.Diseinfo = tempDiaginfos
  2569. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2570. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2571. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2572. tempOpspdiseinfo2.OprnOprtCode = ""
  2573. tempOpspdiseinfo2.OprnOprtName = ""
  2574. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2575. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2576. var iteminfo service.IteminfoStruct
  2577. var bedCostTotal float64 = 0 //床位总费
  2578. var bedCostSelfTotal float64 = 0 //床位自费
  2579. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2580. var operationCostTotal float64 = 0 //手术费
  2581. var operationCostSelfTotal float64 = 0 //手术费
  2582. var operationCostPartSelfTotal float64 = 0 //手术费
  2583. var otherCostTotal float64 = 0 //其他费用
  2584. var otherCostSelfTotal float64 = 0 //其他费用
  2585. var otherCostPartSelfTotal float64 = 0 //其他费用
  2586. var materialCostTotal float64 = 0 //材料费
  2587. var materialCostSelfTotal float64 = 0 //材料费
  2588. var materialCostPartSelfTotal float64 = 0 //材料费
  2589. var westernMedicineCostTotal float64 = 0 //西药费
  2590. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2591. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2592. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2593. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2594. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2595. var checkCostTotal float64 = 0 //检查费
  2596. var checkCostSelfTotal float64 = 0 //检查费
  2597. var checkCostPartSelfTotal float64 = 0 //检查费
  2598. var laboratoryCostTotal float64 = 0 //化验费
  2599. var laboratoryCostSelfTotal float64 = 0 //化验费
  2600. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2601. var treatCostTotal float64 = 0 //治疗费用
  2602. var treatCostSelfTotal float64 = 0 //治疗费用
  2603. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2604. decimal.DivisionPrecision = 2
  2605. var bed_fulamt_ownpay_amt float64 = 0
  2606. var operation_fulamt_ownpay_amt float64 = 0
  2607. var other_fulamt_ownpay_amt float64 = 0
  2608. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2609. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2610. var check_fulamt_ownpay_amt float64 = 0
  2611. var material_fulamt_ownpay_amt float64 = 0
  2612. var laboratory_fulamt_ownpay_amt float64 = 0
  2613. var treat_fulamt_ownpay_amt float64 = 0
  2614. var bed_claa_sunmfee float64 = 0
  2615. var bed_clab_amt float64 = 0
  2616. var bed_other_amt float64 = 0
  2617. var operation_claa_sunmfee float64 = 0
  2618. var operation_clab_amt float64 = 0
  2619. var operation_other_amt float64 = 0
  2620. var other_claa_sunmfee float64 = 0
  2621. var other_clab_amt float64 = 0
  2622. var other_other_amt float64 = 0
  2623. var westernMedicine_claa_sunmfee float64 = 0
  2624. var westernMedicine_clab_amt float64 = 0
  2625. var westernMedicine_other_amt float64 = 0
  2626. var chineseTraditional_claa_sunmfee float64 = 0
  2627. var chineseTraditional_clab_amt float64 = 0
  2628. var chineseTraditional_other_amt float64 = 0
  2629. var check_claa_sunmfee float64 = 0
  2630. var check_clab_amt float64 = 0
  2631. var check_other_amt float64 = 0
  2632. var material_claa_sunmfee float64 = 0
  2633. var material_clab_amt float64 = 0
  2634. var material_other_amt float64 = 0
  2635. var laboratory_claa_sunmfee float64 = 0
  2636. var laboratory_clab_amt float64 = 0
  2637. var laboratory_other_amt float64 = 0
  2638. var treat_claa_sunmfee float64 = 0
  2639. var treat_clab_amt float64 = 0
  2640. var treat_other_amt float64 = 0
  2641. for _, item := range order.HisOrderInfo {
  2642. if item.MedChrgitmType == "01" { //床位费
  2643. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2644. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2645. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2646. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2647. if item.ChrgitmLv == "1" {
  2648. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2649. }
  2650. if item.ChrgitmLv == "2" {
  2651. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2652. }
  2653. if item.ChrgitmLv == "3" {
  2654. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2655. }
  2656. }
  2657. if item.MedChrgitmType == "03" { //检查费
  2658. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2659. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2660. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2661. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2662. if item.ChrgitmLv == "1" {
  2663. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2664. }
  2665. if item.ChrgitmLv == "2" {
  2666. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2667. }
  2668. if item.ChrgitmLv == "3" {
  2669. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2670. }
  2671. }
  2672. if item.MedChrgitmType == "04" { //化验费
  2673. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2674. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2675. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2676. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2677. if item.ChrgitmLv == "1" {
  2678. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2679. }
  2680. if item.ChrgitmLv == "2" {
  2681. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2682. }
  2683. if item.ChrgitmLv == "3" {
  2684. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2685. }
  2686. }
  2687. if item.MedChrgitmType == "05" { //治疗费
  2688. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2689. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2690. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2691. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2692. if item.ChrgitmLv == "1" {
  2693. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2694. }
  2695. if item.ChrgitmLv == "2" {
  2696. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2697. }
  2698. if item.ChrgitmLv == "3" {
  2699. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2700. }
  2701. }
  2702. if item.MedChrgitmType == "06" { //手术费
  2703. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2704. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2705. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2706. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2707. if item.ChrgitmLv == "1" {
  2708. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2709. }
  2710. if item.ChrgitmLv == "2" {
  2711. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2712. }
  2713. if item.ChrgitmLv == "3" {
  2714. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2715. }
  2716. }
  2717. if item.MedChrgitmType == "08" { //材料费
  2718. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2719. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2720. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2721. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2722. if item.ChrgitmLv == "1" {
  2723. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2724. }
  2725. if item.ChrgitmLv == "2" {
  2726. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2727. }
  2728. if item.ChrgitmLv == "3" {
  2729. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2730. }
  2731. }
  2732. if item.MedChrgitmType == "09" { //西药费
  2733. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2734. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2735. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2736. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2737. if item.ChrgitmLv == "1" {
  2738. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2739. }
  2740. if item.ChrgitmLv == "2" {
  2741. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2742. }
  2743. if item.ChrgitmLv == "3" {
  2744. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2745. }
  2746. }
  2747. if item.MedChrgitmType == "11" { //中成费
  2748. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2749. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2750. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2751. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2752. if item.ChrgitmLv == "1" {
  2753. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2754. }
  2755. if item.ChrgitmLv == "2" {
  2756. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2757. }
  2758. if item.ChrgitmLv == "3" {
  2759. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2760. }
  2761. }
  2762. if item.MedChrgitmType == "14" { //其他费
  2763. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2764. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2765. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2766. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2767. if item.ChrgitmLv == "1" {
  2768. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2769. }
  2770. if item.ChrgitmLv == "2" {
  2771. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2772. }
  2773. if item.ChrgitmLv == "3" {
  2774. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2775. }
  2776. }
  2777. }
  2778. var iteminfoStructs []service.IteminfoStruct
  2779. if bedCostTotal != 0 {
  2780. iteminfo.MedChrgitm = "01"
  2781. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2782. iteminfo.Amt = bedCostTotal
  2783. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2784. iteminfo.ClabAmt = bed_clab_amt
  2785. iteminfo.OthAmt = bed_other_amt
  2786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2787. }
  2788. if checkCostTotal != 0 {
  2789. iteminfo.MedChrgitm = "03"
  2790. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2791. iteminfo.Amt = checkCostTotal
  2792. iteminfo.ClaaSumfee = check_claa_sunmfee
  2793. iteminfo.ClabAmt = check_clab_amt
  2794. iteminfo.OthAmt = check_other_amt
  2795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2796. }
  2797. if laboratoryCostTotal != 0 {
  2798. iteminfo.MedChrgitm = "04"
  2799. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2800. iteminfo.Amt = laboratoryCostTotal
  2801. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2802. iteminfo.ClabAmt = laboratory_clab_amt
  2803. iteminfo.OthAmt = laboratory_other_amt
  2804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2805. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2806. }
  2807. if treatCostTotal != 0 {
  2808. iteminfo.MedChrgitm = "05"
  2809. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2810. iteminfo.Amt = treatCostTotal
  2811. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2812. iteminfo.ClabAmt = treat_clab_amt
  2813. iteminfo.OthAmt = treat_other_amt
  2814. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2815. //(struct4101.IteminfoStruct, iteminfo)
  2816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2817. }
  2818. if operationCostTotal != 0 {
  2819. iteminfo.MedChrgitm = "06"
  2820. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2821. iteminfo.Amt = operationCostTotal
  2822. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2823. iteminfo.ClabAmt = operation_clab_amt
  2824. iteminfo.OthAmt = operation_other_amt
  2825. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2826. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2827. }
  2828. if materialCostTotal != 0 {
  2829. iteminfo.MedChrgitm = "08"
  2830. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2831. iteminfo.Amt = materialCostTotal
  2832. iteminfo.ClaaSumfee = material_claa_sunmfee
  2833. iteminfo.ClabAmt = material_clab_amt
  2834. iteminfo.OthAmt = material_other_amt
  2835. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2836. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2837. }
  2838. if westernMedicineCostTotal != 0 {
  2839. iteminfo.MedChrgitm = "09"
  2840. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2841. iteminfo.Amt = westernMedicineCostTotal
  2842. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2843. iteminfo.ClabAmt = westernMedicine_clab_amt
  2844. iteminfo.OthAmt = westernMedicine_other_amt
  2845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2847. }
  2848. if chineseTraditionalMedicineCostTotal != 0 {
  2849. iteminfo.MedChrgitm = "11"
  2850. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2851. iteminfo.Amt = westernMedicineCostTotal
  2852. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2853. iteminfo.ClabAmt = westernMedicine_clab_amt
  2854. iteminfo.OthAmt = westernMedicine_other_amt
  2855. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2857. }
  2858. if otherCostTotal != 0 {
  2859. iteminfo.MedChrgitm = "14"
  2860. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2861. iteminfo.Amt = otherCostTotal
  2862. iteminfo.ClaaSumfee = other_claa_sunmfee
  2863. iteminfo.ClabAmt = other_clab_amt
  2864. iteminfo.OthAmt = other_other_amt
  2865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2867. }
  2868. struct4101.IteminfoStruct = iteminfoStructs
  2869. struct4101.Ntly = "中国"
  2870. struct4101.AdmCaty = "A03.06"
  2871. fmt.Println("111111111")
  2872. fmt.Println(tempFunPays)
  2873. struct4101.CustomStruct = tempFunPays
  2874. fmt.Println(struct4101.CustomStruct)
  2875. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2876. fmt.Println(result)
  2877. var dat map[string]interface{}
  2878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2879. fmt.Println(dat)
  2880. } else {
  2881. fmt.Println(err)
  2882. }
  2883. userJSONBytes, _ := json.Marshal(dat)
  2884. var res ResultSeventeen
  2885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2886. utils.ErrorLog("解析失败:%v", err)
  2887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2888. return
  2889. }
  2890. if res.Infcode != 0 {
  2891. c.ServeSuccessJSON(map[string]interface{}{
  2892. "failed_code": -10,
  2893. "msg": res.ErrMsg,
  2894. })
  2895. return
  2896. } else {
  2897. order.FaPiaoNumber = zero
  2898. order.FaPiaoCode = last_order.FaPiaoCode
  2899. service.UpdateOrder(order)
  2900. hisFundSettleListResult := &models.HisFundSettleListResult{
  2901. Number: res.Output.SetlListId,
  2902. Status: 1,
  2903. Ctime: time.Now().Unix(),
  2904. Mtime: time.Now().Unix(),
  2905. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2906. IsUpload: 1,
  2907. OrderId: order_id,
  2908. }
  2909. service.CreateUploadRecord(hisFundSettleListResult)
  2910. c.ServeSuccessJSON(map[string]interface{}{
  2911. "msg": "上传成功",
  2912. "result": hisFundSettleListResult,
  2913. })
  2914. return
  2915. }
  2916. }
  2917. func (c *HisApiController) GetBatchSettleList() {
  2918. orders, _ := service.GetAllHisOrder(10106)
  2919. for _, item := range orders {
  2920. order_id := item.ID
  2921. order, _ := service.GetHisOrderByIDTwo(order_id)
  2922. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2923. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2924. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2925. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2926. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2927. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2928. if order.ID == 0 {
  2929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2930. return
  2931. }
  2932. if his.BalanceAccountsType == 2 {
  2933. continue
  2934. }
  2935. struct4101 := service.Struct4101{
  2936. PsnNo: order.PsnNo,
  2937. MdtrtId: order.MdtrtId,
  2938. SetlId: order.SetlId,
  2939. PsnName: order.PsnName,
  2940. Gend: order.Gend,
  2941. Brdy: his.Brdy,
  2942. Age: his.Age,
  2943. Naty: order.Naty,
  2944. PatnCertType: "01",
  2945. Certno: order.Certno,
  2946. Prfs: "90",
  2947. ConerName: roles[0].UserName,
  2948. PatnRlts: "99",
  2949. ConerAddr: miConfig.OrgName,
  2950. ConerTel: admin.Mobile,
  2951. HiType: order.Insutype,
  2952. Insuplc: his.InsuplcAdmdvs,
  2953. MaindiagFlag: "1",
  2954. BillCode: order.FaPiaoCode,
  2955. BillNo: order.FaPiaoNumber,
  2956. BizSn: order.Number,
  2957. PsnSelfPay: order.PsnPartAmt,
  2958. PsnOwnPay: order.PsnPartAmt,
  2959. AcctPay: order.AcctPay,
  2960. PsnCashpay: order.PsnCashPay,
  2961. HiPaymtd: "1",
  2962. Hsorg: his.InsuplcAdmdvs,
  2963. HsorgOpter: his.InsuplcAdmdvs,
  2964. MedinsFillPsn: curRoles.UserName,
  2965. MedinsFillDept: depart.Name,
  2966. IptMedType: "2",
  2967. }
  2968. struct4101.SetlBegnDate = order.SetlTime
  2969. struct4101.SetlEndDate = order.SetlTime
  2970. //if order.SettleType == 1 {
  2971. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2972. // dateStr := t.Format("2006-01-02")
  2973. // struct4101.SetlBegnDate = dateStr
  2974. // struct4101.SetlEndDate = dateStr
  2975. //} else {
  2976. // t := time.Unix(int64(order.SettleStartTime), 0)
  2977. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2978. // dateStartStr := t.Format("2006-01-02")
  2979. // dateEndStr := t2.Format("2006-01-02")
  2980. // struct4101.SetlBegnDate = dateStartStr
  2981. // struct4101.SetlEndDate = dateEndStr
  2982. //}
  2983. var rf []CustomFundPay
  2984. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2985. var tempFunPays []service.CustomStruct
  2986. var tempFunPay610100 service.CustomStruct
  2987. for _, item := range rf {
  2988. if item.FundPayType == "610100" {
  2989. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2990. tempFunPay610100.FundPayType = item.FundPayType
  2991. } else {
  2992. var tempFunPay service.CustomStruct
  2993. tempFunPay.FundPayamt = item.FundPayamt
  2994. tempFunPay.FundPayType = item.FundPayType
  2995. tempFunPays = append(tempFunPays, tempFunPay)
  2996. }
  2997. }
  2998. tempFunPays = append(tempFunPays, tempFunPay610100)
  2999. struct4101.CustomStruct = tempFunPays
  3000. var tempDiaginfos []service.DiaginfoStructTwo
  3001. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3002. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3003. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3004. var config []*models.HisXtDiagnoseConfig
  3005. for _, item := range diagnosis_ids {
  3006. id, _ := strconv.ParseInt(item, 10, 64)
  3007. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3008. config = append(config, &diagnosisConfig)
  3009. }
  3010. for index, item := range config {
  3011. if index == 0 {
  3012. var tempDiaginfo service.DiaginfoStructTwo
  3013. tempDiaginfo.DiagCode = item.CountryCode
  3014. tempDiaginfo.DiagName = item.CountryContentName
  3015. tempDiaginfo.DiagType = "1"
  3016. tempDiaginfo.MaindiagFlag = "1"
  3017. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3018. } else {
  3019. var tempDiaginfo service.DiaginfoStructTwo
  3020. tempDiaginfo.DiagCode = item.CountryCode
  3021. tempDiaginfo.DiagName = item.CountryContentName
  3022. tempDiaginfo.DiagType = "2"
  3023. tempDiaginfo.MaindiagFlag = "0"
  3024. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3025. }
  3026. }
  3027. struct4101.Diseinfo = tempDiaginfos
  3028. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3029. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3030. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3031. tempOpspdiseinfo2.OprnOprtCode = ""
  3032. tempOpspdiseinfo2.OprnOprtName = ""
  3033. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3034. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3035. var iteminfo service.IteminfoStruct
  3036. var bedCostTotal float64 = 0 //床位总费
  3037. var bedCostSelfTotal float64 = 0 //床位自费
  3038. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3039. var examineCostTotal float64 = 0 //诊查总费
  3040. var examineCostSelfTotal float64 = 0 //诊查自费
  3041. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3042. var nursingCostTotal float64 = 0 //护理总费
  3043. var nursingCostSelfTotal float64 = 0 //护理自费
  3044. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3045. var chineseMedicineCostTotal float64 = 0 //中成药
  3046. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3047. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3048. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3049. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3050. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3051. var registerCostTotal float64 = 0 //一般诊疗费
  3052. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3053. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3054. var operationCostTotal float64 = 0 //手术费
  3055. var operationCostSelfTotal float64 = 0 //手术费
  3056. var operationCostPartSelfTotal float64 = 0 //手术费
  3057. var otherCostTotal float64 = 0 //其他费用
  3058. var otherCostSelfTotal float64 = 0 //其他费用
  3059. var otherCostPartSelfTotal float64 = 0 //其他费用
  3060. var materialCostTotal float64 = 0 //材料费
  3061. var materialCostSelfTotal float64 = 0 //材料费
  3062. var materialCostPartSelfTotal float64 = 0 //材料费
  3063. var westernMedicineCostTotal float64 = 0 //西药费
  3064. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3065. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3066. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3067. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3068. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3069. var checkCostTotal float64 = 0 //检查费
  3070. var checkCostSelfTotal float64 = 0 //检查费
  3071. var checkCostPartSelfTotal float64 = 0 //检查费
  3072. var laboratoryCostTotal float64 = 0 //化验费
  3073. var laboratoryCostSelfTotal float64 = 0 //化验费
  3074. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3075. var treatCostTotal float64 = 0 //治疗费用
  3076. var treatCostSelfTotal float64 = 0 //治疗费用
  3077. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3078. decimal.DivisionPrecision = 2
  3079. var bed_fulamt_ownpay_amt float64 = 0
  3080. var examine_fulamt_ownpay_amt float64 = 0
  3081. var nursing_fulamt_ownpay_amt float64 = 0
  3082. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3083. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3084. var register_fulamt_ownpay_amt float64 = 0
  3085. var operation_fulamt_ownpay_amt float64 = 0
  3086. var other_fulamt_ownpay_amt float64 = 0
  3087. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3088. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3089. var check_fulamt_ownpay_amt float64 = 0
  3090. var material_fulamt_ownpay_amt float64 = 0
  3091. var laboratory_fulamt_ownpay_amt float64 = 0
  3092. var treat_fulamt_ownpay_amt float64 = 0
  3093. var bed_claa_sunmfee float64 = 0
  3094. var bed_clab_amt float64 = 0
  3095. var bed_other_amt float64 = 0
  3096. var examine_claa_sunmfee float64 = 0
  3097. var examine_clab_amt float64 = 0
  3098. var examine_other_amt float64 = 0
  3099. var nursing_claa_sunmfee float64 = 0
  3100. var nursing_clab_amt float64 = 0
  3101. var nursing_other_amt float64 = 0
  3102. var chinese_medicine_claa_sunmfee float64 = 0
  3103. var chinese_medicine_clab_amt float64 = 0
  3104. var chinese_medicine_other_amt float64 = 0
  3105. var commonly_treatment_claa_sunmfee float64 = 0
  3106. var commonly_treatment_clab_amt float64 = 0
  3107. var commonly_treatment_other_amt float64 = 0
  3108. var operation_claa_sunmfee float64 = 0
  3109. var operation_clab_amt float64 = 0
  3110. var operation_other_amt float64 = 0
  3111. var other_claa_sunmfee float64 = 0
  3112. var other_clab_amt float64 = 0
  3113. var other_other_amt float64 = 0
  3114. var westernMedicine_claa_sunmfee float64 = 0
  3115. var westernMedicine_clab_amt float64 = 0
  3116. var westernMedicine_other_amt float64 = 0
  3117. var chineseTraditional_claa_sunmfee float64 = 0
  3118. var chineseTraditional_clab_amt float64 = 0
  3119. var chineseTraditional_other_amt float64 = 0
  3120. var check_claa_sunmfee float64 = 0
  3121. var check_clab_amt float64 = 0
  3122. var check_other_amt float64 = 0
  3123. var material_claa_sunmfee float64 = 0
  3124. var material_clab_amt float64 = 0
  3125. var material_other_amt float64 = 0
  3126. var laboratory_claa_sunmfee float64 = 0
  3127. var laboratory_clab_amt float64 = 0
  3128. var laboratory_other_amt float64 = 0
  3129. var treat_claa_sunmfee float64 = 0
  3130. var treat_clab_amt float64 = 0
  3131. var treat_other_amt float64 = 0
  3132. var register_claa_sunmfee float64 = 0
  3133. var register_clab_amt float64 = 0
  3134. var register_other_amt float64 = 0
  3135. for _, item := range order.HisOrderInfo {
  3136. if item.MedChrgitmType == "01" { //床位费
  3137. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3139. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3140. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3141. if item.ChrgitmLv == "1" {
  3142. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3143. }
  3144. if item.ChrgitmLv == "2" {
  3145. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "3" {
  3148. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. }
  3150. }
  3151. if item.MedChrgitmType == "02" { //诊查
  3152. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3154. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3155. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3156. if item.ChrgitmLv == "1" {
  3157. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3158. }
  3159. if item.ChrgitmLv == "2" {
  3160. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "3" {
  3163. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. }
  3165. }
  3166. if item.MedChrgitmType == "03" { //检查费
  3167. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3169. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3170. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3171. if item.ChrgitmLv == "1" {
  3172. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3173. }
  3174. if item.ChrgitmLv == "2" {
  3175. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "3" {
  3178. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3179. }
  3180. }
  3181. if item.MedChrgitmType == "04" { //化验费
  3182. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3183. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3184. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3185. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3186. if item.ChrgitmLv == "1" {
  3187. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3188. }
  3189. if item.ChrgitmLv == "2" {
  3190. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3191. }
  3192. if item.ChrgitmLv == "3" {
  3193. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3194. }
  3195. }
  3196. if item.MedChrgitmType == "05" { //治疗费
  3197. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3198. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3199. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3200. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3201. if item.ChrgitmLv == "1" {
  3202. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3203. }
  3204. if item.ChrgitmLv == "2" {
  3205. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3206. }
  3207. if item.ChrgitmLv == "3" {
  3208. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3209. }
  3210. }
  3211. if item.MedChrgitmType == "06" { //手术费
  3212. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3213. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3214. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3215. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3216. if item.ChrgitmLv == "1" {
  3217. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3218. }
  3219. if item.ChrgitmLv == "2" {
  3220. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3221. }
  3222. if item.ChrgitmLv == "3" {
  3223. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3224. }
  3225. }
  3226. if item.MedChrgitmType == "07" { //手术费
  3227. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3228. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3229. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3230. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3231. if item.ChrgitmLv == "1" {
  3232. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3233. }
  3234. if item.ChrgitmLv == "2" {
  3235. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3236. }
  3237. if item.ChrgitmLv == "3" {
  3238. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3239. }
  3240. }
  3241. if item.MedChrgitmType == "08" { //材料费
  3242. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3243. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3244. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3245. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3246. if item.ChrgitmLv == "1" {
  3247. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3248. }
  3249. if item.ChrgitmLv == "2" {
  3250. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3251. }
  3252. if item.ChrgitmLv == "3" {
  3253. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3254. }
  3255. }
  3256. if item.MedChrgitmType == "09" { //西药费
  3257. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3258. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3259. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3260. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3261. if item.ChrgitmLv == "1" {
  3262. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3263. }
  3264. if item.ChrgitmLv == "2" {
  3265. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3266. }
  3267. if item.ChrgitmLv == "3" {
  3268. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3269. }
  3270. }
  3271. if item.MedChrgitmType == "10" { //中药饮片
  3272. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3273. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3274. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3275. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3276. if item.ChrgitmLv == "1" {
  3277. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3278. }
  3279. if item.ChrgitmLv == "2" {
  3280. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3281. }
  3282. if item.ChrgitmLv == "3" {
  3283. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3284. }
  3285. }
  3286. if item.MedChrgitmType == "11" { //中成费
  3287. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3288. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3289. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3290. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3291. if item.ChrgitmLv == "1" {
  3292. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3293. }
  3294. if item.ChrgitmLv == "2" {
  3295. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3296. }
  3297. if item.ChrgitmLv == "3" {
  3298. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3299. }
  3300. }
  3301. if item.MedChrgitmType == "12" { //中成费
  3302. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3303. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3304. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3305. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3306. if item.ChrgitmLv == "1" {
  3307. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3308. }
  3309. if item.ChrgitmLv == "2" {
  3310. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3311. }
  3312. if item.ChrgitmLv == "3" {
  3313. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3314. }
  3315. }
  3316. if item.MedChrgitmType == "13" { //中成费
  3317. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3318. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3319. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3320. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3321. if item.ChrgitmLv == "1" {
  3322. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3323. }
  3324. if item.ChrgitmLv == "2" {
  3325. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3326. }
  3327. if item.ChrgitmLv == "3" {
  3328. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3329. }
  3330. }
  3331. if item.MedChrgitmType == "14" { //其他费
  3332. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3333. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3334. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3335. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3336. if item.ChrgitmLv == "1" {
  3337. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3338. }
  3339. if item.ChrgitmLv == "2" {
  3340. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3341. }
  3342. if item.ChrgitmLv == "3" {
  3343. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3344. }
  3345. }
  3346. }
  3347. var iteminfoStructs []service.IteminfoStruct
  3348. if bedCostTotal != 0 {
  3349. iteminfo.MedChrgitm = "01"
  3350. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3351. iteminfo.Amt = bedCostTotal
  3352. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3353. iteminfo.ClabAmt = bed_clab_amt
  3354. iteminfo.OthAmt = bed_other_amt
  3355. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3356. }
  3357. if examineCostTotal != 0 {
  3358. iteminfo.MedChrgitm = "02"
  3359. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3360. iteminfo.Amt = examineCostTotal
  3361. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3362. iteminfo.ClabAmt = examine_clab_amt
  3363. iteminfo.OthAmt = examine_other_amt
  3364. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3366. }
  3367. if checkCostTotal != 0 {
  3368. iteminfo.MedChrgitm = "03"
  3369. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3370. iteminfo.Amt = checkCostTotal
  3371. iteminfo.ClaaSumfee = check_claa_sunmfee
  3372. iteminfo.ClabAmt = check_clab_amt
  3373. iteminfo.OthAmt = check_other_amt
  3374. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3375. }
  3376. if laboratoryCostTotal != 0 {
  3377. iteminfo.MedChrgitm = "04"
  3378. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3379. iteminfo.Amt = laboratoryCostTotal
  3380. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3381. iteminfo.ClabAmt = laboratory_clab_amt
  3382. iteminfo.OthAmt = laboratory_other_amt
  3383. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3384. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3385. }
  3386. if treatCostTotal != 0 {
  3387. iteminfo.MedChrgitm = "05"
  3388. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3389. iteminfo.Amt = treatCostTotal
  3390. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3391. iteminfo.ClabAmt = treat_clab_amt
  3392. iteminfo.OthAmt = treat_other_amt
  3393. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3394. //(struct4101.IteminfoStruct, iteminfo)
  3395. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3396. }
  3397. if operationCostTotal != 0 {
  3398. iteminfo.MedChrgitm = "06"
  3399. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3400. iteminfo.Amt = operationCostTotal
  3401. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3402. iteminfo.ClabAmt = operation_clab_amt
  3403. iteminfo.OthAmt = operation_other_amt
  3404. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3405. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3406. }
  3407. if nursingCostTotal != 0 {
  3408. iteminfo.MedChrgitm = "07"
  3409. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3410. iteminfo.Amt = nursingCostTotal
  3411. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3412. iteminfo.ClabAmt = nursing_clab_amt
  3413. iteminfo.OthAmt = nursing_other_amt
  3414. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3415. }
  3416. if materialCostTotal != 0 {
  3417. iteminfo.MedChrgitm = "08"
  3418. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3419. iteminfo.Amt = materialCostTotal
  3420. iteminfo.ClaaSumfee = material_claa_sunmfee
  3421. iteminfo.ClabAmt = material_clab_amt
  3422. iteminfo.OthAmt = material_other_amt
  3423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3424. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3425. }
  3426. if westernMedicineCostTotal != 0 {
  3427. iteminfo.MedChrgitm = "09"
  3428. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3429. iteminfo.Amt = westernMedicineCostTotal
  3430. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3431. iteminfo.ClabAmt = westernMedicine_clab_amt
  3432. iteminfo.OthAmt = westernMedicine_other_amt
  3433. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3434. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3435. }
  3436. if chineseMedicineCostTotal != 0 {
  3437. iteminfo.MedChrgitm = "10"
  3438. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3439. iteminfo.Amt = chineseMedicineCostTotal
  3440. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3441. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3442. iteminfo.OthAmt = chinese_medicine_other_amt
  3443. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3444. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3445. }
  3446. if chineseTraditionalMedicineCostTotal != 0 {
  3447. iteminfo.MedChrgitm = "11"
  3448. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3449. iteminfo.Amt = westernMedicineCostTotal
  3450. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3451. iteminfo.ClabAmt = westernMedicine_clab_amt
  3452. iteminfo.OthAmt = westernMedicine_other_amt
  3453. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3454. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3455. }
  3456. if commonlyTreatmentCostTotal != 0 {
  3457. iteminfo.MedChrgitm = "12"
  3458. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3459. iteminfo.Amt = commonlyTreatmentCostTotal
  3460. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3461. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3462. iteminfo.OthAmt = commonly_treatment_other_amt
  3463. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3464. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3465. }
  3466. if registerCostTotal != 0 {
  3467. iteminfo.MedChrgitm = "13"
  3468. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3469. iteminfo.Amt = registerCostTotal
  3470. iteminfo.ClaaSumfee = register_claa_sunmfee
  3471. iteminfo.ClabAmt = register_clab_amt
  3472. iteminfo.OthAmt = register_other_amt
  3473. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3474. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3475. }
  3476. if otherCostTotal != 0 {
  3477. iteminfo.MedChrgitm = "14"
  3478. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3479. iteminfo.Amt = otherCostTotal
  3480. iteminfo.ClaaSumfee = other_claa_sunmfee
  3481. iteminfo.ClabAmt = other_clab_amt
  3482. iteminfo.OthAmt = other_other_amt
  3483. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3485. }
  3486. struct4101.IteminfoStruct = iteminfoStructs
  3487. struct4101.Ntly = "中国"
  3488. struct4101.AdmCaty = "A03.06"
  3489. result := service.Gdyb4101ForGZ(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3490. fmt.Println(result)
  3491. var dat map[string]interface{}
  3492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3493. fmt.Println(dat)
  3494. } else {
  3495. fmt.Println(err)
  3496. }
  3497. userJSONBytes, _ := json.Marshal(dat)
  3498. var res ResultSeventeen
  3499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3500. utils.ErrorLog("解析失败:%v", err)
  3501. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. adminUser := c.GetAdminUserInfo()
  3503. errlog := &models.HisOrderError{
  3504. UserOrgId: adminUser.CurrentOrgId,
  3505. Ctime: time.Now().Unix(),
  3506. Mtime: time.Now().Unix(),
  3507. ErrMsg: res.ErrMsg + "解析失败",
  3508. Status: 1,
  3509. PatientId: order_id,
  3510. Stage: 10106,
  3511. }
  3512. service.CreateErrMsgLog(errlog)
  3513. continue
  3514. }
  3515. if res.Infcode != 0 {
  3516. adminUser := c.GetAdminUserInfo()
  3517. errlog := &models.HisOrderError{
  3518. UserOrgId: adminUser.CurrentOrgId,
  3519. Ctime: time.Now().Unix(),
  3520. Mtime: time.Now().Unix(),
  3521. ErrMsg: res.ErrMsg,
  3522. Status: 1,
  3523. PatientId: order_id,
  3524. Stage: 10106,
  3525. }
  3526. service.CreateErrMsgLog(errlog)
  3527. continue
  3528. } else {
  3529. hisFundSettleListResult := &models.HisFundSettleListResult{
  3530. Number: res.Output.SetlListId,
  3531. Status: 1,
  3532. Ctime: time.Now().Unix(),
  3533. Mtime: time.Now().Unix(),
  3534. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3535. IsUpload: 1,
  3536. OrderId: order_id,
  3537. }
  3538. service.CreateUploadRecord(hisFundSettleListResult)
  3539. continue
  3540. }
  3541. }
  3542. }
  3543. func (c *HisApiController) GetOrgInfo() {
  3544. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3545. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3546. }
  3547. func (c *HisApiController) GetHisPatientInfo() {
  3548. medical_insurance_card := c.GetString("medical_insurance_card")
  3549. id_card_type, _ := c.GetInt64("id_card_type")
  3550. id_card := c.GetString("id_card")
  3551. adminInfo := c.GetAdminUserInfo()
  3552. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3553. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3554. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3555. IdCardNo := ""
  3556. if id_card_type == 1 {
  3557. IdCardNo = medical_insurance_card
  3558. } else if id_card_type == 2 {
  3559. IdCardNo = id_card
  3560. }
  3561. if config.IsOpen == 1 {
  3562. 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
  3563. resp, requestErr := http.Get(api)
  3564. if requestErr != nil {
  3565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3566. return
  3567. }
  3568. defer resp.Body.Close()
  3569. body, ioErr := ioutil.ReadAll(resp.Body)
  3570. if ioErr != nil {
  3571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3573. return
  3574. }
  3575. var respJSON map[string]interface{}
  3576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3579. return
  3580. }
  3581. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3582. userJSONBytes, _ := json.Marshal(userJSON)
  3583. var res ResultTwo
  3584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3585. utils.ErrorLog("解析失败:%v", err)
  3586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3587. return
  3588. }
  3589. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  3590. Idetinfos, _ := json.Marshal(res.Output[0].Idetinfo)
  3591. infoStr := string(Iinfos)
  3592. idetinfoStr := string(Idetinfos)
  3593. if res.Infcode == 0 {
  3594. his := models.VMHisPatient{
  3595. Status: 1,
  3596. Ctime: time.Now().Unix(),
  3597. Mtime: time.Now().Unix(),
  3598. PsnNo: res.Output[0].Baseinfo.PsnNo,
  3599. PsnCertType: res.Output[0].Baseinfo.PsnCertType,
  3600. Certno: res.Output[0].Baseinfo.Certno,
  3601. PsnName: res.Output[0].Baseinfo.PsnName,
  3602. Gend: res.Output[0].Baseinfo.Gend,
  3603. Naty: res.Output[0].Baseinfo.Naty,
  3604. Brdy: res.Output[0].Baseinfo.Brdy,
  3605. Age: res.Output[0].Baseinfo.Age,
  3606. Iinfo: infoStr,
  3607. Idetinfo: idetinfoStr,
  3608. UserOrgId: adminInfo.CurrentOrgId,
  3609. IsReturn: 1,
  3610. IdCardType: id_card_type,
  3611. }
  3612. c.ServeSuccessJSON(map[string]interface{}{
  3613. "info": his,
  3614. })
  3615. } else {
  3616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3617. return
  3618. }
  3619. }
  3620. }
  3621. //func GetBasBaseInfo() (jsonStr string, err error) {
  3622. //
  3623. // handle := syscall.NewLazyDLL("SSCard.dll")
  3624. // add := handle.NewProc("ReadCardBas")
  3625. // str := make([]byte, 1024)
  3626. // str1 := make([]byte, 1024)
  3627. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3628. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3629. //
  3630. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3631. //
  3632. // fmt.Println("> Add(4,5)的结果为:", ret)
  3633. // handle.Release()
  3634. //
  3635. // return "", nil
  3636. //
  3637. //}
  3638. //func GetQRBaseInfo() (jsonStr string, err error) {
  3639. // handle := syscall.LoadDLL("SSCard.dll")
  3640. // ReadCardBas := handle.FindProc("GetQRBase")
  3641. //
  3642. // str := make([]byte, 256)
  3643. // str1 := make([]byte, 256)
  3644. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3645. //
  3646. // fmt.Println(string(str))
  3647. // fmt.Println(r)
  3648. // return string(str), nil
  3649. //}
  3650. //func CardInit() int {
  3651. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3652. // add := DllTestDef.MustFindProc("Init")
  3653. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3654. // if err != nil {
  3655. // fmt.Println("SSCard的运算结果为:", ret)
  3656. // }
  3657. // result := int(ret)
  3658. // return result
  3659. //}
  3660. //func CardInit() int {
  3661. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3662. // if err != nil {
  3663. // fmt.Println("SSCard的运算结果为:", ret)
  3664. // }
  3665. // fmt.Println(err)
  3666. // result := int(ret)
  3667. // return result
  3668. //}
  3669. func IntPtr(n int) uintptr {
  3670. return uintptr(n)
  3671. }
  3672. func StrPtr(s string) uintptr {
  3673. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3674. }
  3675. type Result2001 struct {
  3676. Cainfo interface{} `json:"cainfo"`
  3677. ErrMsg string `json:"err_msg"`
  3678. InfRefmsgid string `json:"inf_refmsgid"`
  3679. Infcode int64 `json:"infcode"`
  3680. Output struct {
  3681. Trtinfo struct {
  3682. PsnNo string `json:"psn_no"`
  3683. TrtChkType string `json:"trt_chk_type"`
  3684. FundPayType string `json:"fund_pay_type"`
  3685. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3686. Begndate string `json:"begndate"`
  3687. Enddate string `json:"enddate"`
  3688. TrtChkRslt string `json:"trt_chk_rslt"`
  3689. } `json:"trtinfo"`
  3690. } `json:"output"`
  3691. RefmsgTime string `json:"refmsg_time"`
  3692. RespondTime string `json:"respond_time"`
  3693. Signtype interface{} `json:"signtype"`
  3694. WarnMsg interface{} `json:"warn_msg"`
  3695. }
  3696. type Result2001Org10265 struct {
  3697. Cainfo interface{} `json:"cainfo"`
  3698. ErrMsg string `json:"err_msg"`
  3699. InfRefmsgid string `json:"inf_refmsgid"`
  3700. Infcode string `json:"infcode"`
  3701. Output struct {
  3702. Trtinfo struct {
  3703. PsnNo string `json:"psn_no"`
  3704. TrtChkType string `json:"trt_chk_type"`
  3705. FundPayType string `json:"fund_pay_type"`
  3706. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3707. Begndate string `json:"begndate"`
  3708. Enddate string `json:"enddate"`
  3709. TrtChkRslt string `json:"trt_chk_rslt"`
  3710. } `json:"trtinfo"`
  3711. } `json:"output"`
  3712. RefmsgTime string `json:"refmsg_time"`
  3713. RespondTime string `json:"respond_time"`
  3714. Signtype interface{} `json:"signtype"`
  3715. WarnMsg interface{} `json:"warn_msg"`
  3716. }
  3717. type ResultTwo struct {
  3718. ErrMsg string `json:"err_msg"`
  3719. InfRefmsgid string `json:"inf_refmsgid"`
  3720. Infcode int64 `json:"infcode"`
  3721. Output []struct {
  3722. Baseinfo struct {
  3723. Age float64 `json:"age"`
  3724. Brdy string `json:"brdy"`
  3725. Certno string `json:"certno"`
  3726. Gend string `json:"gend"`
  3727. Naty string `json:"naty"`
  3728. PsnCertType string `json:"psn_cert_type"`
  3729. PsnName string `json:"psn_name"`
  3730. PsnNo string `json:"psn_no"`
  3731. } `json:"baseinfo"`
  3732. Idetinfo []interface{} `json:"idetinfo"`
  3733. Iinfo []struct {
  3734. Balc float64 `json:"balc"`
  3735. CvlservFlag string `json:"cvlserv_flag"`
  3736. EmpName string `json:"emp_name"`
  3737. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3738. Insutype string `json:"insutype"`
  3739. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3740. PausInsuDate string `json:"paus_insu_date"`
  3741. PsnInsuDate string `json:"psn_insu_date"`
  3742. PsnInsuStas string `json:"psn_insu_stas"`
  3743. PsnType string `json:"psn_type"`
  3744. } `json:"insuinfo"`
  3745. } `json:"output"`
  3746. RefmsgTime string `json:"refmsg_time"`
  3747. RespondTime string `json:"respond_time"`
  3748. Signtype interface{} `json:"signtype"`
  3749. WarnInfo interface{} `json:"warn_info"`
  3750. }
  3751. type ResultTwo10265 struct {
  3752. ErrMsg string `json:"err_msg"`
  3753. InfRefmsgid string `json:"inf_refmsgid"`
  3754. Infcode string `json:"infcode"`
  3755. Output struct {
  3756. Baseinfo struct {
  3757. Age float64 `json:"age"`
  3758. Brdy string `json:"brdy"`
  3759. Certno string `json:"certno"`
  3760. Gend string `json:"gend"`
  3761. Naty string `json:"naty"`
  3762. PsnCertType string `json:"psn_cert_type"`
  3763. PsnName string `json:"psn_name"`
  3764. PsnNo string `json:"psn_no"`
  3765. } `json:"baseinfo"`
  3766. Idetinfo []interface{} `json:"idetinfo"`
  3767. Iinfo []struct {
  3768. Balc float64 `json:"balc"`
  3769. CvlservFlag string `json:"cvlserv_flag"`
  3770. EmpName string `json:"emp_name"`
  3771. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3772. Insutype string `json:"insutype"`
  3773. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3774. PausInsuDate string `json:"paus_insu_date"`
  3775. PsnInsuDate string `json:"psn_insu_date"`
  3776. PsnInsuStas string `json:"psn_insu_stas"`
  3777. PsnType string `json:"psn_type"`
  3778. } `json:"insuinfo"`
  3779. } `json:"output"`
  3780. RefmsgTime string `json:"refmsg_time"`
  3781. RespondTime string `json:"respond_time"`
  3782. Signtype interface{} `json:"signtype"`
  3783. WarnInfo interface{} `json:"warn_info"`
  3784. }
  3785. type ResultThree struct {
  3786. Cainfo interface{} `json:"cainfo"`
  3787. ErrMsg string `json:"err_msg"`
  3788. InfRefmsgid string `json:"inf_refmsgid"`
  3789. Infcode int64 `json:"infcode"`
  3790. Output struct {
  3791. Data struct {
  3792. IptOtpNo string `json:"ipt_otp_no"`
  3793. MdtrtID string `json:"mdtrt_id"`
  3794. PsnNo string `json:"psn_no"`
  3795. } `json:"data"`
  3796. } `json:"output"`
  3797. RefmsgTime string `json:"refmsg_time"`
  3798. RespondTime string `json:"respond_time"`
  3799. Signtype interface{} `json:"signtype"`
  3800. WarnMsg interface{} `json:"warn_msg"`
  3801. }
  3802. type ResultThree10265 struct {
  3803. Cainfo interface{} `json:"cainfo"`
  3804. ErrMsg string `json:"err_msg"`
  3805. InfRefmsgid string `json:"inf_refmsgid"`
  3806. Infcode string `json:"infcode"`
  3807. Output struct {
  3808. Data struct {
  3809. IptOtpNo string `json:"ipt_otp_no"`
  3810. MdtrtID string `json:"mdtrt_id"`
  3811. PsnNo string `json:"psn_no"`
  3812. } `json:"data"`
  3813. } `json:"output"`
  3814. RefmsgTime string `json:"refmsg_time"`
  3815. RespondTime string `json:"respond_time"`
  3816. Signtype interface{} `json:"signtype"`
  3817. WarnMsg interface{} `json:"warn_msg"`
  3818. }
  3819. type ResultFour struct {
  3820. Cainfo string `json:"cainfo"`
  3821. ErrMsg string `json:"err_msg"`
  3822. InfRefmsgid string `json:"inf_refmsgid"`
  3823. Infcode int64 `json:"infcode"`
  3824. Output struct {
  3825. Result []struct {
  3826. BasMednFlag string `json:"bas_medn_flag"`
  3827. ChldMedcFlag string `json:"chld_medc_flag"`
  3828. ChrgitmLv string `json:"chrgitm_lv"`
  3829. Cnt float64 `json:"cnt"`
  3830. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3831. DrtReimFlag string `json:"drt_reim_flag"`
  3832. FeedetlSn string `json:"feedetl_sn"`
  3833. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3834. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3835. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3836. ListSpItemFlag string `json:"list_sp_item_flag"`
  3837. LmtUsedFlag string `json:"lmt_used_flag"`
  3838. MedChrgitmType string `json:"med_chrgitm_type"`
  3839. Memo string `json:"memo"`
  3840. OverlmtAmt float64 `json:"overlmt_amt"`
  3841. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3842. Pric float64 `json:"pric"`
  3843. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3844. SelfpayProp float64 `json:"selfpay_prop"`
  3845. } `json:"result"`
  3846. } `json:"output"`
  3847. RefmsgTime string `json:"refmsg_time"`
  3848. RespondTime string `json:"respond_time"`
  3849. Signtype string `json:"signtype"`
  3850. WarnMsg string `json:"warn_msg"`
  3851. }
  3852. type ResultFour10265 struct {
  3853. Cainfo string `json:"cainfo"`
  3854. ErrMsg string `json:"err_msg"`
  3855. InfRefmsgid string `json:"inf_refmsgid"`
  3856. Infcode string `json:"infcode"`
  3857. Output struct {
  3858. Result []struct {
  3859. BasMednFlag string `json:"bas_medn_flag"`
  3860. ChldMedcFlag string `json:"chld_medc_flag"`
  3861. ChrgitmLv string `json:"chrgitm_lv"`
  3862. Cnt float64 `json:"cnt"`
  3863. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3864. DrtReimFlag string `json:"drt_reim_flag"`
  3865. FeedetlSn string `json:"feedetl_sn"`
  3866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3867. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3868. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3869. ListSpItemFlag string `json:"list_sp_item_flag"`
  3870. LmtUsedFlag string `json:"lmt_used_flag"`
  3871. MedChrgitmType string `json:"med_chrgitm_type"`
  3872. Memo string `json:"memo"`
  3873. OverlmtAmt float64 `json:"overlmt_amt"`
  3874. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3875. Pric float64 `json:"pric"`
  3876. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3877. SelfpayProp float64 `json:"selfpay_prop"`
  3878. } `json:"result"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype string `json:"signtype"`
  3883. WarnMsg string `json:"warn_msg"`
  3884. }
  3885. type ResultFive struct {
  3886. Balc float64 `json:"balc"`
  3887. CvlservFlag string `json:"cvlserv_flag"`
  3888. EmpName string `json:"emp_name"`
  3889. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3890. Insutype string `json:"insutype"`
  3891. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3892. PausInsuDate string `json:"paus_insu_date"`
  3893. PsnInsuDate string `json:"psn_insu_date"`
  3894. PsnInsuStas string `json:"psn_insu_stas"`
  3895. PsnType string `json:"psn_type"`
  3896. }
  3897. type ResultSix struct {
  3898. Cainfo interface{} `json:"cainfo"`
  3899. ErrMsg string `json:"err_msg"`
  3900. InfRefmsgid string `json:"inf_refmsgid"`
  3901. Infcode int64 `json:"infcode"`
  3902. RefmsgTime string `json:"refmsg_time"`
  3903. RespondTime string `json:"respond_time"`
  3904. Signtype interface{} `json:"signtype"`
  3905. WarnMsg interface{} `json:"warn_msg"`
  3906. }
  3907. type ResultSix10265 struct {
  3908. Cainfo interface{} `json:"cainfo"`
  3909. ErrMsg string `json:"err_msg"`
  3910. InfRefmsgid string `json:"inf_refmsgid"`
  3911. Infcode string `json:"infcode"`
  3912. Output struct {
  3913. } `json:"output"`
  3914. RefmsgTime string `json:"refmsg_time"`
  3915. RespondTime string `json:"respond_time"`
  3916. Signtype interface{} `json:"signtype"`
  3917. WarnMsg interface{} `json:"warn_msg"`
  3918. }
  3919. type ResultSeven struct {
  3920. Cainfo string `json:"cainfo"`
  3921. ErrMsg string `json:"err_msg"`
  3922. InfRefmsgid string `json:"inf_refmsgid"`
  3923. Infcode int64 `json:"infcode"`
  3924. Output struct {
  3925. Setldetail []interface{} `json:"setldetail"`
  3926. Setlinfo struct {
  3927. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3928. AcctPay float64 `json:"acct_pay"`
  3929. ActPayDedc float64 `json:"act_pay_dedc"`
  3930. Age float64 `json:"age"`
  3931. Balc float64 `json:"balc"`
  3932. Brdy string `json:"brdy"`
  3933. Certno string `json:"certno"`
  3934. ClrOptins string `json:"clr_optins"`
  3935. ClrType string `json:"clr_type"`
  3936. ClrWay string `json:"clr_way"`
  3937. CvlservFlag string `json:"cvlserv_flag"`
  3938. CvlservPay float64 `json:"cvlserv_pay"`
  3939. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3940. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3941. Gend string `json:"gend"`
  3942. HifesPay float64 `json:"hifes_pay"`
  3943. HifmiPay float64 `json:"hifmi_pay"`
  3944. HifpPay float64 `json:"hifp_pay"`
  3945. HospPartAmt float64 `json:"hosp_part_amt"`
  3946. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3947. Insutype string `json:"insutype"`
  3948. MafPay float64 `json:"maf_pay"`
  3949. MdtrtCertType string `json:"mdtrt_cert_type"`
  3950. HifobPay float64 `json:"hifob_pay"`
  3951. MdtrtID string `json:"mdtrt_id"`
  3952. MedType string `json:"med_type"`
  3953. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3954. MedinsSetlID string `json:"medins_setl_id"`
  3955. Naty string `json:"naty"`
  3956. OthPay float64 `json:"oth_pay"`
  3957. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3958. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3959. PsnCashPay float64 `json:"psn_cash_pay"`
  3960. PsnCertType string `json:"psn_cert_type"`
  3961. PsnName string `json:"psn_name"`
  3962. PsnNo string `json:"psn_no"`
  3963. PsnPartAmt float64 `json:"psn_part_amt"`
  3964. PsnType string `json:"psn_type"`
  3965. SetlID string `json:"setl_id"`
  3966. SetlTime string `json:"setl_time"`
  3967. } `json:"setlinfo"`
  3968. } `json:"output"`
  3969. RefmsgTime string `json:"refmsg_time"`
  3970. RespondTime string `json:"respond_time"`
  3971. Signtype interface{} `json:"signtype"`
  3972. WarnMsg interface{} `json:"warn_msg"`
  3973. }
  3974. type ResultSeven10265 struct {
  3975. Cainfo string `json:"cainfo"`
  3976. ErrMsg string `json:"err_msg"`
  3977. InfRefmsgid string `json:"inf_refmsgid"`
  3978. Infcode string `json:"infcode"`
  3979. Output struct {
  3980. Setldetail []interface{} `json:"setldetail"`
  3981. Setlinfo struct {
  3982. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3983. AcctPay float64 `json:"acct_pay"`
  3984. ActPayDedc float64 `json:"act_pay_dedc"`
  3985. Age float64 `json:"age"`
  3986. Balc float64 `json:"balc"`
  3987. Brdy string `json:"brdy"`
  3988. Certno string `json:"certno"`
  3989. ClrOptins string `json:"clr_optins"`
  3990. ClrType string `json:"clr_type"`
  3991. ClrWay string `json:"clr_way"`
  3992. CvlservFlag string `json:"cvlserv_flag"`
  3993. CvlservPay float64 `json:"cvlserv_pay"`
  3994. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3995. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3996. Gend string `json:"gend"`
  3997. HifesPay float64 `json:"hifes_pay"`
  3998. HifmiPay float64 `json:"hifmi_pay"`
  3999. HifpPay float64 `json:"hifp_pay"`
  4000. HospPartAmt float64 `json:"hosp_part_amt"`
  4001. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4002. Insutype string `json:"insutype"`
  4003. MafPay float64 `json:"maf_pay"`
  4004. MdtrtCertType string `json:"mdtrt_cert_type"`
  4005. HifobPay float64 `json:"hifob_pay"`
  4006. MdtrtID string `json:"mdtrt_id"`
  4007. MedType string `json:"med_type"`
  4008. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4009. MedinsSetlID string `json:"medins_setl_id"`
  4010. Naty string `json:"naty"`
  4011. OthPay float64 `json:"oth_pay"`
  4012. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4013. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4014. PsnCashPay float64 `json:"psn_cash_pay"`
  4015. PsnCertType string `json:"psn_cert_type"`
  4016. PsnName string `json:"psn_name"`
  4017. PsnNo string `json:"psn_no"`
  4018. PsnPartAmt float64 `json:"psn_part_amt"`
  4019. PsnType string `json:"psn_type"`
  4020. SetlID string `json:"setl_id"`
  4021. SetlTime string `json:"setl_time"`
  4022. } `json:"setlinfo"`
  4023. } `json:"output"`
  4024. RefmsgTime string `json:"refmsg_time"`
  4025. RespondTime string `json:"respond_time"`
  4026. Signtype interface{} `json:"signtype"`
  4027. WarnMsg interface{} `json:"warn_msg"`
  4028. }
  4029. type ResultEight struct {
  4030. Cainfo string `json:"cainfo"`
  4031. ErrMsg string `json:"err_msg"`
  4032. InfRefmsgid string `json:"inf_refmsgid"`
  4033. Infcode int64 `json:"infcode"`
  4034. Output struct {
  4035. Stmtinfo struct {
  4036. SetlOptins string `json:"setl_optins"`
  4037. StmtRslt string `json:"stmt_rslt"`
  4038. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4039. } `json:"stmtinfo"`
  4040. } `json:"output"`
  4041. RefmsgTime string `json:"refmsg_time"`
  4042. RespondTime string `json:"respond_time"`
  4043. Signtype interface{} `json:"signtype"`
  4044. WarnMsg interface{} `json:"warn_msg"`
  4045. }
  4046. type ResultEightFor10188 struct {
  4047. Cainfo string `json:"cainfo"`
  4048. ErrMsg string `json:"err_msg"`
  4049. InfRefmsgid string `json:"inf_refmsgid"`
  4050. Infcode string `json:"infcode"`
  4051. Output struct {
  4052. Stmtinfo struct {
  4053. SetlOptins string `json:"setl_optins"`
  4054. StmtRslt string `json:"stmt_rslt"`
  4055. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4056. } `json:"stmtinfo"`
  4057. } `json:"output"`
  4058. RefmsgTime string `json:"refmsg_time"`
  4059. RespondTime string `json:"respond_time"`
  4060. Signtype interface{} `json:"signtype"`
  4061. WarnMsg interface{} `json:"warn_msg"`
  4062. }
  4063. type ResultNine struct {
  4064. Cainfo string `json:"cainfo"`
  4065. ErrMsg string `json:"err_msg"`
  4066. InfRefmsgid string `json:"inf_refmsgid"`
  4067. Infcode int64 `json:"infcode"`
  4068. Output struct {
  4069. FileQuryNo string `json:"file_qury_no"`
  4070. } `json:"output"`
  4071. RefmsgTime string `json:"refmsg_time"`
  4072. RespondTime string `json:"respond_time"`
  4073. Signtype interface{} `json:"signtype"`
  4074. WarnMsg interface{} `json:"warn_msg"`
  4075. }
  4076. type ResultTen struct {
  4077. Cainfo string `json:"cainfo"`
  4078. ErrMsg string `json:"err_msg"`
  4079. InfRefmsgid string `json:"inf_refmsgid"`
  4080. Infcode int64 `json:"infcode"`
  4081. Output struct {
  4082. DldEndtime string `json:"dld_endtime"`
  4083. FileQuryNo string `json:"file_qury_no"`
  4084. Filename string `json:"filename"`
  4085. } `json:"output"`
  4086. RefmsgTime string `json:"refmsg_time"`
  4087. RespondTime string `json:"respond_time"`
  4088. Signtype interface{} `json:"signtype"`
  4089. WarnMsg interface{} `json:"warn_msg"`
  4090. }
  4091. //type Autogenerated struct {
  4092. // Output struct {
  4093. // Setlinfo struct {
  4094. // SetlTime string `json:"setl_time"`
  4095. // CvlservPay float64 `json:"cvlserv_pay"`
  4096. // Year string `json:"year"`
  4097. // MedType string `json:"med_type"`
  4098. // PsnPay float64 `json:"psn_pay"`
  4099. // OpterID string `json:"opter_id"`
  4100. // Begndate string `json:"begndate"`
  4101. // FlxempeFlag string `json:"flxempe_flag"`
  4102. // HifmiPay float64 `json:"hifmi_pay"`
  4103. // PsnNo string `json:"psn_no"`
  4104. // ActPayDedc float64 `json:"act_pay_dedc"`
  4105. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4106. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4107. // ClrWay string `json:"clr_way"`
  4108. // OthPay float64 `json:"oth_pay"`
  4109. // Gend string `json:"gend"`
  4110. // MdtrtID string `json:"mdtrt_id"`
  4111. // AcctPay float64 `json:"acct_pay"`
  4112. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4113. // Insutype string `json:"insutype"`
  4114. // Invono interface{} `json:"invono"`
  4115. // Enddate string `json:"enddate"`
  4116. // CashPayamt float64 `json:"cash_payamt"`
  4117. // PsnType string `json:"psn_type"`
  4118. // FixmedinsName string `json:"fixmedins_name"`
  4119. // HifpPay float64 `json:"hifp_pay"`
  4120. // NewFlag interface{} `json:"new_flag"`
  4121. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4122. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4123. // PayLoc string `json:"pay_loc"`
  4124. // ClrType string `json:"clr_type"`
  4125. // RefdSetlFlag string `json:"refd_setl_flag"`
  4126. // CvlservFlag string `json:"cvlserv_flag"`
  4127. // EmpName string `json:"emp_name"`
  4128. // Brdy string `json:"brdy"`
  4129. // Naty string `json:"naty"`
  4130. // Certno string `json:"certno"`
  4131. // DiseCode string `json:"dise_code"`
  4132. // FixmedinsCode string `json:"fixmedins_code"`
  4133. // DedcHospLv string `json:"dedc_hosp_lv"`
  4134. // OpterName string `json:"opter_name"`
  4135. // Balc float64 `json:"balc"`
  4136. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4137. // PsnCertType string `json:"psn_cert_type"`
  4138. // HifobPay float64 `json:"hifob_pay"`
  4139. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4140. // HifesPay float64 `json:"hifes_pay"`
  4141. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4142. // OptTime string `json:"opt_time"`
  4143. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4144. // SetlID string `json:"setl_id"`
  4145. // MafPay float64 `json:"maf_pay"`
  4146. // PsnName string `json:"psn_name"`
  4147. // InsuOptins interface{} `json:"insu_optins"`
  4148. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4149. // ClrOptins string `json:"clr_optins"`
  4150. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4151. // DiseName string `json:"dise_name"`
  4152. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4153. // Age float64 `json:"age"`
  4154. // DtrtCertType string `json:"dtrt_cert_type"`
  4155. // HospLv string `json:"hosp_lv"`
  4156. // } `json:"setlinfo"`
  4157. // Setldetail []struct {
  4158. // FundPayType string `json:"fund_pay_type"`
  4159. // FundPayamt float64 `json:"fund_payamt"`
  4160. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4161. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4162. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4163. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4164. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4165. // } `json:"setldetail"`
  4166. // } `json:"output"`
  4167. // Infcode int `json:"infcode"`
  4168. // WarnMsg interface{} `json:"warn_msg"`
  4169. // Cainfo interface{} `json:"cainfo"`
  4170. // ErrMsg interface{} `json:"err_msg"`
  4171. // RefmsgTime string `json:"refmsg_time"`
  4172. // Signtype interface{} `json:"signtype"`
  4173. // RespondTime string `json:"respond_time"`
  4174. // InfRefmsgid string `json:"inf_refmsgid"`
  4175. //}
  4176. type ResultEleven struct {
  4177. Cainfo string `json:"cainfo"`
  4178. ErrMsg string `json:"err_msg"`
  4179. InfRefmsgid string `json:"inf_refmsgid"`
  4180. Infcode int64 `json:"infcode"`
  4181. Output struct {
  4182. Setlinfo struct {
  4183. SetlTime string `json:"setl_time"`
  4184. CvlservPay float64 `json:"cvlserv_pay"`
  4185. Year string `json:"year"`
  4186. MedType string `json:"med_type"`
  4187. PsnPay float64 `json:"psn_pay"`
  4188. OpterID string `json:"opter_id"`
  4189. Begndate string `json:"begndate"`
  4190. FlxempeFlag string `json:"flxempe_flag"`
  4191. HifmiPay float64 `json:"hifmi_pay"`
  4192. PsnNo string `json:"psn_no"`
  4193. ActPayDedc float64 `json:"act_pay_dedc"`
  4194. MedinsSetlID interface{} `json:"medins_setl_id"`
  4195. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4196. ClrWay string `json:"clr_way"`
  4197. OthPay float64 `json:"oth_pay"`
  4198. Gend string `json:"gend"`
  4199. MdtrtID string `json:"mdtrt_id"`
  4200. AcctPay float64 `json:"acct_pay"`
  4201. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4202. Insutype string `json:"insutype"`
  4203. Invono interface{} `json:"invono"`
  4204. Enddate string `json:"enddate"`
  4205. CashPayamt float64 `json:"cash_payamt"`
  4206. PsnType string `json:"psn_type"`
  4207. FixmedinsName string `json:"fixmedins_name"`
  4208. HifpPay float64 `json:"hifp_pay"`
  4209. NewFlag interface{} `json:"new_flag"`
  4210. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4211. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4212. PayLoc string `json:"pay_loc"`
  4213. ClrType string `json:"clr_type"`
  4214. RefdSetlFlag string `json:"refd_setl_flag"`
  4215. CvlservFlag string `json:"cvlserv_flag"`
  4216. EmpName string `json:"emp_name"`
  4217. Brdy string `json:"brdy"`
  4218. Naty string `json:"naty"`
  4219. Certno string `json:"certno"`
  4220. DiseCode string `json:"dise_code"`
  4221. FixmedinsCode string `json:"fixmedins_code"`
  4222. DedcHospLv string `json:"dedc_hosp_lv"`
  4223. OpterName string `json:"opter_name"`
  4224. Balc float64 `json:"balc"`
  4225. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4226. PsnCertType string `json:"psn_cert_type"`
  4227. HifobPay float64 `json:"hifob_pay"`
  4228. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4229. HifesPay float64 `json:"hifes_pay"`
  4230. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4231. OptTime string `json:"opt_time"`
  4232. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4233. SetlID string `json:"setl_id"`
  4234. MafPay float64 `json:"maf_pay"`
  4235. PsnName string `json:"psn_name"`
  4236. InsuOptins interface{} `json:"insu_optins"`
  4237. PrefFundPay interface{} `json:"pref_fund_pay"`
  4238. ClrOptins string `json:"clr_optins"`
  4239. DiseName string `json:"dise_name"`
  4240. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4241. Age float64 `json:"age"`
  4242. DtrtCertType string `json:"dtrt_cert_type"`
  4243. HospLv string `json:"hosp_lv"`
  4244. } `json:"setlinfo"`
  4245. } `json:"output"`
  4246. RefmsgTime string `json:"refmsg_time"`
  4247. RespondTime string `json:"respond_time"`
  4248. Signtype interface{} `json:"signtype"`
  4249. WarnMsg interface{} `json:"warn_msg"`
  4250. }
  4251. type ResultEleven10265 struct {
  4252. Cainfo string `json:"cainfo"`
  4253. ErrMsg string `json:"err_msg"`
  4254. InfRefmsgid string `json:"inf_refmsgid"`
  4255. Infcode string `json:"infcode"`
  4256. Output struct {
  4257. Setlinfo struct {
  4258. SetlTime string `json:"setl_time"`
  4259. CvlservPay float64 `json:"cvlserv_pay"`
  4260. Year string `json:"year"`
  4261. MedType string `json:"med_type"`
  4262. PsnPay float64 `json:"psn_pay"`
  4263. OpterID string `json:"opter_id"`
  4264. Begndate string `json:"begndate"`
  4265. FlxempeFlag string `json:"flxempe_flag"`
  4266. HifmiPay float64 `json:"hifmi_pay"`
  4267. PsnNo string `json:"psn_no"`
  4268. ActPayDedc float64 `json:"act_pay_dedc"`
  4269. MedinsSetlID interface{} `json:"medins_setl_id"`
  4270. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4271. ClrWay string `json:"clr_way"`
  4272. OthPay float64 `json:"oth_pay"`
  4273. Gend string `json:"gend"`
  4274. MdtrtID string `json:"mdtrt_id"`
  4275. AcctPay float64 `json:"acct_pay"`
  4276. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4277. Insutype string `json:"insutype"`
  4278. Invono interface{} `json:"invono"`
  4279. Enddate string `json:"enddate"`
  4280. CashPayamt float64 `json:"cash_payamt"`
  4281. PsnType string `json:"psn_type"`
  4282. FixmedinsName string `json:"fixmedins_name"`
  4283. HifpPay float64 `json:"hifp_pay"`
  4284. NewFlag interface{} `json:"new_flag"`
  4285. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4286. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4287. PayLoc string `json:"pay_loc"`
  4288. ClrType string `json:"clr_type"`
  4289. RefdSetlFlag string `json:"refd_setl_flag"`
  4290. CvlservFlag string `json:"cvlserv_flag"`
  4291. EmpName string `json:"emp_name"`
  4292. Brdy string `json:"brdy"`
  4293. Naty string `json:"naty"`
  4294. Certno string `json:"certno"`
  4295. DiseCode string `json:"dise_code"`
  4296. FixmedinsCode string `json:"fixmedins_code"`
  4297. DedcHospLv string `json:"dedc_hosp_lv"`
  4298. OpterName string `json:"opter_name"`
  4299. Balc float64 `json:"balc"`
  4300. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4301. PsnCertType string `json:"psn_cert_type"`
  4302. HifobPay float64 `json:"hifob_pay"`
  4303. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4304. HifesPay float64 `json:"hifes_pay"`
  4305. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4306. OptTime string `json:"opt_time"`
  4307. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4308. SetlID string `json:"setl_id"`
  4309. MafPay float64 `json:"maf_pay"`
  4310. PsnName string `json:"psn_name"`
  4311. InsuOptins interface{} `json:"insu_optins"`
  4312. PrefFundPay interface{} `json:"pref_fund_pay"`
  4313. ClrOptins string `json:"clr_optins"`
  4314. DiseName string `json:"dise_name"`
  4315. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4316. Age float64 `json:"age"`
  4317. DtrtCertType string `json:"dtrt_cert_type"`
  4318. HospLv string `json:"hosp_lv"`
  4319. } `json:"setlinfo"`
  4320. } `json:"output"`
  4321. RefmsgTime string `json:"refmsg_time"`
  4322. RespondTime string `json:"respond_time"`
  4323. Signtype interface{} `json:"signtype"`
  4324. WarnMsg interface{} `json:"warn_msg"`
  4325. }
  4326. type ResultTwelve struct {
  4327. Cainfo string `json:"cainfo"`
  4328. ErrMsg string `json:"err_msg"`
  4329. InfRefmsgid string `json:"inf_refmsgid"`
  4330. Infcode int64 `json:"infcode"`
  4331. Output struct {
  4332. MdtrtId string `json:"mdtrt_id"`
  4333. ChrgBchno string `json:"chrg_bchno"`
  4334. PsnNo string `json:"psn_no"`
  4335. } `json:"output"`
  4336. RefmsgTime string `json:"refmsg_time"`
  4337. RespondTime string `json:"respond_time"`
  4338. Signtype interface{} `json:"signtype"`
  4339. WarnMsg interface{} `json:"warn_msg"`
  4340. }
  4341. type ResultThirteen struct {
  4342. ErrMsg string `json:"err_msg"`
  4343. InfRefmsgid string `json:"inf_refmsgid"`
  4344. Infcode int64 `json:"infcode"`
  4345. Output struct {
  4346. Result struct {
  4347. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4348. } `json:"result"`
  4349. } `json:"output"`
  4350. RefmsgTime string `json:"refmsg_time"`
  4351. RespondTime string `json:"respond_time"`
  4352. Signtype interface{} `json:"signtype"`
  4353. WarnInfo interface{} `json:"warn_info"`
  4354. }
  4355. type ResultThirteen10265 struct {
  4356. ErrMsg string `json:"err_msg"`
  4357. InfRefmsgid string `json:"inf_refmsgid"`
  4358. Infcode string `json:"infcode"`
  4359. Output struct {
  4360. Result struct {
  4361. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4362. } `json:"result"`
  4363. } `json:"output"`
  4364. RefmsgTime string `json:"refmsg_time"`
  4365. RespondTime string `json:"respond_time"`
  4366. Signtype interface{} `json:"signtype"`
  4367. WarnInfo interface{} `json:"warn_info"`
  4368. }
  4369. type ResultFourteen struct {
  4370. ErrMsg string `json:"err_msg"`
  4371. InfRefmsgid string `json:"inf_refmsgid"`
  4372. Infcode int64 `json:"infcode"`
  4373. Output struct {
  4374. } `json:"output"`
  4375. RefmsgTime string `json:"refmsg_time"`
  4376. RespondTime string `json:"respond_time"`
  4377. Signtype interface{} `json:"signtype"`
  4378. WarnInfo interface{} `json:"warn_info"`
  4379. }
  4380. type ResultFourteen10265 struct {
  4381. ErrMsg string `json:"err_msg"`
  4382. InfRefmsgid string `json:"inf_refmsgid"`
  4383. Infcode string `json:"infcode"`
  4384. Output struct {
  4385. } `json:"output"`
  4386. RefmsgTime string `json:"refmsg_time"`
  4387. RespondTime string `json:"respond_time"`
  4388. Signtype interface{} `json:"signtype"`
  4389. WarnInfo interface{} `json:"warn_info"`
  4390. }
  4391. type ResultSixteen struct {
  4392. Cainfo string `json:"cainfo"`
  4393. ErrMsg string `json:"err_msg"`
  4394. InfRefmsgid string `json:"inf_refmsgid"`
  4395. Infcode int64 `json:"infcode"`
  4396. Output struct {
  4397. Setldetail []interface{} `json:"setldetail"`
  4398. Setlinfo struct {
  4399. MdtrtID string `json:"mdtrt_id"`
  4400. SetlID string `json:"setl_id"`
  4401. ClrOptins string `json:"clr_optins"`
  4402. SetlTime string `json:"setl_time"`
  4403. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4404. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4405. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4406. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4407. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4408. ActPayDedc float64 `json:"act_pay_dedc"`
  4409. HifpPay float64 `json:"hifp_pay"`
  4410. Lfpay float64 `json:"selfpay"`
  4411. CvlservPay float64 `json:"cvlserv_pay"`
  4412. HifesPay float64 `json:"hifes_pay"`
  4413. HifmiPay float64 `json:"hifmi_pay"`
  4414. HifobPay float64 `json:"hifob_pay"`
  4415. MafPay float64 `json:"maf_pay"`
  4416. OthPay float64 `json:"oth_pay"`
  4417. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4418. PsnPartAmt float64 `json:"psn_part_amt"`
  4419. AcctPay float64 `json:"acct_pay"`
  4420. Balc float64 `json:"balc"`
  4421. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4422. HospPartAmt float64 `json:"hosp_part_amt"`
  4423. MedinsSetlID string `json:"medins_setl_id"`
  4424. PdnCashPay string `json:"pdn_cash_pay"`
  4425. } `json:"setlinfo"`
  4426. } `json:"output"`
  4427. RefmsgTime string `json:"refmsg_time"`
  4428. RespondTime string `json:"respond_time"`
  4429. Signtype interface{} `json:"signtype"`
  4430. WarnMsg interface{} `json:"warn_msg"`
  4431. }
  4432. type ResultSixteen10265 struct {
  4433. Cainfo string `json:"cainfo"`
  4434. ErrMsg string `json:"err_msg"`
  4435. InfRefmsgid string `json:"inf_refmsgid"`
  4436. Infcode string `json:"infcode"`
  4437. Output struct {
  4438. Setldetail []interface{} `json:"setldetail"`
  4439. Setlinfo struct {
  4440. MdtrtID string `json:"mdtrt_id"`
  4441. SetlID string `json:"setl_id"`
  4442. ClrOptins string `json:"clr_optins"`
  4443. SetlTime string `json:"setl_time"`
  4444. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4445. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4446. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4447. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4448. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4449. ActPayDedc float64 `json:"act_pay_dedc"`
  4450. HifpPay float64 `json:"hifp_pay"`
  4451. Lfpay float64 `json:"selfpay"`
  4452. CvlservPay float64 `json:"cvlserv_pay"`
  4453. HifesPay float64 `json:"hifes_pay"`
  4454. HifmiPay float64 `json:"hifmi_pay"`
  4455. HifobPay float64 `json:"hifob_pay"`
  4456. MafPay float64 `json:"maf_pay"`
  4457. OthPay float64 `json:"oth_pay"`
  4458. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4459. PsnPartAmt float64 `json:"psn_part_amt"`
  4460. AcctPay float64 `json:"acct_pay"`
  4461. Balc float64 `json:"balc"`
  4462. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4463. HospPartAmt float64 `json:"hosp_part_amt"`
  4464. MedinsSetlID string `json:"medins_setl_id"`
  4465. PdnCashPay string `json:"pdn_cash_pay"`
  4466. } `json:"setlinfo"`
  4467. } `json:"output"`
  4468. RefmsgTime string `json:"refmsg_time"`
  4469. RespondTime string `json:"respond_time"`
  4470. Signtype interface{} `json:"signtype"`
  4471. WarnMsg interface{} `json:"warn_msg"`
  4472. }
  4473. type ResultSeventeen struct {
  4474. ErrMsg string `json:"err_msg"`
  4475. InfRefmsgid string `json:"inf_refmsgid"`
  4476. Infcode int64 `json:"infcode"`
  4477. Output struct {
  4478. SetlListId string `json:"setl_list_id"`
  4479. } `json:"output"`
  4480. RefmsgTime string `json:"refmsg_time"`
  4481. RespondTime string `json:"respond_time"`
  4482. Signtype string `json:"signtype"`
  4483. WarnInfo string `json:"warn_info"`
  4484. }
  4485. type ResultSeventeenOther struct {
  4486. ErrMsg string `json:"err_msg"`
  4487. InfRefmsgid string `json:"inf_refmsgid"`
  4488. Infcode string `json:"infcode"`
  4489. Output struct {
  4490. SetlListId string `json:"setl_list_id"`
  4491. } `json:"output"`
  4492. RefmsgTime string `json:"refmsg_time"`
  4493. RespondTime string `json:"respond_time"`
  4494. Signtype string `json:"signtype"`
  4495. WarnInfo string `json:"warn_info"`
  4496. }
  4497. type Result90991 struct {
  4498. ErrMsg string `json:"err_msg"`
  4499. InfRefmsgid string `json:"inf_refmsgid"`
  4500. Infcode int64 `json:"infcode"`
  4501. Output struct {
  4502. Result struct {
  4503. PsnNo string `json:"psn_no"`
  4504. CardStat string `json:"card_stat"`
  4505. Certno string `json:"certno"`
  4506. PsnName string `json:"psn_name"`
  4507. CheckStat string `json:"check_stat"`
  4508. SscnoCheckStat string `json:"sscno_check_stat"`
  4509. } `json:"result"`
  4510. } `json:"output"`
  4511. RefmsgTime string `json:"refmsg_time"`
  4512. RespondTime string `json:"respond_time"`
  4513. Signtype interface{} `json:"signtype"`
  4514. WarnInfo interface{} `json:"warn_info"`
  4515. }
  4516. type Result90100 struct {
  4517. ErrMsg string `json:"err_msg"`
  4518. InfRefmsgid string `json:"inf_refmsgid"`
  4519. Infcode int64 `json:"infcode"`
  4520. Output struct {
  4521. PoolareaNo string `json:"poolarea_no"`
  4522. PoolareaNoName string `json:"poolarea_no_name"`
  4523. Insutype string `json:"insutype"`
  4524. InsutypeName string `json:"insutype_name"`
  4525. ClctType string `json:"clct_type"`
  4526. ClctTypeName string `json:"clct_type_name"`
  4527. ClctFlag string `json:"clct_flag"`
  4528. ClctFlagName string `json:"clct_flag_name"`
  4529. AccrymBegn string `json:"accrym_begn"`
  4530. AccrymEnd string `json:"accrym_end"`
  4531. ClctTime string `json:"clct_time"`
  4532. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4533. } `json:"output"`
  4534. RefmsgTime string `json:"refmsg_time"`
  4535. RespondTime string `json:"respond_time"`
  4536. Signtype interface{} `json:"signtype"`
  4537. WarnInfo interface{} `json:"warn_info"`
  4538. }
  4539. type Custom struct {
  4540. DetItemFeeSumamt string
  4541. Cut string
  4542. FeedetlSn string
  4543. Price string
  4544. MedListCodg string
  4545. Type int64
  4546. AdviceId int64
  4547. ProjectId int64
  4548. ItemId int64
  4549. }
  4550. type Result5301 struct {
  4551. ErrMsg string `json:"err_msg"`
  4552. InfRefmsgid string `json:"inf_refmsgid"`
  4553. Infcode int64 `json:"infcode"`
  4554. Output struct {
  4555. Result []struct {
  4556. OpspDiseCode string `json:"opsp_dise_code"`
  4557. OpspDiseName string `json:"opsp_dise_name"`
  4558. Begndate string `json:"begndate"`
  4559. Enddate string `json:"enddate"`
  4560. } `json:"feedetail"`
  4561. } `json:"output"`
  4562. RefmsgTime string `json:"refmsg_time"`
  4563. RespondTime string `json:"respond_time"`
  4564. Signtype interface{} `json:"signtype"`
  4565. WarnInfo interface{} `json:"warn_info"`
  4566. }
  4567. type Result5301For10265 struct {
  4568. ErrMsg string `json:"err_msg"`
  4569. InfRefmsgid string `json:"inf_refmsgid"`
  4570. Infcode string `json:"infcode"`
  4571. Output struct {
  4572. Result []struct {
  4573. OpspDiseCode string `json:"opsp_dise_code"`
  4574. OpspDiseName string `json:"opsp_dise_name"`
  4575. Begndate string `json:"begndate"`
  4576. Enddate string `json:"enddate"`
  4577. } `json:"feedetail"`
  4578. } `json:"output"`
  4579. RefmsgTime string `json:"refmsg_time"`
  4580. RespondTime string `json:"respond_time"`
  4581. Signtype interface{} `json:"signtype"`
  4582. WarnInfo interface{} `json:"warn_info"`
  4583. }
  4584. // 获取个人信息----挂号-----上传就诊信息
  4585. func (c *HisApiController) GetRegisterInfo() {
  4586. id, _ := c.GetInt64("id")
  4587. record_time := c.GetString("record_time")
  4588. settlementValue, _ := c.GetInt64("settlement_value")
  4589. medical_insurance_card := c.GetString("medical_insurance_card")
  4590. name := c.GetString("name")
  4591. id_card_type, _ := c.GetInt64("id_card_type")
  4592. certificates, _ := c.GetInt64("certificates")
  4593. medical_care, _ := c.GetInt64("medical_care")
  4594. birthday := c.GetString("birthday")
  4595. id_card := c.GetString("id_card")
  4596. register_type, _ := c.GetInt64("register")
  4597. doctor, _ := c.GetInt64("doctor")
  4598. department, _ := c.GetInt64("department")
  4599. gender, _ := c.GetInt64("sex")
  4600. registration_fee, _ := c.GetFloat("registration_fee")
  4601. medical_expenses, _ := c.GetFloat("medical_expenses")
  4602. social_type, _ := c.GetInt64("social_type")
  4603. med_type := c.GetString("social_type")
  4604. admin_user_id, _ := c.GetInt64("admin_user_id")
  4605. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4606. timeLayout := "2006-01-02"
  4607. loc, _ := time.LoadLocation("Local")
  4608. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4609. birthUnix := birthdays.Unix()
  4610. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4611. if err != nil {
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4613. return
  4614. }
  4615. recordDateTime := theTime.Unix()
  4616. adminInfo := c.GetAdminUserInfo()
  4617. var patient service.Patients
  4618. if id == 0 {
  4619. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4620. } else {
  4621. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4622. }
  4623. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4624. if patientPrescription.ID == 0 {
  4625. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4626. }
  4627. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4628. if patient.ID == 0 {
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4630. return
  4631. }
  4632. if len(patient.IdCardNo) == 0 {
  4633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4634. return
  4635. }
  4636. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4637. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4638. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4639. //就诊结算未完成,不能进行二次挂号
  4640. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4641. if len(his) >= 1 {
  4642. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4643. if len(his) >= 1 && order.ID == 0 {
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4645. return
  4646. }
  4647. }
  4648. //var register_log string
  4649. if config.IsOpen == 1 {
  4650. var res ResultTwo
  4651. var res10265 ResultTwo10265
  4652. var PsnNo string
  4653. var PsnCertType string
  4654. var Certno string
  4655. var PsnName string
  4656. var Gend string
  4657. var Naty string
  4658. var Brdy string
  4659. var Age float64
  4660. var infoStr string
  4661. var idetinfoStr string
  4662. var infocode int64
  4663. var verify_number string
  4664. fmt.Println(verify_number)
  4665. if miConfig.MdtrtareaAdmvs == "421300" {
  4666. psn_info, _ := service.GetPsnByPatientId(id)
  4667. PsnNo = psn_info.PsnNo
  4668. PsnCertType = psn_info.PsnCertType
  4669. Certno = psn_info.Certno
  4670. PsnName = psn_info.PsnName
  4671. Gend = psn_info.Gend
  4672. Naty = psn_info.Naty
  4673. Brdy = psn_info.Brdy
  4674. Age = psn_info.Age
  4675. infoStr = psn_info.Insuinfo
  4676. idetinfoStr = psn_info.Idetinfo
  4677. infocode = 0
  4678. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4679. psn_info, _ := service.GetPsnByPatientId(id)
  4680. PsnNo = psn_info.PsnNo
  4681. PsnCertType = psn_info.PsnCertType
  4682. Certno = psn_info.Certno
  4683. PsnName = psn_info.PsnName
  4684. Gend = psn_info.Gend
  4685. Naty = psn_info.Naty
  4686. Brdy = psn_info.Brdy
  4687. Age = psn_info.Age
  4688. infoStr = psn_info.Insuinfo
  4689. idetinfoStr = psn_info.Idetinfo
  4690. infocode = 0
  4691. verify_number = psn_info.VerifyNumber
  4692. } else {
  4693. var result string
  4694. var requestLog string
  4695. if miConfig.UserOrgId == 10138 {
  4696. 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)
  4697. } else {
  4698. 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)
  4699. }
  4700. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4701. if miConfig.Code == "H15049901371" {
  4702. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4703. utils.ErrorLog("解析失败:%v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. res.ErrMsg = res10265.ErrMsg
  4708. //res.Output = res10265.Output
  4709. res.InfRefmsgid = res10265.InfRefmsgid
  4710. } else {
  4711. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4712. utils.ErrorLog("解析失败:%v", err)
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. }
  4717. PsnNo = res.Output[0].Baseinfo.PsnNo
  4718. PsnCertType = res.Output[0].Baseinfo.PsnCertType
  4719. Certno = res.Output[0].Baseinfo.Certno
  4720. PsnName = res.Output[0].Baseinfo.PsnName
  4721. Gend = res.Output[0].Baseinfo.Gend
  4722. Naty = res.Output[0].Baseinfo.Naty
  4723. Brdy = res.Output[0].Baseinfo.Brdy
  4724. Age = res.Output[0].Baseinfo.Age
  4725. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  4726. Idetinfos, _ := json.Marshal(res.Output[0].Idetinfo)
  4727. infoStr = string(Iinfos)
  4728. idetinfoStr = string(Idetinfos)
  4729. if miConfig.Code == "H15049901371" {
  4730. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4731. } else {
  4732. infocode = res.Infcode
  4733. }
  4734. }
  4735. if infocode == 0 {
  4736. his := models.VMHisPatient{
  4737. Name: name,
  4738. Gender: gender,
  4739. Birthday: birthUnix,
  4740. MedicalTreatmentType: medical_care,
  4741. IdType: certificates,
  4742. IdCardNo: id_card,
  4743. BalanceAccountsType: settlementValue,
  4744. SocialType: social_type,
  4745. MedicalInsuranceNumber: medical_insurance_card,
  4746. RegisterType: register_type,
  4747. RegisterCost: registration_fee,
  4748. TreatmentCost: medical_expenses,
  4749. Status: 1,
  4750. Ctime: time.Now().Unix(),
  4751. Mtime: time.Now().Unix(),
  4752. PsnNo: PsnNo,
  4753. PsnCertType: PsnCertType,
  4754. Certno: Certno,
  4755. PsnName: PsnName,
  4756. Gend: Gend,
  4757. Naty: Naty,
  4758. Brdy: Brdy,
  4759. Age: Age,
  4760. Iinfo: infoStr,
  4761. Idetinfo: idetinfoStr,
  4762. PatientId: patient.ID,
  4763. RecordDate: theTime.Unix(),
  4764. UserOrgId: adminInfo.CurrentOrgId,
  4765. AdminUserId: admin_user_id,
  4766. IsReturn: 1,
  4767. IdCardType: id_card_type,
  4768. Doctor: doctor,
  4769. Departments: department,
  4770. }
  4771. timestamp := time.Now().Unix()
  4772. tempTime := time.Unix(timestamp, 0)
  4773. timeFormat := tempTime.Format("20060102150405")
  4774. chrgBchno := rand.Intn(100000) + 10000
  4775. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4776. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4777. department, _ := service.GetDepartMentDetail(department)
  4778. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4779. IdCardNo := ""
  4780. if id_card_type == 1 {
  4781. // IdCardNo = medical_insurance_card
  4782. IdCardNo = patient.IdCardNo
  4783. } else {
  4784. IdCardNo = patient.IdCardNo
  4785. }
  4786. var rf []*ResultFive
  4787. json.Unmarshal([]byte(his.Iinfo), &rf)
  4788. var insutypes []*ResultFive
  4789. var insutype string
  4790. var insuplc_admdvs_temp string
  4791. var is390 int = 0
  4792. var is310 int = 0
  4793. for _, item := range rf {
  4794. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4795. insutypes = append(insutypes, item)
  4796. }
  4797. }
  4798. if len(insutypes) == 1 {
  4799. insutype = insutypes[0].Insutype
  4800. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4801. } else {
  4802. for _, i := range insutypes {
  4803. if i.Insutype == "390" {
  4804. is390 = 1
  4805. }
  4806. if i.Insutype == "310" {
  4807. is310 = 1
  4808. }
  4809. }
  4810. }
  4811. if is390 == 1 {
  4812. insutype = "390"
  4813. }
  4814. if is310 == 1 {
  4815. insutype = "310"
  4816. }
  4817. if len(insutypes) == 0 {
  4818. insutype = "310"
  4819. }
  4820. if len(insutypes) == 2 {
  4821. insutype = med_type
  4822. }
  4823. if len(med_type) > 0 {
  4824. insutype = med_type
  4825. }
  4826. //for _, item := range rf {
  4827. // if item.Insutype == insutype {
  4828. // insuplc_admdvs = item.InsuplcAdmdvs
  4829. // }
  4830. //}
  4831. var infocode int64
  4832. var resThree ResultThree
  4833. var resThree10265 ResultThree10265
  4834. if len(insuplc_admdvs) == 0 {
  4835. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4836. } else {
  4837. insuplc_admdvs_temp = insuplc_admdvs
  4838. }
  4839. if miConfig.MdtrtareaAdmvs == "421300" {
  4840. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4841. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4842. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  4843. resp, requestErr := http.Get(api)
  4844. if requestErr != nil {
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. body, ioErr := ioutil.ReadAll(resp.Body)
  4849. if ioErr != nil {
  4850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4852. return
  4853. }
  4854. var respJSON map[string]interface{}
  4855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4858. return
  4859. }
  4860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4861. result, _ := json.Marshal(respJSON)
  4862. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4863. utils.ErrorLog("解析失败:%v", err)
  4864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4865. return
  4866. }
  4867. infocode = resThree.Infcode
  4868. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4869. psn_info, _ := service.GetPsnByPatientId(id)
  4870. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4871. var cert_no string
  4872. if id_card_type == 3 {
  4873. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4874. cert_no = IdCardNo
  4875. } else if id_card_type == 4 {
  4876. cert_no = IdCardNo
  4877. psn_info.VerifyNumber = psn_info.VerifyNumber
  4878. } else {
  4879. bas := strings.Split(psn_info.CardInfo, "|")
  4880. cert_no = bas[2]
  4881. }
  4882. var api string
  4883. if miConfig.MdtrtareaAdmvs == "320921" {
  4884. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4885. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4886. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4887. } else {
  4888. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4889. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4890. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4891. }
  4892. resp, requestErr := http.Get(api)
  4893. if requestErr != nil {
  4894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4895. return
  4896. }
  4897. body, ioErr := ioutil.ReadAll(resp.Body)
  4898. if ioErr != nil {
  4899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4901. return
  4902. }
  4903. var respJSON map[string]interface{}
  4904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4907. return
  4908. }
  4909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4910. result, _ := json.Marshal(respJSON)
  4911. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4912. utils.ErrorLog("解析失败:%v", err)
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4914. return
  4915. }
  4916. resThree.ErrMsg = resThree10265.ErrMsg
  4917. resThree.Output = resThree10265.Output
  4918. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4919. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4920. } else {
  4921. result, requestLog := service.Gdyb2201ForGz(res.Output[0].Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4922. saveLog(result, requestLog, "2201A", "挂号")
  4923. if miConfig.Code == "H15049901371" {
  4924. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4925. utils.ErrorLog("解析失败:%v", err)
  4926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4927. return
  4928. }
  4929. resThree.ErrMsg = resThree10265.ErrMsg
  4930. resThree.Output = resThree10265.Output
  4931. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4932. } else {
  4933. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4934. utils.ErrorLog("解析失败:%v", err)
  4935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4936. return
  4937. }
  4938. }
  4939. if miConfig.Code == "H15049901371" {
  4940. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4941. } else {
  4942. infocode = resThree.Infcode
  4943. }
  4944. }
  4945. if infocode != 0 {
  4946. adminUser := c.GetAdminUserInfo()
  4947. errlog := &models.HisOrderError{
  4948. UserOrgId: adminUser.CurrentOrgId,
  4949. Ctime: time.Now().Unix(),
  4950. Mtime: time.Now().Unix(),
  4951. ErrMsg: resThree.ErrMsg,
  4952. Status: 1,
  4953. PatientId: id,
  4954. RecordTime: recordDateTime,
  4955. Stage: 2,
  4956. }
  4957. service.CreateErrMsgLog(errlog)
  4958. c.ServeSuccessJSON(map[string]interface{}{
  4959. "failed_code": -10,
  4960. "msg": resThree.ErrMsg,
  4961. })
  4962. return
  4963. }
  4964. his.Number = resThree.Output.Data.MdtrtID
  4965. his.PsnNo = resThree.Output.Data.PsnNo
  4966. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4967. his.IdCardNo = patient.IdCardNo
  4968. his.PhoneNumber = patient.Phone
  4969. his.UserOrgId = adminInfo.CurrentOrgId
  4970. his.Insutype = insutype
  4971. his.Ctime = time.Now().Unix()
  4972. his.Mtime = time.Now().Unix()
  4973. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4974. his.Status = 1
  4975. service.UpdateHisPatientStatus(&his)
  4976. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4977. c.ServeSuccessJSON(map[string]interface{}{
  4978. "his_info": his,
  4979. })
  4980. } else {
  4981. adminUser := c.GetAdminUserInfo()
  4982. errlog := &models.HisOrderError{
  4983. UserOrgId: adminUser.CurrentOrgId,
  4984. Ctime: time.Now().Unix(),
  4985. Mtime: time.Now().Unix(),
  4986. ErrMsg: res.ErrMsg,
  4987. Status: 1,
  4988. PatientId: id,
  4989. RecordTime: recordDateTime,
  4990. Stage: 1,
  4991. }
  4992. service.CreateErrMsgLog(errlog)
  4993. c.ServeSuccessJSON(map[string]interface{}{
  4994. "failed_code": -10,
  4995. "msg": res.ErrMsg,
  4996. })
  4997. return
  4998. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4999. }
  5000. }
  5001. }
  5002. // 上传明细----预结算----确认订单
  5003. func (c *HisApiController) GetUploadInfo() {
  5004. id, _ := c.GetInt64("id")
  5005. record_time := c.GetString("record_time")
  5006. his_patient_id, _ := c.GetInt64("his_patient_id")
  5007. order_id, _ := c.GetInt64("order_id")
  5008. pay_way, _ := c.GetInt64("pay_way")
  5009. pay_price, _ := c.GetFloat("pay_price")
  5010. pay_card_no := c.GetString("pay_card_no")
  5011. token := c.GetString("token")
  5012. discount_price, _ := c.GetFloat("discount_price")
  5013. preferential_price, _ := c.GetFloat("preferential_price")
  5014. reality_price, _ := c.GetFloat("reality_price")
  5015. found_price, _ := c.GetFloat("found_price")
  5016. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5017. private_price, _ := c.GetFloat("private_price")
  5018. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5019. admin_user_id, _ := c.GetInt64("admin_user_id")
  5020. fapiao_code := c.GetString("fapiao_code")
  5021. fapiao_number := c.GetString("fapiao_number")
  5022. pack_num, _ := c.GetInt64("pack_num")
  5023. good_pack_num, _ := c.GetInt64("good_pack_num")
  5024. diagnosis_id := c.GetString("diagnosis")
  5025. sick_type, _ := c.GetInt64("sick_type")
  5026. reg_type, _ := c.GetInt64("p_type")
  5027. begin_time := c.GetString("begin_time")
  5028. id_str := c.GetString("ids")
  5029. ids_arr := strings.Split(id_str, ",")
  5030. timeLayout := "2006-01-02"
  5031. loc, _ := time.LoadLocation("Local")
  5032. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5033. if err != nil {
  5034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5035. return
  5036. }
  5037. recordDateTime := theTime.Unix()
  5038. adminUser := c.GetAdminUserInfo()
  5039. var tempOrder models.HisOrder
  5040. tempOrder, _ = service.GetHisOrderByID(order_id)
  5041. var prescriptions []*models.HisPrescription
  5042. var start_time int64
  5043. var end_time int64
  5044. //押金模块
  5045. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5046. tmp_decimal := c.GetString("tmp_decimal")
  5047. var decimal float64 //本次使用的押金
  5048. var errmsg error
  5049. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5050. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5051. return
  5052. }
  5053. if len(tmp_decimal) > 0 {
  5054. if tmp_decimal[0] == 45 {
  5055. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5056. return
  5057. }
  5058. }
  5059. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5060. fmt.Println(errs)
  5061. decimal = tt
  5062. //if adminUser.CurrentOrgId == 10106{
  5063. // if len(fapiao_code) == 0{
  5064. // fapiao_code = "144072080589"
  5065. // }
  5066. // if len(fapiao_number) == 0{
  5067. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5068. // if order.ID == 0{
  5069. // fapiao_number = "00001520"
  5070. // }else{
  5071. // //fapiao_code = "00001520"
  5072. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5073. // var zero string
  5074. // if fpNumber >= 1000{
  5075. // zero = "0000" + strconv.Itoa(fpNumber)
  5076. // }else if fpNumber >= 10000{
  5077. // zero = "000" + strconv.Itoa(fpNumber)
  5078. // } else if fpNumber >= 100000{
  5079. // zero = "00" + strconv.Itoa(fpNumber)
  5080. // } else if fpNumber >= 1000000{
  5081. // zero = "0" + strconv.Itoa(fpNumber)
  5082. // }else {
  5083. // zero = strconv.Itoa(fpNumber)
  5084. // }
  5085. // fapiao_number = zero
  5086. // }
  5087. // }
  5088. //}
  5089. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5090. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5091. var patientPrescription models.HisPrescriptionInfo
  5092. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5093. if patientPrescription.ID == 0 {
  5094. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5095. }
  5096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5097. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5098. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5099. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5100. var config []*models.HisXtDiagnoseConfig
  5101. for _, item := range diagnosis_ids {
  5102. id, _ := strconv.ParseInt(item, 10, 64)
  5103. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5104. config = append(config, &diagnosisConfig)
  5105. }
  5106. sickConfig, _ := service.FindSickById(sick_type)
  5107. //if tempOrder.ID == 0 {
  5108. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5109. //}
  5110. if tempOrder.ID == 0 {
  5111. var result string
  5112. var requestLog string
  5113. var res2 ResultSix
  5114. var ressix10265 ResultSix10265
  5115. if miConfig.MdtrtareaAdmvs == "421300" {
  5116. data := make(map[string]interface{})
  5117. client := &http.Client{}
  5118. data["psn_no"] = his.PsnNo
  5119. data["mdtrt_id"] = his.Number
  5120. data["doctor"] = roles.UserName
  5121. data["department"] = department.Name
  5122. data["org_name"] = miConfig.OrgName
  5123. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5124. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5125. data["fixmedins_code"] = miConfig.Code
  5126. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5127. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5128. data["secret_key"] = miConfig.SecretKey
  5129. data["sick_code"] = sickConfig.CountryCode
  5130. data["sick_name"] = sickConfig.ClassName
  5131. data["dept"] = strconv.FormatInt(department.ID, 10)
  5132. data["config"] = config
  5133. data["begin_time"] = begin_time
  5134. bytesData, _ := json.Marshal(data)
  5135. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5136. resp, _ := client.Do(req)
  5137. defer resp.Body.Close()
  5138. body, ioErr := ioutil.ReadAll(resp.Body)
  5139. if ioErr != nil {
  5140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5142. return
  5143. }
  5144. var respJSON map[string]interface{}
  5145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5148. return
  5149. }
  5150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5151. userJSONBytes, _ := json.Marshal(respJSON)
  5152. fmt.Println("log")
  5153. fmt.Println(string(userJSONBytes))
  5154. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5155. utils.ErrorLog("解析失败:%v", err)
  5156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5157. return
  5158. }
  5159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5160. //江苏地区国家医保医疗类别
  5161. //职工透析:医疗类别选特殊情况门诊9933
  5162. //居民血透门慢: 医疗类别选门诊慢病1402
  5163. //var med_type string
  5164. //if his.Insutype == "310" {
  5165. // if reg_type == 14 {
  5166. // med_type = "9933"
  5167. // } else if reg_type == 11 {
  5168. // med_type = "11"
  5169. //
  5170. // }
  5171. //} else if his.Insutype == "390" {
  5172. // if reg_type == 14 {
  5173. // med_type = "1402"
  5174. // } else if reg_type == 11 {
  5175. // med_type = "11"
  5176. // }
  5177. //}
  5178. data := make(map[string]interface{})
  5179. client := &http.Client{}
  5180. data["psn_no"] = his.PsnNo
  5181. data["mdtrt_id"] = his.Number
  5182. data["doctor"] = roles.UserName
  5183. data["department"] = department.Name
  5184. data["org_name"] = miConfig.OrgName
  5185. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5186. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5187. data["fixmedins_code"] = miConfig.Code
  5188. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5189. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5190. data["secret_key"] = miConfig.SecretKey
  5191. data["sick_code"] = sickConfig.CountryCode
  5192. data["sick_name"] = sickConfig.ClassName
  5193. data["url"] = miConfig.Url
  5194. data["ak"] = miConfig.AccessKey
  5195. data["begin_time"] = begin_time
  5196. data["cainfo"] = miConfig.Cainfo
  5197. data["dept"] = strconv.FormatInt(department.ID, 10)
  5198. data["config"] = config
  5199. bytesData, _ := json.Marshal(data)
  5200. var req *http.Request
  5201. if miConfig.MdtrtareaAdmvs == "320921" {
  5202. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5203. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5204. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5205. } else {
  5206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5207. }
  5208. resp, _ := client.Do(req)
  5209. defer resp.Body.Close()
  5210. body, ioErr := ioutil.ReadAll(resp.Body)
  5211. if ioErr != nil {
  5212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5214. return
  5215. }
  5216. var respJSON map[string]interface{}
  5217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5220. return
  5221. }
  5222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5223. userJSONBytes, _ := json.Marshal(respJSON)
  5224. fmt.Println("log")
  5225. fmt.Println(string(userJSONBytes))
  5226. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5227. utils.ErrorLog("解析失败:%v", err)
  5228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5229. return
  5230. }
  5231. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5232. // res2.Output = ressix10265.Output
  5233. res2.ErrMsg = ressix10265.ErrMsg
  5234. res2.Cainfo = ressix10265.Cainfo
  5235. res2.WarnMsg = ressix10265.WarnMsg
  5236. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5237. res2.Infcode = infocode
  5238. } else {
  5239. if miConfig.MdtrtareaAdmvs == "440781" { //
  5240. result, requestLog = service.Gdyb2203ForGz(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)
  5241. } else {
  5242. if miConfig.Code == "H15049901371" {
  5243. //赤峰地区国家医保医疗类别
  5244. //职工透析:医疗类别选特殊情况门诊990502
  5245. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5246. var med_type string
  5247. if his.Insutype == "390" {
  5248. if reg_type == 14 {
  5249. med_type = "9933"
  5250. } else if reg_type == 11 {
  5251. med_type = "11"
  5252. }
  5253. } else if his.Insutype == "310" {
  5254. if reg_type == 14 {
  5255. med_type = "990502"
  5256. } else if reg_type == 11 {
  5257. med_type = "11"
  5258. }
  5259. }
  5260. result, requestLog = service.Gdyb2203ForGz(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)
  5261. } else {
  5262. var med_type string
  5263. if reg_type == 14 {
  5264. med_type = "141009"
  5265. result, requestLog = service.Gdyb2203ForGz(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)
  5266. } else if reg_type == 11 {
  5267. med_type = "11"
  5268. // sickConfig.ClassName = sic
  5269. // sickConfig.ContentCode = ""
  5270. result, requestLog = service.Gdyb2203ForGz(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, "", roles.UserName, config, begin_time)
  5271. }
  5272. }
  5273. }
  5274. saveLog(result, requestLog, "2203", "上传就诊信息")
  5275. var respJSON2 map[string]interface{}
  5276. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5279. return
  5280. }
  5281. userJSONBytes2, _ := json.Marshal(respJSON2)
  5282. if miConfig.Code == "H15049901371" {
  5283. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5284. utils.ErrorLog("解析失败:%v", err)
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5286. return
  5287. }
  5288. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5289. // res2.Output = ressix10265.Output
  5290. res2.ErrMsg = ressix10265.ErrMsg
  5291. res2.Cainfo = ressix10265.Cainfo
  5292. res2.WarnMsg = ressix10265.WarnMsg
  5293. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5294. res2.Infcode = infocode
  5295. } else {
  5296. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5297. utils.ErrorLog("解析失败:%v", err)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. }
  5302. }
  5303. if res2.Infcode != 0 {
  5304. adminUser := c.GetAdminUserInfo()
  5305. errlog := &models.HisOrderError{
  5306. UserOrgId: adminUser.CurrentOrgId,
  5307. Ctime: time.Now().Unix(),
  5308. Mtime: time.Now().Unix(),
  5309. ErrMsg: res2.ErrMsg,
  5310. Status: 1,
  5311. PatientId: id,
  5312. RecordTime: recordDateTime,
  5313. Stage: 3,
  5314. }
  5315. service.CreateErrMsgLog(errlog)
  5316. c.ServeSuccessJSON(map[string]interface{}{
  5317. "failed_code": -10,
  5318. "msg": res2.ErrMsg,
  5319. })
  5320. return
  5321. } else {
  5322. his.Diagnosis = diagnosis_id
  5323. his.SickType = sickConfig.ID
  5324. //var p_type int64
  5325. //if reg_type == 1111 || reg_type == 1112 {
  5326. // p_type = 11
  5327. //
  5328. //}
  5329. his.PType = fmt.Sprintf("%d", reg_type)
  5330. service.UpdateHisPatientThree(&his)
  5331. data := make(map[string]interface{})
  5332. if settle_accounts_type == 1 { //日结
  5333. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5334. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5335. } else {
  5336. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5337. }
  5338. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5339. data["pre"] = prescriptions
  5340. } else { //月结
  5341. start_time_str := c.GetString("start_time")
  5342. end_time_str := c.GetString("end_time")
  5343. timeLayout := "2006-01-02"
  5344. loc, _ := time.LoadLocation("Local")
  5345. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5346. if err != nil {
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5348. return
  5349. }
  5350. recordStartTime := theStartTime.Unix()
  5351. start_time = recordStartTime
  5352. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5353. if err != nil {
  5354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5355. return
  5356. }
  5357. recordEndTime := theEndTime.Unix()
  5358. end_time = recordEndTime
  5359. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5360. data["pre"] = prescriptions
  5361. }
  5362. timestamp := time.Now().Unix()
  5363. tempTime := time.Unix(timestamp, 0)
  5364. timeFormat := tempTime.Format("20060102150405")
  5365. chrgBchno := rand.Intn(100000) + 10000
  5366. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5367. strconv.FormatInt(his.PatientId, 10)
  5368. client := &http.Client{}
  5369. data["psn_no"] = his.PsnNo
  5370. data["mdtrt_id"] = his.Number
  5371. data["chrg_bchno"] = chrg_bchno
  5372. data["org_name"] = miConfig.OrgName
  5373. data["doctor"] = roles.UserName
  5374. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5375. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5376. data["fixmedins_code"] = miConfig.Code
  5377. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5378. // data["dept_code"] = "15"
  5379. //} else {
  5380. data["dept_code"] = department.Number
  5381. //}
  5382. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5383. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5384. data["secret_key"] = miConfig.SecretKey
  5385. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5386. data["url"] = miConfig.Url
  5387. data["ak"] = miConfig.AccessKey
  5388. data["new_doctor_name"] = patientPrescription.Doctor
  5389. data["diag_code"] = sickConfig.CountryCode
  5390. data["cainfo"] = miConfig.Cainfo
  5391. var ids []int64
  5392. for _, item := range prescriptions {
  5393. ids = append(ids, item.ID)
  5394. }
  5395. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5396. if config.IsOpen == 1 { //对接了医保,走医保流程
  5397. var res ResultFour
  5398. var resFour10265 ResultFour10265
  5399. if miConfig.MdtrtareaAdmvs == "421300" {
  5400. bytesData, _ := json.Marshal(data)
  5401. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5402. resp, _ := client.Do(req)
  5403. defer resp.Body.Close()
  5404. body, ioErr := ioutil.ReadAll(resp.Body)
  5405. if ioErr != nil {
  5406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. var respJSON map[string]interface{}
  5411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5417. userJSONBytes, _ := json.Marshal(respJSON)
  5418. fmt.Println("log")
  5419. fmt.Println(string(userJSONBytes))
  5420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5421. utils.ErrorLog("解析失败:%v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5426. bytesData, _ := json.Marshal(data)
  5427. var req *http.Request
  5428. if miConfig.MdtrtareaAdmvs == "320921" {
  5429. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5430. } else {
  5431. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5432. }
  5433. resp, _ := client.Do(req)
  5434. defer resp.Body.Close()
  5435. body, ioErr := ioutil.ReadAll(resp.Body)
  5436. if ioErr != nil {
  5437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. var respJSON map[string]interface{}
  5442. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5448. userJSONBytes, _ := json.Marshal(respJSON)
  5449. fmt.Println("log")
  5450. fmt.Println(string(userJSONBytes))
  5451. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5452. utils.ErrorLog("解析失败:%v", err)
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5454. return
  5455. }
  5456. res.InfRefmsgid = resFour10265.InfRefmsgid
  5457. res.Output = resFour10265.Output
  5458. res.ErrMsg = resFour10265.ErrMsg
  5459. res.Cainfo = resFour10265.Cainfo
  5460. res.WarnMsg = resFour10265.WarnMsg
  5461. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5462. res.Infcode = infocode
  5463. } else {
  5464. if miConfig.Code == "H15049901371" {
  5465. 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)
  5466. var dat map[string]interface{}
  5467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5468. fmt.Println(dat)
  5469. } else {
  5470. fmt.Println(err)
  5471. }
  5472. saveLog(result, request_log, "2204", "上传费用明细")
  5473. userJSONBytes, _ := json.Marshal(dat)
  5474. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5475. utils.ErrorLog("解析失败:%v", err)
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5477. return
  5478. }
  5479. res.InfRefmsgid = resFour10265.InfRefmsgid
  5480. res.Output = resFour10265.Output
  5481. res.ErrMsg = resFour10265.ErrMsg
  5482. res.Cainfo = resFour10265.Cainfo
  5483. res.WarnMsg = resFour10265.WarnMsg
  5484. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5485. res.Infcode = infocode
  5486. } else {
  5487. 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)
  5488. var dat map[string]interface{}
  5489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5490. fmt.Println(dat)
  5491. } else {
  5492. fmt.Println(err)
  5493. }
  5494. saveLog(result, request_log, "2204", "上传费用明细")
  5495. userJSONBytes, _ := json.Marshal(dat)
  5496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5497. utils.ErrorLog("解析失败:%v", err)
  5498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5499. return
  5500. }
  5501. }
  5502. }
  5503. if res.Infcode == 0 {
  5504. order := &models.HisOrder{
  5505. UserOrgId: adminUser.CurrentOrgId,
  5506. HisPatientId: his.ID,
  5507. PatientId: his.PatientId,
  5508. SettleAccountsDate: recordDateTime,
  5509. MdtrtId: his.Number,
  5510. PsnNo: his.PsnNo,
  5511. MedType: strconv.FormatInt(reg_type, 10),
  5512. Ctime: time.Now().Unix(),
  5513. Mtime: time.Now().Unix(),
  5514. Status: 1,
  5515. Number: chrg_bchno,
  5516. Infcode: res.Infcode,
  5517. WarnMsg: res.WarnMsg,
  5518. Cainfo: res.Cainfo,
  5519. ErrMsg: res.ErrMsg,
  5520. RespondTime: res.RefmsgTime,
  5521. InfRefmsgid: res.InfRefmsgid,
  5522. OrderStatus: 1,
  5523. PayWay: pay_way,
  5524. PayPrice: pay_price,
  5525. PayCardNo: pay_card_no,
  5526. DiscountPrice: discount_price,
  5527. PreferentialPrice: preferential_price,
  5528. RealityPrice: reality_price,
  5529. FoundPrice: found_price,
  5530. MedicalInsurancePrice: medical_insurance_price,
  5531. PrivatePrice: private_price,
  5532. IsMedicineInsurance: 1,
  5533. SettleType: settle_accounts_type,
  5534. SettleStartTime: start_time,
  5535. SettleEndTime: end_time,
  5536. Creator: roles.AdminUserId,
  5537. Modify: roles.AdminUserId,
  5538. FaPiaoNumber: fapiao_number,
  5539. FaPiaoCode: fapiao_code,
  5540. PType: 2,
  5541. Diagnosis: diagnosis_id,
  5542. }
  5543. err = service.CreateOrder(order)
  5544. if err != nil {
  5545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5546. return
  5547. }
  5548. for _, item := range res.Output.Result {
  5549. temp := strings.Split(item.FeedetlSn, "-")
  5550. var advice_id int64 = 0
  5551. var project_id int64 = 0
  5552. var types int64 = 0
  5553. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5554. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5555. if temp[1] == "1" {
  5556. advice_id = id
  5557. project_id = 0
  5558. } else if temp[1] == "2" {
  5559. advice_id = 0
  5560. project_id = id
  5561. }
  5562. info := &models.HisOrderInfo{
  5563. OrderNumber: order.Number,
  5564. FeedetlSn: item.FeedetlSn,
  5565. UploadDate: time.Now().Unix(),
  5566. AdviceId: advice_id,
  5567. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5568. Cnt: item.Cnt,
  5569. Pric: float64(item.Pric),
  5570. PatientId: his.PatientId,
  5571. PricUplmtAmt: item.PricUplmtAmt,
  5572. SelfpayProp: item.SelfpayProp,
  5573. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5574. OverlmtAmt: item.OverlmtAmt,
  5575. PreselfpayAmt: item.PreselfpayAmt,
  5576. BasMednFlag: item.BasMednFlag,
  5577. MedChrgitmType: item.MedChrgitmType,
  5578. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5579. Status: 1,
  5580. Memo: item.Memo,
  5581. Mtime: time.Now().Unix(),
  5582. InscpScpAmt: item.InscpScpAmt,
  5583. DrtReimFlag: item.DrtReimFlag,
  5584. Ctime: time.Now().Unix(),
  5585. ListSpItemFlag: item.ListSpItemFlag,
  5586. ChldMedcFlag: item.ChldMedcFlag,
  5587. LmtUsedFlag: item.LmtUsedFlag,
  5588. ChrgitmLv: item.ChrgitmLv,
  5589. UserOrgId: adminUser.CurrentOrgId,
  5590. HisPatientId: his.ID,
  5591. OrderId: order.ID,
  5592. ProjectId: project_id,
  5593. Type: types,
  5594. }
  5595. service.CreateOrderInfo(info)
  5596. }
  5597. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5598. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5599. var total float64
  5600. for _, item := range prescriptions {
  5601. if item.Type == 1 { //药品
  5602. for _, subItem := range item.HisDoctorAdviceInfo {
  5603. total = total + (subItem.Price * subItem.PrescribingNumber)
  5604. }
  5605. }
  5606. if item.Type == 2 { //项目
  5607. for _, subItem := range item.HisPrescriptionProject {
  5608. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5609. total = total + (subItem.Price * cnt)
  5610. }
  5611. }
  5612. }
  5613. for _, item := range prescriptions {
  5614. for _, subItem := range item.HisAdditionalCharge {
  5615. total = total + (subItem.Price * float64(subItem.Count))
  5616. }
  5617. }
  5618. var allTotal string
  5619. if adminUser.CurrentOrgId == 9919 {
  5620. allTotal = fmt.Sprintf("%.4f", total)
  5621. } else {
  5622. allTotal = fmt.Sprintf("%.4f", total)
  5623. }
  5624. if res.Infcode == 0 {
  5625. var rf []*ResultFive
  5626. json.Unmarshal([]byte(his.Iinfo), &rf)
  5627. chrg_bchno := chrg_bchno
  5628. cert_no := his.Certno
  5629. var insutypes []string
  5630. var insutype string
  5631. var is390 int = 0
  5632. var is310 int = 0
  5633. for _, item := range rf {
  5634. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5635. insutypes = append(insutypes, item.Insutype)
  5636. }
  5637. }
  5638. if len(insutypes) == 1 {
  5639. insutype = insutypes[0]
  5640. } else {
  5641. for _, i := range insutypes {
  5642. if i == "390" {
  5643. is390 = 1
  5644. }
  5645. if i == "310" {
  5646. is310 = 1
  5647. }
  5648. }
  5649. }
  5650. if is390 == 1 {
  5651. insutype = "390"
  5652. }
  5653. if is310 == 1 {
  5654. insutype = "310"
  5655. }
  5656. if len(insutypes) == 0 {
  5657. insutype = "310"
  5658. }
  5659. if len(insutypes) == 2 {
  5660. insutype = strconv.FormatInt(his.SocialType, 10)
  5661. }
  5662. insutype = strconv.FormatInt(his.SocialType, 10)
  5663. //insutype = "390"
  5664. if his.IdCardType == 1 {
  5665. // cert_no = his.MedicalInsuranceNumber
  5666. cert_no = his.Certno
  5667. } else {
  5668. cert_no = his.Certno
  5669. }
  5670. var res models.GZResult2207
  5671. var resSeven10265 ResultSeven10265
  5672. var src_resquest string
  5673. var result2 string
  5674. var acct_used_flag string
  5675. fmt.Println("pay_way")
  5676. fmt.Println(pay_way)
  5677. fmt.Println("pay_way")
  5678. if pay_way == 5 {
  5679. acct_used_flag = "1"
  5680. } else {
  5681. acct_used_flag = "0"
  5682. }
  5683. if miConfig.MdtrtareaAdmvs == "421300" {
  5684. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5685. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5686. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5687. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5688. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5689. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5690. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5691. resp, requestErr := http.Get(api)
  5692. if requestErr != nil {
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. return
  5695. }
  5696. body, ioErr := ioutil.ReadAll(resp.Body)
  5697. if ioErr != nil {
  5698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5700. return
  5701. }
  5702. var respJSON map[string]interface{}
  5703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5706. return
  5707. }
  5708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5709. result, _ := json.Marshal(respJSON)
  5710. if miConfig.Code == "H15049901371" {
  5711. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5712. utils.ErrorLog("解析失败:%v", err)
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. return
  5715. }
  5716. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5717. // res.Output = resSeven10265.Output
  5718. res.ErrMsg = resSeven10265.ErrMsg
  5719. res.Cainfo = resSeven10265.Cainfo
  5720. // res.WarnMsg = resSeven10265.WarnMsg
  5721. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5722. // res.Infcode = infocode
  5723. } else {
  5724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5725. utils.ErrorLog("解析失败:%v", err)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. }
  5730. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5731. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5732. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5733. bas := strings.Split(psn_info.CardInfo, "|")
  5734. if his.IdCardType == 1 {
  5735. cert_no = bas[2]
  5736. } else if his.IdCardType == 3 {
  5737. cert_no = his.Certno
  5738. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5739. } else if his.IdCardType == 4 {
  5740. cert_no = his.Certno
  5741. psn_info.VerifyNumber = token
  5742. }
  5743. var api string
  5744. if miConfig.MdtrtareaAdmvs == "320921" {
  5745. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5746. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5747. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5749. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5750. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5751. "&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
  5752. } else {
  5753. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5754. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5755. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5756. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5757. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5758. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5759. "&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
  5760. }
  5761. resp, requestErr := http.Get(api)
  5762. if requestErr != nil {
  5763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5764. return
  5765. }
  5766. body, ioErr := ioutil.ReadAll(resp.Body)
  5767. if ioErr != nil {
  5768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5770. return
  5771. }
  5772. var respJSON map[string]interface{}
  5773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5776. return
  5777. }
  5778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5779. result, _ := json.Marshal(respJSON)
  5780. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5781. utils.ErrorLog("解析失败:%v", err)
  5782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5783. return
  5784. }
  5785. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5786. // res.Output = resSeven10265.Output
  5787. res.ErrMsg = resSeven10265.ErrMsg
  5788. res.Cainfo = resSeven10265.Cainfo
  5789. // res.WarnMsg = resSeven10265.WarnMsg
  5790. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5791. // res.Infcode = infocode
  5792. } else {
  5793. if miConfig.Code == "H15049901371" {
  5794. //赤峰地区国家医保医疗类别
  5795. //职工透析:医疗类别选特殊情况门诊990502
  5796. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5797. var med_type string
  5798. if his.Insutype == "390" {
  5799. if reg_type == 14 {
  5800. med_type = "9933"
  5801. } else if reg_type == 11 {
  5802. med_type = "11"
  5803. }
  5804. } else if his.Insutype == "310" {
  5805. if reg_type == 14 {
  5806. med_type = "990502"
  5807. } else if reg_type == 11 {
  5808. med_type = "11"
  5809. }
  5810. }
  5811. 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, pack_num, good_pack_num)
  5812. } else {
  5813. var med_type string
  5814. if reg_type == 14 {
  5815. med_type = "141009"
  5816. } else if reg_type == 11 {
  5817. med_type = "11"
  5818. }
  5819. 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, pack_num, good_pack_num)
  5820. }
  5821. //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)
  5822. var dat map[string]interface{}
  5823. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5824. fmt.Println(dat)
  5825. } else {
  5826. fmt.Println(err)
  5827. }
  5828. saveLog(result2, src_resquest, "2207", "结算")
  5829. userJSONBytes, _ := json.Marshal(dat)
  5830. if miConfig.Code == "H15049901371" {
  5831. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5832. utils.ErrorLog("解析失败:%v", err)
  5833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5834. return
  5835. }
  5836. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5837. // res.Output = resSeven10265.Output
  5838. res.ErrMsg = resSeven10265.ErrMsg
  5839. res.Cainfo = resSeven10265.Cainfo
  5840. // res.WarnMsg = resSeven10265.WarnMsg
  5841. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5842. // res.Infcode = infocode
  5843. } else {
  5844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5845. utils.ErrorLog("解析失败:%v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. }
  5850. }
  5851. if res.Infcode != 0 {
  5852. errlog := &models.HisOrderError{
  5853. UserOrgId: adminUser.CurrentOrgId,
  5854. Ctime: time.Now().Unix(),
  5855. Mtime: time.Now().Unix(),
  5856. Number: chrg_bchno,
  5857. ErrMsg: res.ErrMsg,
  5858. Status: 1,
  5859. PatientId: id,
  5860. RecordTime: recordDateTime,
  5861. Stage: 6,
  5862. }
  5863. service.CreateErrMsgLog(errlog)
  5864. c.ServeSuccessJSON(map[string]interface{}{
  5865. "failed_code": -10,
  5866. "msg": res.ErrMsg,
  5867. })
  5868. return
  5869. } else {
  5870. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5871. order.OrderStatus = 2
  5872. order.Status = 1
  5873. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5874. order.SetlId = res.Output.Setlinfo.SetlID
  5875. order.PsnNo = res.Output.Setlinfo.PsnNo
  5876. order.PsnName = res.Output.Setlinfo.PsnName
  5877. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5878. order.Certno = res.Output.Setlinfo.Certno
  5879. order.Gend = res.Output.Setlinfo.Gend
  5880. order.Naty = res.Output.Setlinfo.Naty
  5881. order.Age = res.Output.Setlinfo.Age
  5882. order.Insutype = res.Output.Setlinfo.Insutype
  5883. order.PsnType = res.Output.Setlinfo.PsnType
  5884. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5885. order.SetlTime = res.Output.Setlinfo.SetlTime
  5886. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5887. if res.Output.Setlinfo.MedType == "140101" {
  5888. order.MedType = "14"
  5889. } else {
  5890. order.MedType = res.Output.Setlinfo.MedType
  5891. }
  5892. if reg_type == 1112 {
  5893. order.MedType = "1112"
  5894. }
  5895. if reg_type == 1111 {
  5896. order.MedType = "1111"
  5897. }
  5898. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5899. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5900. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5901. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5902. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5903. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5904. order.HifpPay = res.Output.Setlinfo.HifpPay
  5905. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5906. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5907. order.HifesPay = res.Output.Setlinfo.HifesPay
  5908. order.HifobPay = res.Output.Setlinfo.HifobPay
  5909. order.MafPay = res.Output.Setlinfo.MafPay
  5910. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5911. order.OthPay = res.Output.Setlinfo.OthPay
  5912. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5913. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5914. order.AcctPay = res.Output.Setlinfo.AcctPay
  5915. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5916. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5917. order.Balc = res.Output.Setlinfo.Balc
  5918. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5919. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5920. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5921. order.ClrType = res.Output.Setlinfo.ClrType
  5922. order.ClrWay = res.Output.Setlinfo.ClrWay
  5923. order.Creator = order.Creator
  5924. order.Modify = roles.AdminUserId
  5925. order.RequestLog = src_resquest
  5926. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5927. detailStr := string(setlDetail)
  5928. order.SetlDetail = detailStr
  5929. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5930. err = service.UpDateOrder(order)
  5931. if err == nil {
  5932. //判断是否使用了押金
  5933. if dec_way == "true" {
  5934. tmpstring := strconv.FormatInt(order.ID, 10)
  5935. order.Decimal = decimal
  5936. service.UpDateOrder(order)
  5937. //扣押金
  5938. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5939. if errmsg != nil {
  5940. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5941. return
  5942. }
  5943. }
  5944. c.ServeSuccessJSON(map[string]interface{}{
  5945. "msg": "结算成功",
  5946. })
  5947. } else {
  5948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5949. return
  5950. }
  5951. }
  5952. } else {
  5953. adminUser := c.GetAdminUserInfo()
  5954. errlog := &models.HisOrderError{
  5955. UserOrgId: adminUser.CurrentOrgId,
  5956. Ctime: time.Now().Unix(),
  5957. Mtime: time.Now().Unix(),
  5958. ErrMsg: res.ErrMsg,
  5959. Status: 1,
  5960. PatientId: id,
  5961. RecordTime: recordDateTime,
  5962. Stage: 4,
  5963. }
  5964. service.CreateErrMsgLog(errlog)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5966. return
  5967. }
  5968. } else {
  5969. adminUser := c.GetAdminUserInfo()
  5970. errlog := &models.HisOrderError{
  5971. UserOrgId: adminUser.CurrentOrgId,
  5972. Ctime: time.Now().Unix(),
  5973. Mtime: time.Now().Unix(),
  5974. ErrMsg: res.ErrMsg,
  5975. Status: 1,
  5976. PatientId: id,
  5977. RecordTime: recordDateTime,
  5978. Stage: 4,
  5979. }
  5980. service.CreateErrMsgLog(errlog)
  5981. c.ServeSuccessJSON(map[string]interface{}{
  5982. "failed_code": -10,
  5983. "msg": res.ErrMsg,
  5984. })
  5985. return
  5986. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5987. //return
  5988. }
  5989. }
  5990. }
  5991. } else if tempOrder.ID > 0 {
  5992. if tempOrder.IsPre == 1 {
  5993. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5994. var rf []*ResultFive
  5995. json.Unmarshal([]byte(his.Iinfo), &rf)
  5996. chrg_bchno := tempOrder.Number
  5997. cert_no := his.Certno
  5998. var insutypes []string
  5999. var insutype string
  6000. var is390 int = 0
  6001. var is310 int = 0
  6002. for _, item := range rf {
  6003. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6004. insutypes = append(insutypes, item.Insutype)
  6005. }
  6006. }
  6007. if len(insutypes) == 1 {
  6008. insutype = insutypes[0]
  6009. } else {
  6010. for _, i := range insutypes {
  6011. if i == "390" {
  6012. is390 = 1
  6013. }
  6014. if i == "310" {
  6015. is310 = 1
  6016. }
  6017. }
  6018. }
  6019. if is390 == 1 {
  6020. insutype = "390"
  6021. }
  6022. if is310 == 1 {
  6023. insutype = "310"
  6024. }
  6025. if len(insutypes) == 0 {
  6026. insutype = "310"
  6027. }
  6028. if len(insutypes) == 2 {
  6029. insutype = strconv.FormatInt(his.SocialType, 64)
  6030. }
  6031. //insutype = "390"
  6032. if his.IdCardType == 1 {
  6033. // cert_no = his.MedicalInsuranceNumber
  6034. cert_no = his.Certno
  6035. } else {
  6036. cert_no = his.Certno
  6037. }
  6038. var res ResultSeven
  6039. var resSeven10265 ResultSeven10265
  6040. var src_resquest string
  6041. var result2 string
  6042. var acct_used_flag string
  6043. fmt.Println("pay_way")
  6044. fmt.Println(pay_way)
  6045. fmt.Println("pay_way")
  6046. if pay_way == 5 {
  6047. acct_used_flag = "1"
  6048. } else {
  6049. acct_used_flag = "0"
  6050. }
  6051. if miConfig.MdtrtareaAdmvs == "421300" {
  6052. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6053. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6054. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6055. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6056. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6057. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6058. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6059. resp, requestErr := http.Get(api)
  6060. if requestErr != nil {
  6061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6062. return
  6063. }
  6064. body, ioErr := ioutil.ReadAll(resp.Body)
  6065. if ioErr != nil {
  6066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6068. return
  6069. }
  6070. var respJSON map[string]interface{}
  6071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6074. return
  6075. }
  6076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6077. result, _ := json.Marshal(respJSON)
  6078. fmt.Println("log")
  6079. fmt.Println(string(result))
  6080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6081. utils.ErrorLog("解析失败:%v", err)
  6082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6083. return
  6084. }
  6085. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6086. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6087. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6088. //psn_info, _ := service.GetPsnByPatientId(id)
  6089. bas := strings.Split(psn_info.CardInfo, "|")
  6090. if his.IdCardType == 1 {
  6091. cert_no = bas[2]
  6092. } else {
  6093. cert_no = bas[1]
  6094. }
  6095. //江苏地区国家医保医疗类别
  6096. //职工透析:医疗类别选特殊情况门诊9933
  6097. //居民血透门慢: 医疗类别选门诊慢病1402
  6098. //var med_type string
  6099. //if his.Insutype == "310" {
  6100. // if reg_type == 14 {
  6101. // med_type = "9933"
  6102. // } else if reg_type == 11 {
  6103. // med_type = "11"
  6104. //
  6105. // }
  6106. //} else if his.Insutype == "390" {
  6107. // if reg_type == 14 {
  6108. // med_type = "1402"
  6109. // } else if reg_type == 11 {
  6110. // med_type = "11"
  6111. // }
  6112. //}
  6113. var api string
  6114. if miConfig.MdtrtareaAdmvs == "320921" {
  6115. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6116. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6117. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6119. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6120. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6121. "&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
  6122. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6123. } else {
  6124. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6125. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6126. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6127. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6129. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6130. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6131. "&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
  6132. }
  6133. resp, requestErr := http.Get(api)
  6134. if requestErr != nil {
  6135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6136. return
  6137. }
  6138. body, ioErr := ioutil.ReadAll(resp.Body)
  6139. if ioErr != nil {
  6140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6142. return
  6143. }
  6144. var respJSON map[string]interface{}
  6145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6148. return
  6149. }
  6150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6151. result, _ := json.Marshal(respJSON)
  6152. fmt.Println("log")
  6153. fmt.Println(string(result))
  6154. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6155. utils.ErrorLog("解析失败:%v", err)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6160. res.Output = resSeven10265.Output
  6161. res.ErrMsg = resSeven10265.ErrMsg
  6162. res.Cainfo = resSeven10265.Cainfo
  6163. res.WarnMsg = resSeven10265.WarnMsg
  6164. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6165. res.Infcode = infocode
  6166. } else {
  6167. var src_resquest string
  6168. if miConfig.Code == "H15049901371" {
  6169. //赤峰地区国家医保医疗类别
  6170. //职工透析:医疗类别选特殊情况门诊990502
  6171. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6172. var med_type string
  6173. if his.Insutype == "390" {
  6174. if reg_type == 14 {
  6175. med_type = "9933"
  6176. } else if reg_type == 11 {
  6177. med_type = "11"
  6178. }
  6179. } else if his.Insutype == "310" {
  6180. if reg_type == 14 {
  6181. med_type = "990502"
  6182. } else if reg_type == 11 {
  6183. med_type = "11"
  6184. }
  6185. }
  6186. 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)
  6187. } else {
  6188. var med_type string
  6189. if reg_type == 14 {
  6190. med_type = "14"
  6191. } else if reg_type == 11 {
  6192. med_type = "11"
  6193. }
  6194. result2, src_resquest = service.Gdyb2207ForGz(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)
  6195. }
  6196. var dat map[string]interface{}
  6197. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6198. fmt.Println(dat)
  6199. } else {
  6200. fmt.Println(err)
  6201. }
  6202. saveLog(result2, src_resquest, "2207", "结算")
  6203. userJSONBytes, _ := json.Marshal(dat)
  6204. if miConfig.Code == "H15049901371" {
  6205. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6206. utils.ErrorLog("解析失败:%v", err)
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. return
  6209. }
  6210. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6211. res.Output = resSeven10265.Output
  6212. res.ErrMsg = resSeven10265.ErrMsg
  6213. res.Cainfo = resSeven10265.Cainfo
  6214. res.WarnMsg = resSeven10265.WarnMsg
  6215. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6216. res.Infcode = infocode
  6217. } else {
  6218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6219. utils.ErrorLog("解析失败:%v", err)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. return
  6222. }
  6223. }
  6224. }
  6225. if res.Infcode != 0 {
  6226. errlog := &models.HisOrderError{
  6227. UserOrgId: adminUser.CurrentOrgId,
  6228. Ctime: time.Now().Unix(),
  6229. Mtime: time.Now().Unix(),
  6230. Number: chrg_bchno,
  6231. ErrMsg: res.ErrMsg,
  6232. Status: 1,
  6233. PatientId: id,
  6234. RecordTime: recordDateTime,
  6235. Stage: 6,
  6236. }
  6237. service.CreateErrMsgLog(errlog)
  6238. c.ServeSuccessJSON(map[string]interface{}{
  6239. "failed_code": -10,
  6240. "msg": res.ErrMsg,
  6241. })
  6242. return
  6243. } else {
  6244. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6245. order.OrderStatus = 2
  6246. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6247. order.SetlId = res.Output.Setlinfo.SetlID
  6248. order.PsnNo = res.Output.Setlinfo.PsnNo
  6249. order.PsnName = res.Output.Setlinfo.PsnName
  6250. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6251. order.Certno = res.Output.Setlinfo.Certno
  6252. order.Gend = res.Output.Setlinfo.Gend
  6253. order.Naty = res.Output.Setlinfo.Naty
  6254. order.Age = res.Output.Setlinfo.Age
  6255. order.Insutype = res.Output.Setlinfo.Insutype
  6256. order.PsnType = res.Output.Setlinfo.PsnType
  6257. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6258. order.SetlTime = res.Output.Setlinfo.SetlTime
  6259. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6260. //order.MedType = res.Output.Setlinfo.MedType
  6261. if reg_type == 1112 {
  6262. order.MedType = "1112"
  6263. }
  6264. if reg_type == 1111 {
  6265. order.MedType = "1111"
  6266. }
  6267. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6268. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6269. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6270. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6271. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6272. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6273. order.HifpPay = res.Output.Setlinfo.HifpPay
  6274. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6275. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6276. order.HifesPay = res.Output.Setlinfo.HifesPay
  6277. order.HifobPay = res.Output.Setlinfo.HifobPay
  6278. order.MafPay = res.Output.Setlinfo.MafPay
  6279. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6280. order.OthPay = res.Output.Setlinfo.OthPay
  6281. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6282. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6283. order.AcctPay = res.Output.Setlinfo.AcctPay
  6284. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6285. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6286. order.Balc = res.Output.Setlinfo.Balc
  6287. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6288. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6289. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6290. order.ClrWay = res.Output.Setlinfo.ClrWay
  6291. order.Creator = order.Creator
  6292. order.Modify = roles.AdminUserId
  6293. order.RequestLog = src_resquest
  6294. order.Diagnosis = diagnosis_id
  6295. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6296. detailStr := string(setlDetail)
  6297. order.SetlDetail = detailStr
  6298. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6299. err = service.UpDateOrder(order)
  6300. if err == nil {
  6301. //判断是否使用了押金
  6302. if dec_way == "true" {
  6303. tmpstring := strconv.FormatInt(order.ID, 10)
  6304. //扣押金
  6305. order.Decimal = decimal
  6306. service.UpDateOrder(order)
  6307. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6308. if errmsg != nil {
  6309. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6310. return
  6311. }
  6312. }
  6313. c.ServeSuccessJSON(map[string]interface{}{
  6314. "msg": "结算成功",
  6315. })
  6316. } else {
  6317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6318. return
  6319. }
  6320. }
  6321. }
  6322. }
  6323. }
  6324. //func (c *HisApiController) GetPreUploadInfo() {
  6325. // id, _ := c.GetInt64("id")
  6326. // record_time := c.GetString("record_time")
  6327. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6328. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6329. //
  6330. // timeLayout := "2006-01-02"
  6331. // loc, _ := time.LoadLocation("Local")
  6332. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6333. // if err != nil {
  6334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6335. // return
  6336. // }
  6337. // recordDateTime := theTime.Unix()
  6338. // adminUser := c.GetAdminUserInfo()
  6339. //
  6340. // var prescriptions []*models.HisPrescription
  6341. //
  6342. // var start_time int64
  6343. // var end_time int64
  6344. //
  6345. // data := make(map[string]interface{})
  6346. // if settle_accounts_type == 1 { //日结
  6347. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6348. // data["pre"] = prescriptions
  6349. //
  6350. // } else { //月结
  6351. // start_time_str := c.GetString("start_time")
  6352. // end_time_str := c.GetString("end_time")
  6353. // timeLayout := "2006-01-02"
  6354. // loc, _ := time.LoadLocation("Local")
  6355. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6356. // if err != nil {
  6357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6358. // return
  6359. // }
  6360. // recordStartTime := theStartTime.Unix()
  6361. // start_time = recordStartTime
  6362. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6363. // if err != nil {
  6364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6365. // return
  6366. // }
  6367. // recordEndTime := theEndTime.Unix()
  6368. // end_time = recordEndTime
  6369. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6370. // data["pre"] = prescriptions
  6371. //
  6372. // }
  6373. //
  6374. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6375. //
  6376. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6377. // timestamp := time.Now().Unix()
  6378. // tempTime := time.Unix(timestamp, 0)
  6379. // timeFormat := tempTime.Format("20060102150405")
  6380. // chrgBchno := rand.Intn(100000) + 10000
  6381. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6382. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6383. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6384. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6385. // strconv.FormatInt(his.PatientId, 10)
  6386. // client := &http.Client{}
  6387. // data["psn_no"] = his.PsnNo
  6388. // data["mdtrt_id"] = his.Number
  6389. // data["chrg_bchno"] = chrg_bchno
  6390. // data["org_name"] = miConfig.OrgName
  6391. // data["doctor"] = roles.UserName
  6392. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6393. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6394. // data["fixmedins_code"] = miConfig.Code
  6395. // data["dept_code"] = department.Number
  6396. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6397. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6398. // data["secret_key"] = miConfig.SecretKey
  6399. // var ids []int64
  6400. //
  6401. // for _, item := range prescriptions {
  6402. // ids = append(ids, item.ID)
  6403. // }
  6404. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6405. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6406. // bytesData, _ := json.Marshal(data)
  6407. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6408. // resp, _ := client.Do(req)
  6409. // defer resp.Body.Close()
  6410. // body, ioErr := ioutil.ReadAll(resp.Body)
  6411. // if ioErr != nil {
  6412. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6414. // return
  6415. // }
  6416. // var respJSON map[string]interface{}
  6417. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6418. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. // return
  6421. // }
  6422. //
  6423. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6424. // userJSONBytes, _ := json.Marshal(respJSON)
  6425. // var res ResultFour
  6426. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6427. // utils.ErrorLog("解析失败:%v", err)
  6428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. // return
  6430. // }
  6431. //
  6432. // if res.Infcode == 0 {
  6433. // order := &models.HisOrder{
  6434. // UserOrgId: adminUser.CurrentOrgId,
  6435. // HisPatientId: his.ID,
  6436. // PatientId: his.PatientId,
  6437. // SettleAccountsDate: recordDateTime,
  6438. // Ctime: time.Now().Unix(),
  6439. // Mtime: time.Now().Unix(),
  6440. // Status: 1,
  6441. // Number: chrg_bchno,
  6442. // Infcode: res.Infcode,
  6443. // WarnMsg: res.WarnMsg,
  6444. // Cainfo: res.Cainfo,
  6445. // ErrMsg: res.ErrMsg,
  6446. // RespondTime: res.RefmsgTime,
  6447. // InfRefmsgid: res.InfRefmsgid,
  6448. // OrderStatus: 1,
  6449. // IsMedicineInsurance: 1,
  6450. // SettleType: settle_accounts_type,
  6451. // SettleStartTime: start_time,
  6452. // SettleEndTime: end_time,
  6453. // Creator: roles.ID,
  6454. // Modify: roles.ID,
  6455. // PType: 2,
  6456. // }
  6457. // err = service.CreateOrder(order)
  6458. // if err != nil {
  6459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6460. // return
  6461. // }
  6462. //
  6463. // for _, item := range res.Output.Result {
  6464. // temp := strings.Split(item.FeedetlSn, "-")
  6465. // var advice_id int64 = 0
  6466. // var project_id int64 = 0
  6467. // var types int64 = 0
  6468. //
  6469. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6470. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6471. //
  6472. // if temp[1] == "1" {
  6473. // advice_id = id
  6474. // project_id = 0
  6475. // } else if temp[1] == "2" {
  6476. // advice_id = 0
  6477. // project_id = id
  6478. // }
  6479. //
  6480. // info := &models.HisOrderInfo{
  6481. // OrderNumber: order.Number,
  6482. // FeedetlSn: item.FeedetlSn,
  6483. // UploadDate: time.Now().Unix(),
  6484. // AdviceId: advice_id,
  6485. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6486. // Cnt: item.Cnt,
  6487. // Pric: float64(item.Pric),
  6488. // PatientId: his.PatientId,
  6489. // PricUplmtAmt: item.PricUplmtAmt,
  6490. // SelfpayProp: item.SelfpayProp,
  6491. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6492. // OverlmtAmt: item.OverlmtAmt,
  6493. // PreselfpayAmt: item.PreselfpayAmt,
  6494. // BasMednFlag: item.BasMednFlag,
  6495. // MedChrgitmType: item.MedChrgitmType,
  6496. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6497. // Status: 1,
  6498. // Memo: item.Memo,
  6499. // Mtime: time.Now().Unix(),
  6500. // InscpScpAmt: item.InscpScpAmt,
  6501. // DrtReimFlag: item.DrtReimFlag,
  6502. // Ctime: time.Now().Unix(),
  6503. // ListSpItemFlag: item.ListSpItemFlag,
  6504. // ChldMedcFlag: item.ChldMedcFlag,
  6505. // LmtUsedFlag: item.LmtUsedFlag,
  6506. // ChrgitmLv: item.ChrgitmLv,
  6507. // UserOrgId: adminUser.CurrentOrgId,
  6508. // HisPatientId: his.ID,
  6509. // OrderId: order.ID,
  6510. // ProjectId: project_id,
  6511. // Type: types,
  6512. // }
  6513. // service.CreateOrderInfo(info)
  6514. //
  6515. // }
  6516. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6517. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6518. //
  6519. // var total float64
  6520. // for _, item := range prescriptions {
  6521. // if item.Type == 1 { //药品
  6522. // for _, subItem := range item.HisDoctorAdviceInfo {
  6523. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6524. // }
  6525. // }
  6526. // if item.Type == 2 { //项目
  6527. // for _, subItem := range item.HisPrescriptionProject {
  6528. // total = total + (subItem.Price * float64(subItem.Count))
  6529. // }
  6530. // }
  6531. // }
  6532. //
  6533. // for _, item := range prescriptions {
  6534. // for _, subItem := range item.HisAdditionalCharge {
  6535. // total = total + (subItem.Price * float64(subItem.Count))
  6536. // }
  6537. // }
  6538. //
  6539. // allTotal := fmt.Sprintf("%.2f", total)
  6540. // if res.Infcode == 0 {
  6541. // var rf []*ResultFive
  6542. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6543. // psn_no := his.PsnNo
  6544. // mdtrt_id := his.Number
  6545. // chrg_bchno := chrg_bchno
  6546. // cert_no := his.Certno
  6547. // insutype := rf[0].Insutype
  6548. //
  6549. // if his.IdCardType == 1 {
  6550. // cert_no = his.MedicalInsuranceNumber
  6551. //
  6552. // } else {
  6553. //
  6554. // cert_no = his.Certno
  6555. //
  6556. // }
  6557. //
  6558. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6559. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6560. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6561. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6562. // resp, requestErr := http.Get(api)
  6563. // if requestErr != nil {
  6564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. // return
  6566. // }
  6567. // defer resp.Body.Close()
  6568. // body, ioErr := ioutil.ReadAll(resp.Body)
  6569. // if ioErr != nil {
  6570. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. // return
  6573. // }
  6574. // var respJSON map[string]interface{}
  6575. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6576. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6578. // return
  6579. // }
  6580. // fmt.Println(respJSON)
  6581. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6582. // userJSONBytes, _ := json.Marshal(respJSON)
  6583. // var res ResultSeven
  6584. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6585. // utils.ErrorLog("解析失败:%v", err)
  6586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6587. // return
  6588. // }
  6589. // if res.Infcode != 0 {
  6590. // errlog := &models.HisOrderError{
  6591. // UserOrgId: adminUser.CurrentOrgId,
  6592. // Ctime: time.Now().Unix(),
  6593. // Mtime: time.Now().Unix(),
  6594. // Number: chrg_bchno,
  6595. // ErrMsg: res.ErrMsg,
  6596. // Status: 1,
  6597. // PatientId: id,
  6598. // RecordTime: recordDateTime,
  6599. // Stage: 7,
  6600. // }
  6601. // service.CreateErrMsgLog(errlog)
  6602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6603. // return
  6604. // } else {
  6605. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6606. // order.OrderStatus = 1
  6607. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6608. // order.SetlId = res.Output.Setlinfo.SetlID
  6609. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6610. // order.PsnName = res.Output.Setlinfo.PsnName
  6611. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6612. // order.Certno = res.Output.Setlinfo.Certno
  6613. // order.Gend = res.Output.Setlinfo.Gend
  6614. // order.Naty = res.Output.Setlinfo.Naty
  6615. // order.Age = res.Output.Setlinfo.Age
  6616. // order.Insutype = res.Output.Setlinfo.Insutype
  6617. // order.PsnType = res.Output.Setlinfo.PsnType
  6618. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6619. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6620. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6621. // order.MedType = res.Output.Setlinfo.MedType
  6622. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6623. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6624. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6625. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6626. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6627. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6628. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6629. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6630. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6631. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6632. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6633. // order.MafPay = res.Output.Setlinfo.MafPay
  6634. // order.OthPay = res.Output.Setlinfo.OthPay
  6635. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6636. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6637. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6638. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6639. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6640. // order.Balc = res.Output.Setlinfo.Balc
  6641. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6642. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6643. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6644. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6645. // order.Creator = order.Creator
  6646. // order.Modify = roles.ID
  6647. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6648. // detailStr := string(setlDetail)
  6649. // order.SetlDetail = detailStr
  6650. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6651. // err = service.UpDateOrder(order)
  6652. // if err == nil {
  6653. // c.ServeSuccessJSON(map[string]interface{}{
  6654. // "msg": "预结算成功",
  6655. // })
  6656. // } else {
  6657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6658. // return
  6659. // }
  6660. // }
  6661. // } else {
  6662. // adminUser := c.GetAdminUserInfo()
  6663. // errlog := &models.HisOrderError{
  6664. // UserOrgId: adminUser.CurrentOrgId,
  6665. // Ctime: time.Now().Unix(),
  6666. // Mtime: time.Now().Unix(),
  6667. // ErrMsg: res.ErrMsg,
  6668. // Status: 1,
  6669. // PatientId: id,
  6670. // RecordTime: recordDateTime,
  6671. // Stage: 4,
  6672. // }
  6673. // service.CreateErrMsgLog(errlog)
  6674. //
  6675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6676. // return
  6677. // }
  6678. // } else {
  6679. // adminUser := c.GetAdminUserInfo()
  6680. // errlog := &models.HisOrderError{
  6681. // UserOrgId: adminUser.CurrentOrgId,
  6682. // Ctime: time.Now().Unix(),
  6683. // Mtime: time.Now().Unix(),
  6684. // ErrMsg: res.ErrMsg,
  6685. // Status: 1,
  6686. // PatientId: id,
  6687. // RecordTime: recordDateTime,
  6688. // Stage: 4,
  6689. // }
  6690. // service.CreateErrMsgLog(errlog)
  6691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6692. // return
  6693. // }
  6694. //
  6695. // } else {
  6696. // var total float64
  6697. // for _, item := range prescriptions {
  6698. // if item.Type == 1 { //药品
  6699. // for _, subItem := range item.HisDoctorAdviceInfo {
  6700. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6701. // }
  6702. // }
  6703. // if item.Type == 2 { //项目
  6704. // for _, subItem := range item.HisPrescriptionProject {
  6705. // total = total + (subItem.Price * float64(subItem.Count))
  6706. // }
  6707. // }
  6708. //
  6709. // for _, subItem := range item.HisAdditionalCharge {
  6710. // total = total + (subItem.Price * float64(subItem.Count))
  6711. // }
  6712. // }
  6713. //
  6714. // allTotal := fmt.Sprintf("%.2f", total)
  6715. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6716. // order := &models.HisOrder{
  6717. // UserOrgId: adminUser.CurrentOrgId,
  6718. // HisPatientId: his.ID,
  6719. // PatientId: id,
  6720. // SettleAccountsDate: recordDateTime,
  6721. // Ctime: time.Now().Unix(),
  6722. // Mtime: time.Now().Unix(),
  6723. // Status: 1,
  6724. // OrderStatus: 2,
  6725. // Number: chrg_bchno,
  6726. // MedfeeSumamt: totals,
  6727. // }
  6728. // err = service.CreateOrder(order)
  6729. // if err != nil {
  6730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6731. // return
  6732. // }
  6733. //
  6734. // var customs []*Custom
  6735. // for _, item := range prescriptions {
  6736. //
  6737. // if item.Type == 1 { //药品
  6738. // for _, subItem := range item.HisDoctorAdviceInfo {
  6739. // cus := &Custom{
  6740. // AdviceId: subItem.ID,
  6741. // ProjectId: 0,
  6742. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6743. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6744. // FeedetlSn: subItem.FeedetlSn,
  6745. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6746. // MedListCodg: subItem.MedListCodg,
  6747. // Type: 1,
  6748. // }
  6749. // customs = append(customs, cus)
  6750. // }
  6751. // }
  6752. //
  6753. // if item.Type == 2 { //项目
  6754. // for _, subItem := range item.HisPrescriptionProject {
  6755. //
  6756. // cus := &Custom{
  6757. // AdviceId: 0,
  6758. // ProjectId: subItem.ID,
  6759. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6760. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6761. // FeedetlSn: subItem.FeedetlSn,
  6762. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6763. // MedListCodg: subItem.MedListCodg,
  6764. // Type: 2,
  6765. // }
  6766. //
  6767. // customs = append(customs, cus)
  6768. // }
  6769. // }
  6770. //
  6771. // for _, item := range item.HisAdditionalCharge {
  6772. // cus := &Custom{
  6773. // ItemId: item.ID,
  6774. // AdviceId: 0,
  6775. // ProjectId: 0,
  6776. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6777. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6778. // FeedetlSn: item.FeedetlSn,
  6779. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6780. // MedListCodg: item.XtHisAddtionConfig.Code,
  6781. // Type: 3,
  6782. // }
  6783. //
  6784. // customs = append(customs, cus)
  6785. // }
  6786. //
  6787. // }
  6788. //
  6789. // for _, item := range customs {
  6790. // var advice_id int64 = 0
  6791. // var project_id int64 = 0
  6792. // var item_id int64 = 0
  6793. //
  6794. // var types int64 = 0
  6795. //
  6796. // if item.Type == 1 {
  6797. // advice_id = item.AdviceId
  6798. // project_id = 0
  6799. // item_id = 0
  6800. // } else if item.Type == 2 {
  6801. // advice_id = 0
  6802. // item_id = 0
  6803. //
  6804. // project_id = item.ProjectId
  6805. // } else if item.Type == 3 {
  6806. // advice_id = 0
  6807. // item_id = item.ItemId
  6808. // project_id = 0
  6809. // }
  6810. //
  6811. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6812. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6813. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6814. //
  6815. // info := &models.HisOrderInfo{
  6816. // OrderNumber: order.Number,
  6817. // UploadDate: time.Now().Unix(),
  6818. // AdviceId: advice_id,
  6819. // DetItemFeeSumamt: detItemFeeSumamt,
  6820. // Cnt: cut,
  6821. // Pric: pric,
  6822. // PatientId: id,
  6823. // Status: 1,
  6824. // Mtime: time.Now().Unix(),
  6825. // Ctime: time.Now().Unix(),
  6826. // UserOrgId: adminUser.CurrentOrgId,
  6827. // HisPatientId: his.ID,
  6828. // OrderId: order.ID,
  6829. // ProjectId: project_id,
  6830. // Type: types,
  6831. // ItemId: item_id,
  6832. // }
  6833. // service.CreateOrderInfo(info)
  6834. // }
  6835. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6836. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6837. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6838. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6839. // if err == nil {
  6840. // c.ServeSuccessJSON(map[string]interface{}{
  6841. // "msg": "结算成功",
  6842. // })
  6843. // } else {
  6844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6845. // return
  6846. // }
  6847. // }
  6848. //}
  6849. // 上传明细-预结算-
  6850. func (c *HisApiController) GetPreUploadInfo() {
  6851. id, _ := c.GetInt64("id")
  6852. record_time := c.GetString("record_time")
  6853. his_patient_id, _ := c.GetInt64("his_patient_id")
  6854. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6855. admin_user_id, _ := c.GetInt64("admin_user_id")
  6856. diagnosis_id := c.GetString("diagnosis")
  6857. sick_type, _ := c.GetInt64("sick_type")
  6858. reg_type, _ := c.GetInt64("p_type")
  6859. begin_time := c.GetString("begin_time")
  6860. id_str := c.GetString("ids")
  6861. ids_arr := strings.Split(id_str, ",")
  6862. timeLayout := "2006-01-02"
  6863. loc, _ := time.LoadLocation("Local")
  6864. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6865. if err != nil {
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6867. return
  6868. }
  6869. recordDateTime := theTime.Unix()
  6870. adminUser := c.GetAdminUserInfo()
  6871. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6872. var config []*models.HisXtDiagnoseConfig
  6873. for _, item := range diagnosis_ids {
  6874. id, _ := strconv.ParseInt(item, 10, 64)
  6875. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6876. config = append(config, &diagnosisConfig)
  6877. }
  6878. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6879. sickConfig, _ := service.FindSickById(sick_type)
  6880. var prescriptions []*models.HisPrescription
  6881. var start_time int64
  6882. var end_time int64
  6883. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6884. fmt.Println(his_patient_id)
  6885. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6886. timestamp := time.Now().Unix()
  6887. tempTime := time.Unix(timestamp, 0)
  6888. timeFormat := tempTime.Format("20060102150405")
  6889. chrgBchno := rand.Intn(100000) + 10000
  6890. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6892. var patientPrescription models.HisPrescriptionInfo
  6893. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6894. if patientPrescription.ID == 0 {
  6895. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6896. }
  6897. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6898. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6899. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6900. strconv.FormatInt(his.PatientId, 10)
  6901. var res2 ResultSix
  6902. var resSix10265 ResultSix10265
  6903. var time_stamp string
  6904. if miConfig.MdtrtareaAdmvs == "421300" {
  6905. data := make(map[string]interface{})
  6906. client := &http.Client{}
  6907. data["psn_no"] = his.PsnNo
  6908. data["mdtrt_id"] = his.Number
  6909. data["doctor"] = roles.UserName
  6910. data["department"] = department.Name
  6911. data["org_name"] = miConfig.OrgName
  6912. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6913. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6914. data["fixmedins_code"] = miConfig.Code
  6915. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6916. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6917. data["secret_key"] = miConfig.SecretKey
  6918. data["sick_code"] = sickConfig.CountryCode
  6919. data["sick_name"] = sickConfig.ClassName
  6920. data["begin_time"] = begin_time
  6921. data["dept"] = strconv.FormatInt(department.ID, 10)
  6922. data["config"] = config
  6923. fmt.Println(data)
  6924. bytesData, _ := json.Marshal(data)
  6925. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6926. resp, _ := client.Do(req)
  6927. defer resp.Body.Close()
  6928. body, ioErr := ioutil.ReadAll(resp.Body)
  6929. if ioErr != nil {
  6930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6932. return
  6933. }
  6934. var respJSON map[string]interface{}
  6935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. return
  6939. }
  6940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6941. userJSONBytes, _ := json.Marshal(respJSON)
  6942. fmt.Println("log")
  6943. fmt.Println(string(userJSONBytes))
  6944. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6945. utils.ErrorLog("解析失败:%v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6950. //江苏地区国家医保医疗类别
  6951. //职工透析:医疗类别选特殊情况门诊9933
  6952. //居民血透门慢: 医疗类别选门诊慢病1402
  6953. //var med_type string
  6954. //if his.Insutype == "310" {
  6955. // if reg_type == 14 {
  6956. // med_type = "9933"
  6957. // } else if reg_type == 11 {
  6958. // med_type = "11"
  6959. //
  6960. // }
  6961. //} else if his.Insutype == "390" {
  6962. // if reg_type == 14 {
  6963. // med_type = "1402"
  6964. // } else if reg_type == 11 {
  6965. // med_type = "11"
  6966. // }
  6967. //}
  6968. data := make(map[string]interface{})
  6969. client := &http.Client{}
  6970. data["psn_no"] = his.PsnNo
  6971. data["mdtrt_id"] = his.Number
  6972. data["doctor"] = roles.UserName
  6973. data["department"] = department.Name
  6974. data["org_name"] = miConfig.OrgName
  6975. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6976. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6977. data["fixmedins_code"] = miConfig.Code
  6978. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6979. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6980. data["secret_key"] = miConfig.SecretKey
  6981. data["sick_code"] = sickConfig.CountryCode
  6982. data["sick_name"] = sickConfig.ClassName
  6983. data["begin_time"] = begin_time
  6984. data["dept"] = strconv.FormatInt(department.ID, 10)
  6985. data["config"] = config
  6986. data["url"] = miConfig.Url
  6987. data["ak"] = miConfig.AccessKey
  6988. data["cainfo"] = miConfig.Cainfo
  6989. bytesData, _ := json.Marshal(data)
  6990. var req *http.Request
  6991. if miConfig.MdtrtareaAdmvs == "320921" {
  6992. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6993. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6994. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6995. } else {
  6996. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6997. }
  6998. resp, _ := client.Do(req)
  6999. defer resp.Body.Close()
  7000. body, ioErr := ioutil.ReadAll(resp.Body)
  7001. if ioErr != nil {
  7002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7004. return
  7005. }
  7006. var respJSON map[string]interface{}
  7007. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7010. return
  7011. }
  7012. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7013. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7014. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7016. userJSONBytes, _ := json.Marshal(respJSON)
  7017. fmt.Println("log")
  7018. fmt.Println(string(userJSONBytes))
  7019. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7020. utils.ErrorLog("解析失败:%v", err)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. return
  7023. }
  7024. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7025. // res2.Output = resSix10265.Output
  7026. res2.ErrMsg = resSix10265.ErrMsg
  7027. res2.Cainfo = resSix10265.Cainfo
  7028. res2.WarnMsg = resSix10265.WarnMsg
  7029. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7030. res2.Infcode = infocode
  7031. } else {
  7032. var result string
  7033. var requestLog string
  7034. if miConfig.MdtrtareaAdmvs == "440781" { //
  7035. 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)
  7036. } else {
  7037. if miConfig.Code == "H15049901371" {
  7038. //赤峰地区国家医保医疗类别
  7039. //职工透析:医疗类别选特殊情况门诊990502
  7040. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7041. var med_type string
  7042. if his.Insutype == "390" {
  7043. if reg_type == 14 {
  7044. med_type = "9933"
  7045. } else if reg_type == 11 {
  7046. med_type = "11"
  7047. }
  7048. } else if his.Insutype == "310" {
  7049. if reg_type == 14 {
  7050. med_type = "990502"
  7051. } else if reg_type == 11 {
  7052. med_type = "11"
  7053. }
  7054. }
  7055. result, requestLog = service.Gdyb2203ForGz(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)
  7056. } else {
  7057. var med_type string
  7058. if reg_type == 14 {
  7059. med_type = "14"
  7060. result, requestLog = service.Gdyb2203ForGz(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)
  7061. } else if reg_type == 11 {
  7062. med_type = "11"
  7063. // sickConfig.ClassName = "普通门诊"
  7064. // sickConfig.ContentCode = "11"
  7065. result, requestLog = service.Gdyb2203ForGz(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)
  7066. }
  7067. }
  7068. saveLog(result, requestLog, "2203", "上传就诊信息")
  7069. var respJSON2 map[string]interface{}
  7070. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7073. return
  7074. }
  7075. userJSONBytes2, _ := json.Marshal(respJSON2)
  7076. if miConfig.Code == "H15049901371" {
  7077. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7078. utils.ErrorLog("解析失败:%v", err)
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. return
  7081. }
  7082. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7083. // res2.Output = resSix10265.Output
  7084. res2.ErrMsg = resSix10265.ErrMsg
  7085. res2.Cainfo = resSix10265.Cainfo
  7086. res2.WarnMsg = resSix10265.WarnMsg
  7087. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7088. res2.Infcode = infocode
  7089. } else {
  7090. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7091. utils.ErrorLog("解析失败:%v", err)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. return
  7094. }
  7095. }
  7096. }
  7097. }
  7098. if res2.Infcode != 0 {
  7099. adminUser := c.GetAdminUserInfo()
  7100. errlog := &models.HisOrderError{
  7101. UserOrgId: adminUser.CurrentOrgId,
  7102. Ctime: time.Now().Unix(),
  7103. Mtime: time.Now().Unix(),
  7104. ErrMsg: res2.ErrMsg,
  7105. Status: 1,
  7106. PatientId: id,
  7107. RecordTime: recordDateTime,
  7108. Stage: 3,
  7109. }
  7110. service.CreateErrMsgLog(errlog)
  7111. c.ServeSuccessJSON(map[string]interface{}{
  7112. "failed_code": -10,
  7113. "msg": res2.ErrMsg,
  7114. })
  7115. return
  7116. } else {
  7117. his.Diagnosis = diagnosis_id
  7118. his.SickType = sickConfig.ID
  7119. his.PType = fmt.Sprintf("%d", reg_type)
  7120. service.UpdateHisPatientThree(&his)
  7121. data := make(map[string]interface{})
  7122. if settle_accounts_type == 1 { //日结
  7123. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7124. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7125. } else {
  7126. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7127. }
  7128. data["pre"] = prescriptions
  7129. } else { //月结
  7130. start_time_str := c.GetString("start_time")
  7131. end_time_str := c.GetString("end_time")
  7132. timeLayout := "2006-01-02"
  7133. loc, _ := time.LoadLocation("Local")
  7134. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7135. if err != nil {
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7137. return
  7138. }
  7139. recordStartTime := theStartTime.Unix()
  7140. start_time = recordStartTime
  7141. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7142. if err != nil {
  7143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7144. return
  7145. }
  7146. recordEndTime := theEndTime.Unix()
  7147. end_time = recordEndTime
  7148. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7149. data["pre"] = prescriptions
  7150. }
  7151. client := &http.Client{}
  7152. data["psn_no"] = his.PsnNo
  7153. data["mdtrt_id"] = his.Number
  7154. data["chrg_bchno"] = chrg_bchno
  7155. data["org_name"] = miConfig.OrgName
  7156. data["doctor"] = roles.UserName
  7157. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7158. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7159. data["fixmedins_code"] = miConfig.Code
  7160. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7161. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7162. data["dept_code"] = "15"
  7163. } else {
  7164. data["dept_code"] = department.Number
  7165. }
  7166. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7167. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7168. data["secret_key"] = miConfig.SecretKey
  7169. data["url"] = miConfig.Url
  7170. data["ak"] = miConfig.AccessKey
  7171. data["new_doctor_name"] = patientPrescription.Doctor
  7172. data["diag_code"] = sickConfig.CountryCode
  7173. data["time_stamp"] = time_stamp
  7174. data["cainfo"] = miConfig.Cainfo
  7175. var ids []int64
  7176. for _, item := range prescriptions {
  7177. ids = append(ids, item.ID)
  7178. }
  7179. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7180. if config.IsOpen == 1 { //对接了医保,走医保流程
  7181. var res ResultFour
  7182. var resFour10265 ResultFour10265
  7183. if miConfig.MdtrtareaAdmvs == "421300" {
  7184. bytesData, _ := json.Marshal(data)
  7185. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7186. resp, _ := client.Do(req)
  7187. defer resp.Body.Close()
  7188. body, ioErr := ioutil.ReadAll(resp.Body)
  7189. if ioErr != nil {
  7190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. var respJSON map[string]interface{}
  7195. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7201. userJSONBytes, _ := json.Marshal(respJSON)
  7202. fmt.Println("log")
  7203. fmt.Println(string(userJSONBytes))
  7204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7205. utils.ErrorLog("解析失败:%v", err)
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. return
  7208. }
  7209. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7210. bytesData, _ := json.Marshal(data)
  7211. var req *http.Request
  7212. if miConfig.MdtrtareaAdmvs == "320921" {
  7213. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7214. } else {
  7215. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7216. }
  7217. resp, _ := client.Do(req)
  7218. defer resp.Body.Close()
  7219. body, ioErr := ioutil.ReadAll(resp.Body)
  7220. if ioErr != nil {
  7221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. return
  7224. }
  7225. var respJSON map[string]interface{}
  7226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. return
  7230. }
  7231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7232. userJSONBytes, _ := json.Marshal(respJSON)
  7233. fmt.Println("log")
  7234. fmt.Println(string(userJSONBytes))
  7235. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7236. utils.ErrorLog("解析失败:%v", err)
  7237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7238. return
  7239. }
  7240. res.InfRefmsgid = resFour10265.InfRefmsgid
  7241. res.Output = resFour10265.Output
  7242. res.ErrMsg = resFour10265.ErrMsg
  7243. res.Cainfo = resFour10265.Cainfo
  7244. res.WarnMsg = resFour10265.WarnMsg
  7245. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7246. res.Infcode = infocode
  7247. } else {
  7248. if miConfig.Code == "H15049901371" {
  7249. 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)
  7250. var dat map[string]interface{}
  7251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7252. fmt.Println(dat)
  7253. } else {
  7254. fmt.Println(err)
  7255. }
  7256. saveLog(result, request_log, "2204", "上传费用明细")
  7257. userJSONBytes, _ := json.Marshal(dat)
  7258. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7259. utils.ErrorLog("解析失败:%v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. res.InfRefmsgid = resFour10265.InfRefmsgid
  7264. res.Output = resFour10265.Output
  7265. res.ErrMsg = resFour10265.ErrMsg
  7266. res.Cainfo = resFour10265.Cainfo
  7267. res.WarnMsg = resFour10265.WarnMsg
  7268. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7269. res.Infcode = infocode
  7270. } else {
  7271. 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)
  7272. var dat map[string]interface{}
  7273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7274. fmt.Println(dat)
  7275. } else {
  7276. fmt.Println(err)
  7277. }
  7278. saveLog(result, request_log, "2204", "上传费用明细")
  7279. userJSONBytes, _ := json.Marshal(dat)
  7280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7281. utils.ErrorLog("解析失败:%v", err)
  7282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7283. return
  7284. }
  7285. }
  7286. }
  7287. if res.Infcode == 0 {
  7288. order := &models.HisOrder{
  7289. UserOrgId: adminUser.CurrentOrgId,
  7290. HisPatientId: his.ID,
  7291. PatientId: his.PatientId,
  7292. SettleAccountsDate: recordDateTime,
  7293. Ctime: time.Now().Unix(),
  7294. Mtime: time.Now().Unix(),
  7295. MdtrtId: his.Number,
  7296. PsnNo: his.PsnNo,
  7297. MedType: strconv.FormatInt(reg_type, 10),
  7298. Status: 1,
  7299. Number: chrg_bchno,
  7300. Infcode: res.Infcode,
  7301. WarnMsg: res.WarnMsg,
  7302. Cainfo: res.Cainfo,
  7303. ErrMsg: res.ErrMsg,
  7304. RespondTime: res.RefmsgTime,
  7305. InfRefmsgid: res.InfRefmsgid,
  7306. OrderStatus: 1,
  7307. IsMedicineInsurance: 1,
  7308. SettleType: settle_accounts_type,
  7309. SettleStartTime: start_time,
  7310. SettleEndTime: end_time,
  7311. Creator: roles.AdminUserId,
  7312. Modify: roles.AdminUserId,
  7313. PType: 2,
  7314. Diagnosis: diagnosis_id,
  7315. }
  7316. err = service.CreateOrder(order)
  7317. if err != nil {
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7319. return
  7320. }
  7321. for _, item := range res.Output.Result {
  7322. temp := strings.Split(item.FeedetlSn, "-")
  7323. var advice_id int64 = 0
  7324. var project_id int64 = 0
  7325. var types int64 = 0
  7326. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7327. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7328. if temp[1] == "1" {
  7329. advice_id = id
  7330. project_id = 0
  7331. } else if temp[1] == "2" {
  7332. advice_id = 0
  7333. project_id = id
  7334. }
  7335. info := &models.HisOrderInfo{
  7336. OrderNumber: order.Number,
  7337. FeedetlSn: item.FeedetlSn,
  7338. UploadDate: time.Now().Unix(),
  7339. AdviceId: advice_id,
  7340. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7341. Cnt: item.Cnt,
  7342. Pric: float64(item.Pric),
  7343. PatientId: his.PatientId,
  7344. PricUplmtAmt: item.PricUplmtAmt,
  7345. SelfpayProp: item.SelfpayProp,
  7346. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7347. OverlmtAmt: item.OverlmtAmt,
  7348. PreselfpayAmt: item.PreselfpayAmt,
  7349. BasMednFlag: item.BasMednFlag,
  7350. MedChrgitmType: item.MedChrgitmType,
  7351. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7352. Status: 1,
  7353. Memo: item.Memo,
  7354. Mtime: time.Now().Unix(),
  7355. InscpScpAmt: item.InscpScpAmt,
  7356. DrtReimFlag: item.DrtReimFlag,
  7357. Ctime: time.Now().Unix(),
  7358. ListSpItemFlag: item.ListSpItemFlag,
  7359. ChldMedcFlag: item.ChldMedcFlag,
  7360. LmtUsedFlag: item.LmtUsedFlag,
  7361. ChrgitmLv: item.ChrgitmLv,
  7362. UserOrgId: adminUser.CurrentOrgId,
  7363. HisPatientId: his.ID,
  7364. OrderId: order.ID,
  7365. ProjectId: project_id,
  7366. Type: types,
  7367. }
  7368. service.CreateOrderInfo(info)
  7369. }
  7370. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7371. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7372. var total float64
  7373. for _, item := range prescriptions {
  7374. if item.Type == 1 { //药品
  7375. for _, subItem := range item.HisDoctorAdviceInfo {
  7376. total = total + (subItem.Price * subItem.PrescribingNumber)
  7377. }
  7378. }
  7379. if item.Type == 2 { //项目
  7380. for _, subItem := range item.HisPrescriptionProject {
  7381. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7382. total = total + (subItem.Price * cnt)
  7383. }
  7384. }
  7385. }
  7386. for _, item := range prescriptions {
  7387. for _, subItem := range item.HisAdditionalCharge {
  7388. total = total + (subItem.Price * float64(subItem.Count))
  7389. }
  7390. }
  7391. allTotal := fmt.Sprintf("%.4f", total)
  7392. if res.Infcode == 0 {
  7393. var rf []*ResultFive
  7394. json.Unmarshal([]byte(his.Iinfo), &rf)
  7395. chrg_bchno := chrg_bchno
  7396. cert_no := his.Certno
  7397. var insutypes []string
  7398. var insutype string
  7399. var is390 int = 0
  7400. var is310 int = 0
  7401. for _, item := range rf {
  7402. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7403. insutypes = append(insutypes, item.Insutype)
  7404. }
  7405. }
  7406. if len(insutypes) == 1 {
  7407. insutype = insutypes[0]
  7408. } else {
  7409. for _, i := range insutypes {
  7410. if i == "390" {
  7411. is390 = 1
  7412. }
  7413. if i == "310" {
  7414. is310 = 1
  7415. }
  7416. }
  7417. }
  7418. if is390 == 1 {
  7419. insutype = "390"
  7420. }
  7421. if is310 == 1 {
  7422. insutype = "310"
  7423. }
  7424. if len(insutypes) == 0 {
  7425. insutype = "310"
  7426. }
  7427. if len(insutypes) == 2 {
  7428. insutype = strconv.FormatInt(his.SocialType, 64)
  7429. }
  7430. //insutype = "390"
  7431. if his.IdCardType == 1 {
  7432. cert_no = his.MedicalInsuranceNumber
  7433. } else {
  7434. cert_no = his.Certno
  7435. }
  7436. var res models.GZResult2206
  7437. var resSeven10265 ResultSeven10265
  7438. if miConfig.MdtrtareaAdmvs == "421300" {
  7439. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7440. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7441. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7443. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7444. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7445. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7446. resp, requestErr := http.Get(api)
  7447. if requestErr != nil {
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. body, ioErr := ioutil.ReadAll(resp.Body)
  7452. if ioErr != nil {
  7453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. var respJSON map[string]interface{}
  7458. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7464. result, _ := json.Marshal(respJSON)
  7465. fmt.Println("log")
  7466. fmt.Println(string(result))
  7467. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7468. utils.ErrorLog("解析失败:%v", err)
  7469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7470. return
  7471. }
  7472. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7473. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7474. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7475. bas := strings.Split(psn_info.CardInfo, "|")
  7476. if his.IdCardType == 1 {
  7477. cert_no = bas[2]
  7478. } else {
  7479. cert_no = bas[1]
  7480. }
  7481. //江苏地区国家医保医疗类别
  7482. //职工透析:医疗类别选特殊情况门诊9933
  7483. //居民血透门慢: 医疗类别选门诊慢病1402
  7484. //var med_type string
  7485. //if his.Insutype == "310" {
  7486. // if reg_type == 14 {
  7487. // med_type = "9933"
  7488. // } else if reg_type == 11 {
  7489. // med_type = "11"
  7490. //
  7491. // }
  7492. //} else if his.Insutype == "390" {
  7493. // if reg_type == 14 {
  7494. // med_type = "1402"
  7495. // } else if reg_type == 11 {
  7496. // med_type = "11"
  7497. // }
  7498. //}
  7499. var api string
  7500. if miConfig.MdtrtareaAdmvs == "320921" {
  7501. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7507. "&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
  7508. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7509. } else {
  7510. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7511. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7517. "&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
  7518. }
  7519. resp, requestErr := http.Get(api)
  7520. if requestErr != nil {
  7521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7522. return
  7523. }
  7524. body, ioErr := ioutil.ReadAll(resp.Body)
  7525. if ioErr != nil {
  7526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7528. return
  7529. }
  7530. var respJSON map[string]interface{}
  7531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7537. result, _ := json.Marshal(respJSON)
  7538. fmt.Println("log")
  7539. fmt.Println(string(result))
  7540. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7541. utils.ErrorLog("解析失败:%v", err)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7546. // res.Output = resSeven10265.Output
  7547. res.ErrMsg = resSeven10265.ErrMsg
  7548. res.Cainfo = resSeven10265.Cainfo
  7549. // res.WarnMsg = resSeven10265.WarnMsg
  7550. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7551. // res.Infcode = infocode
  7552. } else {
  7553. var result string
  7554. var request_log string
  7555. if miConfig.Code == "H15049901371" {
  7556. //赤峰地区国家医保医疗类别
  7557. //职工透析:医疗类别选特殊情况门诊990502
  7558. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7559. var med_type string
  7560. if his.Insutype == "390" {
  7561. if reg_type == 14 {
  7562. med_type = "9933"
  7563. } else if reg_type == 11 {
  7564. med_type = "11"
  7565. }
  7566. } else if his.Insutype == "310" {
  7567. if reg_type == 14 {
  7568. med_type = "990502"
  7569. } else if reg_type == 11 {
  7570. med_type = "11"
  7571. }
  7572. }
  7573. 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)
  7574. } else {
  7575. var med_type string
  7576. if reg_type == 14 {
  7577. med_type = "141009"
  7578. } else if reg_type == 11 {
  7579. med_type = "11"
  7580. }
  7581. 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)
  7582. }
  7583. var dat map[string]interface{}
  7584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7585. fmt.Println(dat)
  7586. } else {
  7587. fmt.Println(err)
  7588. }
  7589. saveLog(result, request_log, "2206", "预结算")
  7590. //userJSONBytes, _ := json.Marshal(dat)
  7591. //
  7592. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7593. // utils.ErrorLog("解析失败:%v", err)
  7594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7595. // return
  7596. //}
  7597. userJSONBytes, _ := json.Marshal(dat)
  7598. if miConfig.Code == "H15049901371" {
  7599. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7600. utils.ErrorLog("解析失败:%v", err)
  7601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7602. return
  7603. }
  7604. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7605. // res.Output = resSeven10265.Output
  7606. res.ErrMsg = resSeven10265.ErrMsg
  7607. res.Cainfo = resSeven10265.Cainfo
  7608. // res.WarnMsg = resSeven10265.WarnMsg
  7609. // infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7610. // res.Infcode = infocode
  7611. } else {
  7612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7613. utils.ErrorLog("解析失败:%v", err)
  7614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7615. return
  7616. }
  7617. }
  7618. }
  7619. if res.Infcode != 0 {
  7620. errlog := &models.HisOrderError{
  7621. UserOrgId: adminUser.CurrentOrgId,
  7622. Ctime: time.Now().Unix(),
  7623. Mtime: time.Now().Unix(),
  7624. Number: chrg_bchno,
  7625. ErrMsg: res.ErrMsg,
  7626. Status: 1,
  7627. PatientId: id,
  7628. RecordTime: recordDateTime,
  7629. Stage: 20,
  7630. }
  7631. service.CreateErrMsgLog(errlog)
  7632. c.ServeSuccessJSON(map[string]interface{}{
  7633. "failed_code": -10,
  7634. "msg": res.ErrMsg,
  7635. })
  7636. return
  7637. } else {
  7638. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7639. order.OrderStatus = 1
  7640. order.IsPre = 1
  7641. order.Status = 1
  7642. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7643. // order.SetlId = res.Output.Setlinfo.SetlID
  7644. order.PsnNo = res.Output.Setlinfo.PsnNo
  7645. order.PsnName = res.Output.Setlinfo.PsnName
  7646. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7647. order.Certno = res.Output.Setlinfo.Certno
  7648. order.Gend = res.Output.Setlinfo.Gend
  7649. order.Naty = res.Output.Setlinfo.Naty
  7650. order.Age = res.Output.Setlinfo.Age
  7651. order.Insutype = res.Output.Setlinfo.Insutype
  7652. order.PsnType = res.Output.Setlinfo.PsnType
  7653. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7654. order.SetlTime = res.Output.Setlinfo.SetlTime
  7655. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7656. if res.Output.Setlinfo.MedType == "140101" {
  7657. order.MedType = "14"
  7658. } else {
  7659. order.MedType = res.Output.Setlinfo.MedType
  7660. }
  7661. if reg_type == 1112 {
  7662. order.MedType = "1112"
  7663. }
  7664. if reg_type == 1111 {
  7665. order.MedType = "1111"
  7666. }
  7667. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7668. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7669. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7670. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7671. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7672. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7673. order.HifpPay = res.Output.Setlinfo.HifpPay
  7674. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7675. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7676. order.HifesPay = res.Output.Setlinfo.HifesPay
  7677. order.HifobPay = res.Output.Setlinfo.HifobPay
  7678. order.MafPay = res.Output.Setlinfo.MafPay
  7679. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7680. order.OthPay = res.Output.Setlinfo.OthPay
  7681. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7682. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7683. order.AcctPay = res.Output.Setlinfo.AcctPay
  7684. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7685. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7686. order.Balc = res.Output.Setlinfo.Balc
  7687. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7688. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7689. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7690. order.ClrWay = res.Output.Setlinfo.ClrWay
  7691. order.Creator = order.Creator
  7692. order.Modify = roles.AdminUserId
  7693. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7694. detailStr := string(setlDetail)
  7695. order.SetlDetail = detailStr
  7696. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7697. err = service.UpDateOrder(order)
  7698. if err == nil {
  7699. c.ServeSuccessJSON(map[string]interface{}{
  7700. "msg": "预结算成功",
  7701. })
  7702. } else {
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7704. return
  7705. }
  7706. }
  7707. } else {
  7708. adminUser := c.GetAdminUserInfo()
  7709. errlog := &models.HisOrderError{
  7710. UserOrgId: adminUser.CurrentOrgId,
  7711. Ctime: time.Now().Unix(),
  7712. Mtime: time.Now().Unix(),
  7713. ErrMsg: res.ErrMsg,
  7714. Status: 1,
  7715. PatientId: id,
  7716. RecordTime: recordDateTime,
  7717. Stage: 4,
  7718. }
  7719. service.CreateErrMsgLog(errlog)
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7721. return
  7722. }
  7723. } else {
  7724. adminUser := c.GetAdminUserInfo()
  7725. errlog := &models.HisOrderError{
  7726. UserOrgId: adminUser.CurrentOrgId,
  7727. Ctime: time.Now().Unix(),
  7728. Mtime: time.Now().Unix(),
  7729. ErrMsg: res.ErrMsg,
  7730. Status: 1,
  7731. PatientId: id,
  7732. RecordTime: recordDateTime,
  7733. Stage: 4,
  7734. }
  7735. service.CreateErrMsgLog(errlog)
  7736. c.ServeSuccessJSON(map[string]interface{}{
  7737. "failed_code": -10,
  7738. "msg": res.ErrMsg,
  7739. })
  7740. return
  7741. }
  7742. }
  7743. }
  7744. }
  7745. //func (c *HisApiController) GetSettleInfo() {
  7746. // id, _ := c.GetInt64("id")
  7747. // order_id, _ := c.GetInt64("order_id")
  7748. //
  7749. // record_time := c.GetString("record_time")
  7750. // pay_way, _ := c.GetInt64("pay_way")
  7751. // pay_price, _ := c.GetFloat("pay_price")
  7752. // pay_card_no := c.GetString("pay_card_no")
  7753. // discount_price, _ := c.GetFloat("discount_price")
  7754. // preferential_price, _ := c.GetFloat("preferential_price")
  7755. // reality_price, _ := c.GetFloat("reality_price")
  7756. // found_price, _ := c.GetFloat("found_price")
  7757. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7758. // private_price, _ := c.GetFloat("private_price")
  7759. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7760. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7761. //
  7762. // timeLayout := "2006-01-02"
  7763. // loc, _ := time.LoadLocation("Local")
  7764. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7765. // if err != nil {
  7766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7767. // return
  7768. // }
  7769. // recordDateTime := theTime.Unix()
  7770. // adminUser := c.GetAdminUserInfo()
  7771. //
  7772. // var prescriptions []*models.HisPrescription
  7773. //
  7774. // data := make(map[string]interface{})
  7775. // if settle_accounts_type == 1 { //日结
  7776. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7777. // data["pre"] = prescriptions
  7778. //
  7779. // } else { //月结
  7780. // start_time_str := c.GetString("start_time")
  7781. // end_time_str := c.GetString("end_time")
  7782. // timeLayout := "2006-01-02"
  7783. // loc, _ := time.LoadLocation("Local")
  7784. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7785. // if err != nil {
  7786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7787. // return
  7788. // }
  7789. // recordStartTime := theStartTime.Unix()
  7790. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7791. // if err != nil {
  7792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7793. // return
  7794. // }
  7795. // recordEndTime := theEndTime.Unix()
  7796. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7797. // data["pre"] = prescriptions
  7798. //
  7799. // }
  7800. //
  7801. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7802. //
  7803. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7804. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7805. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7806. // strconv.FormatInt(his.PatientId, 10)
  7807. //
  7808. // order_src, _ := service.GetHisOrderByID(order_id)
  7809. //
  7810. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7811. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7812. //
  7813. // var total float64
  7814. // for _, item := range prescriptions {
  7815. // if item.Type == 1 { //药品
  7816. // for _, subItem := range item.HisDoctorAdviceInfo {
  7817. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7818. // }
  7819. // }
  7820. // if item.Type == 2 { //项目
  7821. // for _, subItem := range item.HisPrescriptionProject {
  7822. // total = total + (subItem.Price * float64(subItem.Count))
  7823. // }
  7824. // }
  7825. // }
  7826. //
  7827. // for _, item := range prescriptions {
  7828. // for _, subItem := range item.HisAdditionalCharge {
  7829. // total = total + (subItem.Price * float64(subItem.Count))
  7830. // }
  7831. // }
  7832. //
  7833. // allTotal := fmt.Sprintf("%.2f", total)
  7834. // var rf []*ResultFive
  7835. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7836. // psn_no := order_src.PsnNo
  7837. // mdtrt_id := order_src.MdtrtId
  7838. // chrg_bchno := order_src.Number
  7839. // cert_no := order_src.Certno
  7840. // insutype := rf[0].Insutype
  7841. //
  7842. // if his.IdCardType == 1 {
  7843. // cert_no = his.MedicalInsuranceNumber
  7844. // } else {
  7845. // cert_no = his.Certno
  7846. // }
  7847. //
  7848. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7849. // var dat map[string]interface{}
  7850. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7851. // fmt.Println(dat)
  7852. // } else {
  7853. // fmt.Println(err)
  7854. // }
  7855. //
  7856. // userJSONBytes, _ := json.Marshal(dat)
  7857. //
  7858. //
  7859. //
  7860. // var res ResultSeven
  7861. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7862. // utils.ErrorLog("解析失败:%v", err)
  7863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7864. // return
  7865. // }
  7866. // if res.Infcode == -1 {
  7867. // errlog := &models.HisOrderError{
  7868. // UserOrgId: adminUser.CurrentOrgId,
  7869. // Ctime: time.Now().Unix(),
  7870. // Mtime: time.Now().Unix(),
  7871. // Number: chrg_bchno,
  7872. // ErrMsg: res.ErrMsg,
  7873. // Status: 1,
  7874. // PatientId: id,
  7875. // RecordTime: recordDateTime,
  7876. // Stage: 6,
  7877. // }
  7878. // service.CreateErrMsgLog(errlog)
  7879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7880. // return
  7881. // } else {
  7882. // order_src.OrderStatus = 2
  7883. // order_src.PayWay = pay_way
  7884. // order_src.PayPrice = pay_price
  7885. // order_src.PayCardNo = pay_card_no
  7886. // order_src.DiscountPrice = discount_price
  7887. // order_src.PreferentialPrice = preferential_price
  7888. // order_src.RealityPrice = reality_price
  7889. // order_src.FoundPrice = found_price
  7890. // order_src.MedicalInsurancePrice = medical_insurance_price
  7891. // order_src.PrivatePrice = private_price
  7892. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7893. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7894. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7895. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7896. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7897. // order_src.Certno = res.Output.Setlinfo.Certno
  7898. // order_src.Gend = res.Output.Setlinfo.Gend
  7899. // order_src.Naty = res.Output.Setlinfo.Naty
  7900. // order_src.Age = res.Output.Setlinfo.Age
  7901. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7902. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7903. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7904. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7905. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7906. // order_src.MedType = res.Output.Setlinfo.MedType
  7907. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7908. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7909. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7910. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7911. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7912. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7913. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7914. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7915. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7916. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7917. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7918. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7919. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7920. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7921. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7922. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7923. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7924. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7925. // order_src.Balc = res.Output.Setlinfo.Balc
  7926. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7927. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7928. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7929. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7930. // order_src.Creator = order_src.Creator
  7931. // order_src.Modify = roles.ID
  7932. // order_src.RequestLog = src_resquest
  7933. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7934. // detailStr := string(setlDetail)
  7935. // order_src.SetlDetail = detailStr
  7936. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7937. // err = service.UpDateOrder(order_src)
  7938. //
  7939. // if err == nil {
  7940. // c.ServeSuccessJSON(map[string]interface{}{
  7941. // "msg": "结算成功",
  7942. // })
  7943. // } else {
  7944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7945. // return
  7946. // }
  7947. // }
  7948. // }
  7949. //}
  7950. // 退款
  7951. func (c *HisApiController) Refund() {
  7952. order_id, _ := c.GetInt64("order_id")
  7953. admin_user_id, _ := c.GetInt64("admin_user_id")
  7954. adminUser := c.GetAdminUserInfo()
  7955. var order models.HisOrder
  7956. order, _ = service.GetHisOrderByID(order_id)
  7957. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7958. if order.ID == 0 {
  7959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7960. return
  7961. }
  7962. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7964. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7965. if config.IsOpen == 1 { //对接了医保,走医保流程
  7966. var res ResultFourteen
  7967. var resSixteen10265 ResultSixteen10265
  7968. var src_resquest string
  7969. var result string
  7970. if miConfig.MdtrtareaAdmvs == "421300" {
  7971. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7972. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7973. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7974. resp3, requestErr3 := http.Get(api3)
  7975. if requestErr3 != nil {
  7976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. return
  7978. }
  7979. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7980. if ioErr3 != nil {
  7981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7983. return
  7984. }
  7985. var respJSON3 map[string]interface{}
  7986. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7992. userJSONBytes3, _ := json.Marshal(respJSON3)
  7993. fmt.Println("log")
  7994. fmt.Println(string(userJSONBytes3))
  7995. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7996. utils.ErrorLog("解析失败:%v", err)
  7997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7998. return
  7999. }
  8000. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8001. var api3 string
  8002. if miConfig.MdtrtareaAdmvs == "320921" {
  8003. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8004. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8006. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8007. } else {
  8008. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8009. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8010. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8011. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8012. }
  8013. resp3, requestErr3 := http.Get(api3)
  8014. if requestErr3 != nil {
  8015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8016. return
  8017. }
  8018. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8019. if ioErr3 != nil {
  8020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. var respJSON3 map[string]interface{}
  8025. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8031. userJSONBytes3, _ := json.Marshal(respJSON3)
  8032. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8033. utils.ErrorLog("解析失败:%v", err)
  8034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8035. return
  8036. }
  8037. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8038. // res.Output = resSixteen10265.Output
  8039. res.ErrMsg = resSixteen10265.ErrMsg
  8040. // res.Cainfo = resSixteen10265.Cainfo
  8041. // res.WarnMsg = resSixteen10265.WarnMsg
  8042. // infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8043. // res.Infcode = infocode
  8044. } else {
  8045. if miConfig.Code == "H15049901371" {
  8046. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8047. var dat map[string]interface{}
  8048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8049. fmt.Println(dat)
  8050. } else {
  8051. fmt.Println(err)
  8052. }
  8053. saveLog(result, src_resquest, "2208", "退费")
  8054. userJSONBytes, _ := json.Marshal(dat)
  8055. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8056. utils.ErrorLog("解析失败:%v", err)
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. return
  8059. }
  8060. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8061. // res.Output = resSixteen10265.Output
  8062. res.ErrMsg = resSixteen10265.ErrMsg
  8063. // res.Cainfo = resSixteen10265.Cainfo
  8064. // res.WarnMsg = resSixteen10265.WarnMsg
  8065. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8066. res.Infcode = infocode
  8067. } else {
  8068. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8069. var dat map[string]interface{}
  8070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8071. fmt.Println(dat)
  8072. } else {
  8073. fmt.Println(err)
  8074. }
  8075. saveLog(result, src_resquest, "2208", "退费")
  8076. userJSONBytes, _ := json.Marshal(dat)
  8077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8078. utils.ErrorLog("解析失败:%v", err)
  8079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. return
  8081. }
  8082. }
  8083. }
  8084. if res.Infcode == 0 {
  8085. var res2 ResultSix
  8086. var resSix10265 ResultSix10265
  8087. if miConfig.MdtrtareaAdmvs == "421300" {
  8088. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8089. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8090. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8091. resp3, requestErr3 := http.Get(api3)
  8092. if requestErr3 != nil {
  8093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8094. return
  8095. }
  8096. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8097. if ioErr3 != nil {
  8098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. var respJSON3 map[string]interface{}
  8103. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8106. return
  8107. }
  8108. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8109. userJSONBytes3, _ := json.Marshal(respJSON3)
  8110. fmt.Println("log")
  8111. fmt.Println(string(userJSONBytes3))
  8112. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8113. utils.ErrorLog("解析失败:%v", err)
  8114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. return
  8116. }
  8117. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8118. var api3 string
  8119. if miConfig.MdtrtareaAdmvs == "320921" {
  8120. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8121. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8123. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8124. } else {
  8125. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8126. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8127. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8129. }
  8130. resp3, requestErr3 := http.Get(api3)
  8131. if requestErr3 != nil {
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8136. if ioErr3 != nil {
  8137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. return
  8140. }
  8141. var respJSON3 map[string]interface{}
  8142. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8148. userJSONBytes3, _ := json.Marshal(respJSON3)
  8149. fmt.Println("log")
  8150. fmt.Println(string(userJSONBytes3))
  8151. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8152. utils.ErrorLog("解析失败:%v", err)
  8153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. return
  8155. }
  8156. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8157. // res2.Output = resSix10265.Output
  8158. res2.ErrMsg = resSix10265.ErrMsg
  8159. res2.Cainfo = resSix10265.Cainfo
  8160. res2.WarnMsg = resSix10265.WarnMsg
  8161. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8162. res2.Infcode = infocode
  8163. } else {
  8164. if miConfig.Code == "H15049901371" {
  8165. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8166. var dat map[string]interface{}
  8167. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8168. fmt.Println(dat)
  8169. } else {
  8170. fmt.Println(err)
  8171. }
  8172. saveLog(result2, src_request, "2205", "撤销明细")
  8173. userJSONBytes, _ := json.Marshal(dat)
  8174. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8180. // res2.Output = resSix10265.Output
  8181. res2.ErrMsg = resSix10265.ErrMsg
  8182. res2.Cainfo = resSix10265.Cainfo
  8183. res2.WarnMsg = resSix10265.WarnMsg
  8184. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8185. res2.Infcode = infocode
  8186. } else {
  8187. order_infos, _ := service.GetHisOrderInfoByNumberFour(order.Number)
  8188. for _, item := range order_infos {
  8189. result2, src_request := service.Gdyb2205ForGz(order.PsnNo, order.MdtrtId, item.FeedetlSn, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8190. var dat map[string]interface{}
  8191. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8192. fmt.Println(dat)
  8193. } else {
  8194. fmt.Println(err)
  8195. }
  8196. saveLog(result2, src_request, "2205", "撤销明细")
  8197. userJSONBytes, _ := json.Marshal(dat)
  8198. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8199. utils.ErrorLog("解析失败:%v", err)
  8200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8201. return
  8202. }
  8203. }
  8204. }
  8205. }
  8206. if res2.Infcode == 0 {
  8207. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8208. if err == nil {
  8209. //当押金不为零时产生退费记录
  8210. if order.Decimal != 0 {
  8211. tmp := strconv.FormatInt(order.ID, 10)
  8212. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8213. if err != nil {
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. }
  8218. c.ServeSuccessJSON(map[string]interface{}{
  8219. "msg": "退费成功",
  8220. })
  8221. } else {
  8222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8223. return
  8224. }
  8225. } else {
  8226. c.ServeSuccessJSON(map[string]interface{}{
  8227. "code": -10,
  8228. "msg": res2.ErrMsg,
  8229. })
  8230. }
  8231. } else {
  8232. c.ServeSuccessJSON(map[string]interface{}{
  8233. "code": -10,
  8234. "msg": res.ErrMsg,
  8235. })
  8236. }
  8237. }
  8238. }
  8239. func (c *HisApiController) RefundNumber() {
  8240. record_time := c.GetString("record_time")
  8241. //patient_id, _ := c.GetInt64("patient_id")
  8242. admin_user_id, _ := c.GetInt64("admin_user_id")
  8243. his_patient_id, _ := c.GetInt64("id")
  8244. timeLayout := "2006-01-02"
  8245. loc, _ := time.LoadLocation("Local")
  8246. adminUser := c.GetAdminUserInfo()
  8247. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8248. fmt.Println(err)
  8249. if err != nil {
  8250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8251. return
  8252. }
  8253. recordDateTime := theTime.Unix()
  8254. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8255. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8256. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8257. //order, _ := service.GetHisOrderByID(order_id)
  8258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8259. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8260. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8261. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8262. if count > 0 {
  8263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8264. return
  8265. }
  8266. if config.IsOpen == 1 { //对接了医保,走医保流程
  8267. var res2 ResultSix
  8268. var resSix10265 ResultSix10265
  8269. if miConfig.MdtrtareaAdmvs == "421300" {
  8270. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8271. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8273. resp3, requestErr3 := http.Get(api3)
  8274. if requestErr3 != nil {
  8275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8276. return
  8277. }
  8278. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8279. if ioErr3 != nil {
  8280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8282. return
  8283. }
  8284. var respJSON3 map[string]interface{}
  8285. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8291. userJSONBytes3, _ := json.Marshal(respJSON3)
  8292. fmt.Println("log")
  8293. fmt.Println(string(userJSONBytes3))
  8294. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8295. utils.ErrorLog("解析失败:%v", err)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8300. var api3 string
  8301. if miConfig.MdtrtareaAdmvs == "320921" {
  8302. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8303. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8304. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8305. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8306. } else {
  8307. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8308. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8309. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8310. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8311. }
  8312. resp3, requestErr3 := http.Get(api3)
  8313. if requestErr3 != nil {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8318. if ioErr3 != nil {
  8319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. var respJSON3 map[string]interface{}
  8324. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8330. userJSONBytes3, _ := json.Marshal(respJSON3)
  8331. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8332. utils.ErrorLog("解析失败:%v", err)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8337. // res2.Output = resSix10265.Output
  8338. res2.ErrMsg = resSix10265.ErrMsg
  8339. res2.Cainfo = resSix10265.Cainfo
  8340. res2.WarnMsg = resSix10265.WarnMsg
  8341. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8342. res2.Infcode = infocode
  8343. } else {
  8344. var api3 string
  8345. if miConfig.Code == "H15049901371" {
  8346. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8347. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8348. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8349. } else {
  8350. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8351. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8352. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8353. }
  8354. resp3, requestErr3 := http.Get(api3)
  8355. if requestErr3 != nil {
  8356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8357. return
  8358. }
  8359. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8360. if ioErr3 != nil {
  8361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8363. return
  8364. }
  8365. var respJSON3 map[string]interface{}
  8366. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8369. return
  8370. }
  8371. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8372. userJSONBytes3, _ := json.Marshal(respJSON3)
  8373. if miConfig.Code == "H15049901371" {
  8374. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8375. utils.ErrorLog("解析失败:%v", err)
  8376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8377. return
  8378. }
  8379. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8380. // res2.Output = resSix10265.Output
  8381. res2.ErrMsg = resSix10265.ErrMsg
  8382. res2.Cainfo = resSix10265.Cainfo
  8383. res2.WarnMsg = resSix10265.WarnMsg
  8384. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8385. res2.Infcode = infocode
  8386. } else {
  8387. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8388. utils.ErrorLog("解析失败:%v", err)
  8389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. return
  8391. }
  8392. }
  8393. }
  8394. if res2.Infcode == 0 {
  8395. if err == nil {
  8396. c.ServeSuccessJSON(map[string]interface{}{
  8397. "msg": "退号成功",
  8398. })
  8399. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8400. } else {
  8401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8402. return
  8403. }
  8404. } else {
  8405. c.ServeSuccessJSON(map[string]interface{}{
  8406. "code": -10,
  8407. "msg": res2.ErrMsg,
  8408. })
  8409. }
  8410. } else {
  8411. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8412. //if err == nil {
  8413. // c.ServeSuccessJSON(map[string]interface{}{
  8414. // "msg": "退费成功",
  8415. // })
  8416. //} else {
  8417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. // return
  8419. //}
  8420. }
  8421. }
  8422. func (c *HisApiController) RefundDetail() {
  8423. order_id, _ := c.GetInt64("order_id")
  8424. admin_user_id, _ := c.GetInt64("admin_user_id")
  8425. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8426. number := c.GetString("number")
  8427. record_time := c.GetString("record_time")
  8428. patient_id, _ := c.GetInt64("patient_id")
  8429. //med_type, _ := c.GetInt64("med_type")
  8430. timeLayout := "2006-01-02"
  8431. loc, _ := time.LoadLocation("Local")
  8432. adminUser := c.GetAdminUserInfo()
  8433. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8435. fmt.Println(err)
  8436. if err != nil {
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8438. return
  8439. }
  8440. recordDateTime := theTime.Unix()
  8441. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8442. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8444. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8445. var order models.HisOrder
  8446. order, _ = service.GetHisOrderByID(order_id)
  8447. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8448. if config.IsOpen == 1 { //对接了医保,走医保流程
  8449. var res2 ResultSix
  8450. if miConfig.MdtrtareaAdmvs == "421300" {
  8451. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8452. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8453. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8454. resp3, requestErr3 := http.Get(api3)
  8455. if requestErr3 != nil {
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8460. if ioErr3 != nil {
  8461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return
  8464. }
  8465. var respJSON3 map[string]interface{}
  8466. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8469. return
  8470. }
  8471. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8472. userJSONBytes3, _ := json.Marshal(respJSON3)
  8473. fmt.Println("log")
  8474. fmt.Println(string(userJSONBytes3))
  8475. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8476. utils.ErrorLog("解析失败:%v", err)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return
  8479. }
  8480. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8481. if err == nil {
  8482. c.ServeSuccessJSON(map[string]interface{}{
  8483. "msg": "撤销明细成功",
  8484. })
  8485. return
  8486. } else {
  8487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8488. return
  8489. }
  8490. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8491. var resSix10265 ResultSix10265
  8492. var api3 string
  8493. if miConfig.MdtrtareaAdmvs == "320921" {
  8494. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8495. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8497. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8498. } else {
  8499. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8500. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8501. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8503. }
  8504. resp3, requestErr3 := http.Get(api3)
  8505. if requestErr3 != nil {
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8510. if ioErr3 != nil {
  8511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. var respJSON3 map[string]interface{}
  8516. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8522. userJSONBytes3, _ := json.Marshal(respJSON3)
  8523. fmt.Println("log")
  8524. fmt.Println(string(userJSONBytes3))
  8525. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8531. // res2.Output = resSix10265.Output
  8532. res2.ErrMsg = resSix10265.ErrMsg
  8533. res2.Cainfo = resSix10265.Cainfo
  8534. res2.WarnMsg = resSix10265.WarnMsg
  8535. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8536. res2.Infcode = infocode
  8537. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8538. if err == nil {
  8539. c.ServeSuccessJSON(map[string]interface{}{
  8540. "msg": "撤销明细成功",
  8541. })
  8542. return
  8543. } else {
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. } else {
  8548. order_infos, _ := service.GetHisOrderInfoByNumberFour(order.Number)
  8549. for _, item := range order_infos {
  8550. result2, src_request := service.Gdyb2205ForGz(order.PsnNo, order.MdtrtId, item.FeedetlSn, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8551. var dat map[string]interface{}
  8552. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8553. fmt.Println(dat)
  8554. } else {
  8555. fmt.Println(err)
  8556. }
  8557. saveLog(result2, src_request, "2205", "撤销明细")
  8558. userJSONBytes, _ := json.Marshal(dat)
  8559. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8560. utils.ErrorLog("解析失败:%v", err)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. }
  8565. }
  8566. }
  8567. }
  8568. // 对账
  8569. func (c *HisApiController) GetCheckAccount() {
  8570. start_time := c.GetString("start_time")
  8571. end_time := c.GetString("end_time")
  8572. insutype := c.GetString("insutype")
  8573. clr_type := c.GetString("clr_type")
  8574. clr_org := c.GetString("clr_optins")
  8575. admin_user_id, _ := c.GetInt64("admin_user_id")
  8576. adminUser := c.GetAdminUserInfo()
  8577. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8578. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8579. if len(clr_org) == 0 {
  8580. clr_org = miConfig.MdtrtareaAdmvs
  8581. }
  8582. timeLayout := "2006-01-02"
  8583. loc, _ := time.LoadLocation("Local")
  8584. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8585. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8586. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8587. fixmedins_setl_cnt := int64(len(orders))
  8588. var medfee_sumamt float64
  8589. var acct_pay float64
  8590. var fund_pay_sumamt float64
  8591. for _, item := range orders {
  8592. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8593. acct_pay = acct_pay + item.AcctPay
  8594. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8595. }
  8596. var user_name string
  8597. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8598. if role.ID == 0 {
  8599. user_name = "xxx"
  8600. } else {
  8601. user_name = role.UserName
  8602. }
  8603. var res ResultEight
  8604. var res10188 ResultEightFor10188
  8605. if config.IsOpen == 1 {
  8606. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8607. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8608. "insutype=" + insutype +
  8609. "&clr_type=" + "11" +
  8610. "&setl_optins=" + clr_org +
  8611. "&stmt_begndate=" + start_time +
  8612. "&stm_enddate=" + end_time +
  8613. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8614. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8615. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8616. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8617. "&fixmedins_code=" + miConfig.Code +
  8618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8619. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8620. "&secret_key=" + miConfig.SecretKey +
  8621. "&org_name=" + miConfig.OrgName +
  8622. "&doctor=" + user_name +
  8623. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8624. fmt.Println(api)
  8625. resp, requestErr := http.Get(api)
  8626. if requestErr != nil {
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. body, ioErr := ioutil.ReadAll(resp.Body)
  8631. fmt.Println(body)
  8632. if ioErr != nil {
  8633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8635. return
  8636. }
  8637. var respJSON map[string]interface{}
  8638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8641. return
  8642. }
  8643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8644. userJSONBytes, _ := json.Marshal(respJSON)
  8645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8646. utils.ErrorLog("解析失败:%v", err)
  8647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8648. return
  8649. }
  8650. res.InfRefmsgid = res10188.InfRefmsgid
  8651. res.Output = res10188.Output
  8652. res.ErrMsg = res10188.ErrMsg
  8653. res.Cainfo = res10188.Cainfo
  8654. res.WarnMsg = res10188.WarnMsg
  8655. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8656. res.Infcode = infocode
  8657. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8658. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8659. "insutype=" + insutype +
  8660. "&clr_type=" + "21" +
  8661. "&setl_optins=" + clr_org +
  8662. "&stmt_begndate=" + start_time +
  8663. "&stm_enddate=" + end_time +
  8664. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8665. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8666. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8667. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8668. "&fixmedins_code=" + miConfig.Code +
  8669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8670. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8671. "&secret_key=" + miConfig.SecretKey +
  8672. "&org_name=" + miConfig.OrgName +
  8673. "&doctor=" + user_name
  8674. resp, requestErr := http.Get(api)
  8675. if requestErr != nil {
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8677. return
  8678. }
  8679. body, ioErr := ioutil.ReadAll(resp.Body)
  8680. if ioErr != nil {
  8681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. var respJSON map[string]interface{}
  8686. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8692. result, _ := json.Marshal(respJSON)
  8693. fmt.Println("log")
  8694. fmt.Println(string(result))
  8695. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8696. utils.ErrorLog("解析失败:%v", err)
  8697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8698. return
  8699. }
  8700. res.InfRefmsgid = res10188.InfRefmsgid
  8701. res.Output = res10188.Output
  8702. res.ErrMsg = res10188.ErrMsg
  8703. res.Cainfo = res10188.Cainfo
  8704. res.WarnMsg = res10188.WarnMsg
  8705. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8706. res.Infcode = infocode
  8707. } else {
  8708. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8709. "insutype=" + insutype +
  8710. "&clr_type=" + clr_type +
  8711. "&setl_optins=" + "440104" +
  8712. "&stmt_begndate=" + start_time +
  8713. "&stm_enddate=" + end_time +
  8714. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8715. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8716. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8717. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8718. "&fixmedins_code=" + miConfig.Code +
  8719. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8720. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8721. "&secret_key=" + miConfig.SecretKey +
  8722. "&org_name=" + miConfig.OrgName +
  8723. "&doctor=" + user_name
  8724. fmt.Println(api)
  8725. resp, requestErr := http.Get(api)
  8726. if requestErr != nil {
  8727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8728. return
  8729. }
  8730. body, ioErr := ioutil.ReadAll(resp.Body)
  8731. fmt.Println(body)
  8732. if ioErr != nil {
  8733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8735. return
  8736. }
  8737. var respJSON map[string]interface{}
  8738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8744. userJSONBytes, _ := json.Marshal(respJSON)
  8745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8746. utils.ErrorLog("解析失败:%v", err)
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8748. return
  8749. }
  8750. }
  8751. if res.Infcode == 0 {
  8752. if res.Output.Stmtinfo.StmtRslt == "0" {
  8753. micc := &models.MedicalInsuranceCostCompare{
  8754. StartTime: startime.Unix(),
  8755. EndTime: endtime.Unix(),
  8756. Insutype: insutype,
  8757. CheckType: 1,
  8758. Num: fixmedins_setl_cnt,
  8759. Mtime: time.Now().Unix(),
  8760. Status: 1,
  8761. UserOrgId: adminUser.CurrentOrgId,
  8762. CostTotal: medfee_sumamt,
  8763. FuncTotal: fund_pay_sumamt,
  8764. PsnPay: acct_pay,
  8765. Creator: admin_user_id,
  8766. Ctime: time.Now().Unix(),
  8767. ClrType: clr_type,
  8768. }
  8769. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8770. if err == nil {
  8771. c.ServeSuccessJSON(map[string]interface{}{
  8772. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8773. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8774. })
  8775. } else {
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8777. }
  8778. } else {
  8779. c.ServeSuccessJSON(map[string]interface{}{
  8780. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8781. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8782. })
  8783. }
  8784. } else {
  8785. c.ServeSuccessJSON(map[string]interface{}{
  8786. "code": -10,
  8787. "msg": res.ErrMsg,
  8788. })
  8789. }
  8790. }
  8791. }
  8792. func (c *HisApiController) Check310() {
  8793. adminUser := c.GetAdminUserInfo()
  8794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8795. var user_name string
  8796. user_name = "高慧裕"
  8797. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8798. "insutype=" + "310" +
  8799. "&clr_type=" + "" +
  8800. "&setl_optins=" + "441202" +
  8801. "&stmt_begndate=" + "2022-03-01" +
  8802. "&stm_enddate=" + "2022-03-31" +
  8803. "&medfee_sumamt=" + "194930.12" +
  8804. "&fund_pay_sumamt=" + "188741.46" +
  8805. "&acct_pay=" + "0" +
  8806. "&fixmedins_setl_cnt=" + "452" +
  8807. "&fixmedins_code=" + miConfig.Code +
  8808. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8809. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8810. "&secret_key=" + miConfig.SecretKey +
  8811. "&org_name=" + miConfig.OrgName +
  8812. "&doctor=" + user_name
  8813. fmt.Println(api)
  8814. resp, requestErr := http.Get(api)
  8815. if requestErr != nil {
  8816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8817. return
  8818. }
  8819. body, ioErr := ioutil.ReadAll(resp.Body)
  8820. fmt.Println(body)
  8821. if ioErr != nil {
  8822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8824. return
  8825. }
  8826. var respJSON map[string]interface{}
  8827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8830. return
  8831. }
  8832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8833. userJSONBytes, _ := json.Marshal(respJSON)
  8834. var res ResultEight
  8835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8836. utils.ErrorLog("解析失败:%v", err)
  8837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8838. return
  8839. }
  8840. }
  8841. func (c *HisApiController) Check390() {
  8842. adminUser := c.GetAdminUserInfo()
  8843. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8844. var user_name string
  8845. user_name = "高慧裕"
  8846. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8847. "insutype=" + "390" +
  8848. "&clr_type=" + "" +
  8849. "&setl_optins=" + "441202" +
  8850. "&stmt_begndate=" + "2022-03-01" +
  8851. "&stm_enddate=" + "2022-03-31" +
  8852. "&medfee_sumamt=" + "1068448.89" +
  8853. "&fund_pay_sumamt=" + "1014677.62" +
  8854. "&acct_pay=" + "0" +
  8855. "&fixmedins_setl_cnt=" + "1950" +
  8856. "&fixmedins_code=" + miConfig.Code +
  8857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8858. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8859. "&secret_key=" + miConfig.SecretKey +
  8860. "&org_name=" + miConfig.OrgName +
  8861. "&doctor=" + user_name
  8862. fmt.Println(api)
  8863. resp, requestErr := http.Get(api)
  8864. if requestErr != nil {
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. body, ioErr := ioutil.ReadAll(resp.Body)
  8869. fmt.Println(body)
  8870. if ioErr != nil {
  8871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8873. return
  8874. }
  8875. var respJSON map[string]interface{}
  8876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8882. userJSONBytes, _ := json.Marshal(respJSON)
  8883. var res ResultEight
  8884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8885. utils.ErrorLog("解析失败:%v", err)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. }
  8890. // 对账明细
  8891. func (c *HisApiController) GetCheckDetailAccount() {
  8892. start_time := c.GetString("start_time")
  8893. end_time := c.GetString("end_time")
  8894. admin_user_id, _ := c.GetInt64("admin_user_id")
  8895. adminUser := c.GetAdminUserInfo()
  8896. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8897. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8898. timeLayout := "2006-01-02"
  8899. loc, _ := time.LoadLocation("Local")
  8900. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8901. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8902. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8903. rand.Seed(time.Now().UnixNano())
  8904. num := rand.Intn(30000)
  8905. Mkdir(miConfig.OrgName)
  8906. file := strconv.FormatInt(int64(num), 10)
  8907. file_name := file + ".txt"
  8908. zip_name := file + ".zip"
  8909. zip_path := miConfig.OrgName + "/" + zip_name
  8910. file_path := miConfig.OrgName + "/" + file_name
  8911. decimal.DivisionPrecision = 2
  8912. var medfee_sumamt float64
  8913. var psn_cash_pay float64
  8914. var fund_pay_sumamt float64
  8915. fixmedins_setl_cnt := int64(len(orders))
  8916. for _, item := range orders {
  8917. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8918. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8919. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8920. }
  8921. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8922. defer f.Close()
  8923. if err != nil {
  8924. fmt.Println(err.Error())
  8925. } else {
  8926. for _, item := range orders {
  8927. var refd_setl_flag string
  8928. if item.OrderStatus == 2 {
  8929. refd_setl_flag = "0"
  8930. var str string
  8931. str = item.SetlId + " " +
  8932. item.MdtrtId + " " +
  8933. item.PsnNo + " " +
  8934. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8935. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8936. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8937. _, err = f.Write([]byte(str))
  8938. }
  8939. if item.OrderStatus == 3 {
  8940. var str string
  8941. str = item.SetlId + " " +
  8942. item.MdtrtId + " " +
  8943. item.PsnNo + " " +
  8944. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8945. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8946. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8947. _, err = f.Write([]byte(str))
  8948. var str2 string
  8949. str2 = item.SetlId + " " +
  8950. item.MdtrtId + " " +
  8951. item.PsnNo + " " +
  8952. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8953. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8954. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8955. _, err = f.Write([]byte(str2))
  8956. }
  8957. }
  8958. }
  8959. Zip(file_path, zip_path)
  8960. fmt.Println(ReadFile(zip_path))
  8961. fmt.Println(string(ReadFile(zip_path)))
  8962. if config.IsOpen == 1 {
  8963. var user_name string
  8964. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8965. if role.ID == 0 {
  8966. user_name = "管理员"
  8967. } else {
  8968. user_name = role.UserName
  8969. }
  8970. baseParams := models.BaseParams{
  8971. SecretKey: miConfig.SecretKey,
  8972. FixmedinsCode: miConfig.Code,
  8973. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8974. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8975. OrgName: miConfig.OrgName,
  8976. Doctor: user_name,
  8977. }
  8978. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8979. var dat map[string]interface{}
  8980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8981. fmt.Println(dat)
  8982. } else {
  8983. fmt.Println(err)
  8984. }
  8985. userJSONBytes, _ := json.Marshal(dat)
  8986. var res ResultNine
  8987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8988. utils.ErrorLog("解析失败:%v", err)
  8989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8990. return
  8991. }
  8992. if res.Infcode == 0 {
  8993. fileNo := res.Output.FileQuryNo
  8994. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8995. "file_qury_no=" + fileNo +
  8996. "&setl_optins=" + "定点医保中心" +
  8997. "&stmt_begndate=" + start_time +
  8998. "&stm_enddate=" + end_time +
  8999. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9000. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9001. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9002. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9003. "&fixmedins_code=" + miConfig.Code +
  9004. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9005. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9006. "&secret_key=" + miConfig.SecretKey +
  9007. "&org_name=" + miConfig.OrgName +
  9008. "&doctor=" + user_name
  9009. resp, requestErr := http.Get(api)
  9010. if requestErr != nil {
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. body, ioErr := ioutil.ReadAll(resp.Body)
  9015. if ioErr != nil {
  9016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9018. return
  9019. }
  9020. var respJSON map[string]interface{}
  9021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9024. return
  9025. }
  9026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9027. userJSONBytes, _ := json.Marshal(respJSON)
  9028. var res ResultTen
  9029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9030. utils.ErrorLog("解析失败:%v", err)
  9031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9032. return
  9033. }
  9034. if res.Infcode == 0 {
  9035. service.Gdyb9102(baseParams, zip_name, fileNo)
  9036. micc := &models.MedicalInsuranceCostCompare{
  9037. StartTime: startime.Unix(),
  9038. EndTime: endtime.Unix(),
  9039. Insutype: "0",
  9040. CheckType: 2,
  9041. Num: fixmedins_setl_cnt,
  9042. Mtime: time.Now().Unix(),
  9043. Status: 1,
  9044. UserOrgId: adminUser.CurrentOrgId,
  9045. CostTotal: medfee_sumamt,
  9046. FuncTotal: fund_pay_sumamt,
  9047. PsnPay: psn_cash_pay,
  9048. Creator: admin_user_id,
  9049. Ctime: time.Now().Unix(),
  9050. }
  9051. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9052. c.ServeSuccessJSON(map[string]interface{}{
  9053. "msg": "明细对账成功",
  9054. })
  9055. }
  9056. } else {
  9057. }
  9058. }
  9059. }
  9060. type CustomOrderInfo struct {
  9061. Name string
  9062. Spec string
  9063. Unit string
  9064. Count float64
  9065. Price float64
  9066. Total float64
  9067. }
  9068. func (c *HisApiController) GetSettleAccounts() {
  9069. //id, _ := c.GetInt64("id")
  9070. //record_time := c.GetString("record_time")
  9071. order_id, _ := c.GetInt64("order_id")
  9072. admin_user_id, _ := c.GetInt64("admin_user_id")
  9073. //timeLayout := "2006-01-02"
  9074. //loc, _ := time.LoadLocation("Local")
  9075. //
  9076. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9077. //if err != nil {
  9078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9079. // return
  9080. //}
  9081. //recordDateTime := theTime.Unix()
  9082. adminUser := c.GetAdminUserInfo()
  9083. order, _ := service.GetHisOrderByID(order_id)
  9084. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9085. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9086. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9087. orderInfos = append(orderInfos, orderInfos_two...)
  9088. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9089. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9090. var diagnosis_ids []string
  9091. if his.ID > 0 {
  9092. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9093. } else {
  9094. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9095. }
  9096. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9097. var dia_config []*models.HisXtDiagnoseConfig
  9098. var name string
  9099. for _, item := range diagnosis_ids {
  9100. id, _ := strconv.ParseInt(item, 10, 64)
  9101. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9102. dia_config = append(dia_config, &diagnosisConfig)
  9103. if len(name) == 0 {
  9104. name = diagnosisConfig.ClassName
  9105. } else {
  9106. name = name + "," + diagnosisConfig.ClassName
  9107. }
  9108. }
  9109. var bedCostTotal float64 = 0 //床位总费
  9110. var bedCostSelfTotal float64 = 0 //床位自费
  9111. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9112. var operationCostTotal float64 = 0 //手术费
  9113. var operationCostSelfTotal float64 = 0 //手术费
  9114. var operationCostPartSelfTotal float64 = 0 //手术费
  9115. var otherCostTotal float64 = 0 //其他费用
  9116. var otherCostSelfTotal float64 = 0 //其他费用
  9117. var otherCostPartSelfTotal float64 = 0 //其他费用
  9118. var materialCostTotal float64 = 0 //材料费
  9119. var materialCostSelfTotal float64 = 0 //材料费
  9120. var materialCostPartSelfTotal float64 = 0 //材料费
  9121. var westernMedicineCostTotal float64 = 0 //西药费
  9122. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9123. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9124. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9125. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9126. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9127. var checkCostTotal float64 = 0 //检查费
  9128. var checkCostSelfTotal float64 = 0 //检查费
  9129. var checkCostPartSelfTotal float64 = 0 //检查费
  9130. var laboratoryCostTotal float64 = 0 //化验费
  9131. var laboratoryCostSelfTotal float64 = 0 //化验费
  9132. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9133. var treatCostTotal float64 = 0 //治疗费用
  9134. var treatCostSelfTotal float64 = 0 //治疗费用
  9135. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9136. decimal.DivisionPrecision = 2
  9137. for _, item := range orderInfos {
  9138. if item.MedChrgitmType == "01" { //床位费
  9139. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9140. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9141. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9142. }
  9143. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9144. if item.MedChrgitmType == "03" { //检查费
  9145. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9146. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9147. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9148. }
  9149. } else {
  9150. if item.MedChrgitmType == "03" { //检查费
  9151. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9152. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9153. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9154. }
  9155. }
  9156. if item.MedChrgitmType == "04" { //化验费
  9157. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9158. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9159. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9160. }
  9161. if item.MedChrgitmType == "05" { //治疗费
  9162. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9163. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9164. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9165. }
  9166. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  9167. fmt.Println("------------")
  9168. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9169. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9170. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9171. }
  9172. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  9173. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9174. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9175. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9176. }
  9177. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  9178. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9179. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9180. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9181. }
  9182. if item.MedChrgitmType == "09" { //西药费
  9183. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9184. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9185. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9186. }
  9187. if item.MedChrgitmType == "11" { //中成费
  9188. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9189. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9190. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9191. }
  9192. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9193. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9194. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9195. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9196. }
  9197. }
  9198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9200. var user_name string
  9201. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9202. if role.ID == 0 {
  9203. user_name = "管理员"
  9204. } else {
  9205. user_name = role.UserName
  9206. }
  9207. baseParams := models.BaseParams{
  9208. SecretKey: miConfig.SecretKey,
  9209. FixmedinsCode: miConfig.Code,
  9210. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9211. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9212. OrgName: miConfig.OrgName,
  9213. Doctor: user_name,
  9214. }
  9215. businessParams := models.BusinessParams{
  9216. PsnNo: order.PsnNo,
  9217. MdtrtId: order.MdtrtId,
  9218. SetlId: order.SetlId,
  9219. }
  9220. var res ResultEleven
  9221. var resEleven10265 ResultEleven10265
  9222. if config.IsOpen == 1 {
  9223. if miConfig.MdtrtareaAdmvs == "421300" {
  9224. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9225. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9226. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9227. resp, requestErr := http.Get(api)
  9228. if requestErr != nil {
  9229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9230. return
  9231. }
  9232. body, ioErr := ioutil.ReadAll(resp.Body)
  9233. if ioErr != nil {
  9234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9236. return
  9237. }
  9238. var respJSON map[string]interface{}
  9239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9242. return
  9243. }
  9244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9245. result, _ := json.Marshal(respJSON)
  9246. fmt.Println("log")
  9247. fmt.Println(string(result))
  9248. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9249. utils.ErrorLog("解析失败:%v", err)
  9250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9251. return
  9252. }
  9253. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9254. var api string
  9255. if miConfig.MdtrtareaAdmvs == "320921" {
  9256. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9257. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9258. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9259. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9260. } else {
  9261. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9262. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9263. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9264. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9265. }
  9266. resp, requestErr := http.Get(api)
  9267. if requestErr != nil {
  9268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9269. return
  9270. }
  9271. body, ioErr := ioutil.ReadAll(resp.Body)
  9272. if ioErr != nil {
  9273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9275. return
  9276. }
  9277. var respJSON map[string]interface{}
  9278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9281. return
  9282. }
  9283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9284. result, _ := json.Marshal(respJSON)
  9285. fmt.Println("log")
  9286. fmt.Println(string(result))
  9287. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9288. utils.ErrorLog("解析失败:%v", err)
  9289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9290. return
  9291. }
  9292. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9293. res.Output = resEleven10265.Output
  9294. res.ErrMsg = resEleven10265.ErrMsg
  9295. res.Cainfo = resEleven10265.Cainfo
  9296. res.WarnMsg = resEleven10265.WarnMsg
  9297. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9298. res.Infcode = infocode
  9299. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9300. fmt.Println("~~~~~~~")
  9301. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9302. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9304. resp, requestErr := http.Get(api)
  9305. if requestErr != nil {
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. body, ioErr := ioutil.ReadAll(resp.Body)
  9310. if ioErr != nil {
  9311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9313. return
  9314. }
  9315. var respJSON map[string]interface{}
  9316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9319. return
  9320. }
  9321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9322. result, _ := json.Marshal(respJSON)
  9323. fmt.Println("log")
  9324. fmt.Println(string(result))
  9325. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9326. utils.ErrorLog("解析失败:%v", err)
  9327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9328. return
  9329. }
  9330. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9331. res.Output = resEleven10265.Output
  9332. res.ErrMsg = resEleven10265.ErrMsg
  9333. res.Cainfo = resEleven10265.Cainfo
  9334. res.WarnMsg = resEleven10265.WarnMsg
  9335. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9336. res.Infcode = infocode
  9337. } else {
  9338. result := service.Gdyb5203(baseParams, businessParams)
  9339. //service.Gdyb5204(baseParams, businessParams)
  9340. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9341. var dat map[string]interface{}
  9342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9343. fmt.Println(dat)
  9344. } else {
  9345. fmt.Println(err)
  9346. }
  9347. userJSONBytes, _ := json.Marshal(dat)
  9348. if miConfig.Code == "H15049901371" {
  9349. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9350. utils.ErrorLog("解析失败:%v", err)
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9352. return
  9353. }
  9354. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9355. res.Output = resEleven10265.Output
  9356. res.ErrMsg = resEleven10265.ErrMsg
  9357. res.Cainfo = resEleven10265.Cainfo
  9358. res.WarnMsg = resEleven10265.WarnMsg
  9359. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9360. res.Infcode = infocode
  9361. } else {
  9362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9363. utils.ErrorLog("解析失败:%v", err)
  9364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9365. return
  9366. }
  9367. }
  9368. }
  9369. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9370. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9371. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9372. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9373. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9374. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9375. var doctor_name string
  9376. if roles.ID == 0 {
  9377. doctor_name = "管理员"
  9378. } else {
  9379. doctor_name = roles.UserName
  9380. }
  9381. yiliao_leibie := ""
  9382. switch order.MedType {
  9383. case "11":
  9384. yiliao_leibie = "普通门诊"
  9385. break
  9386. case "12":
  9387. yiliao_leibie = "门诊挂号"
  9388. break
  9389. case "13":
  9390. yiliao_leibie = "急诊"
  9391. break
  9392. case "14":
  9393. yiliao_leibie = "门诊特殊病"
  9394. break
  9395. case "15":
  9396. yiliao_leibie = "门诊统筹"
  9397. break
  9398. case "16":
  9399. yiliao_leibie = "门诊慢性病"
  9400. break
  9401. case "21":
  9402. yiliao_leibie = "普通住院"
  9403. break
  9404. }
  9405. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9406. if res.Infcode == 0 {
  9407. c.ServeSuccessJSON(map[string]interface{}{
  9408. "diagnosis": name,
  9409. "order_infos": orderInfos,
  9410. "number": order.MdtrtId,
  9411. "date": order.SettleAccountsDate,
  9412. "charge_admin": charge_admin,
  9413. "printor_admin": printor_admin,
  9414. "info": res.Output.Setlinfo,
  9415. "order": order,
  9416. "bedCostTotal": bedCostTotal,
  9417. "bedCostSelfTotal": bedCostSelfTotal,
  9418. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9419. "operationCostTotal": operationCostTotal,
  9420. "operationCostSelfTotal": operationCostSelfTotal,
  9421. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9422. "otherCostTotal": otherCostTotal,
  9423. "otherCostSelfTotal": otherCostSelfTotal,
  9424. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9425. "materialCostTotal": materialCostTotal,
  9426. "materialCostSelfTotal": materialCostSelfTotal,
  9427. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9428. "westernMedicineCostTotal": westernMedicineCostTotal,
  9429. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9430. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9431. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9432. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9433. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9434. "checkCostTotal": checkCostTotal,
  9435. "checkCostSelfTotal": checkCostSelfTotal,
  9436. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9437. "laboratoryCostTotal": laboratoryCostTotal,
  9438. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9439. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9440. "treatCostTotal": treatCostTotal,
  9441. "treatCostSelfTotal": treatCostSelfTotal,
  9442. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9443. "doctor_info": doctor_info,
  9444. "doctor_code": adminRole_two.DoctorCode,
  9445. "doctor_name": doctor_name,
  9446. "health_card_no": order.PsnNo,
  9447. "department": departments.Name,
  9448. "yiliao_leibie": yiliao_leibie,
  9449. "after_money": order.AccountPrice,
  9450. "patient": patient,
  9451. "org_name": miConfig.OrgName,
  9452. "org_code": miConfig.Code,
  9453. "order_number": order.Number,
  9454. "his_hospital": his_hospital,
  9455. "his": his,
  9456. "dia_config": dia_config,
  9457. //"check_order_info": cus_slice,
  9458. })
  9459. }
  9460. }
  9461. }
  9462. func (c *HisApiController) CheckTreatment() {
  9463. patient_id, _ := c.GetInt64("patient_id")
  9464. id_card_no := c.GetString("id_card_no")
  9465. insutype := c.GetString("insutype")
  9466. med_type := c.GetString("med_type")
  9467. admin_user_id, _ := c.GetInt64("admin_user_id")
  9468. adminUser := c.GetAdminUserInfo()
  9469. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9470. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9471. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9472. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9473. if miConfig.MdtrtareaAdmvs == "421300" {
  9474. var res ResultTwo
  9475. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9476. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9477. "&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)
  9478. resp, requestErr := http.Get(api)
  9479. if requestErr != nil {
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9481. return
  9482. }
  9483. body, ioErr := ioutil.ReadAll(resp.Body)
  9484. if ioErr != nil {
  9485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. var respJSON map[string]interface{}
  9490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9493. return
  9494. }
  9495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9496. result, _ := json.Marshal(respJSON)
  9497. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9498. utils.ErrorLog("解析失败:%v", err)
  9499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9500. return
  9501. }
  9502. if res.Infcode == 0 {
  9503. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9504. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9505. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output[0].Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9506. resp, requestErr := http.Get(api)
  9507. if requestErr != nil {
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. body, ioErr := ioutil.ReadAll(resp.Body)
  9512. if ioErr != nil {
  9513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9515. return
  9516. }
  9517. var respJSON map[string]interface{}
  9518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9521. return
  9522. }
  9523. var res Result2001
  9524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9525. result2, _ := json.Marshal(respJSON)
  9526. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9527. utils.ErrorLog("解析失败:%v", err)
  9528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. return
  9530. }
  9531. if res.Infcode == 0 {
  9532. c.ServeSuccessJSON(map[string]interface{}{
  9533. "msg": res.Output.Trtinfo,
  9534. })
  9535. }
  9536. } else {
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9538. return
  9539. }
  9540. } else {
  9541. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9542. var dat map[string]interface{}
  9543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9544. fmt.Println(dat)
  9545. } else {
  9546. fmt.Println(err)
  9547. }
  9548. userJSONBytes, _ := json.Marshal(dat)
  9549. var res ResultTwo
  9550. var res10265 ResultTwo10265
  9551. if miConfig.Code == "H15049901371" {
  9552. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9553. utils.ErrorLog("解析失败:%v", err)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. res.ErrMsg = res10265.ErrMsg
  9558. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9559. res.Infcode = infocode
  9560. //res.Output = res10265.Output
  9561. res.InfRefmsgid = res10265.InfRefmsgid
  9562. } else {
  9563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9564. utils.ErrorLog("解析失败:%v", err)
  9565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9566. return
  9567. }
  9568. }
  9569. var user_name string
  9570. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9571. if role.ID == 0 {
  9572. user_name = "xxx"
  9573. } else {
  9574. user_name = role.UserName
  9575. }
  9576. baseParams := models.BaseParams{
  9577. SecretKey: miConfig.SecretKey,
  9578. FixmedinsCode: miConfig.Code,
  9579. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9580. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9581. OrgName: miConfig.OrgName,
  9582. Doctor: user_name,
  9583. }
  9584. if config.IsOpen == 1 {
  9585. if miConfig.Code == "H15049901371" {
  9586. if med_type == "14" {
  9587. if insutype == "390" {
  9588. med_type = "9933"
  9589. } else if insutype == "310" {
  9590. med_type = "990502"
  9591. }
  9592. } else if med_type == "11" {
  9593. med_type = "11"
  9594. }
  9595. }
  9596. result := service.Gdyb2001(baseParams, res.Output[0].Baseinfo.PsnNo, insutype, med_type)
  9597. var dat map[string]interface{}
  9598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9599. fmt.Println(dat)
  9600. } else {
  9601. fmt.Println(err)
  9602. }
  9603. var res Result2001
  9604. var res10265 Result2001Org10265
  9605. if miConfig.Code == "H15049901371" {
  9606. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9607. utils.ErrorLog("解析失败:%v", err)
  9608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9609. return
  9610. }
  9611. res.ErrMsg = res10265.ErrMsg
  9612. res.Output = res10265.Output
  9613. res.InfRefmsgid = res10265.InfRefmsgid
  9614. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9615. res.Infcode = infocode
  9616. } else {
  9617. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9618. utils.ErrorLog("解析失败:%v", err)
  9619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9620. return
  9621. }
  9622. }
  9623. if res.Infcode == 0 {
  9624. c.ServeSuccessJSON(map[string]interface{}{
  9625. "msg": res.Output.Trtinfo,
  9626. })
  9627. }
  9628. }
  9629. }
  9630. }
  9631. //func (c *HisApiController) PutRecord() {
  9632. // id, _ := c.GetInt64("id")
  9633. // record_time := c.GetString("record_time")
  9634. // timeLayout := "2006-01-02"
  9635. // loc, _ := time.LoadLocation("Local")
  9636. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9637. // if err != nil {
  9638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9639. // return
  9640. // }
  9641. // recordDateTime := theTime.Unix()
  9642. //
  9643. // adminInfo := c.GetAdminUserInfo()
  9644. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9645. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9646. //
  9647. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9648. //
  9649. // fmt.Println(miConfig.SecretKey)
  9650. //
  9651. // if patient == nil {
  9652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9653. // return
  9654. // }
  9655. // if len(patient.IdCardNo) == 0 {
  9656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9657. // return
  9658. // }
  9659. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9660. // if config.IsOpen == 1 {
  9661. // 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
  9662. // resp, requestErr := http.Get(api)
  9663. // if requestErr != nil {
  9664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9665. // return
  9666. // }
  9667. // defer resp.Body.Close()
  9668. // body, ioErr := ioutil.ReadAll(resp.Body)
  9669. // if ioErr != nil {
  9670. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9672. // return
  9673. // }
  9674. // var respJSON map[string]interface{}
  9675. //
  9676. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9677. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9679. // return
  9680. // }
  9681. //
  9682. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9683. // userJSONBytes, _ := json.Marshal(userJSON)
  9684. // var res ResultTwo
  9685. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9686. // utils.ErrorLog("解析失败:%v", err)
  9687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9688. // return
  9689. // }
  9690. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9691. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9692. // infoStr := string(Iinfos)
  9693. // idetinfoStr := string(Idetinfos)
  9694. //
  9695. // if res.Infcode == 0 {
  9696. // his := models.VMHisPatient{
  9697. // Status: 1,
  9698. // Ctime: time.Now().Unix(),
  9699. // Mtime: time.Now().Unix(),
  9700. // PsnNo: res.Output.Baseinfo.PsnNo,
  9701. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9702. // Certno: res.Output.Baseinfo.Certno,
  9703. // PsnName: res.Output.Baseinfo.PsnName,
  9704. // Gend: res.Output.Baseinfo.Gend,
  9705. // Naty: res.Output.Baseinfo.Naty,
  9706. // Brdy: res.Output.Baseinfo.Brdy,
  9707. // Age: res.Output.Baseinfo.Age,
  9708. // Iinfo: infoStr,
  9709. // Idetinfo: idetinfoStr,
  9710. // PatientId: patient.ID,
  9711. // RecordDate: theTime.Unix(),
  9712. // UserOrgId: adminInfo.CurrentOrgId,
  9713. // AdminUserId: adminInfo.AdminUser.Id,
  9714. // IsReturn: 1,
  9715. // }
  9716. //
  9717. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9718. // //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")
  9719. // //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")
  9720. //
  9721. // //var dat map[string]interface{}
  9722. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9723. // // fmt.Println(dat)
  9724. // //} else {
  9725. // // fmt.Println(err)
  9726. // //}
  9727. //
  9728. // var dat2 map[string]interface{}
  9729. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9730. // fmt.Println(dat2)
  9731. // } else {
  9732. // fmt.Println(err)
  9733. // }
  9734. //
  9735. // } else {
  9736. // adminUser := c.GetAdminUserInfo()
  9737. // errlog := &models.HisOrderError{
  9738. // UserOrgId: adminUser.CurrentOrgId,
  9739. // Ctime: time.Now().Unix(),
  9740. // Mtime: time.Now().Unix(),
  9741. // ErrMsg: res.ErrMsg,
  9742. // Status: 1,
  9743. // PatientId: id,
  9744. // RecordTime: recordDateTime,
  9745. // Stage: 1,
  9746. // }
  9747. // service.CreateErrMsgLog(errlog)
  9748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9749. // return
  9750. // }
  9751. // }
  9752. //
  9753. //}
  9754. //func (c *HisApiController) GetUploadDiag() {
  9755. // id, _ := c.GetInt64("id")
  9756. // record_time := c.GetString("record_time")
  9757. //
  9758. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9759. // sick_type, _ := c.GetInt64("sick_type")
  9760. // reg_type, _ := c.GetInt64("reg_type")
  9761. //
  9762. // timeLayout := "2006-01-02"
  9763. // loc, _ := time.LoadLocation("Local")
  9764. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9765. // if err != nil {
  9766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9767. // return
  9768. // }
  9769. //
  9770. // var patientPrescription models.HisPrescriptionInfo
  9771. // recordDateTime := theTime.Unix()
  9772. // adminInfo := c.GetAdminUserInfo()
  9773. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9774. //
  9775. // if patientPrescription.ID == 0 {
  9776. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9777. // }
  9778. //
  9779. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9780. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9781. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9782. // sickConfig, _ := service.FindSickById(sick_type)
  9783. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9784. //
  9785. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9786. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9787. // "&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 +
  9788. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9789. // resp2, requestErr2 := http.Get(api2)
  9790. // if requestErr2 != nil {
  9791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9792. // return
  9793. // }
  9794. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9795. // if ioErr2 != nil {
  9796. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. // return
  9799. // }
  9800. // var respJSON2 map[string]interface{}
  9801. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9802. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. // return
  9805. // }
  9806. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9807. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9808. //
  9809. // var res2 ResultSix
  9810. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9811. // utils.ErrorLog("解析失败:%v", err)
  9812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9813. // return
  9814. // }
  9815. // if res2.Infcode != 0 {
  9816. // adminUser := c.GetAdminUserInfo()
  9817. // errlog := &models.HisOrderError{
  9818. // UserOrgId: adminUser.CurrentOrgId,
  9819. // Ctime: time.Now().Unix(),
  9820. // Mtime: time.Now().Unix(),
  9821. // ErrMsg: res2.ErrMsg,
  9822. // Status: 1,
  9823. // PatientId: id,
  9824. // RecordTime: recordDateTime,
  9825. // Stage: 3,
  9826. // }
  9827. // service.CreateErrMsgLog(errlog)
  9828. //
  9829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9830. // return
  9831. // }
  9832. //
  9833. // c.ServeSuccessJSON(map[string]interface{}{
  9834. // "msg": "上传成功",
  9835. // })
  9836. //
  9837. //}
  9838. type QueryResult struct {
  9839. ID int64
  9840. Name string
  9841. Code string
  9842. List_type_code string
  9843. }
  9844. func (c *HisApiController) GetCheckCode() {
  9845. ids_str := c.GetString("ids")
  9846. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9847. ids_arr := strings.Split(ids_str, ",")
  9848. var queryResult []QueryResult
  9849. ids := make([]int64, 0)
  9850. for _, item := range ids_arr {
  9851. id, _ := strconv.ParseInt(item, 10, 64)
  9852. ids = append(ids, id)
  9853. }
  9854. if record_type == 1 {
  9855. drugs, _ := service.GetBatchDrugList(ids)
  9856. for _, item := range drugs {
  9857. result := QueryResult{
  9858. ID: item.ID,
  9859. Name: item.DrugName,
  9860. Code: item.MedicalInsuranceNumber,
  9861. List_type_code: "101",
  9862. }
  9863. queryResult = append(queryResult, result)
  9864. }
  9865. } else if record_type == 2 {
  9866. goods, _ := service.GetBatchGoodInformationList(ids)
  9867. for _, item := range goods {
  9868. result := QueryResult{
  9869. ID: item.ID,
  9870. Name: item.GoodName,
  9871. Code: item.MedicalInsuranceNumber,
  9872. List_type_code: "301",
  9873. }
  9874. queryResult = append(queryResult, result)
  9875. }
  9876. } else if record_type == 3 {
  9877. projects, _ := service.GetBathchMyPorjecgList(ids)
  9878. for _, item := range projects {
  9879. result := QueryResult{
  9880. ID: item.ID,
  9881. Name: item.ProjectName,
  9882. Code: item.MedicalCode,
  9883. List_type_code: "201",
  9884. }
  9885. queryResult = append(queryResult, result)
  9886. }
  9887. }
  9888. admin_user_id, _ := c.GetInt64("admin_user_id")
  9889. adminUser := c.GetAdminUserInfo()
  9890. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9891. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9892. var user_name string
  9893. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9894. if role.ID == 0 {
  9895. user_name = "xxx"
  9896. } else {
  9897. user_name = role.UserName
  9898. }
  9899. baseParams := &models.BaseParams{
  9900. SecretKey: miConfig.SecretKey,
  9901. FixmedinsCode: miConfig.Code,
  9902. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9903. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9904. OrgName: miConfig.OrgName,
  9905. Doctor: user_name,
  9906. }
  9907. if config.IsOpen == 1 {
  9908. for _, item := range queryResult {
  9909. var result string
  9910. if record_type == 1 {
  9911. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9912. } else if record_type == 2 {
  9913. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9914. } else if record_type == 3 {
  9915. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9916. }
  9917. var dat map[string]interface{}
  9918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9919. fmt.Println(dat)
  9920. } else {
  9921. fmt.Println(err)
  9922. }
  9923. userJSONBytes, _ := json.Marshal(dat)
  9924. var res ResultSix
  9925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9926. utils.ErrorLog("解析失败:%v", err)
  9927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9928. return
  9929. }
  9930. if res.Infcode == 0 {
  9931. if record_type == 1 {
  9932. service.UpdateBaseDrugById(item.ID)
  9933. } else if record_type == 2 {
  9934. service.UpdateGoodInformaitonByDetail(item.ID)
  9935. } else if record_type == 3 {
  9936. service.UpdateProjectById(item.ID)
  9937. }
  9938. c.ServeSuccessJSON(map[string]interface{}{
  9939. "failed_code": 0,
  9940. "msg": "目录对照成功",
  9941. })
  9942. } else {
  9943. c.ServeSuccessJSON(map[string]interface{}{
  9944. "failed_code": -10,
  9945. "msg": res.ErrMsg,
  9946. })
  9947. }
  9948. }
  9949. }
  9950. }
  9951. func (c *HisApiController) UnCheckCode() {
  9952. ids_str := c.GetString("ids")
  9953. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9954. admin_user_id, _ := c.GetInt64("admin_user_id")
  9955. ids_arr := strings.Split(ids_str, ",")
  9956. var queryResult []QueryResult
  9957. ids := make([]int64, 0)
  9958. for _, item := range ids_arr {
  9959. id, _ := strconv.ParseInt(item, 10, 64)
  9960. ids = append(ids, id)
  9961. }
  9962. if record_type == 1 {
  9963. drugs, _ := service.GetBatchDrugList(ids)
  9964. for _, item := range drugs {
  9965. result := QueryResult{
  9966. ID: item.ID,
  9967. Name: item.DrugName,
  9968. Code: item.MedicalInsuranceNumber,
  9969. List_type_code: "101",
  9970. }
  9971. queryResult = append(queryResult, result)
  9972. }
  9973. } else if record_type == 2 {
  9974. goods, _ := service.GetBatchGoodInformationList(ids)
  9975. for _, item := range goods {
  9976. result := QueryResult{
  9977. ID: item.ID,
  9978. Name: item.GoodName,
  9979. Code: item.MedicalInsuranceNumber,
  9980. List_type_code: "301",
  9981. }
  9982. queryResult = append(queryResult, result)
  9983. }
  9984. } else if record_type == 3 {
  9985. projects, _ := service.GetBathchMyPorjecgList(ids)
  9986. for _, item := range projects {
  9987. result := QueryResult{
  9988. ID: item.ID,
  9989. Name: item.ProjectName,
  9990. Code: item.MedicalCode,
  9991. List_type_code: "201",
  9992. }
  9993. queryResult = append(queryResult, result)
  9994. }
  9995. }
  9996. adminUser := c.GetAdminUserInfo()
  9997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9998. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9999. var user_name string
  10000. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10001. if role.ID == 0 {
  10002. user_name = "xxx"
  10003. } else {
  10004. user_name = role.UserName
  10005. }
  10006. baseParams := &models.BaseParams{
  10007. SecretKey: miConfig.SecretKey,
  10008. FixmedinsCode: miConfig.Code,
  10009. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10010. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10011. OrgName: miConfig.OrgName,
  10012. Doctor: user_name,
  10013. }
  10014. if config.IsOpen == 1 {
  10015. for _, item := range queryResult {
  10016. var result string
  10017. if record_type == 1 {
  10018. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10019. } else if record_type == 2 {
  10020. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10021. } else if record_type == 3 {
  10022. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10023. }
  10024. var dat2 map[string]interface{}
  10025. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10026. fmt.Println(dat2)
  10027. } else {
  10028. fmt.Println(err)
  10029. }
  10030. userJSONBytes, _ := json.Marshal(dat2)
  10031. var res ResultSix
  10032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10033. utils.ErrorLog("解析失败:%v", err)
  10034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10035. return
  10036. }
  10037. if res.Infcode == 0 {
  10038. if record_type == 1 {
  10039. service.UpdateDrugByIdDetail(item.ID)
  10040. } else if record_type == 2 {
  10041. service.UpdateGoodInfoById(item.ID)
  10042. } else if record_type == 3 {
  10043. service.UpdateMyProjectById(item.ID)
  10044. }
  10045. c.ServeSuccessJSON(map[string]interface{}{
  10046. "failed_code": 0,
  10047. "msg": "撤销目录对照成功",
  10048. })
  10049. } else {
  10050. c.ServeSuccessJSON(map[string]interface{}{
  10051. "failed_code": -10,
  10052. "msg": res.ErrMsg,
  10053. })
  10054. }
  10055. }
  10056. }
  10057. }
  10058. func (c *HisApiController) GetPatientInfo() {
  10059. id_card_no := c.GetString("id_card_no")
  10060. admin_user_id, _ := c.GetInt64("admin_user_id")
  10061. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10062. if patient.ID == 0 {
  10063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10064. return
  10065. }
  10066. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10067. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10068. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10069. if config.IsOpen == 1 {
  10070. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10071. var dat map[string]interface{}
  10072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10073. fmt.Println(dat)
  10074. } else {
  10075. fmt.Println(err)
  10076. }
  10077. userJSONBytes, _ := json.Marshal(dat)
  10078. var res ResultTwo
  10079. var res10265 ResultTwo10265
  10080. if miConfig.Code == "H15049901371" {
  10081. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10082. utils.ErrorLog("解析失败:%v", err)
  10083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10084. return
  10085. }
  10086. res.ErrMsg = res10265.ErrMsg
  10087. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10088. res.Infcode = infocode
  10089. //res.Output = res10265.Output
  10090. res.InfRefmsgid = res10265.InfRefmsgid
  10091. } else {
  10092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10093. utils.ErrorLog("解析失败:%v", err)
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. }
  10098. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10099. // utils.ErrorLog("解析失败:%v", err)
  10100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10101. // return
  10102. //}
  10103. if res.Infcode != 0 {
  10104. c.ServeSuccessJSON(map[string]interface{}{
  10105. "failed_code": -10,
  10106. "msg": res.ErrMsg,
  10107. })
  10108. } else {
  10109. c.ServeSuccessJSON(map[string]interface{}{
  10110. "failed_code": 0,
  10111. "info": res,
  10112. })
  10113. }
  10114. }
  10115. }
  10116. func (c *HisApiController) PsnPutOnRecord() {
  10117. record_type, _ := c.GetInt64("type")
  10118. patient_id, _ := c.GetInt64("patient_id")
  10119. admin_user_id, _ := c.GetInt64("admin_user_id")
  10120. start_time := c.GetString("start_time")
  10121. end_time := c.GetString("end_time")
  10122. adminUser := c.GetAdminUserInfo()
  10123. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10124. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10125. var patients []*models.Patients
  10126. if record_type == 1 { //全部备案
  10127. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10128. patients = append(patients, patient...)
  10129. } else { //单个备案
  10130. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10131. patients = append(patients, patient)
  10132. }
  10133. var user_name string
  10134. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10135. if role.ID == 0 {
  10136. user_name = "xxx"
  10137. } else {
  10138. user_name = role.UserName
  10139. }
  10140. if config.IsOpen == 1 {
  10141. for _, item := range patients {
  10142. 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
  10143. resp, requestErr := http.Get(api)
  10144. if requestErr != nil {
  10145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10146. return
  10147. }
  10148. defer resp.Body.Close()
  10149. body, ioErr := ioutil.ReadAll(resp.Body)
  10150. if ioErr != nil {
  10151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. var respJSON map[string]interface{}
  10156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10159. return
  10160. }
  10161. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10162. userJSONBytes, _ := json.Marshal(userJSON)
  10163. var res ResultTwo
  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. result := service.Gdyb2505(res.Output[0].Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10171. var dat map[string]interface{}
  10172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10173. fmt.Println(dat)
  10174. } else {
  10175. fmt.Println(err)
  10176. }
  10177. userJSONBytes, _ := json.Marshal(dat)
  10178. var res2 ResultThirteen
  10179. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10180. utils.ErrorLog("解析失败:%v", err)
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. return
  10183. }
  10184. if res2.Infcode == 0 {
  10185. psnResult := &models.GdybPsnRecord{
  10186. UserOrgId: adminUser.CurrentOrgId,
  10187. PatientId: item.ID,
  10188. PsnNo: res.Output[0].Baseinfo.PsnNo,
  10189. Ctime: time.Now().Unix(),
  10190. Mtime: time.Now().Unix(),
  10191. Status: 1,
  10192. IsCancel: 1,
  10193. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10194. }
  10195. service.CreatePsnRecord(psnResult)
  10196. } else {
  10197. c.ServeSuccessJSON(map[string]interface{}{
  10198. "failed_code": -10,
  10199. "msg": res2.ErrMsg,
  10200. })
  10201. return
  10202. }
  10203. }
  10204. }
  10205. }
  10206. }
  10207. func (c *HisApiController) PsnUnPutOnRecord() {
  10208. id, _ := c.GetInt64("id")
  10209. //record_type, _ := c.GetInt64("type")
  10210. admin_user_id, _ := c.GetInt64("admin_user_id")
  10211. adminUser := c.GetAdminUserInfo()
  10212. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10213. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10214. var user_name string
  10215. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10216. if role.ID == 0 {
  10217. user_name = "xxx"
  10218. } else {
  10219. user_name = role.UserName
  10220. }
  10221. psn_record, _ := service.GetPsnRecordById(id)
  10222. if psn_record.ID == 0 {
  10223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10224. return
  10225. }
  10226. if config.IsOpen == 1 {
  10227. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10228. var dat map[string]interface{}
  10229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10230. fmt.Println(dat)
  10231. } else {
  10232. fmt.Println(err)
  10233. }
  10234. userJSONBytes, _ := json.Marshal(dat)
  10235. var res ResultFourteen
  10236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10237. utils.ErrorLog("解析失败:%v", err)
  10238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10239. return
  10240. }
  10241. if res.Infcode == 0 {
  10242. psn_record.IsCancel = 2
  10243. service.CreatePsnRecord(&psn_record)
  10244. } else {
  10245. c.ServeSuccessJSON(map[string]interface{}{
  10246. "failed_code": -10,
  10247. "msg": res.ErrMsg,
  10248. })
  10249. return
  10250. }
  10251. }
  10252. }
  10253. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10254. patient_id, _ := c.GetInt64("patient_id")
  10255. insutype_two := c.GetString("insutype")
  10256. psn_no := c.GetString("psn_no")
  10257. doctor_id, _ := c.GetInt64("doctor_id")
  10258. sick_id, _ := c.GetInt64("sick_id")
  10259. department_id, _ := c.GetInt64("department_id")
  10260. start_time := c.GetString("start_time")
  10261. end_time := c.GetString("end_time")
  10262. check_time := c.GetString("check_time")
  10263. adminUser := c.GetAdminUserInfo()
  10264. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10265. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10266. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10267. sick, _ := service.FindSickById(sick_id)
  10268. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10269. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10270. var res ResultTwo
  10271. var res10265 ResultTwo10265
  10272. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10273. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10274. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10275. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10276. "&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
  10277. resp, requestErr := http.Get(api)
  10278. if requestErr != nil {
  10279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10280. return
  10281. }
  10282. body, ioErr := ioutil.ReadAll(resp.Body)
  10283. if ioErr != nil {
  10284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10286. return
  10287. }
  10288. var respJSON map[string]interface{}
  10289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10292. return
  10293. }
  10294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10295. result, _ := json.Marshal(respJSON)
  10296. fmt.Println("log")
  10297. fmt.Println(string(result))
  10298. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10299. utils.ErrorLog("解析失败:%v", err)
  10300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10301. return
  10302. }
  10303. res.ErrMsg = res10265.ErrMsg
  10304. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10305. res.Infcode = infocode
  10306. //res.Output = res10265.Output
  10307. res.InfRefmsgid = res10265.InfRefmsgid
  10308. } else {
  10309. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10310. if miConfig.Code == "H15049901371" {
  10311. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10312. utils.ErrorLog("解析失败:%v", err)
  10313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10314. return
  10315. }
  10316. res.ErrMsg = res10265.ErrMsg
  10317. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10318. res.Infcode = infocode
  10319. //res.Output = res10265.Output
  10320. res.InfRefmsgid = res10265.InfRefmsgid
  10321. } else {
  10322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10323. utils.ErrorLog("解析失败:%v", err)
  10324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10325. return
  10326. }
  10327. }
  10328. }
  10329. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  10330. infoStr := string(Iinfos)
  10331. var rf []*ResultFive
  10332. json.Unmarshal([]byte(infoStr), &rf)
  10333. var insuplc_admdvs string
  10334. var insutype string
  10335. var is390 int = 0
  10336. var is310 int = 0
  10337. var insutypes []*ResultFive
  10338. for _, item := range rf {
  10339. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10340. insutypes = append(insutypes, item)
  10341. }
  10342. }
  10343. if len(insutypes) == 1 {
  10344. insutype = insutypes[0].Insutype
  10345. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10346. } else {
  10347. for _, i := range insutypes {
  10348. if i.Insutype == "390" {
  10349. is390 = 1
  10350. }
  10351. if i.Insutype == "310" {
  10352. is310 = 1
  10353. }
  10354. }
  10355. }
  10356. if is390 == 1 {
  10357. insutype = "390"
  10358. }
  10359. if is310 == 1 {
  10360. insutype = "310"
  10361. }
  10362. if len(insutypes) == 2 {
  10363. insutype = insutype_two
  10364. }
  10365. if len(insutypes) == 0 {
  10366. insutype = "310"
  10367. }
  10368. insutype = insutype_two
  10369. fmt.Println(insutype)
  10370. for _, item := range rf {
  10371. fmt.Println(item.Insutype)
  10372. fmt.Println(insutype)
  10373. if item.Insutype == insutype {
  10374. fmt.Println(item.Insutype)
  10375. fmt.Println(insutype)
  10376. insuplc_admdvs = item.InsuplcAdmdvs
  10377. }
  10378. }
  10379. fmt.Println(insuplc_admdvs)
  10380. var res2 ResultThirteen
  10381. var res10265_2 ResultThirteen10265
  10382. if config.IsOpen == 1 {
  10383. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10384. } else {
  10385. 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)
  10386. var dat map[string]interface{}
  10387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10388. fmt.Println(dat)
  10389. } else {
  10390. fmt.Println(err)
  10391. }
  10392. userJSONBytes, _ := json.Marshal(dat)
  10393. if miConfig.Code == "H15049901371" {
  10394. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10395. utils.ErrorLog("解析失败:%v", err)
  10396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10397. return
  10398. }
  10399. res2.ErrMsg = res10265_2.ErrMsg
  10400. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10401. res2.Infcode = infocode
  10402. res2.Output = res10265_2.Output
  10403. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10404. } else {
  10405. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10406. utils.ErrorLog("解析失败:%v", err)
  10407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10408. return
  10409. }
  10410. }
  10411. }
  10412. if res2.Infcode == 0 {
  10413. psnResult := &models.GdybPsnNcdsRecord{
  10414. UserOrgId: adminUser.CurrentOrgId,
  10415. PatientId: patient.ID,
  10416. PsnNo: psn_no,
  10417. DoctorId: doctor.AdminUserId,
  10418. DepartmentId: department_id,
  10419. SickType: sick_id,
  10420. Insutype: insutype,
  10421. Ctime: time.Now().Unix(),
  10422. Mtime: time.Now().Unix(),
  10423. Status: 1,
  10424. IsCancel: 1,
  10425. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10426. }
  10427. service.CreatePsnNCDSRecord(psnResult)
  10428. c.ServeSuccessJSON(map[string]interface{}{
  10429. "failed_code": 0,
  10430. "msg": "备案成功",
  10431. "result": psnResult,
  10432. })
  10433. } else {
  10434. c.ServeSuccessJSON(map[string]interface{}{
  10435. "failed_code": -10,
  10436. "msg": res2.ErrMsg,
  10437. })
  10438. return
  10439. }
  10440. }
  10441. }
  10442. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10443. id, _ := c.GetInt64("id")
  10444. admin_user_id, _ := c.GetInt64("admin_user_id")
  10445. adminUser := c.GetAdminUserInfo()
  10446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10447. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10448. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10449. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10450. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10451. //var user_name string
  10452. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10453. //if role.ID == 0 {
  10454. // user_name = "xxx"
  10455. //} else {
  10456. // user_name = role.UserName
  10457. //}
  10458. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10459. if psn_record.ID == 0 {
  10460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10461. return
  10462. }
  10463. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10464. var res ResultTwo
  10465. var res10265 ResultTwo10265
  10466. if miConfig.Code == "H15049901371" {
  10467. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10468. utils.ErrorLog("解析失败:%v", err)
  10469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10470. return
  10471. }
  10472. res.ErrMsg = res10265.ErrMsg
  10473. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10474. res.Infcode = infocode
  10475. //res.Output = res10265.Output
  10476. res.InfRefmsgid = res10265.InfRefmsgid
  10477. } else {
  10478. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10479. utils.ErrorLog("解析失败:%v", err)
  10480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10481. return
  10482. }
  10483. }
  10484. Iinfos, _ := json.Marshal(res.Output[0].Iinfo)
  10485. infoStr := string(Iinfos)
  10486. var rf []*ResultFive
  10487. json.Unmarshal([]byte(infoStr), &rf)
  10488. var insuplc_admdvs string
  10489. var insutype string
  10490. var is390 int = 0
  10491. var is310 int = 0
  10492. var insutypes []*ResultFive
  10493. for _, item := range rf {
  10494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10495. insutypes = append(insutypes, item)
  10496. }
  10497. }
  10498. if len(insutypes) == 1 {
  10499. insutype = insutypes[0].Insutype
  10500. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10501. } else {
  10502. for _, i := range insutypes {
  10503. if i.Insutype == "390" {
  10504. is390 = 1
  10505. }
  10506. if i.Insutype == "310" {
  10507. is310 = 1
  10508. }
  10509. }
  10510. }
  10511. if is390 == 1 {
  10512. insutype = "390"
  10513. }
  10514. if is310 == 1 {
  10515. insutype = "310"
  10516. }
  10517. if len(insutypes) == 0 {
  10518. insutype = "310"
  10519. }
  10520. insutype = psn_record.Insutype
  10521. for _, item := range rf {
  10522. if item.Insutype == insutype {
  10523. insuplc_admdvs = item.InsuplcAdmdvs
  10524. }
  10525. }
  10526. if config.IsOpen == 1 {
  10527. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10528. var dat map[string]interface{}
  10529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10530. fmt.Println(dat)
  10531. } else {
  10532. fmt.Println(err)
  10533. }
  10534. userJSONBytes, _ := json.Marshal(dat)
  10535. var res ResultFourteen
  10536. var res10265 ResultFourteen10265
  10537. if miConfig.Code == "H15049901371" {
  10538. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10539. utils.ErrorLog("解析失败:%v", err)
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return
  10542. }
  10543. res.ErrMsg = res10265.ErrMsg
  10544. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10545. res.Infcode = infocode
  10546. res.Output = res10265.Output
  10547. res.InfRefmsgid = res10265.InfRefmsgid
  10548. } else {
  10549. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10550. utils.ErrorLog("解析失败:%v", err)
  10551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10552. return
  10553. }
  10554. }
  10555. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10556. // utils.ErrorLog("解析失败:%v", err)
  10557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10558. // return
  10559. //}
  10560. if res.Infcode == 0 {
  10561. psn_record.IsCancel = 2
  10562. service.CreatePsnNCDSRecord(&psn_record)
  10563. c.ServeSuccessJSON(map[string]interface{}{
  10564. "failed_code": 0,
  10565. "msg": "撤销备案成功",
  10566. })
  10567. } else {
  10568. c.ServeSuccessJSON(map[string]interface{}{
  10569. "failed_code": -10,
  10570. "msg": res.ErrMsg,
  10571. })
  10572. return
  10573. }
  10574. }
  10575. }
  10576. func (c *HisApiController) TestTest() {
  10577. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10578. fmt.Println(patient.Iinfo)
  10579. }
  10580. type CustomData struct {
  10581. MsgId string
  10582. PsnNo string
  10583. Info string
  10584. }
  10585. func (c *HisApiController) ReversalData() {
  10586. var customData []*CustomData
  10587. custom := &CustomData{
  10588. MsgId: "H44022900158202103301714472004",
  10589. PsnNo: "44020000001101329945",
  10590. Info: "2207",
  10591. }
  10592. customData = append(customData, custom)
  10593. custom1 := &CustomData{
  10594. MsgId: "H4402290015820210330172057803",
  10595. PsnNo: "44020000001101161813",
  10596. Info: "2207",
  10597. }
  10598. customData = append(customData, custom1)
  10599. custom2 := &CustomData{
  10600. MsgId: "H44022900158202103301705198813",
  10601. PsnNo: "44190000133097375417",
  10602. Info: "2207",
  10603. }
  10604. customData = append(customData, custom2)
  10605. custom3 := &CustomData{
  10606. MsgId: "H44022900158202103301715524756",
  10607. PsnNo: "44020000001100187221",
  10608. Info: "2207",
  10609. }
  10610. customData = append(customData, custom3)
  10611. custom4 := &CustomData{
  10612. MsgId: "H44022900158202103301730376224",
  10613. PsnNo: "44020000001101959155",
  10614. Info: "2207",
  10615. }
  10616. customData = append(customData, custom4)
  10617. custom5 := &CustomData{
  10618. MsgId: "H44022900158202103301748008725",
  10619. PsnNo: "44020000001104246641",
  10620. Info: "2207",
  10621. }
  10622. customData = append(customData, custom5)
  10623. custom6 := &CustomData{
  10624. MsgId: "H44022900158202103301718096755",
  10625. PsnNo: "44020000001102211860",
  10626. Info: "2207",
  10627. }
  10628. customData = append(customData, custom6)
  10629. custom7 := &CustomData{
  10630. MsgId: "H44022900158202103301736551640",
  10631. PsnNo: "44020000001102687718",
  10632. Info: "2207",
  10633. }
  10634. customData = append(customData, custom7)
  10635. custom8 := &CustomData{
  10636. MsgId: "H44022900158202103301743097676",
  10637. PsnNo: "44020000001102127785",
  10638. Info: "2207",
  10639. }
  10640. customData = append(customData, custom8)
  10641. custom9 := &CustomData{
  10642. MsgId: "H44022900158202103301712304203",
  10643. PsnNo: "44020000001101518097",
  10644. Info: "2207",
  10645. }
  10646. customData = append(customData, custom9)
  10647. custom10 := &CustomData{
  10648. MsgId: "H44022900158202103301738448785",
  10649. PsnNo: "44020000001100500813",
  10650. Info: "2207",
  10651. }
  10652. customData = append(customData, custom10)
  10653. custom11 := &CustomData{
  10654. MsgId: "H44022900158202103301732455843",
  10655. PsnNo: "44020000001102690557",
  10656. Info: "2207",
  10657. }
  10658. customData = append(customData, custom11)
  10659. custom12 := &CustomData{
  10660. MsgId: "H44022900158202103301745421708",
  10661. PsnNo: "44020000001102211928",
  10662. Info: "2207",
  10663. }
  10664. customData = append(customData, custom12)
  10665. custom1212 := &CustomData{
  10666. MsgId: "H440229001582021033017351627",
  10667. PsnNo: "44020000001102481733",
  10668. Info: "2207",
  10669. }
  10670. customData = append(customData, custom1212)
  10671. custom13 := &CustomData{
  10672. MsgId: "H44022900158202103301740327951",
  10673. PsnNo: "44020000001103174866",
  10674. Info: "2207",
  10675. }
  10676. customData = append(customData, custom13)
  10677. custom14 := &CustomData{
  10678. MsgId: "H4402290015820210330174922668",
  10679. PsnNo: "44020000001102927272",
  10680. Info: "2207",
  10681. }
  10682. customData = append(customData, custom14)
  10683. custom15 := &CustomData{
  10684. MsgId: "H44022900158202103301752362273",
  10685. PsnNo: "44020000001102942890",
  10686. Info: "2207",
  10687. }
  10688. customData = append(customData, custom15)
  10689. custom16 := &CustomData{
  10690. MsgId: "H44022900158202103301751082917",
  10691. PsnNo: "44020000001101662162",
  10692. Info: "2207",
  10693. }
  10694. customData = append(customData, custom16)
  10695. custom17 := &CustomData{
  10696. MsgId: "H44022900158202103301754147728",
  10697. PsnNo: "44020000000229014511",
  10698. Info: "2207",
  10699. }
  10700. customData = append(customData, custom17)
  10701. adminUser := c.GetAdminUserInfo()
  10702. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10703. for _, item := range customData {
  10704. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10705. fmt.Println(result)
  10706. }
  10707. }
  10708. //func (c *HisApiController) GetAllopatry() {
  10709. // year := c.GetString("year")
  10710. // month := c.GetString("month")
  10711. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10712. // adminUser := c.GetAdminUserInfo()
  10713. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10714. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10715. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10716. //
  10717. // var dat map[string]interface{}
  10718. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10719. // fmt.Println(dat)
  10720. // } else {
  10721. // fmt.Println(err)
  10722. // }
  10723. // userJSONBytes, _ := json.Marshal(dat)
  10724. // var res models.Result9001
  10725. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10726. // utils.ErrorLog("解析失败:%v", err)
  10727. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10728. // return
  10729. // }
  10730. //
  10731. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10732. // var dat2 map[string]interface{}
  10733. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10734. // fmt.Println(dat)
  10735. // } else {
  10736. // fmt.Println(err)
  10737. // }
  10738. // userJSONBytes2, _ := json.Marshal(dat2)
  10739. // var res2 models.Result3260
  10740. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10741. // utils.ErrorLog("解析失败:%v", err)
  10742. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10743. // return
  10744. // }
  10745. // if res2.Infcode == 0 {
  10746. // c.ServeSuccessJSON(map[string]interface{}{
  10747. // "list": res2.Output.Data,
  10748. // })
  10749. // return
  10750. // } else {
  10751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10752. // return
  10753. // }
  10754. //
  10755. //}
  10756. //func (c *HisApiController) ComfirmAllopatry() {
  10757. // year := c.GetString("year")
  10758. // month := c.GetString("month")
  10759. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10760. // adminUser := c.GetAdminUserInfo()
  10761. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10762. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10763. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10764. // var dat map[string]interface{}
  10765. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10766. // fmt.Println(dat)
  10767. // } else {
  10768. // fmt.Println(err)
  10769. // }
  10770. // userJSONBytes, _ := json.Marshal(dat)
  10771. // var res models.Result9001
  10772. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10773. // utils.ErrorLog("解析失败:%v", err)
  10774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10775. // return
  10776. // }
  10777. //
  10778. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "")
  10779. // var dat2 map[string]interface{}
  10780. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10781. // fmt.Println(dat)
  10782. // } else {
  10783. // fmt.Println(err)
  10784. // }
  10785. // userJSONBytes2, _ := json.Marshal(dat2)
  10786. // var res2 models.Result3260
  10787. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10788. // utils.ErrorLog("解析失败:%v", err)
  10789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10790. // return
  10791. // }
  10792. //
  10793. // if res2.Infcode == 0 {
  10794. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10795. // var dat map[string]interface{}
  10796. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10797. // fmt.Println(dat)
  10798. // } else {
  10799. // fmt.Println(err)
  10800. // }
  10801. // userJSONBytes, _ := json.Marshal(dat)
  10802. // var res3 models.Result3261
  10803. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10804. // utils.ErrorLog("解析失败:%v", err)
  10805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10806. // return
  10807. // }
  10808. //
  10809. // if res3.Infcode == 0 {
  10810. // record := &models.HisYidiClearRecord{
  10811. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10812. // Ctime: time.Now().Unix(),
  10813. // Mtime: time.Now().Unix(),
  10814. // Status: 1,
  10815. // MsgId: msgId,
  10816. // }
  10817. // service.SaveClearRecord(record)
  10818. // c.ServeSuccessJSON(map[string]interface{}{
  10819. // "msg": "提取成功",
  10820. // })
  10821. // }
  10822. // }
  10823. //}
  10824. //
  10825. //func (c *HisApiController) RefundAllopatry() {
  10826. // year := c.GetString("year")
  10827. // month := c.GetString("month")
  10828. // id, _ := c.GetInt64("id")
  10829. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10830. // adminUser := c.GetAdminUserInfo()
  10831. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10832. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10833. // record, _ := service.GetClearRecordById(id)
  10834. // result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10835. //
  10836. // var dat map[string]interface{}
  10837. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10838. // fmt.Println(dat)
  10839. // } else {
  10840. // fmt.Println(err)
  10841. // }
  10842. // userJSONBytes, _ := json.Marshal(dat)
  10843. // var empty ResultFourteen
  10844. // if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10845. // utils.ErrorLog("解析失败:%v", err)
  10846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10847. // return
  10848. // }
  10849. // if empty.Infcode == 0 {
  10850. // c.ServeSuccessJSON(map[string]interface{}{
  10851. // "msg": "撤销成功",
  10852. // })
  10853. // return
  10854. // }
  10855. //}
  10856. func (c *HisApiController) ReversalOtherData() {
  10857. var customData []*CustomData
  10858. custom := &CustomData{
  10859. MsgId: "H44022900158202103301714472004",
  10860. PsnNo: "44020000001101329945",
  10861. Info: "2208",
  10862. }
  10863. customData = append(customData, custom)
  10864. custom1 := &CustomData{
  10865. MsgId: "H4402290015820210330172057803",
  10866. PsnNo: "44020000001101161813",
  10867. Info: "2208",
  10868. }
  10869. customData = append(customData, custom1)
  10870. custom2 := &CustomData{
  10871. MsgId: "H44022900158202103301705198813",
  10872. PsnNo: "44190000133097375417",
  10873. Info: "2208",
  10874. }
  10875. customData = append(customData, custom2)
  10876. custom3 := &CustomData{
  10877. MsgId: "H44022900158202103301715524756",
  10878. PsnNo: "44020000001100187221",
  10879. Info: "2208",
  10880. }
  10881. customData = append(customData, custom3)
  10882. custom4 := &CustomData{
  10883. MsgId: "H44022900158202103301730376224",
  10884. PsnNo: "44020000001101959155",
  10885. Info: "2208",
  10886. }
  10887. customData = append(customData, custom4)
  10888. custom5 := &CustomData{
  10889. MsgId: "H44022900158202103301748008725",
  10890. PsnNo: "44020000001104246641",
  10891. Info: "2208",
  10892. }
  10893. customData = append(customData, custom5)
  10894. custom6 := &CustomData{
  10895. MsgId: "H44022900158202103301718096755",
  10896. PsnNo: "44020000001102211860",
  10897. Info: "2208",
  10898. }
  10899. customData = append(customData, custom6)
  10900. custom7 := &CustomData{
  10901. MsgId: "H44022900158202103301736551640",
  10902. PsnNo: "44020000001102687718",
  10903. Info: "2208",
  10904. }
  10905. customData = append(customData, custom7)
  10906. custom8 := &CustomData{
  10907. MsgId: "H44022900158202103301743097676",
  10908. PsnNo: "44020000001102127785",
  10909. Info: "2208",
  10910. }
  10911. customData = append(customData, custom8)
  10912. custom9 := &CustomData{
  10913. MsgId: "H44022900158202103301712304203",
  10914. PsnNo: "44020000001101518097",
  10915. Info: "2208",
  10916. }
  10917. customData = append(customData, custom9)
  10918. custom10 := &CustomData{
  10919. MsgId: "H44022900158202103301738448785",
  10920. PsnNo: "44020000001100500813",
  10921. Info: "2208",
  10922. }
  10923. customData = append(customData, custom10)
  10924. custom11 := &CustomData{
  10925. MsgId: "H44022900158202103301732455843",
  10926. PsnNo: "44020000001102690557",
  10927. Info: "2208",
  10928. }
  10929. customData = append(customData, custom11)
  10930. custom12 := &CustomData{
  10931. MsgId: "H44022900158202103301745421708",
  10932. PsnNo: "44020000001102211928",
  10933. Info: "2208",
  10934. }
  10935. customData = append(customData, custom12)
  10936. custom1212 := &CustomData{
  10937. MsgId: "H440229001582021033017351627",
  10938. PsnNo: "44020000001102481733",
  10939. Info: "2208",
  10940. }
  10941. customData = append(customData, custom1212)
  10942. custom13 := &CustomData{
  10943. MsgId: "H44022900158202103301740327951",
  10944. PsnNo: "44020000001103174866",
  10945. Info: "2208",
  10946. }
  10947. customData = append(customData, custom13)
  10948. custom14 := &CustomData{
  10949. MsgId: "H4402290015820210330174922668",
  10950. PsnNo: "44020000001102927272",
  10951. Info: "2208",
  10952. }
  10953. customData = append(customData, custom14)
  10954. custom15 := &CustomData{
  10955. MsgId: "H44022900158202103301752362273",
  10956. PsnNo: "44020000001102942890",
  10957. Info: "2208",
  10958. }
  10959. customData = append(customData, custom15)
  10960. custom16 := &CustomData{
  10961. MsgId: "H44022900158202103301751082917",
  10962. PsnNo: "44020000001101662162",
  10963. Info: "2208",
  10964. }
  10965. customData = append(customData, custom16)
  10966. custom17 := &CustomData{
  10967. MsgId: "H44022900158202103301754147728",
  10968. PsnNo: "44020000000229014511",
  10969. Info: "2208",
  10970. }
  10971. customData = append(customData, custom17)
  10972. adminUser := c.GetAdminUserInfo()
  10973. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10974. for _, item := range customData {
  10975. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10976. fmt.Println(result)
  10977. }
  10978. }
  10979. func PathExists(path string) (bool, error) {
  10980. _, err := os.Stat(path)
  10981. if err == nil {
  10982. return true, nil
  10983. }
  10984. if os.IsNotExist(err) {
  10985. return false, nil
  10986. }
  10987. return false, err
  10988. }
  10989. // 创建文件夹
  10990. func Mkdir(dir string) {
  10991. // 创建文件夹
  10992. exist, err := PathExists(dir)
  10993. if err != nil {
  10994. fmt.Println(err.Error())
  10995. } else {
  10996. if exist {
  10997. fmt.Println(dir + "文件夹已存在!")
  10998. } else {
  10999. // 文件夹名称,权限
  11000. err := os.Mkdir(dir, os.ModePerm)
  11001. if err != nil {
  11002. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11003. } else {
  11004. fmt.Println(dir + "文件夹创建成功!")
  11005. }
  11006. }
  11007. }
  11008. }
  11009. // 压缩文件
  11010. func Zip(srcFile string, destZip string) error {
  11011. zipfile, err := os.Create(destZip)
  11012. if err != nil {
  11013. return err
  11014. }
  11015. defer zipfile.Close()
  11016. archive := zip.NewWriter(zipfile)
  11017. defer archive.Close()
  11018. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11019. if err != nil {
  11020. return err
  11021. }
  11022. header, err := zip.FileInfoHeader(info)
  11023. if err != nil {
  11024. return err
  11025. }
  11026. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11027. // header.Name = path
  11028. if info.IsDir() {
  11029. header.Name += "/"
  11030. } else {
  11031. header.Method = zip.Deflate
  11032. }
  11033. writer, err := archive.CreateHeader(header)
  11034. if err != nil {
  11035. return err
  11036. }
  11037. if !info.IsDir() {
  11038. file, err := os.Open(path)
  11039. if err != nil {
  11040. return err
  11041. }
  11042. defer file.Close()
  11043. _, err = io.Copy(writer, file)
  11044. }
  11045. return err
  11046. })
  11047. return err
  11048. }
  11049. func ReadFile(filePath string) []byte {
  11050. f, err := os.Open(filePath)
  11051. if err != nil {
  11052. fmt.Println("read file fail", err)
  11053. return nil
  11054. }
  11055. defer f.Close()
  11056. fd, err := ioutil.ReadAll(f)
  11057. if err != nil {
  11058. fmt.Println("read to fd fail", err)
  11059. return nil
  11060. }
  11061. return fd
  11062. }
  11063. func saveLog(result string, request string, infno string, desc string) {
  11064. org_id, _ := beego.AppConfig.Int64("org_id")
  11065. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11066. dir := miConfig.OrgName + "日志"
  11067. utils.Mkdir(dir)
  11068. month := time.Unix(1557042972, 0).Format("1")
  11069. year := time.Now().Format("2006")
  11070. month = time.Now().Format("01")
  11071. day := time.Now().Format("02")
  11072. hour := time.Now().Format("15")
  11073. min := time.Now().Format("04")
  11074. sec := time.Now().Format("05")
  11075. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11076. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11077. file_name := file + ".txt"
  11078. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11079. exist, _ := utils.PathExists(file_path)
  11080. if exist { //存在
  11081. fmt.Println("存在")
  11082. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11083. if err != nil {
  11084. fmt.Println("read fail")
  11085. }
  11086. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11087. n, _ := f.Seek(0, 2)
  11088. _, err = f.WriteAt([]byte(content), n)
  11089. } else { //不存在
  11090. fmt.Println("文件不存在,创建文件")
  11091. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11092. defer f.Close()
  11093. if err != nil {
  11094. } else {
  11095. _, err = f.Write([]byte("记录日志"))
  11096. }
  11097. }
  11098. }
  11099. type Charset string
  11100. const (
  11101. UTF8 = Charset("UTF-8")
  11102. GB18030 = Charset("GB18030")
  11103. )
  11104. func ConvertToString(src string, srcCode string, tagCode string) string {
  11105. srcCoder := mahonia.NewDecoder(srcCode)
  11106. srcResult := srcCoder.ConvertString(src)
  11107. tagCoder := mahonia.NewDecoder(tagCode)
  11108. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11109. result := string(cdata)
  11110. return result
  11111. }
  11112. func (c *HisApiController) ReadEleCard() {
  11113. id_card_type, _ := c.GetInt64("id_card_type")
  11114. admin_user_id, _ := c.GetInt64("admin_user_id")
  11115. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11116. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11117. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11118. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11119. var api string
  11120. if miConfig.MdtrtareaAdmvs == "320921" {
  11121. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11122. "&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
  11123. fmt.Println(api)
  11124. } else {
  11125. 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 +
  11126. "&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)
  11127. }
  11128. resp, requestErr := http.Get(api)
  11129. if requestErr != nil {
  11130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11131. return
  11132. }
  11133. body, ioErr := ioutil.ReadAll(resp.Body)
  11134. if ioErr != nil {
  11135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. var respJSON map[string]interface{}
  11140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11143. return
  11144. }
  11145. var status string
  11146. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11147. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11148. var token string
  11149. var res ResultTwo //1101结果
  11150. var res10265 ResultTwo10265 //1101结果
  11151. if status == "0" { //读卡成功
  11152. var card_info string //卡信息
  11153. var busi_card_info string
  11154. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11155. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11156. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11157. fmt.Println(card_info)
  11158. fmt.Println(busi_card_info)
  11159. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11160. result, _ := json.Marshal(respJSON)
  11161. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11162. utils.ErrorLog("解析失败:%v", err)
  11163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11164. return
  11165. }
  11166. res.ErrMsg = res10265.ErrMsg
  11167. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11168. res.Infcode = infocode
  11169. //res.Output = res10265.Output
  11170. res.InfRefmsgid = res10265.InfRefmsgid
  11171. if res.Infcode == 0 {
  11172. c.ServeSuccessJSON(map[string]interface{}{
  11173. "number": token,
  11174. })
  11175. }
  11176. } else {
  11177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11178. return
  11179. }
  11180. } else { //读卡失败
  11181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11182. return
  11183. }
  11184. }