his_api_controller.go 477KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. type Result3101 struct {
  80. Infcode string `json:"infcode"`
  81. InfRefmsgid string `json:"inf_refmsgid"`
  82. RefmsgTime string `json:"refmsg_time"`
  83. RespondTime string `json:"respond_time"`
  84. Enctype string `json:"enctype"`
  85. Signtype string `json:"signtype"`
  86. ErrMsg string `json:"err_msg"`
  87. Output struct {
  88. Result []struct {
  89. JudgeResultDetailDtos []struct {
  90. VolaItemType string `json:"vola_item_type"`
  91. MdtrtID string `json:"mdtrt_id"`
  92. JrdID string `json:"jrd_id"`
  93. PatnID string `json:"patn_id"`
  94. RxID string `json:"rx_id"`
  95. VolaAmt interface{} `json:"vola_amt"`
  96. } `json:"judge_result_detail_dtos"`
  97. RuleID string `json:"rule_id"`
  98. VolaEvid string `json:"vola_evid"`
  99. MdtrtID string `json:"mdtrt_id"`
  100. RuleName string `json:"rule_name"`
  101. VolaAmtStas string `json:"vola_amt_stas"`
  102. JrID string `json:"jr_id"`
  103. PatnID string `json:"patn_id"`
  104. SevDeg string `json:"sev_deg"`
  105. VolaAmt float64 `json:"vola_amt"`
  106. VolaBhvrType string `json:"vola_bhvr_type"`
  107. VolaCont string `json:"vola_cont"`
  108. } `json:"result"`
  109. } `json:"output"`
  110. }
  111. func (c *HisApiController) Get9001() {
  112. adminUser := c.GetAdminUserInfo()
  113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  114. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  115. if miConfig.MdtrtareaAdmvs == "350500" {
  116. service.GetFjAuthorizationInfo(miConfig.Code)
  117. } else {
  118. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  119. var dat map[string]interface{}
  120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  121. fmt.Println(dat)
  122. } else {
  123. fmt.Println(err)
  124. }
  125. userJSONBytes, _ := json.Marshal(dat)
  126. var res models.Result9001
  127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  128. utils.ErrorLog("解析失败:%v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. }
  133. }
  134. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  135. adminUser := c.GetAdminUserInfo()
  136. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  137. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  139. //record_time := c.GetString("record_time")
  140. //trig_scen := c.GetString("trig_scen")
  141. timeLayout := "2006-01-02"
  142. loc, _ := time.LoadLocation("Local")
  143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  144. if err != nil {
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  146. return res
  147. }
  148. recordDateTime := theTime.Unix()
  149. var patientPrescription models.HisPrescriptionInfo
  150. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  151. //if patientPrescription.ID == 0 {
  152. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  153. //}
  154. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  155. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  156. //
  157. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  158. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  159. var pp models.PublicParams
  160. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  161. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  162. pp.FixmedinsName = miConfig.OrgName
  163. pp.FixmedinsCode = miConfig.Code
  164. pp.RequestUrl = miConfig.Url
  165. pp.Cainfo = miConfig.Cainfo
  166. pp.SecretKey = miConfig.SecretKey
  167. pp.AccessKey = miConfig.AccessKey
  168. pp.OpterName = roles.UserName
  169. var config []*models.HisXtDiagnoseConfig
  170. for _, item := range diagnosis_ids {
  171. id, _ := strconv.ParseInt(item, 10, 64)
  172. diagnosisConfig, _ := service.FindDiagnoseById(id)
  173. config = append(config, &diagnosisConfig)
  174. }
  175. var pd models.PatientDtos
  176. pd.PatnID = his.PsnNo
  177. pd.PatnName = his.Name
  178. pd.Gend = his.Gend
  179. pd.Brdy = his.Brdy
  180. pd.Poolarea = his.InsuplcAdmdvs
  181. pd.CurrMdtrtID = his.Number
  182. var fed models.FsiEncounterDtos
  183. fed.MdtrtID = his.Number
  184. fed.MedinsID = miConfig.Code
  185. fed.MedinsName = miConfig.OrgName
  186. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  187. fed.MedMdtrtType = "1"
  188. fed.MedinsType = "1"
  189. fed.MedinsLv = "11"
  190. tm := time.Unix(his.RecordDate, 0)
  191. s_tm := tm.Format("2006-01-02 15:04:05")
  192. fed.AdmDate = s_tm
  193. fed.DscgDate = s_tm
  194. fed.DscgMainDiseCodg = config[0].CountryCode
  195. fed.DscgMainDiseName = config[0].CountryContentName
  196. //诊断信息
  197. var fdds []*models.FsiDiagnoseDtos
  198. for index, item := range config {
  199. if index == 0 {
  200. var fdd models.FsiDiagnoseDtos
  201. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  202. fdd.InoutDiseType = "1"
  203. fdd.MaindiseFlag = "1"
  204. fdd.DiseDate = s_tm
  205. fdd.DiasSrtNo = "1"
  206. fdd.DiseName = item.CountryContentName
  207. fdd.DiseCodg = item.CountryCode
  208. fdds = append(fdds, &fdd)
  209. } else {
  210. var fdd models.FsiDiagnoseDtos
  211. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  212. fdd.InoutDiseType = "1"
  213. fdd.MaindiseFlag = "1"
  214. fdd.DiseDate = s_tm
  215. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  216. fdd.DiseName = item.CountryContentName
  217. fdd.DiseCodg = item.CountryCode
  218. fdds = append(fdds, &fdd)
  219. }
  220. }
  221. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  222. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  223. fed.AdmDeptName = department.Name
  224. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  225. fed.DscgDeptName = department.Name
  226. fed.MedMdtrtType = "1"
  227. fed.MedType = "11"
  228. //if his.Insutype == "390" {
  229. // fed.MedType = "1402"
  230. //} else {
  231. // fed.MedType = "9933"
  232. //}
  233. var orders []*models.FsiOrderDtos
  234. if trig_scen == "2" {
  235. //处方医嘱信息
  236. for _, item := range prescriptions {
  237. for _, subItem := range item.HisDoctorAdviceInfo {
  238. var order models.FsiOrderDtos
  239. order.RxID = strconv.FormatInt(item.ID, 10)
  240. order.Rxno = strconv.FormatInt(item.ID, 10)
  241. order.LongDrordFlag = "0"
  242. order.HilistType = "1"
  243. order.ChrgType = "1"
  244. order.DrordBhvr = "-"
  245. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  246. order.HosplistName = subItem.BaseDrugLib.DrugName
  247. order.HilistLv = "1"
  248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  249. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  250. order.HosplistName = subItem.BaseDrugLib.DrugName
  251. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  252. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  254. order.OwnpayAmt = ""
  255. order.SelfpayAmt = ""
  256. order.Spec = ""
  257. order.SpecUnt = ""
  258. order.DrordBegnDate = s_tm
  259. order.DrordStopDate = ""
  260. order.DrordDrCodg = "1"
  261. order.DrordDeptName = department.Name
  262. order.DrordDrCodg = "1"
  263. order.DrordDrName = doctor_info.UserName
  264. order.DrordDrProfttl = ""
  265. order.CurrDrordFlag = "1"
  266. orders = append(orders, &order)
  267. }
  268. for _, subItem := range item.HisPrescriptionProject {
  269. if subItem.Type == 2 {
  270. var order models.FsiOrderDtos
  271. order.RxID = strconv.FormatInt(item.ID, 10)
  272. order.Rxno = strconv.FormatInt(item.ID, 10)
  273. order.LongDrordFlag = "0"
  274. order.HilistType = "1"
  275. order.ChrgType = "1"
  276. order.DrordBhvr = "-"
  277. order.HilistCode = subItem.HisProject.MedicalCode
  278. order.HosplistName = subItem.HisProject.ProjectName
  279. order.HilistLv = "1"
  280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  281. order.HosplistCode = subItem.HisProject.MedicalCode
  282. order.HosplistName = subItem.HisProject.ProjectName
  283. order.Cnt = subItem.Count
  284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  287. order.OwnpayAmt = ""
  288. order.SelfpayAmt = ""
  289. order.Spec = ""
  290. order.SpecUnt = ""
  291. order.DrordBegnDate = s_tm
  292. order.DrordStopDate = ""
  293. order.DrordDrCodg = "1"
  294. order.DrordDeptName = department.Name
  295. order.DrordDrCodg = "1"
  296. order.DrordDrName = doctor_info.UserName
  297. order.DrordDrProfttl = ""
  298. order.CurrDrordFlag = "1"
  299. orders = append(orders, &order)
  300. }
  301. if subItem.Type == 3 {
  302. var order models.FsiOrderDtos
  303. order.RxID = strconv.FormatInt(item.ID, 10)
  304. order.Rxno = strconv.FormatInt(item.ID, 10)
  305. order.LongDrordFlag = "0"
  306. order.HilistType = "1"
  307. order.ChrgType = "1"
  308. order.DrordBhvr = "-"
  309. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  310. order.HosplistName = subItem.GoodInfo.GoodName
  311. order.HilistLv = "1"
  312. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  313. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  314. order.HosplistName = subItem.GoodInfo.GoodName
  315. order.Cnt = subItem.Count
  316. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  317. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  318. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  319. order.OwnpayAmt = ""
  320. order.SelfpayAmt = ""
  321. order.Spec = ""
  322. order.SpecUnt = ""
  323. order.DrordBegnDate = s_tm
  324. order.DrordStopDate = ""
  325. order.DrordDrCodg = "1"
  326. order.DrordDeptName = department.Name
  327. order.DrordDrCodg = "1"
  328. order.DrordDrName = doctor_info.UserName
  329. order.DrordDrProfttl = ""
  330. order.CurrDrordFlag = "1"
  331. orders = append(orders, &order)
  332. }
  333. }
  334. }
  335. //处方医嘱信息
  336. }
  337. fed.MatnStas = "0"
  338. fed.MedfeeSumamt = "0"
  339. fed.OwnpayAmt = "0"
  340. fed.SelfpayAmt = "0"
  341. fed.AcctPayamt = "0"
  342. fed.MaAmt = "0"
  343. fed.HifpPayamt = "0"
  344. fed.SetlTotlnum = "1"
  345. fed.Insutype = his.Insutype
  346. fed.ReimFlag = "0"
  347. fed.OutSetlFlag = "0"
  348. var fopd []*models.FsiOperationDtosData
  349. data := make(map[string]interface{})
  350. data["fed"] = fed
  351. data["fdd"] = fdds
  352. data["fod"] = orders
  353. data["pd"] = pd
  354. data["pp"] = pp
  355. data["fopd"] = fopd
  356. data["trig_scen"] = trig_scen
  357. fmt.Println(data)
  358. fmt.Println(fed)
  359. fmt.Println(fdds)
  360. fmt.Println(orders)
  361. fmt.Println(pd)
  362. fmt.Println(pp)
  363. fmt.Println(fopd)
  364. client := &http.Client{}
  365. bytesData, _ := json.Marshal(data)
  366. var req *http.Request
  367. if miConfig.MdtrtareaAdmvs == "320921" {
  368. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  369. } else {
  370. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  371. }
  372. resp, _ := client.Do(req)
  373. defer resp.Body.Close()
  374. body, ioErr := ioutil.ReadAll(resp.Body)
  375. if ioErr != nil {
  376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return res
  379. }
  380. var respJSON map[string]interface{}
  381. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  384. return res
  385. }
  386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  387. result, _ := json.Marshal(respJSON)
  388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  389. utils.ErrorLog("解析失败:%v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return res
  392. }
  393. return res
  394. }
  395. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  396. adminUser := c.GetAdminUserInfo()
  397. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  398. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  399. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  400. //record_time := c.GetString("record_time")
  401. //trig_scen := c.GetString("trig_scen")
  402. timeLayout := "2006-01-02"
  403. loc, _ := time.LoadLocation("Local")
  404. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  405. if err != nil {
  406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  407. return res
  408. }
  409. recordDateTime := theTime.Unix()
  410. var patientPrescription models.HisPrescriptionInfo
  411. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  412. if patientPrescription.ID == 0 {
  413. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  414. }
  415. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  416. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  417. //
  418. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  419. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  420. var pp models.PublicParams
  421. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  422. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  423. pp.FixmedinsName = miConfig.OrgName
  424. pp.FixmedinsCode = miConfig.Code
  425. pp.RequestUrl = miConfig.Url
  426. pp.Cainfo = miConfig.Cainfo
  427. pp.SecretKey = miConfig.SecretKey
  428. pp.AccessKey = miConfig.AccessKey
  429. pp.OpterName = roles.UserName
  430. var config []*models.HisXtDiagnoseConfig
  431. for _, item := range diagnosis_ids {
  432. id, _ := strconv.ParseInt(item, 10, 64)
  433. diagnosisConfig, _ := service.FindDiagnoseById(id)
  434. config = append(config, &diagnosisConfig)
  435. }
  436. var pd models.PatientDtos
  437. pd.PatnID = his.PsnNo
  438. pd.PatnName = his.Name
  439. pd.Gend = his.Gend
  440. pd.Brdy = his.Brdy
  441. pd.Poolarea = his.InsuplcAdmdvs
  442. pd.CurrMdtrtID = his.Number
  443. var fed models.FsiEncounterDtos
  444. fed.MdtrtID = his.Number
  445. fed.MedinsID = miConfig.Code
  446. fed.MedinsName = miConfig.OrgName
  447. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  448. fed.MedMdtrtType = "1"
  449. fed.MedinsType = "1"
  450. fed.MedinsLv = "11"
  451. tm := time.Unix(his.RecordDate, 0)
  452. s_tm := tm.Format("2006-01-02 15:04:05")
  453. fed.AdmDate = s_tm
  454. fed.DscgDate = s_tm
  455. fed.DscgMainDiseCodg = config[0].CountryCode
  456. fed.DscgMainDiseName = config[0].CountryContentName
  457. //诊断信息
  458. var fdds []*models.FsiDiagnoseDtos
  459. for index, item := range config {
  460. if index == 0 {
  461. var fdd models.FsiDiagnoseDtos
  462. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  463. fdd.InoutDiseType = "1"
  464. fdd.MaindiseFlag = "1"
  465. fdd.DiseDate = s_tm
  466. fdd.DiasSrtNo = "1"
  467. fdd.DiseName = item.CountryContentName
  468. fdd.DiseCodg = item.CountryCode
  469. fdds = append(fdds, &fdd)
  470. } else {
  471. var fdd models.FsiDiagnoseDtos
  472. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  473. fdd.InoutDiseType = "1"
  474. fdd.MaindiseFlag = "1"
  475. fdd.DiseDate = s_tm
  476. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  477. fdd.DiseName = item.CountryContentName
  478. fdd.DiseCodg = item.CountryCode
  479. fdds = append(fdds, &fdd)
  480. }
  481. }
  482. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  483. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  484. fed.AdmDeptName = department.Name
  485. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  486. fed.DscgDeptName = department.Name
  487. fed.MedMdtrtType = "1"
  488. fed.MedType = "11"
  489. //if his.Insutype == "390" {
  490. // fed.MedType = "1402"
  491. //} else {
  492. // fed.MedType = "9933"
  493. //}
  494. var orders []*models.FsiOrderDtos
  495. if trig_scen == "2" {
  496. //处方医嘱信息
  497. for _, item := range prescriptions {
  498. for _, subItem := range item.HisDoctorAdviceInfo {
  499. var order models.FsiOrderDtos
  500. order.RxID = strconv.FormatInt(item.ID, 10)
  501. order.Rxno = strconv.FormatInt(item.ID, 10)
  502. order.LongDrordFlag = "0"
  503. order.HilistType = "1"
  504. order.ChrgType = "1"
  505. order.DrordBhvr = "-"
  506. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  507. order.HosplistName = subItem.BaseDrugLib.DrugName
  508. order.HilistLv = "1"
  509. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  510. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  511. order.HosplistName = subItem.BaseDrugLib.DrugName
  512. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  513. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  514. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  515. order.OwnpayAmt = ""
  516. order.SelfpayAmt = ""
  517. order.Spec = ""
  518. order.SpecUnt = ""
  519. order.DrordBegnDate = s_tm
  520. order.DrordStopDate = ""
  521. order.DrordDrCodg = "1"
  522. order.DrordDeptName = department.Name
  523. order.DrordDrCodg = "1"
  524. order.DrordDrName = doctor_info.UserName
  525. order.DrordDrProfttl = ""
  526. order.CurrDrordFlag = "1"
  527. orders = append(orders, &order)
  528. }
  529. for _, subItem := range item.HisPrescriptionProject {
  530. if subItem.Type == 2 {
  531. var order models.FsiOrderDtos
  532. order.RxID = strconv.FormatInt(item.ID, 10)
  533. order.Rxno = strconv.FormatInt(item.ID, 10)
  534. order.LongDrordFlag = "0"
  535. order.HilistType = "1"
  536. order.ChrgType = "1"
  537. order.DrordBhvr = "-"
  538. order.HilistCode = subItem.HisProject.MedicalCode
  539. order.HosplistName = subItem.HisProject.ProjectName
  540. order.HilistLv = "1"
  541. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  542. order.HosplistCode = subItem.HisProject.MedicalCode
  543. order.HosplistName = subItem.HisProject.ProjectName
  544. order.Cnt = subItem.Count
  545. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  546. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  547. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  548. order.OwnpayAmt = ""
  549. order.SelfpayAmt = ""
  550. order.Spec = ""
  551. order.SpecUnt = ""
  552. order.DrordBegnDate = s_tm
  553. order.DrordStopDate = ""
  554. order.DrordDrCodg = "1"
  555. order.DrordDeptName = department.Name
  556. order.DrordDrCodg = "1"
  557. order.DrordDrName = doctor_info.UserName
  558. order.DrordDrProfttl = ""
  559. order.CurrDrordFlag = "1"
  560. orders = append(orders, &order)
  561. }
  562. if subItem.Type == 3 {
  563. var order models.FsiOrderDtos
  564. order.RxID = strconv.FormatInt(item.ID, 10)
  565. order.Rxno = strconv.FormatInt(item.ID, 10)
  566. order.LongDrordFlag = "0"
  567. order.HilistType = "1"
  568. order.ChrgType = "1"
  569. order.DrordBhvr = "-"
  570. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  571. order.HosplistName = subItem.GoodInfo.GoodName
  572. order.HilistLv = "1"
  573. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  574. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  575. order.HosplistName = subItem.GoodInfo.GoodName
  576. order.Cnt = subItem.Count
  577. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  578. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  579. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  580. order.OwnpayAmt = ""
  581. order.SelfpayAmt = ""
  582. order.Spec = ""
  583. order.SpecUnt = ""
  584. order.DrordBegnDate = s_tm
  585. order.DrordStopDate = ""
  586. order.DrordDrCodg = "1"
  587. order.DrordDeptName = department.Name
  588. order.DrordDrCodg = "1"
  589. order.DrordDrName = doctor_info.UserName
  590. order.DrordDrProfttl = ""
  591. order.CurrDrordFlag = "1"
  592. orders = append(orders, &order)
  593. }
  594. }
  595. }
  596. //处方医嘱信息
  597. }
  598. fed.MatnStas = "0"
  599. fed.MedfeeSumamt = "0"
  600. fed.OwnpayAmt = "0"
  601. fed.SelfpayAmt = "0"
  602. fed.AcctPayamt = "0"
  603. fed.MaAmt = "0"
  604. fed.HifpPayamt = "0"
  605. fed.SetlTotlnum = "1"
  606. fed.Insutype = his.Insutype
  607. fed.ReimFlag = "0"
  608. fed.OutSetlFlag = "0"
  609. var fopd []*models.FsiOperationDtosData
  610. data := make(map[string]interface{})
  611. data["fed"] = fed
  612. data["fdd"] = fdds
  613. data["fod"] = orders
  614. data["pd"] = pd
  615. data["pp"] = pp
  616. data["fopd"] = fopd
  617. data["trig_scen"] = trig_scen
  618. fmt.Println(data)
  619. fmt.Println(fed)
  620. fmt.Println(fdds)
  621. fmt.Println(orders)
  622. fmt.Println(pd)
  623. fmt.Println(pp)
  624. fmt.Println(fopd)
  625. client := &http.Client{}
  626. bytesData, _ := json.Marshal(data)
  627. var req *http.Request
  628. if miConfig.MdtrtareaAdmvs == "320921" {
  629. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  630. } else {
  631. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  632. }
  633. resp, _ := client.Do(req)
  634. defer resp.Body.Close()
  635. body, ioErr := ioutil.ReadAll(resp.Body)
  636. if ioErr != nil {
  637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  639. return res
  640. }
  641. var respJSON map[string]interface{}
  642. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  645. return res
  646. }
  647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  648. result, _ := json.Marshal(respJSON)
  649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  650. utils.ErrorLog("解析失败:%v", err)
  651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  652. return res
  653. }
  654. return res
  655. }
  656. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  657. ////patient_id, _ := c.GetInt64("patient_id")
  658. //order_id, _ := c.GetInt64("order_id")
  659. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  660. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  661. //trig_scen := c.GetString("trig_scen")
  662. adminUser := c.GetAdminUserInfo()
  663. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  664. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  665. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  666. record_time := c.GetString("record_time")
  667. order, _ := service.GetHisOrderByID(order_id)
  668. timeLayout := "2006-01-02"
  669. loc, _ := time.LoadLocation("Local")
  670. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  671. if err != nil {
  672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  673. return
  674. }
  675. recordDateTime := theTime.Unix()
  676. var patientPrescription models.HisPrescriptionInfo
  677. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  678. if patientPrescription.ID == 0 {
  679. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  680. }
  681. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  682. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  683. //
  684. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  685. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  686. var pp models.PublicParams
  687. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  688. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  689. pp.FixmedinsName = miConfig.OrgName
  690. pp.FixmedinsCode = miConfig.Code
  691. pp.RequestUrl = miConfig.Url
  692. pp.Cainfo = miConfig.Cainfo
  693. pp.SecretKey = miConfig.SecretKey
  694. pp.AccessKey = miConfig.AccessKey
  695. pp.OpterName = roles.UserName
  696. var config []*models.HisXtDiagnoseConfig
  697. for _, item := range diagnosis_ids {
  698. id, _ := strconv.ParseInt(item, 10, 64)
  699. diagnosisConfig, _ := service.FindDiagnoseById(id)
  700. config = append(config, &diagnosisConfig)
  701. }
  702. var pd models.PatientDtos
  703. pd.PatnID = his.PsnNo
  704. pd.PatnName = his.Name
  705. pd.Gend = his.Gend
  706. pd.Brdy = his.Brdy
  707. pd.Poolarea = his.InsuplcAdmdvs
  708. pd.CurrMdtrtID = his.Number
  709. var fed models.FsiEncounterDtos
  710. fed.MdtrtID = his.Number
  711. fed.MedinsID = miConfig.Code
  712. fed.MedinsName = miConfig.OrgName
  713. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  714. fed.MedMdtrtType = "1"
  715. fed.MedinsType = "1"
  716. fed.MedinsLv = "11"
  717. tm := time.Unix(his.RecordDate, 0)
  718. s_tm := tm.Format("2006-01-02 15:04:05")
  719. fed.AdmDate = s_tm
  720. fed.DscgDate = s_tm
  721. fed.DscgMainDiseCodg = config[0].CountryCode
  722. fed.DscgMainDiseName = config[0].CountryContentName
  723. //诊断信息
  724. var fdds []*models.FsiDiagnoseDtos
  725. for index, item := range config {
  726. if index == 0 {
  727. var fdd models.FsiDiagnoseDtos
  728. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  729. fdd.InoutDiseType = "1"
  730. fdd.MaindiseFlag = "1"
  731. fdd.DiseDate = s_tm
  732. fdd.DiasSrtNo = "1"
  733. fdd.DiseName = item.CountryContentName
  734. fdd.DiseCodg = item.CountryCode
  735. fdds = append(fdds, &fdd)
  736. } else {
  737. var fdd models.FsiDiagnoseDtos
  738. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  739. fdd.InoutDiseType = "1"
  740. fdd.MaindiseFlag = "1"
  741. fdd.DiseDate = s_tm
  742. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  743. fdd.DiseName = item.CountryContentName
  744. fdd.DiseCodg = item.CountryCode
  745. fdds = append(fdds, &fdd)
  746. }
  747. }
  748. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  749. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  750. fed.AdmDeptName = department.Name
  751. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  752. fed.DscgDeptName = department.Name
  753. fed.MedType = order.MedType
  754. //处方医嘱信息
  755. var orders []*models.FsiOrderDtos
  756. //for _, item := range prescriptions {
  757. // for _, subItem := range item.HisDoctorAdviceInfo {
  758. // var order models.FsiOrderDtos
  759. // order.RxID = strconv.FormatInt(item.ID, 10)
  760. // order.Rxno = strconv.FormatInt(item.ID, 10)
  761. // order.LongDrordFlag = "0"
  762. // order.HilistType = "1"
  763. // order.ChrgType = "1"
  764. // order.DrordBhvr = "-"
  765. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  766. // order.HosplistName = subItem.BaseDrugLib.DrugName
  767. // order.HilistLv = "1"
  768. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  769. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  770. // order.HosplistName = subItem.BaseDrugLib.DrugName
  771. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  772. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  773. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  774. // order.OwnpayAmt = ""
  775. // order.SelfpayAmt = ""
  776. // order.Spec = ""
  777. // order.SpecUnt = ""
  778. // order.DrordBegnDate = s_tm
  779. // order.DrordStopDate = ""
  780. // order.DrordDrCodg = "1"
  781. // order.DrordDeptName = department.Name
  782. // order.DrordDrCodg = "1"
  783. // order.DrordDrName = doctor_info.UserName
  784. // order.DrordDrProfttl = ""
  785. // order.CurrDrordFlag = "1"
  786. // orders = append(orders, &order)
  787. // }
  788. // for _, subItem := range item.HisPrescriptionProject {
  789. // if subItem.Type == 2 {
  790. // var order models.FsiOrderDtos
  791. // order.RxID = strconv.FormatInt(item.ID, 10)
  792. // order.Rxno = strconv.FormatInt(item.ID, 10)
  793. // order.LongDrordFlag = "0"
  794. // order.HilistType = "1"
  795. // order.ChrgType = "1"
  796. // order.DrordBhvr = "-"
  797. // order.HilistCode = subItem.HisProject.MedicalCode
  798. // order.HosplistName = subItem.HisProject.ProjectName
  799. // order.HilistLv = "1"
  800. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  801. // order.HosplistCode = subItem.HisProject.MedicalCode
  802. // order.HosplistName = subItem.HisProject.ProjectName
  803. // order.Cnt = subItem.Count
  804. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  805. //
  806. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  807. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  808. // order.OwnpayAmt = ""
  809. // order.SelfpayAmt = ""
  810. // order.Spec = ""
  811. // order.SpecUnt = ""
  812. // order.DrordBegnDate = s_tm
  813. // order.DrordStopDate = ""
  814. // order.DrordDrCodg = "1"
  815. // order.DrordDeptName = department.Name
  816. // order.DrordDrCodg = "1"
  817. // order.DrordDrName = doctor_info.UserName
  818. // order.DrordDrProfttl = ""
  819. // order.CurrDrordFlag = "1"
  820. // orders = append(orders, &order)
  821. //
  822. // }
  823. // if subItem.Type == 3 {
  824. //
  825. // var order models.FsiOrderDtos
  826. // order.RxID = strconv.FormatInt(item.ID, 10)
  827. // order.Rxno = strconv.FormatInt(item.ID, 10)
  828. // order.LongDrordFlag = "0"
  829. // order.HilistType = "1"
  830. // order.ChrgType = "1"
  831. // order.DrordBhvr = "-"
  832. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  833. // order.HosplistName = subItem.GoodInfo.GoodName
  834. // order.HilistLv = "1"
  835. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  836. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  837. // order.HosplistName = subItem.GoodInfo.GoodName
  838. // order.Cnt = subItem.Count
  839. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  840. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  841. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  842. // order.OwnpayAmt = ""
  843. // order.SelfpayAmt = ""
  844. // order.Spec = ""
  845. // order.SpecUnt = ""
  846. // order.DrordBegnDate = s_tm
  847. // order.DrordStopDate = ""
  848. // order.DrordDrCodg = "1"
  849. // order.DrordDeptName = department.Name
  850. // order.DrordDrCodg = "1"
  851. // order.DrordDrName = doctor_info.UserName
  852. // order.DrordDrProfttl = ""
  853. // order.CurrDrordFlag = "1"
  854. // orders = append(orders, &order)
  855. //
  856. // }
  857. // }
  858. //}
  859. for _, item := range prescriptions {
  860. for _, subItem := range item.HisDoctorAdviceInfo {
  861. var order models.FsiOrderDtos
  862. order.RxID = strconv.FormatInt(item.ID, 10)
  863. order.Rxno = strconv.FormatInt(item.ID, 10)
  864. order.LongDrordFlag = "0"
  865. order.HilistType = "1"
  866. order.ChrgType = "1"
  867. order.DrordBhvr = "-"
  868. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  869. order.HosplistName = subItem.BaseDrugLib.DrugName
  870. order.HilistLv = "1"
  871. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  872. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  873. order.HosplistName = subItem.BaseDrugLib.DrugName
  874. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  875. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  876. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  877. order.OwnpayAmt = ""
  878. order.SelfpayAmt = ""
  879. order.Spec = ""
  880. order.SpecUnt = ""
  881. order.DrordBegnDate = s_tm
  882. order.DrordStopDate = ""
  883. order.DrordDrCodg = "1"
  884. order.DrordDeptName = department.Name
  885. order.DrordDrCodg = "1"
  886. order.DrordDrName = doctor_info.UserName
  887. order.DrordDrProfttl = ""
  888. order.CurrDrordFlag = "1"
  889. orders = append(orders, &order)
  890. }
  891. for _, subItem := range item.HisPrescriptionProject {
  892. if subItem.Type == 2 {
  893. var order models.FsiOrderDtos
  894. order.RxID = strconv.FormatInt(item.ID, 10)
  895. order.Rxno = strconv.FormatInt(item.ID, 10)
  896. order.LongDrordFlag = "0"
  897. order.HilistType = "1"
  898. order.ChrgType = "1"
  899. order.DrordBhvr = "-"
  900. order.HilistCode = subItem.HisProject.MedicalCode
  901. order.HosplistName = subItem.HisProject.ProjectName
  902. order.HilistLv = "1"
  903. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  904. order.HosplistCode = subItem.HisProject.MedicalCode
  905. order.HosplistName = subItem.HisProject.ProjectName
  906. order.Cnt = subItem.Count
  907. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  908. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  909. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  910. order.OwnpayAmt = ""
  911. order.SelfpayAmt = ""
  912. order.Spec = ""
  913. order.SpecUnt = ""
  914. order.DrordBegnDate = s_tm
  915. order.DrordStopDate = ""
  916. order.DrordDrCodg = "1"
  917. order.DrordDeptName = department.Name
  918. order.DrordDrCodg = "1"
  919. order.DrordDrName = doctor_info.UserName
  920. order.DrordDrProfttl = ""
  921. order.CurrDrordFlag = "1"
  922. orders = append(orders, &order)
  923. }
  924. if subItem.Type == 3 {
  925. var order models.FsiOrderDtos
  926. order.RxID = strconv.FormatInt(item.ID, 10)
  927. order.Rxno = strconv.FormatInt(item.ID, 10)
  928. order.LongDrordFlag = "0"
  929. order.HilistType = "1"
  930. order.ChrgType = "1"
  931. order.DrordBhvr = "-"
  932. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  933. order.HosplistName = subItem.GoodInfo.GoodName
  934. order.HilistLv = "1"
  935. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  936. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  937. order.HosplistName = subItem.GoodInfo.GoodName
  938. order.Cnt = subItem.Count
  939. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  940. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  941. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  942. order.OwnpayAmt = ""
  943. order.SelfpayAmt = ""
  944. order.Spec = ""
  945. order.SpecUnt = ""
  946. order.DrordBegnDate = s_tm
  947. order.DrordStopDate = ""
  948. order.DrordDrCodg = "1"
  949. order.DrordDeptName = department.Name
  950. order.DrordDrCodg = "1"
  951. order.DrordDrName = doctor_info.UserName
  952. order.DrordDrProfttl = ""
  953. order.CurrDrordFlag = "1"
  954. orders = append(orders, &order)
  955. }
  956. }
  957. }
  958. //处方医嘱信息
  959. fed.MatnStas = "0"
  960. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  961. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  962. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  963. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  964. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  965. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  966. fed.SetlTotlnum = "1"
  967. fed.Insutype = his.Insutype
  968. fed.ReimFlag = "0"
  969. fed.OutSetlFlag = "0"
  970. var fopd []*models.FsiOperationDtosData
  971. data := make(map[string]interface{})
  972. data["fed"] = fed
  973. data["fdd"] = fdds
  974. data["fod"] = orders
  975. data["pd"] = pd
  976. data["pp"] = pp
  977. data["fopd"] = fopd
  978. data["trig_scen"] = trig_scen
  979. client := &http.Client{}
  980. bytesData, _ := json.Marshal(data)
  981. var req *http.Request
  982. if miConfig.MdtrtareaAdmvs == "320921" {
  983. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  984. } else {
  985. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  986. }
  987. resp, _ := client.Do(req)
  988. defer resp.Body.Close()
  989. body, ioErr := ioutil.ReadAll(resp.Body)
  990. if ioErr != nil {
  991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. return res
  994. }
  995. var respJSON map[string]interface{}
  996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  999. return res
  1000. }
  1001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1002. result, _ := json.Marshal(respJSON)
  1003. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1004. utils.ErrorLog("解析失败:%v", err)
  1005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1006. return res
  1007. }
  1008. return res
  1009. //手术操作集合
  1010. //手术操作集合
  1011. }
  1012. func (c *HisApiController) Check() {
  1013. psn_no := c.GetString("psn_no")
  1014. in := c.GetString("in")
  1015. mt := c.GetString("mt")
  1016. baseParams := models.BaseParams{
  1017. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1018. FixmedinsCode: "H15049901371",
  1019. InsuplcAdmdvs: "150499",
  1020. MdtrtareaAdmvs: "150499",
  1021. OrgName: "赤峰费森血液透析中心",
  1022. Doctor: "1111",
  1023. }
  1024. service.Gdyb2001(baseParams, psn_no, in, mt)
  1025. }
  1026. func (c *HisApiController) GetPsnNcdsInfo() {
  1027. admin_user_id, _ := c.GetInt64("admin_user_id")
  1028. patient_id, _ := c.GetInt64("patient_id")
  1029. id, _ := c.GetInt64("id")
  1030. adminUser := c.GetAdminUserInfo()
  1031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1032. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1033. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1034. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1035. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1036. //
  1037. //if psn_record.ID == 0 {
  1038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1039. // return
  1040. //}
  1041. var res Result5301
  1042. var res10265 Result5301For10265
  1043. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1044. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1045. var api string
  1046. if miConfig.MdtrtareaAdmvs == "320921" {
  1047. 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 +
  1048. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1049. } else {
  1050. 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 +
  1051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1052. }
  1053. resp, requestErr := http.Get(api)
  1054. if requestErr != nil {
  1055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1056. return
  1057. }
  1058. body, ioErr := ioutil.ReadAll(resp.Body)
  1059. if ioErr != nil {
  1060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1062. return
  1063. }
  1064. var respJSON map[string]interface{}
  1065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1068. return
  1069. }
  1070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1071. result, _ := json.Marshal(respJSON)
  1072. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1073. utils.ErrorLog("解析失败:%v", err)
  1074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1075. return
  1076. }
  1077. res.ErrMsg = res10265.ErrMsg
  1078. res.Output = res10265.Output
  1079. res.InfRefmsgid = res10265.InfRefmsgid
  1080. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1081. res.Infcode = infocode
  1082. } else {
  1083. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1084. var dat map[string]interface{}
  1085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1086. fmt.Println(dat)
  1087. } else {
  1088. fmt.Println(err)
  1089. }
  1090. userJSONBytes, _ := json.Marshal(dat)
  1091. if miConfig.Code == "H15049901371" {
  1092. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1093. utils.ErrorLog("解析失败:%v", err)
  1094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1095. return
  1096. }
  1097. res.InfRefmsgid = res10265.InfRefmsgid
  1098. res.Output = res10265.Output
  1099. res.ErrMsg = res10265.ErrMsg
  1100. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1101. res.Infcode = infocode
  1102. } else {
  1103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return
  1107. }
  1108. }
  1109. }
  1110. if res.Infcode == 0 {
  1111. c.ServeSuccessJSON(map[string]interface{}{
  1112. "result": res.Output.Result,
  1113. })
  1114. }
  1115. }
  1116. func (c *HisApiController) CheckInsutype() {
  1117. his_patient_id, _ := c.GetInt64("his_patient_id")
  1118. admin_user_id, _ := c.GetInt64("admin_user_id")
  1119. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1122. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1123. var dat map[string]interface{}
  1124. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1125. fmt.Println(dat)
  1126. } else {
  1127. fmt.Println(err)
  1128. }
  1129. userJSONBytes, _ := json.Marshal(dat)
  1130. var res Result90100
  1131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1132. utils.ErrorLog("解析失败:%v", err)
  1133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1134. return
  1135. }
  1136. if res.Infcode != 0 {
  1137. c.ServeSuccessJSON(map[string]interface{}{
  1138. "failed_code": -10,
  1139. "msg": res.ErrMsg,
  1140. })
  1141. return
  1142. } else {
  1143. fmt.Println(res)
  1144. }
  1145. }
  1146. func (c *HisApiController) CheckCardPWD() {
  1147. card_pwd := c.GetString("card_pwd")
  1148. his_patient_id, _ := c.GetInt64("his_patient_id")
  1149. admin_user_id, _ := c.GetInt64("admin_user_id")
  1150. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1152. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1153. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1154. bas := strings.Split(psn.CardInfo, "|")
  1155. basNumber := bas[2]
  1156. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1157. var dat map[string]interface{}
  1158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1159. fmt.Println(dat)
  1160. } else {
  1161. fmt.Println(err)
  1162. }
  1163. userJSONBytes, _ := json.Marshal(dat)
  1164. var res Result90991
  1165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1166. utils.ErrorLog("解析失败:%v", err)
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1168. return
  1169. }
  1170. if res.Infcode != 0 {
  1171. c.ServeSuccessJSON(map[string]interface{}{
  1172. "failed_code": -10,
  1173. "msg": res.ErrMsg,
  1174. })
  1175. return
  1176. } else {
  1177. if res.Output.Result.SscnoCheckStat == "0" {
  1178. var msg string
  1179. switch res.Output.Result.CardStat {
  1180. case "00":
  1181. msg = "未激活"
  1182. break
  1183. case "10":
  1184. msg = "激活"
  1185. break
  1186. case "20":
  1187. msg = "窗口挂失"
  1188. break
  1189. case "21":
  1190. msg = "电话挂失"
  1191. break
  1192. case "22":
  1193. msg = "单位网上申报挂失"
  1194. break
  1195. case "23":
  1196. msg = "保健办挂失"
  1197. break
  1198. case "24":
  1199. msg = "个人网上挂失"
  1200. break
  1201. case "25":
  1202. msg = "网上服务大厅挂失"
  1203. break
  1204. case "30":
  1205. msg = "注销"
  1206. break
  1207. case "40":
  1208. msg = "回收"
  1209. break
  1210. case "99":
  1211. msg = "制卡中(无效卡)"
  1212. break
  1213. }
  1214. c.ServeSuccessJSON(map[string]interface{}{
  1215. "failed_code": -10,
  1216. "msg": msg,
  1217. })
  1218. return
  1219. } else {
  1220. c.ServeSuccessJSON(map[string]interface{}{
  1221. "msg": "校验成功",
  1222. })
  1223. return
  1224. }
  1225. }
  1226. }
  1227. func (c *HisApiController) CheckCardPWDTwo() {
  1228. //card_pwd := c.GetString("card_pwd")
  1229. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1230. admin_user_id, _ := c.GetInt64("admin_user_id")
  1231. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1232. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1233. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1234. var dat map[string]interface{}
  1235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1236. fmt.Println(dat)
  1237. } else {
  1238. fmt.Println(err)
  1239. }
  1240. userJSONBytes, _ := json.Marshal(dat)
  1241. var res Result90991
  1242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1243. utils.ErrorLog("解析失败:%v", err)
  1244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1245. return
  1246. }
  1247. if res.Infcode != 0 {
  1248. c.ServeSuccessJSON(map[string]interface{}{
  1249. "failed_code": -10,
  1250. "msg": res.ErrMsg,
  1251. })
  1252. return
  1253. } else {
  1254. if res.Output.Result.SscnoCheckStat == "0" {
  1255. var msg string
  1256. switch res.Output.Result.CardStat {
  1257. case "00":
  1258. msg = "未激活"
  1259. break
  1260. case "10":
  1261. msg = "激活"
  1262. break
  1263. case "20":
  1264. msg = "窗口挂失"
  1265. break
  1266. case "21":
  1267. msg = "电话挂失"
  1268. break
  1269. case "22":
  1270. msg = "单位网上申报挂失"
  1271. break
  1272. case "23":
  1273. msg = "保健办挂失"
  1274. break
  1275. case "24":
  1276. msg = "个人网上挂失"
  1277. break
  1278. case "25":
  1279. msg = "网上服务大厅挂失"
  1280. break
  1281. case "30":
  1282. msg = "注销"
  1283. break
  1284. case "40":
  1285. msg = "回收"
  1286. break
  1287. case "99":
  1288. msg = "制卡中(无效卡)"
  1289. break
  1290. }
  1291. c.ServeSuccessJSON(map[string]interface{}{
  1292. "failed_code": -10,
  1293. "msg": msg,
  1294. })
  1295. return
  1296. } else {
  1297. c.ServeSuccessJSON(map[string]interface{}{
  1298. "msg": "校验成功",
  1299. })
  1300. return
  1301. }
  1302. }
  1303. }
  1304. type ELeCertData struct {
  1305. Data struct {
  1306. Extra string `json:"extra"`
  1307. IDNo string `json:"idNo"`
  1308. IDType string `json:"idType"`
  1309. EcToken string `json:"ecToken"`
  1310. InsuOrg string `json:"insuOrg"`
  1311. UserName string `json:"userName"`
  1312. EcIndexNo string `json:"ecIndexNo"`
  1313. Gender string `json:"gender"`
  1314. Birthday string `json:"birthday"`
  1315. Nationality string `json:"nationality"`
  1316. Email string `json:"email"`
  1317. } `json:"OutData"`
  1318. }
  1319. func (c *HisApiController) ReadCard() {
  1320. id_card_type, _ := c.GetInt64("id_card_type")
  1321. admin_user_id, _ := c.GetInt64("admin_user_id")
  1322. certificates, _ := c.GetInt64("certificates")
  1323. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1324. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1325. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1326. switch id_card_type {
  1327. case 1:
  1328. if miConfig.MdtrtareaAdmvs == "421300" {
  1329. var res ResultTwo
  1330. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1331. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1332. "&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)
  1333. resp, requestErr := http.Get(api)
  1334. if requestErr != nil {
  1335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1336. return
  1337. }
  1338. body, ioErr := ioutil.ReadAll(resp.Body)
  1339. if ioErr != nil {
  1340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1342. return
  1343. }
  1344. var respJSON map[string]interface{}
  1345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1348. return
  1349. }
  1350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1351. result, _ := json.Marshal(respJSON)
  1352. fmt.Println("log")
  1353. fmt.Println(string(result))
  1354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. return
  1358. }
  1359. if res.Infcode == 0 {
  1360. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1361. if err == gorm.ErrRecordNotFound {
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1363. return
  1364. } else if err != nil {
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1366. return
  1367. } else {
  1368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1370. infoStr := string(Iinfos)
  1371. idetinfoStr := string(Idetinfos)
  1372. psn := &models.HisPsn{
  1373. PsnNo: res.Output.Baseinfo.PsnNo,
  1374. Age: res.Output.Baseinfo.Age,
  1375. PatientId: patient.ID,
  1376. Certno: res.Output.Baseinfo.Certno,
  1377. Brdy: res.Output.Baseinfo.Brdy,
  1378. Gend: res.Output.Baseinfo.Gend,
  1379. Naty: res.Output.Baseinfo.Naty,
  1380. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1381. PsnName: res.Output.Baseinfo.PsnName,
  1382. Idetinfo: idetinfoStr,
  1383. Insuinfo: infoStr,
  1384. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1385. }
  1386. service.CreateHisPsn(psn)
  1387. c.ServeSuccessJSON(map[string]interface{}{
  1388. "patient": patient,
  1389. "number": res.Output.Baseinfo.Certno,
  1390. })
  1391. }
  1392. } else {
  1393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1394. return
  1395. }
  1396. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1397. var api string
  1398. if miConfig.MdtrtareaAdmvs == "320921" {
  1399. 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 +
  1400. "&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
  1401. fmt.Println(api)
  1402. } else {
  1403. 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 +
  1404. "&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)
  1405. }
  1406. resp, requestErr := http.Get(api)
  1407. if requestErr != nil {
  1408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1409. return
  1410. }
  1411. body, ioErr := ioutil.ReadAll(resp.Body)
  1412. if ioErr != nil {
  1413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. return
  1416. }
  1417. var respJSON map[string]interface{}
  1418. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1421. return
  1422. }
  1423. var status string
  1424. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1425. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1426. //console.log()
  1427. fmt.Println("type===")
  1428. fmt.Println(card_type)
  1429. var token string
  1430. var res ResultTwo //1101结果
  1431. var res10265 ResultTwo10265 //1101结果
  1432. var card_info string //卡信息
  1433. var busi_card_info string
  1434. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1435. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1436. if status == "0" { //读卡成功
  1437. if card_type == "1" {
  1438. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1439. result, _ := json.Marshal(respJSON)
  1440. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1441. utils.ErrorLog("解析失败:%v", err)
  1442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1443. return
  1444. }
  1445. res.ErrMsg = res10265.ErrMsg
  1446. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1447. res.Infcode = infocode
  1448. res.Output = res10265.Output
  1449. res.InfRefmsgid = res10265.InfRefmsgid
  1450. } else {
  1451. //var card_info string //卡信息
  1452. //var busi_card_info string
  1453. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1454. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1455. //fmt.Println(card_info)
  1456. //fmt.Println(busi_card_info)
  1457. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1458. result, _ := json.Marshal(respJSON)
  1459. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1460. utils.ErrorLog("解析失败:%v", err)
  1461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1462. return
  1463. }
  1464. res.ErrMsg = res10265.ErrMsg
  1465. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1466. res.Infcode = infocode
  1467. res.Output = res10265.Output
  1468. res.InfRefmsgid = res10265.InfRefmsgid
  1469. }
  1470. if res.Infcode == 0 {
  1471. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1472. if err == gorm.ErrRecordNotFound {
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1474. return
  1475. } else if err != nil {
  1476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1477. return
  1478. } else {
  1479. if card_type == "1" {
  1480. bas := strings.Split(card_info, "|")
  1481. basNumber := bas[2]
  1482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1484. infoStr := string(Iinfos)
  1485. idetinfoStr := string(Idetinfos)
  1486. psn := &models.HisPsn{
  1487. PsnNo: res.Output.Baseinfo.PsnNo,
  1488. Age: res.Output.Baseinfo.Age,
  1489. PatientId: patient.ID,
  1490. Certno: res.Output.Baseinfo.Certno,
  1491. Brdy: res.Output.Baseinfo.Brdy,
  1492. Gend: res.Output.Baseinfo.Gend,
  1493. Naty: res.Output.Baseinfo.Naty,
  1494. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1495. PsnName: res.Output.Baseinfo.PsnName,
  1496. Idetinfo: idetinfoStr,
  1497. Insuinfo: infoStr,
  1498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1499. CardInfo: card_info,
  1500. VerifyNumber: busi_card_info,
  1501. }
  1502. service.CreateHisPsn(psn)
  1503. var rf []*ResultFive
  1504. json.Unmarshal([]byte(infoStr), &rf)
  1505. var insutypes []*ResultFive
  1506. var insutype string
  1507. var is390 int = 0
  1508. var is310 int = 0
  1509. for _, item := range rf {
  1510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1511. insutypes = append(insutypes, item)
  1512. }
  1513. }
  1514. if len(insutypes) == 1 {
  1515. insutype = insutypes[0].Insutype
  1516. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1517. } else {
  1518. for _, i := range insutypes {
  1519. if i.Insutype == "390" {
  1520. is390 = 1
  1521. }
  1522. if i.Insutype == "310" {
  1523. is310 = 1
  1524. }
  1525. }
  1526. }
  1527. if is390 == 1 {
  1528. insutype = "390"
  1529. }
  1530. if is310 == 1 {
  1531. insutype = "310"
  1532. }
  1533. if len(insutypes) == 0 {
  1534. insutype = "310"
  1535. }
  1536. c.ServeSuccessJSON(map[string]interface{}{
  1537. "patient": patient,
  1538. "number": basNumber,
  1539. "insutype": insutype,
  1540. })
  1541. } else {
  1542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1544. infoStr := string(Iinfos)
  1545. idetinfoStr := string(Idetinfos)
  1546. psn := &models.HisPsn{
  1547. PsnNo: res.Output.Baseinfo.PsnNo,
  1548. Age: res.Output.Baseinfo.Age,
  1549. PatientId: patient.ID,
  1550. Certno: res.Output.Baseinfo.Certno,
  1551. Brdy: res.Output.Baseinfo.Brdy,
  1552. Gend: res.Output.Baseinfo.Gend,
  1553. Naty: res.Output.Baseinfo.Naty,
  1554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1555. PsnName: res.Output.Baseinfo.PsnName,
  1556. Idetinfo: idetinfoStr,
  1557. Insuinfo: infoStr,
  1558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1559. CardInfo: card_info,
  1560. VerifyNumber: token,
  1561. }
  1562. service.CreateHisPsn(psn)
  1563. c.ServeSuccessJSON(map[string]interface{}{
  1564. "patient": patient,
  1565. "number": token,
  1566. })
  1567. }
  1568. }
  1569. } else {
  1570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1571. return
  1572. }
  1573. } else { //读卡失败
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1575. return
  1576. }
  1577. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1578. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1579. cardnum = DeleteExtraSpaceTwo(cardnum)
  1580. cardCode = DeleteExtraSpaceTwo(cardCode)
  1581. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1582. name = DeleteExtraSpaceTwo(name)
  1583. errmsg = DeleteExtraSpaceTwo(errmsg)
  1584. cardnum = Remove0000(cardnum)
  1585. cardCode = Remove0000(cardCode)
  1586. id_card_no = Remove0000(id_card_no)
  1587. name = Remove0000(name)
  1588. errmsg = Remove0000(errmsg)
  1589. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1590. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1591. saveLog(result, requestLog, "1101", "获取人员信息")
  1592. fmt.Println(errMsgLog)
  1593. if len(errMsgLog) > 0 {
  1594. } else {
  1595. var dat map[string]interface{}
  1596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1597. fmt.Println(dat)
  1598. } else {
  1599. fmt.Println(err)
  1600. }
  1601. userJSONBytes, _ := json.Marshal(dat)
  1602. var res ResultTwo
  1603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1604. utils.ErrorLog("解析失败:%v", err)
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1606. return
  1607. }
  1608. res.ErrMsg = errMsgLog
  1609. if res.Infcode == 0 {
  1610. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1611. if err == gorm.ErrRecordNotFound {
  1612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1613. return
  1614. } else if err != nil {
  1615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1616. return
  1617. } else {
  1618. fmt.Println(res)
  1619. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1620. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1621. infoStr := string(Iinfos)
  1622. idetinfoStr := string(Idetinfos)
  1623. psn := &models.HisPsn{
  1624. PsnNo: res.Output.Baseinfo.PsnNo,
  1625. Age: res.Output.Baseinfo.Age,
  1626. PatientId: patient.ID,
  1627. Certno: res.Output.Baseinfo.Certno,
  1628. Brdy: res.Output.Baseinfo.Brdy,
  1629. Gend: res.Output.Baseinfo.Gend,
  1630. Naty: res.Output.Baseinfo.Naty,
  1631. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1632. PsnName: res.Output.Baseinfo.PsnName,
  1633. Idetinfo: idetinfoStr,
  1634. Insuinfo: infoStr,
  1635. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1636. CardInfo: basStr,
  1637. VerifyNumber: "",
  1638. }
  1639. service.CreateHisPsn(psn)
  1640. var rf []*ResultFive
  1641. json.Unmarshal([]byte(infoStr), &rf)
  1642. var insutypes []*ResultFive
  1643. var insutype string
  1644. var is390 int = 0
  1645. var is310 int = 0
  1646. for _, item := range rf {
  1647. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1648. insutypes = append(insutypes, item)
  1649. }
  1650. }
  1651. if len(insutypes) == 1 {
  1652. insutype = insutypes[0].Insutype
  1653. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1654. } else {
  1655. for _, i := range insutypes {
  1656. if i.Insutype == "390" {
  1657. is390 = 1
  1658. }
  1659. if i.Insutype == "310" {
  1660. is310 = 1
  1661. }
  1662. }
  1663. }
  1664. if is390 == 1 {
  1665. insutype = "390"
  1666. }
  1667. if is310 == 1 {
  1668. insutype = "310"
  1669. }
  1670. if len(insutypes) == 0 {
  1671. insutype = "310"
  1672. }
  1673. c.ServeSuccessJSON(map[string]interface{}{
  1674. "patient": patient,
  1675. "number": cardnum,
  1676. "insutype": insutype,
  1677. })
  1678. }
  1679. } else {
  1680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1681. return
  1682. }
  1683. }
  1684. } else {
  1685. if initFlag == 0 {
  1686. c.TestGetBasBaseInit()
  1687. }
  1688. basStr := c.GetBasBaseInfo()
  1689. if len(basStr) == 0 {
  1690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1691. return
  1692. }
  1693. fmt.Println(basStr)
  1694. bas := strings.Split(basStr, "|")
  1695. basNumber := bas[1]
  1696. fmt.Println(basNumber)
  1697. card_sn := bas[3]
  1698. fmt.Println(card_sn)
  1699. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1700. var dat map[string]interface{}
  1701. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1702. fmt.Println(dat)
  1703. } else {
  1704. fmt.Println(err)
  1705. }
  1706. userJSONBytes, _ := json.Marshal(dat)
  1707. var res ResultTwo
  1708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1709. utils.ErrorLog("解析失败:%v", err)
  1710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1711. return
  1712. }
  1713. if res.Infcode == 0 {
  1714. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1715. if err == gorm.ErrRecordNotFound {
  1716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1717. return
  1718. } else if err != nil {
  1719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1720. return
  1721. } else {
  1722. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1723. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1724. infoStr := string(Iinfos)
  1725. idetinfoStr := string(Idetinfos)
  1726. psn := &models.HisPsn{
  1727. PsnNo: res.Output.Baseinfo.PsnNo,
  1728. Age: res.Output.Baseinfo.Age,
  1729. PatientId: patient.ID,
  1730. Certno: res.Output.Baseinfo.Certno,
  1731. Brdy: res.Output.Baseinfo.Brdy,
  1732. Gend: res.Output.Baseinfo.Gend,
  1733. Naty: res.Output.Baseinfo.Naty,
  1734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1735. PsnName: res.Output.Baseinfo.PsnName,
  1736. Idetinfo: idetinfoStr,
  1737. Insuinfo: infoStr,
  1738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1739. CardInfo: basStr,
  1740. VerifyNumber: "",
  1741. }
  1742. service.CreateHisPsn(psn)
  1743. c.ServeSuccessJSON(map[string]interface{}{
  1744. "patient": patient,
  1745. "number": basNumber,
  1746. })
  1747. }
  1748. } else {
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1750. return
  1751. }
  1752. break
  1753. }
  1754. case 2:
  1755. SFZStr := c.GetSFZBaseInfo()
  1756. id_card_str := strings.Split(SFZStr, "^")
  1757. id_card_number := id_card_str[0]
  1758. card_sn := ""
  1759. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1760. var dat map[string]interface{}
  1761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1762. fmt.Println(dat)
  1763. } else {
  1764. fmt.Println(err)
  1765. }
  1766. userJSONBytes, _ := json.Marshal(dat)
  1767. var res ResultTwo
  1768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1769. utils.ErrorLog("解析失败:%v", err)
  1770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1771. return
  1772. }
  1773. if res.Infcode == 0 {
  1774. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1775. if err == gorm.ErrRecordNotFound {
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1777. return
  1778. } else if err != nil {
  1779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1780. return
  1781. } else {
  1782. c.ServeSuccessJSON(map[string]interface{}{
  1783. "patient": patient,
  1784. "number": id_card_number,
  1785. })
  1786. }
  1787. } else {
  1788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1789. return
  1790. }
  1791. break
  1792. case 3:
  1793. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1794. var api string
  1795. if miConfig.MdtrtareaAdmvs == "320921" {
  1796. 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 +
  1797. "&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
  1798. fmt.Println(api)
  1799. } else {
  1800. 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 +
  1801. "&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)
  1802. }
  1803. resp, requestErr := http.Get(api)
  1804. if requestErr != nil {
  1805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1806. return
  1807. }
  1808. body, ioErr := ioutil.ReadAll(resp.Body)
  1809. if ioErr != nil {
  1810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. return
  1813. }
  1814. var respJSON map[string]interface{}
  1815. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1818. return
  1819. }
  1820. var status string
  1821. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1822. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1823. var token string
  1824. var res ResultTwo //1101结果
  1825. var res10265 ResultTwo10265 //1101结果
  1826. var card_info string //卡信息
  1827. var busi_card_info string
  1828. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1829. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1830. if status == "0" { //读卡成功
  1831. if card_type == "1" {
  1832. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1833. result, _ := json.Marshal(respJSON)
  1834. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1835. utils.ErrorLog("解析失败:%v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. res.ErrMsg = res10265.ErrMsg
  1840. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1841. res.Infcode = infocode
  1842. res.Output = res10265.Output
  1843. res.InfRefmsgid = res10265.InfRefmsgid
  1844. } else {
  1845. //var card_info string //卡信息
  1846. //var busi_card_info string
  1847. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1848. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1849. //fmt.Println(card_info)
  1850. //fmt.Println(busi_card_info)
  1851. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1852. result, _ := json.Marshal(respJSON)
  1853. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1854. utils.ErrorLog("解析失败:%v", err)
  1855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1856. return
  1857. }
  1858. res.ErrMsg = res10265.ErrMsg
  1859. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1860. res.Infcode = infocode
  1861. res.Output = res10265.Output
  1862. res.InfRefmsgid = res10265.InfRefmsgid
  1863. }
  1864. if res.Infcode == 0 {
  1865. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1866. if err == gorm.ErrRecordNotFound {
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1868. return
  1869. } else if err != nil {
  1870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1871. return
  1872. } else {
  1873. if card_type == "1" {
  1874. bas := strings.Split(card_info, "|")
  1875. basNumber := bas[2]
  1876. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1877. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1878. infoStr := string(Iinfos)
  1879. idetinfoStr := string(Idetinfos)
  1880. psn := &models.HisPsn{
  1881. PsnNo: res.Output.Baseinfo.PsnNo,
  1882. Age: res.Output.Baseinfo.Age,
  1883. PatientId: patient.ID,
  1884. Certno: res.Output.Baseinfo.Certno,
  1885. Brdy: res.Output.Baseinfo.Brdy,
  1886. Gend: res.Output.Baseinfo.Gend,
  1887. Naty: res.Output.Baseinfo.Naty,
  1888. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1889. PsnName: res.Output.Baseinfo.PsnName,
  1890. Idetinfo: idetinfoStr,
  1891. Insuinfo: infoStr,
  1892. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1893. CardInfo: card_info,
  1894. VerifyNumber: busi_card_info,
  1895. }
  1896. service.CreateHisPsn(psn)
  1897. c.ServeSuccessJSON(map[string]interface{}{
  1898. "patient": patient,
  1899. "number": basNumber,
  1900. })
  1901. } else {
  1902. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1903. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1904. infoStr := string(Iinfos)
  1905. idetinfoStr := string(Idetinfos)
  1906. psn := &models.HisPsn{
  1907. PsnNo: res.Output.Baseinfo.PsnNo,
  1908. Age: res.Output.Baseinfo.Age,
  1909. PatientId: patient.ID,
  1910. Certno: res.Output.Baseinfo.Certno,
  1911. Brdy: res.Output.Baseinfo.Brdy,
  1912. Gend: res.Output.Baseinfo.Gend,
  1913. Naty: res.Output.Baseinfo.Naty,
  1914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1915. PsnName: res.Output.Baseinfo.PsnName,
  1916. Idetinfo: idetinfoStr,
  1917. Insuinfo: infoStr,
  1918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1919. CardInfo: card_info,
  1920. VerifyNumber: token,
  1921. }
  1922. service.CreateHisPsn(psn)
  1923. var rf []*ResultFive
  1924. json.Unmarshal([]byte(infoStr), &rf)
  1925. var insutypes []*ResultFive
  1926. var insutype string
  1927. var is390 int = 0
  1928. var is310 int = 0
  1929. for _, item := range rf {
  1930. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1931. insutypes = append(insutypes, item)
  1932. }
  1933. }
  1934. if len(insutypes) == 1 {
  1935. insutype = insutypes[0].Insutype
  1936. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1937. } else {
  1938. for _, i := range insutypes {
  1939. if i.Insutype == "390" {
  1940. is390 = 1
  1941. }
  1942. if i.Insutype == "310" {
  1943. is310 = 1
  1944. }
  1945. }
  1946. }
  1947. if is390 == 1 {
  1948. insutype = "390"
  1949. }
  1950. if is310 == 1 {
  1951. insutype = "310"
  1952. }
  1953. if len(insutypes) == 0 {
  1954. insutype = "310"
  1955. }
  1956. c.ServeSuccessJSON(map[string]interface{}{
  1957. "patient": patient,
  1958. "number": token,
  1959. "insutype": insutype,
  1960. })
  1961. }
  1962. }
  1963. } else {
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1965. return
  1966. }
  1967. } else { //读卡失败
  1968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1969. return
  1970. }
  1971. }
  1972. break
  1973. case 4:
  1974. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1975. var api string
  1976. if miConfig.MdtrtareaAdmvs == "320921" {
  1977. 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 +
  1978. "&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
  1979. fmt.Println(api)
  1980. } else {
  1981. 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 +
  1982. "&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)
  1983. }
  1984. resp, requestErr := http.Get(api)
  1985. if requestErr != nil {
  1986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1987. return
  1988. }
  1989. body, ioErr := ioutil.ReadAll(resp.Body)
  1990. if ioErr != nil {
  1991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1993. return
  1994. }
  1995. var respJSON map[string]interface{}
  1996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1999. return
  2000. }
  2001. var status string
  2002. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2003. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2004. var token string
  2005. var res ResultTwo //1101结果
  2006. var res10265 ResultTwo10265 //1101结果
  2007. if status == "0" { //读卡成功
  2008. var card_info string //卡信息
  2009. var busi_card_info string
  2010. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2011. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2012. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2013. fmt.Println(card_info)
  2014. fmt.Println(busi_card_info)
  2015. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2016. result, _ := json.Marshal(respJSON)
  2017. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2018. utils.ErrorLog("解析失败:%v", err)
  2019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2020. return
  2021. }
  2022. res.ErrMsg = res10265.ErrMsg
  2023. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2024. res.Infcode = infocode
  2025. res.Output = res10265.Output
  2026. res.InfRefmsgid = res10265.InfRefmsgid
  2027. if res.Infcode == 0 {
  2028. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2029. if err == gorm.ErrRecordNotFound {
  2030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2031. return
  2032. } else if err != nil {
  2033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2034. return
  2035. } else {
  2036. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2037. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2038. infoStr := string(Iinfos)
  2039. idetinfoStr := string(Idetinfos)
  2040. psn := &models.HisPsn{
  2041. PsnNo: res.Output.Baseinfo.PsnNo,
  2042. Age: res.Output.Baseinfo.Age,
  2043. PatientId: patient.ID,
  2044. Certno: res.Output.Baseinfo.Certno,
  2045. Brdy: res.Output.Baseinfo.Brdy,
  2046. Gend: res.Output.Baseinfo.Gend,
  2047. Naty: res.Output.Baseinfo.Naty,
  2048. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2049. PsnName: res.Output.Baseinfo.PsnName,
  2050. Idetinfo: idetinfoStr,
  2051. Insuinfo: infoStr,
  2052. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2053. CardInfo: card_info,
  2054. VerifyNumber: token,
  2055. }
  2056. service.CreateHisPsn(psn)
  2057. c.ServeSuccessJSON(map[string]interface{}{
  2058. "patient": patient,
  2059. "number": token,
  2060. })
  2061. }
  2062. } else {
  2063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2064. return
  2065. }
  2066. } else { //读卡失败
  2067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2068. return
  2069. }
  2070. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2071. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2072. saveLog(result, requestLog, "6101", "电子凭证")
  2073. var ele ELeCertData
  2074. err := json.Unmarshal([]byte(result), &ele)
  2075. if err != nil {
  2076. utils.ErrorLog("解析失败:%v", err)
  2077. }
  2078. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  2079. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2080. var res ResultTwo
  2081. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2082. utils.ErrorLog("解析失败:%v", err)
  2083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2084. return
  2085. }
  2086. if res.Infcode == 0 {
  2087. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  2088. if err == gorm.ErrRecordNotFound {
  2089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2090. return
  2091. } else if err != nil {
  2092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2093. return
  2094. } else {
  2095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2097. infoStr := string(Iinfos)
  2098. idetinfoStr := string(Idetinfos)
  2099. psn := &models.HisPsn{
  2100. PsnNo: res.Output.Baseinfo.PsnNo,
  2101. Age: res.Output.Baseinfo.Age,
  2102. PatientId: patient.ID,
  2103. Certno: res.Output.Baseinfo.Certno,
  2104. Brdy: res.Output.Baseinfo.Brdy,
  2105. Gend: res.Output.Baseinfo.Gend,
  2106. Naty: res.Output.Baseinfo.Naty,
  2107. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2108. PsnName: res.Output.Baseinfo.PsnName,
  2109. Idetinfo: idetinfoStr,
  2110. Insuinfo: infoStr,
  2111. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2112. CardInfo: "",
  2113. VerifyNumber: ele.Data.EcToken,
  2114. }
  2115. service.CreateHisPsn(psn)
  2116. c.ServeSuccessJSON(map[string]interface{}{
  2117. "patient": patient,
  2118. "number": ele.Data.EcToken,
  2119. })
  2120. }
  2121. } else {
  2122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2123. return
  2124. }
  2125. }
  2126. break
  2127. }
  2128. }
  2129. var initFlag int64 = 0
  2130. func (c *HisApiController) TestGetBasBaseInit() {
  2131. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2132. Iinit := DllDef.MustFindProc("Init")
  2133. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2134. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  2135. if ret != 0 {
  2136. fmt.Println("SSCard的报错原因:", err)
  2137. fmt.Println("SSCard的运算结果为:", ret)
  2138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2139. return
  2140. }
  2141. result := int(ret)
  2142. fmt.Println("SSCard的运算结果为1:", result)
  2143. initFlag = 1
  2144. return
  2145. }
  2146. func (c *HisApiController) GetSFZBaseInfo() string {
  2147. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2148. readCard := DllDef.MustFindProc("ReadSFZ")
  2149. if readCard == nil {
  2150. fmt.Println("readcard is nil")
  2151. readCard = DllDef.MustFindProc("ReadSFZ")
  2152. }
  2153. str := make([]byte, 256)
  2154. str1 := make([]byte, 256)
  2155. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2156. fmt.Println(r)
  2157. return string(str)
  2158. }
  2159. func (c *HisApiController) GetBasBaseInfo() string {
  2160. DllDef := syscall.MustLoadDLL("SSCard.dll")
  2161. readCard := DllDef.MustFindProc("ReadCardBas")
  2162. if readCard == nil {
  2163. fmt.Println("readcard is nil")
  2164. readCard = DllDef.MustFindProc("ReadCardBas")
  2165. }
  2166. str := make([]byte, 1024)
  2167. str1 := make([]byte, 1024)
  2168. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  2169. fmt.Println(string(str1))
  2170. fmt.Println(string(str))
  2171. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2172. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2173. if ret2 != 0 {
  2174. return ""
  2175. }
  2176. return string(str)
  2177. }
  2178. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  2179. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2180. readCard := DllDef.MustFindProc("read_cardinfo")
  2181. if readCard == nil {
  2182. fmt.Println("readcard is nil")
  2183. readCard = DllDef.MustFindProc("read_cardinfo")
  2184. }
  2185. str := make([]byte, 1024) //卡号
  2186. str1 := make([]byte, 1024) //卡识别码
  2187. str2 := make([]byte, 1024) //身份证号
  2188. str3 := make([]byte, 1024) //姓名
  2189. str4 := make([]byte, 1024) //错误信息
  2190. 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])))
  2191. fmt.Println(string(str1))
  2192. fmt.Println(string(str))
  2193. fmt.Println(string(str2))
  2194. fmt.Println(string(str3))
  2195. fmt.Println(string(str4))
  2196. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  2197. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  2198. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  2199. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  2200. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  2201. if ret2 != 0 {
  2202. return "", "", "", "", ""
  2203. }
  2204. return string(str), string(str1), string(str2), string(str3), string(str4)
  2205. }
  2206. type CustomFundPay struct {
  2207. FundPayType string `json:"fund_pay_type"`
  2208. FundPayamt float64 `json:"fund_payamt"`
  2209. }
  2210. func (c *HisApiController) GetSettleList() {
  2211. order_id, _ := c.GetInt64("order_id")
  2212. admin_user_id, _ := c.GetInt64("admin_user_id")
  2213. order, _ := service.GetHisOrderByIDTwo(order_id)
  2214. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2215. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2216. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2217. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2218. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2220. if order.ID == 0 {
  2221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2222. return
  2223. }
  2224. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2225. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2226. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2227. fmt.Println(count)
  2228. var zero string
  2229. number := count + 1
  2230. if number >= 1000 {
  2231. zero = "0000" + strconv.FormatInt(number, 10)
  2232. } else if number >= 10000 {
  2233. zero = "000" + strconv.FormatInt(number, 10)
  2234. } else if number >= 100000 {
  2235. zero = "00" + strconv.FormatInt(number, 10)
  2236. } else if number >= 1000000 {
  2237. zero = "0" + strconv.FormatInt(number, 10)
  2238. } else {
  2239. zero = strconv.FormatInt(number, 10)
  2240. }
  2241. fmt.Println(zero)
  2242. struct4101 := service.Struct4101{
  2243. PsnNo: order.PsnNo,
  2244. MdtrtId: order.MdtrtId,
  2245. SetlId: order.SetlId,
  2246. PsnName: order.PsnName,
  2247. Gend: order.Gend,
  2248. Brdy: his.Brdy,
  2249. Age: his.Age,
  2250. Naty: order.Naty,
  2251. PatnCertType: "01",
  2252. Certno: order.Certno,
  2253. Prfs: "90",
  2254. ConerName: roles[0].UserName,
  2255. PatnRlts: "99",
  2256. ConerAddr: miConfig.OrgName,
  2257. ConerTel: admin.Mobile,
  2258. HiType: order.Insutype,
  2259. Insuplc: miConfig.InsuplcAdmdvs,
  2260. MaindiagFlag: "1",
  2261. BillCode: last_order.FaPiaoCode,
  2262. BillNo: zero,
  2263. BizSn: order.Number,
  2264. PsnSelfPay: order.PsnPartAmt,
  2265. PsnOwnPay: order.PsnPartAmt,
  2266. AcctPay: order.AcctPay,
  2267. PsnCashpay: order.PsnCashPay,
  2268. HiPaymtd: "1",
  2269. Hsorg: miConfig.InsuplcAdmdvs,
  2270. HsorgOpter: miConfig.InsuplcAdmdvs,
  2271. MedinsFillPsn: curRoles.UserName,
  2272. MedinsFillDept: depart.Name,
  2273. IptMedType: "2",
  2274. }
  2275. struct4101.SetlBegnDate = order.SetlTime
  2276. struct4101.SetlEndDate = order.SetlTime
  2277. time_arr := strings.Split(order.SetlTime, " ")
  2278. struct4101.AdmTime = time_arr[0]
  2279. struct4101.AdmEndTime = time_arr[0]
  2280. var rf []CustomFundPay
  2281. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2282. var tempFunPays []service.CustomStruct
  2283. for _, item := range rf {
  2284. var tempFunPay service.CustomStruct
  2285. tempFunPay.FundPayamt = item.FundPayamt
  2286. tempFunPay.FundPayType = item.FundPayType
  2287. tempFunPays = append(tempFunPays, tempFunPay)
  2288. }
  2289. struct4101.CustomStruct = tempFunPays
  2290. var tempDiaginfos []service.DiaginfoStructTwo
  2291. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2292. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2293. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2294. var config []*models.HisXtDiagnoseConfig
  2295. for _, item := range diagnosis_ids {
  2296. id, _ := strconv.ParseInt(item, 10, 64)
  2297. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2298. config = append(config, &diagnosisConfig)
  2299. }
  2300. for index, item := range config {
  2301. if index == 0 {
  2302. var tempDiaginfo service.DiaginfoStructTwo
  2303. tempDiaginfo.DiagCode = item.CountryCode
  2304. tempDiaginfo.DiagName = item.CountryContentName
  2305. tempDiaginfo.DiagType = "1"
  2306. tempDiaginfo.MaindiagFlag = "1"
  2307. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2308. } else {
  2309. var tempDiaginfo service.DiaginfoStructTwo
  2310. tempDiaginfo.DiagCode = item.CountryCode
  2311. tempDiaginfo.DiagName = item.CountryContentName
  2312. tempDiaginfo.DiagType = "2"
  2313. tempDiaginfo.MaindiagFlag = "0"
  2314. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2315. }
  2316. }
  2317. struct4101.Diseinfo = tempDiaginfos
  2318. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2319. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2320. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2321. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2322. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2323. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2324. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2325. var iteminfo service.IteminfoStruct
  2326. var bedCostTotal float64 = 0 //床位总费
  2327. var bedCostSelfTotal float64 = 0 //床位自费
  2328. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2329. var operationCostTotal float64 = 0 //手术费
  2330. var operationCostSelfTotal float64 = 0 //手术费
  2331. var operationCostPartSelfTotal float64 = 0 //手术费
  2332. var otherCostTotal float64 = 0 //其他费用
  2333. var otherCostSelfTotal float64 = 0 //其他费用
  2334. var otherCostPartSelfTotal float64 = 0 //其他费用
  2335. var materialCostTotal float64 = 0 //材料费
  2336. var materialCostSelfTotal float64 = 0 //材料费
  2337. var materialCostPartSelfTotal float64 = 0 //材料费
  2338. var westernMedicineCostTotal float64 = 0 //西药费
  2339. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2340. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2341. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2342. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2343. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2344. var checkCostTotal float64 = 0 //检查费
  2345. var checkCostSelfTotal float64 = 0 //检查费
  2346. var checkCostPartSelfTotal float64 = 0 //检查费
  2347. var laboratoryCostTotal float64 = 0 //化验费
  2348. var laboratoryCostSelfTotal float64 = 0 //化验费
  2349. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2350. var treatCostTotal float64 = 0 //治疗费用
  2351. var treatCostSelfTotal float64 = 0 //治疗费用
  2352. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2353. decimal.DivisionPrecision = 2
  2354. var bed_fulamt_ownpay_amt float64 = 0
  2355. var operation_fulamt_ownpay_amt float64 = 0
  2356. var other_fulamt_ownpay_amt float64 = 0
  2357. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2358. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2359. var check_fulamt_ownpay_amt float64 = 0
  2360. var material_fulamt_ownpay_amt float64 = 0
  2361. var laboratory_fulamt_ownpay_amt float64 = 0
  2362. var treat_fulamt_ownpay_amt float64 = 0
  2363. var bed_claa_sunmfee float64 = 0
  2364. var bed_clab_amt float64 = 0
  2365. var bed_other_amt float64 = 0
  2366. var operation_claa_sunmfee float64 = 0
  2367. var operation_clab_amt float64 = 0
  2368. var operation_other_amt float64 = 0
  2369. var other_claa_sunmfee float64 = 0
  2370. var other_clab_amt float64 = 0
  2371. var other_other_amt float64 = 0
  2372. var westernMedicine_claa_sunmfee float64 = 0
  2373. var westernMedicine_clab_amt float64 = 0
  2374. var westernMedicine_other_amt float64 = 0
  2375. var chineseTraditional_claa_sunmfee float64 = 0
  2376. var chineseTraditional_clab_amt float64 = 0
  2377. var chineseTraditional_other_amt float64 = 0
  2378. var check_claa_sunmfee float64 = 0
  2379. var check_clab_amt float64 = 0
  2380. var check_other_amt float64 = 0
  2381. var material_claa_sunmfee float64 = 0
  2382. var material_clab_amt float64 = 0
  2383. var material_other_amt float64 = 0
  2384. var laboratory_claa_sunmfee float64 = 0
  2385. var laboratory_clab_amt float64 = 0
  2386. var laboratory_other_amt float64 = 0
  2387. var treat_claa_sunmfee float64 = 0
  2388. var treat_clab_amt float64 = 0
  2389. var treat_other_amt float64 = 0
  2390. for _, item := range order.HisOrderInfo {
  2391. if item.MedChrgitmType == "01" { //床位费
  2392. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2393. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2394. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2395. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2396. if item.ChrgitmLv == "1" {
  2397. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2398. }
  2399. if item.ChrgitmLv == "2" {
  2400. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2401. }
  2402. if item.ChrgitmLv == "3" {
  2403. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2404. }
  2405. }
  2406. if item.MedChrgitmType == "03" { //检查费
  2407. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2408. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2409. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2410. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2411. if item.ChrgitmLv == "1" {
  2412. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2413. }
  2414. if item.ChrgitmLv == "2" {
  2415. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2416. }
  2417. if item.ChrgitmLv == "3" {
  2418. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2419. }
  2420. }
  2421. if item.MedChrgitmType == "04" { //化验费
  2422. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2423. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2424. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2425. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2426. if item.ChrgitmLv == "1" {
  2427. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2428. }
  2429. if item.ChrgitmLv == "2" {
  2430. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2431. }
  2432. if item.ChrgitmLv == "3" {
  2433. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2434. }
  2435. }
  2436. if item.MedChrgitmType == "05" { //治疗费
  2437. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2438. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2439. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2440. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2441. if item.ChrgitmLv == "1" {
  2442. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2443. }
  2444. if item.ChrgitmLv == "2" {
  2445. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2446. }
  2447. if item.ChrgitmLv == "3" {
  2448. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2449. }
  2450. }
  2451. if item.MedChrgitmType == "06" { //手术费
  2452. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2453. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2454. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2455. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2456. if item.ChrgitmLv == "1" {
  2457. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2458. }
  2459. if item.ChrgitmLv == "2" {
  2460. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2461. }
  2462. if item.ChrgitmLv == "3" {
  2463. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2464. }
  2465. }
  2466. if item.MedChrgitmType == "08" { //材料费
  2467. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2468. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2469. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2470. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2471. if item.ChrgitmLv == "1" {
  2472. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2473. }
  2474. if item.ChrgitmLv == "2" {
  2475. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2476. }
  2477. if item.ChrgitmLv == "3" {
  2478. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2479. }
  2480. }
  2481. if item.MedChrgitmType == "09" { //西药费
  2482. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2483. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2485. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2486. if item.ChrgitmLv == "1" {
  2487. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. }
  2489. if item.ChrgitmLv == "2" {
  2490. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2491. }
  2492. if item.ChrgitmLv == "3" {
  2493. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2494. }
  2495. }
  2496. if item.MedChrgitmType == "11" { //中成费
  2497. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2498. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2500. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2501. if item.ChrgitmLv == "1" {
  2502. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. }
  2504. if item.ChrgitmLv == "2" {
  2505. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2506. }
  2507. if item.ChrgitmLv == "3" {
  2508. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2509. }
  2510. }
  2511. if item.MedChrgitmType == "14" { //其他费
  2512. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2513. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2515. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2516. if item.ChrgitmLv == "1" {
  2517. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. }
  2519. if item.ChrgitmLv == "2" {
  2520. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2521. }
  2522. if item.ChrgitmLv == "3" {
  2523. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2524. }
  2525. }
  2526. }
  2527. var iteminfoStructs []service.IteminfoStruct
  2528. if bedCostTotal != 0 {
  2529. iteminfo.MedChrgitm = "01"
  2530. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2531. iteminfo.Amt = bedCostTotal
  2532. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2533. iteminfo.ClabAmt = bed_clab_amt
  2534. iteminfo.OthAmt = bed_other_amt
  2535. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2536. }
  2537. if checkCostTotal != 0 {
  2538. iteminfo.MedChrgitm = "03"
  2539. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2540. iteminfo.Amt = checkCostTotal
  2541. iteminfo.ClaaSumfee = check_claa_sunmfee
  2542. iteminfo.ClabAmt = check_clab_amt
  2543. iteminfo.OthAmt = check_other_amt
  2544. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2545. }
  2546. if laboratoryCostTotal != 0 {
  2547. iteminfo.MedChrgitm = "04"
  2548. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2549. iteminfo.Amt = laboratoryCostTotal
  2550. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2551. iteminfo.ClabAmt = laboratory_clab_amt
  2552. iteminfo.OthAmt = laboratory_other_amt
  2553. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2554. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2555. }
  2556. if treatCostTotal != 0 {
  2557. iteminfo.MedChrgitm = "05"
  2558. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2559. iteminfo.Amt = treatCostTotal
  2560. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2561. iteminfo.ClabAmt = treat_clab_amt
  2562. iteminfo.OthAmt = treat_other_amt
  2563. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2564. //(struct4101.IteminfoStruct, iteminfo)
  2565. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2566. }
  2567. if operationCostTotal != 0 {
  2568. iteminfo.MedChrgitm = "06"
  2569. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2570. iteminfo.Amt = operationCostTotal
  2571. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2572. iteminfo.ClabAmt = operation_clab_amt
  2573. iteminfo.OthAmt = operation_other_amt
  2574. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2575. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2576. }
  2577. if materialCostTotal != 0 {
  2578. iteminfo.MedChrgitm = "08"
  2579. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2580. iteminfo.Amt = materialCostTotal
  2581. iteminfo.ClaaSumfee = material_claa_sunmfee
  2582. iteminfo.ClabAmt = material_clab_amt
  2583. iteminfo.OthAmt = material_other_amt
  2584. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2585. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2586. }
  2587. if westernMedicineCostTotal != 0 {
  2588. iteminfo.MedChrgitm = "09"
  2589. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2590. iteminfo.Amt = westernMedicineCostTotal
  2591. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2592. iteminfo.ClabAmt = westernMedicine_clab_amt
  2593. iteminfo.OthAmt = westernMedicine_other_amt
  2594. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2595. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2596. }
  2597. if chineseTraditionalMedicineCostTotal != 0 {
  2598. iteminfo.MedChrgitm = "11"
  2599. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2600. iteminfo.Amt = westernMedicineCostTotal
  2601. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2602. iteminfo.ClabAmt = westernMedicine_clab_amt
  2603. iteminfo.OthAmt = westernMedicine_other_amt
  2604. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2605. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2606. }
  2607. if otherCostTotal != 0 {
  2608. iteminfo.MedChrgitm = "14"
  2609. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2610. iteminfo.Amt = otherCostTotal
  2611. iteminfo.ClaaSumfee = other_claa_sunmfee
  2612. iteminfo.ClabAmt = other_clab_amt
  2613. iteminfo.OthAmt = other_other_amt
  2614. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2615. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2616. }
  2617. struct4101.IteminfoStruct = iteminfoStructs
  2618. struct4101.Ntly = "中国"
  2619. struct4101.AdmCaty = "A03.06"
  2620. var res ResultSeventeen
  2621. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2622. var resOther ResultSeventeenOther
  2623. var pp models.PublicParams
  2624. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2625. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2626. pp.FixmedinsName = miConfig.OrgName
  2627. pp.FixmedinsCode = miConfig.Code
  2628. pp.RequestUrl = miConfig.Url
  2629. pp.Cainfo = miConfig.Cainfo
  2630. pp.SecretKey = miConfig.SecretKey
  2631. pp.AccessKey = miConfig.AccessKey
  2632. pp.OpterName = curRoles.UserName
  2633. client := &http.Client{}
  2634. var req *http.Request
  2635. data := make(map[string]interface{})
  2636. data["struct4101"] = struct4101
  2637. data["pp"] = pp
  2638. bytesData, _ := json.Marshal(data)
  2639. if miConfig.MdtrtareaAdmvs == "320921" {
  2640. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2641. } else {
  2642. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2643. }
  2644. resp, _ := client.Do(req)
  2645. defer resp.Body.Close()
  2646. body, ioErr := ioutil.ReadAll(resp.Body)
  2647. if ioErr != nil {
  2648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. var respJSON map[string]interface{}
  2653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2656. return
  2657. }
  2658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2659. userJSONBytes, _ := json.Marshal(respJSON)
  2660. fmt.Println("log")
  2661. fmt.Println(string(userJSONBytes))
  2662. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. res.InfRefmsgid = resOther.InfRefmsgid
  2668. res.Output = resOther.Output
  2669. res.ErrMsg = resOther.ErrMsg
  2670. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2671. res.Infcode = infocode
  2672. } else {
  2673. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2674. var dat map[string]interface{}
  2675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2676. fmt.Println(dat)
  2677. } else {
  2678. fmt.Println(err)
  2679. }
  2680. userJSONBytes, _ := json.Marshal(dat)
  2681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2682. utils.ErrorLog("解析失败:%v", err)
  2683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2684. return
  2685. }
  2686. }
  2687. if res.Infcode != 0 {
  2688. c.ServeSuccessJSON(map[string]interface{}{
  2689. "failed_code": -10,
  2690. "msg": res.ErrMsg,
  2691. })
  2692. return
  2693. } else {
  2694. order.FaPiaoNumber = zero
  2695. order.FaPiaoCode = last_order.FaPiaoCode
  2696. service.UpdateOrder(order)
  2697. hisFundSettleListResult := &models.HisFundSettleListResult{
  2698. Number: res.Output.SetlListId,
  2699. Status: 1,
  2700. Ctime: time.Now().Unix(),
  2701. Mtime: time.Now().Unix(),
  2702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2703. IsUpload: 1,
  2704. OrderId: order_id,
  2705. }
  2706. service.CreateUploadRecord(hisFundSettleListResult)
  2707. c.ServeSuccessJSON(map[string]interface{}{
  2708. "msg": "上传成功",
  2709. "result": hisFundSettleListResult,
  2710. })
  2711. return
  2712. }
  2713. }
  2714. func (c *HisApiController) GetSettleListHospital() {
  2715. order_id, _ := c.GetInt64("order_id")
  2716. admin_user_id, _ := c.GetInt64("admin_user_id")
  2717. order, _ := service.GetHisOrderByIDTwo(order_id)
  2718. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2719. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2720. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2721. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2722. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2723. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2724. if order.ID == 0 {
  2725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2726. return
  2727. }
  2728. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2729. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2730. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2731. fmt.Println(count)
  2732. var zero string
  2733. number := count + 1
  2734. if number >= 1000 {
  2735. zero = "0000" + strconv.FormatInt(number, 10)
  2736. } else if number >= 10000 {
  2737. zero = "000" + strconv.FormatInt(number, 10)
  2738. } else if number >= 100000 {
  2739. zero = "00" + strconv.FormatInt(number, 10)
  2740. } else if number >= 1000000 {
  2741. zero = "0" + strconv.FormatInt(number, 10)
  2742. } else {
  2743. zero = strconv.FormatInt(number, 10)
  2744. }
  2745. fmt.Println(zero)
  2746. struct4101 := service.Struct4101{
  2747. PsnNo: order.PsnNo,
  2748. MdtrtId: order.MdtrtId,
  2749. SetlId: order.SetlId,
  2750. PsnName: order.PsnName,
  2751. Gend: order.Gend,
  2752. Brdy: his.Brdy,
  2753. Age: int64(order.Age),
  2754. Naty: order.Naty,
  2755. PatnCertType: "01",
  2756. Certno: order.Certno,
  2757. Prfs: "90",
  2758. ConerName: roles[0].UserName,
  2759. PatnRlts: "99",
  2760. ConerAddr: miConfig.OrgName,
  2761. ConerTel: admin.Mobile,
  2762. HiType: order.Insutype,
  2763. Insuplc: miConfig.InsuplcAdmdvs,
  2764. MaindiagFlag: "1",
  2765. BillCode: last_order.FaPiaoCode,
  2766. BillNo: zero,
  2767. BizSn: order.Number,
  2768. PsnSelfPay: order.PsnPartAmt,
  2769. PsnOwnPay: order.PsnPartAmt,
  2770. AcctPay: order.AcctPay,
  2771. PsnCashpay: order.PsnCashPay,
  2772. HiPaymtd: "1",
  2773. Hsorg: miConfig.InsuplcAdmdvs,
  2774. HsorgOpter: miConfig.InsuplcAdmdvs,
  2775. MedinsFillPsn: curRoles.UserName,
  2776. MedinsFillDept: depart.Name,
  2777. IptMedType: "2",
  2778. AdmTime: his.InHosptialTime,
  2779. AdmEndTime: his.OutHosptialTime,
  2780. }
  2781. struct4101.SetlBegnDate = order.SetlTime
  2782. struct4101.SetlEndDate = order.SetlTime
  2783. var rf []CustomFundPay
  2784. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2785. var tempFunPays []service.CustomStruct
  2786. for _, item := range rf {
  2787. var tempFunPay service.CustomStruct
  2788. tempFunPay.FundPayamt = item.FundPayamt
  2789. tempFunPay.FundPayType = item.FundPayType
  2790. tempFunPays = append(tempFunPays, tempFunPay)
  2791. }
  2792. struct4101.CustomStruct = tempFunPays
  2793. var tempDiaginfos []service.DiaginfoStructTwo
  2794. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2795. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2796. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2797. var config []*models.HisXtDiagnoseConfig
  2798. for _, item := range diagnosis_ids {
  2799. id, _ := strconv.ParseInt(item, 10, 64)
  2800. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2801. config = append(config, &diagnosisConfig)
  2802. }
  2803. for index, item := range config {
  2804. if index == 0 {
  2805. var tempDiaginfo service.DiaginfoStructTwo
  2806. tempDiaginfo.DiagCode = item.CountryCode
  2807. tempDiaginfo.DiagName = item.CountryContentName
  2808. tempDiaginfo.DiagType = "1"
  2809. tempDiaginfo.MaindiagFlag = "1"
  2810. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2811. } else {
  2812. var tempDiaginfo service.DiaginfoStructTwo
  2813. tempDiaginfo.DiagCode = item.CountryCode
  2814. tempDiaginfo.DiagName = item.CountryContentName
  2815. tempDiaginfo.DiagType = "2"
  2816. tempDiaginfo.MaindiagFlag = "0"
  2817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2818. }
  2819. }
  2820. struct4101.Diseinfo = tempDiaginfos
  2821. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2822. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2823. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2824. tempOpspdiseinfo2.OprnOprtCode = ""
  2825. tempOpspdiseinfo2.OprnOprtName = ""
  2826. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2827. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2828. var iteminfo service.IteminfoStruct
  2829. var bedCostTotal float64 = 0 //床位总费
  2830. var bedCostSelfTotal float64 = 0 //床位自费
  2831. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2832. var operationCostTotal float64 = 0 //手术费
  2833. var operationCostSelfTotal float64 = 0 //手术费
  2834. var operationCostPartSelfTotal float64 = 0 //手术费
  2835. var otherCostTotal float64 = 0 //其他费用
  2836. var otherCostSelfTotal float64 = 0 //其他费用
  2837. var otherCostPartSelfTotal float64 = 0 //其他费用
  2838. var materialCostTotal float64 = 0 //材料费
  2839. var materialCostSelfTotal float64 = 0 //材料费
  2840. var materialCostPartSelfTotal float64 = 0 //材料费
  2841. var westernMedicineCostTotal float64 = 0 //西药费
  2842. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2843. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2844. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2845. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2846. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2847. var checkCostTotal float64 = 0 //检查费
  2848. var checkCostSelfTotal float64 = 0 //检查费
  2849. var checkCostPartSelfTotal float64 = 0 //检查费
  2850. var laboratoryCostTotal float64 = 0 //化验费
  2851. var laboratoryCostSelfTotal float64 = 0 //化验费
  2852. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2853. var treatCostTotal float64 = 0 //治疗费用
  2854. var treatCostSelfTotal float64 = 0 //治疗费用
  2855. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2856. decimal.DivisionPrecision = 2
  2857. var bed_fulamt_ownpay_amt float64 = 0
  2858. var operation_fulamt_ownpay_amt float64 = 0
  2859. var other_fulamt_ownpay_amt float64 = 0
  2860. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2861. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2862. var check_fulamt_ownpay_amt float64 = 0
  2863. var material_fulamt_ownpay_amt float64 = 0
  2864. var laboratory_fulamt_ownpay_amt float64 = 0
  2865. var treat_fulamt_ownpay_amt float64 = 0
  2866. var bed_claa_sunmfee float64 = 0
  2867. var bed_clab_amt float64 = 0
  2868. var bed_other_amt float64 = 0
  2869. var operation_claa_sunmfee float64 = 0
  2870. var operation_clab_amt float64 = 0
  2871. var operation_other_amt float64 = 0
  2872. var other_claa_sunmfee float64 = 0
  2873. var other_clab_amt float64 = 0
  2874. var other_other_amt float64 = 0
  2875. var westernMedicine_claa_sunmfee float64 = 0
  2876. var westernMedicine_clab_amt float64 = 0
  2877. var westernMedicine_other_amt float64 = 0
  2878. var chineseTraditional_claa_sunmfee float64 = 0
  2879. var chineseTraditional_clab_amt float64 = 0
  2880. var chineseTraditional_other_amt float64 = 0
  2881. var check_claa_sunmfee float64 = 0
  2882. var check_clab_amt float64 = 0
  2883. var check_other_amt float64 = 0
  2884. var material_claa_sunmfee float64 = 0
  2885. var material_clab_amt float64 = 0
  2886. var material_other_amt float64 = 0
  2887. var laboratory_claa_sunmfee float64 = 0
  2888. var laboratory_clab_amt float64 = 0
  2889. var laboratory_other_amt float64 = 0
  2890. var treat_claa_sunmfee float64 = 0
  2891. var treat_clab_amt float64 = 0
  2892. var treat_other_amt float64 = 0
  2893. for _, item := range order.HisOrderInfo {
  2894. if item.MedChrgitmType == "01" { //床位费
  2895. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2896. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2897. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2898. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2899. if item.ChrgitmLv == "1" {
  2900. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2901. }
  2902. if item.ChrgitmLv == "2" {
  2903. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2904. }
  2905. if item.ChrgitmLv == "3" {
  2906. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2907. }
  2908. }
  2909. if item.MedChrgitmType == "03" { //检查费
  2910. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2911. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2912. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2913. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2914. if item.ChrgitmLv == "1" {
  2915. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2916. }
  2917. if item.ChrgitmLv == "2" {
  2918. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2919. }
  2920. if item.ChrgitmLv == "3" {
  2921. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2922. }
  2923. }
  2924. if item.MedChrgitmType == "04" { //化验费
  2925. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2926. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2927. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2928. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2929. if item.ChrgitmLv == "1" {
  2930. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2931. }
  2932. if item.ChrgitmLv == "2" {
  2933. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2934. }
  2935. if item.ChrgitmLv == "3" {
  2936. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2937. }
  2938. }
  2939. if item.MedChrgitmType == "05" { //治疗费
  2940. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2941. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2942. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2943. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2944. if item.ChrgitmLv == "1" {
  2945. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2946. }
  2947. if item.ChrgitmLv == "2" {
  2948. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2949. }
  2950. if item.ChrgitmLv == "3" {
  2951. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2952. }
  2953. }
  2954. if item.MedChrgitmType == "06" { //手术费
  2955. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2956. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2957. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2958. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2959. if item.ChrgitmLv == "1" {
  2960. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2961. }
  2962. if item.ChrgitmLv == "2" {
  2963. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2964. }
  2965. if item.ChrgitmLv == "3" {
  2966. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2967. }
  2968. }
  2969. if item.MedChrgitmType == "08" { //材料费
  2970. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2971. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2972. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2973. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2974. if item.ChrgitmLv == "1" {
  2975. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2976. }
  2977. if item.ChrgitmLv == "2" {
  2978. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2979. }
  2980. if item.ChrgitmLv == "3" {
  2981. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2982. }
  2983. }
  2984. if item.MedChrgitmType == "09" { //西药费
  2985. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2986. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2987. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2988. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2989. if item.ChrgitmLv == "1" {
  2990. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2991. }
  2992. if item.ChrgitmLv == "2" {
  2993. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2994. }
  2995. if item.ChrgitmLv == "3" {
  2996. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2997. }
  2998. }
  2999. if item.MedChrgitmType == "11" { //中成费
  3000. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3001. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3002. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3003. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3004. if item.ChrgitmLv == "1" {
  3005. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3006. }
  3007. if item.ChrgitmLv == "2" {
  3008. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. }
  3010. if item.ChrgitmLv == "3" {
  3011. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3012. }
  3013. }
  3014. if item.MedChrgitmType == "14" { //其他费
  3015. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3016. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3017. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3018. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3019. if item.ChrgitmLv == "1" {
  3020. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3021. }
  3022. if item.ChrgitmLv == "2" {
  3023. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. }
  3025. if item.ChrgitmLv == "3" {
  3026. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3027. }
  3028. }
  3029. }
  3030. var iteminfoStructs []service.IteminfoStruct
  3031. if bedCostTotal != 0 {
  3032. iteminfo.MedChrgitm = "01"
  3033. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3034. iteminfo.Amt = bedCostTotal
  3035. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3036. iteminfo.ClabAmt = bed_clab_amt
  3037. iteminfo.OthAmt = bed_other_amt
  3038. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3039. }
  3040. if checkCostTotal != 0 {
  3041. iteminfo.MedChrgitm = "03"
  3042. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3043. iteminfo.Amt = checkCostTotal
  3044. iteminfo.ClaaSumfee = check_claa_sunmfee
  3045. iteminfo.ClabAmt = check_clab_amt
  3046. iteminfo.OthAmt = check_other_amt
  3047. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3048. }
  3049. if laboratoryCostTotal != 0 {
  3050. iteminfo.MedChrgitm = "04"
  3051. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3052. iteminfo.Amt = laboratoryCostTotal
  3053. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3054. iteminfo.ClabAmt = laboratory_clab_amt
  3055. iteminfo.OthAmt = laboratory_other_amt
  3056. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3057. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3058. }
  3059. if treatCostTotal != 0 {
  3060. iteminfo.MedChrgitm = "05"
  3061. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3062. iteminfo.Amt = treatCostTotal
  3063. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3064. iteminfo.ClabAmt = treat_clab_amt
  3065. iteminfo.OthAmt = treat_other_amt
  3066. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3067. //(struct4101.IteminfoStruct, iteminfo)
  3068. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3069. }
  3070. if operationCostTotal != 0 {
  3071. iteminfo.MedChrgitm = "06"
  3072. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3073. iteminfo.Amt = operationCostTotal
  3074. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3075. iteminfo.ClabAmt = operation_clab_amt
  3076. iteminfo.OthAmt = operation_other_amt
  3077. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3078. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3079. }
  3080. if materialCostTotal != 0 {
  3081. iteminfo.MedChrgitm = "08"
  3082. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3083. iteminfo.Amt = materialCostTotal
  3084. iteminfo.ClaaSumfee = material_claa_sunmfee
  3085. iteminfo.ClabAmt = material_clab_amt
  3086. iteminfo.OthAmt = material_other_amt
  3087. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3088. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3089. }
  3090. if westernMedicineCostTotal != 0 {
  3091. iteminfo.MedChrgitm = "09"
  3092. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3093. iteminfo.Amt = westernMedicineCostTotal
  3094. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3095. iteminfo.ClabAmt = westernMedicine_clab_amt
  3096. iteminfo.OthAmt = westernMedicine_other_amt
  3097. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3098. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3099. }
  3100. if chineseTraditionalMedicineCostTotal != 0 {
  3101. iteminfo.MedChrgitm = "11"
  3102. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3103. iteminfo.Amt = westernMedicineCostTotal
  3104. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3105. iteminfo.ClabAmt = westernMedicine_clab_amt
  3106. iteminfo.OthAmt = westernMedicine_other_amt
  3107. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3108. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3109. }
  3110. if otherCostTotal != 0 {
  3111. iteminfo.MedChrgitm = "14"
  3112. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3113. iteminfo.Amt = otherCostTotal
  3114. iteminfo.ClaaSumfee = other_claa_sunmfee
  3115. iteminfo.ClabAmt = other_clab_amt
  3116. iteminfo.OthAmt = other_other_amt
  3117. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3118. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3119. }
  3120. struct4101.IteminfoStruct = iteminfoStructs
  3121. struct4101.Ntly = "中国"
  3122. struct4101.AdmCaty = "A03.06"
  3123. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  3124. fmt.Println(result)
  3125. var dat map[string]interface{}
  3126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3127. fmt.Println(dat)
  3128. } else {
  3129. fmt.Println(err)
  3130. }
  3131. userJSONBytes, _ := json.Marshal(dat)
  3132. var res ResultSeventeen
  3133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3134. utils.ErrorLog("解析失败:%v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. if res.Infcode != 0 {
  3139. c.ServeSuccessJSON(map[string]interface{}{
  3140. "failed_code": -10,
  3141. "msg": res.ErrMsg,
  3142. })
  3143. return
  3144. } else {
  3145. order.FaPiaoNumber = zero
  3146. order.FaPiaoCode = last_order.FaPiaoCode
  3147. service.UpdateOrder(order)
  3148. hisFundSettleListResult := &models.HisFundSettleListResult{
  3149. Number: res.Output.SetlListId,
  3150. Status: 1,
  3151. Ctime: time.Now().Unix(),
  3152. Mtime: time.Now().Unix(),
  3153. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3154. IsUpload: 1,
  3155. OrderId: order_id,
  3156. }
  3157. service.CreateUploadRecord(hisFundSettleListResult)
  3158. c.ServeSuccessJSON(map[string]interface{}{
  3159. "msg": "上传成功",
  3160. "result": hisFundSettleListResult,
  3161. })
  3162. return
  3163. }
  3164. }
  3165. func (c *HisApiController) GetBatchSettleList() {
  3166. orders, _ := service.GetAllHisOrder(10138)
  3167. for _, item := range orders {
  3168. order_id := item.ID
  3169. order, _ := service.GetHisOrderByIDTwo(order_id)
  3170. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3171. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3172. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3173. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  3174. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3175. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3176. if order.ID == 0 {
  3177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3178. return
  3179. }
  3180. if his.BalanceAccountsType == 2 {
  3181. continue
  3182. }
  3183. struct4101 := service.Struct4101{
  3184. PsnNo: order.PsnNo,
  3185. MdtrtId: order.MdtrtId,
  3186. SetlId: order.SetlId,
  3187. PsnName: order.PsnName,
  3188. Gend: order.Gend,
  3189. Brdy: his.Brdy,
  3190. Age: his.Age,
  3191. Naty: order.Naty,
  3192. PatnCertType: "01",
  3193. Certno: order.Certno,
  3194. Prfs: "90",
  3195. ConerName: roles[0].UserName,
  3196. PatnRlts: "99",
  3197. ConerAddr: miConfig.OrgName,
  3198. ConerTel: admin.Mobile,
  3199. HiType: order.Insutype,
  3200. Insuplc: his.InsuplcAdmdvs,
  3201. MaindiagFlag: "1",
  3202. BillCode: order.FaPiaoCode,
  3203. BillNo: order.FaPiaoNumber,
  3204. BizSn: order.Number,
  3205. PsnSelfPay: order.PsnPartAmt,
  3206. PsnOwnPay: order.PsnPartAmt,
  3207. AcctPay: order.AcctPay,
  3208. PsnCashpay: order.PsnCashPay,
  3209. HiPaymtd: "1",
  3210. Hsorg: his.InsuplcAdmdvs,
  3211. HsorgOpter: his.InsuplcAdmdvs,
  3212. MedinsFillPsn: curRoles.UserName,
  3213. MedinsFillDept: depart.Name,
  3214. IptMedType: "2",
  3215. }
  3216. struct4101.SetlBegnDate = order.SetlTime
  3217. struct4101.SetlEndDate = order.SetlTime
  3218. //if order.SettleType == 1 {
  3219. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  3220. // dateStr := t.Format("2006-01-02")
  3221. // struct4101.SetlBegnDate = dateStr
  3222. // struct4101.SetlEndDate = dateStr
  3223. //} else {
  3224. // t := time.Unix(int64(order.SettleStartTime), 0)
  3225. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  3226. // dateStartStr := t.Format("2006-01-02")
  3227. // dateEndStr := t2.Format("2006-01-02")
  3228. // struct4101.SetlBegnDate = dateStartStr
  3229. // struct4101.SetlEndDate = dateEndStr
  3230. //}
  3231. var rf []CustomFundPay
  3232. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3233. var tempFunPays []service.CustomStruct
  3234. var tempFunPay610100 service.CustomStruct
  3235. for _, item := range rf {
  3236. if item.FundPayType == "610100" {
  3237. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  3238. tempFunPay610100.FundPayType = item.FundPayType
  3239. } else {
  3240. var tempFunPay service.CustomStruct
  3241. tempFunPay.FundPayamt = item.FundPayamt
  3242. tempFunPay.FundPayType = item.FundPayType
  3243. tempFunPays = append(tempFunPays, tempFunPay)
  3244. }
  3245. }
  3246. tempFunPays = append(tempFunPays, tempFunPay610100)
  3247. struct4101.CustomStruct = tempFunPays
  3248. var tempDiaginfos []service.DiaginfoStructTwo
  3249. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3250. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3251. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3252. var config []*models.HisXtDiagnoseConfig
  3253. for _, item := range diagnosis_ids {
  3254. id, _ := strconv.ParseInt(item, 10, 64)
  3255. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3256. config = append(config, &diagnosisConfig)
  3257. }
  3258. for index, item := range config {
  3259. if index == 0 {
  3260. var tempDiaginfo service.DiaginfoStructTwo
  3261. tempDiaginfo.DiagCode = item.CountryCode
  3262. tempDiaginfo.DiagName = item.CountryContentName
  3263. tempDiaginfo.DiagType = "1"
  3264. tempDiaginfo.MaindiagFlag = "1"
  3265. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3266. } else {
  3267. var tempDiaginfo service.DiaginfoStructTwo
  3268. tempDiaginfo.DiagCode = item.CountryCode
  3269. tempDiaginfo.DiagName = item.CountryContentName
  3270. tempDiaginfo.DiagType = "2"
  3271. tempDiaginfo.MaindiagFlag = "0"
  3272. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3273. }
  3274. }
  3275. struct4101.Diseinfo = tempDiaginfos
  3276. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3277. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3278. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3279. tempOpspdiseinfo2.OprnOprtCode = ""
  3280. tempOpspdiseinfo2.OprnOprtName = ""
  3281. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3282. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3283. var iteminfo service.IteminfoStruct
  3284. var bedCostTotal float64 = 0 //床位总费
  3285. var bedCostSelfTotal float64 = 0 //床位自费
  3286. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3287. var examineCostTotal float64 = 0 //诊查总费
  3288. var examineCostSelfTotal float64 = 0 //诊查自费
  3289. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3290. var nursingCostTotal float64 = 0 //护理总费
  3291. var nursingCostSelfTotal float64 = 0 //护理自费
  3292. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3293. var chineseMedicineCostTotal float64 = 0 //中成药
  3294. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3295. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3296. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3297. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3298. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3299. var registerCostTotal float64 = 0 //一般诊疗费
  3300. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3301. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3302. var operationCostTotal float64 = 0 //手术费
  3303. var operationCostSelfTotal float64 = 0 //手术费
  3304. var operationCostPartSelfTotal float64 = 0 //手术费
  3305. var otherCostTotal float64 = 0 //其他费用
  3306. var otherCostSelfTotal float64 = 0 //其他费用
  3307. var otherCostPartSelfTotal float64 = 0 //其他费用
  3308. var materialCostTotal float64 = 0 //材料费
  3309. var materialCostSelfTotal float64 = 0 //材料费
  3310. var materialCostPartSelfTotal float64 = 0 //材料费
  3311. var westernMedicineCostTotal float64 = 0 //西药费
  3312. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3313. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3314. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3315. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3316. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3317. var checkCostTotal float64 = 0 //检查费
  3318. var checkCostSelfTotal float64 = 0 //检查费
  3319. var checkCostPartSelfTotal float64 = 0 //检查费
  3320. var laboratoryCostTotal float64 = 0 //化验费
  3321. var laboratoryCostSelfTotal float64 = 0 //化验费
  3322. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3323. var treatCostTotal float64 = 0 //治疗费用
  3324. var treatCostSelfTotal float64 = 0 //治疗费用
  3325. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3326. decimal.DivisionPrecision = 2
  3327. var bed_fulamt_ownpay_amt float64 = 0
  3328. var examine_fulamt_ownpay_amt float64 = 0
  3329. var nursing_fulamt_ownpay_amt float64 = 0
  3330. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3331. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3332. var register_fulamt_ownpay_amt float64 = 0
  3333. var operation_fulamt_ownpay_amt float64 = 0
  3334. var other_fulamt_ownpay_amt float64 = 0
  3335. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3336. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3337. var check_fulamt_ownpay_amt float64 = 0
  3338. var material_fulamt_ownpay_amt float64 = 0
  3339. var laboratory_fulamt_ownpay_amt float64 = 0
  3340. var treat_fulamt_ownpay_amt float64 = 0
  3341. var bed_claa_sunmfee float64 = 0
  3342. var bed_clab_amt float64 = 0
  3343. var bed_other_amt float64 = 0
  3344. var examine_claa_sunmfee float64 = 0
  3345. var examine_clab_amt float64 = 0
  3346. var examine_other_amt float64 = 0
  3347. var nursing_claa_sunmfee float64 = 0
  3348. var nursing_clab_amt float64 = 0
  3349. var nursing_other_amt float64 = 0
  3350. var chinese_medicine_claa_sunmfee float64 = 0
  3351. var chinese_medicine_clab_amt float64 = 0
  3352. var chinese_medicine_other_amt float64 = 0
  3353. var commonly_treatment_claa_sunmfee float64 = 0
  3354. var commonly_treatment_clab_amt float64 = 0
  3355. var commonly_treatment_other_amt float64 = 0
  3356. var operation_claa_sunmfee float64 = 0
  3357. var operation_clab_amt float64 = 0
  3358. var operation_other_amt float64 = 0
  3359. var other_claa_sunmfee float64 = 0
  3360. var other_clab_amt float64 = 0
  3361. var other_other_amt float64 = 0
  3362. var westernMedicine_claa_sunmfee float64 = 0
  3363. var westernMedicine_clab_amt float64 = 0
  3364. var westernMedicine_other_amt float64 = 0
  3365. var chineseTraditional_claa_sunmfee float64 = 0
  3366. var chineseTraditional_clab_amt float64 = 0
  3367. var chineseTraditional_other_amt float64 = 0
  3368. var check_claa_sunmfee float64 = 0
  3369. var check_clab_amt float64 = 0
  3370. var check_other_amt float64 = 0
  3371. var material_claa_sunmfee float64 = 0
  3372. var material_clab_amt float64 = 0
  3373. var material_other_amt float64 = 0
  3374. var laboratory_claa_sunmfee float64 = 0
  3375. var laboratory_clab_amt float64 = 0
  3376. var laboratory_other_amt float64 = 0
  3377. var treat_claa_sunmfee float64 = 0
  3378. var treat_clab_amt float64 = 0
  3379. var treat_other_amt float64 = 0
  3380. var register_claa_sunmfee float64 = 0
  3381. var register_clab_amt float64 = 0
  3382. var register_other_amt float64 = 0
  3383. for _, item := range order.HisOrderInfo {
  3384. if item.MedChrgitmType == "01" { //床位费
  3385. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3386. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3387. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3388. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3389. if item.ChrgitmLv == "1" {
  3390. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3391. }
  3392. if item.ChrgitmLv == "2" {
  3393. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3394. }
  3395. if item.ChrgitmLv == "3" {
  3396. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3397. }
  3398. }
  3399. if item.MedChrgitmType == "02" { //诊查
  3400. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3401. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3402. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3403. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3404. if item.ChrgitmLv == "1" {
  3405. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3406. }
  3407. if item.ChrgitmLv == "2" {
  3408. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3409. }
  3410. if item.ChrgitmLv == "3" {
  3411. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3412. }
  3413. }
  3414. if item.MedChrgitmType == "03" { //检查费
  3415. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3416. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3417. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3418. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3419. if item.ChrgitmLv == "1" {
  3420. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3421. }
  3422. if item.ChrgitmLv == "2" {
  3423. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3424. }
  3425. if item.ChrgitmLv == "3" {
  3426. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3427. }
  3428. }
  3429. if item.MedChrgitmType == "04" { //化验费
  3430. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3431. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3432. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3433. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3434. if item.ChrgitmLv == "1" {
  3435. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3436. }
  3437. if item.ChrgitmLv == "2" {
  3438. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3439. }
  3440. if item.ChrgitmLv == "3" {
  3441. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3442. }
  3443. }
  3444. if item.MedChrgitmType == "05" { //治疗费
  3445. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3446. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3447. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3448. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3449. if item.ChrgitmLv == "1" {
  3450. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3451. }
  3452. if item.ChrgitmLv == "2" {
  3453. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3454. }
  3455. if item.ChrgitmLv == "3" {
  3456. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3457. }
  3458. }
  3459. if item.MedChrgitmType == "06" { //手术费
  3460. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3461. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3462. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3463. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3464. if item.ChrgitmLv == "1" {
  3465. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3466. }
  3467. if item.ChrgitmLv == "2" {
  3468. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3469. }
  3470. if item.ChrgitmLv == "3" {
  3471. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3472. }
  3473. }
  3474. if item.MedChrgitmType == "07" { //手术费
  3475. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3476. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3477. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3478. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3479. if item.ChrgitmLv == "1" {
  3480. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3481. }
  3482. if item.ChrgitmLv == "2" {
  3483. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3484. }
  3485. if item.ChrgitmLv == "3" {
  3486. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3487. }
  3488. }
  3489. if item.MedChrgitmType == "08" { //材料费
  3490. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3491. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3492. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3493. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3494. if item.ChrgitmLv == "1" {
  3495. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3496. }
  3497. if item.ChrgitmLv == "2" {
  3498. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3499. }
  3500. if item.ChrgitmLv == "3" {
  3501. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3502. }
  3503. }
  3504. if item.MedChrgitmType == "09" { //西药费
  3505. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3506. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3507. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3508. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3509. if item.ChrgitmLv == "1" {
  3510. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3511. }
  3512. if item.ChrgitmLv == "2" {
  3513. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3514. }
  3515. if item.ChrgitmLv == "3" {
  3516. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3517. }
  3518. }
  3519. if item.MedChrgitmType == "10" { //中药饮片
  3520. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3521. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3522. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3523. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3524. if item.ChrgitmLv == "1" {
  3525. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3526. }
  3527. if item.ChrgitmLv == "2" {
  3528. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3529. }
  3530. if item.ChrgitmLv == "3" {
  3531. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3532. }
  3533. }
  3534. if item.MedChrgitmType == "11" { //中成费
  3535. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3536. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3537. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3538. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3539. if item.ChrgitmLv == "1" {
  3540. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3541. }
  3542. if item.ChrgitmLv == "2" {
  3543. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3544. }
  3545. if item.ChrgitmLv == "3" {
  3546. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3547. }
  3548. }
  3549. if item.MedChrgitmType == "12" { //中成费
  3550. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3551. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3552. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3553. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3554. if item.ChrgitmLv == "1" {
  3555. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3556. }
  3557. if item.ChrgitmLv == "2" {
  3558. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3559. }
  3560. if item.ChrgitmLv == "3" {
  3561. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3562. }
  3563. }
  3564. if item.MedChrgitmType == "13" { //中成费
  3565. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3566. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3567. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3568. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3569. if item.ChrgitmLv == "1" {
  3570. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3571. }
  3572. if item.ChrgitmLv == "2" {
  3573. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3574. }
  3575. if item.ChrgitmLv == "3" {
  3576. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3577. }
  3578. }
  3579. if item.MedChrgitmType == "14" { //其他费
  3580. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3581. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3582. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3583. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3584. if item.ChrgitmLv == "1" {
  3585. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3586. }
  3587. if item.ChrgitmLv == "2" {
  3588. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3589. }
  3590. if item.ChrgitmLv == "3" {
  3591. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3592. }
  3593. }
  3594. }
  3595. var iteminfoStructs []service.IteminfoStruct
  3596. if bedCostTotal != 0 {
  3597. iteminfo.MedChrgitm = "01"
  3598. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3599. iteminfo.Amt = bedCostTotal
  3600. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3601. iteminfo.ClabAmt = bed_clab_amt
  3602. iteminfo.OthAmt = bed_other_amt
  3603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3604. }
  3605. if examineCostTotal != 0 {
  3606. iteminfo.MedChrgitm = "02"
  3607. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3608. iteminfo.Amt = examineCostTotal
  3609. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3610. iteminfo.ClabAmt = examine_clab_amt
  3611. iteminfo.OthAmt = examine_other_amt
  3612. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3614. }
  3615. if checkCostTotal != 0 {
  3616. iteminfo.MedChrgitm = "03"
  3617. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3618. iteminfo.Amt = checkCostTotal
  3619. iteminfo.ClaaSumfee = check_claa_sunmfee
  3620. iteminfo.ClabAmt = check_clab_amt
  3621. iteminfo.OthAmt = check_other_amt
  3622. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3623. }
  3624. if laboratoryCostTotal != 0 {
  3625. iteminfo.MedChrgitm = "04"
  3626. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3627. iteminfo.Amt = laboratoryCostTotal
  3628. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3629. iteminfo.ClabAmt = laboratory_clab_amt
  3630. iteminfo.OthAmt = laboratory_other_amt
  3631. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3632. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3633. }
  3634. if treatCostTotal != 0 {
  3635. iteminfo.MedChrgitm = "05"
  3636. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3637. iteminfo.Amt = treatCostTotal
  3638. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3639. iteminfo.ClabAmt = treat_clab_amt
  3640. iteminfo.OthAmt = treat_other_amt
  3641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3642. //(struct4101.IteminfoStruct, iteminfo)
  3643. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3644. }
  3645. if operationCostTotal != 0 {
  3646. iteminfo.MedChrgitm = "06"
  3647. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3648. iteminfo.Amt = operationCostTotal
  3649. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3650. iteminfo.ClabAmt = operation_clab_amt
  3651. iteminfo.OthAmt = operation_other_amt
  3652. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3653. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3654. }
  3655. if nursingCostTotal != 0 {
  3656. iteminfo.MedChrgitm = "07"
  3657. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3658. iteminfo.Amt = nursingCostTotal
  3659. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3660. iteminfo.ClabAmt = nursing_clab_amt
  3661. iteminfo.OthAmt = nursing_other_amt
  3662. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3663. }
  3664. if materialCostTotal != 0 {
  3665. iteminfo.MedChrgitm = "08"
  3666. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3667. iteminfo.Amt = materialCostTotal
  3668. iteminfo.ClaaSumfee = material_claa_sunmfee
  3669. iteminfo.ClabAmt = material_clab_amt
  3670. iteminfo.OthAmt = material_other_amt
  3671. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3673. }
  3674. if westernMedicineCostTotal != 0 {
  3675. iteminfo.MedChrgitm = "09"
  3676. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3677. iteminfo.Amt = westernMedicineCostTotal
  3678. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3679. iteminfo.ClabAmt = westernMedicine_clab_amt
  3680. iteminfo.OthAmt = westernMedicine_other_amt
  3681. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3682. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3683. }
  3684. if chineseMedicineCostTotal != 0 {
  3685. iteminfo.MedChrgitm = "10"
  3686. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3687. iteminfo.Amt = chineseMedicineCostTotal
  3688. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3689. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3690. iteminfo.OthAmt = chinese_medicine_other_amt
  3691. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3692. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3693. }
  3694. if chineseTraditionalMedicineCostTotal != 0 {
  3695. iteminfo.MedChrgitm = "11"
  3696. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3697. iteminfo.Amt = westernMedicineCostTotal
  3698. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3699. iteminfo.ClabAmt = westernMedicine_clab_amt
  3700. iteminfo.OthAmt = westernMedicine_other_amt
  3701. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3702. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3703. }
  3704. if commonlyTreatmentCostTotal != 0 {
  3705. iteminfo.MedChrgitm = "12"
  3706. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3707. iteminfo.Amt = commonlyTreatmentCostTotal
  3708. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3709. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3710. iteminfo.OthAmt = commonly_treatment_other_amt
  3711. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3712. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3713. }
  3714. if registerCostTotal != 0 {
  3715. iteminfo.MedChrgitm = "13"
  3716. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3717. iteminfo.Amt = registerCostTotal
  3718. iteminfo.ClaaSumfee = register_claa_sunmfee
  3719. iteminfo.ClabAmt = register_clab_amt
  3720. iteminfo.OthAmt = register_other_amt
  3721. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3722. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3723. }
  3724. if otherCostTotal != 0 {
  3725. iteminfo.MedChrgitm = "14"
  3726. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3727. iteminfo.Amt = otherCostTotal
  3728. iteminfo.ClaaSumfee = other_claa_sunmfee
  3729. iteminfo.ClabAmt = other_clab_amt
  3730. iteminfo.OthAmt = other_other_amt
  3731. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3732. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3733. }
  3734. struct4101.IteminfoStruct = iteminfoStructs
  3735. struct4101.Ntly = "中国"
  3736. struct4101.AdmCaty = "A03.06"
  3737. var res ResultSeventeen
  3738. if miConfig.MdtrtareaAdmvs == "421300" {
  3739. data := make(map[string]interface{})
  3740. data["struct4101"] = struct4101
  3741. data["secret_key"] = miConfig.SecretKey
  3742. data["org_name"] = miConfig.OrgName
  3743. data["opera"] = curRoles.UserName
  3744. data["code"] = miConfig.Code
  3745. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3746. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3747. client := &http.Client{}
  3748. bytesData, _ := json.Marshal(data)
  3749. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3750. resp, _ := client.Do(req)
  3751. defer resp.Body.Close()
  3752. body, ioErr := ioutil.ReadAll(resp.Body)
  3753. if ioErr != nil {
  3754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3756. return
  3757. }
  3758. var respJSON map[string]interface{}
  3759. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. return
  3763. }
  3764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3765. userJSONBytes, _ := json.Marshal(respJSON)
  3766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3767. utils.ErrorLog("解析失败:%v", err)
  3768. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3769. adminUser := c.GetAdminUserInfo()
  3770. errlog := &models.HisOrderError{
  3771. UserOrgId: adminUser.CurrentOrgId,
  3772. Ctime: time.Now().Unix(),
  3773. Mtime: time.Now().Unix(),
  3774. ErrMsg: res.ErrMsg + "解析失败",
  3775. Status: 1,
  3776. PatientId: order_id,
  3777. Stage: 10138,
  3778. }
  3779. service.CreateErrMsgLog(errlog)
  3780. continue
  3781. }
  3782. } else {
  3783. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3784. fmt.Println(result)
  3785. var dat map[string]interface{}
  3786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3787. fmt.Println(dat)
  3788. } else {
  3789. fmt.Println(err)
  3790. }
  3791. userJSONBytes, _ := json.Marshal(dat)
  3792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3793. utils.ErrorLog("解析失败:%v", err)
  3794. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. adminUser := c.GetAdminUserInfo()
  3796. errlog := &models.HisOrderError{
  3797. UserOrgId: adminUser.CurrentOrgId,
  3798. Ctime: time.Now().Unix(),
  3799. Mtime: time.Now().Unix(),
  3800. ErrMsg: res.ErrMsg + "解析失败",
  3801. Status: 1,
  3802. PatientId: order_id,
  3803. Stage: 10138,
  3804. }
  3805. service.CreateErrMsgLog(errlog)
  3806. continue
  3807. }
  3808. }
  3809. if res.Infcode != 0 {
  3810. adminUser := c.GetAdminUserInfo()
  3811. errlog := &models.HisOrderError{
  3812. UserOrgId: adminUser.CurrentOrgId,
  3813. Ctime: time.Now().Unix(),
  3814. Mtime: time.Now().Unix(),
  3815. ErrMsg: res.ErrMsg,
  3816. Status: 1,
  3817. PatientId: order_id,
  3818. Stage: 10138,
  3819. }
  3820. service.CreateErrMsgLog(errlog)
  3821. continue
  3822. } else {
  3823. hisFundSettleListResult := &models.HisFundSettleListResult{
  3824. Number: res.Output.SetlListId,
  3825. Status: 1,
  3826. Ctime: time.Now().Unix(),
  3827. Mtime: time.Now().Unix(),
  3828. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3829. IsUpload: 1,
  3830. OrderId: order_id,
  3831. }
  3832. service.CreateUploadRecord(hisFundSettleListResult)
  3833. continue
  3834. }
  3835. }
  3836. }
  3837. func (c *HisApiController) GetOrgInfo() {
  3838. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3839. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3840. }
  3841. func (c *HisApiController) GetHisPatientInfo() {
  3842. medical_insurance_card := c.GetString("medical_insurance_card")
  3843. id_card_type, _ := c.GetInt64("id_card_type")
  3844. id_card := c.GetString("id_card")
  3845. adminInfo := c.GetAdminUserInfo()
  3846. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3847. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3848. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3849. IdCardNo := ""
  3850. if id_card_type == 1 {
  3851. IdCardNo = medical_insurance_card
  3852. } else if id_card_type == 2 {
  3853. IdCardNo = id_card
  3854. }
  3855. if config.IsOpen == 1 {
  3856. 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
  3857. resp, requestErr := http.Get(api)
  3858. if requestErr != nil {
  3859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3860. return
  3861. }
  3862. defer resp.Body.Close()
  3863. body, ioErr := ioutil.ReadAll(resp.Body)
  3864. if ioErr != nil {
  3865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3867. return
  3868. }
  3869. var respJSON map[string]interface{}
  3870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3873. return
  3874. }
  3875. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3876. userJSONBytes, _ := json.Marshal(userJSON)
  3877. var res ResultTwo
  3878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3879. utils.ErrorLog("解析失败:%v", err)
  3880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3881. return
  3882. }
  3883. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3884. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3885. infoStr := string(Iinfos)
  3886. idetinfoStr := string(Idetinfos)
  3887. if res.Infcode == 0 {
  3888. his := models.VMHisPatient{
  3889. Status: 1,
  3890. Ctime: time.Now().Unix(),
  3891. Mtime: time.Now().Unix(),
  3892. PsnNo: res.Output.Baseinfo.PsnNo,
  3893. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3894. Certno: res.Output.Baseinfo.Certno,
  3895. PsnName: res.Output.Baseinfo.PsnName,
  3896. Gend: res.Output.Baseinfo.Gend,
  3897. Naty: res.Output.Baseinfo.Naty,
  3898. Brdy: res.Output.Baseinfo.Brdy,
  3899. Age: res.Output.Baseinfo.Age,
  3900. Iinfo: infoStr,
  3901. Idetinfo: idetinfoStr,
  3902. UserOrgId: adminInfo.CurrentOrgId,
  3903. IsReturn: 1,
  3904. IdCardType: id_card_type,
  3905. }
  3906. c.ServeSuccessJSON(map[string]interface{}{
  3907. "info": his,
  3908. })
  3909. } else {
  3910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3911. return
  3912. }
  3913. }
  3914. }
  3915. //func GetBasBaseInfo() (jsonStr string, err error) {
  3916. //
  3917. // handle := syscall.NewLazyDLL("SSCard.dll")
  3918. // add := handle.NewProc("ReadCardBas")
  3919. // str := make([]byte, 1024)
  3920. // str1 := make([]byte, 1024)
  3921. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3922. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3923. //
  3924. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3925. //
  3926. // fmt.Println("> Add(4,5)的结果为:", ret)
  3927. // handle.Release()
  3928. //
  3929. // return "", nil
  3930. //
  3931. //}
  3932. //func GetQRBaseInfo() (jsonStr string, err error) {
  3933. // handle := syscall.LoadDLL("SSCard.dll")
  3934. // ReadCardBas := handle.FindProc("GetQRBase")
  3935. //
  3936. // str := make([]byte, 256)
  3937. // str1 := make([]byte, 256)
  3938. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3939. //
  3940. // fmt.Println(string(str))
  3941. // fmt.Println(r)
  3942. // return string(str), nil
  3943. //}
  3944. //func CardInit() int {
  3945. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3946. // add := DllTestDef.MustFindProc("Init")
  3947. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3948. // if err != nil {
  3949. // fmt.Println("SSCard的运算结果为:", ret)
  3950. // }
  3951. // result := int(ret)
  3952. // return result
  3953. //}
  3954. //func CardInit() int {
  3955. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3956. // if err != nil {
  3957. // fmt.Println("SSCard的运算结果为:", ret)
  3958. // }
  3959. // fmt.Println(err)
  3960. // result := int(ret)
  3961. // return result
  3962. //}
  3963. func IntPtr(n int) uintptr {
  3964. return uintptr(n)
  3965. }
  3966. func StrPtr(s string) uintptr {
  3967. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3968. }
  3969. type Result2001 struct {
  3970. Cainfo interface{} `json:"cainfo"`
  3971. ErrMsg string `json:"err_msg"`
  3972. InfRefmsgid string `json:"inf_refmsgid"`
  3973. Infcode int64 `json:"infcode"`
  3974. Output struct {
  3975. Trtinfo struct {
  3976. PsnNo string `json:"psn_no"`
  3977. TrtChkType string `json:"trt_chk_type"`
  3978. FundPayType string `json:"fund_pay_type"`
  3979. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3980. Begndate string `json:"begndate"`
  3981. Enddate string `json:"enddate"`
  3982. TrtChkRslt string `json:"trt_chk_rslt"`
  3983. } `json:"trtinfo"`
  3984. } `json:"output"`
  3985. RefmsgTime string `json:"refmsg_time"`
  3986. RespondTime string `json:"respond_time"`
  3987. Signtype interface{} `json:"signtype"`
  3988. WarnMsg interface{} `json:"warn_msg"`
  3989. }
  3990. type Result2001Org10265 struct {
  3991. Cainfo interface{} `json:"cainfo"`
  3992. ErrMsg string `json:"err_msg"`
  3993. InfRefmsgid string `json:"inf_refmsgid"`
  3994. Infcode string `json:"infcode"`
  3995. Output struct {
  3996. Trtinfo struct {
  3997. PsnNo string `json:"psn_no"`
  3998. TrtChkType string `json:"trt_chk_type"`
  3999. FundPayType string `json:"fund_pay_type"`
  4000. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  4001. Begndate string `json:"begndate"`
  4002. Enddate string `json:"enddate"`
  4003. TrtChkRslt string `json:"trt_chk_rslt"`
  4004. } `json:"trtinfo"`
  4005. } `json:"output"`
  4006. RefmsgTime string `json:"refmsg_time"`
  4007. RespondTime string `json:"respond_time"`
  4008. Signtype interface{} `json:"signtype"`
  4009. WarnMsg interface{} `json:"warn_msg"`
  4010. }
  4011. type ResultTwo struct {
  4012. ErrMsg string `json:"err_msg"`
  4013. InfRefmsgid string `json:"inf_refmsgid"`
  4014. Infcode int64 `json:"infcode"`
  4015. Output struct {
  4016. Baseinfo struct {
  4017. Age float64 `json:"age"`
  4018. Brdy string `json:"brdy"`
  4019. Certno string `json:"certno"`
  4020. Gend string `json:"gend"`
  4021. Naty string `json:"naty"`
  4022. PsnCertType string `json:"psn_cert_type"`
  4023. PsnName string `json:"psn_name"`
  4024. PsnNo string `json:"psn_no"`
  4025. } `json:"baseinfo"`
  4026. Idetinfo []interface{} `json:"idetinfo"`
  4027. Iinfo []struct {
  4028. Balc float64 `json:"balc"`
  4029. CvlservFlag string `json:"cvlserv_flag"`
  4030. EmpName string `json:"emp_name"`
  4031. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4032. Insutype string `json:"insutype"`
  4033. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4034. PausInsuDate string `json:"paus_insu_date"`
  4035. PsnInsuDate string `json:"psn_insu_date"`
  4036. PsnInsuStas string `json:"psn_insu_stas"`
  4037. PsnType string `json:"psn_type"`
  4038. } `json:"insuinfo"`
  4039. } `json:"output"`
  4040. RefmsgTime string `json:"refmsg_time"`
  4041. RespondTime string `json:"respond_time"`
  4042. Signtype interface{} `json:"signtype"`
  4043. WarnInfo interface{} `json:"warn_info"`
  4044. }
  4045. type ResultTwo10265 struct {
  4046. ErrMsg string `json:"err_msg"`
  4047. InfRefmsgid string `json:"inf_refmsgid"`
  4048. Infcode string `json:"infcode"`
  4049. Output struct {
  4050. Baseinfo struct {
  4051. Age float64 `json:"age"`
  4052. Brdy string `json:"brdy"`
  4053. Certno string `json:"certno"`
  4054. Gend string `json:"gend"`
  4055. Naty string `json:"naty"`
  4056. PsnCertType string `json:"psn_cert_type"`
  4057. PsnName string `json:"psn_name"`
  4058. PsnNo string `json:"psn_no"`
  4059. } `json:"baseinfo"`
  4060. Idetinfo []interface{} `json:"idetinfo"`
  4061. Iinfo []struct {
  4062. Balc float64 `json:"balc"`
  4063. CvlservFlag string `json:"cvlserv_flag"`
  4064. EmpName string `json:"emp_name"`
  4065. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4066. Insutype string `json:"insutype"`
  4067. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4068. PausInsuDate string `json:"paus_insu_date"`
  4069. PsnInsuDate string `json:"psn_insu_date"`
  4070. PsnInsuStas string `json:"psn_insu_stas"`
  4071. PsnType string `json:"psn_type"`
  4072. } `json:"insuinfo"`
  4073. } `json:"output"`
  4074. RefmsgTime string `json:"refmsg_time"`
  4075. RespondTime string `json:"respond_time"`
  4076. Signtype interface{} `json:"signtype"`
  4077. WarnInfo interface{} `json:"warn_info"`
  4078. }
  4079. type ResultThree struct {
  4080. Cainfo interface{} `json:"cainfo"`
  4081. ErrMsg string `json:"err_msg"`
  4082. InfRefmsgid string `json:"inf_refmsgid"`
  4083. Infcode int64 `json:"infcode"`
  4084. Output struct {
  4085. Data struct {
  4086. IptOtpNo string `json:"ipt_otp_no"`
  4087. MdtrtID string `json:"mdtrt_id"`
  4088. PsnNo string `json:"psn_no"`
  4089. } `json:"data"`
  4090. } `json:"output"`
  4091. RefmsgTime string `json:"refmsg_time"`
  4092. RespondTime string `json:"respond_time"`
  4093. Signtype interface{} `json:"signtype"`
  4094. WarnMsg interface{} `json:"warn_msg"`
  4095. }
  4096. type ResultThree10265 struct {
  4097. Cainfo interface{} `json:"cainfo"`
  4098. ErrMsg string `json:"err_msg"`
  4099. InfRefmsgid string `json:"inf_refmsgid"`
  4100. Infcode string `json:"infcode"`
  4101. Output struct {
  4102. Data struct {
  4103. IptOtpNo string `json:"ipt_otp_no"`
  4104. MdtrtID string `json:"mdtrt_id"`
  4105. PsnNo string `json:"psn_no"`
  4106. } `json:"data"`
  4107. } `json:"output"`
  4108. RefmsgTime string `json:"refmsg_time"`
  4109. RespondTime string `json:"respond_time"`
  4110. Signtype interface{} `json:"signtype"`
  4111. WarnMsg interface{} `json:"warn_msg"`
  4112. }
  4113. type ResultFour struct {
  4114. Cainfo string `json:"cainfo"`
  4115. ErrMsg string `json:"err_msg"`
  4116. InfRefmsgid string `json:"inf_refmsgid"`
  4117. Infcode int64 `json:"infcode"`
  4118. Output struct {
  4119. Result []struct {
  4120. BasMednFlag string `json:"bas_medn_flag"`
  4121. ChldMedcFlag string `json:"chld_medc_flag"`
  4122. ChrgitmLv string `json:"chrgitm_lv"`
  4123. Cnt float64 `json:"cnt"`
  4124. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4125. DrtReimFlag string `json:"drt_reim_flag"`
  4126. FeedetlSn string `json:"feedetl_sn"`
  4127. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4128. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4129. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4130. ListSpItemFlag string `json:"list_sp_item_flag"`
  4131. LmtUsedFlag string `json:"lmt_used_flag"`
  4132. MedChrgitmType string `json:"med_chrgitm_type"`
  4133. Memo string `json:"memo"`
  4134. OverlmtAmt float64 `json:"overlmt_amt"`
  4135. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4136. Pric float64 `json:"pric"`
  4137. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4138. SelfpayProp float64 `json:"selfpay_prop"`
  4139. } `json:"result"`
  4140. } `json:"output"`
  4141. RefmsgTime string `json:"refmsg_time"`
  4142. RespondTime string `json:"respond_time"`
  4143. Signtype string `json:"signtype"`
  4144. WarnMsg string `json:"warn_msg"`
  4145. }
  4146. type ResultFour10265 struct {
  4147. Cainfo string `json:"cainfo"`
  4148. ErrMsg string `json:"err_msg"`
  4149. InfRefmsgid string `json:"inf_refmsgid"`
  4150. Infcode string `json:"infcode"`
  4151. Output struct {
  4152. Result []struct {
  4153. BasMednFlag string `json:"bas_medn_flag"`
  4154. ChldMedcFlag string `json:"chld_medc_flag"`
  4155. ChrgitmLv string `json:"chrgitm_lv"`
  4156. Cnt float64 `json:"cnt"`
  4157. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4158. DrtReimFlag string `json:"drt_reim_flag"`
  4159. FeedetlSn string `json:"feedetl_sn"`
  4160. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4161. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4162. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4163. ListSpItemFlag string `json:"list_sp_item_flag"`
  4164. LmtUsedFlag string `json:"lmt_used_flag"`
  4165. MedChrgitmType string `json:"med_chrgitm_type"`
  4166. Memo string `json:"memo"`
  4167. OverlmtAmt float64 `json:"overlmt_amt"`
  4168. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4169. Pric float64 `json:"pric"`
  4170. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4171. SelfpayProp float64 `json:"selfpay_prop"`
  4172. } `json:"result"`
  4173. } `json:"output"`
  4174. RefmsgTime string `json:"refmsg_time"`
  4175. RespondTime string `json:"respond_time"`
  4176. Signtype string `json:"signtype"`
  4177. WarnMsg string `json:"warn_msg"`
  4178. }
  4179. type ResultFive struct {
  4180. Balc float64 `json:"balc"`
  4181. CvlservFlag string `json:"cvlserv_flag"`
  4182. EmpName string `json:"emp_name"`
  4183. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4184. Insutype string `json:"insutype"`
  4185. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  4186. PausInsuDate string `json:"paus_insu_date"`
  4187. PsnInsuDate string `json:"psn_insu_date"`
  4188. PsnInsuStas string `json:"psn_insu_stas"`
  4189. PsnType string `json:"psn_type"`
  4190. }
  4191. type ResultSix struct {
  4192. Cainfo interface{} `json:"cainfo"`
  4193. ErrMsg string `json:"err_msg"`
  4194. InfRefmsgid string `json:"inf_refmsgid"`
  4195. Infcode int64 `json:"infcode"`
  4196. Output struct {
  4197. } `json:"output"`
  4198. RefmsgTime string `json:"refmsg_time"`
  4199. RespondTime string `json:"respond_time"`
  4200. Signtype interface{} `json:"signtype"`
  4201. WarnMsg interface{} `json:"warn_msg"`
  4202. }
  4203. type ResultSix10265 struct {
  4204. Cainfo interface{} `json:"cainfo"`
  4205. ErrMsg string `json:"err_msg"`
  4206. InfRefmsgid string `json:"inf_refmsgid"`
  4207. Infcode string `json:"infcode"`
  4208. Output struct {
  4209. } `json:"output"`
  4210. RefmsgTime string `json:"refmsg_time"`
  4211. RespondTime string `json:"respond_time"`
  4212. Signtype interface{} `json:"signtype"`
  4213. WarnMsg interface{} `json:"warn_msg"`
  4214. }
  4215. type ResultSeven struct {
  4216. Cainfo string `json:"cainfo"`
  4217. ErrMsg string `json:"err_msg"`
  4218. InfRefmsgid string `json:"inf_refmsgid"`
  4219. Infcode int64 `json:"infcode"`
  4220. Output struct {
  4221. Setldetail []interface{} `json:"setldetail"`
  4222. Setlinfo struct {
  4223. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4224. AcctPay float64 `json:"acct_pay"`
  4225. ActPayDedc float64 `json:"act_pay_dedc"`
  4226. Age float64 `json:"age"`
  4227. Balc float64 `json:"balc"`
  4228. Brdy string `json:"brdy"`
  4229. Certno string `json:"certno"`
  4230. ClrOptins string `json:"clr_optins"`
  4231. ClrType string `json:"clr_type"`
  4232. ClrWay string `json:"clr_way"`
  4233. CvlservFlag string `json:"cvlserv_flag"`
  4234. CvlservPay float64 `json:"cvlserv_pay"`
  4235. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4236. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4237. Gend string `json:"gend"`
  4238. HifesPay float64 `json:"hifes_pay"`
  4239. HifmiPay float64 `json:"hifmi_pay"`
  4240. HifpPay float64 `json:"hifp_pay"`
  4241. HospPartAmt float64 `json:"hosp_part_amt"`
  4242. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4243. Insutype string `json:"insutype"`
  4244. MafPay float64 `json:"maf_pay"`
  4245. MdtrtCertType string `json:"mdtrt_cert_type"`
  4246. HifobPay float64 `json:"hifob_pay"`
  4247. MdtrtID string `json:"mdtrt_id"`
  4248. MedType string `json:"med_type"`
  4249. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4250. MedinsSetlID string `json:"medins_setl_id"`
  4251. Naty string `json:"naty"`
  4252. OthPay float64 `json:"oth_pay"`
  4253. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4254. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4255. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4256. PsnCashPay float64 `json:"psn_cash_pay"`
  4257. PsnCertType string `json:"psn_cert_type"`
  4258. PsnName string `json:"psn_name"`
  4259. PsnNo string `json:"psn_no"`
  4260. PsnPartAmt float64 `json:"psn_part_amt"`
  4261. PsnType string `json:"psn_type"`
  4262. SetlID string `json:"setl_id"`
  4263. SetlTime string `json:"setl_time"`
  4264. } `json:"setlinfo"`
  4265. } `json:"output"`
  4266. RefmsgTime string `json:"refmsg_time"`
  4267. RespondTime string `json:"respond_time"`
  4268. Signtype interface{} `json:"signtype"`
  4269. WarnMsg interface{} `json:"warn_msg"`
  4270. }
  4271. type ResultSeven10265 struct {
  4272. Cainfo string `json:"cainfo"`
  4273. ErrMsg string `json:"err_msg"`
  4274. InfRefmsgid string `json:"inf_refmsgid"`
  4275. Infcode string `json:"infcode"`
  4276. Output struct {
  4277. Setldetail []interface{} `json:"setldetail"`
  4278. Setlinfo struct {
  4279. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4280. AcctPay float64 `json:"acct_pay"`
  4281. ActPayDedc float64 `json:"act_pay_dedc"`
  4282. Age float64 `json:"age"`
  4283. Balc float64 `json:"balc"`
  4284. Brdy string `json:"brdy"`
  4285. Certno string `json:"certno"`
  4286. ClrOptins string `json:"clr_optins"`
  4287. ClrType string `json:"clr_type"`
  4288. ClrWay string `json:"clr_way"`
  4289. CvlservFlag string `json:"cvlserv_flag"`
  4290. CvlservPay float64 `json:"cvlserv_pay"`
  4291. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4292. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4293. Gend string `json:"gend"`
  4294. HifesPay float64 `json:"hifes_pay"`
  4295. HifmiPay float64 `json:"hifmi_pay"`
  4296. HifpPay float64 `json:"hifp_pay"`
  4297. HospPartAmt float64 `json:"hosp_part_amt"`
  4298. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4299. Insutype string `json:"insutype"`
  4300. MafPay float64 `json:"maf_pay"`
  4301. MdtrtCertType string `json:"mdtrt_cert_type"`
  4302. HifobPay float64 `json:"hifob_pay"`
  4303. MdtrtID string `json:"mdtrt_id"`
  4304. MedType string `json:"med_type"`
  4305. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4306. MedinsSetlID string `json:"medins_setl_id"`
  4307. Naty string `json:"naty"`
  4308. OthPay float64 `json:"oth_pay"`
  4309. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4310. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4311. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4312. PsnCashPay float64 `json:"psn_cash_pay"`
  4313. PsnCertType string `json:"psn_cert_type"`
  4314. PsnName string `json:"psn_name"`
  4315. PsnNo string `json:"psn_no"`
  4316. PsnPartAmt float64 `json:"psn_part_amt"`
  4317. PsnType string `json:"psn_type"`
  4318. SetlID string `json:"setl_id"`
  4319. SetlTime string `json:"setl_time"`
  4320. } `json:"setlinfo"`
  4321. } `json:"output"`
  4322. RefmsgTime string `json:"refmsg_time"`
  4323. RespondTime string `json:"respond_time"`
  4324. Signtype interface{} `json:"signtype"`
  4325. WarnMsg interface{} `json:"warn_msg"`
  4326. }
  4327. type ResultEight struct {
  4328. Cainfo string `json:"cainfo"`
  4329. ErrMsg string `json:"err_msg"`
  4330. InfRefmsgid string `json:"inf_refmsgid"`
  4331. Infcode int64 `json:"infcode"`
  4332. Output struct {
  4333. Stmtinfo struct {
  4334. SetlOptins string `json:"setl_optins"`
  4335. StmtRslt string `json:"stmt_rslt"`
  4336. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4337. } `json:"stmtinfo"`
  4338. } `json:"output"`
  4339. RefmsgTime string `json:"refmsg_time"`
  4340. RespondTime string `json:"respond_time"`
  4341. Signtype interface{} `json:"signtype"`
  4342. WarnMsg interface{} `json:"warn_msg"`
  4343. }
  4344. type ResultEightFor10188 struct {
  4345. Cainfo string `json:"cainfo"`
  4346. ErrMsg string `json:"err_msg"`
  4347. InfRefmsgid string `json:"inf_refmsgid"`
  4348. Infcode string `json:"infcode"`
  4349. Output struct {
  4350. Stmtinfo struct {
  4351. SetlOptins string `json:"setl_optins"`
  4352. StmtRslt string `json:"stmt_rslt"`
  4353. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4354. } `json:"stmtinfo"`
  4355. } `json:"output"`
  4356. RefmsgTime string `json:"refmsg_time"`
  4357. RespondTime string `json:"respond_time"`
  4358. Signtype interface{} `json:"signtype"`
  4359. WarnMsg interface{} `json:"warn_msg"`
  4360. }
  4361. type ResultNine struct {
  4362. Cainfo string `json:"cainfo"`
  4363. ErrMsg string `json:"err_msg"`
  4364. InfRefmsgid string `json:"inf_refmsgid"`
  4365. Infcode int64 `json:"infcode"`
  4366. Output struct {
  4367. FileQuryNo string `json:"file_qury_no"`
  4368. } `json:"output"`
  4369. RefmsgTime string `json:"refmsg_time"`
  4370. RespondTime string `json:"respond_time"`
  4371. Signtype interface{} `json:"signtype"`
  4372. WarnMsg interface{} `json:"warn_msg"`
  4373. }
  4374. type ResultTen struct {
  4375. Cainfo string `json:"cainfo"`
  4376. ErrMsg string `json:"err_msg"`
  4377. InfRefmsgid string `json:"inf_refmsgid"`
  4378. Infcode int64 `json:"infcode"`
  4379. Output struct {
  4380. DldEndtime string `json:"dld_endtime"`
  4381. FileQuryNo string `json:"file_qury_no"`
  4382. Filename string `json:"filename"`
  4383. } `json:"output"`
  4384. RefmsgTime string `json:"refmsg_time"`
  4385. RespondTime string `json:"respond_time"`
  4386. Signtype interface{} `json:"signtype"`
  4387. WarnMsg interface{} `json:"warn_msg"`
  4388. }
  4389. //type Autogenerated struct {
  4390. // Output struct {
  4391. // Setlinfo struct {
  4392. // SetlTime string `json:"setl_time"`
  4393. // CvlservPay float64 `json:"cvlserv_pay"`
  4394. // Year string `json:"year"`
  4395. // MedType string `json:"med_type"`
  4396. // PsnPay float64 `json:"psn_pay"`
  4397. // OpterID string `json:"opter_id"`
  4398. // Begndate string `json:"begndate"`
  4399. // FlxempeFlag string `json:"flxempe_flag"`
  4400. // HifmiPay float64 `json:"hifmi_pay"`
  4401. // PsnNo string `json:"psn_no"`
  4402. // ActPayDedc float64 `json:"act_pay_dedc"`
  4403. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4404. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4405. // ClrWay string `json:"clr_way"`
  4406. // OthPay float64 `json:"oth_pay"`
  4407. // Gend string `json:"gend"`
  4408. // MdtrtID string `json:"mdtrt_id"`
  4409. // AcctPay float64 `json:"acct_pay"`
  4410. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4411. // Insutype string `json:"insutype"`
  4412. // Invono interface{} `json:"invono"`
  4413. // Enddate string `json:"enddate"`
  4414. // CashPayamt float64 `json:"cash_payamt"`
  4415. // PsnType string `json:"psn_type"`
  4416. // FixmedinsName string `json:"fixmedins_name"`
  4417. // HifpPay float64 `json:"hifp_pay"`
  4418. // NewFlag interface{} `json:"new_flag"`
  4419. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4420. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4421. // PayLoc string `json:"pay_loc"`
  4422. // ClrType string `json:"clr_type"`
  4423. // RefdSetlFlag string `json:"refd_setl_flag"`
  4424. // CvlservFlag string `json:"cvlserv_flag"`
  4425. // EmpName string `json:"emp_name"`
  4426. // Brdy string `json:"brdy"`
  4427. // Naty string `json:"naty"`
  4428. // Certno string `json:"certno"`
  4429. // DiseCode string `json:"dise_code"`
  4430. // FixmedinsCode string `json:"fixmedins_code"`
  4431. // DedcHospLv string `json:"dedc_hosp_lv"`
  4432. // OpterName string `json:"opter_name"`
  4433. // Balc float64 `json:"balc"`
  4434. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4435. // PsnCertType string `json:"psn_cert_type"`
  4436. // HifobPay float64 `json:"hifob_pay"`
  4437. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4438. // HifesPay float64 `json:"hifes_pay"`
  4439. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4440. // OptTime string `json:"opt_time"`
  4441. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4442. // SetlID string `json:"setl_id"`
  4443. // MafPay float64 `json:"maf_pay"`
  4444. // PsnName string `json:"psn_name"`
  4445. // InsuOptins interface{} `json:"insu_optins"`
  4446. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4447. // ClrOptins string `json:"clr_optins"`
  4448. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4449. // DiseName string `json:"dise_name"`
  4450. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4451. // Age float64 `json:"age"`
  4452. // DtrtCertType string `json:"dtrt_cert_type"`
  4453. // HospLv string `json:"hosp_lv"`
  4454. // } `json:"setlinfo"`
  4455. // Setldetail []struct {
  4456. // FundPayType string `json:"fund_pay_type"`
  4457. // FundPayamt float64 `json:"fund_payamt"`
  4458. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4459. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4460. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4461. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4462. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4463. // } `json:"setldetail"`
  4464. // } `json:"output"`
  4465. // Infcode int `json:"infcode"`
  4466. // WarnMsg interface{} `json:"warn_msg"`
  4467. // Cainfo interface{} `json:"cainfo"`
  4468. // ErrMsg interface{} `json:"err_msg"`
  4469. // RefmsgTime string `json:"refmsg_time"`
  4470. // Signtype interface{} `json:"signtype"`
  4471. // RespondTime string `json:"respond_time"`
  4472. // InfRefmsgid string `json:"inf_refmsgid"`
  4473. //}
  4474. type ResultEleven struct {
  4475. Cainfo string `json:"cainfo"`
  4476. ErrMsg string `json:"err_msg"`
  4477. InfRefmsgid string `json:"inf_refmsgid"`
  4478. Infcode int64 `json:"infcode"`
  4479. Output struct {
  4480. Setlinfo struct {
  4481. SetlTime string `json:"setl_time"`
  4482. CvlservPay float64 `json:"cvlserv_pay"`
  4483. Year string `json:"year"`
  4484. MedType string `json:"med_type"`
  4485. PsnPay float64 `json:"psn_pay"`
  4486. OpterID string `json:"opter_id"`
  4487. Begndate string `json:"begndate"`
  4488. FlxempeFlag string `json:"flxempe_flag"`
  4489. HifmiPay float64 `json:"hifmi_pay"`
  4490. PsnNo string `json:"psn_no"`
  4491. ActPayDedc float64 `json:"act_pay_dedc"`
  4492. MedinsSetlID interface{} `json:"medins_setl_id"`
  4493. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4494. ClrWay string `json:"clr_way"`
  4495. OthPay float64 `json:"oth_pay"`
  4496. Gend string `json:"gend"`
  4497. MdtrtID string `json:"mdtrt_id"`
  4498. AcctPay float64 `json:"acct_pay"`
  4499. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4500. Insutype string `json:"insutype"`
  4501. Invono interface{} `json:"invono"`
  4502. Enddate string `json:"enddate"`
  4503. CashPayamt float64 `json:"cash_payamt"`
  4504. PsnType string `json:"psn_type"`
  4505. FixmedinsName string `json:"fixmedins_name"`
  4506. HifpPay float64 `json:"hifp_pay"`
  4507. NewFlag interface{} `json:"new_flag"`
  4508. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4509. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4510. PayLoc string `json:"pay_loc"`
  4511. ClrType string `json:"clr_type"`
  4512. RefdSetlFlag string `json:"refd_setl_flag"`
  4513. CvlservFlag string `json:"cvlserv_flag"`
  4514. EmpName string `json:"emp_name"`
  4515. Brdy string `json:"brdy"`
  4516. Naty string `json:"naty"`
  4517. Certno string `json:"certno"`
  4518. DiseCode string `json:"dise_code"`
  4519. FixmedinsCode string `json:"fixmedins_code"`
  4520. DedcHospLv string `json:"dedc_hosp_lv"`
  4521. OpterName string `json:"opter_name"`
  4522. Balc float64 `json:"balc"`
  4523. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4524. PsnCertType string `json:"psn_cert_type"`
  4525. HifobPay float64 `json:"hifob_pay"`
  4526. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4527. HifesPay float64 `json:"hifes_pay"`
  4528. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4529. OptTime string `json:"opt_time"`
  4530. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4531. SetlID string `json:"setl_id"`
  4532. MafPay float64 `json:"maf_pay"`
  4533. PsnName string `json:"psn_name"`
  4534. InsuOptins interface{} `json:"insu_optins"`
  4535. PrefFundPay interface{} `json:"pref_fund_pay"`
  4536. ClrOptins string `json:"clr_optins"`
  4537. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4538. DiseName string `json:"dise_name"`
  4539. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4540. Age float64 `json:"age"`
  4541. DtrtCertType string `json:"dtrt_cert_type"`
  4542. HospLv string `json:"hosp_lv"`
  4543. } `json:"setlinfo"`
  4544. } `json:"output"`
  4545. RefmsgTime string `json:"refmsg_time"`
  4546. RespondTime string `json:"respond_time"`
  4547. Signtype interface{} `json:"signtype"`
  4548. WarnMsg interface{} `json:"warn_msg"`
  4549. }
  4550. type ResultEleven10265 struct {
  4551. Cainfo string `json:"cainfo"`
  4552. ErrMsg string `json:"err_msg"`
  4553. InfRefmsgid string `json:"inf_refmsgid"`
  4554. Infcode string `json:"infcode"`
  4555. Output struct {
  4556. Setlinfo struct {
  4557. SetlTime string `json:"setl_time"`
  4558. CvlservPay float64 `json:"cvlserv_pay"`
  4559. Year string `json:"year"`
  4560. MedType string `json:"med_type"`
  4561. PsnPay float64 `json:"psn_pay"`
  4562. OpterID string `json:"opter_id"`
  4563. Begndate string `json:"begndate"`
  4564. FlxempeFlag string `json:"flxempe_flag"`
  4565. HifmiPay float64 `json:"hifmi_pay"`
  4566. PsnNo string `json:"psn_no"`
  4567. ActPayDedc float64 `json:"act_pay_dedc"`
  4568. MedinsSetlID interface{} `json:"medins_setl_id"`
  4569. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4570. ClrWay string `json:"clr_way"`
  4571. OthPay float64 `json:"oth_pay"`
  4572. Gend string `json:"gend"`
  4573. MdtrtID string `json:"mdtrt_id"`
  4574. AcctPay float64 `json:"acct_pay"`
  4575. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4576. Insutype string `json:"insutype"`
  4577. Invono interface{} `json:"invono"`
  4578. Enddate string `json:"enddate"`
  4579. CashPayamt float64 `json:"cash_payamt"`
  4580. PsnType string `json:"psn_type"`
  4581. FixmedinsName string `json:"fixmedins_name"`
  4582. HifpPay float64 `json:"hifp_pay"`
  4583. NewFlag interface{} `json:"new_flag"`
  4584. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4585. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4586. PayLoc string `json:"pay_loc"`
  4587. ClrType string `json:"clr_type"`
  4588. RefdSetlFlag string `json:"refd_setl_flag"`
  4589. CvlservFlag string `json:"cvlserv_flag"`
  4590. EmpName string `json:"emp_name"`
  4591. Brdy string `json:"brdy"`
  4592. Naty string `json:"naty"`
  4593. Certno string `json:"certno"`
  4594. DiseCode string `json:"dise_code"`
  4595. FixmedinsCode string `json:"fixmedins_code"`
  4596. DedcHospLv string `json:"dedc_hosp_lv"`
  4597. OpterName string `json:"opter_name"`
  4598. Balc float64 `json:"balc"`
  4599. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4600. PsnCertType string `json:"psn_cert_type"`
  4601. HifobPay float64 `json:"hifob_pay"`
  4602. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4603. HifesPay float64 `json:"hifes_pay"`
  4604. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4605. OptTime string `json:"opt_time"`
  4606. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4607. SetlID string `json:"setl_id"`
  4608. MafPay float64 `json:"maf_pay"`
  4609. PsnName string `json:"psn_name"`
  4610. InsuOptins interface{} `json:"insu_optins"`
  4611. PrefFundPay interface{} `json:"pref_fund_pay"`
  4612. ClrOptins string `json:"clr_optins"`
  4613. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4614. DiseName string `json:"dise_name"`
  4615. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4616. Age float64 `json:"age"`
  4617. DtrtCertType string `json:"dtrt_cert_type"`
  4618. HospLv string `json:"hosp_lv"`
  4619. } `json:"setlinfo"`
  4620. } `json:"output"`
  4621. RefmsgTime string `json:"refmsg_time"`
  4622. RespondTime string `json:"respond_time"`
  4623. Signtype interface{} `json:"signtype"`
  4624. WarnMsg interface{} `json:"warn_msg"`
  4625. }
  4626. type ResultTwelve struct {
  4627. Cainfo string `json:"cainfo"`
  4628. ErrMsg string `json:"err_msg"`
  4629. InfRefmsgid string `json:"inf_refmsgid"`
  4630. Infcode int64 `json:"infcode"`
  4631. Output struct {
  4632. MdtrtId string `json:"mdtrt_id"`
  4633. ChrgBchno string `json:"chrg_bchno"`
  4634. PsnNo string `json:"psn_no"`
  4635. } `json:"output"`
  4636. RefmsgTime string `json:"refmsg_time"`
  4637. RespondTime string `json:"respond_time"`
  4638. Signtype interface{} `json:"signtype"`
  4639. WarnMsg interface{} `json:"warn_msg"`
  4640. }
  4641. type ResultThirteen struct {
  4642. ErrMsg string `json:"err_msg"`
  4643. InfRefmsgid string `json:"inf_refmsgid"`
  4644. Infcode int64 `json:"infcode"`
  4645. Output struct {
  4646. Result struct {
  4647. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4648. } `json:"result"`
  4649. } `json:"output"`
  4650. RefmsgTime string `json:"refmsg_time"`
  4651. RespondTime string `json:"respond_time"`
  4652. Signtype interface{} `json:"signtype"`
  4653. WarnInfo interface{} `json:"warn_info"`
  4654. }
  4655. type ResultThirteen10265 struct {
  4656. ErrMsg string `json:"err_msg"`
  4657. InfRefmsgid string `json:"inf_refmsgid"`
  4658. Infcode string `json:"infcode"`
  4659. Output struct {
  4660. Result struct {
  4661. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4662. } `json:"result"`
  4663. } `json:"output"`
  4664. RefmsgTime string `json:"refmsg_time"`
  4665. RespondTime string `json:"respond_time"`
  4666. Signtype interface{} `json:"signtype"`
  4667. WarnInfo interface{} `json:"warn_info"`
  4668. }
  4669. type ResultFourteen struct {
  4670. ErrMsg string `json:"err_msg"`
  4671. InfRefmsgid string `json:"inf_refmsgid"`
  4672. Infcode int64 `json:"infcode"`
  4673. Output struct {
  4674. } `json:"output"`
  4675. RefmsgTime string `json:"refmsg_time"`
  4676. RespondTime string `json:"respond_time"`
  4677. Signtype interface{} `json:"signtype"`
  4678. WarnInfo interface{} `json:"warn_info"`
  4679. }
  4680. type ResultFourteen10265 struct {
  4681. ErrMsg string `json:"err_msg"`
  4682. InfRefmsgid string `json:"inf_refmsgid"`
  4683. Infcode string `json:"infcode"`
  4684. Output struct {
  4685. } `json:"output"`
  4686. RefmsgTime string `json:"refmsg_time"`
  4687. RespondTime string `json:"respond_time"`
  4688. Signtype interface{} `json:"signtype"`
  4689. WarnInfo interface{} `json:"warn_info"`
  4690. }
  4691. type ResultSixteen struct {
  4692. Cainfo string `json:"cainfo"`
  4693. ErrMsg string `json:"err_msg"`
  4694. InfRefmsgid string `json:"inf_refmsgid"`
  4695. Infcode int64 `json:"infcode"`
  4696. Output struct {
  4697. Setldetail []interface{} `json:"setldetail"`
  4698. Setlinfo struct {
  4699. MdtrtID string `json:"mdtrt_id"`
  4700. SetlID string `json:"setl_id"`
  4701. ClrOptins string `json:"clr_optins"`
  4702. SetlTime string `json:"setl_time"`
  4703. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4704. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4705. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4706. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4707. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4708. ActPayDedc float64 `json:"act_pay_dedc"`
  4709. HifpPay float64 `json:"hifp_pay"`
  4710. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4711. Lfpay float64 `json:"selfpay"`
  4712. CvlservPay float64 `json:"cvlserv_pay"`
  4713. HifesPay float64 `json:"hifes_pay"`
  4714. HifmiPay float64 `json:"hifmi_pay"`
  4715. HifobPay float64 `json:"hifob_pay"`
  4716. MafPay float64 `json:"maf_pay"`
  4717. OthPay float64 `json:"oth_pay"`
  4718. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4719. PsnPartAmt float64 `json:"psn_part_amt"`
  4720. AcctPay float64 `json:"acct_pay"`
  4721. Balc float64 `json:"balc"`
  4722. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4723. HospPartAmt float64 `json:"hosp_part_amt"`
  4724. MedinsSetlID string `json:"medins_setl_id"`
  4725. PdnCashPay string `json:"pdn_cash_pay"`
  4726. } `json:"setlinfo"`
  4727. } `json:"output"`
  4728. RefmsgTime string `json:"refmsg_time"`
  4729. RespondTime string `json:"respond_time"`
  4730. Signtype interface{} `json:"signtype"`
  4731. WarnMsg interface{} `json:"warn_msg"`
  4732. }
  4733. type ResultSixteen10265 struct {
  4734. Cainfo string `json:"cainfo"`
  4735. ErrMsg string `json:"err_msg"`
  4736. InfRefmsgid string `json:"inf_refmsgid"`
  4737. Infcode string `json:"infcode"`
  4738. Output struct {
  4739. Setldetail []interface{} `json:"setldetail"`
  4740. Setlinfo struct {
  4741. MdtrtID string `json:"mdtrt_id"`
  4742. SetlID string `json:"setl_id"`
  4743. ClrOptins string `json:"clr_optins"`
  4744. SetlTime string `json:"setl_time"`
  4745. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4746. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4747. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4748. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4749. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4750. ActPayDedc float64 `json:"act_pay_dedc"`
  4751. HifpPay float64 `json:"hifp_pay"`
  4752. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4753. Lfpay float64 `json:"selfpay"`
  4754. CvlservPay float64 `json:"cvlserv_pay"`
  4755. HifesPay float64 `json:"hifes_pay"`
  4756. HifmiPay float64 `json:"hifmi_pay"`
  4757. HifobPay float64 `json:"hifob_pay"`
  4758. MafPay float64 `json:"maf_pay"`
  4759. OthPay float64 `json:"oth_pay"`
  4760. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4761. PsnPartAmt float64 `json:"psn_part_amt"`
  4762. AcctPay float64 `json:"acct_pay"`
  4763. Balc float64 `json:"balc"`
  4764. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4765. HospPartAmt float64 `json:"hosp_part_amt"`
  4766. MedinsSetlID string `json:"medins_setl_id"`
  4767. PdnCashPay string `json:"pdn_cash_pay"`
  4768. } `json:"setlinfo"`
  4769. } `json:"output"`
  4770. RefmsgTime string `json:"refmsg_time"`
  4771. RespondTime string `json:"respond_time"`
  4772. Signtype interface{} `json:"signtype"`
  4773. WarnMsg interface{} `json:"warn_msg"`
  4774. }
  4775. type ResultSeventeen struct {
  4776. ErrMsg string `json:"err_msg"`
  4777. InfRefmsgid string `json:"inf_refmsgid"`
  4778. Infcode int64 `json:"infcode"`
  4779. Output struct {
  4780. SetlListId string `json:"setl_list_id"`
  4781. } `json:"output"`
  4782. RefmsgTime string `json:"refmsg_time"`
  4783. RespondTime string `json:"respond_time"`
  4784. Signtype string `json:"signtype"`
  4785. WarnInfo string `json:"warn_info"`
  4786. }
  4787. type ResultSeventeenOther struct {
  4788. ErrMsg string `json:"err_msg"`
  4789. InfRefmsgid string `json:"inf_refmsgid"`
  4790. Infcode string `json:"infcode"`
  4791. Output struct {
  4792. SetlListId string `json:"setl_list_id"`
  4793. } `json:"output"`
  4794. RefmsgTime string `json:"refmsg_time"`
  4795. RespondTime string `json:"respond_time"`
  4796. Signtype string `json:"signtype"`
  4797. WarnInfo string `json:"warn_info"`
  4798. }
  4799. type Result90991 struct {
  4800. ErrMsg string `json:"err_msg"`
  4801. InfRefmsgid string `json:"inf_refmsgid"`
  4802. Infcode int64 `json:"infcode"`
  4803. Output struct {
  4804. Result struct {
  4805. PsnNo string `json:"psn_no"`
  4806. CardStat string `json:"card_stat"`
  4807. Certno string `json:"certno"`
  4808. PsnName string `json:"psn_name"`
  4809. CheckStat string `json:"check_stat"`
  4810. SscnoCheckStat string `json:"sscno_check_stat"`
  4811. } `json:"result"`
  4812. } `json:"output"`
  4813. RefmsgTime string `json:"refmsg_time"`
  4814. RespondTime string `json:"respond_time"`
  4815. Signtype interface{} `json:"signtype"`
  4816. WarnInfo interface{} `json:"warn_info"`
  4817. }
  4818. type Result90100 struct {
  4819. ErrMsg string `json:"err_msg"`
  4820. InfRefmsgid string `json:"inf_refmsgid"`
  4821. Infcode int64 `json:"infcode"`
  4822. Output struct {
  4823. PoolareaNo string `json:"poolarea_no"`
  4824. PoolareaNoName string `json:"poolarea_no_name"`
  4825. Insutype string `json:"insutype"`
  4826. InsutypeName string `json:"insutype_name"`
  4827. ClctType string `json:"clct_type"`
  4828. ClctTypeName string `json:"clct_type_name"`
  4829. ClctFlag string `json:"clct_flag"`
  4830. ClctFlagName string `json:"clct_flag_name"`
  4831. AccrymBegn string `json:"accrym_begn"`
  4832. AccrymEnd string `json:"accrym_end"`
  4833. ClctTime string `json:"clct_time"`
  4834. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4835. } `json:"output"`
  4836. RefmsgTime string `json:"refmsg_time"`
  4837. RespondTime string `json:"respond_time"`
  4838. Signtype interface{} `json:"signtype"`
  4839. WarnInfo interface{} `json:"warn_info"`
  4840. }
  4841. type Custom struct {
  4842. DetItemFeeSumamt string
  4843. Cut string
  4844. FeedetlSn string
  4845. Price string
  4846. MedListCodg string
  4847. Type int64
  4848. AdviceId int64
  4849. ProjectId int64
  4850. ItemId int64
  4851. }
  4852. type Result5301 struct {
  4853. ErrMsg string `json:"err_msg"`
  4854. InfRefmsgid string `json:"inf_refmsgid"`
  4855. Infcode int64 `json:"infcode"`
  4856. Output struct {
  4857. Result []struct {
  4858. OpspDiseCode string `json:"opsp_dise_code"`
  4859. OpspDiseName string `json:"opsp_dise_name"`
  4860. Begndate string `json:"begndate"`
  4861. Enddate string `json:"enddate"`
  4862. } `json:"feedetail"`
  4863. } `json:"output"`
  4864. RefmsgTime string `json:"refmsg_time"`
  4865. RespondTime string `json:"respond_time"`
  4866. Signtype interface{} `json:"signtype"`
  4867. WarnInfo interface{} `json:"warn_info"`
  4868. }
  4869. type Result5301For10265 struct {
  4870. ErrMsg string `json:"err_msg"`
  4871. InfRefmsgid string `json:"inf_refmsgid"`
  4872. Infcode string `json:"infcode"`
  4873. Output struct {
  4874. Result []struct {
  4875. OpspDiseCode string `json:"opsp_dise_code"`
  4876. OpspDiseName string `json:"opsp_dise_name"`
  4877. Begndate string `json:"begndate"`
  4878. Enddate string `json:"enddate"`
  4879. } `json:"feedetail"`
  4880. } `json:"output"`
  4881. RefmsgTime string `json:"refmsg_time"`
  4882. RespondTime string `json:"respond_time"`
  4883. Signtype interface{} `json:"signtype"`
  4884. WarnInfo interface{} `json:"warn_info"`
  4885. }
  4886. //获取个人信息----挂号-----上传就诊信息
  4887. func (c *HisApiController) GetRegisterInfo() {
  4888. id, _ := c.GetInt64("id")
  4889. record_time := c.GetString("record_time")
  4890. settlementValue, _ := c.GetInt64("settlement_value")
  4891. medical_insurance_card := c.GetString("medical_insurance_card")
  4892. name := c.GetString("name")
  4893. id_card_type, _ := c.GetInt64("id_card_type")
  4894. certificates, _ := c.GetInt64("certificates")
  4895. medical_care, _ := c.GetInt64("medical_care")
  4896. birthday := c.GetString("birthday")
  4897. id_card := c.GetString("id_card")
  4898. register_type, _ := c.GetInt64("register")
  4899. doctor, _ := c.GetInt64("doctor")
  4900. department, _ := c.GetInt64("department")
  4901. gender, _ := c.GetInt64("sex")
  4902. registration_fee, _ := c.GetFloat("registration_fee")
  4903. medical_expenses, _ := c.GetFloat("medical_expenses")
  4904. social_type, _ := c.GetInt64("social_type")
  4905. med_type := c.GetString("social_type")
  4906. admin_user_id, _ := c.GetInt64("admin_user_id")
  4907. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4908. timeLayout := "2006-01-02"
  4909. loc, _ := time.LoadLocation("Local")
  4910. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4911. birthUnix := birthdays.Unix()
  4912. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4913. if err != nil {
  4914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4915. return
  4916. }
  4917. recordDateTime := theTime.Unix()
  4918. adminInfo := c.GetAdminUserInfo()
  4919. var patient service.Patients
  4920. if id == 0 {
  4921. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4922. } else {
  4923. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4924. }
  4925. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4926. if patientPrescription.ID == 0 {
  4927. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4928. }
  4929. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4930. if patient.ID == 0 {
  4931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4932. return
  4933. }
  4934. if len(patient.IdCardNo) == 0 {
  4935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4936. return
  4937. }
  4938. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4939. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4940. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4941. //就诊结算未完成,不能进行二次挂号
  4942. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4943. if len(his) >= 1 {
  4944. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4945. if len(his) >= 1 && order.ID == 0 {
  4946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4947. return
  4948. }
  4949. }
  4950. //var register_log string
  4951. if config.IsOpen == 1 {
  4952. var res ResultTwo
  4953. var res10265 ResultTwo10265
  4954. var PsnNo string
  4955. var PsnCertType string
  4956. var Certno string
  4957. var PsnName string
  4958. var Gend string
  4959. var Naty string
  4960. var Brdy string
  4961. var Age float64
  4962. var infoStr string
  4963. var idetinfoStr string
  4964. var infocode int64
  4965. var verify_number string
  4966. fmt.Println(verify_number)
  4967. if miConfig.MdtrtareaAdmvs == "421300" {
  4968. psn_info, _ := service.GetPsnByPatientId(id)
  4969. PsnNo = psn_info.PsnNo
  4970. PsnCertType = psn_info.PsnCertType
  4971. Certno = psn_info.Certno
  4972. PsnName = psn_info.PsnName
  4973. Gend = psn_info.Gend
  4974. Naty = psn_info.Naty
  4975. Brdy = psn_info.Brdy
  4976. Age = psn_info.Age
  4977. infoStr = psn_info.Insuinfo
  4978. idetinfoStr = psn_info.Idetinfo
  4979. infocode = 0
  4980. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4981. psn_info, _ := service.GetPsnByPatientId(id)
  4982. PsnNo = psn_info.PsnNo
  4983. PsnCertType = psn_info.PsnCertType
  4984. Certno = psn_info.Certno
  4985. PsnName = psn_info.PsnName
  4986. Gend = psn_info.Gend
  4987. Naty = psn_info.Naty
  4988. Brdy = psn_info.Brdy
  4989. Age = psn_info.Age
  4990. infoStr = psn_info.Insuinfo
  4991. idetinfoStr = psn_info.Idetinfo
  4992. infocode = 0
  4993. verify_number = psn_info.VerifyNumber
  4994. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4995. if id_card_type == 1 {
  4996. psn_info, _ := service.GetPsnByPatientId(id)
  4997. PsnNo = psn_info.PsnNo
  4998. PsnCertType = psn_info.PsnCertType
  4999. Certno = psn_info.Certno
  5000. PsnName = psn_info.PsnName
  5001. Gend = psn_info.Gend
  5002. Naty = psn_info.Naty
  5003. Brdy = psn_info.Brdy
  5004. Age = psn_info.Age
  5005. infoStr = psn_info.Insuinfo
  5006. idetinfoStr = psn_info.Idetinfo
  5007. infocode = 0
  5008. verify_number = psn_info.VerifyNumber
  5009. } else if id_card_type == 2 {
  5010. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5011. fmt.Println(errMsgLog)
  5012. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5014. utils.ErrorLog("解析失败:%v", err)
  5015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5016. return
  5017. }
  5018. PsnNo = res.Output.Baseinfo.PsnNo
  5019. PsnCertType = res.Output.Baseinfo.PsnCertType
  5020. Certno = res.Output.Baseinfo.Certno
  5021. PsnName = res.Output.Baseinfo.PsnName
  5022. Gend = res.Output.Baseinfo.Gend
  5023. Naty = res.Output.Baseinfo.Naty
  5024. Brdy = res.Output.Baseinfo.Brdy
  5025. Age = res.Output.Baseinfo.Age
  5026. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5027. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5028. infoStr = string(Iinfos)
  5029. idetinfoStr = string(Idetinfos)
  5030. infocode = res.Infcode
  5031. }
  5032. } else {
  5033. var result string
  5034. var requestLog string
  5035. if miConfig.UserOrgId == 10138 {
  5036. if id_card_type == 4 {
  5037. psn_info, _ := service.GetPsnByPatientId(id)
  5038. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  5039. } else {
  5040. 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)
  5041. }
  5042. } else {
  5043. 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)
  5044. }
  5045. saveLog(result, requestLog, "1101", "人员基本信息获取")
  5046. if miConfig.Code == "H15049901371" {
  5047. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5048. utils.ErrorLog("解析失败:%v", err)
  5049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5050. return
  5051. }
  5052. res.ErrMsg = res10265.ErrMsg
  5053. res.Output = res10265.Output
  5054. res.InfRefmsgid = res10265.InfRefmsgid
  5055. } else {
  5056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5057. utils.ErrorLog("解析失败:%v", err)
  5058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5059. return
  5060. }
  5061. }
  5062. PsnNo = res.Output.Baseinfo.PsnNo
  5063. PsnCertType = res.Output.Baseinfo.PsnCertType
  5064. Certno = res.Output.Baseinfo.Certno
  5065. PsnName = res.Output.Baseinfo.PsnName
  5066. Gend = res.Output.Baseinfo.Gend
  5067. Naty = res.Output.Baseinfo.Naty
  5068. Brdy = res.Output.Baseinfo.Brdy
  5069. Age = res.Output.Baseinfo.Age
  5070. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5071. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5072. infoStr = string(Iinfos)
  5073. idetinfoStr = string(Idetinfos)
  5074. if miConfig.Code == "H15049901371" {
  5075. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  5076. } else {
  5077. infocode = res.Infcode
  5078. }
  5079. }
  5080. if infocode == 0 {
  5081. his := models.VMHisPatient{
  5082. Name: name,
  5083. Gender: gender,
  5084. Birthday: birthUnix,
  5085. MedicalTreatmentType: medical_care,
  5086. IdType: certificates,
  5087. IdCardNo: id_card,
  5088. BalanceAccountsType: settlementValue,
  5089. SocialType: social_type,
  5090. MedicalInsuranceNumber: medical_insurance_card,
  5091. RegisterType: register_type,
  5092. RegisterCost: registration_fee,
  5093. TreatmentCost: medical_expenses,
  5094. Status: 1,
  5095. Ctime: time.Now().Unix(),
  5096. Mtime: time.Now().Unix(),
  5097. PsnNo: PsnNo,
  5098. PsnCertType: PsnCertType,
  5099. Certno: Certno,
  5100. PsnName: PsnName,
  5101. Gend: Gend,
  5102. Naty: Naty,
  5103. Brdy: Brdy,
  5104. Age: Age,
  5105. Iinfo: infoStr,
  5106. Idetinfo: idetinfoStr,
  5107. PatientId: patient.ID,
  5108. RecordDate: theTime.Unix(),
  5109. UserOrgId: adminInfo.CurrentOrgId,
  5110. AdminUserId: admin_user_id,
  5111. IsReturn: 1,
  5112. IdCardType: id_card_type,
  5113. Doctor: doctor,
  5114. Departments: department,
  5115. }
  5116. timestamp := time.Now().Unix()
  5117. tempTime := time.Unix(timestamp, 0)
  5118. timeFormat := tempTime.Format("20060102150405")
  5119. chrgBchno := rand.Intn(100000) + 10000
  5120. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5121. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  5122. department, _ := service.GetDepartMentDetail(department)
  5123. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  5124. IdCardNo := ""
  5125. if id_card_type == 1 {
  5126. // IdCardNo = medical_insurance_card
  5127. IdCardNo = patient.IdCardNo
  5128. } else {
  5129. IdCardNo = patient.IdCardNo
  5130. }
  5131. var rf []*ResultFive
  5132. json.Unmarshal([]byte(his.Iinfo), &rf)
  5133. var insutypes []*ResultFive
  5134. var insutype string
  5135. var insuplc_admdvs_temp string
  5136. var is390 int = 0
  5137. var is310 int = 0
  5138. for _, item := range rf {
  5139. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5140. insutypes = append(insutypes, item)
  5141. }
  5142. }
  5143. if len(insutypes) == 1 {
  5144. insutype = insutypes[0].Insutype
  5145. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5146. } else {
  5147. for _, i := range insutypes {
  5148. if i.Insutype == "390" {
  5149. is390 = 1
  5150. }
  5151. if i.Insutype == "310" {
  5152. is310 = 1
  5153. }
  5154. }
  5155. }
  5156. if is390 == 1 {
  5157. insutype = "390"
  5158. }
  5159. if is310 == 1 {
  5160. insutype = "310"
  5161. }
  5162. if len(insutypes) == 0 {
  5163. insutype = "310"
  5164. }
  5165. if len(insutypes) == 2 {
  5166. insutype = med_type
  5167. }
  5168. if len(med_type) > 0 {
  5169. insutype = med_type
  5170. }
  5171. //for _, item := range rf {
  5172. // if item.Insutype == insutype {
  5173. // insuplc_admdvs = item.InsuplcAdmdvs
  5174. // }
  5175. //}
  5176. var infocode int64
  5177. var resThree ResultThree
  5178. var resThree10265 ResultThree10265
  5179. if len(insuplc_admdvs) == 0 {
  5180. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  5181. } else {
  5182. insuplc_admdvs_temp = insuplc_admdvs
  5183. }
  5184. if miConfig.MdtrtareaAdmvs == "421300" {
  5185. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  5186. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  5187. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5188. "&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
  5189. resp, requestErr := http.Get(api)
  5190. if requestErr != nil {
  5191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. return
  5193. }
  5194. body, ioErr := ioutil.ReadAll(resp.Body)
  5195. if ioErr != nil {
  5196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. return
  5199. }
  5200. var respJSON map[string]interface{}
  5201. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5207. result, _ := json.Marshal(respJSON)
  5208. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5209. utils.ErrorLog("解析失败:%v", err)
  5210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5211. return
  5212. }
  5213. infocode = resThree.Infcode
  5214. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5215. psn_info, _ := service.GetPsnByPatientId(id)
  5216. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5217. var cert_no string
  5218. if id_card_type == 3 {
  5219. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  5220. cert_no = IdCardNo
  5221. } else if id_card_type == 4 {
  5222. cert_no = IdCardNo
  5223. psn_info.VerifyNumber = psn_info.VerifyNumber
  5224. } else {
  5225. bas := strings.Split(psn_info.CardInfo, "|")
  5226. cert_no = bas[2]
  5227. }
  5228. var hisPrescription []*models.HisPrescription
  5229. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  5230. if res3101.Infcode == "0" && len(res3101.Output.Result) > 0 {
  5231. for _, item := range res3101.Output.Result {
  5232. if len(res3101.ErrMsg) == 0 {
  5233. res3101.ErrMsg = item.VolaCont
  5234. } else {
  5235. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  5236. }
  5237. }
  5238. c.ServeSuccessJSON(map[string]interface{}{
  5239. "failed_code": -10,
  5240. "msg": res3101.ErrMsg,
  5241. })
  5242. return
  5243. } else if res3101.Infcode != "0" {
  5244. c.ServeSuccessJSON(map[string]interface{}{
  5245. "failed_code": -10,
  5246. "msg": res3101.ErrMsg,
  5247. })
  5248. return
  5249. }
  5250. var api string
  5251. if miConfig.MdtrtareaAdmvs == "320921" {
  5252. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5253. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5254. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5255. } else {
  5256. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  5257. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  5258. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5259. }
  5260. resp, requestErr := http.Get(api)
  5261. if requestErr != nil {
  5262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5263. return
  5264. }
  5265. body, ioErr := ioutil.ReadAll(resp.Body)
  5266. if ioErr != nil {
  5267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5269. return
  5270. }
  5271. var respJSON map[string]interface{}
  5272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5275. return
  5276. }
  5277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5278. result, _ := json.Marshal(respJSON)
  5279. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5280. utils.ErrorLog("解析失败:%v", err)
  5281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5282. return
  5283. }
  5284. resThree.ErrMsg = resThree10265.ErrMsg
  5285. resThree.Output = resThree10265.Output
  5286. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5287. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5288. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5289. psn_info, _ := service.GetPsnByPatientId(id)
  5290. var cert_no string
  5291. if id_card_type == 1 {
  5292. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5293. } else {
  5294. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5295. }
  5296. fmt.Println(cert_no)
  5297. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  5298. saveLog(result, requestLog, "2201", "挂号")
  5299. if miConfig.Code == "H15049901371" {
  5300. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5301. utils.ErrorLog("解析失败:%v", err)
  5302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5303. return
  5304. }
  5305. resThree.ErrMsg = resThree10265.ErrMsg
  5306. resThree.Output = resThree10265.Output
  5307. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5308. } else {
  5309. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5310. utils.ErrorLog("解析失败:%v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. }
  5315. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5316. } else {
  5317. psn_info, _ := service.GetPsnByPatientId(id)
  5318. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  5319. saveLog(result, requestLog, "2201A", "挂号")
  5320. if miConfig.Code == "H15049901371" {
  5321. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5322. utils.ErrorLog("解析失败:%v", err)
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5324. return
  5325. }
  5326. resThree.ErrMsg = resThree10265.ErrMsg
  5327. resThree.Output = resThree10265.Output
  5328. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5329. } else {
  5330. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5331. utils.ErrorLog("解析失败:%v", err)
  5332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5333. return
  5334. }
  5335. }
  5336. if miConfig.Code == "H15049901371" {
  5337. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5338. } else {
  5339. infocode = resThree.Infcode
  5340. }
  5341. }
  5342. if infocode != 0 {
  5343. adminUser := c.GetAdminUserInfo()
  5344. errlog := &models.HisOrderError{
  5345. UserOrgId: adminUser.CurrentOrgId,
  5346. Ctime: time.Now().Unix(),
  5347. Mtime: time.Now().Unix(),
  5348. ErrMsg: resThree.ErrMsg,
  5349. Status: 1,
  5350. PatientId: id,
  5351. RecordTime: recordDateTime,
  5352. Stage: 2,
  5353. }
  5354. service.CreateErrMsgLog(errlog)
  5355. c.ServeSuccessJSON(map[string]interface{}{
  5356. "failed_code": -10,
  5357. "msg": resThree.ErrMsg,
  5358. })
  5359. return
  5360. }
  5361. his.Number = resThree.Output.Data.MdtrtID
  5362. his.PsnNo = resThree.Output.Data.PsnNo
  5363. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5364. his.IdCardNo = patient.IdCardNo
  5365. his.PhoneNumber = patient.Phone
  5366. his.UserOrgId = adminInfo.CurrentOrgId
  5367. his.Insutype = insutype
  5368. his.Ctime = time.Now().Unix()
  5369. his.Mtime = time.Now().Unix()
  5370. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5371. his.Status = 1
  5372. service.UpdateHisPatientStatus(&his)
  5373. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5374. c.ServeSuccessJSON(map[string]interface{}{
  5375. "his_info": his,
  5376. })
  5377. } else {
  5378. adminUser := c.GetAdminUserInfo()
  5379. errlog := &models.HisOrderError{
  5380. UserOrgId: adminUser.CurrentOrgId,
  5381. Ctime: time.Now().Unix(),
  5382. Mtime: time.Now().Unix(),
  5383. ErrMsg: res.ErrMsg,
  5384. Status: 1,
  5385. PatientId: id,
  5386. RecordTime: recordDateTime,
  5387. Stage: 1,
  5388. }
  5389. service.CreateErrMsgLog(errlog)
  5390. c.ServeSuccessJSON(map[string]interface{}{
  5391. "failed_code": -10,
  5392. "msg": res.ErrMsg,
  5393. })
  5394. return
  5395. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5396. }
  5397. }
  5398. }
  5399. //上传明细----预结算----确认订单
  5400. func (c *HisApiController) GetUploadInfo() {
  5401. id, _ := c.GetInt64("id")
  5402. record_time := c.GetString("record_time")
  5403. his_patient_id, _ := c.GetInt64("his_patient_id")
  5404. order_id, _ := c.GetInt64("order_id")
  5405. pay_way, _ := c.GetInt64("pay_way")
  5406. pay_price, _ := c.GetFloat("pay_price")
  5407. pay_card_no := c.GetString("pay_card_no")
  5408. token := c.GetString("token")
  5409. discount_price, _ := c.GetFloat("discount_price")
  5410. preferential_price, _ := c.GetFloat("preferential_price")
  5411. reality_price, _ := c.GetFloat("reality_price")
  5412. found_price, _ := c.GetFloat("found_price")
  5413. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5414. private_price, _ := c.GetFloat("private_price")
  5415. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5416. admin_user_id, _ := c.GetInt64("admin_user_id")
  5417. fapiao_code := c.GetString("fapiao_code")
  5418. fapiao_number := c.GetString("fapiao_number")
  5419. diagnosis_id := c.GetString("diagnosis")
  5420. sick_type, _ := c.GetInt64("sick_type")
  5421. reg_type, _ := c.GetInt64("p_type")
  5422. begin_time := c.GetString("begin_time")
  5423. id_str := c.GetString("ids")
  5424. ids_arr := strings.Split(id_str, ",")
  5425. timeLayout := "2006-01-02"
  5426. loc, _ := time.LoadLocation("Local")
  5427. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5428. if err != nil {
  5429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5430. return
  5431. }
  5432. recordDateTime := theTime.Unix()
  5433. adminUser := c.GetAdminUserInfo()
  5434. var tempOrder models.HisOrder
  5435. tempOrder, _ = service.GetHisOrderByID(order_id)
  5436. var prescriptions []*models.HisPrescription
  5437. var start_time int64
  5438. var end_time int64
  5439. //押金模块
  5440. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5441. tmp_decimal := c.GetString("tmp_decimal")
  5442. var decimal float64 //本次使用的押金
  5443. var errmsg error
  5444. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5445. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5446. return
  5447. }
  5448. if len(tmp_decimal) > 0 {
  5449. if tmp_decimal[0] == 45 {
  5450. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5451. return
  5452. }
  5453. }
  5454. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5455. fmt.Println(errs)
  5456. decimal = tt
  5457. //if adminUser.CurrentOrgId == 10106{
  5458. // if len(fapiao_code) == 0{
  5459. // fapiao_code = "144072080589"
  5460. // }
  5461. // if len(fapiao_number) == 0{
  5462. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5463. // if order.ID == 0{
  5464. // fapiao_number = "00001520"
  5465. // }else{
  5466. // //fapiao_code = "00001520"
  5467. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5468. // var zero string
  5469. // if fpNumber >= 1000{
  5470. // zero = "0000" + strconv.Itoa(fpNumber)
  5471. // }else if fpNumber >= 10000{
  5472. // zero = "000" + strconv.Itoa(fpNumber)
  5473. // } else if fpNumber >= 100000{
  5474. // zero = "00" + strconv.Itoa(fpNumber)
  5475. // } else if fpNumber >= 1000000{
  5476. // zero = "0" + strconv.Itoa(fpNumber)
  5477. // }else {
  5478. // zero = strconv.Itoa(fpNumber)
  5479. // }
  5480. // fapiao_number = zero
  5481. // }
  5482. // }
  5483. //}
  5484. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5485. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5486. var patientPrescription models.HisPrescriptionInfo
  5487. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5488. if patientPrescription.ID == 0 {
  5489. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5490. }
  5491. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5492. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5493. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5494. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5495. var config []*models.HisXtDiagnoseConfig
  5496. for _, item := range diagnosis_ids {
  5497. id, _ := strconv.ParseInt(item, 10, 64)
  5498. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5499. config = append(config, &diagnosisConfig)
  5500. }
  5501. sickConfig, _ := service.FindSickById(sick_type)
  5502. //if tempOrder.ID == 0 {
  5503. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5504. //}
  5505. if tempOrder.ID == 0 {
  5506. var result string
  5507. var requestLog string
  5508. var res2 ResultSix
  5509. var ressix10265 ResultSix10265
  5510. if miConfig.MdtrtareaAdmvs == "421300" {
  5511. data := make(map[string]interface{})
  5512. client := &http.Client{}
  5513. data["psn_no"] = his.PsnNo
  5514. data["mdtrt_id"] = his.Number
  5515. data["opter"] = roles.UserName
  5516. data["org_name"] = miConfig.OrgName
  5517. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5518. data["doctor_id"] = doctor_info.DoctorNumber
  5519. data["doctor_name"] = doctor_info.UserName
  5520. data["department"] = department.Name
  5521. data["fixmedins_code"] = miConfig.Code
  5522. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5523. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5524. data["secret_key"] = miConfig.SecretKey
  5525. data["sick_code"] = sickConfig.CountryCode
  5526. data["sick_name"] = sickConfig.ClassName
  5527. data["dept"] = strconv.FormatInt(department.ID, 10)
  5528. data["config"] = config
  5529. data["begin_time"] = begin_time
  5530. bytesData, _ := json.Marshal(data)
  5531. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5532. resp, _ := client.Do(req)
  5533. defer resp.Body.Close()
  5534. body, ioErr := ioutil.ReadAll(resp.Body)
  5535. if ioErr != nil {
  5536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5538. return
  5539. }
  5540. var respJSON map[string]interface{}
  5541. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5544. return
  5545. }
  5546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5547. userJSONBytes, _ := json.Marshal(respJSON)
  5548. fmt.Println("log")
  5549. fmt.Println(string(userJSONBytes))
  5550. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5551. utils.ErrorLog("解析失败:%v", err)
  5552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. return
  5554. }
  5555. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5556. //江苏地区国家医保医疗类别
  5557. //职工透析:医疗类别选特殊情况门诊9933
  5558. //居民血透门慢: 医疗类别选门诊慢病1402
  5559. //var med_type string
  5560. //if his.Insutype == "310" {
  5561. // if reg_type == 14 {
  5562. // med_type = "9933"
  5563. // } else if reg_type == 11 {
  5564. // med_type = "11"
  5565. //
  5566. // }
  5567. //} else if his.Insutype == "390" {
  5568. // if reg_type == 14 {
  5569. // med_type = "1402"
  5570. // } else if reg_type == 11 {
  5571. // med_type = "11"
  5572. // }
  5573. //}
  5574. data := make(map[string]interface{})
  5575. client := &http.Client{}
  5576. data["psn_no"] = his.PsnNo
  5577. data["mdtrt_id"] = his.Number
  5578. data["doctor"] = roles.UserName
  5579. data["department"] = department.Name
  5580. data["org_name"] = miConfig.OrgName
  5581. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5582. data["doctor_id"] = doctor_info.DoctorNumber
  5583. data["new_doctor_name"] = doctor_info.UserName
  5584. data["fixmedins_code"] = miConfig.Code
  5585. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5586. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5587. data["secret_key"] = miConfig.SecretKey
  5588. data["sick_code"] = sickConfig.CountryCode
  5589. data["sick_name"] = sickConfig.ClassName
  5590. data["url"] = miConfig.Url
  5591. data["ak"] = miConfig.AccessKey
  5592. data["begin_time"] = begin_time
  5593. data["cainfo"] = miConfig.Cainfo
  5594. data["dept"] = strconv.FormatInt(department.ID, 10)
  5595. data["config"] = config
  5596. bytesData, _ := json.Marshal(data)
  5597. var req *http.Request
  5598. if miConfig.MdtrtareaAdmvs == "320921" {
  5599. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5600. //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 +
  5601. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5602. } else {
  5603. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5604. }
  5605. resp, _ := client.Do(req)
  5606. defer resp.Body.Close()
  5607. body, ioErr := ioutil.ReadAll(resp.Body)
  5608. if ioErr != nil {
  5609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5611. return
  5612. }
  5613. var respJSON map[string]interface{}
  5614. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5617. return
  5618. }
  5619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5620. userJSONBytes, _ := json.Marshal(respJSON)
  5621. fmt.Println("log")
  5622. fmt.Println(string(userJSONBytes))
  5623. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5624. utils.ErrorLog("解析失败:%v", err)
  5625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5626. return
  5627. }
  5628. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5629. res2.Output = ressix10265.Output
  5630. res2.ErrMsg = ressix10265.ErrMsg
  5631. res2.Cainfo = ressix10265.Cainfo
  5632. res2.WarnMsg = ressix10265.WarnMsg
  5633. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5634. res2.Infcode = infocode
  5635. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5636. 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)
  5637. saveLog(result, requestLog, "2203", "上传就诊信息")
  5638. var respJSON2 map[string]interface{}
  5639. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5642. return
  5643. }
  5644. userJSONBytes2, _ := json.Marshal(respJSON2)
  5645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5646. utils.ErrorLog("解析失败:%v", err)
  5647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5648. return
  5649. }
  5650. } else {
  5651. if miConfig.MdtrtareaAdmvs == "440781" { //
  5652. 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)
  5653. } else {
  5654. if miConfig.Code == "H15049901371" {
  5655. //赤峰地区国家医保医疗类别
  5656. //职工透析:医疗类别选特殊情况门诊990502
  5657. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5658. var med_type string
  5659. if his.Insutype == "390" {
  5660. if reg_type == 14 {
  5661. med_type = "9933"
  5662. } else if reg_type == 11 {
  5663. med_type = "11"
  5664. }
  5665. } else if his.Insutype == "310" {
  5666. if reg_type == 14 {
  5667. med_type = "990502"
  5668. } else if reg_type == 11 {
  5669. med_type = "11"
  5670. }
  5671. }
  5672. 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)
  5673. } else {
  5674. 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)
  5675. }
  5676. }
  5677. saveLog(result, requestLog, "2203", "上传就诊信息")
  5678. var respJSON2 map[string]interface{}
  5679. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5682. return
  5683. }
  5684. userJSONBytes2, _ := json.Marshal(respJSON2)
  5685. if miConfig.Code == "H15049901371" {
  5686. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5687. utils.ErrorLog("解析失败:%v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5692. res2.Output = ressix10265.Output
  5693. res2.ErrMsg = ressix10265.ErrMsg
  5694. res2.Cainfo = ressix10265.Cainfo
  5695. res2.WarnMsg = ressix10265.WarnMsg
  5696. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5697. res2.Infcode = infocode
  5698. } else {
  5699. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5700. utils.ErrorLog("解析失败:%v", err)
  5701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5702. return
  5703. }
  5704. }
  5705. }
  5706. if res2.Infcode != 0 {
  5707. adminUser := c.GetAdminUserInfo()
  5708. errlog := &models.HisOrderError{
  5709. UserOrgId: adminUser.CurrentOrgId,
  5710. Ctime: time.Now().Unix(),
  5711. Mtime: time.Now().Unix(),
  5712. ErrMsg: res2.ErrMsg,
  5713. Status: 1,
  5714. PatientId: id,
  5715. RecordTime: recordDateTime,
  5716. Stage: 3,
  5717. }
  5718. service.CreateErrMsgLog(errlog)
  5719. c.ServeSuccessJSON(map[string]interface{}{
  5720. "failed_code": -10,
  5721. "msg": res2.ErrMsg,
  5722. })
  5723. return
  5724. } else {
  5725. his.Diagnosis = diagnosis_id
  5726. his.SickType = sickConfig.ID
  5727. //var p_type int64
  5728. //if reg_type == 1111 || reg_type == 1112 {
  5729. // p_type = 11
  5730. //
  5731. //}
  5732. his.PType = fmt.Sprintf("%d", reg_type)
  5733. service.UpdateHisPatientThree(&his)
  5734. data := make(map[string]interface{})
  5735. if settle_accounts_type == 1 { //日结
  5736. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5737. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5738. } else {
  5739. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5740. }
  5741. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5742. data["pre"] = prescriptions
  5743. } else { //月结
  5744. start_time_str := c.GetString("start_time")
  5745. end_time_str := c.GetString("end_time")
  5746. timeLayout := "2006-01-02"
  5747. loc, _ := time.LoadLocation("Local")
  5748. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5749. if err != nil {
  5750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5751. return
  5752. }
  5753. recordStartTime := theStartTime.Unix()
  5754. start_time = recordStartTime
  5755. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5756. if err != nil {
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5758. return
  5759. }
  5760. recordEndTime := theEndTime.Unix()
  5761. end_time = recordEndTime
  5762. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5763. data["pre"] = prescriptions
  5764. }
  5765. timestamp := time.Now().Unix()
  5766. tempTime := time.Unix(timestamp, 0)
  5767. timeFormat := tempTime.Format("20060102150405")
  5768. chrgBchno := rand.Intn(100000) + 10000
  5769. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5770. strconv.FormatInt(his.PatientId, 10)
  5771. client := &http.Client{}
  5772. data["psn_no"] = his.PsnNo
  5773. data["mdtrt_id"] = his.Number
  5774. data["chrg_bchno"] = chrg_bchno
  5775. data["org_name"] = miConfig.OrgName
  5776. data["doctor"] = doctor_info.UserName
  5777. data["doctor_id"] = doctor_info.DoctorNumber
  5778. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5779. data["fixmedins_code"] = miConfig.Code
  5780. data["opter"] = roles.UserName
  5781. data["dept_code"] = department.Number
  5782. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5783. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5784. data["secret_key"] = miConfig.SecretKey
  5785. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5786. data["url"] = miConfig.Url
  5787. data["ak"] = miConfig.AccessKey
  5788. data["new_doctor_name"] = patientPrescription.Doctor
  5789. data["diag_code"] = sickConfig.CountryCode
  5790. data["cainfo"] = miConfig.Cainfo
  5791. var ids []int64
  5792. for _, item := range prescriptions {
  5793. ids = append(ids, item.ID)
  5794. }
  5795. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5796. if config.IsOpen == 1 { //对接了医保,走医保流程
  5797. var res ResultFour
  5798. var resFour10265 ResultFour10265
  5799. if miConfig.MdtrtareaAdmvs == "421300" {
  5800. bytesData, _ := json.Marshal(data)
  5801. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5802. resp, _ := client.Do(req)
  5803. defer resp.Body.Close()
  5804. body, ioErr := ioutil.ReadAll(resp.Body)
  5805. if ioErr != nil {
  5806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5808. return
  5809. }
  5810. var respJSON map[string]interface{}
  5811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. return
  5815. }
  5816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5817. userJSONBytes, _ := json.Marshal(respJSON)
  5818. fmt.Println("log")
  5819. fmt.Println(string(userJSONBytes))
  5820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5821. utils.ErrorLog("解析失败:%v", err)
  5822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5823. return
  5824. }
  5825. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5826. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5827. if result3101.Infcode == "0" {
  5828. if len(result3101.Output.Result) > 0 {
  5829. var errMsgs []string
  5830. for _, item := range result3101.Output.Result {
  5831. errMsgs = append(errMsgs, item.VolaCont)
  5832. }
  5833. c.ServeSuccessJSON(map[string]interface{}{
  5834. "failed_code": -10,
  5835. "msg": errMsgs,
  5836. })
  5837. return
  5838. }
  5839. }
  5840. bytesData, _ := json.Marshal(data)
  5841. var req *http.Request
  5842. if miConfig.MdtrtareaAdmvs == "320921" {
  5843. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5844. } else {
  5845. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5846. }
  5847. resp, _ := client.Do(req)
  5848. defer resp.Body.Close()
  5849. body, ioErr := ioutil.ReadAll(resp.Body)
  5850. if ioErr != nil {
  5851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5853. return
  5854. }
  5855. var respJSON map[string]interface{}
  5856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5859. return
  5860. }
  5861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5862. userJSONBytes, _ := json.Marshal(respJSON)
  5863. fmt.Println("log")
  5864. fmt.Println(string(userJSONBytes))
  5865. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5866. utils.ErrorLog("解析失败:%v", err)
  5867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5868. return
  5869. }
  5870. res.InfRefmsgid = resFour10265.InfRefmsgid
  5871. res.Output = resFour10265.Output
  5872. res.ErrMsg = resFour10265.ErrMsg
  5873. res.Cainfo = resFour10265.Cainfo
  5874. res.WarnMsg = resFour10265.WarnMsg
  5875. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5876. res.Infcode = infocode
  5877. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5878. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  5879. var dat map[string]interface{}
  5880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5881. fmt.Println(dat)
  5882. } else {
  5883. fmt.Println(err)
  5884. }
  5885. saveLog(result, request_log, "2204", "上传费用明细")
  5886. userJSONBytes, _ := json.Marshal(dat)
  5887. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5888. utils.ErrorLog("解析失败:%v", err)
  5889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. return
  5891. }
  5892. res.InfRefmsgid = resFour10265.InfRefmsgid
  5893. res.Output = resFour10265.Output
  5894. res.ErrMsg = resFour10265.ErrMsg
  5895. res.Cainfo = resFour10265.Cainfo
  5896. res.WarnMsg = resFour10265.WarnMsg
  5897. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5898. res.Infcode = infocode
  5899. } else {
  5900. if miConfig.Code == "H15049901371" {
  5901. 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)
  5902. var dat map[string]interface{}
  5903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5904. fmt.Println(dat)
  5905. } else {
  5906. fmt.Println(err)
  5907. }
  5908. saveLog(result, request_log, "2204", "上传费用明细")
  5909. userJSONBytes, _ := json.Marshal(dat)
  5910. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5911. utils.ErrorLog("解析失败:%v", err)
  5912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5913. return
  5914. }
  5915. res.InfRefmsgid = resFour10265.InfRefmsgid
  5916. res.Output = resFour10265.Output
  5917. res.ErrMsg = resFour10265.ErrMsg
  5918. res.Cainfo = resFour10265.Cainfo
  5919. res.WarnMsg = resFour10265.WarnMsg
  5920. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5921. res.Infcode = infocode
  5922. } else {
  5923. 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)
  5924. var dat map[string]interface{}
  5925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5926. fmt.Println(dat)
  5927. } else {
  5928. fmt.Println(err)
  5929. }
  5930. saveLog(result, request_log, "2204", "上传费用明细")
  5931. userJSONBytes, _ := json.Marshal(dat)
  5932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5933. utils.ErrorLog("解析失败:%v", err)
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5935. return
  5936. }
  5937. }
  5938. }
  5939. if res.Infcode == 0 {
  5940. order := &models.HisOrder{
  5941. UserOrgId: adminUser.CurrentOrgId,
  5942. HisPatientId: his.ID,
  5943. PatientId: his.PatientId,
  5944. SettleAccountsDate: recordDateTime,
  5945. MdtrtId: his.Number,
  5946. PsnNo: his.PsnNo,
  5947. MedType: strconv.FormatInt(reg_type, 10),
  5948. Ctime: time.Now().Unix(),
  5949. Mtime: time.Now().Unix(),
  5950. Status: 1,
  5951. Number: chrg_bchno,
  5952. Infcode: res.Infcode,
  5953. WarnMsg: res.WarnMsg,
  5954. Cainfo: res.Cainfo,
  5955. ErrMsg: res.ErrMsg,
  5956. RespondTime: res.RefmsgTime,
  5957. InfRefmsgid: res.InfRefmsgid,
  5958. OrderStatus: 1,
  5959. PayWay: pay_way,
  5960. PayPrice: pay_price,
  5961. PayCardNo: pay_card_no,
  5962. DiscountPrice: discount_price,
  5963. PreferentialPrice: preferential_price,
  5964. RealityPrice: reality_price,
  5965. FoundPrice: found_price,
  5966. MedicalInsurancePrice: medical_insurance_price,
  5967. PrivatePrice: private_price,
  5968. IsMedicineInsurance: 1,
  5969. SettleType: settle_accounts_type,
  5970. SettleStartTime: start_time,
  5971. SettleEndTime: end_time,
  5972. Creator: roles.AdminUserId,
  5973. Modify: roles.AdminUserId,
  5974. FaPiaoNumber: fapiao_number,
  5975. FaPiaoCode: fapiao_code,
  5976. PType: 2,
  5977. Diagnosis: diagnosis_id,
  5978. }
  5979. err = service.CreateOrder(order)
  5980. if err != nil {
  5981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5982. return
  5983. }
  5984. for _, item := range res.Output.Result {
  5985. temp := strings.Split(item.FeedetlSn, "-")
  5986. var advice_id int64 = 0
  5987. var project_id int64 = 0
  5988. var types int64 = 0
  5989. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5990. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5991. if temp[1] == "1" {
  5992. advice_id = id
  5993. project_id = 0
  5994. } else if temp[1] == "2" {
  5995. advice_id = 0
  5996. project_id = id
  5997. }
  5998. info := &models.HisOrderInfo{
  5999. OrderNumber: order.Number,
  6000. FeedetlSn: item.FeedetlSn,
  6001. UploadDate: time.Now().Unix(),
  6002. AdviceId: advice_id,
  6003. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6004. Cnt: item.Cnt,
  6005. Pric: float64(item.Pric),
  6006. PatientId: his.PatientId,
  6007. PricUplmtAmt: item.PricUplmtAmt,
  6008. SelfpayProp: item.SelfpayProp,
  6009. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6010. OverlmtAmt: item.OverlmtAmt,
  6011. PreselfpayAmt: item.PreselfpayAmt,
  6012. BasMednFlag: item.BasMednFlag,
  6013. MedChrgitmType: item.MedChrgitmType,
  6014. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6015. Status: 1,
  6016. Memo: item.Memo,
  6017. Mtime: time.Now().Unix(),
  6018. InscpScpAmt: item.InscpScpAmt,
  6019. DrtReimFlag: item.DrtReimFlag,
  6020. Ctime: time.Now().Unix(),
  6021. ListSpItemFlag: item.ListSpItemFlag,
  6022. ChldMedcFlag: item.ChldMedcFlag,
  6023. LmtUsedFlag: item.LmtUsedFlag,
  6024. ChrgitmLv: item.ChrgitmLv,
  6025. UserOrgId: adminUser.CurrentOrgId,
  6026. HisPatientId: his.ID,
  6027. OrderId: order.ID,
  6028. ProjectId: project_id,
  6029. Type: types,
  6030. }
  6031. service.CreateOrderInfo(info)
  6032. }
  6033. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6034. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6035. var total float64
  6036. for _, item := range prescriptions {
  6037. if item.Type == 1 { //药品
  6038. for _, subItem := range item.HisDoctorAdviceInfo {
  6039. total = total + (subItem.Price * subItem.PrescribingNumber)
  6040. }
  6041. }
  6042. if item.Type == 2 { //项目
  6043. for _, subItem := range item.HisPrescriptionProject {
  6044. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6045. total = total + (subItem.Price * cnt)
  6046. }
  6047. }
  6048. }
  6049. for _, item := range prescriptions {
  6050. for _, subItem := range item.HisAdditionalCharge {
  6051. total = total + (subItem.Price * float64(subItem.Count))
  6052. }
  6053. }
  6054. var allTotal string
  6055. if adminUser.CurrentOrgId == 9919 {
  6056. allTotal = fmt.Sprintf("%.4f", total)
  6057. } else {
  6058. allTotal = fmt.Sprintf("%.4f", total)
  6059. }
  6060. if res.Infcode == 0 {
  6061. var rf []*ResultFive
  6062. json.Unmarshal([]byte(his.Iinfo), &rf)
  6063. chrg_bchno := chrg_bchno
  6064. cert_no := his.Certno
  6065. var insutypes []string
  6066. var insutype string
  6067. var is390 int = 0
  6068. var is310 int = 0
  6069. for _, item := range rf {
  6070. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6071. insutypes = append(insutypes, item.Insutype)
  6072. }
  6073. }
  6074. if len(insutypes) == 1 {
  6075. insutype = insutypes[0]
  6076. } else {
  6077. for _, i := range insutypes {
  6078. if i == "390" {
  6079. is390 = 1
  6080. }
  6081. if i == "310" {
  6082. is310 = 1
  6083. }
  6084. }
  6085. }
  6086. if is390 == 1 {
  6087. insutype = "390"
  6088. }
  6089. if is310 == 1 {
  6090. insutype = "310"
  6091. }
  6092. if len(insutypes) == 0 {
  6093. insutype = "310"
  6094. }
  6095. if len(insutypes) == 2 {
  6096. insutype = strconv.FormatInt(his.SocialType, 10)
  6097. }
  6098. insutype = strconv.FormatInt(his.SocialType, 10)
  6099. //insutype = "390"
  6100. if his.IdCardType == 1 {
  6101. // cert_no = his.MedicalInsuranceNumber
  6102. cert_no = his.Certno
  6103. } else {
  6104. cert_no = his.Certno
  6105. }
  6106. var res ResultSeven
  6107. var resSeven10265 ResultSeven10265
  6108. var src_resquest string
  6109. var result2 string
  6110. var acct_used_flag string
  6111. fmt.Println("pay_way")
  6112. fmt.Println(pay_way)
  6113. fmt.Println("pay_way")
  6114. if pay_way == 4 {
  6115. acct_used_flag = "1"
  6116. } else {
  6117. acct_used_flag = "0"
  6118. }
  6119. if miConfig.MdtrtareaAdmvs == "421300" {
  6120. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6121. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6122. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6124. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6125. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6126. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6127. resp, requestErr := http.Get(api)
  6128. if requestErr != nil {
  6129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6130. return
  6131. }
  6132. body, ioErr := ioutil.ReadAll(resp.Body)
  6133. if ioErr != nil {
  6134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6136. return
  6137. }
  6138. var respJSON map[string]interface{}
  6139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6142. return
  6143. }
  6144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6145. result, _ := json.Marshal(respJSON)
  6146. if miConfig.Code == "H15049901371" {
  6147. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6148. utils.ErrorLog("解析失败:%v", err)
  6149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6150. return
  6151. }
  6152. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6153. res.Output = resSeven10265.Output
  6154. res.ErrMsg = resSeven10265.ErrMsg
  6155. res.Cainfo = resSeven10265.Cainfo
  6156. res.WarnMsg = resSeven10265.WarnMsg
  6157. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6158. res.Infcode = infocode
  6159. } else {
  6160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6161. utils.ErrorLog("解析失败:%v", err)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return
  6164. }
  6165. }
  6166. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6167. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  6168. if result3101.Infcode == "0" {
  6169. if len(result3101.Output.Result) > 0 {
  6170. var errMsgs []string
  6171. for _, item := range result3101.Output.Result {
  6172. errMsgs = append(errMsgs, item.VolaCont)
  6173. }
  6174. c.ServeSuccessJSON(map[string]interface{}{
  6175. "failed_code": -10,
  6176. "msg": errMsgs,
  6177. })
  6178. return
  6179. }
  6180. }
  6181. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6182. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6183. bas := strings.Split(psn_info.CardInfo, "|")
  6184. if his.IdCardType == 1 {
  6185. cert_no = bas[2]
  6186. } else if his.IdCardType == 3 {
  6187. cert_no = his.Certno
  6188. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  6189. } else if his.IdCardType == 4 {
  6190. cert_no = his.Certno
  6191. psn_info.VerifyNumber = token
  6192. }
  6193. var api string
  6194. if miConfig.MdtrtareaAdmvs == "320921" {
  6195. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6201. "&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
  6202. } else {
  6203. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6204. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6205. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6206. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6207. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6208. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6209. "&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
  6210. }
  6211. resp, requestErr := http.Get(api)
  6212. if requestErr != nil {
  6213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6214. return
  6215. }
  6216. body, ioErr := ioutil.ReadAll(resp.Body)
  6217. if ioErr != nil {
  6218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6220. return
  6221. }
  6222. var respJSON map[string]interface{}
  6223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6226. return
  6227. }
  6228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6229. result, _ := json.Marshal(respJSON)
  6230. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6231. utils.ErrorLog("解析失败:%v", err)
  6232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6233. return
  6234. }
  6235. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6236. res.Output = resSeven10265.Output
  6237. res.ErrMsg = resSeven10265.ErrMsg
  6238. res.Cainfo = resSeven10265.Cainfo
  6239. res.WarnMsg = resSeven10265.WarnMsg
  6240. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6241. res.Infcode = infocode
  6242. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6243. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6244. var cert_no string
  6245. if his.IdCardType == 1 {
  6246. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6247. }
  6248. fmt.Println(cert_no)
  6249. 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)
  6250. //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)
  6251. var dat map[string]interface{}
  6252. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6253. fmt.Println(dat)
  6254. } else {
  6255. fmt.Println(err)
  6256. }
  6257. saveLog(result2, src_resquest, "2207", "结算")
  6258. userJSONBytes, _ := json.Marshal(dat)
  6259. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6260. utils.ErrorLog("解析失败:%v", err)
  6261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. return
  6263. }
  6264. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6265. res.Output = resSeven10265.Output
  6266. res.ErrMsg = resSeven10265.ErrMsg
  6267. res.Cainfo = resSeven10265.Cainfo
  6268. res.WarnMsg = resSeven10265.WarnMsg
  6269. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6270. res.Infcode = infocode
  6271. } else {
  6272. if miConfig.Code == "H15049901371" {
  6273. //赤峰地区国家医保医疗类别
  6274. //职工透析:医疗类别选特殊情况门诊990502
  6275. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6276. var med_type string
  6277. if his.Insutype == "390" {
  6278. if reg_type == 14 {
  6279. med_type = "9933"
  6280. } else if reg_type == 11 {
  6281. med_type = "11"
  6282. }
  6283. } else if his.Insutype == "310" {
  6284. if reg_type == 14 {
  6285. med_type = "990502"
  6286. } else if reg_type == 11 {
  6287. med_type = "11"
  6288. }
  6289. }
  6290. 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)
  6291. } else {
  6292. 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)
  6293. }
  6294. //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)
  6295. var dat map[string]interface{}
  6296. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6297. fmt.Println(dat)
  6298. } else {
  6299. fmt.Println(err)
  6300. }
  6301. saveLog(result2, src_resquest, "2207", "结算")
  6302. userJSONBytes, _ := json.Marshal(dat)
  6303. if miConfig.Code == "H15049901371" {
  6304. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6305. utils.ErrorLog("解析失败:%v", err)
  6306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6307. return
  6308. }
  6309. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6310. res.Output = resSeven10265.Output
  6311. res.ErrMsg = resSeven10265.ErrMsg
  6312. res.Cainfo = resSeven10265.Cainfo
  6313. res.WarnMsg = resSeven10265.WarnMsg
  6314. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6315. res.Infcode = infocode
  6316. } else {
  6317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6318. utils.ErrorLog("解析失败:%v", err)
  6319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6320. return
  6321. }
  6322. }
  6323. }
  6324. if res.Infcode != 0 {
  6325. errlog := &models.HisOrderError{
  6326. UserOrgId: adminUser.CurrentOrgId,
  6327. Ctime: time.Now().Unix(),
  6328. Mtime: time.Now().Unix(),
  6329. Number: chrg_bchno,
  6330. ErrMsg: res.ErrMsg,
  6331. Status: 1,
  6332. PatientId: id,
  6333. RecordTime: recordDateTime,
  6334. Stage: 6,
  6335. }
  6336. service.CreateErrMsgLog(errlog)
  6337. c.ServeSuccessJSON(map[string]interface{}{
  6338. "failed_code": -10,
  6339. "msg": res.ErrMsg,
  6340. })
  6341. return
  6342. } else {
  6343. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6344. order.OrderStatus = 2
  6345. order.Status = 1
  6346. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6347. order.SetlId = res.Output.Setlinfo.SetlID
  6348. order.PsnNo = res.Output.Setlinfo.PsnNo
  6349. order.PsnName = res.Output.Setlinfo.PsnName
  6350. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6351. order.Certno = res.Output.Setlinfo.Certno
  6352. order.Gend = res.Output.Setlinfo.Gend
  6353. order.Naty = res.Output.Setlinfo.Naty
  6354. order.Age = res.Output.Setlinfo.Age
  6355. order.Insutype = res.Output.Setlinfo.Insutype
  6356. order.PsnType = res.Output.Setlinfo.PsnType
  6357. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6358. order.SetlTime = res.Output.Setlinfo.SetlTime
  6359. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6360. if res.Output.Setlinfo.MedType == "140101" {
  6361. order.MedType = "14"
  6362. } else {
  6363. order.MedType = res.Output.Setlinfo.MedType
  6364. }
  6365. if reg_type == 1112 {
  6366. order.MedType = "1112"
  6367. }
  6368. if reg_type == 1111 {
  6369. order.MedType = "1111"
  6370. }
  6371. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6372. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6373. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6374. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6375. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6376. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6377. order.HifpPay = res.Output.Setlinfo.HifpPay
  6378. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6379. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6380. order.HifesPay = res.Output.Setlinfo.HifesPay
  6381. order.HifobPay = res.Output.Setlinfo.HifobPay
  6382. order.MafPay = res.Output.Setlinfo.MafPay
  6383. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6384. order.OthPay = res.Output.Setlinfo.OthPay
  6385. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6386. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6387. order.AcctPay = res.Output.Setlinfo.AcctPay
  6388. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6389. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6390. order.Balc = res.Output.Setlinfo.Balc
  6391. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6392. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6393. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6394. order.ClrType = res.Output.Setlinfo.ClrType
  6395. order.ClrWay = res.Output.Setlinfo.ClrWay
  6396. order.Creator = order.Creator
  6397. order.Modify = roles.AdminUserId
  6398. order.RequestLog = src_resquest
  6399. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6400. detailStr := string(setlDetail)
  6401. order.SetlDetail = detailStr
  6402. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6403. err = service.UpDateOrder(order)
  6404. if err == nil {
  6405. //判断是否使用了押金
  6406. if dec_way == "true" {
  6407. tmpstring := strconv.FormatInt(order.ID, 10)
  6408. order.Decimal = decimal
  6409. service.UpDateOrder(order)
  6410. //扣押金
  6411. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6412. if errmsg != nil {
  6413. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6414. return
  6415. }
  6416. }
  6417. c.ServeSuccessJSON(map[string]interface{}{
  6418. "msg": "结算成功",
  6419. })
  6420. } else {
  6421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6422. return
  6423. }
  6424. }
  6425. } else {
  6426. adminUser := c.GetAdminUserInfo()
  6427. errlog := &models.HisOrderError{
  6428. UserOrgId: adminUser.CurrentOrgId,
  6429. Ctime: time.Now().Unix(),
  6430. Mtime: time.Now().Unix(),
  6431. ErrMsg: res.ErrMsg,
  6432. Status: 1,
  6433. PatientId: id,
  6434. RecordTime: recordDateTime,
  6435. Stage: 4,
  6436. }
  6437. service.CreateErrMsgLog(errlog)
  6438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6439. return
  6440. }
  6441. } else {
  6442. adminUser := c.GetAdminUserInfo()
  6443. errlog := &models.HisOrderError{
  6444. UserOrgId: adminUser.CurrentOrgId,
  6445. Ctime: time.Now().Unix(),
  6446. Mtime: time.Now().Unix(),
  6447. ErrMsg: res.ErrMsg,
  6448. Status: 1,
  6449. PatientId: id,
  6450. RecordTime: recordDateTime,
  6451. Stage: 4,
  6452. }
  6453. service.CreateErrMsgLog(errlog)
  6454. c.ServeSuccessJSON(map[string]interface{}{
  6455. "failed_code": -10,
  6456. "msg": res.ErrMsg,
  6457. })
  6458. return
  6459. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6460. //return
  6461. }
  6462. }
  6463. }
  6464. } else if tempOrder.ID > 0 {
  6465. if tempOrder.IsPre == 1 {
  6466. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6467. var rf []*ResultFive
  6468. json.Unmarshal([]byte(his.Iinfo), &rf)
  6469. chrg_bchno := tempOrder.Number
  6470. cert_no := his.Certno
  6471. var insutypes []string
  6472. var insutype string
  6473. var is390 int = 0
  6474. var is310 int = 0
  6475. for _, item := range rf {
  6476. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6477. insutypes = append(insutypes, item.Insutype)
  6478. }
  6479. }
  6480. if len(insutypes) == 1 {
  6481. insutype = insutypes[0]
  6482. } else {
  6483. for _, i := range insutypes {
  6484. if i == "390" {
  6485. is390 = 1
  6486. }
  6487. if i == "310" {
  6488. is310 = 1
  6489. }
  6490. }
  6491. }
  6492. if is390 == 1 {
  6493. insutype = "390"
  6494. }
  6495. if is310 == 1 {
  6496. insutype = "310"
  6497. }
  6498. if len(insutypes) == 0 {
  6499. insutype = "310"
  6500. }
  6501. if len(insutypes) == 2 {
  6502. insutype = strconv.FormatInt(his.SocialType, 64)
  6503. }
  6504. //insutype = "390"
  6505. if his.IdCardType == 1 {
  6506. // cert_no = his.MedicalInsuranceNumber
  6507. cert_no = his.Certno
  6508. } else {
  6509. cert_no = his.Certno
  6510. }
  6511. var res ResultSeven
  6512. var resSeven10265 ResultSeven10265
  6513. var src_resquest string
  6514. var result2 string
  6515. var acct_used_flag string
  6516. fmt.Println("pay_way")
  6517. fmt.Println(pay_way)
  6518. fmt.Println("pay_way")
  6519. if pay_way == 4 {
  6520. acct_used_flag = "1"
  6521. } else {
  6522. acct_used_flag = "0"
  6523. }
  6524. if miConfig.MdtrtareaAdmvs == "421300" {
  6525. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6526. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6527. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6528. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6529. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6530. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6531. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6532. resp, requestErr := http.Get(api)
  6533. if requestErr != nil {
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. return
  6536. }
  6537. body, ioErr := ioutil.ReadAll(resp.Body)
  6538. if ioErr != nil {
  6539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6541. return
  6542. }
  6543. var respJSON map[string]interface{}
  6544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6547. return
  6548. }
  6549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6550. result, _ := json.Marshal(respJSON)
  6551. fmt.Println("log")
  6552. fmt.Println(string(result))
  6553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6554. utils.ErrorLog("解析失败:%v", err)
  6555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. return
  6557. }
  6558. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6559. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  6560. if result3101.Infcode == "0" {
  6561. if len(result3101.Output.Result) > 0 {
  6562. var errMsgs []string
  6563. for _, item := range result3101.Output.Result {
  6564. errMsgs = append(errMsgs, item.VolaCont)
  6565. }
  6566. c.ServeSuccessJSON(map[string]interface{}{
  6567. "failed_code": -10,
  6568. "msg": errMsgs,
  6569. })
  6570. return
  6571. }
  6572. }
  6573. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6574. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6575. //psn_info, _ := service.GetPsnByPatientId(id)
  6576. bas := strings.Split(psn_info.CardInfo, "|")
  6577. if his.IdCardType == 1 {
  6578. cert_no = bas[2]
  6579. } else {
  6580. cert_no = bas[1]
  6581. }
  6582. //江苏地区国家医保医疗类别
  6583. //职工透析:医疗类别选特殊情况门诊9933
  6584. //居民血透门慢: 医疗类别选门诊慢病1402
  6585. //var med_type string
  6586. //if his.Insutype == "310" {
  6587. // if reg_type == 14 {
  6588. // med_type = "9933"
  6589. // } else if reg_type == 11 {
  6590. // med_type = "11"
  6591. //
  6592. // }
  6593. //} else if his.Insutype == "390" {
  6594. // if reg_type == 14 {
  6595. // med_type = "1402"
  6596. // } else if reg_type == 11 {
  6597. // med_type = "11"
  6598. // }
  6599. //}
  6600. var api string
  6601. if miConfig.MdtrtareaAdmvs == "320921" {
  6602. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6603. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6604. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6605. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6606. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6607. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6608. "&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
  6609. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6610. } else {
  6611. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6612. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6613. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6614. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6615. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6616. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6617. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6618. "&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
  6619. }
  6620. resp, requestErr := http.Get(api)
  6621. if requestErr != nil {
  6622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6623. return
  6624. }
  6625. body, ioErr := ioutil.ReadAll(resp.Body)
  6626. if ioErr != nil {
  6627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6629. return
  6630. }
  6631. var respJSON map[string]interface{}
  6632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6635. return
  6636. }
  6637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6638. result, _ := json.Marshal(respJSON)
  6639. fmt.Println("log")
  6640. fmt.Println(string(result))
  6641. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6642. utils.ErrorLog("解析失败:%v", err)
  6643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. return
  6645. }
  6646. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6647. res.Output = resSeven10265.Output
  6648. res.ErrMsg = resSeven10265.ErrMsg
  6649. res.Cainfo = resSeven10265.Cainfo
  6650. res.WarnMsg = resSeven10265.WarnMsg
  6651. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6652. res.Infcode = infocode
  6653. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6654. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6655. var cert_no string
  6656. if his.IdCardType == 1 {
  6657. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6658. }
  6659. fmt.Println(cert_no)
  6660. 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)
  6661. var dat map[string]interface{}
  6662. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6663. fmt.Println(dat)
  6664. } else {
  6665. fmt.Println(err)
  6666. }
  6667. saveLog(result2, src_resquest, "2207", "结算")
  6668. userJSONBytes, _ := json.Marshal(dat)
  6669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6670. utils.ErrorLog("解析失败:%v", err)
  6671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6672. return
  6673. }
  6674. } else {
  6675. var src_resquest string
  6676. if miConfig.Code == "H15049901371" {
  6677. //赤峰地区国家医保医疗类别
  6678. //职工透析:医疗类别选特殊情况门诊990502
  6679. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6680. var med_type string
  6681. if his.Insutype == "390" {
  6682. if reg_type == 14 {
  6683. med_type = "9933"
  6684. } else if reg_type == 11 {
  6685. med_type = "11"
  6686. }
  6687. } else if his.Insutype == "310" {
  6688. if reg_type == 14 {
  6689. med_type = "990502"
  6690. } else if reg_type == 11 {
  6691. med_type = "11"
  6692. }
  6693. }
  6694. 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)
  6695. } else {
  6696. 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)
  6697. }
  6698. var dat map[string]interface{}
  6699. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6700. fmt.Println(dat)
  6701. } else {
  6702. fmt.Println(err)
  6703. }
  6704. saveLog(result2, src_resquest, "2207", "结算")
  6705. userJSONBytes, _ := json.Marshal(dat)
  6706. if miConfig.Code == "H15049901371" {
  6707. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6708. utils.ErrorLog("解析失败:%v", err)
  6709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6710. return
  6711. }
  6712. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6713. res.Output = resSeven10265.Output
  6714. res.ErrMsg = resSeven10265.ErrMsg
  6715. res.Cainfo = resSeven10265.Cainfo
  6716. res.WarnMsg = resSeven10265.WarnMsg
  6717. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6718. res.Infcode = infocode
  6719. } else {
  6720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6721. utils.ErrorLog("解析失败:%v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. return
  6724. }
  6725. }
  6726. }
  6727. if res.Infcode != 0 {
  6728. errlog := &models.HisOrderError{
  6729. UserOrgId: adminUser.CurrentOrgId,
  6730. Ctime: time.Now().Unix(),
  6731. Mtime: time.Now().Unix(),
  6732. Number: chrg_bchno,
  6733. ErrMsg: res.ErrMsg,
  6734. Status: 1,
  6735. PatientId: id,
  6736. RecordTime: recordDateTime,
  6737. Stage: 6,
  6738. }
  6739. service.CreateErrMsgLog(errlog)
  6740. c.ServeSuccessJSON(map[string]interface{}{
  6741. "failed_code": -10,
  6742. "msg": res.ErrMsg,
  6743. })
  6744. return
  6745. } else {
  6746. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6747. order.OrderStatus = 2
  6748. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6749. order.SetlId = res.Output.Setlinfo.SetlID
  6750. order.PsnNo = res.Output.Setlinfo.PsnNo
  6751. order.PsnName = res.Output.Setlinfo.PsnName
  6752. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6753. order.Certno = res.Output.Setlinfo.Certno
  6754. order.Gend = res.Output.Setlinfo.Gend
  6755. order.Naty = res.Output.Setlinfo.Naty
  6756. order.Age = res.Output.Setlinfo.Age
  6757. order.Insutype = res.Output.Setlinfo.Insutype
  6758. order.PsnType = res.Output.Setlinfo.PsnType
  6759. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6760. order.SetlTime = res.Output.Setlinfo.SetlTime
  6761. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6762. //order.MedType = res.Output.Setlinfo.MedType
  6763. if reg_type == 1112 {
  6764. order.MedType = "1112"
  6765. }
  6766. if reg_type == 1111 {
  6767. order.MedType = "1111"
  6768. }
  6769. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6770. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6771. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6772. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6773. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6774. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6775. order.HifpPay = res.Output.Setlinfo.HifpPay
  6776. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6777. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6778. order.HifesPay = res.Output.Setlinfo.HifesPay
  6779. order.HifobPay = res.Output.Setlinfo.HifobPay
  6780. order.MafPay = res.Output.Setlinfo.MafPay
  6781. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6782. order.OthPay = res.Output.Setlinfo.OthPay
  6783. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6784. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6785. order.AcctPay = res.Output.Setlinfo.AcctPay
  6786. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6787. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6788. order.Balc = res.Output.Setlinfo.Balc
  6789. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6790. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6791. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6792. order.ClrWay = res.Output.Setlinfo.ClrWay
  6793. order.Creator = order.Creator
  6794. order.Modify = roles.AdminUserId
  6795. order.RequestLog = src_resquest
  6796. order.Diagnosis = diagnosis_id
  6797. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6798. detailStr := string(setlDetail)
  6799. order.SetlDetail = detailStr
  6800. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6801. err = service.UpDateOrder(order)
  6802. if err == nil {
  6803. //判断是否使用了押金
  6804. if dec_way == "true" {
  6805. tmpstring := strconv.FormatInt(order.ID, 10)
  6806. //扣押金
  6807. order.Decimal = decimal
  6808. service.UpDateOrder(order)
  6809. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6810. if errmsg != nil {
  6811. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6812. return
  6813. }
  6814. }
  6815. c.ServeSuccessJSON(map[string]interface{}{
  6816. "msg": "结算成功",
  6817. })
  6818. } else {
  6819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6820. return
  6821. }
  6822. }
  6823. }
  6824. }
  6825. }
  6826. //func (c *HisApiController) GetPreUploadInfo() {
  6827. // id, _ := c.GetInt64("id")
  6828. // record_time := c.GetString("record_time")
  6829. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6830. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6831. //
  6832. // timeLayout := "2006-01-02"
  6833. // loc, _ := time.LoadLocation("Local")
  6834. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6835. // if err != nil {
  6836. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6837. // return
  6838. // }
  6839. // recordDateTime := theTime.Unix()
  6840. // adminUser := c.GetAdminUserInfo()
  6841. //
  6842. // var prescriptions []*models.HisPrescription
  6843. //
  6844. // var start_time int64
  6845. // var end_time int64
  6846. //
  6847. // data := make(map[string]interface{})
  6848. // if settle_accounts_type == 1 { //日结
  6849. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6850. // data["pre"] = prescriptions
  6851. //
  6852. // } else { //月结
  6853. // start_time_str := c.GetString("start_time")
  6854. // end_time_str := c.GetString("end_time")
  6855. // timeLayout := "2006-01-02"
  6856. // loc, _ := time.LoadLocation("Local")
  6857. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6858. // if err != nil {
  6859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6860. // return
  6861. // }
  6862. // recordStartTime := theStartTime.Unix()
  6863. // start_time = recordStartTime
  6864. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6865. // if err != nil {
  6866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6867. // return
  6868. // }
  6869. // recordEndTime := theEndTime.Unix()
  6870. // end_time = recordEndTime
  6871. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6872. // data["pre"] = prescriptions
  6873. //
  6874. // }
  6875. //
  6876. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6877. //
  6878. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6879. // timestamp := time.Now().Unix()
  6880. // tempTime := time.Unix(timestamp, 0)
  6881. // timeFormat := tempTime.Format("20060102150405")
  6882. // chrgBchno := rand.Intn(100000) + 10000
  6883. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6884. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6885. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6886. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6887. // strconv.FormatInt(his.PatientId, 10)
  6888. // client := &http.Client{}
  6889. // data["psn_no"] = his.PsnNo
  6890. // data["mdtrt_id"] = his.Number
  6891. // data["chrg_bchno"] = chrg_bchno
  6892. // data["org_name"] = miConfig.OrgName
  6893. // data["doctor"] = roles.UserName
  6894. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6895. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6896. // data["fixmedins_code"] = miConfig.Code
  6897. // data["dept_code"] = department.Number
  6898. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6899. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6900. // data["secret_key"] = miConfig.SecretKey
  6901. // var ids []int64
  6902. //
  6903. // for _, item := range prescriptions {
  6904. // ids = append(ids, item.ID)
  6905. // }
  6906. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6907. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6908. // bytesData, _ := json.Marshal(data)
  6909. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6910. // resp, _ := client.Do(req)
  6911. // defer resp.Body.Close()
  6912. // body, ioErr := ioutil.ReadAll(resp.Body)
  6913. // if ioErr != nil {
  6914. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. // return
  6917. // }
  6918. // var respJSON map[string]interface{}
  6919. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6920. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. // return
  6923. // }
  6924. //
  6925. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6926. // userJSONBytes, _ := json.Marshal(respJSON)
  6927. // var res ResultFour
  6928. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6929. // utils.ErrorLog("解析失败:%v", err)
  6930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. // return
  6932. // }
  6933. //
  6934. // if res.Infcode == 0 {
  6935. // order := &models.HisOrder{
  6936. // UserOrgId: adminUser.CurrentOrgId,
  6937. // HisPatientId: his.ID,
  6938. // PatientId: his.PatientId,
  6939. // SettleAccountsDate: recordDateTime,
  6940. // Ctime: time.Now().Unix(),
  6941. // Mtime: time.Now().Unix(),
  6942. // Status: 1,
  6943. // Number: chrg_bchno,
  6944. // Infcode: res.Infcode,
  6945. // WarnMsg: res.WarnMsg,
  6946. // Cainfo: res.Cainfo,
  6947. // ErrMsg: res.ErrMsg,
  6948. // RespondTime: res.RefmsgTime,
  6949. // InfRefmsgid: res.InfRefmsgid,
  6950. // OrderStatus: 1,
  6951. // IsMedicineInsurance: 1,
  6952. // SettleType: settle_accounts_type,
  6953. // SettleStartTime: start_time,
  6954. // SettleEndTime: end_time,
  6955. // Creator: roles.ID,
  6956. // Modify: roles.ID,
  6957. // PType: 2,
  6958. // }
  6959. // err = service.CreateOrder(order)
  6960. // if err != nil {
  6961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6962. // return
  6963. // }
  6964. //
  6965. // for _, item := range res.Output.Result {
  6966. // temp := strings.Split(item.FeedetlSn, "-")
  6967. // var advice_id int64 = 0
  6968. // var project_id int64 = 0
  6969. // var types int64 = 0
  6970. //
  6971. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6972. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6973. //
  6974. // if temp[1] == "1" {
  6975. // advice_id = id
  6976. // project_id = 0
  6977. // } else if temp[1] == "2" {
  6978. // advice_id = 0
  6979. // project_id = id
  6980. // }
  6981. //
  6982. // info := &models.HisOrderInfo{
  6983. // OrderNumber: order.Number,
  6984. // FeedetlSn: item.FeedetlSn,
  6985. // UploadDate: time.Now().Unix(),
  6986. // AdviceId: advice_id,
  6987. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6988. // Cnt: item.Cnt,
  6989. // Pric: float64(item.Pric),
  6990. // PatientId: his.PatientId,
  6991. // PricUplmtAmt: item.PricUplmtAmt,
  6992. // SelfpayProp: item.SelfpayProp,
  6993. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6994. // OverlmtAmt: item.OverlmtAmt,
  6995. // PreselfpayAmt: item.PreselfpayAmt,
  6996. // BasMednFlag: item.BasMednFlag,
  6997. // MedChrgitmType: item.MedChrgitmType,
  6998. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6999. // Status: 1,
  7000. // Memo: item.Memo,
  7001. // Mtime: time.Now().Unix(),
  7002. // InscpScpAmt: item.InscpScpAmt,
  7003. // DrtReimFlag: item.DrtReimFlag,
  7004. // Ctime: time.Now().Unix(),
  7005. // ListSpItemFlag: item.ListSpItemFlag,
  7006. // ChldMedcFlag: item.ChldMedcFlag,
  7007. // LmtUsedFlag: item.LmtUsedFlag,
  7008. // ChrgitmLv: item.ChrgitmLv,
  7009. // UserOrgId: adminUser.CurrentOrgId,
  7010. // HisPatientId: his.ID,
  7011. // OrderId: order.ID,
  7012. // ProjectId: project_id,
  7013. // Type: types,
  7014. // }
  7015. // service.CreateOrderInfo(info)
  7016. //
  7017. // }
  7018. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7019. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  7020. //
  7021. // var total float64
  7022. // for _, item := range prescriptions {
  7023. // if item.Type == 1 { //药品
  7024. // for _, subItem := range item.HisDoctorAdviceInfo {
  7025. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7026. // }
  7027. // }
  7028. // if item.Type == 2 { //项目
  7029. // for _, subItem := range item.HisPrescriptionProject {
  7030. // total = total + (subItem.Price * float64(subItem.Count))
  7031. // }
  7032. // }
  7033. // }
  7034. //
  7035. // for _, item := range prescriptions {
  7036. // for _, subItem := range item.HisAdditionalCharge {
  7037. // total = total + (subItem.Price * float64(subItem.Count))
  7038. // }
  7039. // }
  7040. //
  7041. // allTotal := fmt.Sprintf("%.2f", total)
  7042. // if res.Infcode == 0 {
  7043. // var rf []*ResultFive
  7044. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7045. // psn_no := his.PsnNo
  7046. // mdtrt_id := his.Number
  7047. // chrg_bchno := chrg_bchno
  7048. // cert_no := his.Certno
  7049. // insutype := rf[0].Insutype
  7050. //
  7051. // if his.IdCardType == 1 {
  7052. // cert_no = his.MedicalInsuranceNumber
  7053. //
  7054. // } else {
  7055. //
  7056. // cert_no = his.Certno
  7057. //
  7058. // }
  7059. //
  7060. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  7061. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  7062. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  7063. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  7064. // resp, requestErr := http.Get(api)
  7065. // if requestErr != nil {
  7066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. // return
  7068. // }
  7069. // defer resp.Body.Close()
  7070. // body, ioErr := ioutil.ReadAll(resp.Body)
  7071. // if ioErr != nil {
  7072. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7074. // return
  7075. // }
  7076. // var respJSON map[string]interface{}
  7077. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7078. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. // return
  7081. // }
  7082. // fmt.Println(respJSON)
  7083. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. // userJSONBytes, _ := json.Marshal(respJSON)
  7085. // var res ResultSeven
  7086. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7087. // utils.ErrorLog("解析失败:%v", err)
  7088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7089. // return
  7090. // }
  7091. // if res.Infcode != 0 {
  7092. // errlog := &models.HisOrderError{
  7093. // UserOrgId: adminUser.CurrentOrgId,
  7094. // Ctime: time.Now().Unix(),
  7095. // Mtime: time.Now().Unix(),
  7096. // Number: chrg_bchno,
  7097. // ErrMsg: res.ErrMsg,
  7098. // Status: 1,
  7099. // PatientId: id,
  7100. // RecordTime: recordDateTime,
  7101. // Stage: 7,
  7102. // }
  7103. // service.CreateErrMsgLog(errlog)
  7104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7105. // return
  7106. // } else {
  7107. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7108. // order.OrderStatus = 1
  7109. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7110. // order.SetlId = res.Output.Setlinfo.SetlID
  7111. // order.PsnNo = res.Output.Setlinfo.PsnNo
  7112. // order.PsnName = res.Output.Setlinfo.PsnName
  7113. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7114. // order.Certno = res.Output.Setlinfo.Certno
  7115. // order.Gend = res.Output.Setlinfo.Gend
  7116. // order.Naty = res.Output.Setlinfo.Naty
  7117. // order.Age = res.Output.Setlinfo.Age
  7118. // order.Insutype = res.Output.Setlinfo.Insutype
  7119. // order.PsnType = res.Output.Setlinfo.PsnType
  7120. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7121. // order.SetlTime = res.Output.Setlinfo.SetlTime
  7122. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7123. // order.MedType = res.Output.Setlinfo.MedType
  7124. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7125. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7126. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7127. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7128. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7129. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7130. // order.HifpPay = res.Output.Setlinfo.HifpPay
  7131. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7132. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7133. // order.HifesPay = res.Output.Setlinfo.HifesPay
  7134. // order.HifobPay = res.Output.Setlinfo.HifobPay
  7135. // order.MafPay = res.Output.Setlinfo.MafPay
  7136. // order.OthPay = res.Output.Setlinfo.OthPay
  7137. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7138. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7139. // order.AcctPay = res.Output.Setlinfo.AcctPay
  7140. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7141. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7142. // order.Balc = res.Output.Setlinfo.Balc
  7143. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7144. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7145. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7146. // order.ClrWay = res.Output.Setlinfo.ClrWay
  7147. // order.Creator = order.Creator
  7148. // order.Modify = roles.ID
  7149. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7150. // detailStr := string(setlDetail)
  7151. // order.SetlDetail = detailStr
  7152. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7153. // err = service.UpDateOrder(order)
  7154. // if err == nil {
  7155. // c.ServeSuccessJSON(map[string]interface{}{
  7156. // "msg": "预结算成功",
  7157. // })
  7158. // } else {
  7159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7160. // return
  7161. // }
  7162. // }
  7163. // } else {
  7164. // adminUser := c.GetAdminUserInfo()
  7165. // errlog := &models.HisOrderError{
  7166. // UserOrgId: adminUser.CurrentOrgId,
  7167. // Ctime: time.Now().Unix(),
  7168. // Mtime: time.Now().Unix(),
  7169. // ErrMsg: res.ErrMsg,
  7170. // Status: 1,
  7171. // PatientId: id,
  7172. // RecordTime: recordDateTime,
  7173. // Stage: 4,
  7174. // }
  7175. // service.CreateErrMsgLog(errlog)
  7176. //
  7177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7178. // return
  7179. // }
  7180. // } else {
  7181. // adminUser := c.GetAdminUserInfo()
  7182. // errlog := &models.HisOrderError{
  7183. // UserOrgId: adminUser.CurrentOrgId,
  7184. // Ctime: time.Now().Unix(),
  7185. // Mtime: time.Now().Unix(),
  7186. // ErrMsg: res.ErrMsg,
  7187. // Status: 1,
  7188. // PatientId: id,
  7189. // RecordTime: recordDateTime,
  7190. // Stage: 4,
  7191. // }
  7192. // service.CreateErrMsgLog(errlog)
  7193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  7194. // return
  7195. // }
  7196. //
  7197. // } else {
  7198. // var total float64
  7199. // for _, item := range prescriptions {
  7200. // if item.Type == 1 { //药品
  7201. // for _, subItem := range item.HisDoctorAdviceInfo {
  7202. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7203. // }
  7204. // }
  7205. // if item.Type == 2 { //项目
  7206. // for _, subItem := range item.HisPrescriptionProject {
  7207. // total = total + (subItem.Price * float64(subItem.Count))
  7208. // }
  7209. // }
  7210. //
  7211. // for _, subItem := range item.HisAdditionalCharge {
  7212. // total = total + (subItem.Price * float64(subItem.Count))
  7213. // }
  7214. // }
  7215. //
  7216. // allTotal := fmt.Sprintf("%.2f", total)
  7217. // totals, _ := strconv.ParseFloat(allTotal, 64)
  7218. // order := &models.HisOrder{
  7219. // UserOrgId: adminUser.CurrentOrgId,
  7220. // HisPatientId: his.ID,
  7221. // PatientId: id,
  7222. // SettleAccountsDate: recordDateTime,
  7223. // Ctime: time.Now().Unix(),
  7224. // Mtime: time.Now().Unix(),
  7225. // Status: 1,
  7226. // OrderStatus: 2,
  7227. // Number: chrg_bchno,
  7228. // MedfeeSumamt: totals,
  7229. // }
  7230. // err = service.CreateOrder(order)
  7231. // if err != nil {
  7232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7233. // return
  7234. // }
  7235. //
  7236. // var customs []*Custom
  7237. // for _, item := range prescriptions {
  7238. //
  7239. // if item.Type == 1 { //药品
  7240. // for _, subItem := range item.HisDoctorAdviceInfo {
  7241. // cus := &Custom{
  7242. // AdviceId: subItem.ID,
  7243. // ProjectId: 0,
  7244. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7245. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7246. // FeedetlSn: subItem.FeedetlSn,
  7247. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7248. // MedListCodg: subItem.MedListCodg,
  7249. // Type: 1,
  7250. // }
  7251. // customs = append(customs, cus)
  7252. // }
  7253. // }
  7254. //
  7255. // if item.Type == 2 { //项目
  7256. // for _, subItem := range item.HisPrescriptionProject {
  7257. //
  7258. // cus := &Custom{
  7259. // AdviceId: 0,
  7260. // ProjectId: subItem.ID,
  7261. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7262. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7263. // FeedetlSn: subItem.FeedetlSn,
  7264. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7265. // MedListCodg: subItem.MedListCodg,
  7266. // Type: 2,
  7267. // }
  7268. //
  7269. // customs = append(customs, cus)
  7270. // }
  7271. // }
  7272. //
  7273. // for _, item := range item.HisAdditionalCharge {
  7274. // cus := &Custom{
  7275. // ItemId: item.ID,
  7276. // AdviceId: 0,
  7277. // ProjectId: 0,
  7278. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7279. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7280. // FeedetlSn: item.FeedetlSn,
  7281. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7282. // MedListCodg: item.XtHisAddtionConfig.Code,
  7283. // Type: 3,
  7284. // }
  7285. //
  7286. // customs = append(customs, cus)
  7287. // }
  7288. //
  7289. // }
  7290. //
  7291. // for _, item := range customs {
  7292. // var advice_id int64 = 0
  7293. // var project_id int64 = 0
  7294. // var item_id int64 = 0
  7295. //
  7296. // var types int64 = 0
  7297. //
  7298. // if item.Type == 1 {
  7299. // advice_id = item.AdviceId
  7300. // project_id = 0
  7301. // item_id = 0
  7302. // } else if item.Type == 2 {
  7303. // advice_id = 0
  7304. // item_id = 0
  7305. //
  7306. // project_id = item.ProjectId
  7307. // } else if item.Type == 3 {
  7308. // advice_id = 0
  7309. // item_id = item.ItemId
  7310. // project_id = 0
  7311. // }
  7312. //
  7313. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7314. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7315. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7316. //
  7317. // info := &models.HisOrderInfo{
  7318. // OrderNumber: order.Number,
  7319. // UploadDate: time.Now().Unix(),
  7320. // AdviceId: advice_id,
  7321. // DetItemFeeSumamt: detItemFeeSumamt,
  7322. // Cnt: cut,
  7323. // Pric: pric,
  7324. // PatientId: id,
  7325. // Status: 1,
  7326. // Mtime: time.Now().Unix(),
  7327. // Ctime: time.Now().Unix(),
  7328. // UserOrgId: adminUser.CurrentOrgId,
  7329. // HisPatientId: his.ID,
  7330. // OrderId: order.ID,
  7331. // ProjectId: project_id,
  7332. // Type: types,
  7333. // ItemId: item_id,
  7334. // }
  7335. // service.CreateOrderInfo(info)
  7336. // }
  7337. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7338. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7339. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7340. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7341. // if err == nil {
  7342. // c.ServeSuccessJSON(map[string]interface{}{
  7343. // "msg": "结算成功",
  7344. // })
  7345. // } else {
  7346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7347. // return
  7348. // }
  7349. // }
  7350. //}
  7351. //上传明细-预结算-
  7352. func (c *HisApiController) GetPreUploadInfo() {
  7353. id, _ := c.GetInt64("id")
  7354. record_time := c.GetString("record_time")
  7355. his_patient_id, _ := c.GetInt64("his_patient_id")
  7356. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7357. admin_user_id, _ := c.GetInt64("admin_user_id")
  7358. diagnosis_id := c.GetString("diagnosis")
  7359. sick_type, _ := c.GetInt64("sick_type")
  7360. reg_type, _ := c.GetInt64("p_type")
  7361. begin_time := c.GetString("begin_time")
  7362. id_str := c.GetString("ids")
  7363. ids_arr := strings.Split(id_str, ",")
  7364. timeLayout := "2006-01-02"
  7365. loc, _ := time.LoadLocation("Local")
  7366. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7367. if err != nil {
  7368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7369. return
  7370. }
  7371. recordDateTime := theTime.Unix()
  7372. adminUser := c.GetAdminUserInfo()
  7373. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7374. var config []*models.HisXtDiagnoseConfig
  7375. for _, item := range diagnosis_ids {
  7376. id, _ := strconv.ParseInt(item, 10, 64)
  7377. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7378. config = append(config, &diagnosisConfig)
  7379. }
  7380. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7381. sickConfig, _ := service.FindSickById(sick_type)
  7382. var prescriptions []*models.HisPrescription
  7383. var start_time int64
  7384. var end_time int64
  7385. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7386. fmt.Println(his_patient_id)
  7387. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7388. timestamp := time.Now().Unix()
  7389. tempTime := time.Unix(timestamp, 0)
  7390. timeFormat := tempTime.Format("20060102150405")
  7391. chrgBchno := rand.Intn(100000) + 10000
  7392. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7394. var patientPrescription models.HisPrescriptionInfo
  7395. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7396. if patientPrescription.ID == 0 {
  7397. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7398. }
  7399. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7400. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7401. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7402. strconv.FormatInt(his.PatientId, 10)
  7403. var res2 ResultSix
  7404. var resSix10265 ResultSix10265
  7405. var time_stamp string
  7406. if miConfig.MdtrtareaAdmvs == "421300" {
  7407. data := make(map[string]interface{})
  7408. client := &http.Client{}
  7409. data["psn_no"] = his.PsnNo
  7410. data["mdtrt_id"] = his.Number
  7411. data["department"] = department.Name
  7412. data["org_name"] = miConfig.OrgName
  7413. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7414. data["doctor_id"] = doctor_info.DoctorNumber
  7415. data["doctor_name"] = roles.UserName
  7416. data["fixmedins_code"] = miConfig.Code
  7417. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7418. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7419. data["secret_key"] = miConfig.SecretKey
  7420. data["sick_code"] = sickConfig.CountryCode
  7421. data["sick_name"] = sickConfig.ClassName
  7422. data["begin_time"] = begin_time
  7423. data["dept"] = strconv.FormatInt(department.ID, 10)
  7424. data["config"] = config
  7425. data["opter"] = roles.UserName
  7426. fmt.Println(data)
  7427. bytesData, _ := json.Marshal(data)
  7428. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7429. resp, _ := client.Do(req)
  7430. defer resp.Body.Close()
  7431. body, ioErr := ioutil.ReadAll(resp.Body)
  7432. if ioErr != nil {
  7433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. return
  7436. }
  7437. var respJSON map[string]interface{}
  7438. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7441. return
  7442. }
  7443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7444. userJSONBytes, _ := json.Marshal(respJSON)
  7445. fmt.Println("log")
  7446. fmt.Println(string(userJSONBytes))
  7447. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7448. utils.ErrorLog("解析失败:%v", err)
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7450. return
  7451. }
  7452. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7453. data := make(map[string]interface{})
  7454. client := &http.Client{}
  7455. data["psn_no"] = his.PsnNo
  7456. data["mdtrt_id"] = his.Number
  7457. data["doctor"] = roles.UserName
  7458. data["department"] = department.Name
  7459. data["org_name"] = miConfig.OrgName
  7460. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7461. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7462. data["fixmedins_code"] = miConfig.Code
  7463. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7464. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7465. data["secret_key"] = miConfig.SecretKey
  7466. data["sick_code"] = sickConfig.CountryCode
  7467. data["sick_name"] = sickConfig.ClassName
  7468. data["begin_time"] = begin_time
  7469. data["dept"] = strconv.FormatInt(department.ID, 10)
  7470. data["config"] = config
  7471. data["url"] = miConfig.Url
  7472. data["ak"] = miConfig.AccessKey
  7473. data["cainfo"] = miConfig.Cainfo
  7474. bytesData, _ := json.Marshal(data)
  7475. var req *http.Request
  7476. if miConfig.MdtrtareaAdmvs == "320921" {
  7477. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7478. //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 +
  7479. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7480. } else {
  7481. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7482. }
  7483. resp, _ := client.Do(req)
  7484. defer resp.Body.Close()
  7485. body, ioErr := ioutil.ReadAll(resp.Body)
  7486. if ioErr != nil {
  7487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. return
  7490. }
  7491. var respJSON map[string]interface{}
  7492. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7495. return
  7496. }
  7497. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7498. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7499. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7501. userJSONBytes, _ := json.Marshal(respJSON)
  7502. fmt.Println("log")
  7503. fmt.Println(string(userJSONBytes))
  7504. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7505. utils.ErrorLog("解析失败:%v", err)
  7506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7507. return
  7508. }
  7509. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7510. res2.Output = resSix10265.Output
  7511. res2.ErrMsg = resSix10265.ErrMsg
  7512. res2.Cainfo = resSix10265.Cainfo
  7513. res2.WarnMsg = resSix10265.WarnMsg
  7514. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7515. res2.Infcode = infocode
  7516. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7517. 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)
  7518. saveLog(result, requestLog, "2203", "上传就诊信息")
  7519. var respJSON2 map[string]interface{}
  7520. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7523. return
  7524. }
  7525. userJSONBytes2, _ := json.Marshal(respJSON2)
  7526. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7527. utils.ErrorLog("解析失败:%v", err)
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7529. return
  7530. }
  7531. } else {
  7532. var result string
  7533. var requestLog string
  7534. if miConfig.MdtrtareaAdmvs == "440781" { //
  7535. 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)
  7536. } else {
  7537. if miConfig.Code == "H15049901371" {
  7538. //赤峰地区国家医保医疗类别
  7539. //职工透析:医疗类别选特殊情况门诊990502
  7540. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7541. var med_type string
  7542. if his.Insutype == "390" {
  7543. if reg_type == 14 {
  7544. med_type = "9933"
  7545. } else if reg_type == 11 {
  7546. med_type = "11"
  7547. }
  7548. } else if his.Insutype == "310" {
  7549. if reg_type == 14 {
  7550. med_type = "990502"
  7551. } else if reg_type == 11 {
  7552. med_type = "11"
  7553. }
  7554. }
  7555. 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)
  7556. } else {
  7557. 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)
  7558. }
  7559. saveLog(result, requestLog, "2203", "上传就诊信息")
  7560. var respJSON2 map[string]interface{}
  7561. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7564. return
  7565. }
  7566. userJSONBytes2, _ := json.Marshal(respJSON2)
  7567. if miConfig.Code == "H15049901371" {
  7568. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7569. utils.ErrorLog("解析失败:%v", err)
  7570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7571. return
  7572. }
  7573. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7574. res2.Output = resSix10265.Output
  7575. res2.ErrMsg = resSix10265.ErrMsg
  7576. res2.Cainfo = resSix10265.Cainfo
  7577. res2.WarnMsg = resSix10265.WarnMsg
  7578. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7579. res2.Infcode = infocode
  7580. } else {
  7581. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7582. utils.ErrorLog("解析失败:%v", err)
  7583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. return
  7585. }
  7586. }
  7587. }
  7588. }
  7589. if res2.Infcode != 0 {
  7590. adminUser := c.GetAdminUserInfo()
  7591. errlog := &models.HisOrderError{
  7592. UserOrgId: adminUser.CurrentOrgId,
  7593. Ctime: time.Now().Unix(),
  7594. Mtime: time.Now().Unix(),
  7595. ErrMsg: res2.ErrMsg,
  7596. Status: 1,
  7597. PatientId: id,
  7598. RecordTime: recordDateTime,
  7599. Stage: 3,
  7600. }
  7601. service.CreateErrMsgLog(errlog)
  7602. c.ServeSuccessJSON(map[string]interface{}{
  7603. "failed_code": -10,
  7604. "msg": res2.ErrMsg,
  7605. })
  7606. return
  7607. } else {
  7608. his.Diagnosis = diagnosis_id
  7609. his.SickType = sickConfig.ID
  7610. his.PType = fmt.Sprintf("%d", reg_type)
  7611. service.UpdateHisPatientThree(&his)
  7612. data := make(map[string]interface{})
  7613. if settle_accounts_type == 1 { //日结
  7614. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7615. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7616. } else {
  7617. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7618. }
  7619. data["pre"] = prescriptions
  7620. } else { //月结
  7621. start_time_str := c.GetString("start_time")
  7622. end_time_str := c.GetString("end_time")
  7623. timeLayout := "2006-01-02"
  7624. loc, _ := time.LoadLocation("Local")
  7625. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7626. if err != nil {
  7627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7628. return
  7629. }
  7630. recordStartTime := theStartTime.Unix()
  7631. start_time = recordStartTime
  7632. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7633. if err != nil {
  7634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7635. return
  7636. }
  7637. recordEndTime := theEndTime.Unix()
  7638. end_time = recordEndTime
  7639. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7640. data["pre"] = prescriptions
  7641. }
  7642. client := &http.Client{}
  7643. data["psn_no"] = his.PsnNo
  7644. data["mdtrt_id"] = his.Number
  7645. data["chrg_bchno"] = chrg_bchno
  7646. data["org_name"] = miConfig.OrgName
  7647. data["doctor"] = roles.UserName
  7648. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7649. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7650. data["fixmedins_code"] = miConfig.Code
  7651. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7652. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7653. data["dept_code"] = "15"
  7654. } else {
  7655. data["dept_code"] = department.Number
  7656. }
  7657. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7658. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7659. data["secret_key"] = miConfig.SecretKey
  7660. data["url"] = miConfig.Url
  7661. data["ak"] = miConfig.AccessKey
  7662. data["new_doctor_name"] = patientPrescription.Doctor
  7663. data["diag_code"] = sickConfig.CountryCode
  7664. data["time_stamp"] = time_stamp
  7665. data["cainfo"] = miConfig.Cainfo
  7666. var ids []int64
  7667. for _, item := range prescriptions {
  7668. ids = append(ids, item.ID)
  7669. }
  7670. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7671. if config.IsOpen == 1 { //对接了医保,走医保流程
  7672. var res ResultFour
  7673. var resFour10265 ResultFour10265
  7674. if miConfig.MdtrtareaAdmvs == "421300" {
  7675. bytesData, _ := json.Marshal(data)
  7676. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7677. resp, _ := client.Do(req)
  7678. defer resp.Body.Close()
  7679. body, ioErr := ioutil.ReadAll(resp.Body)
  7680. if ioErr != nil {
  7681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7683. return
  7684. }
  7685. var respJSON map[string]interface{}
  7686. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7689. return
  7690. }
  7691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7692. userJSONBytes, _ := json.Marshal(respJSON)
  7693. fmt.Println("log")
  7694. fmt.Println(string(userJSONBytes))
  7695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7696. utils.ErrorLog("解析失败:%v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7701. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7702. if result3101.Infcode == "0" {
  7703. if len(result3101.Output.Result) > 0 {
  7704. var errMsgs []string
  7705. for _, item := range result3101.Output.Result {
  7706. errMsgs = append(errMsgs, item.VolaCont)
  7707. }
  7708. c.ServeSuccessJSON(map[string]interface{}{
  7709. "failed_code": -10,
  7710. "msg": errMsgs,
  7711. })
  7712. return
  7713. }
  7714. }
  7715. bytesData, _ := json.Marshal(data)
  7716. var req *http.Request
  7717. if miConfig.MdtrtareaAdmvs == "320921" {
  7718. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7719. } else {
  7720. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7721. }
  7722. resp, _ := client.Do(req)
  7723. defer resp.Body.Close()
  7724. body, ioErr := ioutil.ReadAll(resp.Body)
  7725. if ioErr != nil {
  7726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7728. return
  7729. }
  7730. var respJSON map[string]interface{}
  7731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7737. userJSONBytes, _ := json.Marshal(respJSON)
  7738. fmt.Println("log")
  7739. fmt.Println(string(userJSONBytes))
  7740. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7741. utils.ErrorLog("解析失败:%v", err)
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7743. return
  7744. }
  7745. res.InfRefmsgid = resFour10265.InfRefmsgid
  7746. res.Output = resFour10265.Output
  7747. res.ErrMsg = resFour10265.ErrMsg
  7748. res.Cainfo = resFour10265.Cainfo
  7749. res.WarnMsg = resFour10265.WarnMsg
  7750. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7751. res.Infcode = infocode
  7752. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7753. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  7754. var dat map[string]interface{}
  7755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7756. fmt.Println(dat)
  7757. } else {
  7758. fmt.Println(err)
  7759. }
  7760. saveLog(result, request_log, "2204", "上传费用明细")
  7761. userJSONBytes, _ := json.Marshal(dat)
  7762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7763. utils.ErrorLog("解析失败:%v", err)
  7764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. return
  7766. }
  7767. } else {
  7768. if miConfig.Code == "H15049901371" {
  7769. 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)
  7770. var dat map[string]interface{}
  7771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7772. fmt.Println(dat)
  7773. } else {
  7774. fmt.Println(err)
  7775. }
  7776. saveLog(result, request_log, "2204", "上传费用明细")
  7777. userJSONBytes, _ := json.Marshal(dat)
  7778. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7779. utils.ErrorLog("解析失败:%v", err)
  7780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7781. return
  7782. }
  7783. res.InfRefmsgid = resFour10265.InfRefmsgid
  7784. res.Output = resFour10265.Output
  7785. res.ErrMsg = resFour10265.ErrMsg
  7786. res.Cainfo = resFour10265.Cainfo
  7787. res.WarnMsg = resFour10265.WarnMsg
  7788. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7789. res.Infcode = infocode
  7790. } else {
  7791. 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)
  7792. var dat map[string]interface{}
  7793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7794. fmt.Println(dat)
  7795. } else {
  7796. fmt.Println(err)
  7797. }
  7798. saveLog(result, request_log, "2204", "上传费用明细")
  7799. userJSONBytes, _ := json.Marshal(dat)
  7800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7801. utils.ErrorLog("解析失败:%v", err)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. }
  7806. }
  7807. if res.Infcode == 0 {
  7808. order := &models.HisOrder{
  7809. UserOrgId: adminUser.CurrentOrgId,
  7810. HisPatientId: his.ID,
  7811. PatientId: his.PatientId,
  7812. SettleAccountsDate: recordDateTime,
  7813. Ctime: time.Now().Unix(),
  7814. Mtime: time.Now().Unix(),
  7815. MdtrtId: his.Number,
  7816. PsnNo: his.PsnNo,
  7817. MedType: strconv.FormatInt(reg_type, 10),
  7818. Status: 1,
  7819. Number: chrg_bchno,
  7820. Infcode: res.Infcode,
  7821. WarnMsg: res.WarnMsg,
  7822. Cainfo: res.Cainfo,
  7823. ErrMsg: res.ErrMsg,
  7824. RespondTime: res.RefmsgTime,
  7825. InfRefmsgid: res.InfRefmsgid,
  7826. OrderStatus: 1,
  7827. IsMedicineInsurance: 1,
  7828. SettleType: settle_accounts_type,
  7829. SettleStartTime: start_time,
  7830. SettleEndTime: end_time,
  7831. Creator: roles.AdminUserId,
  7832. Modify: roles.AdminUserId,
  7833. PType: 2,
  7834. Diagnosis: diagnosis_id,
  7835. }
  7836. err = service.CreateOrder(order)
  7837. if err != nil {
  7838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7839. return
  7840. }
  7841. for _, item := range res.Output.Result {
  7842. temp := strings.Split(item.FeedetlSn, "-")
  7843. var advice_id int64 = 0
  7844. var project_id int64 = 0
  7845. var types int64 = 0
  7846. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7847. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7848. if temp[1] == "1" {
  7849. advice_id = id
  7850. project_id = 0
  7851. } else if temp[1] == "2" {
  7852. advice_id = 0
  7853. project_id = id
  7854. }
  7855. info := &models.HisOrderInfo{
  7856. OrderNumber: order.Number,
  7857. FeedetlSn: item.FeedetlSn,
  7858. UploadDate: time.Now().Unix(),
  7859. AdviceId: advice_id,
  7860. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7861. Cnt: item.Cnt,
  7862. Pric: float64(item.Pric),
  7863. PatientId: his.PatientId,
  7864. PricUplmtAmt: item.PricUplmtAmt,
  7865. SelfpayProp: item.SelfpayProp,
  7866. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7867. OverlmtAmt: item.OverlmtAmt,
  7868. PreselfpayAmt: item.PreselfpayAmt,
  7869. BasMednFlag: item.BasMednFlag,
  7870. MedChrgitmType: item.MedChrgitmType,
  7871. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7872. Status: 1,
  7873. Memo: item.Memo,
  7874. Mtime: time.Now().Unix(),
  7875. InscpScpAmt: item.InscpScpAmt,
  7876. DrtReimFlag: item.DrtReimFlag,
  7877. Ctime: time.Now().Unix(),
  7878. ListSpItemFlag: item.ListSpItemFlag,
  7879. ChldMedcFlag: item.ChldMedcFlag,
  7880. LmtUsedFlag: item.LmtUsedFlag,
  7881. ChrgitmLv: item.ChrgitmLv,
  7882. UserOrgId: adminUser.CurrentOrgId,
  7883. HisPatientId: his.ID,
  7884. OrderId: order.ID,
  7885. ProjectId: project_id,
  7886. Type: types,
  7887. }
  7888. service.CreateOrderInfo(info)
  7889. }
  7890. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7891. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7892. var total float64
  7893. for _, item := range prescriptions {
  7894. if item.Type == 1 { //药品
  7895. for _, subItem := range item.HisDoctorAdviceInfo {
  7896. total = total + (subItem.Price * subItem.PrescribingNumber)
  7897. }
  7898. }
  7899. if item.Type == 2 { //项目
  7900. for _, subItem := range item.HisPrescriptionProject {
  7901. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7902. total = total + (subItem.Price * cnt)
  7903. }
  7904. }
  7905. }
  7906. for _, item := range prescriptions {
  7907. for _, subItem := range item.HisAdditionalCharge {
  7908. total = total + (subItem.Price * float64(subItem.Count))
  7909. }
  7910. }
  7911. allTotal := fmt.Sprintf("%.4f", total)
  7912. if res.Infcode == 0 {
  7913. var rf []*ResultFive
  7914. json.Unmarshal([]byte(his.Iinfo), &rf)
  7915. chrg_bchno := chrg_bchno
  7916. cert_no := his.Certno
  7917. var insutypes []string
  7918. var insutype string
  7919. var is390 int = 0
  7920. var is310 int = 0
  7921. for _, item := range rf {
  7922. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7923. insutypes = append(insutypes, item.Insutype)
  7924. }
  7925. }
  7926. if len(insutypes) == 1 {
  7927. insutype = insutypes[0]
  7928. } else {
  7929. for _, i := range insutypes {
  7930. if i == "390" {
  7931. is390 = 1
  7932. }
  7933. if i == "310" {
  7934. is310 = 1
  7935. }
  7936. }
  7937. }
  7938. if is390 == 1 {
  7939. insutype = "390"
  7940. }
  7941. if is310 == 1 {
  7942. insutype = "310"
  7943. }
  7944. if len(insutypes) == 0 {
  7945. insutype = "310"
  7946. }
  7947. if len(insutypes) == 2 {
  7948. insutype = strconv.FormatInt(his.SocialType, 64)
  7949. }
  7950. //insutype = "390"
  7951. if his.IdCardType == 1 {
  7952. cert_no = his.MedicalInsuranceNumber
  7953. } else {
  7954. cert_no = his.Certno
  7955. }
  7956. var res ResultSeven
  7957. var resSeven10265 ResultSeven10265
  7958. if miConfig.MdtrtareaAdmvs == "421300" {
  7959. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7960. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7961. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7963. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7964. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7965. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7966. resp, requestErr := http.Get(api)
  7967. if requestErr != nil {
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. body, ioErr := ioutil.ReadAll(resp.Body)
  7972. if ioErr != nil {
  7973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7975. return
  7976. }
  7977. var respJSON map[string]interface{}
  7978. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7981. return
  7982. }
  7983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7984. result, _ := json.Marshal(respJSON)
  7985. fmt.Println("log")
  7986. fmt.Println(string(result))
  7987. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7988. utils.ErrorLog("解析失败:%v", err)
  7989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7990. return
  7991. }
  7992. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7993. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  7994. if result3101.Infcode == "0" {
  7995. if len(result3101.Output.Result) > 0 {
  7996. var errMsgs []string
  7997. for _, item := range result3101.Output.Result {
  7998. errMsgs = append(errMsgs, item.VolaCont)
  7999. }
  8000. c.ServeSuccessJSON(map[string]interface{}{
  8001. "failed_code": -10,
  8002. "msg": errMsgs,
  8003. })
  8004. return
  8005. }
  8006. }
  8007. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8008. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8009. bas := strings.Split(psn_info.CardInfo, "|")
  8010. if his.IdCardType == 1 {
  8011. cert_no = bas[2]
  8012. } else {
  8013. cert_no = bas[1]
  8014. }
  8015. //江苏地区国家医保医疗类别
  8016. //职工透析:医疗类别选特殊情况门诊9933
  8017. //居民血透门慢: 医疗类别选门诊慢病1402
  8018. //var med_type string
  8019. //if his.Insutype == "310" {
  8020. // if reg_type == 14 {
  8021. // med_type = "9933"
  8022. // } else if reg_type == 11 {
  8023. // med_type = "11"
  8024. //
  8025. // }
  8026. //} else if his.Insutype == "390" {
  8027. // if reg_type == 14 {
  8028. // med_type = "1402"
  8029. // } else if reg_type == 11 {
  8030. // med_type = "11"
  8031. // }
  8032. //}
  8033. var api string
  8034. if miConfig.MdtrtareaAdmvs == "320921" {
  8035. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8036. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8037. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8038. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8039. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8040. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8041. "&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
  8042. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8043. } else {
  8044. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8045. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8046. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8047. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8048. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8049. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8050. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8051. "&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
  8052. }
  8053. resp, requestErr := http.Get(api)
  8054. if requestErr != nil {
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. body, ioErr := ioutil.ReadAll(resp.Body)
  8059. if ioErr != nil {
  8060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. var respJSON map[string]interface{}
  8065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8068. return
  8069. }
  8070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8071. result, _ := json.Marshal(respJSON)
  8072. fmt.Println("log")
  8073. fmt.Println(string(result))
  8074. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8075. utils.ErrorLog("解析失败:%v", err)
  8076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8077. return
  8078. }
  8079. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8080. res.Output = resSeven10265.Output
  8081. res.ErrMsg = resSeven10265.ErrMsg
  8082. res.Cainfo = resSeven10265.Cainfo
  8083. res.WarnMsg = resSeven10265.WarnMsg
  8084. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8085. res.Infcode = infocode
  8086. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8087. 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)
  8088. var dat map[string]interface{}
  8089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8090. fmt.Println(dat)
  8091. } else {
  8092. fmt.Println(err)
  8093. }
  8094. saveLog(result, request_log, "2206", "预结算")
  8095. userJSONBytes, _ := json.Marshal(dat)
  8096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8097. utils.ErrorLog("解析失败:%v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. } else {
  8102. var result string
  8103. var request_log string
  8104. if miConfig.Code == "H15049901371" {
  8105. //赤峰地区国家医保医疗类别
  8106. //职工透析:医疗类别选特殊情况门诊990502
  8107. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8108. var med_type string
  8109. if his.Insutype == "390" {
  8110. if reg_type == 14 {
  8111. med_type = "9933"
  8112. } else if reg_type == 11 {
  8113. med_type = "11"
  8114. }
  8115. } else if his.Insutype == "310" {
  8116. if reg_type == 14 {
  8117. med_type = "990502"
  8118. } else if reg_type == 11 {
  8119. med_type = "11"
  8120. }
  8121. }
  8122. 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)
  8123. } else {
  8124. 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)
  8125. }
  8126. var dat map[string]interface{}
  8127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8128. fmt.Println(dat)
  8129. } else {
  8130. fmt.Println(err)
  8131. }
  8132. saveLog(result, request_log, "2206", "预结算")
  8133. //userJSONBytes, _ := json.Marshal(dat)
  8134. //
  8135. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8136. // utils.ErrorLog("解析失败:%v", err)
  8137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. // return
  8139. //}
  8140. userJSONBytes, _ := json.Marshal(dat)
  8141. if miConfig.Code == "H15049901371" {
  8142. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8143. utils.ErrorLog("解析失败:%v", err)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8148. res.Output = resSeven10265.Output
  8149. res.ErrMsg = resSeven10265.ErrMsg
  8150. res.Cainfo = resSeven10265.Cainfo
  8151. res.WarnMsg = resSeven10265.WarnMsg
  8152. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8153. res.Infcode = infocode
  8154. } else {
  8155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8156. utils.ErrorLog("解析失败:%v", err)
  8157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8158. return
  8159. }
  8160. }
  8161. }
  8162. if res.Infcode != 0 {
  8163. errlog := &models.HisOrderError{
  8164. UserOrgId: adminUser.CurrentOrgId,
  8165. Ctime: time.Now().Unix(),
  8166. Mtime: time.Now().Unix(),
  8167. Number: chrg_bchno,
  8168. ErrMsg: res.ErrMsg,
  8169. Status: 1,
  8170. PatientId: id,
  8171. RecordTime: recordDateTime,
  8172. Stage: 20,
  8173. }
  8174. service.CreateErrMsgLog(errlog)
  8175. c.ServeSuccessJSON(map[string]interface{}{
  8176. "failed_code": -10,
  8177. "msg": res.ErrMsg,
  8178. })
  8179. return
  8180. } else {
  8181. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8182. order.OrderStatus = 1
  8183. order.IsPre = 1
  8184. order.Status = 1
  8185. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8186. order.SetlId = res.Output.Setlinfo.SetlID
  8187. order.PsnNo = res.Output.Setlinfo.PsnNo
  8188. order.PsnName = res.Output.Setlinfo.PsnName
  8189. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8190. order.Certno = res.Output.Setlinfo.Certno
  8191. order.Gend = res.Output.Setlinfo.Gend
  8192. order.Naty = res.Output.Setlinfo.Naty
  8193. order.Age = res.Output.Setlinfo.Age
  8194. order.Insutype = res.Output.Setlinfo.Insutype
  8195. order.PsnType = res.Output.Setlinfo.PsnType
  8196. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8197. order.SetlTime = res.Output.Setlinfo.SetlTime
  8198. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8199. if res.Output.Setlinfo.MedType == "140101" {
  8200. order.MedType = "14"
  8201. } else {
  8202. order.MedType = res.Output.Setlinfo.MedType
  8203. }
  8204. if reg_type == 1112 {
  8205. order.MedType = "1112"
  8206. }
  8207. if reg_type == 1111 {
  8208. order.MedType = "1111"
  8209. }
  8210. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8211. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8212. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8213. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8214. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8215. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8216. order.HifpPay = res.Output.Setlinfo.HifpPay
  8217. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8218. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8219. order.HifesPay = res.Output.Setlinfo.HifesPay
  8220. order.HifobPay = res.Output.Setlinfo.HifobPay
  8221. order.MafPay = res.Output.Setlinfo.MafPay
  8222. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8223. order.OthPay = res.Output.Setlinfo.OthPay
  8224. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8225. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8226. order.AcctPay = res.Output.Setlinfo.AcctPay
  8227. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8228. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8229. order.Balc = res.Output.Setlinfo.Balc
  8230. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8231. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8232. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8233. order.ClrWay = res.Output.Setlinfo.ClrWay
  8234. order.Creator = order.Creator
  8235. order.Modify = roles.AdminUserId
  8236. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8237. detailStr := string(setlDetail)
  8238. order.SetlDetail = detailStr
  8239. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8240. err = service.UpDateOrder(order)
  8241. if err == nil {
  8242. c.ServeSuccessJSON(map[string]interface{}{
  8243. "msg": "预结算成功",
  8244. })
  8245. } else {
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8247. return
  8248. }
  8249. }
  8250. } else {
  8251. adminUser := c.GetAdminUserInfo()
  8252. errlog := &models.HisOrderError{
  8253. UserOrgId: adminUser.CurrentOrgId,
  8254. Ctime: time.Now().Unix(),
  8255. Mtime: time.Now().Unix(),
  8256. ErrMsg: res.ErrMsg,
  8257. Status: 1,
  8258. PatientId: id,
  8259. RecordTime: recordDateTime,
  8260. Stage: 4,
  8261. }
  8262. service.CreateErrMsgLog(errlog)
  8263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8264. return
  8265. }
  8266. } else {
  8267. adminUser := c.GetAdminUserInfo()
  8268. errlog := &models.HisOrderError{
  8269. UserOrgId: adminUser.CurrentOrgId,
  8270. Ctime: time.Now().Unix(),
  8271. Mtime: time.Now().Unix(),
  8272. ErrMsg: res.ErrMsg,
  8273. Status: 1,
  8274. PatientId: id,
  8275. RecordTime: recordDateTime,
  8276. Stage: 4,
  8277. }
  8278. service.CreateErrMsgLog(errlog)
  8279. c.ServeSuccessJSON(map[string]interface{}{
  8280. "failed_code": -10,
  8281. "msg": res.ErrMsg,
  8282. })
  8283. return
  8284. }
  8285. }
  8286. }
  8287. }
  8288. //退款
  8289. func (c *HisApiController) Refund() {
  8290. order_id, _ := c.GetInt64("order_id")
  8291. admin_user_id, _ := c.GetInt64("admin_user_id")
  8292. adminUser := c.GetAdminUserInfo()
  8293. var order models.HisOrder
  8294. order, _ = service.GetHisOrderByID(order_id)
  8295. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8296. if order.ID == 0 {
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8298. return
  8299. }
  8300. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8301. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8302. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8303. if config.IsOpen == 1 { //对接了医保,走医保流程
  8304. var res ResultSixteen
  8305. var resSixteen10265 ResultSixteen10265
  8306. var src_resquest string
  8307. var result string
  8308. if miConfig.MdtrtareaAdmvs == "421300" {
  8309. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8310. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8311. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8312. resp3, requestErr3 := http.Get(api3)
  8313. if requestErr3 != nil {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8318. if ioErr3 != nil {
  8319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. var respJSON3 map[string]interface{}
  8324. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8330. userJSONBytes3, _ := json.Marshal(respJSON3)
  8331. fmt.Println("log")
  8332. fmt.Println(string(userJSONBytes3))
  8333. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8334. utils.ErrorLog("解析失败:%v", err)
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. return
  8337. }
  8338. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8339. var api3 string
  8340. if miConfig.MdtrtareaAdmvs == "320921" {
  8341. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8342. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8343. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8344. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8345. } else {
  8346. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8347. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8348. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8349. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8350. }
  8351. resp3, requestErr3 := http.Get(api3)
  8352. if requestErr3 != nil {
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8357. if ioErr3 != nil {
  8358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. var respJSON3 map[string]interface{}
  8363. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8366. return
  8367. }
  8368. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8369. userJSONBytes3, _ := json.Marshal(respJSON3)
  8370. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8371. utils.ErrorLog("解析失败:%v", err)
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8376. res.Output = resSixteen10265.Output
  8377. res.ErrMsg = resSixteen10265.ErrMsg
  8378. res.Cainfo = resSixteen10265.Cainfo
  8379. res.WarnMsg = resSixteen10265.WarnMsg
  8380. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8381. res.Infcode = infocode
  8382. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8383. 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)
  8384. var dat map[string]interface{}
  8385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8386. fmt.Println(dat)
  8387. } else {
  8388. fmt.Println(err)
  8389. }
  8390. saveLog(result, src_resquest, "2208", "退费")
  8391. userJSONBytes, _ := json.Marshal(dat)
  8392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8393. utils.ErrorLog("解析失败:%v", err)
  8394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8395. return
  8396. }
  8397. } else {
  8398. if miConfig.Code == "H15049901371" {
  8399. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8400. var dat map[string]interface{}
  8401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8402. fmt.Println(dat)
  8403. } else {
  8404. fmt.Println(err)
  8405. }
  8406. saveLog(result, src_resquest, "2208", "退费")
  8407. userJSONBytes, _ := json.Marshal(dat)
  8408. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8409. utils.ErrorLog("解析失败:%v", err)
  8410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8411. return
  8412. }
  8413. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8414. res.Output = resSixteen10265.Output
  8415. res.ErrMsg = resSixteen10265.ErrMsg
  8416. res.Cainfo = resSixteen10265.Cainfo
  8417. res.WarnMsg = resSixteen10265.WarnMsg
  8418. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8419. res.Infcode = infocode
  8420. } else {
  8421. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8422. var dat map[string]interface{}
  8423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8424. fmt.Println(dat)
  8425. } else {
  8426. fmt.Println(err)
  8427. }
  8428. saveLog(result, src_resquest, "2208", "退费")
  8429. userJSONBytes, _ := json.Marshal(dat)
  8430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8431. utils.ErrorLog("解析失败:%v", err)
  8432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8433. return
  8434. }
  8435. }
  8436. }
  8437. if res.Infcode == 0 {
  8438. var res2 ResultSix
  8439. var resSix10265 ResultSix10265
  8440. if miConfig.MdtrtareaAdmvs == "421300" {
  8441. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8442. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8444. resp3, requestErr3 := http.Get(api3)
  8445. if requestErr3 != nil {
  8446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8447. return
  8448. }
  8449. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8450. if ioErr3 != nil {
  8451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. var respJSON3 map[string]interface{}
  8456. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8459. return
  8460. }
  8461. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8462. userJSONBytes3, _ := json.Marshal(respJSON3)
  8463. fmt.Println("log")
  8464. fmt.Println(string(userJSONBytes3))
  8465. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8466. utils.ErrorLog("解析失败:%v", err)
  8467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8468. return
  8469. }
  8470. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8471. var api3 string
  8472. if miConfig.MdtrtareaAdmvs == "320921" {
  8473. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8474. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8475. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8476. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8477. } else {
  8478. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8479. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8480. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8481. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8482. }
  8483. resp3, requestErr3 := http.Get(api3)
  8484. if requestErr3 != nil {
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8489. if ioErr3 != nil {
  8490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8492. return
  8493. }
  8494. var respJSON3 map[string]interface{}
  8495. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8498. return
  8499. }
  8500. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8501. userJSONBytes3, _ := json.Marshal(respJSON3)
  8502. fmt.Println("log")
  8503. fmt.Println(string(userJSONBytes3))
  8504. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8505. utils.ErrorLog("解析失败:%v", err)
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8510. res2.Output = resSix10265.Output
  8511. res2.ErrMsg = resSix10265.ErrMsg
  8512. res2.Cainfo = resSix10265.Cainfo
  8513. res2.WarnMsg = resSix10265.WarnMsg
  8514. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8515. res2.Infcode = infocode
  8516. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8517. 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)
  8518. var dat map[string]interface{}
  8519. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8520. fmt.Println(dat)
  8521. } else {
  8522. fmt.Println(err)
  8523. }
  8524. saveLog(result2, src_request, "2205", "撤销明细")
  8525. userJSONBytes, _ := json.Marshal(dat)
  8526. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8527. utils.ErrorLog("解析失败:%v", err)
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. } else {
  8532. if miConfig.Code == "H15049901371" {
  8533. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8534. var dat map[string]interface{}
  8535. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8536. fmt.Println(dat)
  8537. } else {
  8538. fmt.Println(err)
  8539. }
  8540. saveLog(result2, src_request, "2205", "撤销明细")
  8541. userJSONBytes, _ := json.Marshal(dat)
  8542. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8543. utils.ErrorLog("解析失败:%v", err)
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8548. res2.Output = resSix10265.Output
  8549. res2.ErrMsg = resSix10265.ErrMsg
  8550. res2.Cainfo = resSix10265.Cainfo
  8551. res2.WarnMsg = resSix10265.WarnMsg
  8552. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8553. res2.Infcode = infocode
  8554. } else {
  8555. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8556. var dat map[string]interface{}
  8557. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8558. fmt.Println(dat)
  8559. } else {
  8560. fmt.Println(err)
  8561. }
  8562. saveLog(result2, src_request, "2205", "撤销明细")
  8563. userJSONBytes, _ := json.Marshal(dat)
  8564. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8565. utils.ErrorLog("解析失败:%v", err)
  8566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8567. return
  8568. }
  8569. }
  8570. }
  8571. if res2.Infcode == 0 {
  8572. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8573. if err == nil {
  8574. //当押金不为零时产生退费记录
  8575. if order.Decimal != 0 {
  8576. tmp := strconv.FormatInt(order.ID, 10)
  8577. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8578. if err != nil {
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. }
  8583. c.ServeSuccessJSON(map[string]interface{}{
  8584. "msg": "退费成功",
  8585. })
  8586. } else {
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. } else {
  8591. c.ServeSuccessJSON(map[string]interface{}{
  8592. "code": -10,
  8593. "msg": res2.ErrMsg,
  8594. })
  8595. }
  8596. } else {
  8597. c.ServeSuccessJSON(map[string]interface{}{
  8598. "code": -10,
  8599. "msg": res.ErrMsg,
  8600. })
  8601. }
  8602. }
  8603. }
  8604. func (c *HisApiController) RefundNumber() {
  8605. record_time := c.GetString("record_time")
  8606. //patient_id, _ := c.GetInt64("patient_id")
  8607. admin_user_id, _ := c.GetInt64("admin_user_id")
  8608. his_patient_id, _ := c.GetInt64("id")
  8609. timeLayout := "2006-01-02"
  8610. loc, _ := time.LoadLocation("Local")
  8611. adminUser := c.GetAdminUserInfo()
  8612. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8613. fmt.Println(err)
  8614. if err != nil {
  8615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8616. return
  8617. }
  8618. recordDateTime := theTime.Unix()
  8619. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8620. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8621. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8622. //order, _ := service.GetHisOrderByID(order_id)
  8623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8624. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8625. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8626. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8627. if count > 0 {
  8628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8629. return
  8630. }
  8631. if config.IsOpen == 1 { //对接了医保,走医保流程
  8632. var res2 ResultSix
  8633. var resSix10265 ResultSix10265
  8634. if miConfig.MdtrtareaAdmvs == "421300" {
  8635. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8636. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8638. resp3, requestErr3 := http.Get(api3)
  8639. if requestErr3 != nil {
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8641. return
  8642. }
  8643. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8644. if ioErr3 != nil {
  8645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8647. return
  8648. }
  8649. var respJSON3 map[string]interface{}
  8650. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8653. return
  8654. }
  8655. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8656. userJSONBytes3, _ := json.Marshal(respJSON3)
  8657. fmt.Println("log")
  8658. fmt.Println(string(userJSONBytes3))
  8659. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8660. utils.ErrorLog("解析失败:%v", err)
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8662. return
  8663. }
  8664. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8665. var api3 string
  8666. if miConfig.MdtrtareaAdmvs == "320921" {
  8667. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8668. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8669. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8670. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8671. } else {
  8672. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8673. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8674. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8675. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8676. }
  8677. resp3, requestErr3 := http.Get(api3)
  8678. if requestErr3 != nil {
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8680. return
  8681. }
  8682. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8683. if ioErr3 != nil {
  8684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8686. return
  8687. }
  8688. var respJSON3 map[string]interface{}
  8689. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8695. userJSONBytes3, _ := json.Marshal(respJSON3)
  8696. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8697. utils.ErrorLog("解析失败:%v", err)
  8698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8699. return
  8700. }
  8701. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8702. res2.Output = resSix10265.Output
  8703. res2.ErrMsg = resSix10265.ErrMsg
  8704. res2.Cainfo = resSix10265.Cainfo
  8705. res2.WarnMsg = resSix10265.WarnMsg
  8706. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8707. res2.Infcode = infocode
  8708. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8709. 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)
  8710. var dat map[string]interface{}
  8711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8712. fmt.Println(dat)
  8713. } else {
  8714. fmt.Println(err)
  8715. }
  8716. saveLog(result, request, "2202", "退号")
  8717. userJSONBytes, _ := json.Marshal(dat)
  8718. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8719. utils.ErrorLog("解析失败:%v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. } else {
  8724. var api3 string
  8725. if miConfig.Code == "H15049901371" {
  8726. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8727. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8728. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8729. } else {
  8730. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8731. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8732. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8733. }
  8734. resp3, requestErr3 := http.Get(api3)
  8735. if requestErr3 != nil {
  8736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8737. return
  8738. }
  8739. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8740. if ioErr3 != nil {
  8741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8743. return
  8744. }
  8745. var respJSON3 map[string]interface{}
  8746. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8752. userJSONBytes3, _ := json.Marshal(respJSON3)
  8753. if miConfig.Code == "H15049901371" {
  8754. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8760. res2.Output = resSix10265.Output
  8761. res2.ErrMsg = resSix10265.ErrMsg
  8762. res2.Cainfo = resSix10265.Cainfo
  8763. res2.WarnMsg = resSix10265.WarnMsg
  8764. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8765. res2.Infcode = infocode
  8766. } else {
  8767. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8768. utils.ErrorLog("解析失败:%v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. }
  8773. }
  8774. if res2.Infcode == 0 {
  8775. if err == nil {
  8776. c.ServeSuccessJSON(map[string]interface{}{
  8777. "msg": "退号成功",
  8778. })
  8779. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8780. } else {
  8781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8782. return
  8783. }
  8784. } else {
  8785. c.ServeSuccessJSON(map[string]interface{}{
  8786. "code": -10,
  8787. "msg": res2.ErrMsg,
  8788. })
  8789. }
  8790. } else {
  8791. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8792. //if err == nil {
  8793. // c.ServeSuccessJSON(map[string]interface{}{
  8794. // "msg": "退费成功",
  8795. // })
  8796. //} else {
  8797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8798. // return
  8799. //}
  8800. }
  8801. }
  8802. func (c *HisApiController) RefundDetail() {
  8803. order_id, _ := c.GetInt64("order_id")
  8804. admin_user_id, _ := c.GetInt64("admin_user_id")
  8805. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8806. number := c.GetString("number")
  8807. record_time := c.GetString("record_time")
  8808. patient_id, _ := c.GetInt64("patient_id")
  8809. //med_type, _ := c.GetInt64("med_type")
  8810. timeLayout := "2006-01-02"
  8811. loc, _ := time.LoadLocation("Local")
  8812. adminUser := c.GetAdminUserInfo()
  8813. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8814. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8815. fmt.Println(err)
  8816. if err != nil {
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8818. return
  8819. }
  8820. recordDateTime := theTime.Unix()
  8821. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8822. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8823. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8824. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8825. var order models.HisOrder
  8826. order, _ = service.GetHisOrderByID(order_id)
  8827. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8828. if config.IsOpen == 1 { //对接了医保,走医保流程
  8829. var res2 ResultSix
  8830. if miConfig.MdtrtareaAdmvs == "421300" {
  8831. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8832. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8834. resp3, requestErr3 := http.Get(api3)
  8835. if requestErr3 != nil {
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8837. return
  8838. }
  8839. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8840. if ioErr3 != nil {
  8841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. var respJSON3 map[string]interface{}
  8846. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8852. userJSONBytes3, _ := json.Marshal(respJSON3)
  8853. fmt.Println("log")
  8854. fmt.Println(string(userJSONBytes3))
  8855. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8856. utils.ErrorLog("解析失败:%v", err)
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8858. return
  8859. }
  8860. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8861. if err == nil {
  8862. c.ServeSuccessJSON(map[string]interface{}{
  8863. "msg": "撤销明细成功",
  8864. })
  8865. return
  8866. } else {
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8871. var resSix10265 ResultSix10265
  8872. var api3 string
  8873. if miConfig.MdtrtareaAdmvs == "320921" {
  8874. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8875. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8876. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8877. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8878. } else {
  8879. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8880. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8881. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8883. }
  8884. resp3, requestErr3 := http.Get(api3)
  8885. if requestErr3 != nil {
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8890. if ioErr3 != nil {
  8891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8893. return
  8894. }
  8895. var respJSON3 map[string]interface{}
  8896. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8899. return
  8900. }
  8901. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8902. userJSONBytes3, _ := json.Marshal(respJSON3)
  8903. fmt.Println("log")
  8904. fmt.Println(string(userJSONBytes3))
  8905. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8906. utils.ErrorLog("解析失败:%v", err)
  8907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8908. return
  8909. }
  8910. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8911. res2.Output = resSix10265.Output
  8912. res2.ErrMsg = resSix10265.ErrMsg
  8913. res2.Cainfo = resSix10265.Cainfo
  8914. res2.WarnMsg = resSix10265.WarnMsg
  8915. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8916. res2.Infcode = infocode
  8917. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8918. if err == nil {
  8919. c.ServeSuccessJSON(map[string]interface{}{
  8920. "msg": "撤销明细成功",
  8921. })
  8922. return
  8923. } else {
  8924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8925. return
  8926. }
  8927. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8928. 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)
  8929. var dat map[string]interface{}
  8930. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8931. fmt.Println(dat)
  8932. } else {
  8933. fmt.Println(err)
  8934. }
  8935. saveLog(result2, src_request, "2205", "撤销明细")
  8936. userJSONBytes, _ := json.Marshal(dat)
  8937. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8938. utils.ErrorLog("解析失败:%v", err)
  8939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8940. return
  8941. }
  8942. if res2.Infcode == 0 {
  8943. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8944. if err == nil {
  8945. c.ServeSuccessJSON(map[string]interface{}{
  8946. "msg": "撤销明细成功",
  8947. })
  8948. return
  8949. } else {
  8950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8951. return
  8952. }
  8953. } else {
  8954. c.ServeSuccessJSON(map[string]interface{}{
  8955. "code": -10,
  8956. "msg": res2.ErrMsg,
  8957. })
  8958. }
  8959. } else {
  8960. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8961. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8963. resp2, requestErr2 := http.Get(api2)
  8964. if requestErr2 != nil {
  8965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8966. return
  8967. }
  8968. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8969. if ioErr2 != nil {
  8970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8972. return
  8973. }
  8974. var respJSON2 map[string]interface{}
  8975. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8978. return
  8979. }
  8980. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8981. if err == nil {
  8982. c.ServeSuccessJSON(map[string]interface{}{
  8983. "msg": "撤销明细成功",
  8984. })
  8985. return
  8986. } else {
  8987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8988. return
  8989. }
  8990. }
  8991. } else {
  8992. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8993. if err == nil {
  8994. c.ServeSuccessJSON(map[string]interface{}{
  8995. "msg": "退费成功",
  8996. })
  8997. } else {
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. }
  9002. }
  9003. //对账
  9004. func (c *HisApiController) GetCheckAccount() {
  9005. start_time := c.GetString("start_time")
  9006. end_time := c.GetString("end_time")
  9007. insutype := c.GetString("insutype")
  9008. clr_type := c.GetString("clr_type")
  9009. clr_org := c.GetString("clr_optins")
  9010. admin_user_id, _ := c.GetInt64("admin_user_id")
  9011. adminUser := c.GetAdminUserInfo()
  9012. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9013. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9014. if len(clr_org) == 0 {
  9015. clr_org = miConfig.MdtrtareaAdmvs
  9016. }
  9017. timeLayout := "2006-01-02"
  9018. loc, _ := time.LoadLocation("Local")
  9019. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9020. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9021. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  9022. fixmedins_setl_cnt := int64(len(orders))
  9023. var medfee_sumamt float64
  9024. var acct_pay float64
  9025. var fund_pay_sumamt float64
  9026. for _, item := range orders {
  9027. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9028. acct_pay = acct_pay + item.AcctPay
  9029. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9030. }
  9031. var user_name string
  9032. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9033. if role.ID == 0 {
  9034. user_name = "xxx"
  9035. } else {
  9036. user_name = role.UserName
  9037. }
  9038. var res ResultEight
  9039. var res10188 ResultEightFor10188
  9040. if config.IsOpen == 1 {
  9041. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9042. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  9043. "insutype=" + insutype +
  9044. "&clr_type=" + clr_type +
  9045. "&setl_optins=" + clr_org +
  9046. "&stmt_begndate=" + start_time +
  9047. "&stm_enddate=" + end_time +
  9048. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9049. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9050. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9051. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9052. "&fixmedins_code=" + miConfig.Code +
  9053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9054. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9055. "&secret_key=" + miConfig.SecretKey +
  9056. "&org_name=" + miConfig.OrgName +
  9057. "&doctor=" + user_name +
  9058. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9059. fmt.Println(api)
  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. fmt.Println(body)
  9067. if ioErr != nil {
  9068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. return
  9071. }
  9072. var respJSON map[string]interface{}
  9073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9076. return
  9077. }
  9078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9079. userJSONBytes, _ := json.Marshal(respJSON)
  9080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9081. utils.ErrorLog("解析失败:%v", err)
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  9085. res.InfRefmsgid = res10188.InfRefmsgid
  9086. res.Output = res10188.Output
  9087. res.ErrMsg = res10188.ErrMsg
  9088. res.Cainfo = res10188.Cainfo
  9089. res.WarnMsg = res10188.WarnMsg
  9090. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9091. res.Infcode = infocode
  9092. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9093. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  9094. "insutype=" + insutype +
  9095. "&clr_type=" + clr_type +
  9096. "&setl_optins=" + clr_org +
  9097. "&stmt_begndate=" + start_time +
  9098. "&stm_enddate=" + end_time +
  9099. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9100. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9101. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9102. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9103. "&fixmedins_code=" + miConfig.Code +
  9104. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9105. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9106. "&secret_key=" + miConfig.SecretKey +
  9107. "&org_name=" + miConfig.OrgName +
  9108. "&doctor=" + user_name
  9109. resp, requestErr := http.Get(api)
  9110. if requestErr != nil {
  9111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9112. return
  9113. }
  9114. body, ioErr := ioutil.ReadAll(resp.Body)
  9115. if ioErr != nil {
  9116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9118. return
  9119. }
  9120. var respJSON map[string]interface{}
  9121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9124. return
  9125. }
  9126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9127. result, _ := json.Marshal(respJSON)
  9128. fmt.Println("log")
  9129. fmt.Println(string(result))
  9130. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  9131. utils.ErrorLog("解析失败:%v", err)
  9132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9133. return
  9134. }
  9135. res.InfRefmsgid = res10188.InfRefmsgid
  9136. res.Output = res10188.Output
  9137. res.ErrMsg = res10188.ErrMsg
  9138. res.Cainfo = res10188.Cainfo
  9139. res.WarnMsg = res10188.WarnMsg
  9140. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  9141. res.Infcode = infocode
  9142. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9143. var baseParams models.BaseParams
  9144. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9145. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9146. baseParams.SecretKey = miConfig.SecretKey
  9147. baseParams.OrgName = miConfig.OrgName
  9148. baseParams.EncKey = miConfig.EncKey
  9149. baseParams.AppSecret = miConfig.AppSecret
  9150. baseParams.SignKey = miConfig.SignKey
  9151. baseParams.AppID = miConfig.Code
  9152. baseParams.RequestUrl = miConfig.Url
  9153. businessParams := models.BusinessParams{
  9154. Insutype: insutype,
  9155. ClrType: clr_type,
  9156. SetlOptins: clr_org,
  9157. StmtBegndate: start_time,
  9158. StmtEnddate: end_time,
  9159. MedfeeSumamt: medfee_sumamt,
  9160. FundPaySumamt: fund_pay_sumamt,
  9161. AcctPay: acct_pay,
  9162. FixmedinsSetlCnt: fixmedins_setl_cnt,
  9163. }
  9164. result, requestLog := service.FJyb3201(baseParams, businessParams)
  9165. fmt.Println(requestLog)
  9166. fmt.Println(result)
  9167. } else {
  9168. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9169. "insutype=" + insutype +
  9170. "&clr_type=" + clr_type +
  9171. "&setl_optins=" + clr_org +
  9172. "&stmt_begndate=" + start_time +
  9173. "&stm_enddate=" + end_time +
  9174. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9175. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9176. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  9177. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9178. "&fixmedins_code=" + miConfig.Code +
  9179. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9180. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9181. "&secret_key=" + miConfig.SecretKey +
  9182. "&org_name=" + miConfig.OrgName +
  9183. "&doctor=" + user_name
  9184. fmt.Println(api)
  9185. resp, requestErr := http.Get(api)
  9186. if requestErr != nil {
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. body, ioErr := ioutil.ReadAll(resp.Body)
  9191. fmt.Println(body)
  9192. if ioErr != nil {
  9193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9195. return
  9196. }
  9197. var respJSON map[string]interface{}
  9198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9201. return
  9202. }
  9203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9204. userJSONBytes, _ := json.Marshal(respJSON)
  9205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9206. utils.ErrorLog("解析失败:%v", err)
  9207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9208. return
  9209. }
  9210. }
  9211. if res.Infcode == 0 {
  9212. if res.Output.Stmtinfo.StmtRslt == "0" {
  9213. micc := &models.MedicalInsuranceCostCompare{
  9214. StartTime: startime.Unix(),
  9215. EndTime: endtime.Unix(),
  9216. Insutype: insutype,
  9217. CheckType: 1,
  9218. Num: fixmedins_setl_cnt,
  9219. Mtime: time.Now().Unix(),
  9220. Status: 1,
  9221. UserOrgId: adminUser.CurrentOrgId,
  9222. CostTotal: medfee_sumamt,
  9223. FuncTotal: fund_pay_sumamt,
  9224. PsnPay: acct_pay,
  9225. Creator: admin_user_id,
  9226. Ctime: time.Now().Unix(),
  9227. ClrType: clr_type,
  9228. }
  9229. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  9230. if err == nil {
  9231. c.ServeSuccessJSON(map[string]interface{}{
  9232. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9233. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9234. })
  9235. } else {
  9236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9237. }
  9238. } else {
  9239. c.ServeSuccessJSON(map[string]interface{}{
  9240. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  9241. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  9242. })
  9243. }
  9244. } else {
  9245. c.ServeSuccessJSON(map[string]interface{}{
  9246. "code": -10,
  9247. "msg": res.ErrMsg,
  9248. })
  9249. }
  9250. }
  9251. }
  9252. func (c *HisApiController) Check310() {
  9253. adminUser := c.GetAdminUserInfo()
  9254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9255. var user_name string
  9256. user_name = "高慧裕"
  9257. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9258. "insutype=" + "310" +
  9259. "&clr_type=" + "" +
  9260. "&setl_optins=" + "441202" +
  9261. "&stmt_begndate=" + "2022-03-01" +
  9262. "&stm_enddate=" + "2022-03-31" +
  9263. "&medfee_sumamt=" + "194930.12" +
  9264. "&fund_pay_sumamt=" + "188741.46" +
  9265. "&acct_pay=" + "0" +
  9266. "&fixmedins_setl_cnt=" + "452" +
  9267. "&fixmedins_code=" + miConfig.Code +
  9268. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9269. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9270. "&secret_key=" + miConfig.SecretKey +
  9271. "&org_name=" + miConfig.OrgName +
  9272. "&doctor=" + user_name
  9273. fmt.Println(api)
  9274. resp, requestErr := http.Get(api)
  9275. if requestErr != nil {
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. body, ioErr := ioutil.ReadAll(resp.Body)
  9280. fmt.Println(body)
  9281. if ioErr != nil {
  9282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9284. return
  9285. }
  9286. var respJSON map[string]interface{}
  9287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9290. return
  9291. }
  9292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9293. userJSONBytes, _ := json.Marshal(respJSON)
  9294. var res ResultEight
  9295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9296. utils.ErrorLog("解析失败:%v", err)
  9297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9298. return
  9299. }
  9300. }
  9301. func (c *HisApiController) Check390() {
  9302. adminUser := c.GetAdminUserInfo()
  9303. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9304. var user_name string
  9305. user_name = "高慧裕"
  9306. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9307. "insutype=" + "390" +
  9308. "&clr_type=" + "" +
  9309. "&setl_optins=" + "441202" +
  9310. "&stmt_begndate=" + "2022-03-01" +
  9311. "&stm_enddate=" + "2022-03-31" +
  9312. "&medfee_sumamt=" + "1068448.89" +
  9313. "&fund_pay_sumamt=" + "1014677.62" +
  9314. "&acct_pay=" + "0" +
  9315. "&fixmedins_setl_cnt=" + "1950" +
  9316. "&fixmedins_code=" + miConfig.Code +
  9317. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9318. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9319. "&secret_key=" + miConfig.SecretKey +
  9320. "&org_name=" + miConfig.OrgName +
  9321. "&doctor=" + user_name
  9322. fmt.Println(api)
  9323. resp, requestErr := http.Get(api)
  9324. if requestErr != nil {
  9325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9326. return
  9327. }
  9328. body, ioErr := ioutil.ReadAll(resp.Body)
  9329. fmt.Println(body)
  9330. if ioErr != nil {
  9331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. return
  9334. }
  9335. var respJSON map[string]interface{}
  9336. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9342. userJSONBytes, _ := json.Marshal(respJSON)
  9343. var res ResultEight
  9344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9345. utils.ErrorLog("解析失败:%v", err)
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9347. return
  9348. }
  9349. }
  9350. //对账明细
  9351. func (c *HisApiController) GetCheckDetailAccount() {
  9352. start_time := c.GetString("start_time")
  9353. end_time := c.GetString("end_time")
  9354. admin_user_id, _ := c.GetInt64("admin_user_id")
  9355. adminUser := c.GetAdminUserInfo()
  9356. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9357. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9358. timeLayout := "2006-01-02"
  9359. loc, _ := time.LoadLocation("Local")
  9360. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9361. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9362. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9363. rand.Seed(time.Now().UnixNano())
  9364. num := rand.Intn(30000)
  9365. Mkdir(miConfig.OrgName)
  9366. file := strconv.FormatInt(int64(num), 10)
  9367. file_name := file + ".txt"
  9368. zip_name := file + ".zip"
  9369. zip_path := miConfig.OrgName + "/" + zip_name
  9370. file_path := miConfig.OrgName + "/" + file_name
  9371. decimal.DivisionPrecision = 2
  9372. var medfee_sumamt float64
  9373. var psn_cash_pay float64
  9374. var fund_pay_sumamt float64
  9375. fixmedins_setl_cnt := int64(len(orders))
  9376. for _, item := range orders {
  9377. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9378. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9379. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9380. }
  9381. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9382. defer f.Close()
  9383. if err != nil {
  9384. fmt.Println(err.Error())
  9385. } else {
  9386. for _, item := range orders {
  9387. var refd_setl_flag string
  9388. if item.OrderStatus == 2 {
  9389. refd_setl_flag = "0"
  9390. var str string
  9391. str = item.SetlId + " " +
  9392. item.MdtrtId + " " +
  9393. item.PsnNo + " " +
  9394. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9395. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9396. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9397. _, err = f.Write([]byte(str))
  9398. }
  9399. if item.OrderStatus == 3 {
  9400. var str string
  9401. str = item.SetlId + " " +
  9402. item.MdtrtId + " " +
  9403. item.PsnNo + " " +
  9404. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9405. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9406. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9407. _, err = f.Write([]byte(str))
  9408. var str2 string
  9409. str2 = item.SetlId + " " +
  9410. item.MdtrtId + " " +
  9411. item.PsnNo + " " +
  9412. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9413. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9414. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9415. _, err = f.Write([]byte(str2))
  9416. }
  9417. }
  9418. }
  9419. Zip(file_path, zip_path)
  9420. fmt.Println(ReadFile(zip_path))
  9421. fmt.Println(string(ReadFile(zip_path)))
  9422. if config.IsOpen == 1 {
  9423. var user_name string
  9424. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9425. if role.ID == 0 {
  9426. user_name = "管理员"
  9427. } else {
  9428. user_name = role.UserName
  9429. }
  9430. baseParams := models.BaseParams{
  9431. SecretKey: miConfig.SecretKey,
  9432. FixmedinsCode: miConfig.Code,
  9433. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9434. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9435. OrgName: miConfig.OrgName,
  9436. Doctor: user_name,
  9437. }
  9438. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9439. var dat map[string]interface{}
  9440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9441. fmt.Println(dat)
  9442. } else {
  9443. fmt.Println(err)
  9444. }
  9445. userJSONBytes, _ := json.Marshal(dat)
  9446. var res ResultNine
  9447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9448. utils.ErrorLog("解析失败:%v", err)
  9449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9450. return
  9451. }
  9452. if res.Infcode == 0 {
  9453. fileNo := res.Output.FileQuryNo
  9454. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9455. "file_qury_no=" + fileNo +
  9456. "&setl_optins=" + "定点医保中心" +
  9457. "&stmt_begndate=" + start_time +
  9458. "&stm_enddate=" + end_time +
  9459. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9460. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9461. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9462. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9463. "&fixmedins_code=" + miConfig.Code +
  9464. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9465. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9466. "&secret_key=" + miConfig.SecretKey +
  9467. "&org_name=" + miConfig.OrgName +
  9468. "&doctor=" + user_name
  9469. resp, requestErr := http.Get(api)
  9470. if requestErr != nil {
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. body, ioErr := ioutil.ReadAll(resp.Body)
  9475. if ioErr != nil {
  9476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. var respJSON map[string]interface{}
  9481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9487. userJSONBytes, _ := json.Marshal(respJSON)
  9488. var res ResultTen
  9489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9490. utils.ErrorLog("解析失败:%v", err)
  9491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9492. return
  9493. }
  9494. if res.Infcode == 0 {
  9495. service.Gdyb9102(baseParams, zip_name, fileNo)
  9496. micc := &models.MedicalInsuranceCostCompare{
  9497. StartTime: startime.Unix(),
  9498. EndTime: endtime.Unix(),
  9499. Insutype: "0",
  9500. CheckType: 2,
  9501. Num: fixmedins_setl_cnt,
  9502. Mtime: time.Now().Unix(),
  9503. Status: 1,
  9504. UserOrgId: adminUser.CurrentOrgId,
  9505. CostTotal: medfee_sumamt,
  9506. FuncTotal: fund_pay_sumamt,
  9507. PsnPay: psn_cash_pay,
  9508. Creator: admin_user_id,
  9509. Ctime: time.Now().Unix(),
  9510. }
  9511. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9512. c.ServeSuccessJSON(map[string]interface{}{
  9513. "msg": "明细对账成功",
  9514. })
  9515. }
  9516. } else {
  9517. }
  9518. }
  9519. }
  9520. type CustomOrderInfo struct {
  9521. Name string
  9522. Spec string
  9523. Unit string
  9524. Count float64
  9525. Price float64
  9526. Total float64
  9527. }
  9528. func (c *HisApiController) GetSettleAccounts() {
  9529. //id, _ := c.GetInt64("id")
  9530. //record_time := c.GetString("record_time")
  9531. order_id, _ := c.GetInt64("order_id")
  9532. admin_user_id, _ := c.GetInt64("admin_user_id")
  9533. //timeLayout := "2006-01-02"
  9534. //loc, _ := time.LoadLocation("Local")
  9535. //
  9536. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9537. //if err != nil {
  9538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9539. // return
  9540. //}
  9541. //recordDateTime := theTime.Unix()
  9542. adminUser := c.GetAdminUserInfo()
  9543. order, _ := service.GetHisOrderByID(order_id)
  9544. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9545. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9546. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9547. orderInfos = append(orderInfos, orderInfos_two...)
  9548. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9549. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9550. var diagnosis_ids []string
  9551. if his.ID > 0 {
  9552. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9553. } else {
  9554. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9555. }
  9556. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9557. var dia_config []*models.HisXtDiagnoseConfig
  9558. var name string
  9559. for _, item := range diagnosis_ids {
  9560. id, _ := strconv.ParseInt(item, 10, 64)
  9561. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9562. dia_config = append(dia_config, &diagnosisConfig)
  9563. if len(name) == 0 {
  9564. name = diagnosisConfig.ClassName
  9565. } else {
  9566. name = name + "," + diagnosisConfig.ClassName
  9567. }
  9568. }
  9569. var bedCostTotal float64 = 0 //床位总费
  9570. var bedCostSelfTotal float64 = 0 //床位自费
  9571. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9572. var operationCostTotal float64 = 0 //手术费
  9573. var operationCostSelfTotal float64 = 0 //手术费
  9574. var operationCostPartSelfTotal float64 = 0 //手术费
  9575. var otherCostTotal float64 = 0 //其他费用
  9576. var otherCostSelfTotal float64 = 0 //其他费用
  9577. var otherCostPartSelfTotal float64 = 0 //其他费用
  9578. var materialCostTotal float64 = 0 //材料费
  9579. var materialCostSelfTotal float64 = 0 //材料费
  9580. var materialCostPartSelfTotal float64 = 0 //材料费
  9581. var westernMedicineCostTotal float64 = 0 //西药费
  9582. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9583. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9584. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9585. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9586. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9587. var checkCostTotal float64 = 0 //检查费
  9588. var checkCostSelfTotal float64 = 0 //检查费
  9589. var checkCostPartSelfTotal float64 = 0 //检查费
  9590. var laboratoryCostTotal float64 = 0 //化验费
  9591. var laboratoryCostSelfTotal float64 = 0 //化验费
  9592. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9593. var treatCostTotal float64 = 0 //治疗费用
  9594. var treatCostSelfTotal float64 = 0 //治疗费用
  9595. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9596. decimal.DivisionPrecision = 2
  9597. for _, item := range orderInfos {
  9598. if item.MedChrgitmType == "01" { //床位费
  9599. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9600. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9601. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9602. }
  9603. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9604. if item.MedChrgitmType == "03" { //检查费
  9605. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9606. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9607. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9608. }
  9609. } else {
  9610. if item.MedChrgitmType == "03" { //检查费
  9611. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9612. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9613. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9614. }
  9615. }
  9616. if item.MedChrgitmType == "04" { //化验费
  9617. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9618. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9619. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9620. }
  9621. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9622. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9623. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9624. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9625. }
  9626. if item.MedChrgitmType == "06" { //手术费
  9627. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9628. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9629. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9630. }
  9631. if item.MedChrgitmType == "08" { //材料费
  9632. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9633. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9634. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9635. }
  9636. if item.MedChrgitmType == "09" { //西药费
  9637. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9638. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9639. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9640. }
  9641. if item.MedChrgitmType == "11" { //中成费
  9642. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9643. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9644. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9645. }
  9646. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9647. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9648. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9649. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9650. }
  9651. }
  9652. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9653. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9654. var user_name string
  9655. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9656. if role.ID == 0 {
  9657. user_name = "管理员"
  9658. } else {
  9659. user_name = role.UserName
  9660. }
  9661. baseParams := models.BaseParams{
  9662. SecretKey: miConfig.SecretKey,
  9663. FixmedinsCode: miConfig.Code,
  9664. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9665. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9666. OrgName: miConfig.OrgName,
  9667. Doctor: user_name,
  9668. }
  9669. businessParams := models.BusinessParams{
  9670. PsnNo: order.PsnNo,
  9671. MdtrtId: order.MdtrtId,
  9672. SetlId: order.SetlId,
  9673. }
  9674. var res ResultEleven
  9675. var resEleven10265 ResultEleven10265
  9676. if config.IsOpen == 1 {
  9677. if miConfig.MdtrtareaAdmvs == "421300" {
  9678. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9679. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9680. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9681. resp, requestErr := http.Get(api)
  9682. if requestErr != nil {
  9683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9684. return
  9685. }
  9686. body, ioErr := ioutil.ReadAll(resp.Body)
  9687. if ioErr != nil {
  9688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9690. return
  9691. }
  9692. var respJSON map[string]interface{}
  9693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9696. return
  9697. }
  9698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9699. result, _ := json.Marshal(respJSON)
  9700. fmt.Println("log")
  9701. fmt.Println(string(result))
  9702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9703. utils.ErrorLog("解析失败:%v", err)
  9704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9705. return
  9706. }
  9707. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9708. var api string
  9709. if miConfig.MdtrtareaAdmvs == "320921" {
  9710. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9711. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9713. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9714. } else {
  9715. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9716. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9717. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9719. }
  9720. resp, requestErr := http.Get(api)
  9721. if requestErr != nil {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9723. return
  9724. }
  9725. body, ioErr := ioutil.ReadAll(resp.Body)
  9726. if ioErr != nil {
  9727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9729. return
  9730. }
  9731. var respJSON map[string]interface{}
  9732. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9735. return
  9736. }
  9737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9738. result, _ := json.Marshal(respJSON)
  9739. fmt.Println("log")
  9740. fmt.Println(string(result))
  9741. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9742. utils.ErrorLog("解析失败:%v", err)
  9743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9744. return
  9745. }
  9746. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9747. res.Output = resEleven10265.Output
  9748. res.ErrMsg = resEleven10265.ErrMsg
  9749. res.Cainfo = resEleven10265.Cainfo
  9750. res.WarnMsg = resEleven10265.WarnMsg
  9751. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9752. res.Infcode = infocode
  9753. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9754. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9755. saveLog(result, requestLog, "5203", "结算单")
  9756. var dat map[string]interface{}
  9757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9758. fmt.Println(dat)
  9759. } else {
  9760. fmt.Println(err)
  9761. }
  9762. userJSONBytes, _ := json.Marshal(dat)
  9763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9764. utils.ErrorLog("解析失败:%v", err)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return
  9767. }
  9768. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9769. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9770. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9771. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9772. resp, requestErr := http.Get(api)
  9773. if requestErr != nil {
  9774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9775. return
  9776. }
  9777. body, ioErr := ioutil.ReadAll(resp.Body)
  9778. if ioErr != nil {
  9779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9781. return
  9782. }
  9783. var respJSON map[string]interface{}
  9784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9787. return
  9788. }
  9789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9790. result, _ := json.Marshal(respJSON)
  9791. fmt.Println("log")
  9792. fmt.Println(string(result))
  9793. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9794. utils.ErrorLog("解析失败:%v", err)
  9795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9796. return
  9797. }
  9798. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9799. res.Output = resEleven10265.Output
  9800. res.ErrMsg = resEleven10265.ErrMsg
  9801. res.Cainfo = resEleven10265.Cainfo
  9802. res.WarnMsg = resEleven10265.WarnMsg
  9803. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9804. res.Infcode = infocode
  9805. } else {
  9806. result := service.Gdyb5203(baseParams, businessParams)
  9807. //service.Gdyb5204(baseParams, businessParams)
  9808. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9809. var dat map[string]interface{}
  9810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9811. fmt.Println(dat)
  9812. } else {
  9813. fmt.Println(err)
  9814. }
  9815. userJSONBytes, _ := json.Marshal(dat)
  9816. if miConfig.Code == "H15049901371" {
  9817. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9818. utils.ErrorLog("解析失败:%v", err)
  9819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. return
  9821. }
  9822. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9823. res.Output = resEleven10265.Output
  9824. res.ErrMsg = resEleven10265.ErrMsg
  9825. res.Cainfo = resEleven10265.Cainfo
  9826. res.WarnMsg = resEleven10265.WarnMsg
  9827. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9828. res.Infcode = infocode
  9829. } else {
  9830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9831. utils.ErrorLog("解析失败:%v", err)
  9832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9833. return
  9834. }
  9835. }
  9836. }
  9837. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9838. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9839. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9840. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9841. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9842. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9843. var doctor_name string
  9844. if roles.ID == 0 {
  9845. doctor_name = "管理员"
  9846. } else {
  9847. doctor_name = roles.UserName
  9848. }
  9849. yiliao_leibie := ""
  9850. switch order.MedType {
  9851. case "11":
  9852. yiliao_leibie = "普通门诊"
  9853. break
  9854. case "12":
  9855. yiliao_leibie = "门诊挂号"
  9856. break
  9857. case "13":
  9858. yiliao_leibie = "急诊"
  9859. break
  9860. case "14":
  9861. yiliao_leibie = "门诊特殊病"
  9862. break
  9863. case "15":
  9864. yiliao_leibie = "门诊统筹"
  9865. break
  9866. case "16":
  9867. yiliao_leibie = "门诊慢性病"
  9868. break
  9869. case "21":
  9870. yiliao_leibie = "普通住院"
  9871. break
  9872. }
  9873. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9874. if res.Infcode == 0 {
  9875. c.ServeSuccessJSON(map[string]interface{}{
  9876. "diagnosis": name,
  9877. "order_infos": orderInfos,
  9878. "number": order.MdtrtId,
  9879. "date": order.SettleAccountsDate,
  9880. "charge_admin": charge_admin,
  9881. "printor_admin": printor_admin,
  9882. "info": res.Output.Setlinfo,
  9883. "order": order,
  9884. "bedCostTotal": bedCostTotal,
  9885. "bedCostSelfTotal": bedCostSelfTotal,
  9886. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9887. "operationCostTotal": operationCostTotal,
  9888. "operationCostSelfTotal": operationCostSelfTotal,
  9889. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9890. "otherCostTotal": otherCostTotal,
  9891. "otherCostSelfTotal": otherCostSelfTotal,
  9892. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9893. "materialCostTotal": materialCostTotal,
  9894. "materialCostSelfTotal": materialCostSelfTotal,
  9895. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9896. "westernMedicineCostTotal": westernMedicineCostTotal,
  9897. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9898. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9899. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9900. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9901. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9902. "checkCostTotal": checkCostTotal,
  9903. "checkCostSelfTotal": checkCostSelfTotal,
  9904. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9905. "laboratoryCostTotal": laboratoryCostTotal,
  9906. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9907. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9908. "treatCostTotal": treatCostTotal,
  9909. "treatCostSelfTotal": treatCostSelfTotal,
  9910. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9911. "doctor_info": doctor_info,
  9912. "doctor_code": adminRole_two.DoctorCode,
  9913. "doctor_name": doctor_name,
  9914. "health_card_no": order.PsnNo,
  9915. "department": departments.Name,
  9916. "yiliao_leibie": yiliao_leibie,
  9917. "after_money": order.AccountPrice,
  9918. "patient": patient,
  9919. "org_name": miConfig.OrgName,
  9920. "org_code": miConfig.Code,
  9921. "order_number": order.Number,
  9922. "his_hospital": his_hospital,
  9923. "his": his,
  9924. "dia_config": dia_config,
  9925. //"check_order_info": cus_slice,
  9926. })
  9927. }
  9928. }
  9929. }
  9930. func (c *HisApiController) CheckTreatment() {
  9931. patient_id, _ := c.GetInt64("patient_id")
  9932. id_card_no := c.GetString("id_card_no")
  9933. insutype := c.GetString("insutype")
  9934. med_type := c.GetString("med_type")
  9935. admin_user_id, _ := c.GetInt64("admin_user_id")
  9936. adminUser := c.GetAdminUserInfo()
  9937. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9938. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9939. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9940. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9941. if miConfig.MdtrtareaAdmvs == "421300" {
  9942. var res ResultTwo
  9943. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9944. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9945. "&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)
  9946. resp, requestErr := http.Get(api)
  9947. if requestErr != nil {
  9948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9949. return
  9950. }
  9951. body, ioErr := ioutil.ReadAll(resp.Body)
  9952. if ioErr != nil {
  9953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9955. return
  9956. }
  9957. var respJSON map[string]interface{}
  9958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9961. return
  9962. }
  9963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9964. result, _ := json.Marshal(respJSON)
  9965. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9966. utils.ErrorLog("解析失败:%v", err)
  9967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9968. return
  9969. }
  9970. if res.Infcode == 0 {
  9971. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9972. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9973. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9974. resp, requestErr := http.Get(api)
  9975. if requestErr != nil {
  9976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9977. return
  9978. }
  9979. body, ioErr := ioutil.ReadAll(resp.Body)
  9980. if ioErr != nil {
  9981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. var respJSON map[string]interface{}
  9986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9989. return
  9990. }
  9991. var res Result2001
  9992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9993. result2, _ := json.Marshal(respJSON)
  9994. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9995. utils.ErrorLog("解析失败:%v", err)
  9996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9997. return
  9998. }
  9999. if res.Infcode == 0 {
  10000. c.ServeSuccessJSON(map[string]interface{}{
  10001. "msg": res.Output.Trtinfo,
  10002. })
  10003. }
  10004. } else {
  10005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10006. return
  10007. }
  10008. } else {
  10009. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10010. var dat map[string]interface{}
  10011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10012. fmt.Println(dat)
  10013. } else {
  10014. fmt.Println(err)
  10015. }
  10016. userJSONBytes, _ := json.Marshal(dat)
  10017. var res ResultTwo
  10018. var res10265 ResultTwo10265
  10019. if miConfig.Code == "H15049901371" {
  10020. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10021. utils.ErrorLog("解析失败:%v", err)
  10022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10023. return
  10024. }
  10025. res.ErrMsg = res10265.ErrMsg
  10026. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10027. res.Infcode = infocode
  10028. res.Output = res10265.Output
  10029. res.InfRefmsgid = res10265.InfRefmsgid
  10030. } else {
  10031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10032. utils.ErrorLog("解析失败:%v", err)
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10034. return
  10035. }
  10036. }
  10037. var user_name string
  10038. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  10039. if role.ID == 0 {
  10040. user_name = "xxx"
  10041. } else {
  10042. user_name = role.UserName
  10043. }
  10044. baseParams := models.BaseParams{
  10045. SecretKey: miConfig.SecretKey,
  10046. FixmedinsCode: miConfig.Code,
  10047. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10048. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10049. OrgName: miConfig.OrgName,
  10050. Doctor: user_name,
  10051. }
  10052. if config.IsOpen == 1 {
  10053. if miConfig.Code == "H15049901371" {
  10054. if med_type == "14" {
  10055. if insutype == "390" {
  10056. med_type = "9933"
  10057. } else if insutype == "310" {
  10058. med_type = "990502"
  10059. }
  10060. } else if med_type == "11" {
  10061. med_type = "11"
  10062. }
  10063. }
  10064. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  10065. var dat map[string]interface{}
  10066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10067. fmt.Println(dat)
  10068. } else {
  10069. fmt.Println(err)
  10070. }
  10071. var res Result2001
  10072. var res10265 Result2001Org10265
  10073. if miConfig.Code == "H15049901371" {
  10074. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10075. utils.ErrorLog("解析失败:%v", err)
  10076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10077. return
  10078. }
  10079. res.ErrMsg = res10265.ErrMsg
  10080. res.Output = res10265.Output
  10081. res.InfRefmsgid = res10265.InfRefmsgid
  10082. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10083. res.Infcode = infocode
  10084. } else {
  10085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10086. utils.ErrorLog("解析失败:%v", err)
  10087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10088. return
  10089. }
  10090. }
  10091. if res.Infcode == 0 {
  10092. c.ServeSuccessJSON(map[string]interface{}{
  10093. "msg": res.Output.Trtinfo,
  10094. })
  10095. }
  10096. }
  10097. }
  10098. }
  10099. //func (c *HisApiController) PutRecord() {
  10100. // id, _ := c.GetInt64("id")
  10101. // record_time := c.GetString("record_time")
  10102. // timeLayout := "2006-01-02"
  10103. // loc, _ := time.LoadLocation("Local")
  10104. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10105. // if err != nil {
  10106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10107. // return
  10108. // }
  10109. // recordDateTime := theTime.Unix()
  10110. //
  10111. // adminInfo := c.GetAdminUserInfo()
  10112. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  10113. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10114. //
  10115. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10116. //
  10117. // fmt.Println(miConfig.SecretKey)
  10118. //
  10119. // if patient == nil {
  10120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10121. // return
  10122. // }
  10123. // if len(patient.IdCardNo) == 0 {
  10124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10125. // return
  10126. // }
  10127. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10128. // if config.IsOpen == 1 {
  10129. // 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
  10130. // resp, requestErr := http.Get(api)
  10131. // if requestErr != nil {
  10132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. // return
  10134. // }
  10135. // defer resp.Body.Close()
  10136. // body, ioErr := ioutil.ReadAll(resp.Body)
  10137. // if ioErr != nil {
  10138. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10140. // return
  10141. // }
  10142. // var respJSON map[string]interface{}
  10143. //
  10144. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10145. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10147. // return
  10148. // }
  10149. //
  10150. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10151. // userJSONBytes, _ := json.Marshal(userJSON)
  10152. // var res ResultTwo
  10153. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10154. // utils.ErrorLog("解析失败:%v", err)
  10155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. // return
  10157. // }
  10158. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10159. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10160. // infoStr := string(Iinfos)
  10161. // idetinfoStr := string(Idetinfos)
  10162. //
  10163. // if res.Infcode == 0 {
  10164. // his := models.VMHisPatient{
  10165. // Status: 1,
  10166. // Ctime: time.Now().Unix(),
  10167. // Mtime: time.Now().Unix(),
  10168. // PsnNo: res.Output.Baseinfo.PsnNo,
  10169. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10170. // Certno: res.Output.Baseinfo.Certno,
  10171. // PsnName: res.Output.Baseinfo.PsnName,
  10172. // Gend: res.Output.Baseinfo.Gend,
  10173. // Naty: res.Output.Baseinfo.Naty,
  10174. // Brdy: res.Output.Baseinfo.Brdy,
  10175. // Age: res.Output.Baseinfo.Age,
  10176. // Iinfo: infoStr,
  10177. // Idetinfo: idetinfoStr,
  10178. // PatientId: patient.ID,
  10179. // RecordDate: theTime.Unix(),
  10180. // UserOrgId: adminInfo.CurrentOrgId,
  10181. // AdminUserId: adminInfo.AdminUser.Id,
  10182. // IsReturn: 1,
  10183. // }
  10184. //
  10185. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  10186. // //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")
  10187. // //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")
  10188. //
  10189. // //var dat map[string]interface{}
  10190. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10191. // // fmt.Println(dat)
  10192. // //} else {
  10193. // // fmt.Println(err)
  10194. // //}
  10195. //
  10196. // var dat2 map[string]interface{}
  10197. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10198. // fmt.Println(dat2)
  10199. // } else {
  10200. // fmt.Println(err)
  10201. // }
  10202. //
  10203. // } else {
  10204. // adminUser := c.GetAdminUserInfo()
  10205. // errlog := &models.HisOrderError{
  10206. // UserOrgId: adminUser.CurrentOrgId,
  10207. // Ctime: time.Now().Unix(),
  10208. // Mtime: time.Now().Unix(),
  10209. // ErrMsg: res.ErrMsg,
  10210. // Status: 1,
  10211. // PatientId: id,
  10212. // RecordTime: recordDateTime,
  10213. // Stage: 1,
  10214. // }
  10215. // service.CreateErrMsgLog(errlog)
  10216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  10217. // return
  10218. // }
  10219. // }
  10220. //
  10221. //}
  10222. //func (c *HisApiController) GetUploadDiag() {
  10223. // id, _ := c.GetInt64("id")
  10224. // record_time := c.GetString("record_time")
  10225. //
  10226. // diagnosis_id, _ := c.GetInt64("diagnosis")
  10227. // sick_type, _ := c.GetInt64("sick_type")
  10228. // reg_type, _ := c.GetInt64("reg_type")
  10229. //
  10230. // timeLayout := "2006-01-02"
  10231. // loc, _ := time.LoadLocation("Local")
  10232. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10233. // if err != nil {
  10234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10235. // return
  10236. // }
  10237. //
  10238. // var patientPrescription models.HisPrescriptionInfo
  10239. // recordDateTime := theTime.Unix()
  10240. // adminInfo := c.GetAdminUserInfo()
  10241. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10242. //
  10243. // if patientPrescription.ID == 0 {
  10244. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10245. // }
  10246. //
  10247. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10248. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  10249. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10250. // sickConfig, _ := service.FindSickById(sick_type)
  10251. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10252. //
  10253. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  10254. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  10255. // "&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 +
  10256. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  10257. // resp2, requestErr2 := http.Get(api2)
  10258. // if requestErr2 != nil {
  10259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. // return
  10261. // }
  10262. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  10263. // if ioErr2 != nil {
  10264. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10266. // return
  10267. // }
  10268. // var respJSON2 map[string]interface{}
  10269. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10270. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10272. // return
  10273. // }
  10274. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10275. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10276. //
  10277. // var res2 ResultSix
  10278. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10279. // utils.ErrorLog("解析失败:%v", err)
  10280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10281. // return
  10282. // }
  10283. // if res2.Infcode != 0 {
  10284. // adminUser := c.GetAdminUserInfo()
  10285. // errlog := &models.HisOrderError{
  10286. // UserOrgId: adminUser.CurrentOrgId,
  10287. // Ctime: time.Now().Unix(),
  10288. // Mtime: time.Now().Unix(),
  10289. // ErrMsg: res2.ErrMsg,
  10290. // Status: 1,
  10291. // PatientId: id,
  10292. // RecordTime: recordDateTime,
  10293. // Stage: 3,
  10294. // }
  10295. // service.CreateErrMsgLog(errlog)
  10296. //
  10297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10298. // return
  10299. // }
  10300. //
  10301. // c.ServeSuccessJSON(map[string]interface{}{
  10302. // "msg": "上传成功",
  10303. // })
  10304. //
  10305. //}
  10306. type QueryResult struct {
  10307. ID int64
  10308. Name string
  10309. Code string
  10310. List_type_code string
  10311. }
  10312. func (c *HisApiController) GetCheckCode() {
  10313. ids_str := c.GetString("ids")
  10314. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10315. ids_arr := strings.Split(ids_str, ",")
  10316. var queryResult []QueryResult
  10317. ids := make([]int64, 0)
  10318. for _, item := range ids_arr {
  10319. id, _ := strconv.ParseInt(item, 10, 64)
  10320. ids = append(ids, id)
  10321. }
  10322. if record_type == 1 {
  10323. drugs, _ := service.GetBatchDrugList(ids)
  10324. for _, item := range drugs {
  10325. result := QueryResult{
  10326. ID: item.ID,
  10327. Name: item.DrugName,
  10328. Code: item.MedicalInsuranceNumber,
  10329. List_type_code: "101",
  10330. }
  10331. queryResult = append(queryResult, result)
  10332. }
  10333. } else if record_type == 2 {
  10334. goods, _ := service.GetBatchGoodInformationList(ids)
  10335. for _, item := range goods {
  10336. result := QueryResult{
  10337. ID: item.ID,
  10338. Name: item.GoodName,
  10339. Code: item.MedicalInsuranceNumber,
  10340. List_type_code: "301",
  10341. }
  10342. queryResult = append(queryResult, result)
  10343. }
  10344. } else if record_type == 3 {
  10345. projects, _ := service.GetBathchMyPorjecgList(ids)
  10346. for _, item := range projects {
  10347. result := QueryResult{
  10348. ID: item.ID,
  10349. Name: item.ProjectName,
  10350. Code: item.MedicalCode,
  10351. List_type_code: "201",
  10352. }
  10353. queryResult = append(queryResult, result)
  10354. }
  10355. }
  10356. admin_user_id, _ := c.GetInt64("admin_user_id")
  10357. adminUser := c.GetAdminUserInfo()
  10358. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10359. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10360. var user_name string
  10361. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10362. if role.ID == 0 {
  10363. user_name = "xxx"
  10364. } else {
  10365. user_name = role.UserName
  10366. }
  10367. baseParams := &models.BaseParams{
  10368. SecretKey: miConfig.SecretKey,
  10369. FixmedinsCode: miConfig.Code,
  10370. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10371. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10372. OrgName: miConfig.OrgName,
  10373. Doctor: user_name,
  10374. }
  10375. if config.IsOpen == 1 {
  10376. for _, item := range queryResult {
  10377. var result string
  10378. if record_type == 1 {
  10379. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10380. } else if record_type == 2 {
  10381. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10382. } else if record_type == 3 {
  10383. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10384. }
  10385. var dat map[string]interface{}
  10386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10387. fmt.Println(dat)
  10388. } else {
  10389. fmt.Println(err)
  10390. }
  10391. userJSONBytes, _ := json.Marshal(dat)
  10392. var res ResultSix
  10393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10394. utils.ErrorLog("解析失败:%v", err)
  10395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10396. return
  10397. }
  10398. if res.Infcode == 0 {
  10399. if record_type == 1 {
  10400. service.UpdateBaseDrugById(item.ID)
  10401. } else if record_type == 2 {
  10402. service.UpdateGoodInformaitonByDetail(item.ID)
  10403. } else if record_type == 3 {
  10404. service.UpdateProjectById(item.ID)
  10405. }
  10406. c.ServeSuccessJSON(map[string]interface{}{
  10407. "failed_code": 0,
  10408. "msg": "目录对照成功",
  10409. })
  10410. } else {
  10411. c.ServeSuccessJSON(map[string]interface{}{
  10412. "failed_code": -10,
  10413. "msg": res.ErrMsg,
  10414. })
  10415. }
  10416. }
  10417. }
  10418. }
  10419. func (c *HisApiController) UnCheckCode() {
  10420. ids_str := c.GetString("ids")
  10421. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10422. admin_user_id, _ := c.GetInt64("admin_user_id")
  10423. ids_arr := strings.Split(ids_str, ",")
  10424. var queryResult []QueryResult
  10425. ids := make([]int64, 0)
  10426. for _, item := range ids_arr {
  10427. id, _ := strconv.ParseInt(item, 10, 64)
  10428. ids = append(ids, id)
  10429. }
  10430. if record_type == 1 {
  10431. drugs, _ := service.GetBatchDrugList(ids)
  10432. for _, item := range drugs {
  10433. result := QueryResult{
  10434. ID: item.ID,
  10435. Name: item.DrugName,
  10436. Code: item.MedicalInsuranceNumber,
  10437. List_type_code: "101",
  10438. }
  10439. queryResult = append(queryResult, result)
  10440. }
  10441. } else if record_type == 2 {
  10442. goods, _ := service.GetBatchGoodInformationList(ids)
  10443. for _, item := range goods {
  10444. result := QueryResult{
  10445. ID: item.ID,
  10446. Name: item.GoodName,
  10447. Code: item.MedicalInsuranceNumber,
  10448. List_type_code: "301",
  10449. }
  10450. queryResult = append(queryResult, result)
  10451. }
  10452. } else if record_type == 3 {
  10453. projects, _ := service.GetBathchMyPorjecgList(ids)
  10454. for _, item := range projects {
  10455. result := QueryResult{
  10456. ID: item.ID,
  10457. Name: item.ProjectName,
  10458. Code: item.MedicalCode,
  10459. List_type_code: "201",
  10460. }
  10461. queryResult = append(queryResult, result)
  10462. }
  10463. }
  10464. adminUser := c.GetAdminUserInfo()
  10465. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10466. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10467. var user_name string
  10468. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10469. if role.ID == 0 {
  10470. user_name = "xxx"
  10471. } else {
  10472. user_name = role.UserName
  10473. }
  10474. baseParams := &models.BaseParams{
  10475. SecretKey: miConfig.SecretKey,
  10476. FixmedinsCode: miConfig.Code,
  10477. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10478. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10479. OrgName: miConfig.OrgName,
  10480. Doctor: user_name,
  10481. }
  10482. if config.IsOpen == 1 {
  10483. for _, item := range queryResult {
  10484. var result string
  10485. if record_type == 1 {
  10486. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10487. } else if record_type == 2 {
  10488. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10489. } else if record_type == 3 {
  10490. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10491. }
  10492. var dat2 map[string]interface{}
  10493. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10494. fmt.Println(dat2)
  10495. } else {
  10496. fmt.Println(err)
  10497. }
  10498. userJSONBytes, _ := json.Marshal(dat2)
  10499. var res ResultSix
  10500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10501. utils.ErrorLog("解析失败:%v", err)
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10503. return
  10504. }
  10505. if res.Infcode == 0 {
  10506. if record_type == 1 {
  10507. service.UpdateDrugByIdDetail(item.ID)
  10508. } else if record_type == 2 {
  10509. service.UpdateGoodInfoById(item.ID)
  10510. } else if record_type == 3 {
  10511. service.UpdateMyProjectById(item.ID)
  10512. }
  10513. c.ServeSuccessJSON(map[string]interface{}{
  10514. "failed_code": 0,
  10515. "msg": "撤销目录对照成功",
  10516. })
  10517. } else {
  10518. c.ServeSuccessJSON(map[string]interface{}{
  10519. "failed_code": -10,
  10520. "msg": res.ErrMsg,
  10521. })
  10522. }
  10523. }
  10524. }
  10525. }
  10526. func (c *HisApiController) GetPatientInfo() {
  10527. id_card_no := c.GetString("id_card_no")
  10528. admin_user_id, _ := c.GetInt64("admin_user_id")
  10529. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10530. if patient.ID == 0 {
  10531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10532. return
  10533. }
  10534. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10535. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10536. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10537. if config.IsOpen == 1 {
  10538. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10539. var dat map[string]interface{}
  10540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10541. fmt.Println(dat)
  10542. } else {
  10543. fmt.Println(err)
  10544. }
  10545. userJSONBytes, _ := json.Marshal(dat)
  10546. var res ResultTwo
  10547. var res10265 ResultTwo10265
  10548. if miConfig.Code == "H15049901371" {
  10549. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10550. utils.ErrorLog("解析失败:%v", err)
  10551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10552. return
  10553. }
  10554. res.ErrMsg = res10265.ErrMsg
  10555. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10556. res.Infcode = infocode
  10557. res.Output = res10265.Output
  10558. res.InfRefmsgid = res10265.InfRefmsgid
  10559. } else {
  10560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10561. utils.ErrorLog("解析失败:%v", err)
  10562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10563. return
  10564. }
  10565. }
  10566. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10567. // utils.ErrorLog("解析失败:%v", err)
  10568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10569. // return
  10570. //}
  10571. if res.Infcode != 0 {
  10572. c.ServeSuccessJSON(map[string]interface{}{
  10573. "failed_code": -10,
  10574. "msg": res.ErrMsg,
  10575. })
  10576. } else {
  10577. c.ServeSuccessJSON(map[string]interface{}{
  10578. "failed_code": 0,
  10579. "info": res,
  10580. })
  10581. }
  10582. }
  10583. }
  10584. func (c *HisApiController) PsnPutOnRecord() {
  10585. record_type, _ := c.GetInt64("type")
  10586. patient_id, _ := c.GetInt64("patient_id")
  10587. admin_user_id, _ := c.GetInt64("admin_user_id")
  10588. start_time := c.GetString("start_time")
  10589. end_time := c.GetString("end_time")
  10590. adminUser := c.GetAdminUserInfo()
  10591. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10592. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10593. var patients []*models.Patients
  10594. if record_type == 1 { //全部备案
  10595. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10596. patients = append(patients, patient...)
  10597. } else { //单个备案
  10598. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10599. patients = append(patients, patient)
  10600. }
  10601. var user_name string
  10602. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10603. if role.ID == 0 {
  10604. user_name = "xxx"
  10605. } else {
  10606. user_name = role.UserName
  10607. }
  10608. if config.IsOpen == 1 {
  10609. for _, item := range patients {
  10610. 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
  10611. resp, requestErr := http.Get(api)
  10612. if requestErr != nil {
  10613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10614. return
  10615. }
  10616. defer resp.Body.Close()
  10617. body, ioErr := ioutil.ReadAll(resp.Body)
  10618. if ioErr != nil {
  10619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10621. return
  10622. }
  10623. var respJSON map[string]interface{}
  10624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10627. return
  10628. }
  10629. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10630. userJSONBytes, _ := json.Marshal(userJSON)
  10631. var res ResultTwo
  10632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10633. utils.ErrorLog("解析失败:%v", err)
  10634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10635. return
  10636. }
  10637. if res.Infcode == 0 {
  10638. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10639. var dat map[string]interface{}
  10640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10641. fmt.Println(dat)
  10642. } else {
  10643. fmt.Println(err)
  10644. }
  10645. userJSONBytes, _ := json.Marshal(dat)
  10646. var res2 ResultThirteen
  10647. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10648. utils.ErrorLog("解析失败:%v", err)
  10649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10650. return
  10651. }
  10652. if res2.Infcode == 0 {
  10653. psnResult := &models.GdybPsnRecord{
  10654. UserOrgId: adminUser.CurrentOrgId,
  10655. PatientId: item.ID,
  10656. PsnNo: res.Output.Baseinfo.PsnNo,
  10657. Ctime: time.Now().Unix(),
  10658. Mtime: time.Now().Unix(),
  10659. Status: 1,
  10660. IsCancel: 1,
  10661. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10662. }
  10663. service.CreatePsnRecord(psnResult)
  10664. } else {
  10665. c.ServeSuccessJSON(map[string]interface{}{
  10666. "failed_code": -10,
  10667. "msg": res2.ErrMsg,
  10668. })
  10669. return
  10670. }
  10671. }
  10672. }
  10673. }
  10674. }
  10675. func (c *HisApiController) PsnUnPutOnRecord() {
  10676. id, _ := c.GetInt64("id")
  10677. //record_type, _ := c.GetInt64("type")
  10678. admin_user_id, _ := c.GetInt64("admin_user_id")
  10679. adminUser := c.GetAdminUserInfo()
  10680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10681. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10682. var user_name string
  10683. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10684. if role.ID == 0 {
  10685. user_name = "xxx"
  10686. } else {
  10687. user_name = role.UserName
  10688. }
  10689. psn_record, _ := service.GetPsnRecordById(id)
  10690. if psn_record.ID == 0 {
  10691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10692. return
  10693. }
  10694. if config.IsOpen == 1 {
  10695. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10696. var dat map[string]interface{}
  10697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10698. fmt.Println(dat)
  10699. } else {
  10700. fmt.Println(err)
  10701. }
  10702. userJSONBytes, _ := json.Marshal(dat)
  10703. var res ResultFourteen
  10704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10705. utils.ErrorLog("解析失败:%v", err)
  10706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10707. return
  10708. }
  10709. if res.Infcode == 0 {
  10710. psn_record.IsCancel = 2
  10711. service.CreatePsnRecord(&psn_record)
  10712. } else {
  10713. c.ServeSuccessJSON(map[string]interface{}{
  10714. "failed_code": -10,
  10715. "msg": res.ErrMsg,
  10716. })
  10717. return
  10718. }
  10719. }
  10720. }
  10721. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10722. patient_id, _ := c.GetInt64("patient_id")
  10723. insutype_two := c.GetString("insutype")
  10724. psn_no := c.GetString("psn_no")
  10725. doctor_id, _ := c.GetInt64("doctor_id")
  10726. sick_id, _ := c.GetInt64("sick_id")
  10727. department_id, _ := c.GetInt64("department_id")
  10728. start_time := c.GetString("start_time")
  10729. end_time := c.GetString("end_time")
  10730. check_time := c.GetString("check_time")
  10731. adminUser := c.GetAdminUserInfo()
  10732. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10734. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10735. sick, _ := service.FindSickById(sick_id)
  10736. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10737. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10738. var res ResultTwo
  10739. var res10265 ResultTwo10265
  10740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10741. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10742. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10743. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10744. "&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
  10745. resp, requestErr := http.Get(api)
  10746. if requestErr != nil {
  10747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10748. return
  10749. }
  10750. body, ioErr := ioutil.ReadAll(resp.Body)
  10751. if ioErr != nil {
  10752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10754. return
  10755. }
  10756. var respJSON map[string]interface{}
  10757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10760. return
  10761. }
  10762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10763. result, _ := json.Marshal(respJSON)
  10764. fmt.Println("log")
  10765. fmt.Println(string(result))
  10766. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10767. utils.ErrorLog("解析失败:%v", err)
  10768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10769. return
  10770. }
  10771. res.ErrMsg = res10265.ErrMsg
  10772. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10773. res.Infcode = infocode
  10774. res.Output = res10265.Output
  10775. res.InfRefmsgid = res10265.InfRefmsgid
  10776. } else {
  10777. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10778. if miConfig.Code == "H15049901371" {
  10779. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10780. utils.ErrorLog("解析失败:%v", err)
  10781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10782. return
  10783. }
  10784. res.ErrMsg = res10265.ErrMsg
  10785. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10786. res.Infcode = infocode
  10787. res.Output = res10265.Output
  10788. res.InfRefmsgid = res10265.InfRefmsgid
  10789. } else {
  10790. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10791. utils.ErrorLog("解析失败:%v", err)
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10793. return
  10794. }
  10795. }
  10796. }
  10797. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10798. infoStr := string(Iinfos)
  10799. var rf []*ResultFive
  10800. json.Unmarshal([]byte(infoStr), &rf)
  10801. var insuplc_admdvs string
  10802. var insutype string
  10803. var is390 int = 0
  10804. var is310 int = 0
  10805. var insutypes []*ResultFive
  10806. for _, item := range rf {
  10807. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10808. insutypes = append(insutypes, item)
  10809. }
  10810. }
  10811. if len(insutypes) == 1 {
  10812. insutype = insutypes[0].Insutype
  10813. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10814. } else {
  10815. for _, i := range insutypes {
  10816. if i.Insutype == "390" {
  10817. is390 = 1
  10818. }
  10819. if i.Insutype == "310" {
  10820. is310 = 1
  10821. }
  10822. }
  10823. }
  10824. if is390 == 1 {
  10825. insutype = "390"
  10826. }
  10827. if is310 == 1 {
  10828. insutype = "310"
  10829. }
  10830. if len(insutypes) == 2 {
  10831. insutype = insutype_two
  10832. }
  10833. if len(insutypes) == 0 {
  10834. insutype = "310"
  10835. }
  10836. insutype = insutype_two
  10837. fmt.Println(insutype)
  10838. for _, item := range rf {
  10839. fmt.Println(item.Insutype)
  10840. fmt.Println(insutype)
  10841. if item.Insutype == insutype {
  10842. fmt.Println(item.Insutype)
  10843. fmt.Println(insutype)
  10844. insuplc_admdvs = item.InsuplcAdmdvs
  10845. }
  10846. }
  10847. fmt.Println(insuplc_admdvs)
  10848. var res2 ResultThirteen
  10849. var res10265_2 ResultThirteen10265
  10850. if config.IsOpen == 1 {
  10851. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10852. } else {
  10853. 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)
  10854. var dat map[string]interface{}
  10855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10856. fmt.Println(dat)
  10857. } else {
  10858. fmt.Println(err)
  10859. }
  10860. userJSONBytes, _ := json.Marshal(dat)
  10861. if miConfig.Code == "H15049901371" {
  10862. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10863. utils.ErrorLog("解析失败:%v", err)
  10864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10865. return
  10866. }
  10867. res2.ErrMsg = res10265_2.ErrMsg
  10868. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10869. res2.Infcode = infocode
  10870. res2.Output = res10265_2.Output
  10871. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10872. } else {
  10873. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10874. utils.ErrorLog("解析失败:%v", err)
  10875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10876. return
  10877. }
  10878. }
  10879. }
  10880. if res2.Infcode == 0 {
  10881. psnResult := &models.GdybPsnNcdsRecord{
  10882. UserOrgId: adminUser.CurrentOrgId,
  10883. PatientId: patient.ID,
  10884. PsnNo: psn_no,
  10885. DoctorId: doctor.AdminUserId,
  10886. DepartmentId: department_id,
  10887. SickType: sick_id,
  10888. Insutype: insutype,
  10889. Ctime: time.Now().Unix(),
  10890. Mtime: time.Now().Unix(),
  10891. Status: 1,
  10892. IsCancel: 1,
  10893. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10894. }
  10895. service.CreatePsnNCDSRecord(psnResult)
  10896. c.ServeSuccessJSON(map[string]interface{}{
  10897. "failed_code": 0,
  10898. "msg": "备案成功",
  10899. "result": psnResult,
  10900. })
  10901. } else {
  10902. c.ServeSuccessJSON(map[string]interface{}{
  10903. "failed_code": -10,
  10904. "msg": res2.ErrMsg,
  10905. })
  10906. return
  10907. }
  10908. }
  10909. }
  10910. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10911. id, _ := c.GetInt64("id")
  10912. admin_user_id, _ := c.GetInt64("admin_user_id")
  10913. adminUser := c.GetAdminUserInfo()
  10914. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10915. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10916. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10917. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10918. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10919. //var user_name string
  10920. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10921. //if role.ID == 0 {
  10922. // user_name = "xxx"
  10923. //} else {
  10924. // user_name = role.UserName
  10925. //}
  10926. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10927. if psn_record.ID == 0 {
  10928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10929. return
  10930. }
  10931. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10932. var res ResultTwo
  10933. var res10265 ResultTwo10265
  10934. if miConfig.Code == "H15049901371" {
  10935. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10936. utils.ErrorLog("解析失败:%v", err)
  10937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10938. return
  10939. }
  10940. res.ErrMsg = res10265.ErrMsg
  10941. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10942. res.Infcode = infocode
  10943. res.Output = res10265.Output
  10944. res.InfRefmsgid = res10265.InfRefmsgid
  10945. } else {
  10946. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10947. utils.ErrorLog("解析失败:%v", err)
  10948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10949. return
  10950. }
  10951. }
  10952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10953. infoStr := string(Iinfos)
  10954. var rf []*ResultFive
  10955. json.Unmarshal([]byte(infoStr), &rf)
  10956. var insuplc_admdvs string
  10957. var insutype string
  10958. var is390 int = 0
  10959. var is310 int = 0
  10960. var insutypes []*ResultFive
  10961. for _, item := range rf {
  10962. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10963. insutypes = append(insutypes, item)
  10964. }
  10965. }
  10966. if len(insutypes) == 1 {
  10967. insutype = insutypes[0].Insutype
  10968. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10969. } else {
  10970. for _, i := range insutypes {
  10971. if i.Insutype == "390" {
  10972. is390 = 1
  10973. }
  10974. if i.Insutype == "310" {
  10975. is310 = 1
  10976. }
  10977. }
  10978. }
  10979. if is390 == 1 {
  10980. insutype = "390"
  10981. }
  10982. if is310 == 1 {
  10983. insutype = "310"
  10984. }
  10985. if len(insutypes) == 0 {
  10986. insutype = "310"
  10987. }
  10988. insutype = psn_record.Insutype
  10989. for _, item := range rf {
  10990. if item.Insutype == insutype {
  10991. insuplc_admdvs = item.InsuplcAdmdvs
  10992. }
  10993. }
  10994. if config.IsOpen == 1 {
  10995. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10996. var dat map[string]interface{}
  10997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10998. fmt.Println(dat)
  10999. } else {
  11000. fmt.Println(err)
  11001. }
  11002. userJSONBytes, _ := json.Marshal(dat)
  11003. var res ResultFourteen
  11004. var res10265 ResultFourteen10265
  11005. if miConfig.Code == "H15049901371" {
  11006. if err := json.Unmarshal(userJSONBytes, &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. } else {
  11017. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11018. utils.ErrorLog("解析失败:%v", err)
  11019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11020. return
  11021. }
  11022. }
  11023. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11024. // utils.ErrorLog("解析失败:%v", err)
  11025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11026. // return
  11027. //}
  11028. if res.Infcode == 0 {
  11029. psn_record.IsCancel = 2
  11030. service.CreatePsnNCDSRecord(&psn_record)
  11031. c.ServeSuccessJSON(map[string]interface{}{
  11032. "failed_code": 0,
  11033. "msg": "撤销备案成功",
  11034. })
  11035. } else {
  11036. c.ServeSuccessJSON(map[string]interface{}{
  11037. "failed_code": -10,
  11038. "msg": res.ErrMsg,
  11039. })
  11040. return
  11041. }
  11042. }
  11043. }
  11044. func (c *HisApiController) TestTest() {
  11045. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  11046. fmt.Println(patient.Iinfo)
  11047. }
  11048. type CustomData struct {
  11049. MsgId string
  11050. PsnNo string
  11051. Info string
  11052. }
  11053. func (c *HisApiController) ReversalData() {
  11054. var customData []*CustomData
  11055. custom := &CustomData{
  11056. MsgId: "H44022900158202103301714472004",
  11057. PsnNo: "44020000001101329945",
  11058. Info: "2207",
  11059. }
  11060. customData = append(customData, custom)
  11061. custom1 := &CustomData{
  11062. MsgId: "H4402290015820210330172057803",
  11063. PsnNo: "44020000001101161813",
  11064. Info: "2207",
  11065. }
  11066. customData = append(customData, custom1)
  11067. custom2 := &CustomData{
  11068. MsgId: "H44022900158202103301705198813",
  11069. PsnNo: "44190000133097375417",
  11070. Info: "2207",
  11071. }
  11072. customData = append(customData, custom2)
  11073. custom3 := &CustomData{
  11074. MsgId: "H44022900158202103301715524756",
  11075. PsnNo: "44020000001100187221",
  11076. Info: "2207",
  11077. }
  11078. customData = append(customData, custom3)
  11079. custom4 := &CustomData{
  11080. MsgId: "H44022900158202103301730376224",
  11081. PsnNo: "44020000001101959155",
  11082. Info: "2207",
  11083. }
  11084. customData = append(customData, custom4)
  11085. custom5 := &CustomData{
  11086. MsgId: "H44022900158202103301748008725",
  11087. PsnNo: "44020000001104246641",
  11088. Info: "2207",
  11089. }
  11090. customData = append(customData, custom5)
  11091. custom6 := &CustomData{
  11092. MsgId: "H44022900158202103301718096755",
  11093. PsnNo: "44020000001102211860",
  11094. Info: "2207",
  11095. }
  11096. customData = append(customData, custom6)
  11097. custom7 := &CustomData{
  11098. MsgId: "H44022900158202103301736551640",
  11099. PsnNo: "44020000001102687718",
  11100. Info: "2207",
  11101. }
  11102. customData = append(customData, custom7)
  11103. custom8 := &CustomData{
  11104. MsgId: "H44022900158202103301743097676",
  11105. PsnNo: "44020000001102127785",
  11106. Info: "2207",
  11107. }
  11108. customData = append(customData, custom8)
  11109. custom9 := &CustomData{
  11110. MsgId: "H44022900158202103301712304203",
  11111. PsnNo: "44020000001101518097",
  11112. Info: "2207",
  11113. }
  11114. customData = append(customData, custom9)
  11115. custom10 := &CustomData{
  11116. MsgId: "H44022900158202103301738448785",
  11117. PsnNo: "44020000001100500813",
  11118. Info: "2207",
  11119. }
  11120. customData = append(customData, custom10)
  11121. custom11 := &CustomData{
  11122. MsgId: "H44022900158202103301732455843",
  11123. PsnNo: "44020000001102690557",
  11124. Info: "2207",
  11125. }
  11126. customData = append(customData, custom11)
  11127. custom12 := &CustomData{
  11128. MsgId: "H44022900158202103301745421708",
  11129. PsnNo: "44020000001102211928",
  11130. Info: "2207",
  11131. }
  11132. customData = append(customData, custom12)
  11133. custom1212 := &CustomData{
  11134. MsgId: "H440229001582021033017351627",
  11135. PsnNo: "44020000001102481733",
  11136. Info: "2207",
  11137. }
  11138. customData = append(customData, custom1212)
  11139. custom13 := &CustomData{
  11140. MsgId: "H44022900158202103301740327951",
  11141. PsnNo: "44020000001103174866",
  11142. Info: "2207",
  11143. }
  11144. customData = append(customData, custom13)
  11145. custom14 := &CustomData{
  11146. MsgId: "H4402290015820210330174922668",
  11147. PsnNo: "44020000001102927272",
  11148. Info: "2207",
  11149. }
  11150. customData = append(customData, custom14)
  11151. custom15 := &CustomData{
  11152. MsgId: "H44022900158202103301752362273",
  11153. PsnNo: "44020000001102942890",
  11154. Info: "2207",
  11155. }
  11156. customData = append(customData, custom15)
  11157. custom16 := &CustomData{
  11158. MsgId: "H44022900158202103301751082917",
  11159. PsnNo: "44020000001101662162",
  11160. Info: "2207",
  11161. }
  11162. customData = append(customData, custom16)
  11163. custom17 := &CustomData{
  11164. MsgId: "H44022900158202103301754147728",
  11165. PsnNo: "44020000000229014511",
  11166. Info: "2207",
  11167. }
  11168. customData = append(customData, custom17)
  11169. adminUser := c.GetAdminUserInfo()
  11170. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11171. for _, item := range customData {
  11172. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11173. fmt.Println(result)
  11174. }
  11175. }
  11176. //func (c *HisApiController) GetAllopatry() {
  11177. // year := c.GetString("year")
  11178. // month := c.GetString("month")
  11179. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11180. // adminUser := c.GetAdminUserInfo()
  11181. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11182. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11183. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11184. //
  11185. // var dat map[string]interface{}
  11186. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11187. // fmt.Println(dat)
  11188. // } else {
  11189. // fmt.Println(err)
  11190. // }
  11191. // userJSONBytes, _ := json.Marshal(dat)
  11192. // var res models.Result9001
  11193. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11194. // utils.ErrorLog("解析失败:%v", err)
  11195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. // return
  11197. // }
  11198. //
  11199. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11200. // var dat2 map[string]interface{}
  11201. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11202. // fmt.Println(dat)
  11203. // } else {
  11204. // fmt.Println(err)
  11205. // }
  11206. // userJSONBytes2, _ := json.Marshal(dat2)
  11207. // var res2 models.Result3260
  11208. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11209. // utils.ErrorLog("解析失败:%v", err)
  11210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11211. // return
  11212. // }
  11213. // if res2.Infcode == 0 {
  11214. // c.ServeSuccessJSON(map[string]interface{}{
  11215. // "list": res2.Output.Data,
  11216. // })
  11217. // return
  11218. // } else {
  11219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11220. // return
  11221. // }
  11222. //
  11223. //}
  11224. //func (c *HisApiController) ComfirmAllopatry() {
  11225. // year := c.GetString("year")
  11226. // month := c.GetString("month")
  11227. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11228. // adminUser := c.GetAdminUserInfo()
  11229. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11230. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11231. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11232. // var dat map[string]interface{}
  11233. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11234. // fmt.Println(dat)
  11235. // } else {
  11236. // fmt.Println(err)
  11237. // }
  11238. // userJSONBytes, _ := json.Marshal(dat)
  11239. // var res models.Result9001
  11240. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11241. // utils.ErrorLog("解析失败:%v", err)
  11242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11243. // return
  11244. // }
  11245. //
  11246. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  11247. // var dat2 map[string]interface{}
  11248. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  11249. // fmt.Println(dat)
  11250. // } else {
  11251. // fmt.Println(err)
  11252. // }
  11253. // userJSONBytes2, _ := json.Marshal(dat2)
  11254. // var res2 models.Result3260
  11255. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11256. // utils.ErrorLog("解析失败:%v", err)
  11257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11258. // return
  11259. // }
  11260. //
  11261. // if res2.Infcode == 0 {
  11262. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  11263. // var dat map[string]interface{}
  11264. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11265. // fmt.Println(dat)
  11266. // } else {
  11267. // fmt.Println(err)
  11268. // }
  11269. // userJSONBytes, _ := json.Marshal(dat)
  11270. // var res3 models.Result3261
  11271. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11272. // utils.ErrorLog("解析失败:%v", err)
  11273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11274. // return
  11275. // }
  11276. //
  11277. // if res3.Infcode == 0 {
  11278. // record := &models.HisYidiClearRecord{
  11279. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11280. // Ctime: time.Now().Unix(),
  11281. // Mtime: time.Now().Unix(),
  11282. // Status: 1,
  11283. // MsgId: msgId,
  11284. // }
  11285. // service.SaveClearRecord(record)
  11286. // c.ServeSuccessJSON(map[string]interface{}{
  11287. // "msg": "提取成功",
  11288. // })
  11289. // }
  11290. // }
  11291. //}
  11292. func (c *HisApiController) RefundAllopatry() {
  11293. year := c.GetString("year")
  11294. month := c.GetString("month")
  11295. id, _ := c.GetInt64("id")
  11296. admin_user_id, _ := c.GetInt64("admin_user_id")
  11297. adminUser := c.GetAdminUserInfo()
  11298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11299. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11300. record, _ := service.GetClearRecordById(id)
  11301. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11302. var dat map[string]interface{}
  11303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11304. fmt.Println(dat)
  11305. } else {
  11306. fmt.Println(err)
  11307. }
  11308. userJSONBytes, _ := json.Marshal(dat)
  11309. var empty ResultFourteen
  11310. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11311. utils.ErrorLog("解析失败:%v", err)
  11312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11313. return
  11314. }
  11315. if empty.Infcode == 0 {
  11316. c.ServeSuccessJSON(map[string]interface{}{
  11317. "msg": "撤销成功",
  11318. })
  11319. return
  11320. }
  11321. }
  11322. func (c *HisApiController) ReversalOtherData() {
  11323. var customData []*CustomData
  11324. custom := &CustomData{
  11325. MsgId: "H44022900158202103301714472004",
  11326. PsnNo: "44020000001101329945",
  11327. Info: "2208",
  11328. }
  11329. customData = append(customData, custom)
  11330. custom1 := &CustomData{
  11331. MsgId: "H4402290015820210330172057803",
  11332. PsnNo: "44020000001101161813",
  11333. Info: "2208",
  11334. }
  11335. customData = append(customData, custom1)
  11336. custom2 := &CustomData{
  11337. MsgId: "H44022900158202103301705198813",
  11338. PsnNo: "44190000133097375417",
  11339. Info: "2208",
  11340. }
  11341. customData = append(customData, custom2)
  11342. custom3 := &CustomData{
  11343. MsgId: "H44022900158202103301715524756",
  11344. PsnNo: "44020000001100187221",
  11345. Info: "2208",
  11346. }
  11347. customData = append(customData, custom3)
  11348. custom4 := &CustomData{
  11349. MsgId: "H44022900158202103301730376224",
  11350. PsnNo: "44020000001101959155",
  11351. Info: "2208",
  11352. }
  11353. customData = append(customData, custom4)
  11354. custom5 := &CustomData{
  11355. MsgId: "H44022900158202103301748008725",
  11356. PsnNo: "44020000001104246641",
  11357. Info: "2208",
  11358. }
  11359. customData = append(customData, custom5)
  11360. custom6 := &CustomData{
  11361. MsgId: "H44022900158202103301718096755",
  11362. PsnNo: "44020000001102211860",
  11363. Info: "2208",
  11364. }
  11365. customData = append(customData, custom6)
  11366. custom7 := &CustomData{
  11367. MsgId: "H44022900158202103301736551640",
  11368. PsnNo: "44020000001102687718",
  11369. Info: "2208",
  11370. }
  11371. customData = append(customData, custom7)
  11372. custom8 := &CustomData{
  11373. MsgId: "H44022900158202103301743097676",
  11374. PsnNo: "44020000001102127785",
  11375. Info: "2208",
  11376. }
  11377. customData = append(customData, custom8)
  11378. custom9 := &CustomData{
  11379. MsgId: "H44022900158202103301712304203",
  11380. PsnNo: "44020000001101518097",
  11381. Info: "2208",
  11382. }
  11383. customData = append(customData, custom9)
  11384. custom10 := &CustomData{
  11385. MsgId: "H44022900158202103301738448785",
  11386. PsnNo: "44020000001100500813",
  11387. Info: "2208",
  11388. }
  11389. customData = append(customData, custom10)
  11390. custom11 := &CustomData{
  11391. MsgId: "H44022900158202103301732455843",
  11392. PsnNo: "44020000001102690557",
  11393. Info: "2208",
  11394. }
  11395. customData = append(customData, custom11)
  11396. custom12 := &CustomData{
  11397. MsgId: "H44022900158202103301745421708",
  11398. PsnNo: "44020000001102211928",
  11399. Info: "2208",
  11400. }
  11401. customData = append(customData, custom12)
  11402. custom1212 := &CustomData{
  11403. MsgId: "H440229001582021033017351627",
  11404. PsnNo: "44020000001102481733",
  11405. Info: "2208",
  11406. }
  11407. customData = append(customData, custom1212)
  11408. custom13 := &CustomData{
  11409. MsgId: "H44022900158202103301740327951",
  11410. PsnNo: "44020000001103174866",
  11411. Info: "2208",
  11412. }
  11413. customData = append(customData, custom13)
  11414. custom14 := &CustomData{
  11415. MsgId: "H4402290015820210330174922668",
  11416. PsnNo: "44020000001102927272",
  11417. Info: "2208",
  11418. }
  11419. customData = append(customData, custom14)
  11420. custom15 := &CustomData{
  11421. MsgId: "H44022900158202103301752362273",
  11422. PsnNo: "44020000001102942890",
  11423. Info: "2208",
  11424. }
  11425. customData = append(customData, custom15)
  11426. custom16 := &CustomData{
  11427. MsgId: "H44022900158202103301751082917",
  11428. PsnNo: "44020000001101662162",
  11429. Info: "2208",
  11430. }
  11431. customData = append(customData, custom16)
  11432. custom17 := &CustomData{
  11433. MsgId: "H44022900158202103301754147728",
  11434. PsnNo: "44020000000229014511",
  11435. Info: "2208",
  11436. }
  11437. customData = append(customData, custom17)
  11438. adminUser := c.GetAdminUserInfo()
  11439. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11440. for _, item := range customData {
  11441. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11442. fmt.Println(result)
  11443. }
  11444. }
  11445. func PathExists(path string) (bool, error) {
  11446. _, err := os.Stat(path)
  11447. if err == nil {
  11448. return true, nil
  11449. }
  11450. if os.IsNotExist(err) {
  11451. return false, nil
  11452. }
  11453. return false, err
  11454. }
  11455. //创建文件夹
  11456. func Mkdir(dir string) {
  11457. // 创建文件夹
  11458. exist, err := PathExists(dir)
  11459. if err != nil {
  11460. fmt.Println(err.Error())
  11461. } else {
  11462. if exist {
  11463. fmt.Println(dir + "文件夹已存在!")
  11464. } else {
  11465. // 文件夹名称,权限
  11466. err := os.Mkdir(dir, os.ModePerm)
  11467. if err != nil {
  11468. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11469. } else {
  11470. fmt.Println(dir + "文件夹创建成功!")
  11471. }
  11472. }
  11473. }
  11474. }
  11475. //压缩文件
  11476. func Zip(srcFile string, destZip string) error {
  11477. zipfile, err := os.Create(destZip)
  11478. if err != nil {
  11479. return err
  11480. }
  11481. defer zipfile.Close()
  11482. archive := zip.NewWriter(zipfile)
  11483. defer archive.Close()
  11484. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11485. if err != nil {
  11486. return err
  11487. }
  11488. header, err := zip.FileInfoHeader(info)
  11489. if err != nil {
  11490. return err
  11491. }
  11492. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11493. // header.Name = path
  11494. if info.IsDir() {
  11495. header.Name += "/"
  11496. } else {
  11497. header.Method = zip.Deflate
  11498. }
  11499. writer, err := archive.CreateHeader(header)
  11500. if err != nil {
  11501. return err
  11502. }
  11503. if !info.IsDir() {
  11504. file, err := os.Open(path)
  11505. if err != nil {
  11506. return err
  11507. }
  11508. defer file.Close()
  11509. _, err = io.Copy(writer, file)
  11510. }
  11511. return err
  11512. })
  11513. return err
  11514. }
  11515. func ReadFile(filePath string) []byte {
  11516. f, err := os.Open(filePath)
  11517. if err != nil {
  11518. fmt.Println("read file fail", err)
  11519. return nil
  11520. }
  11521. defer f.Close()
  11522. fd, err := ioutil.ReadAll(f)
  11523. if err != nil {
  11524. fmt.Println("read to fd fail", err)
  11525. return nil
  11526. }
  11527. return fd
  11528. }
  11529. func saveLog(result string, request string, infno string, desc string) {
  11530. org_id, _ := beego.AppConfig.Int64("org_id")
  11531. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11532. dir := miConfig.OrgName + "日志"
  11533. utils.Mkdir(dir)
  11534. month := time.Unix(1557042972, 0).Format("1")
  11535. year := time.Now().Format("2006")
  11536. month = time.Now().Format("01")
  11537. day := time.Now().Format("02")
  11538. hour := time.Now().Format("15")
  11539. min := time.Now().Format("04")
  11540. sec := time.Now().Format("05")
  11541. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11542. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11543. file_name := file + ".txt"
  11544. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11545. exist, _ := utils.PathExists(file_path)
  11546. if exist { //存在
  11547. fmt.Println("存在")
  11548. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11549. if err != nil {
  11550. fmt.Println("read fail")
  11551. }
  11552. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11553. n, _ := f.Seek(0, 2)
  11554. _, err = f.WriteAt([]byte(content), n)
  11555. } else { //不存在
  11556. fmt.Println("文件不存在,创建文件")
  11557. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11558. defer f.Close()
  11559. if err != nil {
  11560. } else {
  11561. _, err = f.Write([]byte("记录日志"))
  11562. }
  11563. }
  11564. }
  11565. type Charset string
  11566. const (
  11567. UTF8 = Charset("UTF-8")
  11568. GB18030 = Charset("GB18030")
  11569. )
  11570. func ConvertToString(src string, srcCode string, tagCode string) string {
  11571. srcCoder := mahonia.NewDecoder(srcCode)
  11572. srcResult := srcCoder.ConvertString(src)
  11573. tagCoder := mahonia.NewDecoder(tagCode)
  11574. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11575. result := string(cdata)
  11576. return result
  11577. }
  11578. func (c *HisApiController) ReadEleCard() {
  11579. id_card_type, _ := c.GetInt64("id_card_type")
  11580. admin_user_id, _ := c.GetInt64("admin_user_id")
  11581. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11582. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11583. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11584. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11585. var api string
  11586. if miConfig.MdtrtareaAdmvs == "320921" {
  11587. 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 +
  11588. "&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
  11589. fmt.Println(api)
  11590. } else {
  11591. 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 +
  11592. "&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
  11593. }
  11594. resp, requestErr := http.Get(api)
  11595. if requestErr != nil {
  11596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11597. return
  11598. }
  11599. body, ioErr := ioutil.ReadAll(resp.Body)
  11600. if ioErr != nil {
  11601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11603. return
  11604. }
  11605. var respJSON map[string]interface{}
  11606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11609. return
  11610. }
  11611. var status string
  11612. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11613. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11614. var token string
  11615. var res ResultTwo //1101结果
  11616. var res10265 ResultTwo10265 //1101结果
  11617. if status == "0" { //读卡成功
  11618. var card_info string //卡信息
  11619. var busi_card_info string
  11620. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11621. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11622. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11623. fmt.Println(card_info)
  11624. fmt.Println(busi_card_info)
  11625. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11626. result, _ := json.Marshal(respJSON)
  11627. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11628. utils.ErrorLog("解析失败:%v", err)
  11629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11630. return
  11631. }
  11632. res.ErrMsg = res10265.ErrMsg
  11633. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11634. res.Infcode = infocode
  11635. res.Output = res10265.Output
  11636. res.InfRefmsgid = res10265.InfRefmsgid
  11637. if res.Infcode == 0 {
  11638. c.ServeSuccessJSON(map[string]interface{}{
  11639. "number": token,
  11640. })
  11641. }
  11642. } else {
  11643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11644. return
  11645. }
  11646. } else { //读卡失败
  11647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11648. return
  11649. }
  11650. }
  11651. func DeleteExtraSpaceTwo(s string) string {
  11652. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11653. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11654. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11655. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11656. s2 := make([]byte, len(s1)) //定义字符数组切片
  11657. copy(s2, s1) //将字符串复制到切片
  11658. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11659. for len(spc_index) > 0 { //找到适配项
  11660. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11661. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11662. }
  11663. return string(s2)
  11664. }
  11665. func Remove0000(s string) string {
  11666. str := make([]rune, 0, len(s))
  11667. for _, v := range []rune(s) {
  11668. if v == 0 {
  11669. continue
  11670. }
  11671. str = append(str, v)
  11672. }
  11673. return string(str)
  11674. }
  11675. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11676. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11677. readCard := DllDef.MustFindProc("EcQuery")
  11678. pCardInfo := make([]byte, 8192)
  11679. pBusiCardInfo := make([]byte, 8192)
  11680. data := make(map[string]interface{})
  11681. //pData := make(map[string]interface{})
  11682. inputData := make(map[string]interface{})
  11683. inputData["orgId"] = code
  11684. inputData["businessType"] = "01101"
  11685. inputData["operatorId"] = operator_id
  11686. inputData["operatorName"] = operator_name
  11687. inputData["officeId"] = "001"
  11688. inputData["officeName"] = "血透室"
  11689. //
  11690. data["data"] = inputData
  11691. data["transType"] = "ec.query"
  11692. data["orgId"] = code
  11693. bytesData, _ := json.Marshal(data)
  11694. pCardInfo = bytesData
  11695. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11696. fmt.Println(ret2)
  11697. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11698. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11699. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11700. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11701. if ret2 != 0 {
  11702. return "", ""
  11703. }
  11704. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11705. }
  11706. func DeleteExtraSpace(s string) string {
  11707. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11708. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11709. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11710. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11711. s2 := make([]byte, len(s1)) //定义字符数组切片
  11712. copy(s2, s1) //将字符串复制到切片
  11713. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11714. for len(spc_index) > 0 { //找到适配项
  11715. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11716. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11717. }
  11718. return string(s2)
  11719. }