his_api_controller.go 454KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. 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 +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&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)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1082. "&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
  1083. fmt.Println(api)
  1084. } else {
  1085. 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 +
  1086. "&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)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. result, _ := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1273. var dat map[string]interface{}
  1274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1275. fmt.Println(dat)
  1276. } else {
  1277. fmt.Println(err)
  1278. }
  1279. userJSONBytes, _ := json.Marshal(dat)
  1280. var res ResultTwo
  1281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1282. utils.ErrorLog("解析失败:%v", err)
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1284. return
  1285. }
  1286. if res.Infcode == 0 {
  1287. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1288. if err == gorm.ErrRecordNotFound {
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1290. return
  1291. } else if err != nil {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1293. return
  1294. } else {
  1295. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1296. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1297. infoStr := string(Iinfos)
  1298. idetinfoStr := string(Idetinfos)
  1299. psn := &models.HisPsn{
  1300. PsnNo: res.Output.Baseinfo.PsnNo,
  1301. Age: res.Output.Baseinfo.Age,
  1302. PatientId: patient.ID,
  1303. Certno: res.Output.Baseinfo.Certno,
  1304. Brdy: res.Output.Baseinfo.Brdy,
  1305. Gend: res.Output.Baseinfo.Gend,
  1306. Naty: res.Output.Baseinfo.Naty,
  1307. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1308. PsnName: res.Output.Baseinfo.PsnName,
  1309. Idetinfo: idetinfoStr,
  1310. Insuinfo: infoStr,
  1311. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1312. CardInfo: basStr,
  1313. VerifyNumber: "",
  1314. }
  1315. service.CreateHisPsn(psn)
  1316. c.ServeSuccessJSON(map[string]interface{}{
  1317. "patient": patient,
  1318. "number": cardnum,
  1319. })
  1320. }
  1321. } else {
  1322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1323. return
  1324. }
  1325. } else {
  1326. if initFlag == 0 {
  1327. c.TestGetBasBaseInit()
  1328. }
  1329. basStr := c.GetBasBaseInfo()
  1330. if len(basStr) == 0 {
  1331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1332. return
  1333. }
  1334. fmt.Println(basStr)
  1335. bas := strings.Split(basStr, "|")
  1336. basNumber := bas[1]
  1337. fmt.Println(basNumber)
  1338. card_sn := bas[3]
  1339. fmt.Println(card_sn)
  1340. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1341. var dat map[string]interface{}
  1342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1343. fmt.Println(dat)
  1344. } else {
  1345. fmt.Println(err)
  1346. }
  1347. userJSONBytes, _ := json.Marshal(dat)
  1348. var res ResultTwo
  1349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1350. utils.ErrorLog("解析失败:%v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. if res.Infcode == 0 {
  1355. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1356. if err == gorm.ErrRecordNotFound {
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1358. return
  1359. } else if err != nil {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1361. return
  1362. } else {
  1363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1365. infoStr := string(Iinfos)
  1366. idetinfoStr := string(Idetinfos)
  1367. psn := &models.HisPsn{
  1368. PsnNo: res.Output.Baseinfo.PsnNo,
  1369. Age: res.Output.Baseinfo.Age,
  1370. PatientId: patient.ID,
  1371. Certno: res.Output.Baseinfo.Certno,
  1372. Brdy: res.Output.Baseinfo.Brdy,
  1373. Gend: res.Output.Baseinfo.Gend,
  1374. Naty: res.Output.Baseinfo.Naty,
  1375. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1376. PsnName: res.Output.Baseinfo.PsnName,
  1377. Idetinfo: idetinfoStr,
  1378. Insuinfo: infoStr,
  1379. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1380. CardInfo: basStr,
  1381. VerifyNumber: "",
  1382. }
  1383. service.CreateHisPsn(psn)
  1384. c.ServeSuccessJSON(map[string]interface{}{
  1385. "patient": patient,
  1386. "number": basNumber,
  1387. })
  1388. }
  1389. } else {
  1390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1391. return
  1392. }
  1393. break
  1394. }
  1395. case 2:
  1396. SFZStr := c.GetSFZBaseInfo()
  1397. id_card_str := strings.Split(SFZStr, "^")
  1398. id_card_number := id_card_str[0]
  1399. card_sn := ""
  1400. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1401. var dat map[string]interface{}
  1402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1403. fmt.Println(dat)
  1404. } else {
  1405. fmt.Println(err)
  1406. }
  1407. userJSONBytes, _ := json.Marshal(dat)
  1408. var res ResultTwo
  1409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1410. utils.ErrorLog("解析失败:%v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. return
  1413. }
  1414. if res.Infcode == 0 {
  1415. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1416. if err == gorm.ErrRecordNotFound {
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1418. return
  1419. } else if err != nil {
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1421. return
  1422. } else {
  1423. c.ServeSuccessJSON(map[string]interface{}{
  1424. "patient": patient,
  1425. "number": id_card_number,
  1426. })
  1427. }
  1428. } else {
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1430. return
  1431. }
  1432. break
  1433. case 3:
  1434. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1435. var api string
  1436. if miConfig.MdtrtareaAdmvs == "320921" {
  1437. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1438. "&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
  1439. fmt.Println(api)
  1440. } else {
  1441. 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 +
  1442. "&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)
  1443. }
  1444. resp, requestErr := http.Get(api)
  1445. if requestErr != nil {
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. body, ioErr := ioutil.ReadAll(resp.Body)
  1450. if ioErr != nil {
  1451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return
  1454. }
  1455. var respJSON map[string]interface{}
  1456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1459. return
  1460. }
  1461. var status string
  1462. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1463. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1464. var token string
  1465. var res ResultTwo //1101结果
  1466. var res10265 ResultTwo10265 //1101结果
  1467. var card_info string //卡信息
  1468. var busi_card_info string
  1469. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1470. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1471. if status == "0" { //读卡成功
  1472. if card_type == "1" {
  1473. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1474. result, _ := json.Marshal(respJSON)
  1475. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1476. utils.ErrorLog("解析失败:%v", err)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. return
  1479. }
  1480. res.ErrMsg = res10265.ErrMsg
  1481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1482. res.Infcode = infocode
  1483. res.Output = res10265.Output
  1484. res.InfRefmsgid = res10265.InfRefmsgid
  1485. } else {
  1486. //var card_info string //卡信息
  1487. //var busi_card_info string
  1488. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1489. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1490. //fmt.Println(card_info)
  1491. //fmt.Println(busi_card_info)
  1492. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1493. result, _ := json.Marshal(respJSON)
  1494. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1495. utils.ErrorLog("解析失败:%v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. res.ErrMsg = res10265.ErrMsg
  1500. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1501. res.Infcode = infocode
  1502. res.Output = res10265.Output
  1503. res.InfRefmsgid = res10265.InfRefmsgid
  1504. }
  1505. if res.Infcode == 0 {
  1506. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1507. if err == gorm.ErrRecordNotFound {
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1509. return
  1510. } else if err != nil {
  1511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1512. return
  1513. } else {
  1514. if card_type == "1" {
  1515. bas := strings.Split(card_info, "|")
  1516. basNumber := bas[2]
  1517. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1518. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1519. infoStr := string(Iinfos)
  1520. idetinfoStr := string(Idetinfos)
  1521. psn := &models.HisPsn{
  1522. PsnNo: res.Output.Baseinfo.PsnNo,
  1523. Age: res.Output.Baseinfo.Age,
  1524. PatientId: patient.ID,
  1525. Certno: res.Output.Baseinfo.Certno,
  1526. Brdy: res.Output.Baseinfo.Brdy,
  1527. Gend: res.Output.Baseinfo.Gend,
  1528. Naty: res.Output.Baseinfo.Naty,
  1529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1530. PsnName: res.Output.Baseinfo.PsnName,
  1531. Idetinfo: idetinfoStr,
  1532. Insuinfo: infoStr,
  1533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1534. CardInfo: card_info,
  1535. VerifyNumber: busi_card_info,
  1536. }
  1537. service.CreateHisPsn(psn)
  1538. c.ServeSuccessJSON(map[string]interface{}{
  1539. "patient": patient,
  1540. "number": basNumber,
  1541. })
  1542. } else {
  1543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1545. infoStr := string(Iinfos)
  1546. idetinfoStr := string(Idetinfos)
  1547. psn := &models.HisPsn{
  1548. PsnNo: res.Output.Baseinfo.PsnNo,
  1549. Age: res.Output.Baseinfo.Age,
  1550. PatientId: patient.ID,
  1551. Certno: res.Output.Baseinfo.Certno,
  1552. Brdy: res.Output.Baseinfo.Brdy,
  1553. Gend: res.Output.Baseinfo.Gend,
  1554. Naty: res.Output.Baseinfo.Naty,
  1555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1556. PsnName: res.Output.Baseinfo.PsnName,
  1557. Idetinfo: idetinfoStr,
  1558. Insuinfo: infoStr,
  1559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1560. CardInfo: card_info,
  1561. VerifyNumber: token,
  1562. }
  1563. service.CreateHisPsn(psn)
  1564. var rf []*ResultFive
  1565. json.Unmarshal([]byte(infoStr), &rf)
  1566. var insutypes []*ResultFive
  1567. var insutype string
  1568. var is390 int = 0
  1569. var is310 int = 0
  1570. for _, item := range rf {
  1571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1572. insutypes = append(insutypes, item)
  1573. }
  1574. }
  1575. if len(insutypes) == 1 {
  1576. insutype = insutypes[0].Insutype
  1577. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1578. } else {
  1579. for _, i := range insutypes {
  1580. if i.Insutype == "390" {
  1581. is390 = 1
  1582. }
  1583. if i.Insutype == "310" {
  1584. is310 = 1
  1585. }
  1586. }
  1587. }
  1588. if is390 == 1 {
  1589. insutype = "390"
  1590. }
  1591. if is310 == 1 {
  1592. insutype = "310"
  1593. }
  1594. if len(insutypes) == 0 {
  1595. insutype = "310"
  1596. }
  1597. c.ServeSuccessJSON(map[string]interface{}{
  1598. "patient": patient,
  1599. "number": token,
  1600. "insutype": insutype,
  1601. })
  1602. }
  1603. }
  1604. } else {
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1606. return
  1607. }
  1608. } else { //读卡失败
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1610. return
  1611. }
  1612. }
  1613. break
  1614. case 4:
  1615. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1616. var api string
  1617. if miConfig.MdtrtareaAdmvs == "320921" {
  1618. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1619. "&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
  1620. fmt.Println(api)
  1621. } else {
  1622. 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 +
  1623. "&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)
  1624. }
  1625. resp, requestErr := http.Get(api)
  1626. if requestErr != nil {
  1627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1628. return
  1629. }
  1630. body, ioErr := ioutil.ReadAll(resp.Body)
  1631. if ioErr != nil {
  1632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1634. return
  1635. }
  1636. var respJSON map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. var status string
  1643. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1644. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1645. var token string
  1646. var res ResultTwo //1101结果
  1647. var res10265 ResultTwo10265 //1101结果
  1648. if status == "0" { //读卡成功
  1649. var card_info string //卡信息
  1650. var busi_card_info string
  1651. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1652. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1653. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1654. fmt.Println(card_info)
  1655. fmt.Println(busi_card_info)
  1656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1657. result, _ := json.Marshal(respJSON)
  1658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1659. utils.ErrorLog("解析失败:%v", err)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. return
  1662. }
  1663. res.ErrMsg = res10265.ErrMsg
  1664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1665. res.Infcode = infocode
  1666. res.Output = res10265.Output
  1667. res.InfRefmsgid = res10265.InfRefmsgid
  1668. if res.Infcode == 0 {
  1669. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1670. if err == gorm.ErrRecordNotFound {
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1672. return
  1673. } else if err != nil {
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1675. return
  1676. } else {
  1677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1679. infoStr := string(Iinfos)
  1680. idetinfoStr := string(Idetinfos)
  1681. psn := &models.HisPsn{
  1682. PsnNo: res.Output.Baseinfo.PsnNo,
  1683. Age: res.Output.Baseinfo.Age,
  1684. PatientId: patient.ID,
  1685. Certno: res.Output.Baseinfo.Certno,
  1686. Brdy: res.Output.Baseinfo.Brdy,
  1687. Gend: res.Output.Baseinfo.Gend,
  1688. Naty: res.Output.Baseinfo.Naty,
  1689. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1690. PsnName: res.Output.Baseinfo.PsnName,
  1691. Idetinfo: idetinfoStr,
  1692. Insuinfo: infoStr,
  1693. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1694. CardInfo: card_info,
  1695. VerifyNumber: token,
  1696. }
  1697. service.CreateHisPsn(psn)
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "patient": patient,
  1700. "number": token,
  1701. })
  1702. }
  1703. } else {
  1704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1705. return
  1706. }
  1707. } else { //读卡失败
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1709. return
  1710. }
  1711. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1712. }
  1713. break
  1714. }
  1715. }
  1716. var initFlag int64 = 0
  1717. func (c *HisApiController) TestGetBasBaseInit() {
  1718. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1719. Iinit := DllDef.MustFindProc("Init")
  1720. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1721. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1722. if ret != 0 {
  1723. fmt.Println("SSCard的报错原因:", err)
  1724. fmt.Println("SSCard的运算结果为:", ret)
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1726. return
  1727. }
  1728. result := int(ret)
  1729. fmt.Println("SSCard的运算结果为1:", result)
  1730. initFlag = 1
  1731. return
  1732. }
  1733. func (c *HisApiController) GetSFZBaseInfo() string {
  1734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1735. readCard := DllDef.MustFindProc("ReadSFZ")
  1736. if readCard == nil {
  1737. fmt.Println("readcard is nil")
  1738. readCard = DllDef.MustFindProc("ReadSFZ")
  1739. }
  1740. str := make([]byte, 256)
  1741. str1 := make([]byte, 256)
  1742. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1743. fmt.Println(r)
  1744. return string(str)
  1745. }
  1746. func (c *HisApiController) GetBasBaseInfo() string {
  1747. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1748. readCard := DllDef.MustFindProc("ReadCardBas")
  1749. if readCard == nil {
  1750. fmt.Println("readcard is nil")
  1751. readCard = DllDef.MustFindProc("ReadCardBas")
  1752. }
  1753. str := make([]byte, 1024)
  1754. str1 := make([]byte, 1024)
  1755. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1756. fmt.Println(string(str1))
  1757. fmt.Println(string(str))
  1758. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1759. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1760. if ret2 != 0 {
  1761. return ""
  1762. }
  1763. return string(str)
  1764. }
  1765. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1766. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1767. readCard := DllDef.MustFindProc("read_cardinfo")
  1768. if readCard == nil {
  1769. fmt.Println("readcard is nil")
  1770. readCard = DllDef.MustFindProc("read_cardinfo")
  1771. }
  1772. str := make([]byte, 1024) //卡号
  1773. str1 := make([]byte, 1024) //卡识别码
  1774. str2 := make([]byte, 1024) //身份证号
  1775. str3 := make([]byte, 1024) //姓名
  1776. str4 := make([]byte, 1024) //错误信息
  1777. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1778. fmt.Println(string(str1))
  1779. fmt.Println(string(str))
  1780. fmt.Println(string(str2))
  1781. fmt.Println(string(str3))
  1782. fmt.Println(string(str4))
  1783. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1784. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1785. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1786. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1787. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1788. if ret2 != 0 {
  1789. return "", "", "", "", ""
  1790. }
  1791. return string(str), string(str1), string(str2), string(str3), string(str4)
  1792. }
  1793. type CustomFundPay struct {
  1794. FundPayType string `json:"fund_pay_type"`
  1795. FundPayamt float64 `json:"fund_payamt"`
  1796. }
  1797. func (c *HisApiController) GetSettleList() {
  1798. order_id, _ := c.GetInt64("order_id")
  1799. admin_user_id, _ := c.GetInt64("admin_user_id")
  1800. order, _ := service.GetHisOrderByIDTwo(order_id)
  1801. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1802. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1803. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1804. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1805. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1807. if order.ID == 0 {
  1808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1809. return
  1810. }
  1811. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1812. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1813. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1814. fmt.Println(count)
  1815. var zero string
  1816. number := count + 1
  1817. if number >= 1000 {
  1818. zero = "0000" + strconv.FormatInt(number, 10)
  1819. } else if number >= 10000 {
  1820. zero = "000" + strconv.FormatInt(number, 10)
  1821. } else if number >= 100000 {
  1822. zero = "00" + strconv.FormatInt(number, 10)
  1823. } else if number >= 1000000 {
  1824. zero = "0" + strconv.FormatInt(number, 10)
  1825. } else {
  1826. zero = strconv.FormatInt(number, 10)
  1827. }
  1828. fmt.Println(zero)
  1829. struct4101 := service.Struct4101{
  1830. PsnNo: order.PsnNo,
  1831. MdtrtId: order.MdtrtId,
  1832. SetlId: order.SetlId,
  1833. PsnName: order.PsnName,
  1834. Gend: order.Gend,
  1835. Brdy: his.Brdy,
  1836. Age: his.Age,
  1837. Naty: order.Naty,
  1838. PatnCertType: "01",
  1839. Certno: order.Certno,
  1840. Prfs: "90",
  1841. ConerName: roles[0].UserName,
  1842. PatnRlts: "99",
  1843. ConerAddr: miConfig.OrgName,
  1844. ConerTel: admin.Mobile,
  1845. HiType: order.Insutype,
  1846. Insuplc: miConfig.InsuplcAdmdvs,
  1847. MaindiagFlag: "1",
  1848. BillCode: last_order.FaPiaoCode,
  1849. BillNo: zero,
  1850. BizSn: order.Number,
  1851. PsnSelfPay: order.PsnPartAmt,
  1852. PsnOwnPay: order.PsnPartAmt,
  1853. AcctPay: order.AcctPay,
  1854. PsnCashpay: order.PsnCashPay,
  1855. HiPaymtd: "1",
  1856. Hsorg: miConfig.InsuplcAdmdvs,
  1857. HsorgOpter: miConfig.InsuplcAdmdvs,
  1858. MedinsFillPsn: curRoles.UserName,
  1859. MedinsFillDept: depart.Name,
  1860. IptMedType: "2",
  1861. }
  1862. struct4101.SetlBegnDate = order.SetlTime
  1863. struct4101.SetlEndDate = order.SetlTime
  1864. time_arr := strings.Split(order.SetlTime, " ")
  1865. struct4101.AdmTime = time_arr[0]
  1866. struct4101.AdmEndTime = time_arr[0]
  1867. var rf []CustomFundPay
  1868. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1869. var tempFunPays []service.CustomStruct
  1870. for _, item := range rf {
  1871. var tempFunPay service.CustomStruct
  1872. tempFunPay.FundPayamt = item.FundPayamt
  1873. tempFunPay.FundPayType = item.FundPayType
  1874. tempFunPays = append(tempFunPays, tempFunPay)
  1875. }
  1876. struct4101.CustomStruct = tempFunPays
  1877. var tempDiaginfos []service.DiaginfoStructTwo
  1878. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1879. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1880. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1881. var config []*models.HisXtDiagnoseConfig
  1882. for _, item := range diagnosis_ids {
  1883. id, _ := strconv.ParseInt(item, 10, 64)
  1884. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1885. config = append(config, &diagnosisConfig)
  1886. }
  1887. for index, item := range config {
  1888. if index == 0 {
  1889. var tempDiaginfo service.DiaginfoStructTwo
  1890. tempDiaginfo.DiagCode = item.CountryCode
  1891. tempDiaginfo.DiagName = item.CountryContentName
  1892. tempDiaginfo.DiagType = "1"
  1893. tempDiaginfo.MaindiagFlag = "1"
  1894. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1895. } else {
  1896. var tempDiaginfo service.DiaginfoStructTwo
  1897. tempDiaginfo.DiagCode = item.CountryCode
  1898. tempDiaginfo.DiagName = item.CountryContentName
  1899. tempDiaginfo.DiagType = "2"
  1900. tempDiaginfo.MaindiagFlag = "0"
  1901. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1902. }
  1903. }
  1904. struct4101.Diseinfo = tempDiaginfos
  1905. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1906. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1907. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1908. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1909. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1910. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1911. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1912. var iteminfo service.IteminfoStruct
  1913. var bedCostTotal float64 = 0 //床位总费
  1914. var bedCostSelfTotal float64 = 0 //床位自费
  1915. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1916. var operationCostTotal float64 = 0 //手术费
  1917. var operationCostSelfTotal float64 = 0 //手术费
  1918. var operationCostPartSelfTotal float64 = 0 //手术费
  1919. var otherCostTotal float64 = 0 //其他费用
  1920. var otherCostSelfTotal float64 = 0 //其他费用
  1921. var otherCostPartSelfTotal float64 = 0 //其他费用
  1922. var materialCostTotal float64 = 0 //材料费
  1923. var materialCostSelfTotal float64 = 0 //材料费
  1924. var materialCostPartSelfTotal float64 = 0 //材料费
  1925. var westernMedicineCostTotal float64 = 0 //西药费
  1926. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1927. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1928. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1929. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1930. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1931. var checkCostTotal float64 = 0 //检查费
  1932. var checkCostSelfTotal float64 = 0 //检查费
  1933. var checkCostPartSelfTotal float64 = 0 //检查费
  1934. var laboratoryCostTotal float64 = 0 //化验费
  1935. var laboratoryCostSelfTotal float64 = 0 //化验费
  1936. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1937. var treatCostTotal float64 = 0 //治疗费用
  1938. var treatCostSelfTotal float64 = 0 //治疗费用
  1939. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1940. decimal.DivisionPrecision = 2
  1941. var bed_fulamt_ownpay_amt float64 = 0
  1942. var operation_fulamt_ownpay_amt float64 = 0
  1943. var other_fulamt_ownpay_amt float64 = 0
  1944. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1945. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1946. var check_fulamt_ownpay_amt float64 = 0
  1947. var material_fulamt_ownpay_amt float64 = 0
  1948. var laboratory_fulamt_ownpay_amt float64 = 0
  1949. var treat_fulamt_ownpay_amt float64 = 0
  1950. var bed_claa_sunmfee float64 = 0
  1951. var bed_clab_amt float64 = 0
  1952. var bed_other_amt float64 = 0
  1953. var operation_claa_sunmfee float64 = 0
  1954. var operation_clab_amt float64 = 0
  1955. var operation_other_amt float64 = 0
  1956. var other_claa_sunmfee float64 = 0
  1957. var other_clab_amt float64 = 0
  1958. var other_other_amt float64 = 0
  1959. var westernMedicine_claa_sunmfee float64 = 0
  1960. var westernMedicine_clab_amt float64 = 0
  1961. var westernMedicine_other_amt float64 = 0
  1962. var chineseTraditional_claa_sunmfee float64 = 0
  1963. var chineseTraditional_clab_amt float64 = 0
  1964. var chineseTraditional_other_amt float64 = 0
  1965. var check_claa_sunmfee float64 = 0
  1966. var check_clab_amt float64 = 0
  1967. var check_other_amt float64 = 0
  1968. var material_claa_sunmfee float64 = 0
  1969. var material_clab_amt float64 = 0
  1970. var material_other_amt float64 = 0
  1971. var laboratory_claa_sunmfee float64 = 0
  1972. var laboratory_clab_amt float64 = 0
  1973. var laboratory_other_amt float64 = 0
  1974. var treat_claa_sunmfee float64 = 0
  1975. var treat_clab_amt float64 = 0
  1976. var treat_other_amt float64 = 0
  1977. for _, item := range order.HisOrderInfo {
  1978. if item.MedChrgitmType == "01" { //床位费
  1979. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1980. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1981. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1982. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1983. if item.ChrgitmLv == "1" {
  1984. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1985. }
  1986. if item.ChrgitmLv == "2" {
  1987. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1988. }
  1989. if item.ChrgitmLv == "3" {
  1990. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1991. }
  1992. }
  1993. if item.MedChrgitmType == "03" { //检查费
  1994. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1995. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1996. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1997. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1998. if item.ChrgitmLv == "1" {
  1999. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2000. }
  2001. if item.ChrgitmLv == "2" {
  2002. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2003. }
  2004. if item.ChrgitmLv == "3" {
  2005. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2006. }
  2007. }
  2008. if item.MedChrgitmType == "04" { //化验费
  2009. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2010. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2011. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2012. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2013. if item.ChrgitmLv == "1" {
  2014. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2015. }
  2016. if item.ChrgitmLv == "2" {
  2017. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2018. }
  2019. if item.ChrgitmLv == "3" {
  2020. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2021. }
  2022. }
  2023. if item.MedChrgitmType == "05" { //治疗费
  2024. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2025. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2026. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2027. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2028. if item.ChrgitmLv == "1" {
  2029. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2030. }
  2031. if item.ChrgitmLv == "2" {
  2032. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2033. }
  2034. if item.ChrgitmLv == "3" {
  2035. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2036. }
  2037. }
  2038. if item.MedChrgitmType == "06" { //手术费
  2039. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2040. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2041. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2042. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2043. if item.ChrgitmLv == "1" {
  2044. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2045. }
  2046. if item.ChrgitmLv == "2" {
  2047. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2048. }
  2049. if item.ChrgitmLv == "3" {
  2050. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2051. }
  2052. }
  2053. if item.MedChrgitmType == "08" { //材料费
  2054. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2055. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2056. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2057. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2058. if item.ChrgitmLv == "1" {
  2059. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2060. }
  2061. if item.ChrgitmLv == "2" {
  2062. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "3" {
  2065. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2066. }
  2067. }
  2068. if item.MedChrgitmType == "09" { //西药费
  2069. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2070. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2071. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2072. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2073. if item.ChrgitmLv == "1" {
  2074. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2075. }
  2076. if item.ChrgitmLv == "2" {
  2077. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "3" {
  2080. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2081. }
  2082. }
  2083. if item.MedChrgitmType == "11" { //中成费
  2084. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2085. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2086. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2087. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2088. if item.ChrgitmLv == "1" {
  2089. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2090. }
  2091. if item.ChrgitmLv == "2" {
  2092. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "3" {
  2095. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2096. }
  2097. }
  2098. if item.MedChrgitmType == "14" { //其他费
  2099. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2100. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2101. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2102. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2103. if item.ChrgitmLv == "1" {
  2104. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "2" {
  2107. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "3" {
  2110. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2111. }
  2112. }
  2113. }
  2114. var iteminfoStructs []service.IteminfoStruct
  2115. if bedCostTotal != 0 {
  2116. iteminfo.MedChrgitm = "01"
  2117. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2118. iteminfo.Amt = bedCostTotal
  2119. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2120. iteminfo.ClabAmt = bed_clab_amt
  2121. iteminfo.OthAmt = bed_other_amt
  2122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2123. }
  2124. if checkCostTotal != 0 {
  2125. iteminfo.MedChrgitm = "03"
  2126. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2127. iteminfo.Amt = checkCostTotal
  2128. iteminfo.ClaaSumfee = check_claa_sunmfee
  2129. iteminfo.ClabAmt = check_clab_amt
  2130. iteminfo.OthAmt = check_other_amt
  2131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2132. }
  2133. if laboratoryCostTotal != 0 {
  2134. iteminfo.MedChrgitm = "04"
  2135. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2136. iteminfo.Amt = laboratoryCostTotal
  2137. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2138. iteminfo.ClabAmt = laboratory_clab_amt
  2139. iteminfo.OthAmt = laboratory_other_amt
  2140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2142. }
  2143. if treatCostTotal != 0 {
  2144. iteminfo.MedChrgitm = "05"
  2145. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2146. iteminfo.Amt = treatCostTotal
  2147. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2148. iteminfo.ClabAmt = treat_clab_amt
  2149. iteminfo.OthAmt = treat_other_amt
  2150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2151. //(struct4101.IteminfoStruct, iteminfo)
  2152. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2153. }
  2154. if operationCostTotal != 0 {
  2155. iteminfo.MedChrgitm = "06"
  2156. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2157. iteminfo.Amt = operationCostTotal
  2158. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2159. iteminfo.ClabAmt = operation_clab_amt
  2160. iteminfo.OthAmt = operation_other_amt
  2161. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2163. }
  2164. if materialCostTotal != 0 {
  2165. iteminfo.MedChrgitm = "08"
  2166. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2167. iteminfo.Amt = materialCostTotal
  2168. iteminfo.ClaaSumfee = material_claa_sunmfee
  2169. iteminfo.ClabAmt = material_clab_amt
  2170. iteminfo.OthAmt = material_other_amt
  2171. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2172. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2173. }
  2174. if westernMedicineCostTotal != 0 {
  2175. iteminfo.MedChrgitm = "09"
  2176. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2177. iteminfo.Amt = westernMedicineCostTotal
  2178. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2179. iteminfo.ClabAmt = westernMedicine_clab_amt
  2180. iteminfo.OthAmt = westernMedicine_other_amt
  2181. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2183. }
  2184. if chineseTraditionalMedicineCostTotal != 0 {
  2185. iteminfo.MedChrgitm = "11"
  2186. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2187. iteminfo.Amt = westernMedicineCostTotal
  2188. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2189. iteminfo.ClabAmt = westernMedicine_clab_amt
  2190. iteminfo.OthAmt = westernMedicine_other_amt
  2191. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2193. }
  2194. if otherCostTotal != 0 {
  2195. iteminfo.MedChrgitm = "14"
  2196. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2197. iteminfo.Amt = otherCostTotal
  2198. iteminfo.ClaaSumfee = other_claa_sunmfee
  2199. iteminfo.ClabAmt = other_clab_amt
  2200. iteminfo.OthAmt = other_other_amt
  2201. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2203. }
  2204. struct4101.IteminfoStruct = iteminfoStructs
  2205. struct4101.Ntly = "中国"
  2206. struct4101.AdmCaty = "A03.06"
  2207. var res ResultSeventeen
  2208. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2209. var resOther ResultSeventeenOther
  2210. var pp models.PublicParams
  2211. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2212. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2213. pp.FixmedinsName = miConfig.OrgName
  2214. pp.FixmedinsCode = miConfig.Code
  2215. pp.RequestUrl = miConfig.Url
  2216. pp.Cainfo = miConfig.Cainfo
  2217. pp.SecretKey = miConfig.SecretKey
  2218. pp.AccessKey = miConfig.AccessKey
  2219. pp.OpterName = curRoles.UserName
  2220. client := &http.Client{}
  2221. var req *http.Request
  2222. data := make(map[string]interface{})
  2223. data["struct4101"] = struct4101
  2224. data["pp"] = pp
  2225. bytesData, _ := json.Marshal(data)
  2226. if miConfig.MdtrtareaAdmvs == "320921" {
  2227. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2228. } else {
  2229. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2230. }
  2231. resp, _ := client.Do(req)
  2232. defer resp.Body.Close()
  2233. body, ioErr := ioutil.ReadAll(resp.Body)
  2234. if ioErr != nil {
  2235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2237. return
  2238. }
  2239. var respJSON map[string]interface{}
  2240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2246. userJSONBytes, _ := json.Marshal(respJSON)
  2247. fmt.Println("log")
  2248. fmt.Println(string(userJSONBytes))
  2249. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2250. utils.ErrorLog("解析失败:%v", err)
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. return
  2253. }
  2254. res.InfRefmsgid = resOther.InfRefmsgid
  2255. res.Output = resOther.Output
  2256. res.ErrMsg = resOther.ErrMsg
  2257. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2258. res.Infcode = infocode
  2259. } else {
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2261. var dat map[string]interface{}
  2262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2263. fmt.Println(dat)
  2264. } else {
  2265. fmt.Println(err)
  2266. }
  2267. userJSONBytes, _ := json.Marshal(dat)
  2268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2269. utils.ErrorLog("解析失败:%v", err)
  2270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2271. return
  2272. }
  2273. }
  2274. if res.Infcode != 0 {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "failed_code": -10,
  2277. "msg": res.ErrMsg,
  2278. })
  2279. return
  2280. } else {
  2281. order.FaPiaoNumber = zero
  2282. order.FaPiaoCode = last_order.FaPiaoCode
  2283. service.UpdateOrder(order)
  2284. hisFundSettleListResult := &models.HisFundSettleListResult{
  2285. Number: res.Output.SetlListId,
  2286. Status: 1,
  2287. Ctime: time.Now().Unix(),
  2288. Mtime: time.Now().Unix(),
  2289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2290. IsUpload: 1,
  2291. OrderId: order_id,
  2292. }
  2293. service.CreateUploadRecord(hisFundSettleListResult)
  2294. c.ServeSuccessJSON(map[string]interface{}{
  2295. "msg": "上传成功",
  2296. "result": hisFundSettleListResult,
  2297. })
  2298. return
  2299. }
  2300. }
  2301. func (c *HisApiController) GetSettleListHospital() {
  2302. order_id, _ := c.GetInt64("order_id")
  2303. admin_user_id, _ := c.GetInt64("admin_user_id")
  2304. order, _ := service.GetHisOrderByIDTwo(order_id)
  2305. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2306. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2307. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2309. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2311. if order.ID == 0 {
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2313. return
  2314. }
  2315. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2316. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2317. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2318. fmt.Println(count)
  2319. var zero string
  2320. number := count + 1
  2321. if number >= 1000 {
  2322. zero = "0000" + strconv.FormatInt(number, 10)
  2323. } else if number >= 10000 {
  2324. zero = "000" + strconv.FormatInt(number, 10)
  2325. } else if number >= 100000 {
  2326. zero = "00" + strconv.FormatInt(number, 10)
  2327. } else if number >= 1000000 {
  2328. zero = "0" + strconv.FormatInt(number, 10)
  2329. } else {
  2330. zero = strconv.FormatInt(number, 10)
  2331. }
  2332. fmt.Println(zero)
  2333. struct4101 := service.Struct4101{
  2334. PsnNo: order.PsnNo,
  2335. MdtrtId: order.MdtrtId,
  2336. SetlId: order.SetlId,
  2337. PsnName: order.PsnName,
  2338. Gend: order.Gend,
  2339. Brdy: his.Brdy,
  2340. Age: int64(order.Age),
  2341. Naty: order.Naty,
  2342. PatnCertType: "01",
  2343. Certno: order.Certno,
  2344. Prfs: "90",
  2345. ConerName: roles[0].UserName,
  2346. PatnRlts: "99",
  2347. ConerAddr: miConfig.OrgName,
  2348. ConerTel: admin.Mobile,
  2349. HiType: order.Insutype,
  2350. Insuplc: miConfig.InsuplcAdmdvs,
  2351. MaindiagFlag: "1",
  2352. BillCode: last_order.FaPiaoCode,
  2353. BillNo: zero,
  2354. BizSn: order.Number,
  2355. PsnSelfPay: order.PsnPartAmt,
  2356. PsnOwnPay: order.PsnPartAmt,
  2357. AcctPay: order.AcctPay,
  2358. PsnCashpay: order.PsnCashPay,
  2359. HiPaymtd: "1",
  2360. Hsorg: miConfig.InsuplcAdmdvs,
  2361. HsorgOpter: miConfig.InsuplcAdmdvs,
  2362. MedinsFillPsn: curRoles.UserName,
  2363. MedinsFillDept: depart.Name,
  2364. IptMedType: "2",
  2365. AdmTime: his.InHosptialTime,
  2366. AdmEndTime: his.OutHosptialTime,
  2367. }
  2368. struct4101.SetlBegnDate = order.SetlTime
  2369. struct4101.SetlEndDate = order.SetlTime
  2370. var rf []CustomFundPay
  2371. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2372. var tempFunPays []service.CustomStruct
  2373. for _, item := range rf {
  2374. var tempFunPay service.CustomStruct
  2375. tempFunPay.FundPayamt = item.FundPayamt
  2376. tempFunPay.FundPayType = item.FundPayType
  2377. tempFunPays = append(tempFunPays, tempFunPay)
  2378. }
  2379. struct4101.CustomStruct = tempFunPays
  2380. var tempDiaginfos []service.DiaginfoStructTwo
  2381. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2382. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2384. var config []*models.HisXtDiagnoseConfig
  2385. for _, item := range diagnosis_ids {
  2386. id, _ := strconv.ParseInt(item, 10, 64)
  2387. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2388. config = append(config, &diagnosisConfig)
  2389. }
  2390. for index, item := range config {
  2391. if index == 0 {
  2392. var tempDiaginfo service.DiaginfoStructTwo
  2393. tempDiaginfo.DiagCode = item.CountryCode
  2394. tempDiaginfo.DiagName = item.CountryContentName
  2395. tempDiaginfo.DiagType = "1"
  2396. tempDiaginfo.MaindiagFlag = "1"
  2397. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2398. } else {
  2399. var tempDiaginfo service.DiaginfoStructTwo
  2400. tempDiaginfo.DiagCode = item.CountryCode
  2401. tempDiaginfo.DiagName = item.CountryContentName
  2402. tempDiaginfo.DiagType = "2"
  2403. tempDiaginfo.MaindiagFlag = "0"
  2404. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2405. }
  2406. }
  2407. struct4101.Diseinfo = tempDiaginfos
  2408. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2409. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2410. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2411. tempOpspdiseinfo2.OprnOprtCode = ""
  2412. tempOpspdiseinfo2.OprnOprtName = ""
  2413. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2414. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2415. var iteminfo service.IteminfoStruct
  2416. var bedCostTotal float64 = 0 //床位总费
  2417. var bedCostSelfTotal float64 = 0 //床位自费
  2418. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2419. var operationCostTotal float64 = 0 //手术费
  2420. var operationCostSelfTotal float64 = 0 //手术费
  2421. var operationCostPartSelfTotal float64 = 0 //手术费
  2422. var otherCostTotal float64 = 0 //其他费用
  2423. var otherCostSelfTotal float64 = 0 //其他费用
  2424. var otherCostPartSelfTotal float64 = 0 //其他费用
  2425. var materialCostTotal float64 = 0 //材料费
  2426. var materialCostSelfTotal float64 = 0 //材料费
  2427. var materialCostPartSelfTotal float64 = 0 //材料费
  2428. var westernMedicineCostTotal float64 = 0 //西药费
  2429. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2430. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2431. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2432. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2433. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2434. var checkCostTotal float64 = 0 //检查费
  2435. var checkCostSelfTotal float64 = 0 //检查费
  2436. var checkCostPartSelfTotal float64 = 0 //检查费
  2437. var laboratoryCostTotal float64 = 0 //化验费
  2438. var laboratoryCostSelfTotal float64 = 0 //化验费
  2439. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2440. var treatCostTotal float64 = 0 //治疗费用
  2441. var treatCostSelfTotal float64 = 0 //治疗费用
  2442. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2443. decimal.DivisionPrecision = 2
  2444. var bed_fulamt_ownpay_amt float64 = 0
  2445. var operation_fulamt_ownpay_amt float64 = 0
  2446. var other_fulamt_ownpay_amt float64 = 0
  2447. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2448. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2449. var check_fulamt_ownpay_amt float64 = 0
  2450. var material_fulamt_ownpay_amt float64 = 0
  2451. var laboratory_fulamt_ownpay_amt float64 = 0
  2452. var treat_fulamt_ownpay_amt float64 = 0
  2453. var bed_claa_sunmfee float64 = 0
  2454. var bed_clab_amt float64 = 0
  2455. var bed_other_amt float64 = 0
  2456. var operation_claa_sunmfee float64 = 0
  2457. var operation_clab_amt float64 = 0
  2458. var operation_other_amt float64 = 0
  2459. var other_claa_sunmfee float64 = 0
  2460. var other_clab_amt float64 = 0
  2461. var other_other_amt float64 = 0
  2462. var westernMedicine_claa_sunmfee float64 = 0
  2463. var westernMedicine_clab_amt float64 = 0
  2464. var westernMedicine_other_amt float64 = 0
  2465. var chineseTraditional_claa_sunmfee float64 = 0
  2466. var chineseTraditional_clab_amt float64 = 0
  2467. var chineseTraditional_other_amt float64 = 0
  2468. var check_claa_sunmfee float64 = 0
  2469. var check_clab_amt float64 = 0
  2470. var check_other_amt float64 = 0
  2471. var material_claa_sunmfee float64 = 0
  2472. var material_clab_amt float64 = 0
  2473. var material_other_amt float64 = 0
  2474. var laboratory_claa_sunmfee float64 = 0
  2475. var laboratory_clab_amt float64 = 0
  2476. var laboratory_other_amt float64 = 0
  2477. var treat_claa_sunmfee float64 = 0
  2478. var treat_clab_amt float64 = 0
  2479. var treat_other_amt float64 = 0
  2480. for _, item := range order.HisOrderInfo {
  2481. if item.MedChrgitmType == "01" { //床位费
  2482. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2483. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2485. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2486. if item.ChrgitmLv == "1" {
  2487. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. }
  2489. if item.ChrgitmLv == "2" {
  2490. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2491. }
  2492. if item.ChrgitmLv == "3" {
  2493. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2494. }
  2495. }
  2496. if item.MedChrgitmType == "03" { //检查费
  2497. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2498. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2500. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2501. if item.ChrgitmLv == "1" {
  2502. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. }
  2504. if item.ChrgitmLv == "2" {
  2505. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2506. }
  2507. if item.ChrgitmLv == "3" {
  2508. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2509. }
  2510. }
  2511. if item.MedChrgitmType == "04" { //化验费
  2512. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2513. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2515. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2516. if item.ChrgitmLv == "1" {
  2517. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. }
  2519. if item.ChrgitmLv == "2" {
  2520. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2521. }
  2522. if item.ChrgitmLv == "3" {
  2523. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2524. }
  2525. }
  2526. if item.MedChrgitmType == "05" { //治疗费
  2527. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2528. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2529. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2530. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2531. if item.ChrgitmLv == "1" {
  2532. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2533. }
  2534. if item.ChrgitmLv == "2" {
  2535. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2536. }
  2537. if item.ChrgitmLv == "3" {
  2538. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2539. }
  2540. }
  2541. if item.MedChrgitmType == "06" { //手术费
  2542. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2543. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2544. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2545. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2546. if item.ChrgitmLv == "1" {
  2547. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2548. }
  2549. if item.ChrgitmLv == "2" {
  2550. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2551. }
  2552. if item.ChrgitmLv == "3" {
  2553. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2554. }
  2555. }
  2556. if item.MedChrgitmType == "08" { //材料费
  2557. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2558. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2559. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2560. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2561. if item.ChrgitmLv == "1" {
  2562. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2563. }
  2564. if item.ChrgitmLv == "2" {
  2565. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2566. }
  2567. if item.ChrgitmLv == "3" {
  2568. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2569. }
  2570. }
  2571. if item.MedChrgitmType == "09" { //西药费
  2572. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2573. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2574. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2575. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2576. if item.ChrgitmLv == "1" {
  2577. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2578. }
  2579. if item.ChrgitmLv == "2" {
  2580. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2581. }
  2582. if item.ChrgitmLv == "3" {
  2583. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2584. }
  2585. }
  2586. if item.MedChrgitmType == "11" { //中成费
  2587. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2588. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2589. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2590. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2591. if item.ChrgitmLv == "1" {
  2592. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2593. }
  2594. if item.ChrgitmLv == "2" {
  2595. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2596. }
  2597. if item.ChrgitmLv == "3" {
  2598. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2599. }
  2600. }
  2601. if item.MedChrgitmType == "14" { //其他费
  2602. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2603. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2604. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2605. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2606. if item.ChrgitmLv == "1" {
  2607. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2608. }
  2609. if item.ChrgitmLv == "2" {
  2610. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2611. }
  2612. if item.ChrgitmLv == "3" {
  2613. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2614. }
  2615. }
  2616. }
  2617. var iteminfoStructs []service.IteminfoStruct
  2618. if bedCostTotal != 0 {
  2619. iteminfo.MedChrgitm = "01"
  2620. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2621. iteminfo.Amt = bedCostTotal
  2622. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2623. iteminfo.ClabAmt = bed_clab_amt
  2624. iteminfo.OthAmt = bed_other_amt
  2625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2626. }
  2627. if checkCostTotal != 0 {
  2628. iteminfo.MedChrgitm = "03"
  2629. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2630. iteminfo.Amt = checkCostTotal
  2631. iteminfo.ClaaSumfee = check_claa_sunmfee
  2632. iteminfo.ClabAmt = check_clab_amt
  2633. iteminfo.OthAmt = check_other_amt
  2634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2635. }
  2636. if laboratoryCostTotal != 0 {
  2637. iteminfo.MedChrgitm = "04"
  2638. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2639. iteminfo.Amt = laboratoryCostTotal
  2640. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2641. iteminfo.ClabAmt = laboratory_clab_amt
  2642. iteminfo.OthAmt = laboratory_other_amt
  2643. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2645. }
  2646. if treatCostTotal != 0 {
  2647. iteminfo.MedChrgitm = "05"
  2648. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2649. iteminfo.Amt = treatCostTotal
  2650. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2651. iteminfo.ClabAmt = treat_clab_amt
  2652. iteminfo.OthAmt = treat_other_amt
  2653. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2654. //(struct4101.IteminfoStruct, iteminfo)
  2655. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2656. }
  2657. if operationCostTotal != 0 {
  2658. iteminfo.MedChrgitm = "06"
  2659. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2660. iteminfo.Amt = operationCostTotal
  2661. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2662. iteminfo.ClabAmt = operation_clab_amt
  2663. iteminfo.OthAmt = operation_other_amt
  2664. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2665. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2666. }
  2667. if materialCostTotal != 0 {
  2668. iteminfo.MedChrgitm = "08"
  2669. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2670. iteminfo.Amt = materialCostTotal
  2671. iteminfo.ClaaSumfee = material_claa_sunmfee
  2672. iteminfo.ClabAmt = material_clab_amt
  2673. iteminfo.OthAmt = material_other_amt
  2674. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2675. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2676. }
  2677. if westernMedicineCostTotal != 0 {
  2678. iteminfo.MedChrgitm = "09"
  2679. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2680. iteminfo.Amt = westernMedicineCostTotal
  2681. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2682. iteminfo.ClabAmt = westernMedicine_clab_amt
  2683. iteminfo.OthAmt = westernMedicine_other_amt
  2684. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2685. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2686. }
  2687. if chineseTraditionalMedicineCostTotal != 0 {
  2688. iteminfo.MedChrgitm = "11"
  2689. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2690. iteminfo.Amt = westernMedicineCostTotal
  2691. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2692. iteminfo.ClabAmt = westernMedicine_clab_amt
  2693. iteminfo.OthAmt = westernMedicine_other_amt
  2694. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2696. }
  2697. if otherCostTotal != 0 {
  2698. iteminfo.MedChrgitm = "14"
  2699. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2700. iteminfo.Amt = otherCostTotal
  2701. iteminfo.ClaaSumfee = other_claa_sunmfee
  2702. iteminfo.ClabAmt = other_clab_amt
  2703. iteminfo.OthAmt = other_other_amt
  2704. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2705. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2706. }
  2707. struct4101.IteminfoStruct = iteminfoStructs
  2708. struct4101.Ntly = "中国"
  2709. struct4101.AdmCaty = "A03.06"
  2710. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2711. fmt.Println(result)
  2712. var dat map[string]interface{}
  2713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2714. fmt.Println(dat)
  2715. } else {
  2716. fmt.Println(err)
  2717. }
  2718. userJSONBytes, _ := json.Marshal(dat)
  2719. var res ResultSeventeen
  2720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2721. utils.ErrorLog("解析失败:%v", err)
  2722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2723. return
  2724. }
  2725. if res.Infcode != 0 {
  2726. c.ServeSuccessJSON(map[string]interface{}{
  2727. "failed_code": -10,
  2728. "msg": res.ErrMsg,
  2729. })
  2730. return
  2731. } else {
  2732. order.FaPiaoNumber = zero
  2733. order.FaPiaoCode = last_order.FaPiaoCode
  2734. service.UpdateOrder(order)
  2735. hisFundSettleListResult := &models.HisFundSettleListResult{
  2736. Number: res.Output.SetlListId,
  2737. Status: 1,
  2738. Ctime: time.Now().Unix(),
  2739. Mtime: time.Now().Unix(),
  2740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2741. IsUpload: 1,
  2742. OrderId: order_id,
  2743. }
  2744. service.CreateUploadRecord(hisFundSettleListResult)
  2745. c.ServeSuccessJSON(map[string]interface{}{
  2746. "msg": "上传成功",
  2747. "result": hisFundSettleListResult,
  2748. })
  2749. return
  2750. }
  2751. }
  2752. func (c *HisApiController) GetBatchSettleList() {
  2753. orders, _ := service.GetAllHisOrder(10106)
  2754. for _, item := range orders {
  2755. order_id := item.ID
  2756. order, _ := service.GetHisOrderByIDTwo(order_id)
  2757. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2758. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2759. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2760. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2761. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2762. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2763. if order.ID == 0 {
  2764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2765. return
  2766. }
  2767. if his.BalanceAccountsType == 2 {
  2768. continue
  2769. }
  2770. struct4101 := service.Struct4101{
  2771. PsnNo: order.PsnNo,
  2772. MdtrtId: order.MdtrtId,
  2773. SetlId: order.SetlId,
  2774. PsnName: order.PsnName,
  2775. Gend: order.Gend,
  2776. Brdy: his.Brdy,
  2777. Age: his.Age,
  2778. Naty: order.Naty,
  2779. PatnCertType: "01",
  2780. Certno: order.Certno,
  2781. Prfs: "90",
  2782. ConerName: roles[0].UserName,
  2783. PatnRlts: "99",
  2784. ConerAddr: miConfig.OrgName,
  2785. ConerTel: admin.Mobile,
  2786. HiType: order.Insutype,
  2787. Insuplc: his.InsuplcAdmdvs,
  2788. MaindiagFlag: "1",
  2789. BillCode: order.FaPiaoCode,
  2790. BillNo: order.FaPiaoNumber,
  2791. BizSn: order.Number,
  2792. PsnSelfPay: order.PsnPartAmt,
  2793. PsnOwnPay: order.PsnPartAmt,
  2794. AcctPay: order.AcctPay,
  2795. PsnCashpay: order.PsnCashPay,
  2796. HiPaymtd: "1",
  2797. Hsorg: his.InsuplcAdmdvs,
  2798. HsorgOpter: his.InsuplcAdmdvs,
  2799. MedinsFillPsn: curRoles.UserName,
  2800. MedinsFillDept: depart.Name,
  2801. IptMedType: "2",
  2802. }
  2803. struct4101.SetlBegnDate = order.SetlTime
  2804. struct4101.SetlEndDate = order.SetlTime
  2805. //if order.SettleType == 1 {
  2806. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2807. // dateStr := t.Format("2006-01-02")
  2808. // struct4101.SetlBegnDate = dateStr
  2809. // struct4101.SetlEndDate = dateStr
  2810. //} else {
  2811. // t := time.Unix(int64(order.SettleStartTime), 0)
  2812. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2813. // dateStartStr := t.Format("2006-01-02")
  2814. // dateEndStr := t2.Format("2006-01-02")
  2815. // struct4101.SetlBegnDate = dateStartStr
  2816. // struct4101.SetlEndDate = dateEndStr
  2817. //}
  2818. var rf []CustomFundPay
  2819. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2820. var tempFunPays []service.CustomStruct
  2821. var tempFunPay610100 service.CustomStruct
  2822. for _, item := range rf {
  2823. if item.FundPayType == "610100" {
  2824. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2825. tempFunPay610100.FundPayType = item.FundPayType
  2826. } else {
  2827. var tempFunPay service.CustomStruct
  2828. tempFunPay.FundPayamt = item.FundPayamt
  2829. tempFunPay.FundPayType = item.FundPayType
  2830. tempFunPays = append(tempFunPays, tempFunPay)
  2831. }
  2832. }
  2833. tempFunPays = append(tempFunPays, tempFunPay610100)
  2834. struct4101.CustomStruct = tempFunPays
  2835. var tempDiaginfos []service.DiaginfoStructTwo
  2836. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2837. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2838. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2839. var config []*models.HisXtDiagnoseConfig
  2840. for _, item := range diagnosis_ids {
  2841. id, _ := strconv.ParseInt(item, 10, 64)
  2842. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2843. config = append(config, &diagnosisConfig)
  2844. }
  2845. for index, item := range config {
  2846. if index == 0 {
  2847. var tempDiaginfo service.DiaginfoStructTwo
  2848. tempDiaginfo.DiagCode = item.CountryCode
  2849. tempDiaginfo.DiagName = item.CountryContentName
  2850. tempDiaginfo.DiagType = "1"
  2851. tempDiaginfo.MaindiagFlag = "1"
  2852. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2853. } else {
  2854. var tempDiaginfo service.DiaginfoStructTwo
  2855. tempDiaginfo.DiagCode = item.CountryCode
  2856. tempDiaginfo.DiagName = item.CountryContentName
  2857. tempDiaginfo.DiagType = "2"
  2858. tempDiaginfo.MaindiagFlag = "0"
  2859. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2860. }
  2861. }
  2862. struct4101.Diseinfo = tempDiaginfos
  2863. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2864. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2865. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2866. tempOpspdiseinfo2.OprnOprtCode = ""
  2867. tempOpspdiseinfo2.OprnOprtName = ""
  2868. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2869. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2870. var iteminfo service.IteminfoStruct
  2871. var bedCostTotal float64 = 0 //床位总费
  2872. var bedCostSelfTotal float64 = 0 //床位自费
  2873. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2874. var examineCostTotal float64 = 0 //诊查总费
  2875. var examineCostSelfTotal float64 = 0 //诊查自费
  2876. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2877. var nursingCostTotal float64 = 0 //护理总费
  2878. var nursingCostSelfTotal float64 = 0 //护理自费
  2879. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2880. var chineseMedicineCostTotal float64 = 0 //中成药
  2881. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2882. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2883. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2884. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2885. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2886. var registerCostTotal float64 = 0 //一般诊疗费
  2887. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2888. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2889. var operationCostTotal float64 = 0 //手术费
  2890. var operationCostSelfTotal float64 = 0 //手术费
  2891. var operationCostPartSelfTotal float64 = 0 //手术费
  2892. var otherCostTotal float64 = 0 //其他费用
  2893. var otherCostSelfTotal float64 = 0 //其他费用
  2894. var otherCostPartSelfTotal float64 = 0 //其他费用
  2895. var materialCostTotal float64 = 0 //材料费
  2896. var materialCostSelfTotal float64 = 0 //材料费
  2897. var materialCostPartSelfTotal float64 = 0 //材料费
  2898. var westernMedicineCostTotal float64 = 0 //西药费
  2899. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2900. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2901. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2902. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2903. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2904. var checkCostTotal float64 = 0 //检查费
  2905. var checkCostSelfTotal float64 = 0 //检查费
  2906. var checkCostPartSelfTotal float64 = 0 //检查费
  2907. var laboratoryCostTotal float64 = 0 //化验费
  2908. var laboratoryCostSelfTotal float64 = 0 //化验费
  2909. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2910. var treatCostTotal float64 = 0 //治疗费用
  2911. var treatCostSelfTotal float64 = 0 //治疗费用
  2912. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2913. decimal.DivisionPrecision = 2
  2914. var bed_fulamt_ownpay_amt float64 = 0
  2915. var examine_fulamt_ownpay_amt float64 = 0
  2916. var nursing_fulamt_ownpay_amt float64 = 0
  2917. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2918. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2919. var register_fulamt_ownpay_amt float64 = 0
  2920. var operation_fulamt_ownpay_amt float64 = 0
  2921. var other_fulamt_ownpay_amt float64 = 0
  2922. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2923. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2924. var check_fulamt_ownpay_amt float64 = 0
  2925. var material_fulamt_ownpay_amt float64 = 0
  2926. var laboratory_fulamt_ownpay_amt float64 = 0
  2927. var treat_fulamt_ownpay_amt float64 = 0
  2928. var bed_claa_sunmfee float64 = 0
  2929. var bed_clab_amt float64 = 0
  2930. var bed_other_amt float64 = 0
  2931. var examine_claa_sunmfee float64 = 0
  2932. var examine_clab_amt float64 = 0
  2933. var examine_other_amt float64 = 0
  2934. var nursing_claa_sunmfee float64 = 0
  2935. var nursing_clab_amt float64 = 0
  2936. var nursing_other_amt float64 = 0
  2937. var chinese_medicine_claa_sunmfee float64 = 0
  2938. var chinese_medicine_clab_amt float64 = 0
  2939. var chinese_medicine_other_amt float64 = 0
  2940. var commonly_treatment_claa_sunmfee float64 = 0
  2941. var commonly_treatment_clab_amt float64 = 0
  2942. var commonly_treatment_other_amt float64 = 0
  2943. var operation_claa_sunmfee float64 = 0
  2944. var operation_clab_amt float64 = 0
  2945. var operation_other_amt float64 = 0
  2946. var other_claa_sunmfee float64 = 0
  2947. var other_clab_amt float64 = 0
  2948. var other_other_amt float64 = 0
  2949. var westernMedicine_claa_sunmfee float64 = 0
  2950. var westernMedicine_clab_amt float64 = 0
  2951. var westernMedicine_other_amt float64 = 0
  2952. var chineseTraditional_claa_sunmfee float64 = 0
  2953. var chineseTraditional_clab_amt float64 = 0
  2954. var chineseTraditional_other_amt float64 = 0
  2955. var check_claa_sunmfee float64 = 0
  2956. var check_clab_amt float64 = 0
  2957. var check_other_amt float64 = 0
  2958. var material_claa_sunmfee float64 = 0
  2959. var material_clab_amt float64 = 0
  2960. var material_other_amt float64 = 0
  2961. var laboratory_claa_sunmfee float64 = 0
  2962. var laboratory_clab_amt float64 = 0
  2963. var laboratory_other_amt float64 = 0
  2964. var treat_claa_sunmfee float64 = 0
  2965. var treat_clab_amt float64 = 0
  2966. var treat_other_amt float64 = 0
  2967. var register_claa_sunmfee float64 = 0
  2968. var register_clab_amt float64 = 0
  2969. var register_other_amt float64 = 0
  2970. for _, item := range order.HisOrderInfo {
  2971. if item.MedChrgitmType == "01" { //床位费
  2972. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2973. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2975. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2976. if item.ChrgitmLv == "1" {
  2977. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. }
  2979. if item.ChrgitmLv == "2" {
  2980. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2981. }
  2982. if item.ChrgitmLv == "3" {
  2983. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2984. }
  2985. }
  2986. if item.MedChrgitmType == "02" { //诊查
  2987. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2988. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2990. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2991. if item.ChrgitmLv == "1" {
  2992. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. }
  2994. if item.ChrgitmLv == "2" {
  2995. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2996. }
  2997. if item.ChrgitmLv == "3" {
  2998. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2999. }
  3000. }
  3001. if item.MedChrgitmType == "03" { //检查费
  3002. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3003. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3005. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3006. if item.ChrgitmLv == "1" {
  3007. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. }
  3009. if item.ChrgitmLv == "2" {
  3010. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3011. }
  3012. if item.ChrgitmLv == "3" {
  3013. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3014. }
  3015. }
  3016. if item.MedChrgitmType == "04" { //化验费
  3017. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3018. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3020. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3021. if item.ChrgitmLv == "1" {
  3022. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. }
  3024. if item.ChrgitmLv == "2" {
  3025. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3026. }
  3027. if item.ChrgitmLv == "3" {
  3028. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3029. }
  3030. }
  3031. if item.MedChrgitmType == "05" { //治疗费
  3032. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3033. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3035. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3036. if item.ChrgitmLv == "1" {
  3037. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3038. }
  3039. if item.ChrgitmLv == "2" {
  3040. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3041. }
  3042. if item.ChrgitmLv == "3" {
  3043. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3044. }
  3045. }
  3046. if item.MedChrgitmType == "06" { //手术费
  3047. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3048. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3049. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3050. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3051. if item.ChrgitmLv == "1" {
  3052. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3053. }
  3054. if item.ChrgitmLv == "2" {
  3055. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3056. }
  3057. if item.ChrgitmLv == "3" {
  3058. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3059. }
  3060. }
  3061. if item.MedChrgitmType == "07" { //手术费
  3062. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3063. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3064. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3065. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3066. if item.ChrgitmLv == "1" {
  3067. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3068. }
  3069. if item.ChrgitmLv == "2" {
  3070. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3071. }
  3072. if item.ChrgitmLv == "3" {
  3073. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3074. }
  3075. }
  3076. if item.MedChrgitmType == "08" { //材料费
  3077. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3078. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3079. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3080. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3081. if item.ChrgitmLv == "1" {
  3082. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3083. }
  3084. if item.ChrgitmLv == "2" {
  3085. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3086. }
  3087. if item.ChrgitmLv == "3" {
  3088. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3089. }
  3090. }
  3091. if item.MedChrgitmType == "09" { //西药费
  3092. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3093. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3094. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3095. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3096. if item.ChrgitmLv == "1" {
  3097. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3098. }
  3099. if item.ChrgitmLv == "2" {
  3100. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3101. }
  3102. if item.ChrgitmLv == "3" {
  3103. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3104. }
  3105. }
  3106. if item.MedChrgitmType == "10" { //中药饮片
  3107. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3108. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3109. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3110. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3111. if item.ChrgitmLv == "1" {
  3112. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3113. }
  3114. if item.ChrgitmLv == "2" {
  3115. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3116. }
  3117. if item.ChrgitmLv == "3" {
  3118. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3119. }
  3120. }
  3121. if item.MedChrgitmType == "11" { //中成费
  3122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3126. if item.ChrgitmLv == "1" {
  3127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3128. }
  3129. if item.ChrgitmLv == "2" {
  3130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3131. }
  3132. if item.ChrgitmLv == "3" {
  3133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3134. }
  3135. }
  3136. if item.MedChrgitmType == "12" { //中成费
  3137. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3139. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3140. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3141. if item.ChrgitmLv == "1" {
  3142. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3143. }
  3144. if item.ChrgitmLv == "2" {
  3145. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "3" {
  3148. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. }
  3150. }
  3151. if item.MedChrgitmType == "13" { //中成费
  3152. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3154. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3155. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3156. if item.ChrgitmLv == "1" {
  3157. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3158. }
  3159. if item.ChrgitmLv == "2" {
  3160. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "3" {
  3163. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. }
  3165. }
  3166. if item.MedChrgitmType == "14" { //其他费
  3167. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3169. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3170. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3171. if item.ChrgitmLv == "1" {
  3172. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3173. }
  3174. if item.ChrgitmLv == "2" {
  3175. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "3" {
  3178. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3179. }
  3180. }
  3181. }
  3182. var iteminfoStructs []service.IteminfoStruct
  3183. if bedCostTotal != 0 {
  3184. iteminfo.MedChrgitm = "01"
  3185. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3186. iteminfo.Amt = bedCostTotal
  3187. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3188. iteminfo.ClabAmt = bed_clab_amt
  3189. iteminfo.OthAmt = bed_other_amt
  3190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3191. }
  3192. if examineCostTotal != 0 {
  3193. iteminfo.MedChrgitm = "02"
  3194. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3195. iteminfo.Amt = examineCostTotal
  3196. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3197. iteminfo.ClabAmt = examine_clab_amt
  3198. iteminfo.OthAmt = examine_other_amt
  3199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3201. }
  3202. if checkCostTotal != 0 {
  3203. iteminfo.MedChrgitm = "03"
  3204. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3205. iteminfo.Amt = checkCostTotal
  3206. iteminfo.ClaaSumfee = check_claa_sunmfee
  3207. iteminfo.ClabAmt = check_clab_amt
  3208. iteminfo.OthAmt = check_other_amt
  3209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3210. }
  3211. if laboratoryCostTotal != 0 {
  3212. iteminfo.MedChrgitm = "04"
  3213. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3214. iteminfo.Amt = laboratoryCostTotal
  3215. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3216. iteminfo.ClabAmt = laboratory_clab_amt
  3217. iteminfo.OthAmt = laboratory_other_amt
  3218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3220. }
  3221. if treatCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "05"
  3223. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3224. iteminfo.Amt = treatCostTotal
  3225. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3226. iteminfo.ClabAmt = treat_clab_amt
  3227. iteminfo.OthAmt = treat_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. //(struct4101.IteminfoStruct, iteminfo)
  3230. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3231. }
  3232. if operationCostTotal != 0 {
  3233. iteminfo.MedChrgitm = "06"
  3234. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3235. iteminfo.Amt = operationCostTotal
  3236. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3237. iteminfo.ClabAmt = operation_clab_amt
  3238. iteminfo.OthAmt = operation_other_amt
  3239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3241. }
  3242. if nursingCostTotal != 0 {
  3243. iteminfo.MedChrgitm = "07"
  3244. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3245. iteminfo.Amt = nursingCostTotal
  3246. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3247. iteminfo.ClabAmt = nursing_clab_amt
  3248. iteminfo.OthAmt = nursing_other_amt
  3249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3250. }
  3251. if materialCostTotal != 0 {
  3252. iteminfo.MedChrgitm = "08"
  3253. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3254. iteminfo.Amt = materialCostTotal
  3255. iteminfo.ClaaSumfee = material_claa_sunmfee
  3256. iteminfo.ClabAmt = material_clab_amt
  3257. iteminfo.OthAmt = material_other_amt
  3258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3260. }
  3261. if westernMedicineCostTotal != 0 {
  3262. iteminfo.MedChrgitm = "09"
  3263. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3264. iteminfo.Amt = westernMedicineCostTotal
  3265. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3266. iteminfo.ClabAmt = westernMedicine_clab_amt
  3267. iteminfo.OthAmt = westernMedicine_other_amt
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3270. }
  3271. if chineseMedicineCostTotal != 0 {
  3272. iteminfo.MedChrgitm = "10"
  3273. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3274. iteminfo.Amt = chineseMedicineCostTotal
  3275. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3276. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3277. iteminfo.OthAmt = chinese_medicine_other_amt
  3278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3279. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3280. }
  3281. if chineseTraditionalMedicineCostTotal != 0 {
  3282. iteminfo.MedChrgitm = "11"
  3283. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3284. iteminfo.Amt = westernMedicineCostTotal
  3285. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3286. iteminfo.ClabAmt = westernMedicine_clab_amt
  3287. iteminfo.OthAmt = westernMedicine_other_amt
  3288. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3290. }
  3291. if commonlyTreatmentCostTotal != 0 {
  3292. iteminfo.MedChrgitm = "12"
  3293. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3294. iteminfo.Amt = commonlyTreatmentCostTotal
  3295. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3296. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3297. iteminfo.OthAmt = commonly_treatment_other_amt
  3298. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3300. }
  3301. if registerCostTotal != 0 {
  3302. iteminfo.MedChrgitm = "13"
  3303. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3304. iteminfo.Amt = registerCostTotal
  3305. iteminfo.ClaaSumfee = register_claa_sunmfee
  3306. iteminfo.ClabAmt = register_clab_amt
  3307. iteminfo.OthAmt = register_other_amt
  3308. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3310. }
  3311. if otherCostTotal != 0 {
  3312. iteminfo.MedChrgitm = "14"
  3313. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3314. iteminfo.Amt = otherCostTotal
  3315. iteminfo.ClaaSumfee = other_claa_sunmfee
  3316. iteminfo.ClabAmt = other_clab_amt
  3317. iteminfo.OthAmt = other_other_amt
  3318. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3319. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3320. }
  3321. struct4101.IteminfoStruct = iteminfoStructs
  3322. struct4101.Ntly = "中国"
  3323. struct4101.AdmCaty = "A03.06"
  3324. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3325. fmt.Println(result)
  3326. var dat map[string]interface{}
  3327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3328. fmt.Println(dat)
  3329. } else {
  3330. fmt.Println(err)
  3331. }
  3332. userJSONBytes, _ := json.Marshal(dat)
  3333. var res ResultSeventeen
  3334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3335. utils.ErrorLog("解析失败:%v", err)
  3336. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3337. adminUser := c.GetAdminUserInfo()
  3338. errlog := &models.HisOrderError{
  3339. UserOrgId: adminUser.CurrentOrgId,
  3340. Ctime: time.Now().Unix(),
  3341. Mtime: time.Now().Unix(),
  3342. ErrMsg: res.ErrMsg + "解析失败",
  3343. Status: 1,
  3344. PatientId: order_id,
  3345. Stage: 10106,
  3346. }
  3347. service.CreateErrMsgLog(errlog)
  3348. continue
  3349. }
  3350. if res.Infcode != 0 {
  3351. adminUser := c.GetAdminUserInfo()
  3352. errlog := &models.HisOrderError{
  3353. UserOrgId: adminUser.CurrentOrgId,
  3354. Ctime: time.Now().Unix(),
  3355. Mtime: time.Now().Unix(),
  3356. ErrMsg: res.ErrMsg,
  3357. Status: 1,
  3358. PatientId: order_id,
  3359. Stage: 10106,
  3360. }
  3361. service.CreateErrMsgLog(errlog)
  3362. continue
  3363. } else {
  3364. hisFundSettleListResult := &models.HisFundSettleListResult{
  3365. Number: res.Output.SetlListId,
  3366. Status: 1,
  3367. Ctime: time.Now().Unix(),
  3368. Mtime: time.Now().Unix(),
  3369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3370. IsUpload: 1,
  3371. OrderId: order_id,
  3372. }
  3373. service.CreateUploadRecord(hisFundSettleListResult)
  3374. continue
  3375. }
  3376. }
  3377. }
  3378. func (c *HisApiController) GetOrgInfo() {
  3379. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3380. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3381. }
  3382. func (c *HisApiController) GetHisPatientInfo() {
  3383. medical_insurance_card := c.GetString("medical_insurance_card")
  3384. id_card_type, _ := c.GetInt64("id_card_type")
  3385. id_card := c.GetString("id_card")
  3386. adminInfo := c.GetAdminUserInfo()
  3387. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3388. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3389. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3390. IdCardNo := ""
  3391. if id_card_type == 1 {
  3392. IdCardNo = medical_insurance_card
  3393. } else if id_card_type == 2 {
  3394. IdCardNo = id_card
  3395. }
  3396. if config.IsOpen == 1 {
  3397. 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
  3398. resp, requestErr := http.Get(api)
  3399. if requestErr != nil {
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. defer resp.Body.Close()
  3404. body, ioErr := ioutil.ReadAll(resp.Body)
  3405. if ioErr != nil {
  3406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. var respJSON map[string]interface{}
  3411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3414. return
  3415. }
  3416. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3417. userJSONBytes, _ := json.Marshal(userJSON)
  3418. var res ResultTwo
  3419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3426. infoStr := string(Iinfos)
  3427. idetinfoStr := string(Idetinfos)
  3428. if res.Infcode == 0 {
  3429. his := models.VMHisPatient{
  3430. Status: 1,
  3431. Ctime: time.Now().Unix(),
  3432. Mtime: time.Now().Unix(),
  3433. PsnNo: res.Output.Baseinfo.PsnNo,
  3434. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3435. Certno: res.Output.Baseinfo.Certno,
  3436. PsnName: res.Output.Baseinfo.PsnName,
  3437. Gend: res.Output.Baseinfo.Gend,
  3438. Naty: res.Output.Baseinfo.Naty,
  3439. Brdy: res.Output.Baseinfo.Brdy,
  3440. Age: res.Output.Baseinfo.Age,
  3441. Iinfo: infoStr,
  3442. Idetinfo: idetinfoStr,
  3443. UserOrgId: adminInfo.CurrentOrgId,
  3444. IsReturn: 1,
  3445. IdCardType: id_card_type,
  3446. }
  3447. c.ServeSuccessJSON(map[string]interface{}{
  3448. "info": his,
  3449. })
  3450. } else {
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3452. return
  3453. }
  3454. }
  3455. }
  3456. //func GetBasBaseInfo() (jsonStr string, err error) {
  3457. //
  3458. // handle := syscall.NewLazyDLL("SSCard.dll")
  3459. // add := handle.NewProc("ReadCardBas")
  3460. // str := make([]byte, 1024)
  3461. // str1 := make([]byte, 1024)
  3462. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3463. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3464. //
  3465. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3466. //
  3467. // fmt.Println("> Add(4,5)的结果为:", ret)
  3468. // handle.Release()
  3469. //
  3470. // return "", nil
  3471. //
  3472. //}
  3473. //func GetQRBaseInfo() (jsonStr string, err error) {
  3474. // handle := syscall.LoadDLL("SSCard.dll")
  3475. // ReadCardBas := handle.FindProc("GetQRBase")
  3476. //
  3477. // str := make([]byte, 256)
  3478. // str1 := make([]byte, 256)
  3479. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3480. //
  3481. // fmt.Println(string(str))
  3482. // fmt.Println(r)
  3483. // return string(str), nil
  3484. //}
  3485. //func CardInit() int {
  3486. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3487. // add := DllTestDef.MustFindProc("Init")
  3488. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3489. // if err != nil {
  3490. // fmt.Println("SSCard的运算结果为:", ret)
  3491. // }
  3492. // result := int(ret)
  3493. // return result
  3494. //}
  3495. //func CardInit() int {
  3496. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3497. // if err != nil {
  3498. // fmt.Println("SSCard的运算结果为:", ret)
  3499. // }
  3500. // fmt.Println(err)
  3501. // result := int(ret)
  3502. // return result
  3503. //}
  3504. func IntPtr(n int) uintptr {
  3505. return uintptr(n)
  3506. }
  3507. func StrPtr(s string) uintptr {
  3508. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3509. }
  3510. type Result2001 struct {
  3511. Cainfo interface{} `json:"cainfo"`
  3512. ErrMsg string `json:"err_msg"`
  3513. InfRefmsgid string `json:"inf_refmsgid"`
  3514. Infcode int64 `json:"infcode"`
  3515. Output struct {
  3516. Trtinfo struct {
  3517. PsnNo string `json:"psn_no"`
  3518. TrtChkType string `json:"trt_chk_type"`
  3519. FundPayType string `json:"fund_pay_type"`
  3520. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3521. Begndate string `json:"begndate"`
  3522. Enddate string `json:"enddate"`
  3523. TrtChkRslt string `json:"trt_chk_rslt"`
  3524. } `json:"trtinfo"`
  3525. } `json:"output"`
  3526. RefmsgTime string `json:"refmsg_time"`
  3527. RespondTime string `json:"respond_time"`
  3528. Signtype interface{} `json:"signtype"`
  3529. WarnMsg interface{} `json:"warn_msg"`
  3530. }
  3531. type Result2001Org10265 struct {
  3532. Cainfo interface{} `json:"cainfo"`
  3533. ErrMsg string `json:"err_msg"`
  3534. InfRefmsgid string `json:"inf_refmsgid"`
  3535. Infcode string `json:"infcode"`
  3536. Output struct {
  3537. Trtinfo struct {
  3538. PsnNo string `json:"psn_no"`
  3539. TrtChkType string `json:"trt_chk_type"`
  3540. FundPayType string `json:"fund_pay_type"`
  3541. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3542. Begndate string `json:"begndate"`
  3543. Enddate string `json:"enddate"`
  3544. TrtChkRslt string `json:"trt_chk_rslt"`
  3545. } `json:"trtinfo"`
  3546. } `json:"output"`
  3547. RefmsgTime string `json:"refmsg_time"`
  3548. RespondTime string `json:"respond_time"`
  3549. Signtype interface{} `json:"signtype"`
  3550. WarnMsg interface{} `json:"warn_msg"`
  3551. }
  3552. type ResultTwo struct {
  3553. ErrMsg string `json:"err_msg"`
  3554. InfRefmsgid string `json:"inf_refmsgid"`
  3555. Infcode int64 `json:"infcode"`
  3556. Output struct {
  3557. Baseinfo struct {
  3558. Age float64 `json:"age"`
  3559. Brdy string `json:"brdy"`
  3560. Certno string `json:"certno"`
  3561. Gend string `json:"gend"`
  3562. Naty string `json:"naty"`
  3563. PsnCertType string `json:"psn_cert_type"`
  3564. PsnName string `json:"psn_name"`
  3565. PsnNo string `json:"psn_no"`
  3566. } `json:"baseinfo"`
  3567. Idetinfo []interface{} `json:"idetinfo"`
  3568. Iinfo []struct {
  3569. Balc float64 `json:"balc"`
  3570. CvlservFlag string `json:"cvlserv_flag"`
  3571. EmpName string `json:"emp_name"`
  3572. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3573. Insutype string `json:"insutype"`
  3574. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3575. PausInsuDate string `json:"paus_insu_date"`
  3576. PsnInsuDate string `json:"psn_insu_date"`
  3577. PsnInsuStas string `json:"psn_insu_stas"`
  3578. PsnType string `json:"psn_type"`
  3579. } `json:"insuinfo"`
  3580. } `json:"output"`
  3581. RefmsgTime string `json:"refmsg_time"`
  3582. RespondTime string `json:"respond_time"`
  3583. Signtype interface{} `json:"signtype"`
  3584. WarnInfo interface{} `json:"warn_info"`
  3585. }
  3586. type ResultTwo10265 struct {
  3587. ErrMsg string `json:"err_msg"`
  3588. InfRefmsgid string `json:"inf_refmsgid"`
  3589. Infcode string `json:"infcode"`
  3590. Output struct {
  3591. Baseinfo struct {
  3592. Age float64 `json:"age"`
  3593. Brdy string `json:"brdy"`
  3594. Certno string `json:"certno"`
  3595. Gend string `json:"gend"`
  3596. Naty string `json:"naty"`
  3597. PsnCertType string `json:"psn_cert_type"`
  3598. PsnName string `json:"psn_name"`
  3599. PsnNo string `json:"psn_no"`
  3600. } `json:"baseinfo"`
  3601. Idetinfo []interface{} `json:"idetinfo"`
  3602. Iinfo []struct {
  3603. Balc float64 `json:"balc"`
  3604. CvlservFlag string `json:"cvlserv_flag"`
  3605. EmpName string `json:"emp_name"`
  3606. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3607. Insutype string `json:"insutype"`
  3608. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3609. PausInsuDate string `json:"paus_insu_date"`
  3610. PsnInsuDate string `json:"psn_insu_date"`
  3611. PsnInsuStas string `json:"psn_insu_stas"`
  3612. PsnType string `json:"psn_type"`
  3613. } `json:"insuinfo"`
  3614. } `json:"output"`
  3615. RefmsgTime string `json:"refmsg_time"`
  3616. RespondTime string `json:"respond_time"`
  3617. Signtype interface{} `json:"signtype"`
  3618. WarnInfo interface{} `json:"warn_info"`
  3619. }
  3620. type ResultThree struct {
  3621. Cainfo interface{} `json:"cainfo"`
  3622. ErrMsg string `json:"err_msg"`
  3623. InfRefmsgid string `json:"inf_refmsgid"`
  3624. Infcode int64 `json:"infcode"`
  3625. Output struct {
  3626. Data struct {
  3627. IptOtpNo string `json:"ipt_otp_no"`
  3628. MdtrtID string `json:"mdtrt_id"`
  3629. PsnNo string `json:"psn_no"`
  3630. } `json:"data"`
  3631. } `json:"output"`
  3632. RefmsgTime string `json:"refmsg_time"`
  3633. RespondTime string `json:"respond_time"`
  3634. Signtype interface{} `json:"signtype"`
  3635. WarnMsg interface{} `json:"warn_msg"`
  3636. }
  3637. type ResultThree10265 struct {
  3638. Cainfo interface{} `json:"cainfo"`
  3639. ErrMsg string `json:"err_msg"`
  3640. InfRefmsgid string `json:"inf_refmsgid"`
  3641. Infcode string `json:"infcode"`
  3642. Output struct {
  3643. Data struct {
  3644. IptOtpNo string `json:"ipt_otp_no"`
  3645. MdtrtID string `json:"mdtrt_id"`
  3646. PsnNo string `json:"psn_no"`
  3647. } `json:"data"`
  3648. } `json:"output"`
  3649. RefmsgTime string `json:"refmsg_time"`
  3650. RespondTime string `json:"respond_time"`
  3651. Signtype interface{} `json:"signtype"`
  3652. WarnMsg interface{} `json:"warn_msg"`
  3653. }
  3654. type ResultFour struct {
  3655. Cainfo string `json:"cainfo"`
  3656. ErrMsg string `json:"err_msg"`
  3657. InfRefmsgid string `json:"inf_refmsgid"`
  3658. Infcode int64 `json:"infcode"`
  3659. Output struct {
  3660. Result []struct {
  3661. BasMednFlag string `json:"bas_medn_flag"`
  3662. ChldMedcFlag string `json:"chld_medc_flag"`
  3663. ChrgitmLv string `json:"chrgitm_lv"`
  3664. Cnt float64 `json:"cnt"`
  3665. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3666. DrtReimFlag string `json:"drt_reim_flag"`
  3667. FeedetlSn string `json:"feedetl_sn"`
  3668. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3669. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3670. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3671. ListSpItemFlag string `json:"list_sp_item_flag"`
  3672. LmtUsedFlag string `json:"lmt_used_flag"`
  3673. MedChrgitmType string `json:"med_chrgitm_type"`
  3674. Memo string `json:"memo"`
  3675. OverlmtAmt float64 `json:"overlmt_amt"`
  3676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3677. Pric float64 `json:"pric"`
  3678. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3679. SelfpayProp float64 `json:"selfpay_prop"`
  3680. } `json:"result"`
  3681. } `json:"output"`
  3682. RefmsgTime string `json:"refmsg_time"`
  3683. RespondTime string `json:"respond_time"`
  3684. Signtype string `json:"signtype"`
  3685. WarnMsg string `json:"warn_msg"`
  3686. }
  3687. type ResultFour10265 struct {
  3688. Cainfo string `json:"cainfo"`
  3689. ErrMsg string `json:"err_msg"`
  3690. InfRefmsgid string `json:"inf_refmsgid"`
  3691. Infcode string `json:"infcode"`
  3692. Output struct {
  3693. Result []struct {
  3694. BasMednFlag string `json:"bas_medn_flag"`
  3695. ChldMedcFlag string `json:"chld_medc_flag"`
  3696. ChrgitmLv string `json:"chrgitm_lv"`
  3697. Cnt float64 `json:"cnt"`
  3698. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3699. DrtReimFlag string `json:"drt_reim_flag"`
  3700. FeedetlSn string `json:"feedetl_sn"`
  3701. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3702. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3703. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3704. ListSpItemFlag string `json:"list_sp_item_flag"`
  3705. LmtUsedFlag string `json:"lmt_used_flag"`
  3706. MedChrgitmType string `json:"med_chrgitm_type"`
  3707. Memo string `json:"memo"`
  3708. OverlmtAmt float64 `json:"overlmt_amt"`
  3709. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3710. Pric float64 `json:"pric"`
  3711. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3712. SelfpayProp float64 `json:"selfpay_prop"`
  3713. } `json:"result"`
  3714. } `json:"output"`
  3715. RefmsgTime string `json:"refmsg_time"`
  3716. RespondTime string `json:"respond_time"`
  3717. Signtype string `json:"signtype"`
  3718. WarnMsg string `json:"warn_msg"`
  3719. }
  3720. type ResultFive struct {
  3721. Balc float64 `json:"balc"`
  3722. CvlservFlag string `json:"cvlserv_flag"`
  3723. EmpName string `json:"emp_name"`
  3724. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3725. Insutype string `json:"insutype"`
  3726. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3727. PausInsuDate string `json:"paus_insu_date"`
  3728. PsnInsuDate string `json:"psn_insu_date"`
  3729. PsnInsuStas string `json:"psn_insu_stas"`
  3730. PsnType string `json:"psn_type"`
  3731. }
  3732. type ResultSix struct {
  3733. Cainfo interface{} `json:"cainfo"`
  3734. ErrMsg string `json:"err_msg"`
  3735. InfRefmsgid string `json:"inf_refmsgid"`
  3736. Infcode int64 `json:"infcode"`
  3737. Output struct {
  3738. } `json:"output"`
  3739. RefmsgTime string `json:"refmsg_time"`
  3740. RespondTime string `json:"respond_time"`
  3741. Signtype interface{} `json:"signtype"`
  3742. WarnMsg interface{} `json:"warn_msg"`
  3743. }
  3744. type ResultSix10265 struct {
  3745. Cainfo interface{} `json:"cainfo"`
  3746. ErrMsg string `json:"err_msg"`
  3747. InfRefmsgid string `json:"inf_refmsgid"`
  3748. Infcode string `json:"infcode"`
  3749. Output struct {
  3750. } `json:"output"`
  3751. RefmsgTime string `json:"refmsg_time"`
  3752. RespondTime string `json:"respond_time"`
  3753. Signtype interface{} `json:"signtype"`
  3754. WarnMsg interface{} `json:"warn_msg"`
  3755. }
  3756. type ResultSeven struct {
  3757. Cainfo string `json:"cainfo"`
  3758. ErrMsg string `json:"err_msg"`
  3759. InfRefmsgid string `json:"inf_refmsgid"`
  3760. Infcode int64 `json:"infcode"`
  3761. Output struct {
  3762. Setldetail []interface{} `json:"setldetail"`
  3763. Setlinfo struct {
  3764. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3765. AcctPay float64 `json:"acct_pay"`
  3766. ActPayDedc float64 `json:"act_pay_dedc"`
  3767. Age float64 `json:"age"`
  3768. Balc float64 `json:"balc"`
  3769. Brdy string `json:"brdy"`
  3770. Certno string `json:"certno"`
  3771. ClrOptins string `json:"clr_optins"`
  3772. ClrType string `json:"clr_type"`
  3773. ClrWay string `json:"clr_way"`
  3774. CvlservFlag string `json:"cvlserv_flag"`
  3775. CvlservPay float64 `json:"cvlserv_pay"`
  3776. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3777. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3778. Gend string `json:"gend"`
  3779. HifesPay float64 `json:"hifes_pay"`
  3780. HifmiPay float64 `json:"hifmi_pay"`
  3781. HifpPay float64 `json:"hifp_pay"`
  3782. HospPartAmt float64 `json:"hosp_part_amt"`
  3783. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3784. Insutype string `json:"insutype"`
  3785. MafPay float64 `json:"maf_pay"`
  3786. MdtrtCertType string `json:"mdtrt_cert_type"`
  3787. HifobPay float64 `json:"hifob_pay"`
  3788. MdtrtID string `json:"mdtrt_id"`
  3789. MedType string `json:"med_type"`
  3790. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3791. MedinsSetlID string `json:"medins_setl_id"`
  3792. Naty string `json:"naty"`
  3793. OthPay float64 `json:"oth_pay"`
  3794. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3795. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3796. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3797. PsnCashPay float64 `json:"psn_cash_pay"`
  3798. PsnCertType string `json:"psn_cert_type"`
  3799. PsnName string `json:"psn_name"`
  3800. PsnNo string `json:"psn_no"`
  3801. PsnPartAmt float64 `json:"psn_part_amt"`
  3802. PsnType string `json:"psn_type"`
  3803. SetlID string `json:"setl_id"`
  3804. SetlTime string `json:"setl_time"`
  3805. } `json:"setlinfo"`
  3806. } `json:"output"`
  3807. RefmsgTime string `json:"refmsg_time"`
  3808. RespondTime string `json:"respond_time"`
  3809. Signtype interface{} `json:"signtype"`
  3810. WarnMsg interface{} `json:"warn_msg"`
  3811. }
  3812. type ResultSeven10265 struct {
  3813. Cainfo string `json:"cainfo"`
  3814. ErrMsg string `json:"err_msg"`
  3815. InfRefmsgid string `json:"inf_refmsgid"`
  3816. Infcode string `json:"infcode"`
  3817. Output struct {
  3818. Setldetail []interface{} `json:"setldetail"`
  3819. Setlinfo struct {
  3820. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3821. AcctPay float64 `json:"acct_pay"`
  3822. ActPayDedc float64 `json:"act_pay_dedc"`
  3823. Age float64 `json:"age"`
  3824. Balc float64 `json:"balc"`
  3825. Brdy string `json:"brdy"`
  3826. Certno string `json:"certno"`
  3827. ClrOptins string `json:"clr_optins"`
  3828. ClrType string `json:"clr_type"`
  3829. ClrWay string `json:"clr_way"`
  3830. CvlservFlag string `json:"cvlserv_flag"`
  3831. CvlservPay float64 `json:"cvlserv_pay"`
  3832. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3833. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3834. Gend string `json:"gend"`
  3835. HifesPay float64 `json:"hifes_pay"`
  3836. HifmiPay float64 `json:"hifmi_pay"`
  3837. HifpPay float64 `json:"hifp_pay"`
  3838. HospPartAmt float64 `json:"hosp_part_amt"`
  3839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3840. Insutype string `json:"insutype"`
  3841. MafPay float64 `json:"maf_pay"`
  3842. MdtrtCertType string `json:"mdtrt_cert_type"`
  3843. HifobPay float64 `json:"hifob_pay"`
  3844. MdtrtID string `json:"mdtrt_id"`
  3845. MedType string `json:"med_type"`
  3846. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3847. MedinsSetlID string `json:"medins_setl_id"`
  3848. Naty string `json:"naty"`
  3849. OthPay float64 `json:"oth_pay"`
  3850. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3851. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3852. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3853. PsnCashPay float64 `json:"psn_cash_pay"`
  3854. PsnCertType string `json:"psn_cert_type"`
  3855. PsnName string `json:"psn_name"`
  3856. PsnNo string `json:"psn_no"`
  3857. PsnPartAmt float64 `json:"psn_part_amt"`
  3858. PsnType string `json:"psn_type"`
  3859. SetlID string `json:"setl_id"`
  3860. SetlTime string `json:"setl_time"`
  3861. } `json:"setlinfo"`
  3862. } `json:"output"`
  3863. RefmsgTime string `json:"refmsg_time"`
  3864. RespondTime string `json:"respond_time"`
  3865. Signtype interface{} `json:"signtype"`
  3866. WarnMsg interface{} `json:"warn_msg"`
  3867. }
  3868. type ResultEight struct {
  3869. Cainfo string `json:"cainfo"`
  3870. ErrMsg string `json:"err_msg"`
  3871. InfRefmsgid string `json:"inf_refmsgid"`
  3872. Infcode int64 `json:"infcode"`
  3873. Output struct {
  3874. Stmtinfo struct {
  3875. SetlOptins string `json:"setl_optins"`
  3876. StmtRslt string `json:"stmt_rslt"`
  3877. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3878. } `json:"stmtinfo"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype interface{} `json:"signtype"`
  3883. WarnMsg interface{} `json:"warn_msg"`
  3884. }
  3885. type ResultEightFor10188 struct {
  3886. Cainfo string `json:"cainfo"`
  3887. ErrMsg string `json:"err_msg"`
  3888. InfRefmsgid string `json:"inf_refmsgid"`
  3889. Infcode string `json:"infcode"`
  3890. Output struct {
  3891. Stmtinfo struct {
  3892. SetlOptins string `json:"setl_optins"`
  3893. StmtRslt string `json:"stmt_rslt"`
  3894. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3895. } `json:"stmtinfo"`
  3896. } `json:"output"`
  3897. RefmsgTime string `json:"refmsg_time"`
  3898. RespondTime string `json:"respond_time"`
  3899. Signtype interface{} `json:"signtype"`
  3900. WarnMsg interface{} `json:"warn_msg"`
  3901. }
  3902. type ResultNine struct {
  3903. Cainfo string `json:"cainfo"`
  3904. ErrMsg string `json:"err_msg"`
  3905. InfRefmsgid string `json:"inf_refmsgid"`
  3906. Infcode int64 `json:"infcode"`
  3907. Output struct {
  3908. FileQuryNo string `json:"file_qury_no"`
  3909. } `json:"output"`
  3910. RefmsgTime string `json:"refmsg_time"`
  3911. RespondTime string `json:"respond_time"`
  3912. Signtype interface{} `json:"signtype"`
  3913. WarnMsg interface{} `json:"warn_msg"`
  3914. }
  3915. type ResultTen struct {
  3916. Cainfo string `json:"cainfo"`
  3917. ErrMsg string `json:"err_msg"`
  3918. InfRefmsgid string `json:"inf_refmsgid"`
  3919. Infcode int64 `json:"infcode"`
  3920. Output struct {
  3921. DldEndtime string `json:"dld_endtime"`
  3922. FileQuryNo string `json:"file_qury_no"`
  3923. Filename string `json:"filename"`
  3924. } `json:"output"`
  3925. RefmsgTime string `json:"refmsg_time"`
  3926. RespondTime string `json:"respond_time"`
  3927. Signtype interface{} `json:"signtype"`
  3928. WarnMsg interface{} `json:"warn_msg"`
  3929. }
  3930. //type Autogenerated struct {
  3931. // Output struct {
  3932. // Setlinfo struct {
  3933. // SetlTime string `json:"setl_time"`
  3934. // CvlservPay float64 `json:"cvlserv_pay"`
  3935. // Year string `json:"year"`
  3936. // MedType string `json:"med_type"`
  3937. // PsnPay float64 `json:"psn_pay"`
  3938. // OpterID string `json:"opter_id"`
  3939. // Begndate string `json:"begndate"`
  3940. // FlxempeFlag string `json:"flxempe_flag"`
  3941. // HifmiPay float64 `json:"hifmi_pay"`
  3942. // PsnNo string `json:"psn_no"`
  3943. // ActPayDedc float64 `json:"act_pay_dedc"`
  3944. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3945. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3946. // ClrWay string `json:"clr_way"`
  3947. // OthPay float64 `json:"oth_pay"`
  3948. // Gend string `json:"gend"`
  3949. // MdtrtID string `json:"mdtrt_id"`
  3950. // AcctPay float64 `json:"acct_pay"`
  3951. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3952. // Insutype string `json:"insutype"`
  3953. // Invono interface{} `json:"invono"`
  3954. // Enddate string `json:"enddate"`
  3955. // CashPayamt float64 `json:"cash_payamt"`
  3956. // PsnType string `json:"psn_type"`
  3957. // FixmedinsName string `json:"fixmedins_name"`
  3958. // HifpPay float64 `json:"hifp_pay"`
  3959. // NewFlag interface{} `json:"new_flag"`
  3960. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3961. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. // PayLoc string `json:"pay_loc"`
  3963. // ClrType string `json:"clr_type"`
  3964. // RefdSetlFlag string `json:"refd_setl_flag"`
  3965. // CvlservFlag string `json:"cvlserv_flag"`
  3966. // EmpName string `json:"emp_name"`
  3967. // Brdy string `json:"brdy"`
  3968. // Naty string `json:"naty"`
  3969. // Certno string `json:"certno"`
  3970. // DiseCode string `json:"dise_code"`
  3971. // FixmedinsCode string `json:"fixmedins_code"`
  3972. // DedcHospLv string `json:"dedc_hosp_lv"`
  3973. // OpterName string `json:"opter_name"`
  3974. // Balc float64 `json:"balc"`
  3975. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3976. // PsnCertType string `json:"psn_cert_type"`
  3977. // HifobPay float64 `json:"hifob_pay"`
  3978. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3979. // HifesPay float64 `json:"hifes_pay"`
  3980. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3981. // OptTime string `json:"opt_time"`
  3982. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3983. // SetlID string `json:"setl_id"`
  3984. // MafPay float64 `json:"maf_pay"`
  3985. // PsnName string `json:"psn_name"`
  3986. // InsuOptins interface{} `json:"insu_optins"`
  3987. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3988. // ClrOptins string `json:"clr_optins"`
  3989. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3990. // DiseName string `json:"dise_name"`
  3991. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3992. // Age float64 `json:"age"`
  3993. // DtrtCertType string `json:"dtrt_cert_type"`
  3994. // HospLv string `json:"hosp_lv"`
  3995. // } `json:"setlinfo"`
  3996. // Setldetail []struct {
  3997. // FundPayType string `json:"fund_pay_type"`
  3998. // FundPayamt float64 `json:"fund_payamt"`
  3999. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4000. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4001. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4002. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4003. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4004. // } `json:"setldetail"`
  4005. // } `json:"output"`
  4006. // Infcode int `json:"infcode"`
  4007. // WarnMsg interface{} `json:"warn_msg"`
  4008. // Cainfo interface{} `json:"cainfo"`
  4009. // ErrMsg interface{} `json:"err_msg"`
  4010. // RefmsgTime string `json:"refmsg_time"`
  4011. // Signtype interface{} `json:"signtype"`
  4012. // RespondTime string `json:"respond_time"`
  4013. // InfRefmsgid string `json:"inf_refmsgid"`
  4014. //}
  4015. type ResultEleven struct {
  4016. Cainfo string `json:"cainfo"`
  4017. ErrMsg string `json:"err_msg"`
  4018. InfRefmsgid string `json:"inf_refmsgid"`
  4019. Infcode int64 `json:"infcode"`
  4020. Output struct {
  4021. Setlinfo struct {
  4022. SetlTime string `json:"setl_time"`
  4023. CvlservPay float64 `json:"cvlserv_pay"`
  4024. Year string `json:"year"`
  4025. MedType string `json:"med_type"`
  4026. PsnPay float64 `json:"psn_pay"`
  4027. OpterID string `json:"opter_id"`
  4028. Begndate string `json:"begndate"`
  4029. FlxempeFlag string `json:"flxempe_flag"`
  4030. HifmiPay float64 `json:"hifmi_pay"`
  4031. PsnNo string `json:"psn_no"`
  4032. ActPayDedc float64 `json:"act_pay_dedc"`
  4033. MedinsSetlID interface{} `json:"medins_setl_id"`
  4034. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4035. ClrWay string `json:"clr_way"`
  4036. OthPay float64 `json:"oth_pay"`
  4037. Gend string `json:"gend"`
  4038. MdtrtID string `json:"mdtrt_id"`
  4039. AcctPay float64 `json:"acct_pay"`
  4040. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4041. Insutype string `json:"insutype"`
  4042. Invono interface{} `json:"invono"`
  4043. Enddate string `json:"enddate"`
  4044. CashPayamt float64 `json:"cash_payamt"`
  4045. PsnType string `json:"psn_type"`
  4046. FixmedinsName string `json:"fixmedins_name"`
  4047. HifpPay float64 `json:"hifp_pay"`
  4048. NewFlag interface{} `json:"new_flag"`
  4049. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4051. PayLoc string `json:"pay_loc"`
  4052. ClrType string `json:"clr_type"`
  4053. RefdSetlFlag string `json:"refd_setl_flag"`
  4054. CvlservFlag string `json:"cvlserv_flag"`
  4055. EmpName string `json:"emp_name"`
  4056. Brdy string `json:"brdy"`
  4057. Naty string `json:"naty"`
  4058. Certno string `json:"certno"`
  4059. DiseCode string `json:"dise_code"`
  4060. FixmedinsCode string `json:"fixmedins_code"`
  4061. DedcHospLv string `json:"dedc_hosp_lv"`
  4062. OpterName string `json:"opter_name"`
  4063. Balc float64 `json:"balc"`
  4064. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4065. PsnCertType string `json:"psn_cert_type"`
  4066. HifobPay float64 `json:"hifob_pay"`
  4067. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4068. HifesPay float64 `json:"hifes_pay"`
  4069. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4070. OptTime string `json:"opt_time"`
  4071. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4072. SetlID string `json:"setl_id"`
  4073. MafPay float64 `json:"maf_pay"`
  4074. PsnName string `json:"psn_name"`
  4075. InsuOptins interface{} `json:"insu_optins"`
  4076. PrefFundPay interface{} `json:"pref_fund_pay"`
  4077. ClrOptins string `json:"clr_optins"`
  4078. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4079. DiseName string `json:"dise_name"`
  4080. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4081. Age float64 `json:"age"`
  4082. DtrtCertType string `json:"dtrt_cert_type"`
  4083. HospLv string `json:"hosp_lv"`
  4084. } `json:"setlinfo"`
  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 ResultEleven10265 struct {
  4092. Cainfo string `json:"cainfo"`
  4093. ErrMsg string `json:"err_msg"`
  4094. InfRefmsgid string `json:"inf_refmsgid"`
  4095. Infcode string `json:"infcode"`
  4096. Output struct {
  4097. Setlinfo struct {
  4098. SetlTime string `json:"setl_time"`
  4099. CvlservPay float64 `json:"cvlserv_pay"`
  4100. Year string `json:"year"`
  4101. MedType string `json:"med_type"`
  4102. PsnPay float64 `json:"psn_pay"`
  4103. OpterID string `json:"opter_id"`
  4104. Begndate string `json:"begndate"`
  4105. FlxempeFlag string `json:"flxempe_flag"`
  4106. HifmiPay float64 `json:"hifmi_pay"`
  4107. PsnNo string `json:"psn_no"`
  4108. ActPayDedc float64 `json:"act_pay_dedc"`
  4109. MedinsSetlID interface{} `json:"medins_setl_id"`
  4110. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4111. ClrWay string `json:"clr_way"`
  4112. OthPay float64 `json:"oth_pay"`
  4113. Gend string `json:"gend"`
  4114. MdtrtID string `json:"mdtrt_id"`
  4115. AcctPay float64 `json:"acct_pay"`
  4116. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4117. Insutype string `json:"insutype"`
  4118. Invono interface{} `json:"invono"`
  4119. Enddate string `json:"enddate"`
  4120. CashPayamt float64 `json:"cash_payamt"`
  4121. PsnType string `json:"psn_type"`
  4122. FixmedinsName string `json:"fixmedins_name"`
  4123. HifpPay float64 `json:"hifp_pay"`
  4124. NewFlag interface{} `json:"new_flag"`
  4125. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4126. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4127. PayLoc string `json:"pay_loc"`
  4128. ClrType string `json:"clr_type"`
  4129. RefdSetlFlag string `json:"refd_setl_flag"`
  4130. CvlservFlag string `json:"cvlserv_flag"`
  4131. EmpName string `json:"emp_name"`
  4132. Brdy string `json:"brdy"`
  4133. Naty string `json:"naty"`
  4134. Certno string `json:"certno"`
  4135. DiseCode string `json:"dise_code"`
  4136. FixmedinsCode string `json:"fixmedins_code"`
  4137. DedcHospLv string `json:"dedc_hosp_lv"`
  4138. OpterName string `json:"opter_name"`
  4139. Balc float64 `json:"balc"`
  4140. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4141. PsnCertType string `json:"psn_cert_type"`
  4142. HifobPay float64 `json:"hifob_pay"`
  4143. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4144. HifesPay float64 `json:"hifes_pay"`
  4145. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4146. OptTime string `json:"opt_time"`
  4147. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4148. SetlID string `json:"setl_id"`
  4149. MafPay float64 `json:"maf_pay"`
  4150. PsnName string `json:"psn_name"`
  4151. InsuOptins interface{} `json:"insu_optins"`
  4152. PrefFundPay interface{} `json:"pref_fund_pay"`
  4153. ClrOptins string `json:"clr_optins"`
  4154. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4155. DiseName string `json:"dise_name"`
  4156. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4157. Age float64 `json:"age"`
  4158. DtrtCertType string `json:"dtrt_cert_type"`
  4159. HospLv string `json:"hosp_lv"`
  4160. } `json:"setlinfo"`
  4161. } `json:"output"`
  4162. RefmsgTime string `json:"refmsg_time"`
  4163. RespondTime string `json:"respond_time"`
  4164. Signtype interface{} `json:"signtype"`
  4165. WarnMsg interface{} `json:"warn_msg"`
  4166. }
  4167. type ResultTwelve struct {
  4168. Cainfo string `json:"cainfo"`
  4169. ErrMsg string `json:"err_msg"`
  4170. InfRefmsgid string `json:"inf_refmsgid"`
  4171. Infcode int64 `json:"infcode"`
  4172. Output struct {
  4173. MdtrtId string `json:"mdtrt_id"`
  4174. ChrgBchno string `json:"chrg_bchno"`
  4175. PsnNo string `json:"psn_no"`
  4176. } `json:"output"`
  4177. RefmsgTime string `json:"refmsg_time"`
  4178. RespondTime string `json:"respond_time"`
  4179. Signtype interface{} `json:"signtype"`
  4180. WarnMsg interface{} `json:"warn_msg"`
  4181. }
  4182. type ResultThirteen struct {
  4183. ErrMsg string `json:"err_msg"`
  4184. InfRefmsgid string `json:"inf_refmsgid"`
  4185. Infcode int64 `json:"infcode"`
  4186. Output struct {
  4187. Result struct {
  4188. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4189. } `json:"result"`
  4190. } `json:"output"`
  4191. RefmsgTime string `json:"refmsg_time"`
  4192. RespondTime string `json:"respond_time"`
  4193. Signtype interface{} `json:"signtype"`
  4194. WarnInfo interface{} `json:"warn_info"`
  4195. }
  4196. type ResultThirteen10265 struct {
  4197. ErrMsg string `json:"err_msg"`
  4198. InfRefmsgid string `json:"inf_refmsgid"`
  4199. Infcode string `json:"infcode"`
  4200. Output struct {
  4201. Result struct {
  4202. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4203. } `json:"result"`
  4204. } `json:"output"`
  4205. RefmsgTime string `json:"refmsg_time"`
  4206. RespondTime string `json:"respond_time"`
  4207. Signtype interface{} `json:"signtype"`
  4208. WarnInfo interface{} `json:"warn_info"`
  4209. }
  4210. type ResultFourteen struct {
  4211. ErrMsg string `json:"err_msg"`
  4212. InfRefmsgid string `json:"inf_refmsgid"`
  4213. Infcode int64 `json:"infcode"`
  4214. Output struct {
  4215. } `json:"output"`
  4216. RefmsgTime string `json:"refmsg_time"`
  4217. RespondTime string `json:"respond_time"`
  4218. Signtype interface{} `json:"signtype"`
  4219. WarnInfo interface{} `json:"warn_info"`
  4220. }
  4221. type ResultFourteen10265 struct {
  4222. ErrMsg string `json:"err_msg"`
  4223. InfRefmsgid string `json:"inf_refmsgid"`
  4224. Infcode string `json:"infcode"`
  4225. Output struct {
  4226. } `json:"output"`
  4227. RefmsgTime string `json:"refmsg_time"`
  4228. RespondTime string `json:"respond_time"`
  4229. Signtype interface{} `json:"signtype"`
  4230. WarnInfo interface{} `json:"warn_info"`
  4231. }
  4232. type ResultSixteen struct {
  4233. Cainfo string `json:"cainfo"`
  4234. ErrMsg string `json:"err_msg"`
  4235. InfRefmsgid string `json:"inf_refmsgid"`
  4236. Infcode int64 `json:"infcode"`
  4237. Output struct {
  4238. Setldetail []interface{} `json:"setldetail"`
  4239. Setlinfo struct {
  4240. MdtrtID string `json:"mdtrt_id"`
  4241. SetlID string `json:"setl_id"`
  4242. ClrOptins string `json:"clr_optins"`
  4243. SetlTime string `json:"setl_time"`
  4244. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4245. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4246. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4247. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4249. ActPayDedc float64 `json:"act_pay_dedc"`
  4250. HifpPay float64 `json:"hifp_pay"`
  4251. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4252. Lfpay float64 `json:"selfpay"`
  4253. CvlservPay float64 `json:"cvlserv_pay"`
  4254. HifesPay float64 `json:"hifes_pay"`
  4255. HifmiPay float64 `json:"hifmi_pay"`
  4256. HifobPay float64 `json:"hifob_pay"`
  4257. MafPay float64 `json:"maf_pay"`
  4258. OthPay float64 `json:"oth_pay"`
  4259. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4260. PsnPartAmt float64 `json:"psn_part_amt"`
  4261. AcctPay float64 `json:"acct_pay"`
  4262. Balc float64 `json:"balc"`
  4263. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4264. HospPartAmt float64 `json:"hosp_part_amt"`
  4265. MedinsSetlID string `json:"medins_setl_id"`
  4266. PdnCashPay string `json:"pdn_cash_pay"`
  4267. } `json:"setlinfo"`
  4268. } `json:"output"`
  4269. RefmsgTime string `json:"refmsg_time"`
  4270. RespondTime string `json:"respond_time"`
  4271. Signtype interface{} `json:"signtype"`
  4272. WarnMsg interface{} `json:"warn_msg"`
  4273. }
  4274. type ResultSixteen10265 struct {
  4275. Cainfo string `json:"cainfo"`
  4276. ErrMsg string `json:"err_msg"`
  4277. InfRefmsgid string `json:"inf_refmsgid"`
  4278. Infcode string `json:"infcode"`
  4279. Output struct {
  4280. Setldetail []interface{} `json:"setldetail"`
  4281. Setlinfo struct {
  4282. MdtrtID string `json:"mdtrt_id"`
  4283. SetlID string `json:"setl_id"`
  4284. ClrOptins string `json:"clr_optins"`
  4285. SetlTime string `json:"setl_time"`
  4286. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4287. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4288. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4289. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4290. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4291. ActPayDedc float64 `json:"act_pay_dedc"`
  4292. HifpPay float64 `json:"hifp_pay"`
  4293. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4294. Lfpay float64 `json:"selfpay"`
  4295. CvlservPay float64 `json:"cvlserv_pay"`
  4296. HifesPay float64 `json:"hifes_pay"`
  4297. HifmiPay float64 `json:"hifmi_pay"`
  4298. HifobPay float64 `json:"hifob_pay"`
  4299. MafPay float64 `json:"maf_pay"`
  4300. OthPay float64 `json:"oth_pay"`
  4301. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4302. PsnPartAmt float64 `json:"psn_part_amt"`
  4303. AcctPay float64 `json:"acct_pay"`
  4304. Balc float64 `json:"balc"`
  4305. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4306. HospPartAmt float64 `json:"hosp_part_amt"`
  4307. MedinsSetlID string `json:"medins_setl_id"`
  4308. PdnCashPay string `json:"pdn_cash_pay"`
  4309. } `json:"setlinfo"`
  4310. } `json:"output"`
  4311. RefmsgTime string `json:"refmsg_time"`
  4312. RespondTime string `json:"respond_time"`
  4313. Signtype interface{} `json:"signtype"`
  4314. WarnMsg interface{} `json:"warn_msg"`
  4315. }
  4316. type ResultSeventeen struct {
  4317. ErrMsg string `json:"err_msg"`
  4318. InfRefmsgid string `json:"inf_refmsgid"`
  4319. Infcode int64 `json:"infcode"`
  4320. Output struct {
  4321. SetlListId string `json:"setl_list_id"`
  4322. } `json:"output"`
  4323. RefmsgTime string `json:"refmsg_time"`
  4324. RespondTime string `json:"respond_time"`
  4325. Signtype string `json:"signtype"`
  4326. WarnInfo string `json:"warn_info"`
  4327. }
  4328. type ResultSeventeenOther struct {
  4329. ErrMsg string `json:"err_msg"`
  4330. InfRefmsgid string `json:"inf_refmsgid"`
  4331. Infcode string `json:"infcode"`
  4332. Output struct {
  4333. SetlListId string `json:"setl_list_id"`
  4334. } `json:"output"`
  4335. RefmsgTime string `json:"refmsg_time"`
  4336. RespondTime string `json:"respond_time"`
  4337. Signtype string `json:"signtype"`
  4338. WarnInfo string `json:"warn_info"`
  4339. }
  4340. type Result90991 struct {
  4341. ErrMsg string `json:"err_msg"`
  4342. InfRefmsgid string `json:"inf_refmsgid"`
  4343. Infcode int64 `json:"infcode"`
  4344. Output struct {
  4345. Result struct {
  4346. PsnNo string `json:"psn_no"`
  4347. CardStat string `json:"card_stat"`
  4348. Certno string `json:"certno"`
  4349. PsnName string `json:"psn_name"`
  4350. CheckStat string `json:"check_stat"`
  4351. SscnoCheckStat string `json:"sscno_check_stat"`
  4352. } `json:"result"`
  4353. } `json:"output"`
  4354. RefmsgTime string `json:"refmsg_time"`
  4355. RespondTime string `json:"respond_time"`
  4356. Signtype interface{} `json:"signtype"`
  4357. WarnInfo interface{} `json:"warn_info"`
  4358. }
  4359. type Result90100 struct {
  4360. ErrMsg string `json:"err_msg"`
  4361. InfRefmsgid string `json:"inf_refmsgid"`
  4362. Infcode int64 `json:"infcode"`
  4363. Output struct {
  4364. PoolareaNo string `json:"poolarea_no"`
  4365. PoolareaNoName string `json:"poolarea_no_name"`
  4366. Insutype string `json:"insutype"`
  4367. InsutypeName string `json:"insutype_name"`
  4368. ClctType string `json:"clct_type"`
  4369. ClctTypeName string `json:"clct_type_name"`
  4370. ClctFlag string `json:"clct_flag"`
  4371. ClctFlagName string `json:"clct_flag_name"`
  4372. AccrymBegn string `json:"accrym_begn"`
  4373. AccrymEnd string `json:"accrym_end"`
  4374. ClctTime string `json:"clct_time"`
  4375. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnInfo interface{} `json:"warn_info"`
  4381. }
  4382. type Custom struct {
  4383. DetItemFeeSumamt string
  4384. Cut string
  4385. FeedetlSn string
  4386. Price string
  4387. MedListCodg string
  4388. Type int64
  4389. AdviceId int64
  4390. ProjectId int64
  4391. ItemId int64
  4392. }
  4393. type Result5301 struct {
  4394. ErrMsg string `json:"err_msg"`
  4395. InfRefmsgid string `json:"inf_refmsgid"`
  4396. Infcode int64 `json:"infcode"`
  4397. Output struct {
  4398. Result []struct {
  4399. OpspDiseCode string `json:"opsp_dise_code"`
  4400. OpspDiseName string `json:"opsp_dise_name"`
  4401. Begndate string `json:"begndate"`
  4402. Enddate string `json:"enddate"`
  4403. } `json:"feedetail"`
  4404. } `json:"output"`
  4405. RefmsgTime string `json:"refmsg_time"`
  4406. RespondTime string `json:"respond_time"`
  4407. Signtype interface{} `json:"signtype"`
  4408. WarnInfo interface{} `json:"warn_info"`
  4409. }
  4410. type Result5301For10265 struct {
  4411. ErrMsg string `json:"err_msg"`
  4412. InfRefmsgid string `json:"inf_refmsgid"`
  4413. Infcode string `json:"infcode"`
  4414. Output struct {
  4415. Result []struct {
  4416. OpspDiseCode string `json:"opsp_dise_code"`
  4417. OpspDiseName string `json:"opsp_dise_name"`
  4418. Begndate string `json:"begndate"`
  4419. Enddate string `json:"enddate"`
  4420. } `json:"feedetail"`
  4421. } `json:"output"`
  4422. RefmsgTime string `json:"refmsg_time"`
  4423. RespondTime string `json:"respond_time"`
  4424. Signtype interface{} `json:"signtype"`
  4425. WarnInfo interface{} `json:"warn_info"`
  4426. }
  4427. //获取个人信息----挂号-----上传就诊信息
  4428. func (c *HisApiController) GetRegisterInfo() {
  4429. id, _ := c.GetInt64("id")
  4430. record_time := c.GetString("record_time")
  4431. settlementValue, _ := c.GetInt64("settlement_value")
  4432. medical_insurance_card := c.GetString("medical_insurance_card")
  4433. name := c.GetString("name")
  4434. id_card_type, _ := c.GetInt64("id_card_type")
  4435. certificates, _ := c.GetInt64("certificates")
  4436. medical_care, _ := c.GetInt64("medical_care")
  4437. birthday := c.GetString("birthday")
  4438. id_card := c.GetString("id_card")
  4439. register_type, _ := c.GetInt64("register")
  4440. doctor, _ := c.GetInt64("doctor")
  4441. department, _ := c.GetInt64("department")
  4442. gender, _ := c.GetInt64("sex")
  4443. registration_fee, _ := c.GetFloat("registration_fee")
  4444. medical_expenses, _ := c.GetFloat("medical_expenses")
  4445. social_type, _ := c.GetInt64("social_type")
  4446. med_type := c.GetString("social_type")
  4447. admin_user_id, _ := c.GetInt64("admin_user_id")
  4448. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4449. timeLayout := "2006-01-02"
  4450. loc, _ := time.LoadLocation("Local")
  4451. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4452. birthUnix := birthdays.Unix()
  4453. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4454. if err != nil {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4456. return
  4457. }
  4458. recordDateTime := theTime.Unix()
  4459. adminInfo := c.GetAdminUserInfo()
  4460. var patient service.Patients
  4461. if id == 0 {
  4462. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4463. } else {
  4464. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4465. }
  4466. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4467. if patientPrescription.ID == 0 {
  4468. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4469. }
  4470. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4471. if patient.ID == 0 {
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4473. return
  4474. }
  4475. if len(patient.IdCardNo) == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4477. return
  4478. }
  4479. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4480. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4481. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4482. //就诊结算未完成,不能进行二次挂号
  4483. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4484. if len(his) >= 1 {
  4485. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4486. if len(his) >= 1 && order.ID == 0 {
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4488. return
  4489. }
  4490. }
  4491. //var register_log string
  4492. if config.IsOpen == 1 {
  4493. var res ResultTwo
  4494. var res10265 ResultTwo10265
  4495. var PsnNo string
  4496. var PsnCertType string
  4497. var Certno string
  4498. var PsnName string
  4499. var Gend string
  4500. var Naty string
  4501. var Brdy string
  4502. var Age float64
  4503. var infoStr string
  4504. var idetinfoStr string
  4505. var infocode int64
  4506. var verify_number string
  4507. fmt.Println(verify_number)
  4508. if miConfig.MdtrtareaAdmvs == "421300" {
  4509. psn_info, _ := service.GetPsnByPatientId(id)
  4510. PsnNo = psn_info.PsnNo
  4511. PsnCertType = psn_info.PsnCertType
  4512. Certno = psn_info.Certno
  4513. PsnName = psn_info.PsnName
  4514. Gend = psn_info.Gend
  4515. Naty = psn_info.Naty
  4516. Brdy = psn_info.Brdy
  4517. Age = psn_info.Age
  4518. infoStr = psn_info.Insuinfo
  4519. idetinfoStr = psn_info.Idetinfo
  4520. infocode = 0
  4521. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4522. psn_info, _ := service.GetPsnByPatientId(id)
  4523. PsnNo = psn_info.PsnNo
  4524. PsnCertType = psn_info.PsnCertType
  4525. Certno = psn_info.Certno
  4526. PsnName = psn_info.PsnName
  4527. Gend = psn_info.Gend
  4528. Naty = psn_info.Naty
  4529. Brdy = psn_info.Brdy
  4530. Age = psn_info.Age
  4531. infoStr = psn_info.Insuinfo
  4532. idetinfoStr = psn_info.Idetinfo
  4533. infocode = 0
  4534. verify_number = psn_info.VerifyNumber
  4535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4536. psn_info, _ := service.GetPsnByPatientId(id)
  4537. PsnNo = psn_info.PsnNo
  4538. PsnCertType = psn_info.PsnCertType
  4539. Certno = psn_info.Certno
  4540. PsnName = psn_info.PsnName
  4541. Gend = psn_info.Gend
  4542. Naty = psn_info.Naty
  4543. Brdy = psn_info.Brdy
  4544. Age = psn_info.Age
  4545. infoStr = psn_info.Insuinfo
  4546. idetinfoStr = psn_info.Idetinfo
  4547. infocode = 0
  4548. verify_number = psn_info.VerifyNumber
  4549. } else {
  4550. var result string
  4551. var requestLog string
  4552. if miConfig.UserOrgId == 10138 {
  4553. 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)
  4554. } else {
  4555. 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)
  4556. }
  4557. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4558. if miConfig.Code == "H15049901371" {
  4559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4560. utils.ErrorLog("解析失败:%v", err)
  4561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4562. return
  4563. }
  4564. res.ErrMsg = res10265.ErrMsg
  4565. res.Output = res10265.Output
  4566. res.InfRefmsgid = res10265.InfRefmsgid
  4567. } else {
  4568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. }
  4574. PsnNo = res.Output.Baseinfo.PsnNo
  4575. PsnCertType = res.Output.Baseinfo.PsnCertType
  4576. Certno = res.Output.Baseinfo.Certno
  4577. PsnName = res.Output.Baseinfo.PsnName
  4578. Gend = res.Output.Baseinfo.Gend
  4579. Naty = res.Output.Baseinfo.Naty
  4580. Brdy = res.Output.Baseinfo.Brdy
  4581. Age = res.Output.Baseinfo.Age
  4582. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4583. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4584. infoStr = string(Iinfos)
  4585. idetinfoStr = string(Idetinfos)
  4586. if miConfig.Code == "H15049901371" {
  4587. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4588. } else {
  4589. infocode = res.Infcode
  4590. }
  4591. }
  4592. if infocode == 0 {
  4593. his := models.VMHisPatient{
  4594. Name: name,
  4595. Gender: gender,
  4596. Birthday: birthUnix,
  4597. MedicalTreatmentType: medical_care,
  4598. IdType: certificates,
  4599. IdCardNo: id_card,
  4600. BalanceAccountsType: settlementValue,
  4601. SocialType: social_type,
  4602. MedicalInsuranceNumber: medical_insurance_card,
  4603. RegisterType: register_type,
  4604. RegisterCost: registration_fee,
  4605. TreatmentCost: medical_expenses,
  4606. Status: 1,
  4607. Ctime: time.Now().Unix(),
  4608. Mtime: time.Now().Unix(),
  4609. PsnNo: PsnNo,
  4610. PsnCertType: PsnCertType,
  4611. Certno: Certno,
  4612. PsnName: PsnName,
  4613. Gend: Gend,
  4614. Naty: Naty,
  4615. Brdy: Brdy,
  4616. Age: Age,
  4617. Iinfo: infoStr,
  4618. Idetinfo: idetinfoStr,
  4619. PatientId: patient.ID,
  4620. RecordDate: theTime.Unix(),
  4621. UserOrgId: adminInfo.CurrentOrgId,
  4622. AdminUserId: admin_user_id,
  4623. IsReturn: 1,
  4624. IdCardType: id_card_type,
  4625. Doctor: doctor,
  4626. Departments: department,
  4627. }
  4628. timestamp := time.Now().Unix()
  4629. tempTime := time.Unix(timestamp, 0)
  4630. timeFormat := tempTime.Format("20060102150405")
  4631. chrgBchno := rand.Intn(100000) + 10000
  4632. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4633. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4634. department, _ := service.GetDepartMentDetail(department)
  4635. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4636. IdCardNo := ""
  4637. if id_card_type == 1 {
  4638. // IdCardNo = medical_insurance_card
  4639. IdCardNo = patient.IdCardNo
  4640. } else {
  4641. IdCardNo = patient.IdCardNo
  4642. }
  4643. var rf []*ResultFive
  4644. json.Unmarshal([]byte(his.Iinfo), &rf)
  4645. var insutypes []*ResultFive
  4646. var insutype string
  4647. var insuplc_admdvs_temp string
  4648. var is390 int = 0
  4649. var is310 int = 0
  4650. for _, item := range rf {
  4651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4652. insutypes = append(insutypes, item)
  4653. }
  4654. }
  4655. if len(insutypes) == 1 {
  4656. insutype = insutypes[0].Insutype
  4657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4658. } else {
  4659. for _, i := range insutypes {
  4660. if i.Insutype == "390" {
  4661. is390 = 1
  4662. }
  4663. if i.Insutype == "310" {
  4664. is310 = 1
  4665. }
  4666. }
  4667. }
  4668. if is390 == 1 {
  4669. insutype = "390"
  4670. }
  4671. if is310 == 1 {
  4672. insutype = "310"
  4673. }
  4674. if len(insutypes) == 0 {
  4675. insutype = "310"
  4676. }
  4677. if len(insutypes) == 2 {
  4678. insutype = med_type
  4679. }
  4680. if len(med_type) > 0 {
  4681. insutype = med_type
  4682. }
  4683. //for _, item := range rf {
  4684. // if item.Insutype == insutype {
  4685. // insuplc_admdvs = item.InsuplcAdmdvs
  4686. // }
  4687. //}
  4688. var infocode int64
  4689. var resThree ResultThree
  4690. var resThree10265 ResultThree10265
  4691. if len(insuplc_admdvs) == 0 {
  4692. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4693. } else {
  4694. insuplc_admdvs_temp = insuplc_admdvs
  4695. }
  4696. if miConfig.MdtrtareaAdmvs == "421300" {
  4697. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4698. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4699. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4700. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4701. resp, requestErr := http.Get(api)
  4702. if requestErr != nil {
  4703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. body, ioErr := ioutil.ReadAll(resp.Body)
  4707. if ioErr != nil {
  4708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. var respJSON map[string]interface{}
  4713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4719. result, _ := json.Marshal(respJSON)
  4720. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4721. utils.ErrorLog("解析失败:%v", err)
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. infocode = resThree.Infcode
  4726. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4727. psn_info, _ := service.GetPsnByPatientId(id)
  4728. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4729. var cert_no string
  4730. if id_card_type == 3 {
  4731. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4732. cert_no = IdCardNo
  4733. } else if id_card_type == 4 {
  4734. cert_no = IdCardNo
  4735. psn_info.VerifyNumber = psn_info.VerifyNumber
  4736. } else {
  4737. bas := strings.Split(psn_info.CardInfo, "|")
  4738. cert_no = bas[2]
  4739. }
  4740. var api string
  4741. if miConfig.MdtrtareaAdmvs == "320921" {
  4742. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4743. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4744. "&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
  4745. } else {
  4746. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4747. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4748. "&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
  4749. }
  4750. resp, requestErr := http.Get(api)
  4751. if requestErr != nil {
  4752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4753. return
  4754. }
  4755. body, ioErr := ioutil.ReadAll(resp.Body)
  4756. if ioErr != nil {
  4757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. var respJSON map[string]interface{}
  4762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4768. result, _ := json.Marshal(respJSON)
  4769. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4770. utils.ErrorLog("解析失败:%v", err)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. resThree.ErrMsg = resThree10265.ErrMsg
  4775. resThree.Output = resThree10265.Output
  4776. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4777. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4779. psn_info, _ := service.GetPsnByPatientId(id)
  4780. var cert_no string
  4781. if id_card_type == 1 {
  4782. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4783. }
  4784. fmt.Println(cert_no)
  4785. result, requestLog := service.FJyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  4786. saveLog(result, requestLog, "2201", "挂号")
  4787. if miConfig.Code == "H15049901371" {
  4788. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4789. utils.ErrorLog("解析失败:%v", err)
  4790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4791. return
  4792. }
  4793. resThree.ErrMsg = resThree10265.ErrMsg
  4794. resThree.Output = resThree10265.Output
  4795. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4796. } else {
  4797. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4798. utils.ErrorLog("解析失败:%v", err)
  4799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4800. return
  4801. }
  4802. }
  4803. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4804. } else {
  4805. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4806. saveLog(result, requestLog, "2201A", "挂号")
  4807. if miConfig.Code == "H15049901371" {
  4808. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4809. utils.ErrorLog("解析失败:%v", err)
  4810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4811. return
  4812. }
  4813. resThree.ErrMsg = resThree10265.ErrMsg
  4814. resThree.Output = resThree10265.Output
  4815. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4816. } else {
  4817. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4818. utils.ErrorLog("解析失败:%v", err)
  4819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4820. return
  4821. }
  4822. }
  4823. if miConfig.Code == "H15049901371" {
  4824. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4825. } else {
  4826. infocode = resThree.Infcode
  4827. }
  4828. }
  4829. if infocode != 0 {
  4830. adminUser := c.GetAdminUserInfo()
  4831. errlog := &models.HisOrderError{
  4832. UserOrgId: adminUser.CurrentOrgId,
  4833. Ctime: time.Now().Unix(),
  4834. Mtime: time.Now().Unix(),
  4835. ErrMsg: resThree.ErrMsg,
  4836. Status: 1,
  4837. PatientId: id,
  4838. RecordTime: recordDateTime,
  4839. Stage: 2,
  4840. }
  4841. service.CreateErrMsgLog(errlog)
  4842. c.ServeSuccessJSON(map[string]interface{}{
  4843. "failed_code": -10,
  4844. "msg": resThree.ErrMsg,
  4845. })
  4846. return
  4847. }
  4848. his.Number = resThree.Output.Data.MdtrtID
  4849. his.PsnNo = resThree.Output.Data.PsnNo
  4850. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4851. his.IdCardNo = patient.IdCardNo
  4852. his.PhoneNumber = patient.Phone
  4853. his.UserOrgId = adminInfo.CurrentOrgId
  4854. his.Insutype = insutype
  4855. his.Ctime = time.Now().Unix()
  4856. his.Mtime = time.Now().Unix()
  4857. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4858. his.Status = 1
  4859. service.UpdateHisPatientStatus(&his)
  4860. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4861. c.ServeSuccessJSON(map[string]interface{}{
  4862. "his_info": his,
  4863. })
  4864. } else {
  4865. adminUser := c.GetAdminUserInfo()
  4866. errlog := &models.HisOrderError{
  4867. UserOrgId: adminUser.CurrentOrgId,
  4868. Ctime: time.Now().Unix(),
  4869. Mtime: time.Now().Unix(),
  4870. ErrMsg: res.ErrMsg,
  4871. Status: 1,
  4872. PatientId: id,
  4873. RecordTime: recordDateTime,
  4874. Stage: 1,
  4875. }
  4876. service.CreateErrMsgLog(errlog)
  4877. c.ServeSuccessJSON(map[string]interface{}{
  4878. "failed_code": -10,
  4879. "msg": res.ErrMsg,
  4880. })
  4881. return
  4882. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4883. }
  4884. }
  4885. }
  4886. //上传明细----预结算----确认订单
  4887. func (c *HisApiController) GetUploadInfo() {
  4888. id, _ := c.GetInt64("id")
  4889. record_time := c.GetString("record_time")
  4890. his_patient_id, _ := c.GetInt64("his_patient_id")
  4891. order_id, _ := c.GetInt64("order_id")
  4892. pay_way, _ := c.GetInt64("pay_way")
  4893. pay_price, _ := c.GetFloat("pay_price")
  4894. pay_card_no := c.GetString("pay_card_no")
  4895. token := c.GetString("token")
  4896. discount_price, _ := c.GetFloat("discount_price")
  4897. preferential_price, _ := c.GetFloat("preferential_price")
  4898. reality_price, _ := c.GetFloat("reality_price")
  4899. found_price, _ := c.GetFloat("found_price")
  4900. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4901. private_price, _ := c.GetFloat("private_price")
  4902. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4903. admin_user_id, _ := c.GetInt64("admin_user_id")
  4904. fapiao_code := c.GetString("fapiao_code")
  4905. fapiao_number := c.GetString("fapiao_number")
  4906. diagnosis_id := c.GetString("diagnosis")
  4907. sick_type, _ := c.GetInt64("sick_type")
  4908. reg_type, _ := c.GetInt64("p_type")
  4909. begin_time := c.GetString("begin_time")
  4910. id_str := c.GetString("ids")
  4911. ids_arr := strings.Split(id_str, ",")
  4912. timeLayout := "2006-01-02"
  4913. loc, _ := time.LoadLocation("Local")
  4914. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4915. if err != nil {
  4916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4917. return
  4918. }
  4919. recordDateTime := theTime.Unix()
  4920. adminUser := c.GetAdminUserInfo()
  4921. var tempOrder models.HisOrder
  4922. tempOrder, _ = service.GetHisOrderByID(order_id)
  4923. var prescriptions []*models.HisPrescription
  4924. var start_time int64
  4925. var end_time int64
  4926. //押金模块
  4927. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4928. tmp_decimal := c.GetString("tmp_decimal")
  4929. var decimal float64 //本次使用的押金
  4930. var errmsg error
  4931. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4932. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4933. return
  4934. }
  4935. if len(tmp_decimal) > 0 {
  4936. if tmp_decimal[0] == 45 {
  4937. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4938. return
  4939. }
  4940. }
  4941. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4942. fmt.Println(errs)
  4943. decimal = tt
  4944. //if adminUser.CurrentOrgId == 10106{
  4945. // if len(fapiao_code) == 0{
  4946. // fapiao_code = "144072080589"
  4947. // }
  4948. // if len(fapiao_number) == 0{
  4949. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4950. // if order.ID == 0{
  4951. // fapiao_number = "00001520"
  4952. // }else{
  4953. // //fapiao_code = "00001520"
  4954. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4955. // var zero string
  4956. // if fpNumber >= 1000{
  4957. // zero = "0000" + strconv.Itoa(fpNumber)
  4958. // }else if fpNumber >= 10000{
  4959. // zero = "000" + strconv.Itoa(fpNumber)
  4960. // } else if fpNumber >= 100000{
  4961. // zero = "00" + strconv.Itoa(fpNumber)
  4962. // } else if fpNumber >= 1000000{
  4963. // zero = "0" + strconv.Itoa(fpNumber)
  4964. // }else {
  4965. // zero = strconv.Itoa(fpNumber)
  4966. // }
  4967. // fapiao_number = zero
  4968. // }
  4969. // }
  4970. //}
  4971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4972. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4973. var patientPrescription models.HisPrescriptionInfo
  4974. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4975. if patientPrescription.ID == 0 {
  4976. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4977. }
  4978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4979. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4980. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4981. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4982. var config []*models.HisXtDiagnoseConfig
  4983. for _, item := range diagnosis_ids {
  4984. id, _ := strconv.ParseInt(item, 10, 64)
  4985. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4986. config = append(config, &diagnosisConfig)
  4987. }
  4988. sickConfig, _ := service.FindSickById(sick_type)
  4989. //if tempOrder.ID == 0 {
  4990. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4991. //}
  4992. if tempOrder.ID == 0 {
  4993. var result string
  4994. var requestLog string
  4995. var res2 ResultSix
  4996. var ressix10265 ResultSix10265
  4997. if miConfig.MdtrtareaAdmvs == "421300" {
  4998. data := make(map[string]interface{})
  4999. client := &http.Client{}
  5000. data["psn_no"] = his.PsnNo
  5001. data["mdtrt_id"] = his.Number
  5002. data["opter"] = roles.UserName
  5003. data["org_name"] = miConfig.OrgName
  5004. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5005. data["doctor_id"] = doctor_info.DoctorNumber
  5006. data["doctor_name"] = doctor_info.UserName
  5007. data["department"] = department.Name
  5008. data["fixmedins_code"] = miConfig.Code
  5009. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5010. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5011. data["secret_key"] = miConfig.SecretKey
  5012. data["sick_code"] = sickConfig.CountryCode
  5013. data["sick_name"] = sickConfig.ClassName
  5014. data["dept"] = strconv.FormatInt(department.ID, 10)
  5015. data["config"] = config
  5016. data["begin_time"] = begin_time
  5017. bytesData, _ := json.Marshal(data)
  5018. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5019. resp, _ := client.Do(req)
  5020. defer resp.Body.Close()
  5021. body, ioErr := ioutil.ReadAll(resp.Body)
  5022. if ioErr != nil {
  5023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return
  5026. }
  5027. var respJSON map[string]interface{}
  5028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5031. return
  5032. }
  5033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5034. userJSONBytes, _ := json.Marshal(respJSON)
  5035. fmt.Println("log")
  5036. fmt.Println(string(userJSONBytes))
  5037. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5038. utils.ErrorLog("解析失败:%v", err)
  5039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5040. return
  5041. }
  5042. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5043. //江苏地区国家医保医疗类别
  5044. //职工透析:医疗类别选特殊情况门诊9933
  5045. //居民血透门慢: 医疗类别选门诊慢病1402
  5046. //var med_type string
  5047. //if his.Insutype == "310" {
  5048. // if reg_type == 14 {
  5049. // med_type = "9933"
  5050. // } else if reg_type == 11 {
  5051. // med_type = "11"
  5052. //
  5053. // }
  5054. //} else if his.Insutype == "390" {
  5055. // if reg_type == 14 {
  5056. // med_type = "1402"
  5057. // } else if reg_type == 11 {
  5058. // med_type = "11"
  5059. // }
  5060. //}
  5061. data := make(map[string]interface{})
  5062. client := &http.Client{}
  5063. data["psn_no"] = his.PsnNo
  5064. data["mdtrt_id"] = his.Number
  5065. data["doctor"] = roles.UserName
  5066. data["department"] = department.Name
  5067. data["org_name"] = miConfig.OrgName
  5068. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5069. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5070. data["fixmedins_code"] = miConfig.Code
  5071. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5072. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5073. data["secret_key"] = miConfig.SecretKey
  5074. data["sick_code"] = sickConfig.CountryCode
  5075. data["sick_name"] = sickConfig.ClassName
  5076. data["url"] = miConfig.Url
  5077. data["ak"] = miConfig.AccessKey
  5078. data["begin_time"] = begin_time
  5079. data["cainfo"] = miConfig.Cainfo
  5080. data["dept"] = strconv.FormatInt(department.ID, 10)
  5081. data["config"] = config
  5082. bytesData, _ := json.Marshal(data)
  5083. var req *http.Request
  5084. if miConfig.MdtrtareaAdmvs == "320921" {
  5085. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5086. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5087. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5088. } else {
  5089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5090. }
  5091. resp, _ := client.Do(req)
  5092. defer resp.Body.Close()
  5093. body, ioErr := ioutil.ReadAll(resp.Body)
  5094. if ioErr != nil {
  5095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5097. return
  5098. }
  5099. var respJSON map[string]interface{}
  5100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5103. return
  5104. }
  5105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5106. userJSONBytes, _ := json.Marshal(respJSON)
  5107. fmt.Println("log")
  5108. fmt.Println(string(userJSONBytes))
  5109. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5110. utils.ErrorLog("解析失败:%v", err)
  5111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5112. return
  5113. }
  5114. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5115. res2.Output = ressix10265.Output
  5116. res2.ErrMsg = ressix10265.ErrMsg
  5117. res2.Cainfo = ressix10265.Cainfo
  5118. res2.WarnMsg = ressix10265.WarnMsg
  5119. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5120. res2.Infcode = infocode
  5121. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5122. result, requestLog = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5123. saveLog(result, requestLog, "2203", "上传就诊信息")
  5124. var respJSON2 map[string]interface{}
  5125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5128. return
  5129. }
  5130. userJSONBytes2, _ := json.Marshal(respJSON2)
  5131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5132. utils.ErrorLog("解析失败:%v", err)
  5133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5134. return
  5135. }
  5136. } else {
  5137. if miConfig.MdtrtareaAdmvs == "440781" { //
  5138. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5139. } else {
  5140. if miConfig.Code == "H15049901371" {
  5141. //赤峰地区国家医保医疗类别
  5142. //职工透析:医疗类别选特殊情况门诊990502
  5143. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5144. var med_type string
  5145. if his.Insutype == "390" {
  5146. if reg_type == 14 {
  5147. med_type = "9933"
  5148. } else if reg_type == 11 {
  5149. med_type = "11"
  5150. }
  5151. } else if his.Insutype == "310" {
  5152. if reg_type == 14 {
  5153. med_type = "990502"
  5154. } else if reg_type == 11 {
  5155. med_type = "11"
  5156. }
  5157. }
  5158. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5159. } else {
  5160. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5161. }
  5162. }
  5163. saveLog(result, requestLog, "2203", "上传就诊信息")
  5164. var respJSON2 map[string]interface{}
  5165. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. userJSONBytes2, _ := json.Marshal(respJSON2)
  5171. if miConfig.Code == "H15049901371" {
  5172. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5173. utils.ErrorLog("解析失败:%v", err)
  5174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5175. return
  5176. }
  5177. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5178. res2.Output = ressix10265.Output
  5179. res2.ErrMsg = ressix10265.ErrMsg
  5180. res2.Cainfo = ressix10265.Cainfo
  5181. res2.WarnMsg = ressix10265.WarnMsg
  5182. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5183. res2.Infcode = infocode
  5184. } else {
  5185. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5186. utils.ErrorLog("解析失败:%v", err)
  5187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5188. return
  5189. }
  5190. }
  5191. }
  5192. if res2.Infcode != 0 {
  5193. adminUser := c.GetAdminUserInfo()
  5194. errlog := &models.HisOrderError{
  5195. UserOrgId: adminUser.CurrentOrgId,
  5196. Ctime: time.Now().Unix(),
  5197. Mtime: time.Now().Unix(),
  5198. ErrMsg: res2.ErrMsg,
  5199. Status: 1,
  5200. PatientId: id,
  5201. RecordTime: recordDateTime,
  5202. Stage: 3,
  5203. }
  5204. service.CreateErrMsgLog(errlog)
  5205. c.ServeSuccessJSON(map[string]interface{}{
  5206. "failed_code": -10,
  5207. "msg": res2.ErrMsg,
  5208. })
  5209. return
  5210. } else {
  5211. his.Diagnosis = diagnosis_id
  5212. his.SickType = sickConfig.ID
  5213. //var p_type int64
  5214. //if reg_type == 1111 || reg_type == 1112 {
  5215. // p_type = 11
  5216. //
  5217. //}
  5218. his.PType = fmt.Sprintf("%d", reg_type)
  5219. service.UpdateHisPatientThree(&his)
  5220. data := make(map[string]interface{})
  5221. if settle_accounts_type == 1 { //日结
  5222. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5223. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5224. } else {
  5225. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5226. }
  5227. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5228. data["pre"] = prescriptions
  5229. } else { //月结
  5230. start_time_str := c.GetString("start_time")
  5231. end_time_str := c.GetString("end_time")
  5232. timeLayout := "2006-01-02"
  5233. loc, _ := time.LoadLocation("Local")
  5234. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5235. if err != nil {
  5236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5237. return
  5238. }
  5239. recordStartTime := theStartTime.Unix()
  5240. start_time = recordStartTime
  5241. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5242. if err != nil {
  5243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5244. return
  5245. }
  5246. recordEndTime := theEndTime.Unix()
  5247. end_time = recordEndTime
  5248. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5249. data["pre"] = prescriptions
  5250. }
  5251. timestamp := time.Now().Unix()
  5252. tempTime := time.Unix(timestamp, 0)
  5253. timeFormat := tempTime.Format("20060102150405")
  5254. chrgBchno := rand.Intn(100000) + 10000
  5255. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5256. strconv.FormatInt(his.PatientId, 10)
  5257. client := &http.Client{}
  5258. data["psn_no"] = his.PsnNo
  5259. data["mdtrt_id"] = his.Number
  5260. data["chrg_bchno"] = chrg_bchno
  5261. data["org_name"] = miConfig.OrgName
  5262. data["doctor"] = doctor_info.UserName
  5263. data["doctor_id"] = doctor_info.DoctorNumber
  5264. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5265. data["fixmedins_code"] = miConfig.Code
  5266. data["opter"] = roles.UserName
  5267. data["dept_code"] = department.Number
  5268. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5269. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5270. data["secret_key"] = miConfig.SecretKey
  5271. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5272. data["url"] = miConfig.Url
  5273. data["ak"] = miConfig.AccessKey
  5274. data["new_doctor_name"] = patientPrescription.Doctor
  5275. data["diag_code"] = sickConfig.CountryCode
  5276. data["cainfo"] = miConfig.Cainfo
  5277. var ids []int64
  5278. for _, item := range prescriptions {
  5279. ids = append(ids, item.ID)
  5280. }
  5281. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5282. if config.IsOpen == 1 { //对接了医保,走医保流程
  5283. var res ResultFour
  5284. var resFour10265 ResultFour10265
  5285. if miConfig.MdtrtareaAdmvs == "421300" {
  5286. bytesData, _ := json.Marshal(data)
  5287. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5288. resp, _ := client.Do(req)
  5289. defer resp.Body.Close()
  5290. body, ioErr := ioutil.ReadAll(resp.Body)
  5291. if ioErr != nil {
  5292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5294. return
  5295. }
  5296. var respJSON map[string]interface{}
  5297. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5300. return
  5301. }
  5302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5303. userJSONBytes, _ := json.Marshal(respJSON)
  5304. fmt.Println("log")
  5305. fmt.Println(string(userJSONBytes))
  5306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5307. utils.ErrorLog("解析失败:%v", err)
  5308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5309. return
  5310. }
  5311. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5312. bytesData, _ := json.Marshal(data)
  5313. var req *http.Request
  5314. if miConfig.MdtrtareaAdmvs == "320921" {
  5315. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5316. } else {
  5317. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5318. }
  5319. resp, _ := client.Do(req)
  5320. defer resp.Body.Close()
  5321. body, ioErr := ioutil.ReadAll(resp.Body)
  5322. if ioErr != nil {
  5323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5325. return
  5326. }
  5327. var respJSON map[string]interface{}
  5328. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5331. return
  5332. }
  5333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5334. userJSONBytes, _ := json.Marshal(respJSON)
  5335. fmt.Println("log")
  5336. fmt.Println(string(userJSONBytes))
  5337. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5338. utils.ErrorLog("解析失败:%v", err)
  5339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5340. return
  5341. }
  5342. res.InfRefmsgid = resFour10265.InfRefmsgid
  5343. res.Output = resFour10265.Output
  5344. res.ErrMsg = resFour10265.ErrMsg
  5345. res.Cainfo = resFour10265.Cainfo
  5346. res.WarnMsg = resFour10265.WarnMsg
  5347. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5348. res.Infcode = infocode
  5349. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5350. result, request_log := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5351. var dat map[string]interface{}
  5352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5353. fmt.Println(dat)
  5354. } else {
  5355. fmt.Println(err)
  5356. }
  5357. saveLog(result, request_log, "2204", "上传费用明细")
  5358. userJSONBytes, _ := json.Marshal(dat)
  5359. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5360. utils.ErrorLog("解析失败:%v", err)
  5361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5362. return
  5363. }
  5364. res.InfRefmsgid = resFour10265.InfRefmsgid
  5365. res.Output = resFour10265.Output
  5366. res.ErrMsg = resFour10265.ErrMsg
  5367. res.Cainfo = resFour10265.Cainfo
  5368. res.WarnMsg = resFour10265.WarnMsg
  5369. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5370. res.Infcode = infocode
  5371. } else {
  5372. if miConfig.Code == "H15049901371" {
  5373. 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)
  5374. var dat map[string]interface{}
  5375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5376. fmt.Println(dat)
  5377. } else {
  5378. fmt.Println(err)
  5379. }
  5380. saveLog(result, request_log, "2204", "上传费用明细")
  5381. userJSONBytes, _ := json.Marshal(dat)
  5382. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5383. utils.ErrorLog("解析失败:%v", err)
  5384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5385. return
  5386. }
  5387. res.InfRefmsgid = resFour10265.InfRefmsgid
  5388. res.Output = resFour10265.Output
  5389. res.ErrMsg = resFour10265.ErrMsg
  5390. res.Cainfo = resFour10265.Cainfo
  5391. res.WarnMsg = resFour10265.WarnMsg
  5392. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5393. res.Infcode = infocode
  5394. } else {
  5395. 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)
  5396. var dat map[string]interface{}
  5397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5398. fmt.Println(dat)
  5399. } else {
  5400. fmt.Println(err)
  5401. }
  5402. saveLog(result, request_log, "2204", "上传费用明细")
  5403. userJSONBytes, _ := json.Marshal(dat)
  5404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5405. utils.ErrorLog("解析失败:%v", err)
  5406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5407. return
  5408. }
  5409. }
  5410. }
  5411. if res.Infcode == 0 {
  5412. order := &models.HisOrder{
  5413. UserOrgId: adminUser.CurrentOrgId,
  5414. HisPatientId: his.ID,
  5415. PatientId: his.PatientId,
  5416. SettleAccountsDate: recordDateTime,
  5417. MdtrtId: his.Number,
  5418. PsnNo: his.PsnNo,
  5419. MedType: strconv.FormatInt(reg_type, 10),
  5420. Ctime: time.Now().Unix(),
  5421. Mtime: time.Now().Unix(),
  5422. Status: 1,
  5423. Number: chrg_bchno,
  5424. Infcode: res.Infcode,
  5425. WarnMsg: res.WarnMsg,
  5426. Cainfo: res.Cainfo,
  5427. ErrMsg: res.ErrMsg,
  5428. RespondTime: res.RefmsgTime,
  5429. InfRefmsgid: res.InfRefmsgid,
  5430. OrderStatus: 1,
  5431. PayWay: pay_way,
  5432. PayPrice: pay_price,
  5433. PayCardNo: pay_card_no,
  5434. DiscountPrice: discount_price,
  5435. PreferentialPrice: preferential_price,
  5436. RealityPrice: reality_price,
  5437. FoundPrice: found_price,
  5438. MedicalInsurancePrice: medical_insurance_price,
  5439. PrivatePrice: private_price,
  5440. IsMedicineInsurance: 1,
  5441. SettleType: settle_accounts_type,
  5442. SettleStartTime: start_time,
  5443. SettleEndTime: end_time,
  5444. Creator: roles.AdminUserId,
  5445. Modify: roles.AdminUserId,
  5446. FaPiaoNumber: fapiao_number,
  5447. FaPiaoCode: fapiao_code,
  5448. PType: 2,
  5449. Diagnosis: diagnosis_id,
  5450. }
  5451. err = service.CreateOrder(order)
  5452. if err != nil {
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5454. return
  5455. }
  5456. for _, item := range res.Output.Result {
  5457. temp := strings.Split(item.FeedetlSn, "-")
  5458. var advice_id int64 = 0
  5459. var project_id int64 = 0
  5460. var types int64 = 0
  5461. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5462. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5463. if temp[1] == "1" {
  5464. advice_id = id
  5465. project_id = 0
  5466. } else if temp[1] == "2" {
  5467. advice_id = 0
  5468. project_id = id
  5469. }
  5470. info := &models.HisOrderInfo{
  5471. OrderNumber: order.Number,
  5472. FeedetlSn: item.FeedetlSn,
  5473. UploadDate: time.Now().Unix(),
  5474. AdviceId: advice_id,
  5475. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5476. Cnt: item.Cnt,
  5477. Pric: float64(item.Pric),
  5478. PatientId: his.PatientId,
  5479. PricUplmtAmt: item.PricUplmtAmt,
  5480. SelfpayProp: item.SelfpayProp,
  5481. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5482. OverlmtAmt: item.OverlmtAmt,
  5483. PreselfpayAmt: item.PreselfpayAmt,
  5484. BasMednFlag: item.BasMednFlag,
  5485. MedChrgitmType: item.MedChrgitmType,
  5486. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5487. Status: 1,
  5488. Memo: item.Memo,
  5489. Mtime: time.Now().Unix(),
  5490. InscpScpAmt: item.InscpScpAmt,
  5491. DrtReimFlag: item.DrtReimFlag,
  5492. Ctime: time.Now().Unix(),
  5493. ListSpItemFlag: item.ListSpItemFlag,
  5494. ChldMedcFlag: item.ChldMedcFlag,
  5495. LmtUsedFlag: item.LmtUsedFlag,
  5496. ChrgitmLv: item.ChrgitmLv,
  5497. UserOrgId: adminUser.CurrentOrgId,
  5498. HisPatientId: his.ID,
  5499. OrderId: order.ID,
  5500. ProjectId: project_id,
  5501. Type: types,
  5502. }
  5503. service.CreateOrderInfo(info)
  5504. }
  5505. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5506. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5507. var total float64
  5508. for _, item := range prescriptions {
  5509. if item.Type == 1 { //药品
  5510. for _, subItem := range item.HisDoctorAdviceInfo {
  5511. total = total + (subItem.Price * subItem.PrescribingNumber)
  5512. }
  5513. }
  5514. if item.Type == 2 { //项目
  5515. for _, subItem := range item.HisPrescriptionProject {
  5516. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5517. total = total + (subItem.Price * cnt)
  5518. }
  5519. }
  5520. }
  5521. for _, item := range prescriptions {
  5522. for _, subItem := range item.HisAdditionalCharge {
  5523. total = total + (subItem.Price * float64(subItem.Count))
  5524. }
  5525. }
  5526. var allTotal string
  5527. if adminUser.CurrentOrgId == 9919 {
  5528. allTotal = fmt.Sprintf("%.4f", total)
  5529. } else {
  5530. allTotal = fmt.Sprintf("%.4f", total)
  5531. }
  5532. if res.Infcode == 0 {
  5533. var rf []*ResultFive
  5534. json.Unmarshal([]byte(his.Iinfo), &rf)
  5535. chrg_bchno := chrg_bchno
  5536. cert_no := his.Certno
  5537. var insutypes []string
  5538. var insutype string
  5539. var is390 int = 0
  5540. var is310 int = 0
  5541. for _, item := range rf {
  5542. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5543. insutypes = append(insutypes, item.Insutype)
  5544. }
  5545. }
  5546. if len(insutypes) == 1 {
  5547. insutype = insutypes[0]
  5548. } else {
  5549. for _, i := range insutypes {
  5550. if i == "390" {
  5551. is390 = 1
  5552. }
  5553. if i == "310" {
  5554. is310 = 1
  5555. }
  5556. }
  5557. }
  5558. if is390 == 1 {
  5559. insutype = "390"
  5560. }
  5561. if is310 == 1 {
  5562. insutype = "310"
  5563. }
  5564. if len(insutypes) == 0 {
  5565. insutype = "310"
  5566. }
  5567. if len(insutypes) == 2 {
  5568. insutype = strconv.FormatInt(his.SocialType, 10)
  5569. }
  5570. insutype = strconv.FormatInt(his.SocialType, 10)
  5571. //insutype = "390"
  5572. if his.IdCardType == 1 {
  5573. // cert_no = his.MedicalInsuranceNumber
  5574. cert_no = his.Certno
  5575. } else {
  5576. cert_no = his.Certno
  5577. }
  5578. var res ResultSeven
  5579. var resSeven10265 ResultSeven10265
  5580. var src_resquest string
  5581. var result2 string
  5582. var acct_used_flag string
  5583. fmt.Println("pay_way")
  5584. fmt.Println(pay_way)
  5585. fmt.Println("pay_way")
  5586. if pay_way == 4 {
  5587. acct_used_flag = "1"
  5588. } else {
  5589. acct_used_flag = "0"
  5590. }
  5591. if miConfig.MdtrtareaAdmvs == "421300" {
  5592. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5593. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5594. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5595. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5596. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5597. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5598. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5599. resp, requestErr := http.Get(api)
  5600. if requestErr != nil {
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. body, ioErr := ioutil.ReadAll(resp.Body)
  5605. if ioErr != nil {
  5606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5608. return
  5609. }
  5610. var respJSON map[string]interface{}
  5611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5614. return
  5615. }
  5616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5617. result, _ := json.Marshal(respJSON)
  5618. if miConfig.Code == "H15049901371" {
  5619. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5620. utils.ErrorLog("解析失败:%v", err)
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5622. return
  5623. }
  5624. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5625. res.Output = resSeven10265.Output
  5626. res.ErrMsg = resSeven10265.ErrMsg
  5627. res.Cainfo = resSeven10265.Cainfo
  5628. res.WarnMsg = resSeven10265.WarnMsg
  5629. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5630. res.Infcode = infocode
  5631. } else {
  5632. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5633. utils.ErrorLog("解析失败:%v", err)
  5634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5635. return
  5636. }
  5637. }
  5638. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5639. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5640. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5641. bas := strings.Split(psn_info.CardInfo, "|")
  5642. if his.IdCardType == 1 {
  5643. cert_no = bas[2]
  5644. } else if his.IdCardType == 3 {
  5645. cert_no = his.Certno
  5646. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5647. } else if his.IdCardType == 4 {
  5648. cert_no = his.Certno
  5649. psn_info.VerifyNumber = token
  5650. }
  5651. var api string
  5652. if miConfig.MdtrtareaAdmvs == "320921" {
  5653. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5654. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5655. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5656. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5657. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5658. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5659. "&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
  5660. } else {
  5661. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5662. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5663. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5664. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5665. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5666. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5667. "&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
  5668. }
  5669. resp, requestErr := http.Get(api)
  5670. if requestErr != nil {
  5671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5672. return
  5673. }
  5674. body, ioErr := ioutil.ReadAll(resp.Body)
  5675. if ioErr != nil {
  5676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5678. return
  5679. }
  5680. var respJSON map[string]interface{}
  5681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5684. return
  5685. }
  5686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5687. result, _ := json.Marshal(respJSON)
  5688. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5689. utils.ErrorLog("解析失败:%v", err)
  5690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5691. return
  5692. }
  5693. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5694. res.Output = resSeven10265.Output
  5695. res.ErrMsg = resSeven10265.ErrMsg
  5696. res.Cainfo = resSeven10265.Cainfo
  5697. res.WarnMsg = resSeven10265.WarnMsg
  5698. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5699. res.Infcode = infocode
  5700. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5701. result2, src_resquest = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5702. //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)
  5703. var dat map[string]interface{}
  5704. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5705. fmt.Println(dat)
  5706. } else {
  5707. fmt.Println(err)
  5708. }
  5709. saveLog(result2, src_resquest, "2207", "结算")
  5710. userJSONBytes, _ := json.Marshal(dat)
  5711. if err := json.Unmarshal(userJSONBytes, &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 miConfig.Code == "H15049901371" {
  5725. //赤峰地区国家医保医疗类别
  5726. //职工透析:医疗类别选特殊情况门诊990502
  5727. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5728. var med_type string
  5729. if his.Insutype == "390" {
  5730. if reg_type == 14 {
  5731. med_type = "9933"
  5732. } else if reg_type == 11 {
  5733. med_type = "11"
  5734. }
  5735. } else if his.Insutype == "310" {
  5736. if reg_type == 14 {
  5737. med_type = "990502"
  5738. } else if reg_type == 11 {
  5739. med_type = "11"
  5740. }
  5741. }
  5742. 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)
  5743. } else {
  5744. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5745. }
  5746. //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)
  5747. var dat map[string]interface{}
  5748. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5749. fmt.Println(dat)
  5750. } else {
  5751. fmt.Println(err)
  5752. }
  5753. saveLog(result2, src_resquest, "2207", "结算")
  5754. userJSONBytes, _ := json.Marshal(dat)
  5755. if miConfig.Code == "H15049901371" {
  5756. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5757. utils.ErrorLog("解析失败:%v", err)
  5758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5759. return
  5760. }
  5761. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5762. res.Output = resSeven10265.Output
  5763. res.ErrMsg = resSeven10265.ErrMsg
  5764. res.Cainfo = resSeven10265.Cainfo
  5765. res.WarnMsg = resSeven10265.WarnMsg
  5766. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5767. res.Infcode = infocode
  5768. } else {
  5769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5770. utils.ErrorLog("解析失败:%v", err)
  5771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5772. return
  5773. }
  5774. }
  5775. }
  5776. if res.Infcode != 0 {
  5777. errlog := &models.HisOrderError{
  5778. UserOrgId: adminUser.CurrentOrgId,
  5779. Ctime: time.Now().Unix(),
  5780. Mtime: time.Now().Unix(),
  5781. Number: chrg_bchno,
  5782. ErrMsg: res.ErrMsg,
  5783. Status: 1,
  5784. PatientId: id,
  5785. RecordTime: recordDateTime,
  5786. Stage: 6,
  5787. }
  5788. service.CreateErrMsgLog(errlog)
  5789. c.ServeSuccessJSON(map[string]interface{}{
  5790. "failed_code": -10,
  5791. "msg": res.ErrMsg,
  5792. })
  5793. return
  5794. } else {
  5795. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5796. order.OrderStatus = 2
  5797. order.Status = 1
  5798. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5799. order.SetlId = res.Output.Setlinfo.SetlID
  5800. order.PsnNo = res.Output.Setlinfo.PsnNo
  5801. order.PsnName = res.Output.Setlinfo.PsnName
  5802. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5803. order.Certno = res.Output.Setlinfo.Certno
  5804. order.Gend = res.Output.Setlinfo.Gend
  5805. order.Naty = res.Output.Setlinfo.Naty
  5806. order.Age = res.Output.Setlinfo.Age
  5807. order.Insutype = res.Output.Setlinfo.Insutype
  5808. order.PsnType = res.Output.Setlinfo.PsnType
  5809. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5810. order.SetlTime = res.Output.Setlinfo.SetlTime
  5811. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5812. if res.Output.Setlinfo.MedType == "140101" {
  5813. order.MedType = "14"
  5814. } else {
  5815. order.MedType = res.Output.Setlinfo.MedType
  5816. }
  5817. if reg_type == 1112 {
  5818. order.MedType = "1112"
  5819. }
  5820. if reg_type == 1111 {
  5821. order.MedType = "1111"
  5822. }
  5823. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5824. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5825. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5826. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5827. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5828. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5829. order.HifpPay = res.Output.Setlinfo.HifpPay
  5830. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5831. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5832. order.HifesPay = res.Output.Setlinfo.HifesPay
  5833. order.HifobPay = res.Output.Setlinfo.HifobPay
  5834. order.MafPay = res.Output.Setlinfo.MafPay
  5835. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5836. order.OthPay = res.Output.Setlinfo.OthPay
  5837. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5838. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5839. order.AcctPay = res.Output.Setlinfo.AcctPay
  5840. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5841. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5842. order.Balc = res.Output.Setlinfo.Balc
  5843. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5844. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5845. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5846. order.ClrType = res.Output.Setlinfo.ClrType
  5847. order.ClrWay = res.Output.Setlinfo.ClrWay
  5848. order.Creator = order.Creator
  5849. order.Modify = roles.AdminUserId
  5850. order.RequestLog = src_resquest
  5851. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5852. detailStr := string(setlDetail)
  5853. order.SetlDetail = detailStr
  5854. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5855. err = service.UpDateOrder(order)
  5856. if err == nil {
  5857. //判断是否使用了押金
  5858. if dec_way == "true" {
  5859. tmpstring := strconv.FormatInt(order.ID, 10)
  5860. order.Decimal = decimal
  5861. service.UpDateOrder(order)
  5862. //扣押金
  5863. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5864. if errmsg != nil {
  5865. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5866. return
  5867. }
  5868. }
  5869. c.ServeSuccessJSON(map[string]interface{}{
  5870. "msg": "结算成功",
  5871. })
  5872. } else {
  5873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5874. return
  5875. }
  5876. }
  5877. } else {
  5878. adminUser := c.GetAdminUserInfo()
  5879. errlog := &models.HisOrderError{
  5880. UserOrgId: adminUser.CurrentOrgId,
  5881. Ctime: time.Now().Unix(),
  5882. Mtime: time.Now().Unix(),
  5883. ErrMsg: res.ErrMsg,
  5884. Status: 1,
  5885. PatientId: id,
  5886. RecordTime: recordDateTime,
  5887. Stage: 4,
  5888. }
  5889. service.CreateErrMsgLog(errlog)
  5890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5891. return
  5892. }
  5893. } else {
  5894. adminUser := c.GetAdminUserInfo()
  5895. errlog := &models.HisOrderError{
  5896. UserOrgId: adminUser.CurrentOrgId,
  5897. Ctime: time.Now().Unix(),
  5898. Mtime: time.Now().Unix(),
  5899. ErrMsg: res.ErrMsg,
  5900. Status: 1,
  5901. PatientId: id,
  5902. RecordTime: recordDateTime,
  5903. Stage: 4,
  5904. }
  5905. service.CreateErrMsgLog(errlog)
  5906. c.ServeSuccessJSON(map[string]interface{}{
  5907. "failed_code": -10,
  5908. "msg": res.ErrMsg,
  5909. })
  5910. return
  5911. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5912. //return
  5913. }
  5914. }
  5915. }
  5916. } else if tempOrder.ID > 0 {
  5917. if tempOrder.IsPre == 1 {
  5918. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5919. var rf []*ResultFive
  5920. json.Unmarshal([]byte(his.Iinfo), &rf)
  5921. chrg_bchno := tempOrder.Number
  5922. cert_no := his.Certno
  5923. var insutypes []string
  5924. var insutype string
  5925. var is390 int = 0
  5926. var is310 int = 0
  5927. for _, item := range rf {
  5928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5929. insutypes = append(insutypes, item.Insutype)
  5930. }
  5931. }
  5932. if len(insutypes) == 1 {
  5933. insutype = insutypes[0]
  5934. } else {
  5935. for _, i := range insutypes {
  5936. if i == "390" {
  5937. is390 = 1
  5938. }
  5939. if i == "310" {
  5940. is310 = 1
  5941. }
  5942. }
  5943. }
  5944. if is390 == 1 {
  5945. insutype = "390"
  5946. }
  5947. if is310 == 1 {
  5948. insutype = "310"
  5949. }
  5950. if len(insutypes) == 0 {
  5951. insutype = "310"
  5952. }
  5953. if len(insutypes) == 2 {
  5954. insutype = strconv.FormatInt(his.SocialType, 64)
  5955. }
  5956. //insutype = "390"
  5957. if his.IdCardType == 1 {
  5958. // cert_no = his.MedicalInsuranceNumber
  5959. cert_no = his.Certno
  5960. } else {
  5961. cert_no = his.Certno
  5962. }
  5963. var res ResultSeven
  5964. var resSeven10265 ResultSeven10265
  5965. var src_resquest string
  5966. var result2 string
  5967. var acct_used_flag string
  5968. fmt.Println("pay_way")
  5969. fmt.Println(pay_way)
  5970. fmt.Println("pay_way")
  5971. if pay_way == 4 {
  5972. acct_used_flag = "1"
  5973. } else {
  5974. acct_used_flag = "0"
  5975. }
  5976. if miConfig.MdtrtareaAdmvs == "421300" {
  5977. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5978. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5979. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5980. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5981. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5982. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5983. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5984. resp, requestErr := http.Get(api)
  5985. if requestErr != nil {
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5987. return
  5988. }
  5989. body, ioErr := ioutil.ReadAll(resp.Body)
  5990. if ioErr != nil {
  5991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. var respJSON map[string]interface{}
  5996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5999. return
  6000. }
  6001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6002. result, _ := json.Marshal(respJSON)
  6003. fmt.Println("log")
  6004. fmt.Println(string(result))
  6005. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6006. utils.ErrorLog("解析失败:%v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6011. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6012. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6013. //psn_info, _ := service.GetPsnByPatientId(id)
  6014. bas := strings.Split(psn_info.CardInfo, "|")
  6015. if his.IdCardType == 1 {
  6016. cert_no = bas[2]
  6017. } else {
  6018. cert_no = bas[1]
  6019. }
  6020. //江苏地区国家医保医疗类别
  6021. //职工透析:医疗类别选特殊情况门诊9933
  6022. //居民血透门慢: 医疗类别选门诊慢病1402
  6023. //var med_type string
  6024. //if his.Insutype == "310" {
  6025. // if reg_type == 14 {
  6026. // med_type = "9933"
  6027. // } else if reg_type == 11 {
  6028. // med_type = "11"
  6029. //
  6030. // }
  6031. //} else if his.Insutype == "390" {
  6032. // if reg_type == 14 {
  6033. // med_type = "1402"
  6034. // } else if reg_type == 11 {
  6035. // med_type = "11"
  6036. // }
  6037. //}
  6038. var api string
  6039. if miConfig.MdtrtareaAdmvs == "320921" {
  6040. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6041. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6042. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6044. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6045. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6046. "&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
  6047. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6048. } else {
  6049. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6050. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6051. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6052. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6054. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6055. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6056. "&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
  6057. }
  6058. resp, requestErr := http.Get(api)
  6059. if requestErr != nil {
  6060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6061. return
  6062. }
  6063. body, ioErr := ioutil.ReadAll(resp.Body)
  6064. if ioErr != nil {
  6065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6067. return
  6068. }
  6069. var respJSON map[string]interface{}
  6070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6073. return
  6074. }
  6075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6076. result, _ := json.Marshal(respJSON)
  6077. fmt.Println("log")
  6078. fmt.Println(string(result))
  6079. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6080. utils.ErrorLog("解析失败:%v", err)
  6081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6082. return
  6083. }
  6084. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6085. res.Output = resSeven10265.Output
  6086. res.ErrMsg = resSeven10265.ErrMsg
  6087. res.Cainfo = resSeven10265.Cainfo
  6088. res.WarnMsg = resSeven10265.WarnMsg
  6089. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6090. res.Infcode = infocode
  6091. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6092. result2, src_resquest = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6093. var dat map[string]interface{}
  6094. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6095. fmt.Println(dat)
  6096. } else {
  6097. fmt.Println(err)
  6098. }
  6099. saveLog(result2, src_resquest, "2207", "结算")
  6100. userJSONBytes, _ := json.Marshal(dat)
  6101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6102. utils.ErrorLog("解析失败:%v", err)
  6103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. return
  6105. }
  6106. } else {
  6107. var src_resquest string
  6108. if miConfig.Code == "H15049901371" {
  6109. //赤峰地区国家医保医疗类别
  6110. //职工透析:医疗类别选特殊情况门诊990502
  6111. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6112. var med_type string
  6113. if his.Insutype == "390" {
  6114. if reg_type == 14 {
  6115. med_type = "9933"
  6116. } else if reg_type == 11 {
  6117. med_type = "11"
  6118. }
  6119. } else if his.Insutype == "310" {
  6120. if reg_type == 14 {
  6121. med_type = "990502"
  6122. } else if reg_type == 11 {
  6123. med_type = "11"
  6124. }
  6125. }
  6126. 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)
  6127. } else {
  6128. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  6129. }
  6130. var dat map[string]interface{}
  6131. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6132. fmt.Println(dat)
  6133. } else {
  6134. fmt.Println(err)
  6135. }
  6136. saveLog(result2, src_resquest, "2207", "结算")
  6137. userJSONBytes, _ := json.Marshal(dat)
  6138. if miConfig.Code == "H15049901371" {
  6139. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6140. utils.ErrorLog("解析失败:%v", err)
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6142. return
  6143. }
  6144. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6145. res.Output = resSeven10265.Output
  6146. res.ErrMsg = resSeven10265.ErrMsg
  6147. res.Cainfo = resSeven10265.Cainfo
  6148. res.WarnMsg = resSeven10265.WarnMsg
  6149. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6150. res.Infcode = infocode
  6151. } else {
  6152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6153. utils.ErrorLog("解析失败:%v", err)
  6154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6155. return
  6156. }
  6157. }
  6158. }
  6159. if res.Infcode != 0 {
  6160. errlog := &models.HisOrderError{
  6161. UserOrgId: adminUser.CurrentOrgId,
  6162. Ctime: time.Now().Unix(),
  6163. Mtime: time.Now().Unix(),
  6164. Number: chrg_bchno,
  6165. ErrMsg: res.ErrMsg,
  6166. Status: 1,
  6167. PatientId: id,
  6168. RecordTime: recordDateTime,
  6169. Stage: 6,
  6170. }
  6171. service.CreateErrMsgLog(errlog)
  6172. c.ServeSuccessJSON(map[string]interface{}{
  6173. "failed_code": -10,
  6174. "msg": res.ErrMsg,
  6175. })
  6176. return
  6177. } else {
  6178. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6179. order.OrderStatus = 2
  6180. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6181. order.SetlId = res.Output.Setlinfo.SetlID
  6182. order.PsnNo = res.Output.Setlinfo.PsnNo
  6183. order.PsnName = res.Output.Setlinfo.PsnName
  6184. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6185. order.Certno = res.Output.Setlinfo.Certno
  6186. order.Gend = res.Output.Setlinfo.Gend
  6187. order.Naty = res.Output.Setlinfo.Naty
  6188. order.Age = res.Output.Setlinfo.Age
  6189. order.Insutype = res.Output.Setlinfo.Insutype
  6190. order.PsnType = res.Output.Setlinfo.PsnType
  6191. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6192. order.SetlTime = res.Output.Setlinfo.SetlTime
  6193. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6194. //order.MedType = res.Output.Setlinfo.MedType
  6195. if reg_type == 1112 {
  6196. order.MedType = "1112"
  6197. }
  6198. if reg_type == 1111 {
  6199. order.MedType = "1111"
  6200. }
  6201. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6202. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6203. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6204. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6205. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6206. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6207. order.HifpPay = res.Output.Setlinfo.HifpPay
  6208. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6209. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6210. order.HifesPay = res.Output.Setlinfo.HifesPay
  6211. order.HifobPay = res.Output.Setlinfo.HifobPay
  6212. order.MafPay = res.Output.Setlinfo.MafPay
  6213. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6214. order.OthPay = res.Output.Setlinfo.OthPay
  6215. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6216. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6217. order.AcctPay = res.Output.Setlinfo.AcctPay
  6218. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6219. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6220. order.Balc = res.Output.Setlinfo.Balc
  6221. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6222. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6223. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6224. order.ClrWay = res.Output.Setlinfo.ClrWay
  6225. order.Creator = order.Creator
  6226. order.Modify = roles.AdminUserId
  6227. order.RequestLog = src_resquest
  6228. order.Diagnosis = diagnosis_id
  6229. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6230. detailStr := string(setlDetail)
  6231. order.SetlDetail = detailStr
  6232. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6233. err = service.UpDateOrder(order)
  6234. if err == nil {
  6235. //判断是否使用了押金
  6236. if dec_way == "true" {
  6237. tmpstring := strconv.FormatInt(order.ID, 10)
  6238. //扣押金
  6239. order.Decimal = decimal
  6240. service.UpDateOrder(order)
  6241. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6242. if errmsg != nil {
  6243. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6244. return
  6245. }
  6246. }
  6247. c.ServeSuccessJSON(map[string]interface{}{
  6248. "msg": "结算成功",
  6249. })
  6250. } else {
  6251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6252. return
  6253. }
  6254. }
  6255. }
  6256. }
  6257. }
  6258. //func (c *HisApiController) GetPreUploadInfo() {
  6259. // id, _ := c.GetInt64("id")
  6260. // record_time := c.GetString("record_time")
  6261. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6262. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6263. //
  6264. // timeLayout := "2006-01-02"
  6265. // loc, _ := time.LoadLocation("Local")
  6266. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6267. // if err != nil {
  6268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6269. // return
  6270. // }
  6271. // recordDateTime := theTime.Unix()
  6272. // adminUser := c.GetAdminUserInfo()
  6273. //
  6274. // var prescriptions []*models.HisPrescription
  6275. //
  6276. // var start_time int64
  6277. // var end_time int64
  6278. //
  6279. // data := make(map[string]interface{})
  6280. // if settle_accounts_type == 1 { //日结
  6281. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6282. // data["pre"] = prescriptions
  6283. //
  6284. // } else { //月结
  6285. // start_time_str := c.GetString("start_time")
  6286. // end_time_str := c.GetString("end_time")
  6287. // timeLayout := "2006-01-02"
  6288. // loc, _ := time.LoadLocation("Local")
  6289. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6290. // if err != nil {
  6291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6292. // return
  6293. // }
  6294. // recordStartTime := theStartTime.Unix()
  6295. // start_time = recordStartTime
  6296. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6297. // if err != nil {
  6298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6299. // return
  6300. // }
  6301. // recordEndTime := theEndTime.Unix()
  6302. // end_time = recordEndTime
  6303. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6304. // data["pre"] = prescriptions
  6305. //
  6306. // }
  6307. //
  6308. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6309. //
  6310. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6311. // timestamp := time.Now().Unix()
  6312. // tempTime := time.Unix(timestamp, 0)
  6313. // timeFormat := tempTime.Format("20060102150405")
  6314. // chrgBchno := rand.Intn(100000) + 10000
  6315. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6316. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6317. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6318. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6319. // strconv.FormatInt(his.PatientId, 10)
  6320. // client := &http.Client{}
  6321. // data["psn_no"] = his.PsnNo
  6322. // data["mdtrt_id"] = his.Number
  6323. // data["chrg_bchno"] = chrg_bchno
  6324. // data["org_name"] = miConfig.OrgName
  6325. // data["doctor"] = roles.UserName
  6326. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6327. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6328. // data["fixmedins_code"] = miConfig.Code
  6329. // data["dept_code"] = department.Number
  6330. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6331. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6332. // data["secret_key"] = miConfig.SecretKey
  6333. // var ids []int64
  6334. //
  6335. // for _, item := range prescriptions {
  6336. // ids = append(ids, item.ID)
  6337. // }
  6338. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6339. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6340. // bytesData, _ := json.Marshal(data)
  6341. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6342. // resp, _ := client.Do(req)
  6343. // defer resp.Body.Close()
  6344. // body, ioErr := ioutil.ReadAll(resp.Body)
  6345. // if ioErr != nil {
  6346. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6348. // return
  6349. // }
  6350. // var respJSON map[string]interface{}
  6351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6354. // return
  6355. // }
  6356. //
  6357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6358. // userJSONBytes, _ := json.Marshal(respJSON)
  6359. // var res ResultFour
  6360. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6361. // utils.ErrorLog("解析失败:%v", err)
  6362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. // return
  6364. // }
  6365. //
  6366. // if res.Infcode == 0 {
  6367. // order := &models.HisOrder{
  6368. // UserOrgId: adminUser.CurrentOrgId,
  6369. // HisPatientId: his.ID,
  6370. // PatientId: his.PatientId,
  6371. // SettleAccountsDate: recordDateTime,
  6372. // Ctime: time.Now().Unix(),
  6373. // Mtime: time.Now().Unix(),
  6374. // Status: 1,
  6375. // Number: chrg_bchno,
  6376. // Infcode: res.Infcode,
  6377. // WarnMsg: res.WarnMsg,
  6378. // Cainfo: res.Cainfo,
  6379. // ErrMsg: res.ErrMsg,
  6380. // RespondTime: res.RefmsgTime,
  6381. // InfRefmsgid: res.InfRefmsgid,
  6382. // OrderStatus: 1,
  6383. // IsMedicineInsurance: 1,
  6384. // SettleType: settle_accounts_type,
  6385. // SettleStartTime: start_time,
  6386. // SettleEndTime: end_time,
  6387. // Creator: roles.ID,
  6388. // Modify: roles.ID,
  6389. // PType: 2,
  6390. // }
  6391. // err = service.CreateOrder(order)
  6392. // if err != nil {
  6393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6394. // return
  6395. // }
  6396. //
  6397. // for _, item := range res.Output.Result {
  6398. // temp := strings.Split(item.FeedetlSn, "-")
  6399. // var advice_id int64 = 0
  6400. // var project_id int64 = 0
  6401. // var types int64 = 0
  6402. //
  6403. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6404. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6405. //
  6406. // if temp[1] == "1" {
  6407. // advice_id = id
  6408. // project_id = 0
  6409. // } else if temp[1] == "2" {
  6410. // advice_id = 0
  6411. // project_id = id
  6412. // }
  6413. //
  6414. // info := &models.HisOrderInfo{
  6415. // OrderNumber: order.Number,
  6416. // FeedetlSn: item.FeedetlSn,
  6417. // UploadDate: time.Now().Unix(),
  6418. // AdviceId: advice_id,
  6419. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6420. // Cnt: item.Cnt,
  6421. // Pric: float64(item.Pric),
  6422. // PatientId: his.PatientId,
  6423. // PricUplmtAmt: item.PricUplmtAmt,
  6424. // SelfpayProp: item.SelfpayProp,
  6425. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6426. // OverlmtAmt: item.OverlmtAmt,
  6427. // PreselfpayAmt: item.PreselfpayAmt,
  6428. // BasMednFlag: item.BasMednFlag,
  6429. // MedChrgitmType: item.MedChrgitmType,
  6430. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6431. // Status: 1,
  6432. // Memo: item.Memo,
  6433. // Mtime: time.Now().Unix(),
  6434. // InscpScpAmt: item.InscpScpAmt,
  6435. // DrtReimFlag: item.DrtReimFlag,
  6436. // Ctime: time.Now().Unix(),
  6437. // ListSpItemFlag: item.ListSpItemFlag,
  6438. // ChldMedcFlag: item.ChldMedcFlag,
  6439. // LmtUsedFlag: item.LmtUsedFlag,
  6440. // ChrgitmLv: item.ChrgitmLv,
  6441. // UserOrgId: adminUser.CurrentOrgId,
  6442. // HisPatientId: his.ID,
  6443. // OrderId: order.ID,
  6444. // ProjectId: project_id,
  6445. // Type: types,
  6446. // }
  6447. // service.CreateOrderInfo(info)
  6448. //
  6449. // }
  6450. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6451. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6452. //
  6453. // var total float64
  6454. // for _, item := range prescriptions {
  6455. // if item.Type == 1 { //药品
  6456. // for _, subItem := range item.HisDoctorAdviceInfo {
  6457. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6458. // }
  6459. // }
  6460. // if item.Type == 2 { //项目
  6461. // for _, subItem := range item.HisPrescriptionProject {
  6462. // total = total + (subItem.Price * float64(subItem.Count))
  6463. // }
  6464. // }
  6465. // }
  6466. //
  6467. // for _, item := range prescriptions {
  6468. // for _, subItem := range item.HisAdditionalCharge {
  6469. // total = total + (subItem.Price * float64(subItem.Count))
  6470. // }
  6471. // }
  6472. //
  6473. // allTotal := fmt.Sprintf("%.2f", total)
  6474. // if res.Infcode == 0 {
  6475. // var rf []*ResultFive
  6476. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6477. // psn_no := his.PsnNo
  6478. // mdtrt_id := his.Number
  6479. // chrg_bchno := chrg_bchno
  6480. // cert_no := his.Certno
  6481. // insutype := rf[0].Insutype
  6482. //
  6483. // if his.IdCardType == 1 {
  6484. // cert_no = his.MedicalInsuranceNumber
  6485. //
  6486. // } else {
  6487. //
  6488. // cert_no = his.Certno
  6489. //
  6490. // }
  6491. //
  6492. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6493. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6494. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6495. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6496. // resp, requestErr := http.Get(api)
  6497. // if requestErr != nil {
  6498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6499. // return
  6500. // }
  6501. // defer resp.Body.Close()
  6502. // body, ioErr := ioutil.ReadAll(resp.Body)
  6503. // if ioErr != nil {
  6504. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6506. // return
  6507. // }
  6508. // var respJSON map[string]interface{}
  6509. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6510. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6512. // return
  6513. // }
  6514. // fmt.Println(respJSON)
  6515. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6516. // userJSONBytes, _ := json.Marshal(respJSON)
  6517. // var res ResultSeven
  6518. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6519. // utils.ErrorLog("解析失败:%v", err)
  6520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6521. // return
  6522. // }
  6523. // if res.Infcode != 0 {
  6524. // errlog := &models.HisOrderError{
  6525. // UserOrgId: adminUser.CurrentOrgId,
  6526. // Ctime: time.Now().Unix(),
  6527. // Mtime: time.Now().Unix(),
  6528. // Number: chrg_bchno,
  6529. // ErrMsg: res.ErrMsg,
  6530. // Status: 1,
  6531. // PatientId: id,
  6532. // RecordTime: recordDateTime,
  6533. // Stage: 7,
  6534. // }
  6535. // service.CreateErrMsgLog(errlog)
  6536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6537. // return
  6538. // } else {
  6539. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6540. // order.OrderStatus = 1
  6541. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6542. // order.SetlId = res.Output.Setlinfo.SetlID
  6543. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6544. // order.PsnName = res.Output.Setlinfo.PsnName
  6545. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6546. // order.Certno = res.Output.Setlinfo.Certno
  6547. // order.Gend = res.Output.Setlinfo.Gend
  6548. // order.Naty = res.Output.Setlinfo.Naty
  6549. // order.Age = res.Output.Setlinfo.Age
  6550. // order.Insutype = res.Output.Setlinfo.Insutype
  6551. // order.PsnType = res.Output.Setlinfo.PsnType
  6552. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6553. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6554. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6555. // order.MedType = res.Output.Setlinfo.MedType
  6556. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6557. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6558. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6559. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6560. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6561. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6562. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6563. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6564. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6565. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6566. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6567. // order.MafPay = res.Output.Setlinfo.MafPay
  6568. // order.OthPay = res.Output.Setlinfo.OthPay
  6569. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6570. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6571. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6572. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6573. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6574. // order.Balc = res.Output.Setlinfo.Balc
  6575. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6576. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6577. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6578. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6579. // order.Creator = order.Creator
  6580. // order.Modify = roles.ID
  6581. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6582. // detailStr := string(setlDetail)
  6583. // order.SetlDetail = detailStr
  6584. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6585. // err = service.UpDateOrder(order)
  6586. // if err == nil {
  6587. // c.ServeSuccessJSON(map[string]interface{}{
  6588. // "msg": "预结算成功",
  6589. // })
  6590. // } else {
  6591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6592. // return
  6593. // }
  6594. // }
  6595. // } else {
  6596. // adminUser := c.GetAdminUserInfo()
  6597. // errlog := &models.HisOrderError{
  6598. // UserOrgId: adminUser.CurrentOrgId,
  6599. // Ctime: time.Now().Unix(),
  6600. // Mtime: time.Now().Unix(),
  6601. // ErrMsg: res.ErrMsg,
  6602. // Status: 1,
  6603. // PatientId: id,
  6604. // RecordTime: recordDateTime,
  6605. // Stage: 4,
  6606. // }
  6607. // service.CreateErrMsgLog(errlog)
  6608. //
  6609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6610. // return
  6611. // }
  6612. // } else {
  6613. // adminUser := c.GetAdminUserInfo()
  6614. // errlog := &models.HisOrderError{
  6615. // UserOrgId: adminUser.CurrentOrgId,
  6616. // Ctime: time.Now().Unix(),
  6617. // Mtime: time.Now().Unix(),
  6618. // ErrMsg: res.ErrMsg,
  6619. // Status: 1,
  6620. // PatientId: id,
  6621. // RecordTime: recordDateTime,
  6622. // Stage: 4,
  6623. // }
  6624. // service.CreateErrMsgLog(errlog)
  6625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6626. // return
  6627. // }
  6628. //
  6629. // } else {
  6630. // var total float64
  6631. // for _, item := range prescriptions {
  6632. // if item.Type == 1 { //药品
  6633. // for _, subItem := range item.HisDoctorAdviceInfo {
  6634. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6635. // }
  6636. // }
  6637. // if item.Type == 2 { //项目
  6638. // for _, subItem := range item.HisPrescriptionProject {
  6639. // total = total + (subItem.Price * float64(subItem.Count))
  6640. // }
  6641. // }
  6642. //
  6643. // for _, subItem := range item.HisAdditionalCharge {
  6644. // total = total + (subItem.Price * float64(subItem.Count))
  6645. // }
  6646. // }
  6647. //
  6648. // allTotal := fmt.Sprintf("%.2f", total)
  6649. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6650. // order := &models.HisOrder{
  6651. // UserOrgId: adminUser.CurrentOrgId,
  6652. // HisPatientId: his.ID,
  6653. // PatientId: id,
  6654. // SettleAccountsDate: recordDateTime,
  6655. // Ctime: time.Now().Unix(),
  6656. // Mtime: time.Now().Unix(),
  6657. // Status: 1,
  6658. // OrderStatus: 2,
  6659. // Number: chrg_bchno,
  6660. // MedfeeSumamt: totals,
  6661. // }
  6662. // err = service.CreateOrder(order)
  6663. // if err != nil {
  6664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6665. // return
  6666. // }
  6667. //
  6668. // var customs []*Custom
  6669. // for _, item := range prescriptions {
  6670. //
  6671. // if item.Type == 1 { //药品
  6672. // for _, subItem := range item.HisDoctorAdviceInfo {
  6673. // cus := &Custom{
  6674. // AdviceId: subItem.ID,
  6675. // ProjectId: 0,
  6676. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6677. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6678. // FeedetlSn: subItem.FeedetlSn,
  6679. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6680. // MedListCodg: subItem.MedListCodg,
  6681. // Type: 1,
  6682. // }
  6683. // customs = append(customs, cus)
  6684. // }
  6685. // }
  6686. //
  6687. // if item.Type == 2 { //项目
  6688. // for _, subItem := range item.HisPrescriptionProject {
  6689. //
  6690. // cus := &Custom{
  6691. // AdviceId: 0,
  6692. // ProjectId: subItem.ID,
  6693. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6694. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6695. // FeedetlSn: subItem.FeedetlSn,
  6696. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6697. // MedListCodg: subItem.MedListCodg,
  6698. // Type: 2,
  6699. // }
  6700. //
  6701. // customs = append(customs, cus)
  6702. // }
  6703. // }
  6704. //
  6705. // for _, item := range item.HisAdditionalCharge {
  6706. // cus := &Custom{
  6707. // ItemId: item.ID,
  6708. // AdviceId: 0,
  6709. // ProjectId: 0,
  6710. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6711. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6712. // FeedetlSn: item.FeedetlSn,
  6713. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6714. // MedListCodg: item.XtHisAddtionConfig.Code,
  6715. // Type: 3,
  6716. // }
  6717. //
  6718. // customs = append(customs, cus)
  6719. // }
  6720. //
  6721. // }
  6722. //
  6723. // for _, item := range customs {
  6724. // var advice_id int64 = 0
  6725. // var project_id int64 = 0
  6726. // var item_id int64 = 0
  6727. //
  6728. // var types int64 = 0
  6729. //
  6730. // if item.Type == 1 {
  6731. // advice_id = item.AdviceId
  6732. // project_id = 0
  6733. // item_id = 0
  6734. // } else if item.Type == 2 {
  6735. // advice_id = 0
  6736. // item_id = 0
  6737. //
  6738. // project_id = item.ProjectId
  6739. // } else if item.Type == 3 {
  6740. // advice_id = 0
  6741. // item_id = item.ItemId
  6742. // project_id = 0
  6743. // }
  6744. //
  6745. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6746. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6747. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6748. //
  6749. // info := &models.HisOrderInfo{
  6750. // OrderNumber: order.Number,
  6751. // UploadDate: time.Now().Unix(),
  6752. // AdviceId: advice_id,
  6753. // DetItemFeeSumamt: detItemFeeSumamt,
  6754. // Cnt: cut,
  6755. // Pric: pric,
  6756. // PatientId: id,
  6757. // Status: 1,
  6758. // Mtime: time.Now().Unix(),
  6759. // Ctime: time.Now().Unix(),
  6760. // UserOrgId: adminUser.CurrentOrgId,
  6761. // HisPatientId: his.ID,
  6762. // OrderId: order.ID,
  6763. // ProjectId: project_id,
  6764. // Type: types,
  6765. // ItemId: item_id,
  6766. // }
  6767. // service.CreateOrderInfo(info)
  6768. // }
  6769. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6770. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6771. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6772. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6773. // if err == nil {
  6774. // c.ServeSuccessJSON(map[string]interface{}{
  6775. // "msg": "结算成功",
  6776. // })
  6777. // } else {
  6778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6779. // return
  6780. // }
  6781. // }
  6782. //}
  6783. //上传明细-预结算-
  6784. func (c *HisApiController) GetPreUploadInfo() {
  6785. id, _ := c.GetInt64("id")
  6786. record_time := c.GetString("record_time")
  6787. his_patient_id, _ := c.GetInt64("his_patient_id")
  6788. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6789. admin_user_id, _ := c.GetInt64("admin_user_id")
  6790. diagnosis_id := c.GetString("diagnosis")
  6791. sick_type, _ := c.GetInt64("sick_type")
  6792. reg_type, _ := c.GetInt64("p_type")
  6793. begin_time := c.GetString("begin_time")
  6794. id_str := c.GetString("ids")
  6795. ids_arr := strings.Split(id_str, ",")
  6796. timeLayout := "2006-01-02"
  6797. loc, _ := time.LoadLocation("Local")
  6798. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6799. if err != nil {
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6801. return
  6802. }
  6803. recordDateTime := theTime.Unix()
  6804. adminUser := c.GetAdminUserInfo()
  6805. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6806. var config []*models.HisXtDiagnoseConfig
  6807. for _, item := range diagnosis_ids {
  6808. id, _ := strconv.ParseInt(item, 10, 64)
  6809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6810. config = append(config, &diagnosisConfig)
  6811. }
  6812. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6813. sickConfig, _ := service.FindSickById(sick_type)
  6814. var prescriptions []*models.HisPrescription
  6815. var start_time int64
  6816. var end_time int64
  6817. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6818. fmt.Println(his_patient_id)
  6819. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6820. timestamp := time.Now().Unix()
  6821. tempTime := time.Unix(timestamp, 0)
  6822. timeFormat := tempTime.Format("20060102150405")
  6823. chrgBchno := rand.Intn(100000) + 10000
  6824. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6825. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6826. var patientPrescription models.HisPrescriptionInfo
  6827. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6828. if patientPrescription.ID == 0 {
  6829. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6830. }
  6831. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6832. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6833. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6834. strconv.FormatInt(his.PatientId, 10)
  6835. var res2 ResultSix
  6836. var resSix10265 ResultSix10265
  6837. var time_stamp string
  6838. if miConfig.MdtrtareaAdmvs == "421300" {
  6839. data := make(map[string]interface{})
  6840. client := &http.Client{}
  6841. data["psn_no"] = his.PsnNo
  6842. data["mdtrt_id"] = his.Number
  6843. data["department"] = department.Name
  6844. data["org_name"] = miConfig.OrgName
  6845. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6846. data["doctor_id"] = doctor_info.DoctorNumber
  6847. data["doctor_name"] = roles.UserName
  6848. data["fixmedins_code"] = miConfig.Code
  6849. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6850. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6851. data["secret_key"] = miConfig.SecretKey
  6852. data["sick_code"] = sickConfig.CountryCode
  6853. data["sick_name"] = sickConfig.ClassName
  6854. data["begin_time"] = begin_time
  6855. data["dept"] = strconv.FormatInt(department.ID, 10)
  6856. data["config"] = config
  6857. data["opter"] = roles.UserName
  6858. fmt.Println(data)
  6859. bytesData, _ := json.Marshal(data)
  6860. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6861. resp, _ := client.Do(req)
  6862. defer resp.Body.Close()
  6863. body, ioErr := ioutil.ReadAll(resp.Body)
  6864. if ioErr != nil {
  6865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6867. return
  6868. }
  6869. var respJSON map[string]interface{}
  6870. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6873. return
  6874. }
  6875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6876. userJSONBytes, _ := json.Marshal(respJSON)
  6877. fmt.Println("log")
  6878. fmt.Println(string(userJSONBytes))
  6879. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6880. utils.ErrorLog("解析失败:%v", err)
  6881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. return
  6883. }
  6884. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6885. data := make(map[string]interface{})
  6886. client := &http.Client{}
  6887. data["psn_no"] = his.PsnNo
  6888. data["mdtrt_id"] = his.Number
  6889. data["doctor"] = roles.UserName
  6890. data["department"] = department.Name
  6891. data["org_name"] = miConfig.OrgName
  6892. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6893. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6894. data["fixmedins_code"] = miConfig.Code
  6895. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6896. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6897. data["secret_key"] = miConfig.SecretKey
  6898. data["sick_code"] = sickConfig.CountryCode
  6899. data["sick_name"] = sickConfig.ClassName
  6900. data["begin_time"] = begin_time
  6901. data["dept"] = strconv.FormatInt(department.ID, 10)
  6902. data["config"] = config
  6903. data["url"] = miConfig.Url
  6904. data["ak"] = miConfig.AccessKey
  6905. data["cainfo"] = miConfig.Cainfo
  6906. bytesData, _ := json.Marshal(data)
  6907. var req *http.Request
  6908. if miConfig.MdtrtareaAdmvs == "320921" {
  6909. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6910. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6911. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6912. } else {
  6913. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6914. }
  6915. resp, _ := client.Do(req)
  6916. defer resp.Body.Close()
  6917. body, ioErr := ioutil.ReadAll(resp.Body)
  6918. if ioErr != nil {
  6919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6921. return
  6922. }
  6923. var respJSON map[string]interface{}
  6924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6927. return
  6928. }
  6929. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6930. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6931. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6933. userJSONBytes, _ := json.Marshal(respJSON)
  6934. fmt.Println("log")
  6935. fmt.Println(string(userJSONBytes))
  6936. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6937. utils.ErrorLog("解析失败:%v", err)
  6938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. return
  6940. }
  6941. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6942. res2.Output = resSix10265.Output
  6943. res2.ErrMsg = resSix10265.ErrMsg
  6944. res2.Cainfo = resSix10265.Cainfo
  6945. res2.WarnMsg = resSix10265.WarnMsg
  6946. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6947. res2.Infcode = infocode
  6948. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6949. result, requestLog := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6950. saveLog(result, requestLog, "2203", "上传就诊信息")
  6951. var respJSON2 map[string]interface{}
  6952. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. userJSONBytes2, _ := json.Marshal(respJSON2)
  6958. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6959. utils.ErrorLog("解析失败:%v", err)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. return
  6962. }
  6963. } else {
  6964. var result string
  6965. var requestLog string
  6966. if miConfig.MdtrtareaAdmvs == "440781" { //
  6967. 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)
  6968. } else {
  6969. if miConfig.Code == "H15049901371" {
  6970. //赤峰地区国家医保医疗类别
  6971. //职工透析:医疗类别选特殊情况门诊990502
  6972. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6973. var med_type string
  6974. if his.Insutype == "390" {
  6975. if reg_type == 14 {
  6976. med_type = "9933"
  6977. } else if reg_type == 11 {
  6978. med_type = "11"
  6979. }
  6980. } else if his.Insutype == "310" {
  6981. if reg_type == 14 {
  6982. med_type = "990502"
  6983. } else if reg_type == 11 {
  6984. med_type = "11"
  6985. }
  6986. }
  6987. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  6988. } else {
  6989. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  6990. }
  6991. saveLog(result, requestLog, "2203", "上传就诊信息")
  6992. var respJSON2 map[string]interface{}
  6993. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6996. return
  6997. }
  6998. userJSONBytes2, _ := json.Marshal(respJSON2)
  6999. if miConfig.Code == "H15049901371" {
  7000. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7001. utils.ErrorLog("解析失败:%v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. return
  7004. }
  7005. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7006. res2.Output = resSix10265.Output
  7007. res2.ErrMsg = resSix10265.ErrMsg
  7008. res2.Cainfo = resSix10265.Cainfo
  7009. res2.WarnMsg = resSix10265.WarnMsg
  7010. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7011. res2.Infcode = infocode
  7012. } else {
  7013. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7014. utils.ErrorLog("解析失败:%v", err)
  7015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7016. return
  7017. }
  7018. }
  7019. }
  7020. }
  7021. if res2.Infcode != 0 {
  7022. adminUser := c.GetAdminUserInfo()
  7023. errlog := &models.HisOrderError{
  7024. UserOrgId: adminUser.CurrentOrgId,
  7025. Ctime: time.Now().Unix(),
  7026. Mtime: time.Now().Unix(),
  7027. ErrMsg: res2.ErrMsg,
  7028. Status: 1,
  7029. PatientId: id,
  7030. RecordTime: recordDateTime,
  7031. Stage: 3,
  7032. }
  7033. service.CreateErrMsgLog(errlog)
  7034. c.ServeSuccessJSON(map[string]interface{}{
  7035. "failed_code": -10,
  7036. "msg": res2.ErrMsg,
  7037. })
  7038. return
  7039. } else {
  7040. his.Diagnosis = diagnosis_id
  7041. his.SickType = sickConfig.ID
  7042. his.PType = fmt.Sprintf("%d", reg_type)
  7043. service.UpdateHisPatientThree(&his)
  7044. data := make(map[string]interface{})
  7045. if settle_accounts_type == 1 { //日结
  7046. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7047. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7048. } else {
  7049. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7050. }
  7051. data["pre"] = prescriptions
  7052. } else { //月结
  7053. start_time_str := c.GetString("start_time")
  7054. end_time_str := c.GetString("end_time")
  7055. timeLayout := "2006-01-02"
  7056. loc, _ := time.LoadLocation("Local")
  7057. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7058. if err != nil {
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7060. return
  7061. }
  7062. recordStartTime := theStartTime.Unix()
  7063. start_time = recordStartTime
  7064. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7065. if err != nil {
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7067. return
  7068. }
  7069. recordEndTime := theEndTime.Unix()
  7070. end_time = recordEndTime
  7071. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7072. data["pre"] = prescriptions
  7073. }
  7074. client := &http.Client{}
  7075. data["psn_no"] = his.PsnNo
  7076. data["mdtrt_id"] = his.Number
  7077. data["chrg_bchno"] = chrg_bchno
  7078. data["org_name"] = miConfig.OrgName
  7079. data["doctor"] = roles.UserName
  7080. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7081. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7082. data["fixmedins_code"] = miConfig.Code
  7083. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7084. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7085. data["dept_code"] = "15"
  7086. } else {
  7087. data["dept_code"] = department.Number
  7088. }
  7089. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7090. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7091. data["secret_key"] = miConfig.SecretKey
  7092. data["url"] = miConfig.Url
  7093. data["ak"] = miConfig.AccessKey
  7094. data["new_doctor_name"] = patientPrescription.Doctor
  7095. data["diag_code"] = sickConfig.CountryCode
  7096. data["time_stamp"] = time_stamp
  7097. data["cainfo"] = miConfig.Cainfo
  7098. var ids []int64
  7099. for _, item := range prescriptions {
  7100. ids = append(ids, item.ID)
  7101. }
  7102. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7103. if config.IsOpen == 1 { //对接了医保,走医保流程
  7104. var res ResultFour
  7105. var resFour10265 ResultFour10265
  7106. if miConfig.MdtrtareaAdmvs == "421300" {
  7107. bytesData, _ := json.Marshal(data)
  7108. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7109. resp, _ := client.Do(req)
  7110. defer resp.Body.Close()
  7111. body, ioErr := ioutil.ReadAll(resp.Body)
  7112. if ioErr != nil {
  7113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7115. return
  7116. }
  7117. var respJSON map[string]interface{}
  7118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7121. return
  7122. }
  7123. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7124. userJSONBytes, _ := json.Marshal(respJSON)
  7125. fmt.Println("log")
  7126. fmt.Println(string(userJSONBytes))
  7127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7128. utils.ErrorLog("解析失败:%v", err)
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7133. bytesData, _ := json.Marshal(data)
  7134. var req *http.Request
  7135. if miConfig.MdtrtareaAdmvs == "320921" {
  7136. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7137. } else {
  7138. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7139. }
  7140. resp, _ := client.Do(req)
  7141. defer resp.Body.Close()
  7142. body, ioErr := ioutil.ReadAll(resp.Body)
  7143. if ioErr != nil {
  7144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7146. return
  7147. }
  7148. var respJSON map[string]interface{}
  7149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7155. userJSONBytes, _ := json.Marshal(respJSON)
  7156. fmt.Println("log")
  7157. fmt.Println(string(userJSONBytes))
  7158. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7159. utils.ErrorLog("解析失败:%v", err)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. res.InfRefmsgid = resFour10265.InfRefmsgid
  7164. res.Output = resFour10265.Output
  7165. res.ErrMsg = resFour10265.ErrMsg
  7166. res.Cainfo = resFour10265.Cainfo
  7167. res.WarnMsg = resFour10265.WarnMsg
  7168. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7169. res.Infcode = infocode
  7170. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7171. result, request_log := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7172. var dat map[string]interface{}
  7173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7174. fmt.Println(dat)
  7175. } else {
  7176. fmt.Println(err)
  7177. }
  7178. saveLog(result, request_log, "2204", "上传费用明细")
  7179. userJSONBytes, _ := json.Marshal(dat)
  7180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7181. utils.ErrorLog("解析失败:%v", err)
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. return
  7184. }
  7185. } else {
  7186. if miConfig.Code == "H15049901371" {
  7187. 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)
  7188. var dat map[string]interface{}
  7189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7190. fmt.Println(dat)
  7191. } else {
  7192. fmt.Println(err)
  7193. }
  7194. saveLog(result, request_log, "2204", "上传费用明细")
  7195. userJSONBytes, _ := json.Marshal(dat)
  7196. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7197. utils.ErrorLog("解析失败:%v", err)
  7198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7199. return
  7200. }
  7201. res.InfRefmsgid = resFour10265.InfRefmsgid
  7202. res.Output = resFour10265.Output
  7203. res.ErrMsg = resFour10265.ErrMsg
  7204. res.Cainfo = resFour10265.Cainfo
  7205. res.WarnMsg = resFour10265.WarnMsg
  7206. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7207. res.Infcode = infocode
  7208. } else {
  7209. 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)
  7210. var dat map[string]interface{}
  7211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7212. fmt.Println(dat)
  7213. } else {
  7214. fmt.Println(err)
  7215. }
  7216. saveLog(result, request_log, "2204", "上传费用明细")
  7217. userJSONBytes, _ := json.Marshal(dat)
  7218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7219. utils.ErrorLog("解析失败:%v", err)
  7220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7221. return
  7222. }
  7223. }
  7224. }
  7225. if res.Infcode == 0 {
  7226. order := &models.HisOrder{
  7227. UserOrgId: adminUser.CurrentOrgId,
  7228. HisPatientId: his.ID,
  7229. PatientId: his.PatientId,
  7230. SettleAccountsDate: recordDateTime,
  7231. Ctime: time.Now().Unix(),
  7232. Mtime: time.Now().Unix(),
  7233. MdtrtId: his.Number,
  7234. PsnNo: his.PsnNo,
  7235. MedType: strconv.FormatInt(reg_type, 10),
  7236. Status: 1,
  7237. Number: chrg_bchno,
  7238. Infcode: res.Infcode,
  7239. WarnMsg: res.WarnMsg,
  7240. Cainfo: res.Cainfo,
  7241. ErrMsg: res.ErrMsg,
  7242. RespondTime: res.RefmsgTime,
  7243. InfRefmsgid: res.InfRefmsgid,
  7244. OrderStatus: 1,
  7245. IsMedicineInsurance: 1,
  7246. SettleType: settle_accounts_type,
  7247. SettleStartTime: start_time,
  7248. SettleEndTime: end_time,
  7249. Creator: roles.AdminUserId,
  7250. Modify: roles.AdminUserId,
  7251. PType: 2,
  7252. Diagnosis: diagnosis_id,
  7253. }
  7254. err = service.CreateOrder(order)
  7255. if err != nil {
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7257. return
  7258. }
  7259. for _, item := range res.Output.Result {
  7260. temp := strings.Split(item.FeedetlSn, "-")
  7261. var advice_id int64 = 0
  7262. var project_id int64 = 0
  7263. var types int64 = 0
  7264. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7265. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7266. if temp[1] == "1" {
  7267. advice_id = id
  7268. project_id = 0
  7269. } else if temp[1] == "2" {
  7270. advice_id = 0
  7271. project_id = id
  7272. }
  7273. info := &models.HisOrderInfo{
  7274. OrderNumber: order.Number,
  7275. FeedetlSn: item.FeedetlSn,
  7276. UploadDate: time.Now().Unix(),
  7277. AdviceId: advice_id,
  7278. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7279. Cnt: item.Cnt,
  7280. Pric: float64(item.Pric),
  7281. PatientId: his.PatientId,
  7282. PricUplmtAmt: item.PricUplmtAmt,
  7283. SelfpayProp: item.SelfpayProp,
  7284. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7285. OverlmtAmt: item.OverlmtAmt,
  7286. PreselfpayAmt: item.PreselfpayAmt,
  7287. BasMednFlag: item.BasMednFlag,
  7288. MedChrgitmType: item.MedChrgitmType,
  7289. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7290. Status: 1,
  7291. Memo: item.Memo,
  7292. Mtime: time.Now().Unix(),
  7293. InscpScpAmt: item.InscpScpAmt,
  7294. DrtReimFlag: item.DrtReimFlag,
  7295. Ctime: time.Now().Unix(),
  7296. ListSpItemFlag: item.ListSpItemFlag,
  7297. ChldMedcFlag: item.ChldMedcFlag,
  7298. LmtUsedFlag: item.LmtUsedFlag,
  7299. ChrgitmLv: item.ChrgitmLv,
  7300. UserOrgId: adminUser.CurrentOrgId,
  7301. HisPatientId: his.ID,
  7302. OrderId: order.ID,
  7303. ProjectId: project_id,
  7304. Type: types,
  7305. }
  7306. service.CreateOrderInfo(info)
  7307. }
  7308. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7309. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7310. var total float64
  7311. for _, item := range prescriptions {
  7312. if item.Type == 1 { //药品
  7313. for _, subItem := range item.HisDoctorAdviceInfo {
  7314. total = total + (subItem.Price * subItem.PrescribingNumber)
  7315. }
  7316. }
  7317. if item.Type == 2 { //项目
  7318. for _, subItem := range item.HisPrescriptionProject {
  7319. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7320. total = total + (subItem.Price * cnt)
  7321. }
  7322. }
  7323. }
  7324. for _, item := range prescriptions {
  7325. for _, subItem := range item.HisAdditionalCharge {
  7326. total = total + (subItem.Price * float64(subItem.Count))
  7327. }
  7328. }
  7329. allTotal := fmt.Sprintf("%.4f", total)
  7330. if res.Infcode == 0 {
  7331. var rf []*ResultFive
  7332. json.Unmarshal([]byte(his.Iinfo), &rf)
  7333. chrg_bchno := chrg_bchno
  7334. cert_no := his.Certno
  7335. var insutypes []string
  7336. var insutype string
  7337. var is390 int = 0
  7338. var is310 int = 0
  7339. for _, item := range rf {
  7340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7341. insutypes = append(insutypes, item.Insutype)
  7342. }
  7343. }
  7344. if len(insutypes) == 1 {
  7345. insutype = insutypes[0]
  7346. } else {
  7347. for _, i := range insutypes {
  7348. if i == "390" {
  7349. is390 = 1
  7350. }
  7351. if i == "310" {
  7352. is310 = 1
  7353. }
  7354. }
  7355. }
  7356. if is390 == 1 {
  7357. insutype = "390"
  7358. }
  7359. if is310 == 1 {
  7360. insutype = "310"
  7361. }
  7362. if len(insutypes) == 0 {
  7363. insutype = "310"
  7364. }
  7365. if len(insutypes) == 2 {
  7366. insutype = strconv.FormatInt(his.SocialType, 64)
  7367. }
  7368. //insutype = "390"
  7369. if his.IdCardType == 1 {
  7370. cert_no = his.MedicalInsuranceNumber
  7371. } else {
  7372. cert_no = his.Certno
  7373. }
  7374. var res ResultSeven
  7375. var resSeven10265 ResultSeven10265
  7376. if miConfig.MdtrtareaAdmvs == "421300" {
  7377. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7378. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7379. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7380. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7381. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7382. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7383. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7384. resp, requestErr := http.Get(api)
  7385. if requestErr != nil {
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7387. return
  7388. }
  7389. body, ioErr := ioutil.ReadAll(resp.Body)
  7390. if ioErr != nil {
  7391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. return
  7394. }
  7395. var respJSON map[string]interface{}
  7396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7399. return
  7400. }
  7401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7402. result, _ := json.Marshal(respJSON)
  7403. fmt.Println("log")
  7404. fmt.Println(string(result))
  7405. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7406. utils.ErrorLog("解析失败:%v", err)
  7407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7408. return
  7409. }
  7410. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7411. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7412. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7413. bas := strings.Split(psn_info.CardInfo, "|")
  7414. if his.IdCardType == 1 {
  7415. cert_no = bas[2]
  7416. } else {
  7417. cert_no = bas[1]
  7418. }
  7419. //江苏地区国家医保医疗类别
  7420. //职工透析:医疗类别选特殊情况门诊9933
  7421. //居民血透门慢: 医疗类别选门诊慢病1402
  7422. //var med_type string
  7423. //if his.Insutype == "310" {
  7424. // if reg_type == 14 {
  7425. // med_type = "9933"
  7426. // } else if reg_type == 11 {
  7427. // med_type = "11"
  7428. //
  7429. // }
  7430. //} else if his.Insutype == "390" {
  7431. // if reg_type == 14 {
  7432. // med_type = "1402"
  7433. // } else if reg_type == 11 {
  7434. // med_type = "11"
  7435. // }
  7436. //}
  7437. var api string
  7438. if miConfig.MdtrtareaAdmvs == "320921" {
  7439. api = "http://192.168.2.110:9532/" + "jsyb/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) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7446. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7447. } else {
  7448. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7449. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7450. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7451. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7452. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7453. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7454. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7455. "&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
  7456. }
  7457. resp, requestErr := http.Get(api)
  7458. if requestErr != nil {
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. return
  7461. }
  7462. body, ioErr := ioutil.ReadAll(resp.Body)
  7463. if ioErr != nil {
  7464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7466. return
  7467. }
  7468. var respJSON map[string]interface{}
  7469. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7472. return
  7473. }
  7474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7475. result, _ := json.Marshal(respJSON)
  7476. fmt.Println("log")
  7477. fmt.Println(string(result))
  7478. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7479. utils.ErrorLog("解析失败:%v", err)
  7480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7481. return
  7482. }
  7483. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7484. res.Output = resSeven10265.Output
  7485. res.ErrMsg = resSeven10265.ErrMsg
  7486. res.Cainfo = resSeven10265.Cainfo
  7487. res.WarnMsg = resSeven10265.WarnMsg
  7488. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7489. res.Infcode = infocode
  7490. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7491. result, request_log := service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7492. var dat map[string]interface{}
  7493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7494. fmt.Println(dat)
  7495. } else {
  7496. fmt.Println(err)
  7497. }
  7498. saveLog(result, request_log, "2206", "预结算")
  7499. userJSONBytes, _ := json.Marshal(dat)
  7500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7501. utils.ErrorLog("解析失败:%v", err)
  7502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7503. return
  7504. }
  7505. } else {
  7506. var result string
  7507. var request_log string
  7508. if miConfig.Code == "H15049901371" {
  7509. //赤峰地区国家医保医疗类别
  7510. //职工透析:医疗类别选特殊情况门诊990502
  7511. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7512. var med_type string
  7513. if his.Insutype == "390" {
  7514. if reg_type == 14 {
  7515. med_type = "9933"
  7516. } else if reg_type == 11 {
  7517. med_type = "11"
  7518. }
  7519. } else if his.Insutype == "310" {
  7520. if reg_type == 14 {
  7521. med_type = "990502"
  7522. } else if reg_type == 11 {
  7523. med_type = "11"
  7524. }
  7525. }
  7526. 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)
  7527. } else {
  7528. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  7529. }
  7530. var dat map[string]interface{}
  7531. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7532. fmt.Println(dat)
  7533. } else {
  7534. fmt.Println(err)
  7535. }
  7536. saveLog(result, request_log, "2206", "预结算")
  7537. //userJSONBytes, _ := json.Marshal(dat)
  7538. //
  7539. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7540. // utils.ErrorLog("解析失败:%v", err)
  7541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. // return
  7543. //}
  7544. userJSONBytes, _ := json.Marshal(dat)
  7545. if miConfig.Code == "H15049901371" {
  7546. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7547. utils.ErrorLog("解析失败:%v", err)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7552. res.Output = resSeven10265.Output
  7553. res.ErrMsg = resSeven10265.ErrMsg
  7554. res.Cainfo = resSeven10265.Cainfo
  7555. res.WarnMsg = resSeven10265.WarnMsg
  7556. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7557. res.Infcode = infocode
  7558. } else {
  7559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7560. utils.ErrorLog("解析失败:%v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. }
  7565. }
  7566. if res.Infcode != 0 {
  7567. errlog := &models.HisOrderError{
  7568. UserOrgId: adminUser.CurrentOrgId,
  7569. Ctime: time.Now().Unix(),
  7570. Mtime: time.Now().Unix(),
  7571. Number: chrg_bchno,
  7572. ErrMsg: res.ErrMsg,
  7573. Status: 1,
  7574. PatientId: id,
  7575. RecordTime: recordDateTime,
  7576. Stage: 20,
  7577. }
  7578. service.CreateErrMsgLog(errlog)
  7579. c.ServeSuccessJSON(map[string]interface{}{
  7580. "failed_code": -10,
  7581. "msg": res.ErrMsg,
  7582. })
  7583. return
  7584. } else {
  7585. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7586. order.OrderStatus = 1
  7587. order.IsPre = 1
  7588. order.Status = 1
  7589. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7590. order.SetlId = res.Output.Setlinfo.SetlID
  7591. order.PsnNo = res.Output.Setlinfo.PsnNo
  7592. order.PsnName = res.Output.Setlinfo.PsnName
  7593. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7594. order.Certno = res.Output.Setlinfo.Certno
  7595. order.Gend = res.Output.Setlinfo.Gend
  7596. order.Naty = res.Output.Setlinfo.Naty
  7597. order.Age = res.Output.Setlinfo.Age
  7598. order.Insutype = res.Output.Setlinfo.Insutype
  7599. order.PsnType = res.Output.Setlinfo.PsnType
  7600. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7601. order.SetlTime = res.Output.Setlinfo.SetlTime
  7602. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7603. if res.Output.Setlinfo.MedType == "140101" {
  7604. order.MedType = "14"
  7605. } else {
  7606. order.MedType = res.Output.Setlinfo.MedType
  7607. }
  7608. if reg_type == 1112 {
  7609. order.MedType = "1112"
  7610. }
  7611. if reg_type == 1111 {
  7612. order.MedType = "1111"
  7613. }
  7614. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7615. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7616. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7617. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7618. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7619. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7620. order.HifpPay = res.Output.Setlinfo.HifpPay
  7621. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7622. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7623. order.HifesPay = res.Output.Setlinfo.HifesPay
  7624. order.HifobPay = res.Output.Setlinfo.HifobPay
  7625. order.MafPay = res.Output.Setlinfo.MafPay
  7626. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7627. order.OthPay = res.Output.Setlinfo.OthPay
  7628. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7629. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7630. order.AcctPay = res.Output.Setlinfo.AcctPay
  7631. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7632. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7633. order.Balc = res.Output.Setlinfo.Balc
  7634. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7635. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7636. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7637. order.ClrWay = res.Output.Setlinfo.ClrWay
  7638. order.Creator = order.Creator
  7639. order.Modify = roles.AdminUserId
  7640. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7641. detailStr := string(setlDetail)
  7642. order.SetlDetail = detailStr
  7643. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7644. err = service.UpDateOrder(order)
  7645. if err == nil {
  7646. c.ServeSuccessJSON(map[string]interface{}{
  7647. "msg": "预结算成功",
  7648. })
  7649. } else {
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7651. return
  7652. }
  7653. }
  7654. } else {
  7655. adminUser := c.GetAdminUserInfo()
  7656. errlog := &models.HisOrderError{
  7657. UserOrgId: adminUser.CurrentOrgId,
  7658. Ctime: time.Now().Unix(),
  7659. Mtime: time.Now().Unix(),
  7660. ErrMsg: res.ErrMsg,
  7661. Status: 1,
  7662. PatientId: id,
  7663. RecordTime: recordDateTime,
  7664. Stage: 4,
  7665. }
  7666. service.CreateErrMsgLog(errlog)
  7667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7668. return
  7669. }
  7670. } else {
  7671. adminUser := c.GetAdminUserInfo()
  7672. errlog := &models.HisOrderError{
  7673. UserOrgId: adminUser.CurrentOrgId,
  7674. Ctime: time.Now().Unix(),
  7675. Mtime: time.Now().Unix(),
  7676. ErrMsg: res.ErrMsg,
  7677. Status: 1,
  7678. PatientId: id,
  7679. RecordTime: recordDateTime,
  7680. Stage: 4,
  7681. }
  7682. service.CreateErrMsgLog(errlog)
  7683. c.ServeSuccessJSON(map[string]interface{}{
  7684. "failed_code": -10,
  7685. "msg": res.ErrMsg,
  7686. })
  7687. return
  7688. }
  7689. }
  7690. }
  7691. }
  7692. //退款
  7693. func (c *HisApiController) Refund() {
  7694. order_id, _ := c.GetInt64("order_id")
  7695. admin_user_id, _ := c.GetInt64("admin_user_id")
  7696. adminUser := c.GetAdminUserInfo()
  7697. var order models.HisOrder
  7698. order, _ = service.GetHisOrderByID(order_id)
  7699. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7700. if order.ID == 0 {
  7701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7702. return
  7703. }
  7704. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7705. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7706. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7707. if config.IsOpen == 1 { //对接了医保,走医保流程
  7708. var res ResultSixteen
  7709. var resSixteen10265 ResultSixteen10265
  7710. var src_resquest string
  7711. var result string
  7712. if miConfig.MdtrtareaAdmvs == "421300" {
  7713. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7714. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7715. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7716. resp3, requestErr3 := http.Get(api3)
  7717. if requestErr3 != nil {
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7722. if ioErr3 != nil {
  7723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7725. return
  7726. }
  7727. var respJSON3 map[string]interface{}
  7728. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7731. return
  7732. }
  7733. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7734. userJSONBytes3, _ := json.Marshal(respJSON3)
  7735. fmt.Println("log")
  7736. fmt.Println(string(userJSONBytes3))
  7737. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7738. utils.ErrorLog("解析失败:%v", err)
  7739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7740. return
  7741. }
  7742. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7743. var api3 string
  7744. if miConfig.MdtrtareaAdmvs == "320921" {
  7745. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7746. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7748. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7749. } else {
  7750. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7751. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7752. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7753. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7754. }
  7755. resp3, requestErr3 := http.Get(api3)
  7756. if requestErr3 != nil {
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7761. if ioErr3 != nil {
  7762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. return
  7765. }
  7766. var respJSON3 map[string]interface{}
  7767. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7770. return
  7771. }
  7772. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7773. userJSONBytes3, _ := json.Marshal(respJSON3)
  7774. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7775. utils.ErrorLog("解析失败:%v", err)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7780. res.Output = resSixteen10265.Output
  7781. res.ErrMsg = resSixteen10265.ErrMsg
  7782. res.Cainfo = resSixteen10265.Cainfo
  7783. res.WarnMsg = resSixteen10265.WarnMsg
  7784. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7785. res.Infcode = infocode
  7786. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7787. result, src_resquest = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7788. var dat map[string]interface{}
  7789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7790. fmt.Println(dat)
  7791. } else {
  7792. fmt.Println(err)
  7793. }
  7794. saveLog(result, src_resquest, "2208", "退费")
  7795. userJSONBytes, _ := json.Marshal(dat)
  7796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7797. utils.ErrorLog("解析失败:%v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. } else {
  7802. if miConfig.Code == "H15049901371" {
  7803. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7804. var dat map[string]interface{}
  7805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7806. fmt.Println(dat)
  7807. } else {
  7808. fmt.Println(err)
  7809. }
  7810. saveLog(result, src_resquest, "2208", "退费")
  7811. userJSONBytes, _ := json.Marshal(dat)
  7812. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7813. utils.ErrorLog("解析失败:%v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. return
  7816. }
  7817. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7818. res.Output = resSixteen10265.Output
  7819. res.ErrMsg = resSixteen10265.ErrMsg
  7820. res.Cainfo = resSixteen10265.Cainfo
  7821. res.WarnMsg = resSixteen10265.WarnMsg
  7822. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7823. res.Infcode = infocode
  7824. } else {
  7825. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7826. var dat map[string]interface{}
  7827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7828. fmt.Println(dat)
  7829. } else {
  7830. fmt.Println(err)
  7831. }
  7832. saveLog(result, src_resquest, "2208", "退费")
  7833. userJSONBytes, _ := json.Marshal(dat)
  7834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7835. utils.ErrorLog("解析失败:%v", err)
  7836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7837. return
  7838. }
  7839. }
  7840. }
  7841. if res.Infcode == 0 {
  7842. var res2 ResultSix
  7843. var resSix10265 ResultSix10265
  7844. if miConfig.MdtrtareaAdmvs == "421300" {
  7845. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7846. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7847. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7848. resp3, requestErr3 := http.Get(api3)
  7849. if requestErr3 != nil {
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7854. if ioErr3 != nil {
  7855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7857. return
  7858. }
  7859. var respJSON3 map[string]interface{}
  7860. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7863. return
  7864. }
  7865. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7866. userJSONBytes3, _ := json.Marshal(respJSON3)
  7867. fmt.Println("log")
  7868. fmt.Println(string(userJSONBytes3))
  7869. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7870. utils.ErrorLog("解析失败:%v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7875. var api3 string
  7876. if miConfig.MdtrtareaAdmvs == "320921" {
  7877. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7878. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7879. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7880. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7881. } else {
  7882. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7883. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7884. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7885. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7886. }
  7887. resp3, requestErr3 := http.Get(api3)
  7888. if requestErr3 != nil {
  7889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. return
  7891. }
  7892. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7893. if ioErr3 != nil {
  7894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. var respJSON3 map[string]interface{}
  7899. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7902. return
  7903. }
  7904. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7905. userJSONBytes3, _ := json.Marshal(respJSON3)
  7906. fmt.Println("log")
  7907. fmt.Println(string(userJSONBytes3))
  7908. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7909. utils.ErrorLog("解析失败:%v", err)
  7910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7911. return
  7912. }
  7913. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7914. res2.Output = resSix10265.Output
  7915. res2.ErrMsg = resSix10265.ErrMsg
  7916. res2.Cainfo = resSix10265.Cainfo
  7917. res2.WarnMsg = resSix10265.WarnMsg
  7918. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7919. res2.Infcode = infocode
  7920. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7921. result2, src_request := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7922. var dat map[string]interface{}
  7923. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7924. fmt.Println(dat)
  7925. } else {
  7926. fmt.Println(err)
  7927. }
  7928. saveLog(result2, src_request, "2205", "撤销明细")
  7929. userJSONBytes, _ := json.Marshal(dat)
  7930. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7931. utils.ErrorLog("解析失败:%v", err)
  7932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7933. return
  7934. }
  7935. } else {
  7936. if miConfig.Code == "H15049901371" {
  7937. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7938. var dat map[string]interface{}
  7939. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7940. fmt.Println(dat)
  7941. } else {
  7942. fmt.Println(err)
  7943. }
  7944. saveLog(result2, src_request, "2205", "撤销明细")
  7945. userJSONBytes, _ := json.Marshal(dat)
  7946. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7947. utils.ErrorLog("解析失败:%v", err)
  7948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7949. return
  7950. }
  7951. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7952. res2.Output = resSix10265.Output
  7953. res2.ErrMsg = resSix10265.ErrMsg
  7954. res2.Cainfo = resSix10265.Cainfo
  7955. res2.WarnMsg = resSix10265.WarnMsg
  7956. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7957. res2.Infcode = infocode
  7958. } else {
  7959. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7960. var dat map[string]interface{}
  7961. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7962. fmt.Println(dat)
  7963. } else {
  7964. fmt.Println(err)
  7965. }
  7966. saveLog(result2, src_request, "2205", "撤销明细")
  7967. userJSONBytes, _ := json.Marshal(dat)
  7968. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7969. utils.ErrorLog("解析失败:%v", err)
  7970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7971. return
  7972. }
  7973. }
  7974. }
  7975. if res2.Infcode == 0 {
  7976. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7977. if err == nil {
  7978. //当押金不为零时产生退费记录
  7979. if order.Decimal != 0 {
  7980. tmp := strconv.FormatInt(order.ID, 10)
  7981. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7982. if err != nil {
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7984. return
  7985. }
  7986. }
  7987. c.ServeSuccessJSON(map[string]interface{}{
  7988. "msg": "退费成功",
  7989. })
  7990. } else {
  7991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7992. return
  7993. }
  7994. } else {
  7995. c.ServeSuccessJSON(map[string]interface{}{
  7996. "code": -10,
  7997. "msg": res2.ErrMsg,
  7998. })
  7999. }
  8000. } else {
  8001. c.ServeSuccessJSON(map[string]interface{}{
  8002. "code": -10,
  8003. "msg": res.ErrMsg,
  8004. })
  8005. }
  8006. }
  8007. }
  8008. func (c *HisApiController) RefundNumber() {
  8009. record_time := c.GetString("record_time")
  8010. //patient_id, _ := c.GetInt64("patient_id")
  8011. admin_user_id, _ := c.GetInt64("admin_user_id")
  8012. his_patient_id, _ := c.GetInt64("id")
  8013. timeLayout := "2006-01-02"
  8014. loc, _ := time.LoadLocation("Local")
  8015. adminUser := c.GetAdminUserInfo()
  8016. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8017. fmt.Println(err)
  8018. if err != nil {
  8019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8020. return
  8021. }
  8022. recordDateTime := theTime.Unix()
  8023. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8024. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8025. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8026. //order, _ := service.GetHisOrderByID(order_id)
  8027. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8028. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8029. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8030. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8031. if count > 0 {
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8033. return
  8034. }
  8035. if config.IsOpen == 1 { //对接了医保,走医保流程
  8036. var res2 ResultSix
  8037. var resSix10265 ResultSix10265
  8038. if miConfig.MdtrtareaAdmvs == "421300" {
  8039. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8040. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8041. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8042. resp3, requestErr3 := http.Get(api3)
  8043. if requestErr3 != nil {
  8044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8045. return
  8046. }
  8047. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8048. if ioErr3 != nil {
  8049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. var respJSON3 map[string]interface{}
  8054. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. return
  8058. }
  8059. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8060. userJSONBytes3, _ := json.Marshal(respJSON3)
  8061. fmt.Println("log")
  8062. fmt.Println(string(userJSONBytes3))
  8063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8064. utils.ErrorLog("解析失败:%v", err)
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8066. return
  8067. }
  8068. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8069. var api3 string
  8070. if miConfig.MdtrtareaAdmvs == "320921" {
  8071. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8072. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8074. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8075. } else {
  8076. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8077. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8078. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8079. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8080. }
  8081. resp3, requestErr3 := http.Get(api3)
  8082. if requestErr3 != nil {
  8083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8084. return
  8085. }
  8086. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8087. if ioErr3 != nil {
  8088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. return
  8091. }
  8092. var respJSON3 map[string]interface{}
  8093. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8096. return
  8097. }
  8098. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8099. userJSONBytes3, _ := json.Marshal(respJSON3)
  8100. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8101. utils.ErrorLog("解析失败:%v", err)
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8106. res2.Output = resSix10265.Output
  8107. res2.ErrMsg = resSix10265.ErrMsg
  8108. res2.Cainfo = resSix10265.Cainfo
  8109. res2.WarnMsg = resSix10265.WarnMsg
  8110. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8111. res2.Infcode = infocode
  8112. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8113. result, request := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8114. var dat map[string]interface{}
  8115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8116. fmt.Println(dat)
  8117. } else {
  8118. fmt.Println(err)
  8119. }
  8120. saveLog(result, request, "2202", "退号")
  8121. userJSONBytes, _ := json.Marshal(dat)
  8122. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8123. utils.ErrorLog("解析失败:%v", err)
  8124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. return
  8126. }
  8127. } else {
  8128. var api3 string
  8129. if miConfig.Code == "H15049901371" {
  8130. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8131. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8133. } else {
  8134. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8135. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8136. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8137. }
  8138. resp3, requestErr3 := http.Get(api3)
  8139. if requestErr3 != nil {
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8144. if ioErr3 != nil {
  8145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8147. return
  8148. }
  8149. var respJSON3 map[string]interface{}
  8150. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8153. return
  8154. }
  8155. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8156. userJSONBytes3, _ := json.Marshal(respJSON3)
  8157. if miConfig.Code == "H15049901371" {
  8158. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8159. utils.ErrorLog("解析失败:%v", err)
  8160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8161. return
  8162. }
  8163. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8164. res2.Output = resSix10265.Output
  8165. res2.ErrMsg = resSix10265.ErrMsg
  8166. res2.Cainfo = resSix10265.Cainfo
  8167. res2.WarnMsg = resSix10265.WarnMsg
  8168. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8169. res2.Infcode = infocode
  8170. } else {
  8171. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8172. utils.ErrorLog("解析失败:%v", err)
  8173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8174. return
  8175. }
  8176. }
  8177. }
  8178. if res2.Infcode == 0 {
  8179. if err == nil {
  8180. c.ServeSuccessJSON(map[string]interface{}{
  8181. "msg": "退号成功",
  8182. })
  8183. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8184. } else {
  8185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8186. return
  8187. }
  8188. } else {
  8189. c.ServeSuccessJSON(map[string]interface{}{
  8190. "code": -10,
  8191. "msg": res2.ErrMsg,
  8192. })
  8193. }
  8194. } else {
  8195. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8196. //if err == nil {
  8197. // c.ServeSuccessJSON(map[string]interface{}{
  8198. // "msg": "退费成功",
  8199. // })
  8200. //} else {
  8201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. // return
  8203. //}
  8204. }
  8205. }
  8206. func (c *HisApiController) RefundDetail() {
  8207. order_id, _ := c.GetInt64("order_id")
  8208. admin_user_id, _ := c.GetInt64("admin_user_id")
  8209. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8210. number := c.GetString("number")
  8211. record_time := c.GetString("record_time")
  8212. patient_id, _ := c.GetInt64("patient_id")
  8213. //med_type, _ := c.GetInt64("med_type")
  8214. timeLayout := "2006-01-02"
  8215. loc, _ := time.LoadLocation("Local")
  8216. adminUser := c.GetAdminUserInfo()
  8217. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8218. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8219. fmt.Println(err)
  8220. if err != nil {
  8221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8222. return
  8223. }
  8224. recordDateTime := theTime.Unix()
  8225. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8226. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8227. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8228. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8229. var order models.HisOrder
  8230. order, _ = service.GetHisOrderByID(order_id)
  8231. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8232. if config.IsOpen == 1 { //对接了医保,走医保流程
  8233. var res2 ResultSix
  8234. if miConfig.MdtrtareaAdmvs == "421300" {
  8235. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8236. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8238. resp3, requestErr3 := http.Get(api3)
  8239. if requestErr3 != nil {
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8241. return
  8242. }
  8243. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8244. if ioErr3 != nil {
  8245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8247. return
  8248. }
  8249. var respJSON3 map[string]interface{}
  8250. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8253. return
  8254. }
  8255. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8256. userJSONBytes3, _ := json.Marshal(respJSON3)
  8257. fmt.Println("log")
  8258. fmt.Println(string(userJSONBytes3))
  8259. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8260. utils.ErrorLog("解析失败:%v", err)
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. return
  8263. }
  8264. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8265. if err == nil {
  8266. c.ServeSuccessJSON(map[string]interface{}{
  8267. "msg": "撤销明细成功",
  8268. })
  8269. return
  8270. } else {
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8272. return
  8273. }
  8274. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8275. var resSix10265 ResultSix10265
  8276. var api3 string
  8277. if miConfig.MdtrtareaAdmvs == "320921" {
  8278. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8279. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8280. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8281. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8282. } else {
  8283. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8284. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8285. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8286. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8287. }
  8288. resp3, requestErr3 := http.Get(api3)
  8289. if requestErr3 != nil {
  8290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8291. return
  8292. }
  8293. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8294. if ioErr3 != nil {
  8295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. var respJSON3 map[string]interface{}
  8300. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8306. userJSONBytes3, _ := json.Marshal(respJSON3)
  8307. fmt.Println("log")
  8308. fmt.Println(string(userJSONBytes3))
  8309. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8310. utils.ErrorLog("解析失败:%v", err)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8315. res2.Output = resSix10265.Output
  8316. res2.ErrMsg = resSix10265.ErrMsg
  8317. res2.Cainfo = resSix10265.Cainfo
  8318. res2.WarnMsg = resSix10265.WarnMsg
  8319. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8320. res2.Infcode = infocode
  8321. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8322. if err == nil {
  8323. c.ServeSuccessJSON(map[string]interface{}{
  8324. "msg": "撤销明细成功",
  8325. })
  8326. return
  8327. } else {
  8328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8329. return
  8330. }
  8331. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8332. result2, src_request := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8333. var dat map[string]interface{}
  8334. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8335. fmt.Println(dat)
  8336. } else {
  8337. fmt.Println(err)
  8338. }
  8339. saveLog(result2, src_request, "2205", "撤销明细")
  8340. userJSONBytes, _ := json.Marshal(dat)
  8341. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8342. utils.ErrorLog("解析失败:%v", err)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. if res2.Infcode == 0 {
  8347. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8348. if err == nil {
  8349. c.ServeSuccessJSON(map[string]interface{}{
  8350. "msg": "撤销明细成功",
  8351. })
  8352. return
  8353. } else {
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. } else {
  8358. c.ServeSuccessJSON(map[string]interface{}{
  8359. "code": -10,
  8360. "msg": res2.ErrMsg,
  8361. })
  8362. }
  8363. } else {
  8364. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8365. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8366. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8367. resp2, requestErr2 := http.Get(api2)
  8368. if requestErr2 != nil {
  8369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8370. return
  8371. }
  8372. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8373. if ioErr2 != nil {
  8374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. var respJSON2 map[string]interface{}
  8379. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. return
  8383. }
  8384. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8385. if err == nil {
  8386. c.ServeSuccessJSON(map[string]interface{}{
  8387. "msg": "撤销明细成功",
  8388. })
  8389. return
  8390. } else {
  8391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. return
  8393. }
  8394. }
  8395. } else {
  8396. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8397. if err == nil {
  8398. c.ServeSuccessJSON(map[string]interface{}{
  8399. "msg": "退费成功",
  8400. })
  8401. } else {
  8402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. return
  8404. }
  8405. }
  8406. }
  8407. //对账
  8408. func (c *HisApiController) GetCheckAccount() {
  8409. start_time := c.GetString("start_time")
  8410. end_time := c.GetString("end_time")
  8411. insutype := c.GetString("insutype")
  8412. clr_type := c.GetString("clr_type")
  8413. clr_org := c.GetString("clr_optins")
  8414. admin_user_id, _ := c.GetInt64("admin_user_id")
  8415. adminUser := c.GetAdminUserInfo()
  8416. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8417. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8418. if len(clr_org) == 0 {
  8419. clr_org = miConfig.MdtrtareaAdmvs
  8420. }
  8421. timeLayout := "2006-01-02"
  8422. loc, _ := time.LoadLocation("Local")
  8423. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8424. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8425. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8426. fixmedins_setl_cnt := int64(len(orders))
  8427. var medfee_sumamt float64
  8428. var acct_pay float64
  8429. var fund_pay_sumamt float64
  8430. for _, item := range orders {
  8431. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8432. acct_pay = acct_pay + item.AcctPay
  8433. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8434. }
  8435. var user_name string
  8436. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8437. if role.ID == 0 {
  8438. user_name = "xxx"
  8439. } else {
  8440. user_name = role.UserName
  8441. }
  8442. var res ResultEight
  8443. var res10188 ResultEightFor10188
  8444. if config.IsOpen == 1 {
  8445. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8446. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8447. "insutype=" + insutype +
  8448. "&clr_type=" + clr_type +
  8449. "&setl_optins=" + clr_org +
  8450. "&stmt_begndate=" + start_time +
  8451. "&stm_enddate=" + end_time +
  8452. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8453. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8454. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8455. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8456. "&fixmedins_code=" + miConfig.Code +
  8457. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8458. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8459. "&secret_key=" + miConfig.SecretKey +
  8460. "&org_name=" + miConfig.OrgName +
  8461. "&doctor=" + user_name +
  8462. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8463. fmt.Println(api)
  8464. resp, requestErr := http.Get(api)
  8465. if requestErr != nil {
  8466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8467. return
  8468. }
  8469. body, ioErr := ioutil.ReadAll(resp.Body)
  8470. fmt.Println(body)
  8471. if ioErr != nil {
  8472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8474. return
  8475. }
  8476. var respJSON map[string]interface{}
  8477. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8483. userJSONBytes, _ := json.Marshal(respJSON)
  8484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8485. utils.ErrorLog("解析失败:%v", err)
  8486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. return
  8488. }
  8489. res.InfRefmsgid = res10188.InfRefmsgid
  8490. res.Output = res10188.Output
  8491. res.ErrMsg = res10188.ErrMsg
  8492. res.Cainfo = res10188.Cainfo
  8493. res.WarnMsg = res10188.WarnMsg
  8494. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8495. res.Infcode = infocode
  8496. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8497. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8498. "insutype=" + insutype +
  8499. "&clr_type=" + clr_type +
  8500. "&setl_optins=" + clr_org +
  8501. "&stmt_begndate=" + start_time +
  8502. "&stm_enddate=" + end_time +
  8503. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8504. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8505. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8506. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8507. "&fixmedins_code=" + miConfig.Code +
  8508. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8509. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8510. "&secret_key=" + miConfig.SecretKey +
  8511. "&org_name=" + miConfig.OrgName +
  8512. "&doctor=" + user_name
  8513. resp, requestErr := http.Get(api)
  8514. if requestErr != nil {
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. body, ioErr := ioutil.ReadAll(resp.Body)
  8519. if ioErr != nil {
  8520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. return
  8523. }
  8524. var respJSON map[string]interface{}
  8525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8531. result, _ := json.Marshal(respJSON)
  8532. fmt.Println("log")
  8533. fmt.Println(string(result))
  8534. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8535. utils.ErrorLog("解析失败:%v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. res.InfRefmsgid = res10188.InfRefmsgid
  8540. res.Output = res10188.Output
  8541. res.ErrMsg = res10188.ErrMsg
  8542. res.Cainfo = res10188.Cainfo
  8543. res.WarnMsg = res10188.WarnMsg
  8544. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8545. res.Infcode = infocode
  8546. } else {
  8547. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8548. "insutype=" + insutype +
  8549. "&clr_type=" + clr_type +
  8550. "&setl_optins=" + clr_org +
  8551. "&stmt_begndate=" + start_time +
  8552. "&stm_enddate=" + end_time +
  8553. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8554. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8555. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8556. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8557. "&fixmedins_code=" + miConfig.Code +
  8558. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8559. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8560. "&secret_key=" + miConfig.SecretKey +
  8561. "&org_name=" + miConfig.OrgName +
  8562. "&doctor=" + user_name
  8563. fmt.Println(api)
  8564. resp, requestErr := http.Get(api)
  8565. if requestErr != nil {
  8566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8567. return
  8568. }
  8569. body, ioErr := ioutil.ReadAll(resp.Body)
  8570. fmt.Println(body)
  8571. if ioErr != nil {
  8572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8574. return
  8575. }
  8576. var respJSON map[string]interface{}
  8577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8583. userJSONBytes, _ := json.Marshal(respJSON)
  8584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8585. utils.ErrorLog("解析失败:%v", err)
  8586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8587. return
  8588. }
  8589. }
  8590. if res.Infcode == 0 {
  8591. if res.Output.Stmtinfo.StmtRslt == "0" {
  8592. micc := &models.MedicalInsuranceCostCompare{
  8593. StartTime: startime.Unix(),
  8594. EndTime: endtime.Unix(),
  8595. Insutype: insutype,
  8596. CheckType: 1,
  8597. Num: fixmedins_setl_cnt,
  8598. Mtime: time.Now().Unix(),
  8599. Status: 1,
  8600. UserOrgId: adminUser.CurrentOrgId,
  8601. CostTotal: medfee_sumamt,
  8602. FuncTotal: fund_pay_sumamt,
  8603. PsnPay: acct_pay,
  8604. Creator: admin_user_id,
  8605. Ctime: time.Now().Unix(),
  8606. ClrType: clr_type,
  8607. }
  8608. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8609. if err == nil {
  8610. c.ServeSuccessJSON(map[string]interface{}{
  8611. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8612. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8613. })
  8614. } else {
  8615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8616. }
  8617. } else {
  8618. c.ServeSuccessJSON(map[string]interface{}{
  8619. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8620. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8621. })
  8622. }
  8623. } else {
  8624. c.ServeSuccessJSON(map[string]interface{}{
  8625. "code": -10,
  8626. "msg": res.ErrMsg,
  8627. })
  8628. }
  8629. }
  8630. }
  8631. func (c *HisApiController) Check310() {
  8632. adminUser := c.GetAdminUserInfo()
  8633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8634. var user_name string
  8635. user_name = "高慧裕"
  8636. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8637. "insutype=" + "310" +
  8638. "&clr_type=" + "" +
  8639. "&setl_optins=" + "441202" +
  8640. "&stmt_begndate=" + "2022-03-01" +
  8641. "&stm_enddate=" + "2022-03-31" +
  8642. "&medfee_sumamt=" + "194930.12" +
  8643. "&fund_pay_sumamt=" + "188741.46" +
  8644. "&acct_pay=" + "0" +
  8645. "&fixmedins_setl_cnt=" + "452" +
  8646. "&fixmedins_code=" + miConfig.Code +
  8647. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8648. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8649. "&secret_key=" + miConfig.SecretKey +
  8650. "&org_name=" + miConfig.OrgName +
  8651. "&doctor=" + user_name
  8652. fmt.Println(api)
  8653. resp, requestErr := http.Get(api)
  8654. if requestErr != nil {
  8655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8656. return
  8657. }
  8658. body, ioErr := ioutil.ReadAll(resp.Body)
  8659. fmt.Println(body)
  8660. if ioErr != nil {
  8661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. var respJSON map[string]interface{}
  8666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8669. return
  8670. }
  8671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8672. userJSONBytes, _ := json.Marshal(respJSON)
  8673. var res ResultEight
  8674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8675. utils.ErrorLog("解析失败:%v", err)
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8677. return
  8678. }
  8679. }
  8680. func (c *HisApiController) Check390() {
  8681. adminUser := c.GetAdminUserInfo()
  8682. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8683. var user_name string
  8684. user_name = "高慧裕"
  8685. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8686. "insutype=" + "390" +
  8687. "&clr_type=" + "" +
  8688. "&setl_optins=" + "441202" +
  8689. "&stmt_begndate=" + "2022-03-01" +
  8690. "&stm_enddate=" + "2022-03-31" +
  8691. "&medfee_sumamt=" + "1068448.89" +
  8692. "&fund_pay_sumamt=" + "1014677.62" +
  8693. "&acct_pay=" + "0" +
  8694. "&fixmedins_setl_cnt=" + "1950" +
  8695. "&fixmedins_code=" + miConfig.Code +
  8696. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8697. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8698. "&secret_key=" + miConfig.SecretKey +
  8699. "&org_name=" + miConfig.OrgName +
  8700. "&doctor=" + user_name
  8701. fmt.Println(api)
  8702. resp, requestErr := http.Get(api)
  8703. if requestErr != nil {
  8704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8705. return
  8706. }
  8707. body, ioErr := ioutil.ReadAll(resp.Body)
  8708. fmt.Println(body)
  8709. if ioErr != nil {
  8710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8712. return
  8713. }
  8714. var respJSON map[string]interface{}
  8715. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8718. return
  8719. }
  8720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8721. userJSONBytes, _ := json.Marshal(respJSON)
  8722. var res ResultEight
  8723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8724. utils.ErrorLog("解析失败:%v", err)
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. return
  8727. }
  8728. }
  8729. //对账明细
  8730. func (c *HisApiController) GetCheckDetailAccount() {
  8731. start_time := c.GetString("start_time")
  8732. end_time := c.GetString("end_time")
  8733. admin_user_id, _ := c.GetInt64("admin_user_id")
  8734. adminUser := c.GetAdminUserInfo()
  8735. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8736. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8737. timeLayout := "2006-01-02"
  8738. loc, _ := time.LoadLocation("Local")
  8739. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8740. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8741. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8742. rand.Seed(time.Now().UnixNano())
  8743. num := rand.Intn(30000)
  8744. Mkdir(miConfig.OrgName)
  8745. file := strconv.FormatInt(int64(num), 10)
  8746. file_name := file + ".txt"
  8747. zip_name := file + ".zip"
  8748. zip_path := miConfig.OrgName + "/" + zip_name
  8749. file_path := miConfig.OrgName + "/" + file_name
  8750. decimal.DivisionPrecision = 2
  8751. var medfee_sumamt float64
  8752. var psn_cash_pay float64
  8753. var fund_pay_sumamt float64
  8754. fixmedins_setl_cnt := int64(len(orders))
  8755. for _, item := range orders {
  8756. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8757. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8758. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8759. }
  8760. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8761. defer f.Close()
  8762. if err != nil {
  8763. fmt.Println(err.Error())
  8764. } else {
  8765. for _, item := range orders {
  8766. var refd_setl_flag string
  8767. if item.OrderStatus == 2 {
  8768. refd_setl_flag = "0"
  8769. var str string
  8770. str = item.SetlId + " " +
  8771. item.MdtrtId + " " +
  8772. item.PsnNo + " " +
  8773. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8774. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8775. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8776. _, err = f.Write([]byte(str))
  8777. }
  8778. if item.OrderStatus == 3 {
  8779. var str string
  8780. str = item.SetlId + " " +
  8781. item.MdtrtId + " " +
  8782. item.PsnNo + " " +
  8783. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8784. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8785. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8786. _, err = f.Write([]byte(str))
  8787. var str2 string
  8788. str2 = item.SetlId + " " +
  8789. item.MdtrtId + " " +
  8790. item.PsnNo + " " +
  8791. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8792. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8793. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8794. _, err = f.Write([]byte(str2))
  8795. }
  8796. }
  8797. }
  8798. Zip(file_path, zip_path)
  8799. fmt.Println(ReadFile(zip_path))
  8800. fmt.Println(string(ReadFile(zip_path)))
  8801. if config.IsOpen == 1 {
  8802. var user_name string
  8803. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8804. if role.ID == 0 {
  8805. user_name = "管理员"
  8806. } else {
  8807. user_name = role.UserName
  8808. }
  8809. baseParams := models.BaseParams{
  8810. SecretKey: miConfig.SecretKey,
  8811. FixmedinsCode: miConfig.Code,
  8812. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8813. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8814. OrgName: miConfig.OrgName,
  8815. Doctor: user_name,
  8816. }
  8817. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8818. var dat map[string]interface{}
  8819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8820. fmt.Println(dat)
  8821. } else {
  8822. fmt.Println(err)
  8823. }
  8824. userJSONBytes, _ := json.Marshal(dat)
  8825. var res ResultNine
  8826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. if res.Infcode == 0 {
  8832. fileNo := res.Output.FileQuryNo
  8833. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8834. "file_qury_no=" + fileNo +
  8835. "&setl_optins=" + "定点医保中心" +
  8836. "&stmt_begndate=" + start_time +
  8837. "&stm_enddate=" + end_time +
  8838. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8839. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8840. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8841. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8842. "&fixmedins_code=" + miConfig.Code +
  8843. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8844. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8845. "&secret_key=" + miConfig.SecretKey +
  8846. "&org_name=" + miConfig.OrgName +
  8847. "&doctor=" + user_name
  8848. resp, requestErr := http.Get(api)
  8849. if requestErr != nil {
  8850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8851. return
  8852. }
  8853. body, ioErr := ioutil.ReadAll(resp.Body)
  8854. if ioErr != nil {
  8855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8857. return
  8858. }
  8859. var respJSON map[string]interface{}
  8860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8863. return
  8864. }
  8865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8866. userJSONBytes, _ := json.Marshal(respJSON)
  8867. var res ResultTen
  8868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8869. utils.ErrorLog("解析失败:%v", err)
  8870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. return
  8872. }
  8873. if res.Infcode == 0 {
  8874. service.Gdyb9102(baseParams, zip_name, fileNo)
  8875. micc := &models.MedicalInsuranceCostCompare{
  8876. StartTime: startime.Unix(),
  8877. EndTime: endtime.Unix(),
  8878. Insutype: "0",
  8879. CheckType: 2,
  8880. Num: fixmedins_setl_cnt,
  8881. Mtime: time.Now().Unix(),
  8882. Status: 1,
  8883. UserOrgId: adminUser.CurrentOrgId,
  8884. CostTotal: medfee_sumamt,
  8885. FuncTotal: fund_pay_sumamt,
  8886. PsnPay: psn_cash_pay,
  8887. Creator: admin_user_id,
  8888. Ctime: time.Now().Unix(),
  8889. }
  8890. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8891. c.ServeSuccessJSON(map[string]interface{}{
  8892. "msg": "明细对账成功",
  8893. })
  8894. }
  8895. } else {
  8896. }
  8897. }
  8898. }
  8899. type CustomOrderInfo struct {
  8900. Name string
  8901. Spec string
  8902. Unit string
  8903. Count float64
  8904. Price float64
  8905. Total float64
  8906. }
  8907. func (c *HisApiController) GetSettleAccounts() {
  8908. //id, _ := c.GetInt64("id")
  8909. //record_time := c.GetString("record_time")
  8910. order_id, _ := c.GetInt64("order_id")
  8911. admin_user_id, _ := c.GetInt64("admin_user_id")
  8912. //timeLayout := "2006-01-02"
  8913. //loc, _ := time.LoadLocation("Local")
  8914. //
  8915. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8916. //if err != nil {
  8917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8918. // return
  8919. //}
  8920. //recordDateTime := theTime.Unix()
  8921. adminUser := c.GetAdminUserInfo()
  8922. order, _ := service.GetHisOrderByID(order_id)
  8923. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8924. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8925. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8926. orderInfos = append(orderInfos, orderInfos_two...)
  8927. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8928. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8929. var diagnosis_ids []string
  8930. if his.ID > 0 {
  8931. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8932. } else {
  8933. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8934. }
  8935. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8936. var dia_config []*models.HisXtDiagnoseConfig
  8937. var name string
  8938. for _, item := range diagnosis_ids {
  8939. id, _ := strconv.ParseInt(item, 10, 64)
  8940. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8941. dia_config = append(dia_config, &diagnosisConfig)
  8942. if len(name) == 0 {
  8943. name = diagnosisConfig.ClassName
  8944. } else {
  8945. name = name + "," + diagnosisConfig.ClassName
  8946. }
  8947. }
  8948. var bedCostTotal float64 = 0 //床位总费
  8949. var bedCostSelfTotal float64 = 0 //床位自费
  8950. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8951. var operationCostTotal float64 = 0 //手术费
  8952. var operationCostSelfTotal float64 = 0 //手术费
  8953. var operationCostPartSelfTotal float64 = 0 //手术费
  8954. var otherCostTotal float64 = 0 //其他费用
  8955. var otherCostSelfTotal float64 = 0 //其他费用
  8956. var otherCostPartSelfTotal float64 = 0 //其他费用
  8957. var materialCostTotal float64 = 0 //材料费
  8958. var materialCostSelfTotal float64 = 0 //材料费
  8959. var materialCostPartSelfTotal float64 = 0 //材料费
  8960. var westernMedicineCostTotal float64 = 0 //西药费
  8961. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8962. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8963. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8964. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8965. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8966. var checkCostTotal float64 = 0 //检查费
  8967. var checkCostSelfTotal float64 = 0 //检查费
  8968. var checkCostPartSelfTotal float64 = 0 //检查费
  8969. var laboratoryCostTotal float64 = 0 //化验费
  8970. var laboratoryCostSelfTotal float64 = 0 //化验费
  8971. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8972. var treatCostTotal float64 = 0 //治疗费用
  8973. var treatCostSelfTotal float64 = 0 //治疗费用
  8974. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8975. decimal.DivisionPrecision = 2
  8976. for _, item := range orderInfos {
  8977. if item.MedChrgitmType == "01" { //床位费
  8978. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8979. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8980. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8981. }
  8982. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8983. if item.MedChrgitmType == "03" { //检查费
  8984. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8985. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8986. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8987. }
  8988. } else {
  8989. if item.MedChrgitmType == "03" { //检查费
  8990. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8991. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8992. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8993. }
  8994. }
  8995. if item.MedChrgitmType == "04" { //化验费
  8996. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8997. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8998. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8999. }
  9000. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9001. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9002. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9003. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9004. }
  9005. if item.MedChrgitmType == "06" { //手术费
  9006. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9007. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9008. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9009. }
  9010. if item.MedChrgitmType == "08" { //材料费
  9011. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9012. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9013. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9014. }
  9015. if item.MedChrgitmType == "09" { //西药费
  9016. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9017. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9018. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9019. }
  9020. if item.MedChrgitmType == "11" { //中成费
  9021. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9022. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9023. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9024. }
  9025. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9026. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9027. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9028. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9029. }
  9030. }
  9031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9032. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9033. var user_name string
  9034. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9035. if role.ID == 0 {
  9036. user_name = "管理员"
  9037. } else {
  9038. user_name = role.UserName
  9039. }
  9040. baseParams := models.BaseParams{
  9041. SecretKey: miConfig.SecretKey,
  9042. FixmedinsCode: miConfig.Code,
  9043. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9044. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9045. OrgName: miConfig.OrgName,
  9046. Doctor: user_name,
  9047. }
  9048. businessParams := models.BusinessParams{
  9049. PsnNo: order.PsnNo,
  9050. MdtrtId: order.MdtrtId,
  9051. SetlId: order.SetlId,
  9052. }
  9053. var res ResultEleven
  9054. var resEleven10265 ResultEleven10265
  9055. if config.IsOpen == 1 {
  9056. if miConfig.MdtrtareaAdmvs == "421300" {
  9057. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9058. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9059. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9060. resp, requestErr := http.Get(api)
  9061. if requestErr != nil {
  9062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9063. return
  9064. }
  9065. body, ioErr := ioutil.ReadAll(resp.Body)
  9066. if ioErr != nil {
  9067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9069. return
  9070. }
  9071. var respJSON map[string]interface{}
  9072. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9075. return
  9076. }
  9077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9078. result, _ := json.Marshal(respJSON)
  9079. fmt.Println("log")
  9080. fmt.Println(string(result))
  9081. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9082. utils.ErrorLog("解析失败:%v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9087. var api string
  9088. if miConfig.MdtrtareaAdmvs == "320921" {
  9089. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9090. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9091. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9092. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9093. } else {
  9094. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9095. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9096. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9097. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9098. }
  9099. resp, requestErr := http.Get(api)
  9100. if requestErr != nil {
  9101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9102. return
  9103. }
  9104. body, ioErr := ioutil.ReadAll(resp.Body)
  9105. if ioErr != nil {
  9106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9108. return
  9109. }
  9110. var respJSON map[string]interface{}
  9111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9114. return
  9115. }
  9116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9117. result, _ := json.Marshal(respJSON)
  9118. fmt.Println("log")
  9119. fmt.Println(string(result))
  9120. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9121. utils.ErrorLog("解析失败:%v", err)
  9122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9123. return
  9124. }
  9125. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9126. res.Output = resEleven10265.Output
  9127. res.ErrMsg = resEleven10265.ErrMsg
  9128. res.Cainfo = resEleven10265.Cainfo
  9129. res.WarnMsg = resEleven10265.WarnMsg
  9130. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9131. res.Infcode = infocode
  9132. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9133. result := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9134. var dat map[string]interface{}
  9135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9136. fmt.Println(dat)
  9137. } else {
  9138. fmt.Println(err)
  9139. }
  9140. userJSONBytes, _ := json.Marshal(dat)
  9141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9142. utils.ErrorLog("解析失败:%v", err)
  9143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9144. return
  9145. }
  9146. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9147. fmt.Println("~~~~~~~")
  9148. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9149. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9150. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9151. resp, requestErr := http.Get(api)
  9152. if requestErr != nil {
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. return
  9155. }
  9156. body, ioErr := ioutil.ReadAll(resp.Body)
  9157. if ioErr != nil {
  9158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. var respJSON map[string]interface{}
  9163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9169. result, _ := json.Marshal(respJSON)
  9170. fmt.Println("log")
  9171. fmt.Println(string(result))
  9172. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9173. utils.ErrorLog("解析失败:%v", err)
  9174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9175. return
  9176. }
  9177. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9178. res.Output = resEleven10265.Output
  9179. res.ErrMsg = resEleven10265.ErrMsg
  9180. res.Cainfo = resEleven10265.Cainfo
  9181. res.WarnMsg = resEleven10265.WarnMsg
  9182. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9183. res.Infcode = infocode
  9184. } else {
  9185. result := service.Gdyb5203(baseParams, businessParams)
  9186. //service.Gdyb5204(baseParams, businessParams)
  9187. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9188. var dat map[string]interface{}
  9189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9190. fmt.Println(dat)
  9191. } else {
  9192. fmt.Println(err)
  9193. }
  9194. userJSONBytes, _ := json.Marshal(dat)
  9195. if miConfig.Code == "H15049901371" {
  9196. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9197. utils.ErrorLog("解析失败:%v", err)
  9198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9199. return
  9200. }
  9201. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9202. res.Output = resEleven10265.Output
  9203. res.ErrMsg = resEleven10265.ErrMsg
  9204. res.Cainfo = resEleven10265.Cainfo
  9205. res.WarnMsg = resEleven10265.WarnMsg
  9206. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9207. res.Infcode = infocode
  9208. } else {
  9209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9210. utils.ErrorLog("解析失败:%v", err)
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. }
  9215. }
  9216. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9217. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9218. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9219. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9220. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9221. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9222. var doctor_name string
  9223. if roles.ID == 0 {
  9224. doctor_name = "管理员"
  9225. } else {
  9226. doctor_name = roles.UserName
  9227. }
  9228. yiliao_leibie := ""
  9229. switch order.MedType {
  9230. case "11":
  9231. yiliao_leibie = "普通门诊"
  9232. break
  9233. case "12":
  9234. yiliao_leibie = "门诊挂号"
  9235. break
  9236. case "13":
  9237. yiliao_leibie = "急诊"
  9238. break
  9239. case "14":
  9240. yiliao_leibie = "门诊特殊病"
  9241. break
  9242. case "15":
  9243. yiliao_leibie = "门诊统筹"
  9244. break
  9245. case "16":
  9246. yiliao_leibie = "门诊慢性病"
  9247. break
  9248. case "21":
  9249. yiliao_leibie = "普通住院"
  9250. break
  9251. }
  9252. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9253. if res.Infcode == 0 {
  9254. c.ServeSuccessJSON(map[string]interface{}{
  9255. "diagnosis": name,
  9256. "order_infos": orderInfos,
  9257. "number": order.MdtrtId,
  9258. "date": order.SettleAccountsDate,
  9259. "charge_admin": charge_admin,
  9260. "printor_admin": printor_admin,
  9261. "info": res.Output.Setlinfo,
  9262. "order": order,
  9263. "bedCostTotal": bedCostTotal,
  9264. "bedCostSelfTotal": bedCostSelfTotal,
  9265. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9266. "operationCostTotal": operationCostTotal,
  9267. "operationCostSelfTotal": operationCostSelfTotal,
  9268. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9269. "otherCostTotal": otherCostTotal,
  9270. "otherCostSelfTotal": otherCostSelfTotal,
  9271. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9272. "materialCostTotal": materialCostTotal,
  9273. "materialCostSelfTotal": materialCostSelfTotal,
  9274. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9275. "westernMedicineCostTotal": westernMedicineCostTotal,
  9276. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9277. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9278. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9279. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9280. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9281. "checkCostTotal": checkCostTotal,
  9282. "checkCostSelfTotal": checkCostSelfTotal,
  9283. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9284. "laboratoryCostTotal": laboratoryCostTotal,
  9285. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9286. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9287. "treatCostTotal": treatCostTotal,
  9288. "treatCostSelfTotal": treatCostSelfTotal,
  9289. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9290. "doctor_info": doctor_info,
  9291. "doctor_code": adminRole_two.DoctorCode,
  9292. "doctor_name": doctor_name,
  9293. "health_card_no": order.PsnNo,
  9294. "department": departments.Name,
  9295. "yiliao_leibie": yiliao_leibie,
  9296. "after_money": order.AccountPrice,
  9297. "patient": patient,
  9298. "org_name": miConfig.OrgName,
  9299. "org_code": miConfig.Code,
  9300. "order_number": order.Number,
  9301. "his_hospital": his_hospital,
  9302. "his": his,
  9303. "dia_config": dia_config,
  9304. //"check_order_info": cus_slice,
  9305. })
  9306. }
  9307. }
  9308. }
  9309. func (c *HisApiController) CheckTreatment() {
  9310. patient_id, _ := c.GetInt64("patient_id")
  9311. id_card_no := c.GetString("id_card_no")
  9312. insutype := c.GetString("insutype")
  9313. med_type := c.GetString("med_type")
  9314. admin_user_id, _ := c.GetInt64("admin_user_id")
  9315. adminUser := c.GetAdminUserInfo()
  9316. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9317. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9318. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9319. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9320. if miConfig.MdtrtareaAdmvs == "421300" {
  9321. var res ResultTwo
  9322. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9323. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9324. "&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)
  9325. resp, requestErr := http.Get(api)
  9326. if requestErr != nil {
  9327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9328. return
  9329. }
  9330. body, ioErr := ioutil.ReadAll(resp.Body)
  9331. if ioErr != nil {
  9332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9334. return
  9335. }
  9336. var respJSON map[string]interface{}
  9337. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9343. result, _ := json.Marshal(respJSON)
  9344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9345. utils.ErrorLog("解析失败:%v", err)
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9347. return
  9348. }
  9349. if res.Infcode == 0 {
  9350. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9351. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9353. resp, requestErr := http.Get(api)
  9354. if requestErr != nil {
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. body, ioErr := ioutil.ReadAll(resp.Body)
  9359. if ioErr != nil {
  9360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. var respJSON map[string]interface{}
  9365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9368. return
  9369. }
  9370. var res Result2001
  9371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9372. result2, _ := json.Marshal(respJSON)
  9373. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9374. utils.ErrorLog("解析失败:%v", err)
  9375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9376. return
  9377. }
  9378. if res.Infcode == 0 {
  9379. c.ServeSuccessJSON(map[string]interface{}{
  9380. "msg": res.Output.Trtinfo,
  9381. })
  9382. }
  9383. } else {
  9384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9385. return
  9386. }
  9387. } else {
  9388. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9389. var dat map[string]interface{}
  9390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9391. fmt.Println(dat)
  9392. } else {
  9393. fmt.Println(err)
  9394. }
  9395. userJSONBytes, _ := json.Marshal(dat)
  9396. var res ResultTwo
  9397. var res10265 ResultTwo10265
  9398. if miConfig.Code == "H15049901371" {
  9399. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9400. utils.ErrorLog("解析失败:%v", err)
  9401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9402. return
  9403. }
  9404. res.ErrMsg = res10265.ErrMsg
  9405. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9406. res.Infcode = infocode
  9407. res.Output = res10265.Output
  9408. res.InfRefmsgid = res10265.InfRefmsgid
  9409. } else {
  9410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9411. utils.ErrorLog("解析失败:%v", err)
  9412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9413. return
  9414. }
  9415. }
  9416. var user_name string
  9417. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9418. if role.ID == 0 {
  9419. user_name = "xxx"
  9420. } else {
  9421. user_name = role.UserName
  9422. }
  9423. baseParams := models.BaseParams{
  9424. SecretKey: miConfig.SecretKey,
  9425. FixmedinsCode: miConfig.Code,
  9426. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9427. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9428. OrgName: miConfig.OrgName,
  9429. Doctor: user_name,
  9430. }
  9431. if config.IsOpen == 1 {
  9432. if miConfig.Code == "H15049901371" {
  9433. if med_type == "14" {
  9434. if insutype == "390" {
  9435. med_type = "9933"
  9436. } else if insutype == "310" {
  9437. med_type = "990502"
  9438. }
  9439. } else if med_type == "11" {
  9440. med_type = "11"
  9441. }
  9442. }
  9443. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9444. var dat map[string]interface{}
  9445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9446. fmt.Println(dat)
  9447. } else {
  9448. fmt.Println(err)
  9449. }
  9450. var res Result2001
  9451. var res10265 Result2001Org10265
  9452. if miConfig.Code == "H15049901371" {
  9453. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9454. utils.ErrorLog("解析失败:%v", err)
  9455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9456. return
  9457. }
  9458. res.ErrMsg = res10265.ErrMsg
  9459. res.Output = res10265.Output
  9460. res.InfRefmsgid = res10265.InfRefmsgid
  9461. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9462. res.Infcode = infocode
  9463. } else {
  9464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9465. utils.ErrorLog("解析失败:%v", err)
  9466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9467. return
  9468. }
  9469. }
  9470. if res.Infcode == 0 {
  9471. c.ServeSuccessJSON(map[string]interface{}{
  9472. "msg": res.Output.Trtinfo,
  9473. })
  9474. }
  9475. }
  9476. }
  9477. }
  9478. //func (c *HisApiController) PutRecord() {
  9479. // id, _ := c.GetInt64("id")
  9480. // record_time := c.GetString("record_time")
  9481. // timeLayout := "2006-01-02"
  9482. // loc, _ := time.LoadLocation("Local")
  9483. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9484. // if err != nil {
  9485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9486. // return
  9487. // }
  9488. // recordDateTime := theTime.Unix()
  9489. //
  9490. // adminInfo := c.GetAdminUserInfo()
  9491. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9492. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9493. //
  9494. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9495. //
  9496. // fmt.Println(miConfig.SecretKey)
  9497. //
  9498. // if patient == nil {
  9499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9500. // return
  9501. // }
  9502. // if len(patient.IdCardNo) == 0 {
  9503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9504. // return
  9505. // }
  9506. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9507. // if config.IsOpen == 1 {
  9508. // 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
  9509. // resp, requestErr := http.Get(api)
  9510. // if requestErr != nil {
  9511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9512. // return
  9513. // }
  9514. // defer resp.Body.Close()
  9515. // body, ioErr := ioutil.ReadAll(resp.Body)
  9516. // if ioErr != nil {
  9517. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. // return
  9520. // }
  9521. // var respJSON map[string]interface{}
  9522. //
  9523. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9524. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9526. // return
  9527. // }
  9528. //
  9529. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9530. // userJSONBytes, _ := json.Marshal(userJSON)
  9531. // var res ResultTwo
  9532. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9533. // utils.ErrorLog("解析失败:%v", err)
  9534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9535. // return
  9536. // }
  9537. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9538. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9539. // infoStr := string(Iinfos)
  9540. // idetinfoStr := string(Idetinfos)
  9541. //
  9542. // if res.Infcode == 0 {
  9543. // his := models.VMHisPatient{
  9544. // Status: 1,
  9545. // Ctime: time.Now().Unix(),
  9546. // Mtime: time.Now().Unix(),
  9547. // PsnNo: res.Output.Baseinfo.PsnNo,
  9548. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9549. // Certno: res.Output.Baseinfo.Certno,
  9550. // PsnName: res.Output.Baseinfo.PsnName,
  9551. // Gend: res.Output.Baseinfo.Gend,
  9552. // Naty: res.Output.Baseinfo.Naty,
  9553. // Brdy: res.Output.Baseinfo.Brdy,
  9554. // Age: res.Output.Baseinfo.Age,
  9555. // Iinfo: infoStr,
  9556. // Idetinfo: idetinfoStr,
  9557. // PatientId: patient.ID,
  9558. // RecordDate: theTime.Unix(),
  9559. // UserOrgId: adminInfo.CurrentOrgId,
  9560. // AdminUserId: adminInfo.AdminUser.Id,
  9561. // IsReturn: 1,
  9562. // }
  9563. //
  9564. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9565. // //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")
  9566. // //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")
  9567. //
  9568. // //var dat map[string]interface{}
  9569. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9570. // // fmt.Println(dat)
  9571. // //} else {
  9572. // // fmt.Println(err)
  9573. // //}
  9574. //
  9575. // var dat2 map[string]interface{}
  9576. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9577. // fmt.Println(dat2)
  9578. // } else {
  9579. // fmt.Println(err)
  9580. // }
  9581. //
  9582. // } else {
  9583. // adminUser := c.GetAdminUserInfo()
  9584. // errlog := &models.HisOrderError{
  9585. // UserOrgId: adminUser.CurrentOrgId,
  9586. // Ctime: time.Now().Unix(),
  9587. // Mtime: time.Now().Unix(),
  9588. // ErrMsg: res.ErrMsg,
  9589. // Status: 1,
  9590. // PatientId: id,
  9591. // RecordTime: recordDateTime,
  9592. // Stage: 1,
  9593. // }
  9594. // service.CreateErrMsgLog(errlog)
  9595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9596. // return
  9597. // }
  9598. // }
  9599. //
  9600. //}
  9601. //func (c *HisApiController) GetUploadDiag() {
  9602. // id, _ := c.GetInt64("id")
  9603. // record_time := c.GetString("record_time")
  9604. //
  9605. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9606. // sick_type, _ := c.GetInt64("sick_type")
  9607. // reg_type, _ := c.GetInt64("reg_type")
  9608. //
  9609. // timeLayout := "2006-01-02"
  9610. // loc, _ := time.LoadLocation("Local")
  9611. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9612. // if err != nil {
  9613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9614. // return
  9615. // }
  9616. //
  9617. // var patientPrescription models.HisPrescriptionInfo
  9618. // recordDateTime := theTime.Unix()
  9619. // adminInfo := c.GetAdminUserInfo()
  9620. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9621. //
  9622. // if patientPrescription.ID == 0 {
  9623. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9624. // }
  9625. //
  9626. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9627. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9628. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9629. // sickConfig, _ := service.FindSickById(sick_type)
  9630. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9631. //
  9632. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9633. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9634. // "&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 +
  9635. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9636. // resp2, requestErr2 := http.Get(api2)
  9637. // if requestErr2 != nil {
  9638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9639. // return
  9640. // }
  9641. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9642. // if ioErr2 != nil {
  9643. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9645. // return
  9646. // }
  9647. // var respJSON2 map[string]interface{}
  9648. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9649. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9651. // return
  9652. // }
  9653. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9654. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9655. //
  9656. // var res2 ResultSix
  9657. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9658. // utils.ErrorLog("解析失败:%v", err)
  9659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9660. // return
  9661. // }
  9662. // if res2.Infcode != 0 {
  9663. // adminUser := c.GetAdminUserInfo()
  9664. // errlog := &models.HisOrderError{
  9665. // UserOrgId: adminUser.CurrentOrgId,
  9666. // Ctime: time.Now().Unix(),
  9667. // Mtime: time.Now().Unix(),
  9668. // ErrMsg: res2.ErrMsg,
  9669. // Status: 1,
  9670. // PatientId: id,
  9671. // RecordTime: recordDateTime,
  9672. // Stage: 3,
  9673. // }
  9674. // service.CreateErrMsgLog(errlog)
  9675. //
  9676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9677. // return
  9678. // }
  9679. //
  9680. // c.ServeSuccessJSON(map[string]interface{}{
  9681. // "msg": "上传成功",
  9682. // })
  9683. //
  9684. //}
  9685. type QueryResult struct {
  9686. ID int64
  9687. Name string
  9688. Code string
  9689. List_type_code string
  9690. }
  9691. func (c *HisApiController) GetCheckCode() {
  9692. ids_str := c.GetString("ids")
  9693. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9694. ids_arr := strings.Split(ids_str, ",")
  9695. var queryResult []QueryResult
  9696. ids := make([]int64, 0)
  9697. for _, item := range ids_arr {
  9698. id, _ := strconv.ParseInt(item, 10, 64)
  9699. ids = append(ids, id)
  9700. }
  9701. if record_type == 1 {
  9702. drugs, _ := service.GetBatchDrugList(ids)
  9703. for _, item := range drugs {
  9704. result := QueryResult{
  9705. ID: item.ID,
  9706. Name: item.DrugName,
  9707. Code: item.MedicalInsuranceNumber,
  9708. List_type_code: "101",
  9709. }
  9710. queryResult = append(queryResult, result)
  9711. }
  9712. } else if record_type == 2 {
  9713. goods, _ := service.GetBatchGoodInformationList(ids)
  9714. for _, item := range goods {
  9715. result := QueryResult{
  9716. ID: item.ID,
  9717. Name: item.GoodName,
  9718. Code: item.MedicalInsuranceNumber,
  9719. List_type_code: "301",
  9720. }
  9721. queryResult = append(queryResult, result)
  9722. }
  9723. } else if record_type == 3 {
  9724. projects, _ := service.GetBathchMyPorjecgList(ids)
  9725. for _, item := range projects {
  9726. result := QueryResult{
  9727. ID: item.ID,
  9728. Name: item.ProjectName,
  9729. Code: item.MedicalCode,
  9730. List_type_code: "201",
  9731. }
  9732. queryResult = append(queryResult, result)
  9733. }
  9734. }
  9735. admin_user_id, _ := c.GetInt64("admin_user_id")
  9736. adminUser := c.GetAdminUserInfo()
  9737. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9739. var user_name string
  9740. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9741. if role.ID == 0 {
  9742. user_name = "xxx"
  9743. } else {
  9744. user_name = role.UserName
  9745. }
  9746. baseParams := &models.BaseParams{
  9747. SecretKey: miConfig.SecretKey,
  9748. FixmedinsCode: miConfig.Code,
  9749. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9750. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9751. OrgName: miConfig.OrgName,
  9752. Doctor: user_name,
  9753. }
  9754. if config.IsOpen == 1 {
  9755. for _, item := range queryResult {
  9756. var result string
  9757. if record_type == 1 {
  9758. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9759. } else if record_type == 2 {
  9760. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9761. } else if record_type == 3 {
  9762. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9763. }
  9764. var dat map[string]interface{}
  9765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9766. fmt.Println(dat)
  9767. } else {
  9768. fmt.Println(err)
  9769. }
  9770. userJSONBytes, _ := json.Marshal(dat)
  9771. var res ResultSix
  9772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9773. utils.ErrorLog("解析失败:%v", err)
  9774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9775. return
  9776. }
  9777. if res.Infcode == 0 {
  9778. if record_type == 1 {
  9779. service.UpdateBaseDrugById(item.ID)
  9780. } else if record_type == 2 {
  9781. service.UpdateGoodInformaitonByDetail(item.ID)
  9782. } else if record_type == 3 {
  9783. service.UpdateProjectById(item.ID)
  9784. }
  9785. c.ServeSuccessJSON(map[string]interface{}{
  9786. "failed_code": 0,
  9787. "msg": "目录对照成功",
  9788. })
  9789. } else {
  9790. c.ServeSuccessJSON(map[string]interface{}{
  9791. "failed_code": -10,
  9792. "msg": res.ErrMsg,
  9793. })
  9794. }
  9795. }
  9796. }
  9797. }
  9798. func (c *HisApiController) UnCheckCode() {
  9799. ids_str := c.GetString("ids")
  9800. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9801. admin_user_id, _ := c.GetInt64("admin_user_id")
  9802. ids_arr := strings.Split(ids_str, ",")
  9803. var queryResult []QueryResult
  9804. ids := make([]int64, 0)
  9805. for _, item := range ids_arr {
  9806. id, _ := strconv.ParseInt(item, 10, 64)
  9807. ids = append(ids, id)
  9808. }
  9809. if record_type == 1 {
  9810. drugs, _ := service.GetBatchDrugList(ids)
  9811. for _, item := range drugs {
  9812. result := QueryResult{
  9813. ID: item.ID,
  9814. Name: item.DrugName,
  9815. Code: item.MedicalInsuranceNumber,
  9816. List_type_code: "101",
  9817. }
  9818. queryResult = append(queryResult, result)
  9819. }
  9820. } else if record_type == 2 {
  9821. goods, _ := service.GetBatchGoodInformationList(ids)
  9822. for _, item := range goods {
  9823. result := QueryResult{
  9824. ID: item.ID,
  9825. Name: item.GoodName,
  9826. Code: item.MedicalInsuranceNumber,
  9827. List_type_code: "301",
  9828. }
  9829. queryResult = append(queryResult, result)
  9830. }
  9831. } else if record_type == 3 {
  9832. projects, _ := service.GetBathchMyPorjecgList(ids)
  9833. for _, item := range projects {
  9834. result := QueryResult{
  9835. ID: item.ID,
  9836. Name: item.ProjectName,
  9837. Code: item.MedicalCode,
  9838. List_type_code: "201",
  9839. }
  9840. queryResult = append(queryResult, result)
  9841. }
  9842. }
  9843. adminUser := c.GetAdminUserInfo()
  9844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9845. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9846. var user_name string
  9847. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9848. if role.ID == 0 {
  9849. user_name = "xxx"
  9850. } else {
  9851. user_name = role.UserName
  9852. }
  9853. baseParams := &models.BaseParams{
  9854. SecretKey: miConfig.SecretKey,
  9855. FixmedinsCode: miConfig.Code,
  9856. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9857. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9858. OrgName: miConfig.OrgName,
  9859. Doctor: user_name,
  9860. }
  9861. if config.IsOpen == 1 {
  9862. for _, item := range queryResult {
  9863. var result string
  9864. if record_type == 1 {
  9865. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9866. } else if record_type == 2 {
  9867. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9868. } else if record_type == 3 {
  9869. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9870. }
  9871. var dat2 map[string]interface{}
  9872. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9873. fmt.Println(dat2)
  9874. } else {
  9875. fmt.Println(err)
  9876. }
  9877. userJSONBytes, _ := json.Marshal(dat2)
  9878. var res ResultSix
  9879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9880. utils.ErrorLog("解析失败:%v", err)
  9881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9882. return
  9883. }
  9884. if res.Infcode == 0 {
  9885. if record_type == 1 {
  9886. service.UpdateDrugByIdDetail(item.ID)
  9887. } else if record_type == 2 {
  9888. service.UpdateGoodInfoById(item.ID)
  9889. } else if record_type == 3 {
  9890. service.UpdateMyProjectById(item.ID)
  9891. }
  9892. c.ServeSuccessJSON(map[string]interface{}{
  9893. "failed_code": 0,
  9894. "msg": "撤销目录对照成功",
  9895. })
  9896. } else {
  9897. c.ServeSuccessJSON(map[string]interface{}{
  9898. "failed_code": -10,
  9899. "msg": res.ErrMsg,
  9900. })
  9901. }
  9902. }
  9903. }
  9904. }
  9905. func (c *HisApiController) GetPatientInfo() {
  9906. id_card_no := c.GetString("id_card_no")
  9907. admin_user_id, _ := c.GetInt64("admin_user_id")
  9908. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9909. if patient.ID == 0 {
  9910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9911. return
  9912. }
  9913. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9915. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9916. if config.IsOpen == 1 {
  9917. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9918. var dat map[string]interface{}
  9919. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9920. fmt.Println(dat)
  9921. } else {
  9922. fmt.Println(err)
  9923. }
  9924. userJSONBytes, _ := json.Marshal(dat)
  9925. var res ResultTwo
  9926. var res10265 ResultTwo10265
  9927. if miConfig.Code == "H15049901371" {
  9928. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9929. utils.ErrorLog("解析失败:%v", err)
  9930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9931. return
  9932. }
  9933. res.ErrMsg = res10265.ErrMsg
  9934. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9935. res.Infcode = infocode
  9936. res.Output = res10265.Output
  9937. res.InfRefmsgid = res10265.InfRefmsgid
  9938. } else {
  9939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9940. utils.ErrorLog("解析失败:%v", err)
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. }
  9945. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9946. // utils.ErrorLog("解析失败:%v", err)
  9947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9948. // return
  9949. //}
  9950. if res.Infcode != 0 {
  9951. c.ServeSuccessJSON(map[string]interface{}{
  9952. "failed_code": -10,
  9953. "msg": res.ErrMsg,
  9954. })
  9955. } else {
  9956. c.ServeSuccessJSON(map[string]interface{}{
  9957. "failed_code": 0,
  9958. "info": res,
  9959. })
  9960. }
  9961. }
  9962. }
  9963. func (c *HisApiController) PsnPutOnRecord() {
  9964. record_type, _ := c.GetInt64("type")
  9965. patient_id, _ := c.GetInt64("patient_id")
  9966. admin_user_id, _ := c.GetInt64("admin_user_id")
  9967. start_time := c.GetString("start_time")
  9968. end_time := c.GetString("end_time")
  9969. adminUser := c.GetAdminUserInfo()
  9970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9971. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9972. var patients []*models.Patients
  9973. if record_type == 1 { //全部备案
  9974. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9975. patients = append(patients, patient...)
  9976. } else { //单个备案
  9977. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9978. patients = append(patients, patient)
  9979. }
  9980. var user_name string
  9981. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9982. if role.ID == 0 {
  9983. user_name = "xxx"
  9984. } else {
  9985. user_name = role.UserName
  9986. }
  9987. if config.IsOpen == 1 {
  9988. for _, item := range patients {
  9989. 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
  9990. resp, requestErr := http.Get(api)
  9991. if requestErr != nil {
  9992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. return
  9994. }
  9995. defer resp.Body.Close()
  9996. body, ioErr := ioutil.ReadAll(resp.Body)
  9997. if ioErr != nil {
  9998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. return
  10001. }
  10002. var respJSON map[string]interface{}
  10003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10006. return
  10007. }
  10008. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10009. userJSONBytes, _ := json.Marshal(userJSON)
  10010. var res ResultTwo
  10011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10012. utils.ErrorLog("解析失败:%v", err)
  10013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10014. return
  10015. }
  10016. if res.Infcode == 0 {
  10017. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10018. var dat map[string]interface{}
  10019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10020. fmt.Println(dat)
  10021. } else {
  10022. fmt.Println(err)
  10023. }
  10024. userJSONBytes, _ := json.Marshal(dat)
  10025. var res2 ResultThirteen
  10026. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. if res2.Infcode == 0 {
  10032. psnResult := &models.GdybPsnRecord{
  10033. UserOrgId: adminUser.CurrentOrgId,
  10034. PatientId: item.ID,
  10035. PsnNo: res.Output.Baseinfo.PsnNo,
  10036. Ctime: time.Now().Unix(),
  10037. Mtime: time.Now().Unix(),
  10038. Status: 1,
  10039. IsCancel: 1,
  10040. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10041. }
  10042. service.CreatePsnRecord(psnResult)
  10043. } else {
  10044. c.ServeSuccessJSON(map[string]interface{}{
  10045. "failed_code": -10,
  10046. "msg": res2.ErrMsg,
  10047. })
  10048. return
  10049. }
  10050. }
  10051. }
  10052. }
  10053. }
  10054. func (c *HisApiController) PsnUnPutOnRecord() {
  10055. id, _ := c.GetInt64("id")
  10056. //record_type, _ := c.GetInt64("type")
  10057. admin_user_id, _ := c.GetInt64("admin_user_id")
  10058. adminUser := c.GetAdminUserInfo()
  10059. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10060. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10061. var user_name string
  10062. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10063. if role.ID == 0 {
  10064. user_name = "xxx"
  10065. } else {
  10066. user_name = role.UserName
  10067. }
  10068. psn_record, _ := service.GetPsnRecordById(id)
  10069. if psn_record.ID == 0 {
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10071. return
  10072. }
  10073. if config.IsOpen == 1 {
  10074. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10075. var dat map[string]interface{}
  10076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10077. fmt.Println(dat)
  10078. } else {
  10079. fmt.Println(err)
  10080. }
  10081. userJSONBytes, _ := json.Marshal(dat)
  10082. var res ResultFourteen
  10083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10084. utils.ErrorLog("解析失败:%v", err)
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10086. return
  10087. }
  10088. if res.Infcode == 0 {
  10089. psn_record.IsCancel = 2
  10090. service.CreatePsnRecord(&psn_record)
  10091. } else {
  10092. c.ServeSuccessJSON(map[string]interface{}{
  10093. "failed_code": -10,
  10094. "msg": res.ErrMsg,
  10095. })
  10096. return
  10097. }
  10098. }
  10099. }
  10100. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10101. patient_id, _ := c.GetInt64("patient_id")
  10102. insutype_two := c.GetString("insutype")
  10103. psn_no := c.GetString("psn_no")
  10104. doctor_id, _ := c.GetInt64("doctor_id")
  10105. sick_id, _ := c.GetInt64("sick_id")
  10106. department_id, _ := c.GetInt64("department_id")
  10107. start_time := c.GetString("start_time")
  10108. end_time := c.GetString("end_time")
  10109. check_time := c.GetString("check_time")
  10110. adminUser := c.GetAdminUserInfo()
  10111. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10113. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10114. sick, _ := service.FindSickById(sick_id)
  10115. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10116. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10117. var res ResultTwo
  10118. var res10265 ResultTwo10265
  10119. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10120. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10121. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10122. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10123. "&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
  10124. resp, requestErr := http.Get(api)
  10125. if requestErr != nil {
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. return
  10128. }
  10129. body, ioErr := ioutil.ReadAll(resp.Body)
  10130. if ioErr != nil {
  10131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. return
  10134. }
  10135. var respJSON map[string]interface{}
  10136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10139. return
  10140. }
  10141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10142. result, _ := json.Marshal(respJSON)
  10143. fmt.Println("log")
  10144. fmt.Println(string(result))
  10145. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10146. utils.ErrorLog("解析失败:%v", err)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. return
  10149. }
  10150. res.ErrMsg = res10265.ErrMsg
  10151. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10152. res.Infcode = infocode
  10153. res.Output = res10265.Output
  10154. res.InfRefmsgid = res10265.InfRefmsgid
  10155. } else {
  10156. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10157. if miConfig.Code == "H15049901371" {
  10158. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10159. utils.ErrorLog("解析失败:%v", err)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. res.ErrMsg = res10265.ErrMsg
  10164. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10165. res.Infcode = infocode
  10166. res.Output = res10265.Output
  10167. res.InfRefmsgid = res10265.InfRefmsgid
  10168. } else {
  10169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10170. utils.ErrorLog("解析失败:%v", err)
  10171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10172. return
  10173. }
  10174. }
  10175. }
  10176. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10177. infoStr := string(Iinfos)
  10178. var rf []*ResultFive
  10179. json.Unmarshal([]byte(infoStr), &rf)
  10180. var insuplc_admdvs string
  10181. var insutype string
  10182. var is390 int = 0
  10183. var is310 int = 0
  10184. var insutypes []*ResultFive
  10185. for _, item := range rf {
  10186. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10187. insutypes = append(insutypes, item)
  10188. }
  10189. }
  10190. if len(insutypes) == 1 {
  10191. insutype = insutypes[0].Insutype
  10192. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10193. } else {
  10194. for _, i := range insutypes {
  10195. if i.Insutype == "390" {
  10196. is390 = 1
  10197. }
  10198. if i.Insutype == "310" {
  10199. is310 = 1
  10200. }
  10201. }
  10202. }
  10203. if is390 == 1 {
  10204. insutype = "390"
  10205. }
  10206. if is310 == 1 {
  10207. insutype = "310"
  10208. }
  10209. if len(insutypes) == 2 {
  10210. insutype = insutype_two
  10211. }
  10212. if len(insutypes) == 0 {
  10213. insutype = "310"
  10214. }
  10215. insutype = insutype_two
  10216. fmt.Println(insutype)
  10217. for _, item := range rf {
  10218. fmt.Println(item.Insutype)
  10219. fmt.Println(insutype)
  10220. if item.Insutype == insutype {
  10221. fmt.Println(item.Insutype)
  10222. fmt.Println(insutype)
  10223. insuplc_admdvs = item.InsuplcAdmdvs
  10224. }
  10225. }
  10226. fmt.Println(insuplc_admdvs)
  10227. var res2 ResultThirteen
  10228. var res10265_2 ResultThirteen10265
  10229. if config.IsOpen == 1 {
  10230. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10231. } else {
  10232. 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)
  10233. var dat map[string]interface{}
  10234. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10235. fmt.Println(dat)
  10236. } else {
  10237. fmt.Println(err)
  10238. }
  10239. userJSONBytes, _ := json.Marshal(dat)
  10240. if miConfig.Code == "H15049901371" {
  10241. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10242. utils.ErrorLog("解析失败:%v", err)
  10243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10244. return
  10245. }
  10246. res2.ErrMsg = res10265_2.ErrMsg
  10247. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10248. res2.Infcode = infocode
  10249. res2.Output = res10265_2.Output
  10250. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10251. } else {
  10252. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10253. utils.ErrorLog("解析失败:%v", err)
  10254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10255. return
  10256. }
  10257. }
  10258. }
  10259. if res2.Infcode == 0 {
  10260. psnResult := &models.GdybPsnNcdsRecord{
  10261. UserOrgId: adminUser.CurrentOrgId,
  10262. PatientId: patient.ID,
  10263. PsnNo: psn_no,
  10264. DoctorId: doctor.AdminUserId,
  10265. DepartmentId: department_id,
  10266. SickType: sick_id,
  10267. Insutype: insutype,
  10268. Ctime: time.Now().Unix(),
  10269. Mtime: time.Now().Unix(),
  10270. Status: 1,
  10271. IsCancel: 1,
  10272. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10273. }
  10274. service.CreatePsnNCDSRecord(psnResult)
  10275. c.ServeSuccessJSON(map[string]interface{}{
  10276. "failed_code": 0,
  10277. "msg": "备案成功",
  10278. "result": psnResult,
  10279. })
  10280. } else {
  10281. c.ServeSuccessJSON(map[string]interface{}{
  10282. "failed_code": -10,
  10283. "msg": res2.ErrMsg,
  10284. })
  10285. return
  10286. }
  10287. }
  10288. }
  10289. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10290. id, _ := c.GetInt64("id")
  10291. admin_user_id, _ := c.GetInt64("admin_user_id")
  10292. adminUser := c.GetAdminUserInfo()
  10293. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10294. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10295. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10296. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10297. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10298. //var user_name string
  10299. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10300. //if role.ID == 0 {
  10301. // user_name = "xxx"
  10302. //} else {
  10303. // user_name = role.UserName
  10304. //}
  10305. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10306. if psn_record.ID == 0 {
  10307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10308. return
  10309. }
  10310. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10311. var res ResultTwo
  10312. var res10265 ResultTwo10265
  10313. if miConfig.Code == "H15049901371" {
  10314. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10315. utils.ErrorLog("解析失败:%v", err)
  10316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10317. return
  10318. }
  10319. res.ErrMsg = res10265.ErrMsg
  10320. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10321. res.Infcode = infocode
  10322. res.Output = res10265.Output
  10323. res.InfRefmsgid = res10265.InfRefmsgid
  10324. } else {
  10325. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10326. utils.ErrorLog("解析失败:%v", err)
  10327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10328. return
  10329. }
  10330. }
  10331. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10332. infoStr := string(Iinfos)
  10333. var rf []*ResultFive
  10334. json.Unmarshal([]byte(infoStr), &rf)
  10335. var insuplc_admdvs string
  10336. var insutype string
  10337. var is390 int = 0
  10338. var is310 int = 0
  10339. var insutypes []*ResultFive
  10340. for _, item := range rf {
  10341. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10342. insutypes = append(insutypes, item)
  10343. }
  10344. }
  10345. if len(insutypes) == 1 {
  10346. insutype = insutypes[0].Insutype
  10347. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10348. } else {
  10349. for _, i := range insutypes {
  10350. if i.Insutype == "390" {
  10351. is390 = 1
  10352. }
  10353. if i.Insutype == "310" {
  10354. is310 = 1
  10355. }
  10356. }
  10357. }
  10358. if is390 == 1 {
  10359. insutype = "390"
  10360. }
  10361. if is310 == 1 {
  10362. insutype = "310"
  10363. }
  10364. if len(insutypes) == 0 {
  10365. insutype = "310"
  10366. }
  10367. insutype = psn_record.Insutype
  10368. for _, item := range rf {
  10369. if item.Insutype == insutype {
  10370. insuplc_admdvs = item.InsuplcAdmdvs
  10371. }
  10372. }
  10373. if config.IsOpen == 1 {
  10374. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10375. var dat map[string]interface{}
  10376. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10377. fmt.Println(dat)
  10378. } else {
  10379. fmt.Println(err)
  10380. }
  10381. userJSONBytes, _ := json.Marshal(dat)
  10382. var res ResultFourteen
  10383. var res10265 ResultFourteen10265
  10384. if miConfig.Code == "H15049901371" {
  10385. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10386. utils.ErrorLog("解析失败:%v", err)
  10387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10388. return
  10389. }
  10390. res.ErrMsg = res10265.ErrMsg
  10391. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10392. res.Infcode = infocode
  10393. res.Output = res10265.Output
  10394. res.InfRefmsgid = res10265.InfRefmsgid
  10395. } else {
  10396. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10397. utils.ErrorLog("解析失败:%v", err)
  10398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10399. return
  10400. }
  10401. }
  10402. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10403. // utils.ErrorLog("解析失败:%v", err)
  10404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10405. // return
  10406. //}
  10407. if res.Infcode == 0 {
  10408. psn_record.IsCancel = 2
  10409. service.CreatePsnNCDSRecord(&psn_record)
  10410. c.ServeSuccessJSON(map[string]interface{}{
  10411. "failed_code": 0,
  10412. "msg": "撤销备案成功",
  10413. })
  10414. } else {
  10415. c.ServeSuccessJSON(map[string]interface{}{
  10416. "failed_code": -10,
  10417. "msg": res.ErrMsg,
  10418. })
  10419. return
  10420. }
  10421. }
  10422. }
  10423. func (c *HisApiController) TestTest() {
  10424. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10425. fmt.Println(patient.Iinfo)
  10426. }
  10427. type CustomData struct {
  10428. MsgId string
  10429. PsnNo string
  10430. Info string
  10431. }
  10432. func (c *HisApiController) ReversalData() {
  10433. var customData []*CustomData
  10434. custom := &CustomData{
  10435. MsgId: "H44022900158202103301714472004",
  10436. PsnNo: "44020000001101329945",
  10437. Info: "2207",
  10438. }
  10439. customData = append(customData, custom)
  10440. custom1 := &CustomData{
  10441. MsgId: "H4402290015820210330172057803",
  10442. PsnNo: "44020000001101161813",
  10443. Info: "2207",
  10444. }
  10445. customData = append(customData, custom1)
  10446. custom2 := &CustomData{
  10447. MsgId: "H44022900158202103301705198813",
  10448. PsnNo: "44190000133097375417",
  10449. Info: "2207",
  10450. }
  10451. customData = append(customData, custom2)
  10452. custom3 := &CustomData{
  10453. MsgId: "H44022900158202103301715524756",
  10454. PsnNo: "44020000001100187221",
  10455. Info: "2207",
  10456. }
  10457. customData = append(customData, custom3)
  10458. custom4 := &CustomData{
  10459. MsgId: "H44022900158202103301730376224",
  10460. PsnNo: "44020000001101959155",
  10461. Info: "2207",
  10462. }
  10463. customData = append(customData, custom4)
  10464. custom5 := &CustomData{
  10465. MsgId: "H44022900158202103301748008725",
  10466. PsnNo: "44020000001104246641",
  10467. Info: "2207",
  10468. }
  10469. customData = append(customData, custom5)
  10470. custom6 := &CustomData{
  10471. MsgId: "H44022900158202103301718096755",
  10472. PsnNo: "44020000001102211860",
  10473. Info: "2207",
  10474. }
  10475. customData = append(customData, custom6)
  10476. custom7 := &CustomData{
  10477. MsgId: "H44022900158202103301736551640",
  10478. PsnNo: "44020000001102687718",
  10479. Info: "2207",
  10480. }
  10481. customData = append(customData, custom7)
  10482. custom8 := &CustomData{
  10483. MsgId: "H44022900158202103301743097676",
  10484. PsnNo: "44020000001102127785",
  10485. Info: "2207",
  10486. }
  10487. customData = append(customData, custom8)
  10488. custom9 := &CustomData{
  10489. MsgId: "H44022900158202103301712304203",
  10490. PsnNo: "44020000001101518097",
  10491. Info: "2207",
  10492. }
  10493. customData = append(customData, custom9)
  10494. custom10 := &CustomData{
  10495. MsgId: "H44022900158202103301738448785",
  10496. PsnNo: "44020000001100500813",
  10497. Info: "2207",
  10498. }
  10499. customData = append(customData, custom10)
  10500. custom11 := &CustomData{
  10501. MsgId: "H44022900158202103301732455843",
  10502. PsnNo: "44020000001102690557",
  10503. Info: "2207",
  10504. }
  10505. customData = append(customData, custom11)
  10506. custom12 := &CustomData{
  10507. MsgId: "H44022900158202103301745421708",
  10508. PsnNo: "44020000001102211928",
  10509. Info: "2207",
  10510. }
  10511. customData = append(customData, custom12)
  10512. custom1212 := &CustomData{
  10513. MsgId: "H440229001582021033017351627",
  10514. PsnNo: "44020000001102481733",
  10515. Info: "2207",
  10516. }
  10517. customData = append(customData, custom1212)
  10518. custom13 := &CustomData{
  10519. MsgId: "H44022900158202103301740327951",
  10520. PsnNo: "44020000001103174866",
  10521. Info: "2207",
  10522. }
  10523. customData = append(customData, custom13)
  10524. custom14 := &CustomData{
  10525. MsgId: "H4402290015820210330174922668",
  10526. PsnNo: "44020000001102927272",
  10527. Info: "2207",
  10528. }
  10529. customData = append(customData, custom14)
  10530. custom15 := &CustomData{
  10531. MsgId: "H44022900158202103301752362273",
  10532. PsnNo: "44020000001102942890",
  10533. Info: "2207",
  10534. }
  10535. customData = append(customData, custom15)
  10536. custom16 := &CustomData{
  10537. MsgId: "H44022900158202103301751082917",
  10538. PsnNo: "44020000001101662162",
  10539. Info: "2207",
  10540. }
  10541. customData = append(customData, custom16)
  10542. custom17 := &CustomData{
  10543. MsgId: "H44022900158202103301754147728",
  10544. PsnNo: "44020000000229014511",
  10545. Info: "2207",
  10546. }
  10547. customData = append(customData, custom17)
  10548. adminUser := c.GetAdminUserInfo()
  10549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10550. for _, item := range customData {
  10551. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10552. fmt.Println(result)
  10553. }
  10554. }
  10555. //func (c *HisApiController) GetAllopatry() {
  10556. // year := c.GetString("year")
  10557. // month := c.GetString("month")
  10558. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10559. // adminUser := c.GetAdminUserInfo()
  10560. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10561. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10562. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10563. //
  10564. // var dat map[string]interface{}
  10565. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10566. // fmt.Println(dat)
  10567. // } else {
  10568. // fmt.Println(err)
  10569. // }
  10570. // userJSONBytes, _ := json.Marshal(dat)
  10571. // var res models.Result9001
  10572. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10573. // utils.ErrorLog("解析失败:%v", err)
  10574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10575. // return
  10576. // }
  10577. //
  10578. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10579. // var dat2 map[string]interface{}
  10580. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10581. // fmt.Println(dat)
  10582. // } else {
  10583. // fmt.Println(err)
  10584. // }
  10585. // userJSONBytes2, _ := json.Marshal(dat2)
  10586. // var res2 models.Result3260
  10587. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10588. // utils.ErrorLog("解析失败:%v", err)
  10589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10590. // return
  10591. // }
  10592. // if res2.Infcode == 0 {
  10593. // c.ServeSuccessJSON(map[string]interface{}{
  10594. // "list": res2.Output.Data,
  10595. // })
  10596. // return
  10597. // } else {
  10598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10599. // return
  10600. // }
  10601. //
  10602. //}
  10603. //func (c *HisApiController) ComfirmAllopatry() {
  10604. // year := c.GetString("year")
  10605. // month := c.GetString("month")
  10606. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10607. // adminUser := c.GetAdminUserInfo()
  10608. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10609. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10610. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10611. // var dat map[string]interface{}
  10612. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10613. // fmt.Println(dat)
  10614. // } else {
  10615. // fmt.Println(err)
  10616. // }
  10617. // userJSONBytes, _ := json.Marshal(dat)
  10618. // var res models.Result9001
  10619. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10620. // utils.ErrorLog("解析失败:%v", err)
  10621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10622. // return
  10623. // }
  10624. //
  10625. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10626. // var dat2 map[string]interface{}
  10627. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10628. // fmt.Println(dat)
  10629. // } else {
  10630. // fmt.Println(err)
  10631. // }
  10632. // userJSONBytes2, _ := json.Marshal(dat2)
  10633. // var res2 models.Result3260
  10634. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10635. // utils.ErrorLog("解析失败:%v", err)
  10636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10637. // return
  10638. // }
  10639. //
  10640. // if res2.Infcode == 0 {
  10641. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10642. // var dat map[string]interface{}
  10643. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10644. // fmt.Println(dat)
  10645. // } else {
  10646. // fmt.Println(err)
  10647. // }
  10648. // userJSONBytes, _ := json.Marshal(dat)
  10649. // var res3 models.Result3261
  10650. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10651. // utils.ErrorLog("解析失败:%v", err)
  10652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10653. // return
  10654. // }
  10655. //
  10656. // if res3.Infcode == 0 {
  10657. // record := &models.HisYidiClearRecord{
  10658. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10659. // Ctime: time.Now().Unix(),
  10660. // Mtime: time.Now().Unix(),
  10661. // Status: 1,
  10662. // MsgId: msgId,
  10663. // }
  10664. // service.SaveClearRecord(record)
  10665. // c.ServeSuccessJSON(map[string]interface{}{
  10666. // "msg": "提取成功",
  10667. // })
  10668. // }
  10669. // }
  10670. //}
  10671. func (c *HisApiController) RefundAllopatry() {
  10672. year := c.GetString("year")
  10673. month := c.GetString("month")
  10674. id, _ := c.GetInt64("id")
  10675. admin_user_id, _ := c.GetInt64("admin_user_id")
  10676. adminUser := c.GetAdminUserInfo()
  10677. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10678. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10679. record, _ := service.GetClearRecordById(id)
  10680. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10681. var dat map[string]interface{}
  10682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10683. fmt.Println(dat)
  10684. } else {
  10685. fmt.Println(err)
  10686. }
  10687. userJSONBytes, _ := json.Marshal(dat)
  10688. var empty ResultFourteen
  10689. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10690. utils.ErrorLog("解析失败:%v", err)
  10691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10692. return
  10693. }
  10694. if empty.Infcode == 0 {
  10695. c.ServeSuccessJSON(map[string]interface{}{
  10696. "msg": "撤销成功",
  10697. })
  10698. return
  10699. }
  10700. }
  10701. func (c *HisApiController) ReversalOtherData() {
  10702. var customData []*CustomData
  10703. custom := &CustomData{
  10704. MsgId: "H44022900158202103301714472004",
  10705. PsnNo: "44020000001101329945",
  10706. Info: "2208",
  10707. }
  10708. customData = append(customData, custom)
  10709. custom1 := &CustomData{
  10710. MsgId: "H4402290015820210330172057803",
  10711. PsnNo: "44020000001101161813",
  10712. Info: "2208",
  10713. }
  10714. customData = append(customData, custom1)
  10715. custom2 := &CustomData{
  10716. MsgId: "H44022900158202103301705198813",
  10717. PsnNo: "44190000133097375417",
  10718. Info: "2208",
  10719. }
  10720. customData = append(customData, custom2)
  10721. custom3 := &CustomData{
  10722. MsgId: "H44022900158202103301715524756",
  10723. PsnNo: "44020000001100187221",
  10724. Info: "2208",
  10725. }
  10726. customData = append(customData, custom3)
  10727. custom4 := &CustomData{
  10728. MsgId: "H44022900158202103301730376224",
  10729. PsnNo: "44020000001101959155",
  10730. Info: "2208",
  10731. }
  10732. customData = append(customData, custom4)
  10733. custom5 := &CustomData{
  10734. MsgId: "H44022900158202103301748008725",
  10735. PsnNo: "44020000001104246641",
  10736. Info: "2208",
  10737. }
  10738. customData = append(customData, custom5)
  10739. custom6 := &CustomData{
  10740. MsgId: "H44022900158202103301718096755",
  10741. PsnNo: "44020000001102211860",
  10742. Info: "2208",
  10743. }
  10744. customData = append(customData, custom6)
  10745. custom7 := &CustomData{
  10746. MsgId: "H44022900158202103301736551640",
  10747. PsnNo: "44020000001102687718",
  10748. Info: "2208",
  10749. }
  10750. customData = append(customData, custom7)
  10751. custom8 := &CustomData{
  10752. MsgId: "H44022900158202103301743097676",
  10753. PsnNo: "44020000001102127785",
  10754. Info: "2208",
  10755. }
  10756. customData = append(customData, custom8)
  10757. custom9 := &CustomData{
  10758. MsgId: "H44022900158202103301712304203",
  10759. PsnNo: "44020000001101518097",
  10760. Info: "2208",
  10761. }
  10762. customData = append(customData, custom9)
  10763. custom10 := &CustomData{
  10764. MsgId: "H44022900158202103301738448785",
  10765. PsnNo: "44020000001100500813",
  10766. Info: "2208",
  10767. }
  10768. customData = append(customData, custom10)
  10769. custom11 := &CustomData{
  10770. MsgId: "H44022900158202103301732455843",
  10771. PsnNo: "44020000001102690557",
  10772. Info: "2208",
  10773. }
  10774. customData = append(customData, custom11)
  10775. custom12 := &CustomData{
  10776. MsgId: "H44022900158202103301745421708",
  10777. PsnNo: "44020000001102211928",
  10778. Info: "2208",
  10779. }
  10780. customData = append(customData, custom12)
  10781. custom1212 := &CustomData{
  10782. MsgId: "H440229001582021033017351627",
  10783. PsnNo: "44020000001102481733",
  10784. Info: "2208",
  10785. }
  10786. customData = append(customData, custom1212)
  10787. custom13 := &CustomData{
  10788. MsgId: "H44022900158202103301740327951",
  10789. PsnNo: "44020000001103174866",
  10790. Info: "2208",
  10791. }
  10792. customData = append(customData, custom13)
  10793. custom14 := &CustomData{
  10794. MsgId: "H4402290015820210330174922668",
  10795. PsnNo: "44020000001102927272",
  10796. Info: "2208",
  10797. }
  10798. customData = append(customData, custom14)
  10799. custom15 := &CustomData{
  10800. MsgId: "H44022900158202103301752362273",
  10801. PsnNo: "44020000001102942890",
  10802. Info: "2208",
  10803. }
  10804. customData = append(customData, custom15)
  10805. custom16 := &CustomData{
  10806. MsgId: "H44022900158202103301751082917",
  10807. PsnNo: "44020000001101662162",
  10808. Info: "2208",
  10809. }
  10810. customData = append(customData, custom16)
  10811. custom17 := &CustomData{
  10812. MsgId: "H44022900158202103301754147728",
  10813. PsnNo: "44020000000229014511",
  10814. Info: "2208",
  10815. }
  10816. customData = append(customData, custom17)
  10817. adminUser := c.GetAdminUserInfo()
  10818. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10819. for _, item := range customData {
  10820. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10821. fmt.Println(result)
  10822. }
  10823. }
  10824. func PathExists(path string) (bool, error) {
  10825. _, err := os.Stat(path)
  10826. if err == nil {
  10827. return true, nil
  10828. }
  10829. if os.IsNotExist(err) {
  10830. return false, nil
  10831. }
  10832. return false, err
  10833. }
  10834. //创建文件夹
  10835. func Mkdir(dir string) {
  10836. // 创建文件夹
  10837. exist, err := PathExists(dir)
  10838. if err != nil {
  10839. fmt.Println(err.Error())
  10840. } else {
  10841. if exist {
  10842. fmt.Println(dir + "文件夹已存在!")
  10843. } else {
  10844. // 文件夹名称,权限
  10845. err := os.Mkdir(dir, os.ModePerm)
  10846. if err != nil {
  10847. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10848. } else {
  10849. fmt.Println(dir + "文件夹创建成功!")
  10850. }
  10851. }
  10852. }
  10853. }
  10854. //压缩文件
  10855. func Zip(srcFile string, destZip string) error {
  10856. zipfile, err := os.Create(destZip)
  10857. if err != nil {
  10858. return err
  10859. }
  10860. defer zipfile.Close()
  10861. archive := zip.NewWriter(zipfile)
  10862. defer archive.Close()
  10863. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10864. if err != nil {
  10865. return err
  10866. }
  10867. header, err := zip.FileInfoHeader(info)
  10868. if err != nil {
  10869. return err
  10870. }
  10871. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10872. // header.Name = path
  10873. if info.IsDir() {
  10874. header.Name += "/"
  10875. } else {
  10876. header.Method = zip.Deflate
  10877. }
  10878. writer, err := archive.CreateHeader(header)
  10879. if err != nil {
  10880. return err
  10881. }
  10882. if !info.IsDir() {
  10883. file, err := os.Open(path)
  10884. if err != nil {
  10885. return err
  10886. }
  10887. defer file.Close()
  10888. _, err = io.Copy(writer, file)
  10889. }
  10890. return err
  10891. })
  10892. return err
  10893. }
  10894. func ReadFile(filePath string) []byte {
  10895. f, err := os.Open(filePath)
  10896. if err != nil {
  10897. fmt.Println("read file fail", err)
  10898. return nil
  10899. }
  10900. defer f.Close()
  10901. fd, err := ioutil.ReadAll(f)
  10902. if err != nil {
  10903. fmt.Println("read to fd fail", err)
  10904. return nil
  10905. }
  10906. return fd
  10907. }
  10908. func saveLog(result string, request string, infno string, desc string) {
  10909. org_id, _ := beego.AppConfig.Int64("org_id")
  10910. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10911. dir := miConfig.OrgName + "日志"
  10912. utils.Mkdir(dir)
  10913. month := time.Unix(1557042972, 0).Format("1")
  10914. year := time.Now().Format("2006")
  10915. month = time.Now().Format("01")
  10916. day := time.Now().Format("02")
  10917. hour := time.Now().Format("15")
  10918. min := time.Now().Format("04")
  10919. sec := time.Now().Format("05")
  10920. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10921. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10922. file_name := file + ".txt"
  10923. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10924. exist, _ := utils.PathExists(file_path)
  10925. if exist { //存在
  10926. fmt.Println("存在")
  10927. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10928. if err != nil {
  10929. fmt.Println("read fail")
  10930. }
  10931. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10932. n, _ := f.Seek(0, 2)
  10933. _, err = f.WriteAt([]byte(content), n)
  10934. } else { //不存在
  10935. fmt.Println("文件不存在,创建文件")
  10936. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10937. defer f.Close()
  10938. if err != nil {
  10939. } else {
  10940. _, err = f.Write([]byte("记录日志"))
  10941. }
  10942. }
  10943. }
  10944. type Charset string
  10945. const (
  10946. UTF8 = Charset("UTF-8")
  10947. GB18030 = Charset("GB18030")
  10948. )
  10949. func ConvertToString(src string, srcCode string, tagCode string) string {
  10950. srcCoder := mahonia.NewDecoder(srcCode)
  10951. srcResult := srcCoder.ConvertString(src)
  10952. tagCoder := mahonia.NewDecoder(tagCode)
  10953. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10954. result := string(cdata)
  10955. return result
  10956. }
  10957. func (c *HisApiController) ReadEleCard() {
  10958. id_card_type, _ := c.GetInt64("id_card_type")
  10959. admin_user_id, _ := c.GetInt64("admin_user_id")
  10960. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10961. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10962. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10963. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10964. var api string
  10965. if miConfig.MdtrtareaAdmvs == "320921" {
  10966. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10967. "&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
  10968. fmt.Println(api)
  10969. } else {
  10970. 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 +
  10971. "&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)
  10972. }
  10973. resp, requestErr := http.Get(api)
  10974. if requestErr != nil {
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10976. return
  10977. }
  10978. body, ioErr := ioutil.ReadAll(resp.Body)
  10979. if ioErr != nil {
  10980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10982. return
  10983. }
  10984. var respJSON map[string]interface{}
  10985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10988. return
  10989. }
  10990. var status string
  10991. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10992. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10993. var token string
  10994. var res ResultTwo //1101结果
  10995. var res10265 ResultTwo10265 //1101结果
  10996. if status == "0" { //读卡成功
  10997. var card_info string //卡信息
  10998. var busi_card_info string
  10999. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11000. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11001. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11002. fmt.Println(card_info)
  11003. fmt.Println(busi_card_info)
  11004. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11005. result, _ := json.Marshal(respJSON)
  11006. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11007. utils.ErrorLog("解析失败:%v", err)
  11008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11009. return
  11010. }
  11011. res.ErrMsg = res10265.ErrMsg
  11012. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11013. res.Infcode = infocode
  11014. res.Output = res10265.Output
  11015. res.InfRefmsgid = res10265.InfRefmsgid
  11016. if res.Infcode == 0 {
  11017. c.ServeSuccessJSON(map[string]interface{}{
  11018. "number": token,
  11019. })
  11020. }
  11021. } else {
  11022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11023. return
  11024. }
  11025. } else { //读卡失败
  11026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11027. return
  11028. }
  11029. }
  11030. func DeleteExtraSpaceTwo(s string) string {
  11031. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11032. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11033. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11034. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11035. s2 := make([]byte, len(s1)) //定义字符数组切片
  11036. copy(s2, s1) //将字符串复制到切片
  11037. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11038. for len(spc_index) > 0 { //找到适配项
  11039. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11040. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11041. }
  11042. return string(s2)
  11043. }
  11044. func Remove0000(s string) string {
  11045. str := make([]rune, 0, len(s))
  11046. for _, v := range []rune(s) {
  11047. if v == 0 {
  11048. continue
  11049. }
  11050. str = append(str, v)
  11051. }
  11052. return string(str)
  11053. }
  11054. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11055. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11056. readCard := DllDef.MustFindProc("EcQuery")
  11057. pCardInfo := make([]byte, 8192)
  11058. pBusiCardInfo := make([]byte, 8192)
  11059. data := make(map[string]interface{})
  11060. //pData := make(map[string]interface{})
  11061. inputData := make(map[string]interface{})
  11062. inputData["orgId"] = code
  11063. inputData["businessType"] = "01101"
  11064. inputData["operatorId"] = operator_id
  11065. inputData["operatorName"] = operator_name
  11066. inputData["officeId"] = "001"
  11067. inputData["officeName"] = "血透室"
  11068. //
  11069. data["data"] = inputData
  11070. data["transType"] = "ec.query"
  11071. data["orgId"] = code
  11072. bytesData, _ := json.Marshal(data)
  11073. pCardInfo = bytesData
  11074. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11075. fmt.Println(ret2)
  11076. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11077. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11078. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11079. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11080. if ret2 != 0 {
  11081. return "", ""
  11082. }
  11083. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11084. }
  11085. func DeleteExtraSpace(s string) string {
  11086. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11087. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11088. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11089. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11090. s2 := make([]byte, len(s1)) //定义字符数组切片
  11091. copy(s2, s1) //将字符串复制到切片
  11092. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11093. for len(spc_index) > 0 { //找到适配项
  11094. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11095. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11096. }
  11097. return string(s2)
  11098. }