his_api_controller.go 460KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. service.GetFjAuthorizationInfo(miConfig.Code)
  85. } else {
  86. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  87. var dat map[string]interface{}
  88. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  89. fmt.Println(dat)
  90. } else {
  91. fmt.Println(err)
  92. }
  93. userJSONBytes, _ := json.Marshal(dat)
  94. var res models.Result9001
  95. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  96. utils.ErrorLog("解析失败:%v", err)
  97. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  98. return
  99. }
  100. }
  101. }
  102. func (c *HisApiController) Check3101() {
  103. patient_id, _ := c.GetInt64("patient_id")
  104. his_patient_id, _ := c.GetInt64("his_patient_id")
  105. admin_user_id, _ := c.GetInt64("admin_user_id")
  106. adminUser := c.GetAdminUserInfo()
  107. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  108. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  110. record_time := c.GetString("record_time")
  111. trig_scen := c.GetString("trig_scen")
  112. timeLayout := "2006-01-02"
  113. loc, _ := time.LoadLocation("Local")
  114. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  115. if err != nil {
  116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  117. return
  118. }
  119. recordDateTime := theTime.Unix()
  120. var patientPrescription models.HisPrescriptionInfo
  121. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  122. if patientPrescription.ID == 0 {
  123. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  124. }
  125. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  126. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  127. //
  128. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  129. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  130. var pp models.PublicParams
  131. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  132. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  133. pp.FixmedinsName = miConfig.OrgName
  134. pp.FixmedinsCode = miConfig.Code
  135. pp.RequestUrl = miConfig.Url
  136. pp.Cainfo = miConfig.Cainfo
  137. pp.SecretKey = miConfig.SecretKey
  138. pp.AccessKey = miConfig.AccessKey
  139. pp.OpterName = roles.UserName
  140. var config []*models.HisXtDiagnoseConfig
  141. for _, item := range diagnosis_ids {
  142. id, _ := strconv.ParseInt(item, 10, 64)
  143. diagnosisConfig, _ := service.FindDiagnoseById(id)
  144. config = append(config, &diagnosisConfig)
  145. }
  146. var pd models.PatientDtos
  147. pd.PatnID = his.PsnNo
  148. pd.PatnName = his.Name
  149. pd.Gend = his.Gend
  150. pd.Brdy = his.Brdy
  151. pd.Poolarea = his.InsuplcAdmdvs
  152. pd.CurrMdtrtID = his.Number
  153. var fed models.FsiEncounterDtos
  154. fed.MdtrtID = his.Number
  155. fed.MedinsID = miConfig.Code
  156. fed.MedinsName = miConfig.OrgName
  157. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  158. fed.MedMdtrtType = "1"
  159. fed.MedinsType = "1"
  160. fed.MedinsLv = "11"
  161. tm := time.Unix(his.RecordDate, 0)
  162. s_tm := tm.Format("2006-01-02 15:04:05")
  163. fed.AdmDate = s_tm
  164. fed.DscgDate = s_tm
  165. fed.DscgMainDiseCodg = config[0].CountryCode
  166. fed.DscgMainDiseName = config[0].CountryContentName
  167. //诊断信息
  168. var fdds []*models.FsiDiagnoseDtos
  169. for index, item := range config {
  170. if index == 0 {
  171. var fdd models.FsiDiagnoseDtos
  172. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  173. fdd.InoutDiseType = "1"
  174. fdd.MaindiseFlag = "1"
  175. fdd.DiseDate = s_tm
  176. fdd.DiasSrtNo = "1"
  177. fdd.DiseName = item.CountryContentName
  178. fdd.DiseCodg = item.CountryCode
  179. fdds = append(fdds, &fdd)
  180. } else {
  181. var fdd models.FsiDiagnoseDtos
  182. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  183. fdd.InoutDiseType = "1"
  184. fdd.MaindiseFlag = "1"
  185. fdd.DiseDate = s_tm
  186. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  187. fdd.DiseName = item.CountryContentName
  188. fdd.DiseCodg = item.CountryCode
  189. fdds = append(fdds, &fdd)
  190. }
  191. }
  192. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  193. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  194. fed.AdmDeptName = department.Name
  195. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  196. fed.DscgDeptName = department.Name
  197. fed.MedMdtrtType = "1"
  198. fed.MedType = "11"
  199. //if his.Insutype == "390" {
  200. // fed.MedType = "1402"
  201. //} else {
  202. // fed.MedType = "9933"
  203. //}
  204. var orders []*models.FsiOrderDtos
  205. if trig_scen == "2" {
  206. //处方医嘱信息
  207. for _, item := range prescriptions {
  208. for _, subItem := range item.HisDoctorAdviceInfo {
  209. var order models.FsiOrderDtos
  210. order.RxID = strconv.FormatInt(item.ID, 10)
  211. order.Rxno = strconv.FormatInt(item.ID, 10)
  212. order.LongDrordFlag = "0"
  213. order.HilistType = "1"
  214. order.ChrgType = "1"
  215. order.DrordBhvr = "-"
  216. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  217. order.HosplistName = subItem.BaseDrugLib.DrugName
  218. order.HilistLv = "1"
  219. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  220. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  221. order.HosplistName = subItem.BaseDrugLib.DrugName
  222. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  223. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  224. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  225. order.OwnpayAmt = ""
  226. order.SelfpayAmt = ""
  227. order.Spec = ""
  228. order.SpecUnt = ""
  229. order.DrordBegnDate = s_tm
  230. order.DrordStopDate = ""
  231. order.DrordDrCodg = "1"
  232. order.DrordDeptName = department.Name
  233. order.DrordDrCodg = "1"
  234. order.DrordDrName = doctor_info.UserName
  235. order.DrordDrProfttl = ""
  236. order.CurrDrordFlag = "1"
  237. orders = append(orders, &order)
  238. }
  239. for _, subItem := range item.HisPrescriptionProject {
  240. if subItem.Type == 2 {
  241. var order models.FsiOrderDtos
  242. order.RxID = strconv.FormatInt(item.ID, 10)
  243. order.Rxno = strconv.FormatInt(item.ID, 10)
  244. order.LongDrordFlag = "0"
  245. order.HilistType = "1"
  246. order.ChrgType = "1"
  247. order.DrordBhvr = "-"
  248. order.HilistCode = subItem.HisProject.MedicalCode
  249. order.HosplistName = subItem.HisProject.ProjectName
  250. order.HilistLv = "1"
  251. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  252. order.HosplistCode = subItem.HisProject.MedicalCode
  253. order.HosplistName = subItem.HisProject.ProjectName
  254. order.Cnt = subItem.Count
  255. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  256. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  257. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  258. order.OwnpayAmt = ""
  259. order.SelfpayAmt = ""
  260. order.Spec = ""
  261. order.SpecUnt = ""
  262. order.DrordBegnDate = s_tm
  263. order.DrordStopDate = ""
  264. order.DrordDrCodg = "1"
  265. order.DrordDeptName = department.Name
  266. order.DrordDrCodg = "1"
  267. order.DrordDrName = doctor_info.UserName
  268. order.DrordDrProfttl = ""
  269. order.CurrDrordFlag = "1"
  270. orders = append(orders, &order)
  271. }
  272. if subItem.Type == 3 {
  273. var order models.FsiOrderDtos
  274. order.RxID = strconv.FormatInt(item.ID, 10)
  275. order.Rxno = strconv.FormatInt(item.ID, 10)
  276. order.LongDrordFlag = "0"
  277. order.HilistType = "1"
  278. order.ChrgType = "1"
  279. order.DrordBhvr = "-"
  280. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  281. order.HosplistName = subItem.GoodInfo.GoodName
  282. order.HilistLv = "1"
  283. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  284. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  285. order.HosplistName = subItem.GoodInfo.GoodName
  286. order.Cnt = subItem.Count
  287. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  288. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  289. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  290. order.OwnpayAmt = ""
  291. order.SelfpayAmt = ""
  292. order.Spec = ""
  293. order.SpecUnt = ""
  294. order.DrordBegnDate = s_tm
  295. order.DrordStopDate = ""
  296. order.DrordDrCodg = "1"
  297. order.DrordDeptName = department.Name
  298. order.DrordDrCodg = "1"
  299. order.DrordDrName = doctor_info.UserName
  300. order.DrordDrProfttl = ""
  301. order.CurrDrordFlag = "1"
  302. orders = append(orders, &order)
  303. }
  304. }
  305. }
  306. //处方医嘱信息
  307. }
  308. fed.MatnStas = "0"
  309. fed.MedfeeSumamt = "0"
  310. fed.OwnpayAmt = "0"
  311. fed.SelfpayAmt = "0"
  312. fed.AcctPayamt = "0"
  313. fed.MaAmt = "0"
  314. fed.HifpPayamt = "0"
  315. fed.SetlTotlnum = "1"
  316. fed.Insutype = his.Insutype
  317. fed.ReimFlag = "0"
  318. fed.OutSetlFlag = "0"
  319. var fopd []*models.FsiOperationDtosData
  320. data := make(map[string]interface{})
  321. data["fed"] = fed
  322. data["fdd"] = fdds
  323. data["fod"] = orders
  324. data["pd"] = pd
  325. data["pp"] = pp
  326. data["fopd"] = fopd
  327. data["trig_scen"] = trig_scen
  328. fmt.Println(data)
  329. fmt.Println(fed)
  330. fmt.Println(fdds)
  331. fmt.Println(orders)
  332. fmt.Println(pd)
  333. fmt.Println(pp)
  334. fmt.Println(fopd)
  335. client := &http.Client{}
  336. bytesData, _ := json.Marshal(data)
  337. var req *http.Request
  338. if miConfig.MdtrtareaAdmvs == "320921" {
  339. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  340. } else {
  341. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  342. }
  343. resp, _ := client.Do(req)
  344. defer resp.Body.Close()
  345. body, ioErr := ioutil.ReadAll(resp.Body)
  346. if ioErr != nil {
  347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  349. return
  350. }
  351. var respJSON map[string]interface{}
  352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  355. return
  356. }
  357. //手术操作集合
  358. //手术操作集合
  359. }
  360. func (c *HisApiController) Check3102() {
  361. patient_id, _ := c.GetInt64("patient_id")
  362. order_id, _ := c.GetInt64("order_id")
  363. his_patient_id, _ := c.GetInt64("his_patient_id")
  364. admin_user_id, _ := c.GetInt64("admin_user_id")
  365. trig_scen := c.GetString("trig_scen")
  366. adminUser := c.GetAdminUserInfo()
  367. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  368. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  369. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  370. record_time := c.GetString("record_time")
  371. order, _ := service.GetHisOrderByID(order_id)
  372. timeLayout := "2006-01-02"
  373. loc, _ := time.LoadLocation("Local")
  374. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  375. if err != nil {
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  377. return
  378. }
  379. recordDateTime := theTime.Unix()
  380. var patientPrescription models.HisPrescriptionInfo
  381. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  382. if patientPrescription.ID == 0 {
  383. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  384. }
  385. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  386. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  387. //
  388. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  389. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  390. var pp models.PublicParams
  391. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  392. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  393. pp.FixmedinsName = miConfig.OrgName
  394. pp.FixmedinsCode = miConfig.Code
  395. pp.RequestUrl = miConfig.Url
  396. pp.Cainfo = miConfig.Cainfo
  397. pp.SecretKey = miConfig.SecretKey
  398. pp.AccessKey = miConfig.AccessKey
  399. pp.OpterName = roles.UserName
  400. var config []*models.HisXtDiagnoseConfig
  401. for _, item := range diagnosis_ids {
  402. id, _ := strconv.ParseInt(item, 10, 64)
  403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  404. config = append(config, &diagnosisConfig)
  405. }
  406. var pd models.PatientDtos
  407. pd.PatnID = his.PsnNo
  408. pd.PatnName = his.Name
  409. pd.Gend = his.Gend
  410. pd.Brdy = his.Brdy
  411. pd.Poolarea = his.InsuplcAdmdvs
  412. pd.CurrMdtrtID = his.Number
  413. var fed models.FsiEncounterDtos
  414. fed.MdtrtID = his.Number
  415. fed.MedinsID = miConfig.Code
  416. fed.MedinsName = miConfig.OrgName
  417. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  418. fed.MedMdtrtType = "1"
  419. fed.MedinsType = "1"
  420. fed.MedinsLv = "11"
  421. tm := time.Unix(his.RecordDate, 0)
  422. s_tm := tm.Format("2006-01-02 15:04:05")
  423. fed.AdmDate = s_tm
  424. fed.DscgDate = s_tm
  425. fed.DscgMainDiseCodg = config[0].CountryCode
  426. fed.DscgMainDiseName = config[0].CountryContentName
  427. //诊断信息
  428. var fdds []*models.FsiDiagnoseDtos
  429. for index, item := range config {
  430. if index == 0 {
  431. var fdd models.FsiDiagnoseDtos
  432. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  433. fdd.InoutDiseType = "1"
  434. fdd.MaindiseFlag = "1"
  435. fdd.DiseDate = s_tm
  436. fdd.DiasSrtNo = "1"
  437. fdd.DiseName = item.CountryContentName
  438. fdd.DiseCodg = item.CountryCode
  439. fdds = append(fdds, &fdd)
  440. } else {
  441. var fdd models.FsiDiagnoseDtos
  442. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  443. fdd.InoutDiseType = "1"
  444. fdd.MaindiseFlag = "1"
  445. fdd.DiseDate = s_tm
  446. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  447. fdd.DiseName = item.CountryContentName
  448. fdd.DiseCodg = item.CountryCode
  449. fdds = append(fdds, &fdd)
  450. }
  451. }
  452. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  453. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  454. fed.AdmDeptName = department.Name
  455. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  456. fed.DscgDeptName = department.Name
  457. fed.MedType = order.MedType
  458. //处方医嘱信息
  459. var orders []*models.FsiOrderDtos
  460. //for _, item := range prescriptions {
  461. // for _, subItem := range item.HisDoctorAdviceInfo {
  462. // var order models.FsiOrderDtos
  463. // order.RxID = strconv.FormatInt(item.ID, 10)
  464. // order.Rxno = strconv.FormatInt(item.ID, 10)
  465. // order.LongDrordFlag = "0"
  466. // order.HilistType = "1"
  467. // order.ChrgType = "1"
  468. // order.DrordBhvr = "-"
  469. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  470. // order.HosplistName = subItem.BaseDrugLib.DrugName
  471. // order.HilistLv = "1"
  472. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  473. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  474. // order.HosplistName = subItem.BaseDrugLib.DrugName
  475. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  476. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  477. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  478. // order.OwnpayAmt = ""
  479. // order.SelfpayAmt = ""
  480. // order.Spec = ""
  481. // order.SpecUnt = ""
  482. // order.DrordBegnDate = s_tm
  483. // order.DrordStopDate = ""
  484. // order.DrordDrCodg = "1"
  485. // order.DrordDeptName = department.Name
  486. // order.DrordDrCodg = "1"
  487. // order.DrordDrName = doctor_info.UserName
  488. // order.DrordDrProfttl = ""
  489. // order.CurrDrordFlag = "1"
  490. // orders = append(orders, &order)
  491. // }
  492. // for _, subItem := range item.HisPrescriptionProject {
  493. // if subItem.Type == 2 {
  494. // var order models.FsiOrderDtos
  495. // order.RxID = strconv.FormatInt(item.ID, 10)
  496. // order.Rxno = strconv.FormatInt(item.ID, 10)
  497. // order.LongDrordFlag = "0"
  498. // order.HilistType = "1"
  499. // order.ChrgType = "1"
  500. // order.DrordBhvr = "-"
  501. // order.HilistCode = subItem.HisProject.MedicalCode
  502. // order.HosplistName = subItem.HisProject.ProjectName
  503. // order.HilistLv = "1"
  504. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  505. // order.HosplistCode = subItem.HisProject.MedicalCode
  506. // order.HosplistName = subItem.HisProject.ProjectName
  507. // order.Cnt = subItem.Count
  508. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  509. //
  510. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  511. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  512. // order.OwnpayAmt = ""
  513. // order.SelfpayAmt = ""
  514. // order.Spec = ""
  515. // order.SpecUnt = ""
  516. // order.DrordBegnDate = s_tm
  517. // order.DrordStopDate = ""
  518. // order.DrordDrCodg = "1"
  519. // order.DrordDeptName = department.Name
  520. // order.DrordDrCodg = "1"
  521. // order.DrordDrName = doctor_info.UserName
  522. // order.DrordDrProfttl = ""
  523. // order.CurrDrordFlag = "1"
  524. // orders = append(orders, &order)
  525. //
  526. // }
  527. // if subItem.Type == 3 {
  528. //
  529. // var order models.FsiOrderDtos
  530. // order.RxID = strconv.FormatInt(item.ID, 10)
  531. // order.Rxno = strconv.FormatInt(item.ID, 10)
  532. // order.LongDrordFlag = "0"
  533. // order.HilistType = "1"
  534. // order.ChrgType = "1"
  535. // order.DrordBhvr = "-"
  536. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  537. // order.HosplistName = subItem.GoodInfo.GoodName
  538. // order.HilistLv = "1"
  539. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  541. // order.HosplistName = subItem.GoodInfo.GoodName
  542. // order.Cnt = subItem.Count
  543. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  544. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  545. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  546. // order.OwnpayAmt = ""
  547. // order.SelfpayAmt = ""
  548. // order.Spec = ""
  549. // order.SpecUnt = ""
  550. // order.DrordBegnDate = s_tm
  551. // order.DrordStopDate = ""
  552. // order.DrordDrCodg = "1"
  553. // order.DrordDeptName = department.Name
  554. // order.DrordDrCodg = "1"
  555. // order.DrordDrName = doctor_info.UserName
  556. // order.DrordDrProfttl = ""
  557. // order.CurrDrordFlag = "1"
  558. // orders = append(orders, &order)
  559. //
  560. // }
  561. // }
  562. //}
  563. for _, item := range prescriptions {
  564. for _, subItem := range item.HisDoctorAdviceInfo {
  565. var order models.FsiOrderDtos
  566. order.RxID = strconv.FormatInt(item.ID, 10)
  567. order.Rxno = strconv.FormatInt(item.ID, 10)
  568. order.LongDrordFlag = "0"
  569. order.HilistType = "1"
  570. order.ChrgType = "1"
  571. order.DrordBhvr = "-"
  572. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  573. order.HosplistName = subItem.BaseDrugLib.DrugName
  574. order.HilistLv = "1"
  575. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  576. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  577. order.HosplistName = subItem.BaseDrugLib.DrugName
  578. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  579. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  580. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  581. order.OwnpayAmt = ""
  582. order.SelfpayAmt = ""
  583. order.Spec = ""
  584. order.SpecUnt = ""
  585. order.DrordBegnDate = s_tm
  586. order.DrordStopDate = ""
  587. order.DrordDrCodg = "1"
  588. order.DrordDeptName = department.Name
  589. order.DrordDrCodg = "1"
  590. order.DrordDrName = doctor_info.UserName
  591. order.DrordDrProfttl = ""
  592. order.CurrDrordFlag = "1"
  593. orders = append(orders, &order)
  594. }
  595. for _, subItem := range item.HisPrescriptionProject {
  596. if subItem.Type == 2 {
  597. var order models.FsiOrderDtos
  598. order.RxID = strconv.FormatInt(item.ID, 10)
  599. order.Rxno = strconv.FormatInt(item.ID, 10)
  600. order.LongDrordFlag = "0"
  601. order.HilistType = "1"
  602. order.ChrgType = "1"
  603. order.DrordBhvr = "-"
  604. order.HilistCode = subItem.HisProject.MedicalCode
  605. order.HosplistName = subItem.HisProject.ProjectName
  606. order.HilistLv = "1"
  607. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  608. order.HosplistCode = subItem.HisProject.MedicalCode
  609. order.HosplistName = subItem.HisProject.ProjectName
  610. order.Cnt = subItem.Count
  611. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  612. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  613. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  614. order.OwnpayAmt = ""
  615. order.SelfpayAmt = ""
  616. order.Spec = ""
  617. order.SpecUnt = ""
  618. order.DrordBegnDate = s_tm
  619. order.DrordStopDate = ""
  620. order.DrordDrCodg = "1"
  621. order.DrordDeptName = department.Name
  622. order.DrordDrCodg = "1"
  623. order.DrordDrName = doctor_info.UserName
  624. order.DrordDrProfttl = ""
  625. order.CurrDrordFlag = "1"
  626. orders = append(orders, &order)
  627. }
  628. if subItem.Type == 3 {
  629. var order models.FsiOrderDtos
  630. order.RxID = strconv.FormatInt(item.ID, 10)
  631. order.Rxno = strconv.FormatInt(item.ID, 10)
  632. order.LongDrordFlag = "0"
  633. order.HilistType = "1"
  634. order.ChrgType = "1"
  635. order.DrordBhvr = "-"
  636. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  637. order.HosplistName = subItem.GoodInfo.GoodName
  638. order.HilistLv = "1"
  639. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  640. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  641. order.HosplistName = subItem.GoodInfo.GoodName
  642. order.Cnt = subItem.Count
  643. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  644. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  645. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  646. order.OwnpayAmt = ""
  647. order.SelfpayAmt = ""
  648. order.Spec = ""
  649. order.SpecUnt = ""
  650. order.DrordBegnDate = s_tm
  651. order.DrordStopDate = ""
  652. order.DrordDrCodg = "1"
  653. order.DrordDeptName = department.Name
  654. order.DrordDrCodg = "1"
  655. order.DrordDrName = doctor_info.UserName
  656. order.DrordDrProfttl = ""
  657. order.CurrDrordFlag = "1"
  658. orders = append(orders, &order)
  659. }
  660. }
  661. }
  662. //处方医嘱信息
  663. fed.MatnStas = "0"
  664. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  665. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  666. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  667. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  668. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  669. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  670. fed.SetlTotlnum = "1"
  671. fed.Insutype = his.Insutype
  672. fed.ReimFlag = "0"
  673. fed.OutSetlFlag = "0"
  674. var fopd []*models.FsiOperationDtosData
  675. data := make(map[string]interface{})
  676. data["fed"] = fed
  677. data["fdd"] = fdds
  678. data["fod"] = orders
  679. data["pd"] = pd
  680. data["pp"] = pp
  681. data["fopd"] = fopd
  682. data["trig_scen"] = trig_scen
  683. client := &http.Client{}
  684. bytesData, _ := json.Marshal(data)
  685. var req *http.Request
  686. if miConfig.MdtrtareaAdmvs == "320921" {
  687. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  688. } else {
  689. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  690. }
  691. resp, _ := client.Do(req)
  692. defer resp.Body.Close()
  693. body, ioErr := ioutil.ReadAll(resp.Body)
  694. if ioErr != nil {
  695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. var respJSON map[string]interface{}
  700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. //手术操作集合
  706. //手术操作集合
  707. }
  708. func (c *HisApiController) Check() {
  709. psn_no := c.GetString("psn_no")
  710. in := c.GetString("in")
  711. mt := c.GetString("mt")
  712. baseParams := models.BaseParams{
  713. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  714. FixmedinsCode: "H15049901371",
  715. InsuplcAdmdvs: "150499",
  716. MdtrtareaAdmvs: "150499",
  717. OrgName: "赤峰费森血液透析中心",
  718. Doctor: "1111",
  719. }
  720. service.Gdyb2001(baseParams, psn_no, in, mt)
  721. }
  722. func (c *HisApiController) GetPsnNcdsInfo() {
  723. admin_user_id, _ := c.GetInt64("admin_user_id")
  724. patient_id, _ := c.GetInt64("patient_id")
  725. id, _ := c.GetInt64("id")
  726. adminUser := c.GetAdminUserInfo()
  727. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  728. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  729. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  730. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  731. psn_record, _ := service.GetPsnNCDSRecordById(id)
  732. //
  733. //if psn_record.ID == 0 {
  734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  735. // return
  736. //}
  737. var res Result5301
  738. var res10265 Result5301For10265
  739. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  740. psn_info, _ := service.GetPsnByPatientId(patient_id)
  741. var api string
  742. if miConfig.MdtrtareaAdmvs == "320921" {
  743. 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 +
  744. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  745. } else {
  746. 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 +
  747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  748. }
  749. resp, requestErr := http.Get(api)
  750. if requestErr != nil {
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. body, ioErr := ioutil.ReadAll(resp.Body)
  755. if ioErr != nil {
  756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. var respJSON map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  767. result, _ := json.Marshal(respJSON)
  768. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  769. utils.ErrorLog("解析失败:%v", err)
  770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  771. return
  772. }
  773. res.ErrMsg = res10265.ErrMsg
  774. res.Output = res10265.Output
  775. res.InfRefmsgid = res10265.InfRefmsgid
  776. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  777. res.Infcode = infocode
  778. } else {
  779. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  780. var dat map[string]interface{}
  781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  782. fmt.Println(dat)
  783. } else {
  784. fmt.Println(err)
  785. }
  786. userJSONBytes, _ := json.Marshal(dat)
  787. if miConfig.Code == "H15049901371" {
  788. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  789. utils.ErrorLog("解析失败:%v", err)
  790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  791. return
  792. }
  793. res.InfRefmsgid = res10265.InfRefmsgid
  794. res.Output = res10265.Output
  795. res.ErrMsg = res10265.ErrMsg
  796. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  797. res.Infcode = infocode
  798. } else {
  799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  800. utils.ErrorLog("解析失败:%v", err)
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. return
  803. }
  804. }
  805. }
  806. if res.Infcode == 0 {
  807. c.ServeSuccessJSON(map[string]interface{}{
  808. "result": res.Output.Result,
  809. })
  810. }
  811. }
  812. func (c *HisApiController) CheckInsutype() {
  813. his_patient_id, _ := c.GetInt64("his_patient_id")
  814. admin_user_id, _ := c.GetInt64("admin_user_id")
  815. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  816. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  817. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  818. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  819. var dat map[string]interface{}
  820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  821. fmt.Println(dat)
  822. } else {
  823. fmt.Println(err)
  824. }
  825. userJSONBytes, _ := json.Marshal(dat)
  826. var res Result90100
  827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  828. utils.ErrorLog("解析失败:%v", err)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return
  831. }
  832. if res.Infcode != 0 {
  833. c.ServeSuccessJSON(map[string]interface{}{
  834. "failed_code": -10,
  835. "msg": res.ErrMsg,
  836. })
  837. return
  838. } else {
  839. fmt.Println(res)
  840. }
  841. }
  842. func (c *HisApiController) CheckCardPWD() {
  843. card_pwd := c.GetString("card_pwd")
  844. his_patient_id, _ := c.GetInt64("his_patient_id")
  845. admin_user_id, _ := c.GetInt64("admin_user_id")
  846. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  847. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  848. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  849. psn, _ := service.GetPsnByPatientId(his.PatientId)
  850. bas := strings.Split(psn.CardInfo, "|")
  851. basNumber := bas[2]
  852. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  853. var dat map[string]interface{}
  854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  855. fmt.Println(dat)
  856. } else {
  857. fmt.Println(err)
  858. }
  859. userJSONBytes, _ := json.Marshal(dat)
  860. var res Result90991
  861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  862. utils.ErrorLog("解析失败:%v", err)
  863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  864. return
  865. }
  866. if res.Infcode != 0 {
  867. c.ServeSuccessJSON(map[string]interface{}{
  868. "failed_code": -10,
  869. "msg": res.ErrMsg,
  870. })
  871. return
  872. } else {
  873. if res.Output.Result.SscnoCheckStat == "0" {
  874. var msg string
  875. switch res.Output.Result.CardStat {
  876. case "00":
  877. msg = "未激活"
  878. break
  879. case "10":
  880. msg = "激活"
  881. break
  882. case "20":
  883. msg = "窗口挂失"
  884. break
  885. case "21":
  886. msg = "电话挂失"
  887. break
  888. case "22":
  889. msg = "单位网上申报挂失"
  890. break
  891. case "23":
  892. msg = "保健办挂失"
  893. break
  894. case "24":
  895. msg = "个人网上挂失"
  896. break
  897. case "25":
  898. msg = "网上服务大厅挂失"
  899. break
  900. case "30":
  901. msg = "注销"
  902. break
  903. case "40":
  904. msg = "回收"
  905. break
  906. case "99":
  907. msg = "制卡中(无效卡)"
  908. break
  909. }
  910. c.ServeSuccessJSON(map[string]interface{}{
  911. "failed_code": -10,
  912. "msg": msg,
  913. })
  914. return
  915. } else {
  916. c.ServeSuccessJSON(map[string]interface{}{
  917. "msg": "校验成功",
  918. })
  919. return
  920. }
  921. }
  922. }
  923. func (c *HisApiController) CheckCardPWDTwo() {
  924. //card_pwd := c.GetString("card_pwd")
  925. //his_patient_id, _ := c.GetInt64("his_patient_id")
  926. admin_user_id, _ := c.GetInt64("admin_user_id")
  927. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  929. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  930. var dat map[string]interface{}
  931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  932. fmt.Println(dat)
  933. } else {
  934. fmt.Println(err)
  935. }
  936. userJSONBytes, _ := json.Marshal(dat)
  937. var res Result90991
  938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. if res.Infcode != 0 {
  944. c.ServeSuccessJSON(map[string]interface{}{
  945. "failed_code": -10,
  946. "msg": res.ErrMsg,
  947. })
  948. return
  949. } else {
  950. if res.Output.Result.SscnoCheckStat == "0" {
  951. var msg string
  952. switch res.Output.Result.CardStat {
  953. case "00":
  954. msg = "未激活"
  955. break
  956. case "10":
  957. msg = "激活"
  958. break
  959. case "20":
  960. msg = "窗口挂失"
  961. break
  962. case "21":
  963. msg = "电话挂失"
  964. break
  965. case "22":
  966. msg = "单位网上申报挂失"
  967. break
  968. case "23":
  969. msg = "保健办挂失"
  970. break
  971. case "24":
  972. msg = "个人网上挂失"
  973. break
  974. case "25":
  975. msg = "网上服务大厅挂失"
  976. break
  977. case "30":
  978. msg = "注销"
  979. break
  980. case "40":
  981. msg = "回收"
  982. break
  983. case "99":
  984. msg = "制卡中(无效卡)"
  985. break
  986. }
  987. c.ServeSuccessJSON(map[string]interface{}{
  988. "failed_code": -10,
  989. "msg": msg,
  990. })
  991. return
  992. } else {
  993. c.ServeSuccessJSON(map[string]interface{}{
  994. "msg": "校验成功",
  995. })
  996. return
  997. }
  998. }
  999. }
  1000. type ELeCertData struct {
  1001. Data struct {
  1002. Extra string `json:"extra"`
  1003. IDNo string `json:"idNo"`
  1004. IDType string `json:"idType"`
  1005. EcToken string `json:"ecToken"`
  1006. InsuOrg string `json:"insuOrg"`
  1007. UserName string `json:"userName"`
  1008. EcIndexNo string `json:"ecIndexNo"`
  1009. Gender string `json:"gender"`
  1010. Birthday string `json:"birthday"`
  1011. Nationality string `json:"nationality"`
  1012. Email string `json:"email"`
  1013. } `json:"OutData"`
  1014. }
  1015. func (c *HisApiController) ReadCard() {
  1016. id_card_type, _ := c.GetInt64("id_card_type")
  1017. admin_user_id, _ := c.GetInt64("admin_user_id")
  1018. certificates, _ := c.GetInt64("certificates")
  1019. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1020. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1021. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1022. switch id_card_type {
  1023. case 1:
  1024. if miConfig.MdtrtareaAdmvs == "421300" {
  1025. var res ResultTwo
  1026. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1027. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1028. "&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)
  1029. resp, requestErr := http.Get(api)
  1030. if requestErr != nil {
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. return
  1033. }
  1034. body, ioErr := ioutil.ReadAll(resp.Body)
  1035. if ioErr != nil {
  1036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. var respJSON map[string]interface{}
  1041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1044. return
  1045. }
  1046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1047. result, _ := json.Marshal(respJSON)
  1048. fmt.Println("log")
  1049. fmt.Println(string(result))
  1050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1051. utils.ErrorLog("解析失败:%v", err)
  1052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1053. return
  1054. }
  1055. if res.Infcode == 0 {
  1056. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1057. if err == gorm.ErrRecordNotFound {
  1058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1059. return
  1060. } else if err != nil {
  1061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1062. return
  1063. } else {
  1064. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1065. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1066. infoStr := string(Iinfos)
  1067. idetinfoStr := string(Idetinfos)
  1068. psn := &models.HisPsn{
  1069. PsnNo: res.Output.Baseinfo.PsnNo,
  1070. Age: res.Output.Baseinfo.Age,
  1071. PatientId: patient.ID,
  1072. Certno: res.Output.Baseinfo.Certno,
  1073. Brdy: res.Output.Baseinfo.Brdy,
  1074. Gend: res.Output.Baseinfo.Gend,
  1075. Naty: res.Output.Baseinfo.Naty,
  1076. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1077. PsnName: res.Output.Baseinfo.PsnName,
  1078. Idetinfo: idetinfoStr,
  1079. Insuinfo: infoStr,
  1080. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1081. }
  1082. service.CreateHisPsn(psn)
  1083. c.ServeSuccessJSON(map[string]interface{}{
  1084. "patient": patient,
  1085. "number": res.Output.Baseinfo.Certno,
  1086. })
  1087. }
  1088. } else {
  1089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1090. return
  1091. }
  1092. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1093. var api string
  1094. if miConfig.MdtrtareaAdmvs == "320921" {
  1095. 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 +
  1096. "&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
  1097. fmt.Println(api)
  1098. } else {
  1099. 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 +
  1100. "&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)
  1101. }
  1102. resp, requestErr := http.Get(api)
  1103. if requestErr != nil {
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1105. return
  1106. }
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1111. return
  1112. }
  1113. var respJSON map[string]interface{}
  1114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1117. return
  1118. }
  1119. var status string
  1120. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1121. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1122. //console.log()
  1123. fmt.Println("type===")
  1124. fmt.Println(card_type)
  1125. var token string
  1126. var res ResultTwo //1101结果
  1127. var res10265 ResultTwo10265 //1101结果
  1128. var card_info string //卡信息
  1129. var busi_card_info string
  1130. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1131. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1132. if status == "0" { //读卡成功
  1133. if card_type == "1" {
  1134. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1135. result, _ := json.Marshal(respJSON)
  1136. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. res.ErrMsg = res10265.ErrMsg
  1142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1143. res.Infcode = infocode
  1144. res.Output = res10265.Output
  1145. res.InfRefmsgid = res10265.InfRefmsgid
  1146. } else {
  1147. //var card_info string //卡信息
  1148. //var busi_card_info string
  1149. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1150. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1151. //fmt.Println(card_info)
  1152. //fmt.Println(busi_card_info)
  1153. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1154. result, _ := json.Marshal(respJSON)
  1155. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1156. utils.ErrorLog("解析失败:%v", err)
  1157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1158. return
  1159. }
  1160. res.ErrMsg = res10265.ErrMsg
  1161. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1162. res.Infcode = infocode
  1163. res.Output = res10265.Output
  1164. res.InfRefmsgid = res10265.InfRefmsgid
  1165. }
  1166. if res.Infcode == 0 {
  1167. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1168. if err == gorm.ErrRecordNotFound {
  1169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1170. return
  1171. } else if err != nil {
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1173. return
  1174. } else {
  1175. if card_type == "1" {
  1176. bas := strings.Split(card_info, "|")
  1177. basNumber := bas[2]
  1178. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1179. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1180. infoStr := string(Iinfos)
  1181. idetinfoStr := string(Idetinfos)
  1182. psn := &models.HisPsn{
  1183. PsnNo: res.Output.Baseinfo.PsnNo,
  1184. Age: res.Output.Baseinfo.Age,
  1185. PatientId: patient.ID,
  1186. Certno: res.Output.Baseinfo.Certno,
  1187. Brdy: res.Output.Baseinfo.Brdy,
  1188. Gend: res.Output.Baseinfo.Gend,
  1189. Naty: res.Output.Baseinfo.Naty,
  1190. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1191. PsnName: res.Output.Baseinfo.PsnName,
  1192. Idetinfo: idetinfoStr,
  1193. Insuinfo: infoStr,
  1194. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1195. CardInfo: card_info,
  1196. VerifyNumber: busi_card_info,
  1197. }
  1198. service.CreateHisPsn(psn)
  1199. var rf []*ResultFive
  1200. json.Unmarshal([]byte(infoStr), &rf)
  1201. var insutypes []*ResultFive
  1202. var insutype string
  1203. var is390 int = 0
  1204. var is310 int = 0
  1205. for _, item := range rf {
  1206. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1207. insutypes = append(insutypes, item)
  1208. }
  1209. }
  1210. if len(insutypes) == 1 {
  1211. insutype = insutypes[0].Insutype
  1212. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1213. } else {
  1214. for _, i := range insutypes {
  1215. if i.Insutype == "390" {
  1216. is390 = 1
  1217. }
  1218. if i.Insutype == "310" {
  1219. is310 = 1
  1220. }
  1221. }
  1222. }
  1223. if is390 == 1 {
  1224. insutype = "390"
  1225. }
  1226. if is310 == 1 {
  1227. insutype = "310"
  1228. }
  1229. if len(insutypes) == 0 {
  1230. insutype = "310"
  1231. }
  1232. c.ServeSuccessJSON(map[string]interface{}{
  1233. "patient": patient,
  1234. "number": basNumber,
  1235. "insutype": insutype,
  1236. })
  1237. } else {
  1238. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1239. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1240. infoStr := string(Iinfos)
  1241. idetinfoStr := string(Idetinfos)
  1242. psn := &models.HisPsn{
  1243. PsnNo: res.Output.Baseinfo.PsnNo,
  1244. Age: res.Output.Baseinfo.Age,
  1245. PatientId: patient.ID,
  1246. Certno: res.Output.Baseinfo.Certno,
  1247. Brdy: res.Output.Baseinfo.Brdy,
  1248. Gend: res.Output.Baseinfo.Gend,
  1249. Naty: res.Output.Baseinfo.Naty,
  1250. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1251. PsnName: res.Output.Baseinfo.PsnName,
  1252. Idetinfo: idetinfoStr,
  1253. Insuinfo: infoStr,
  1254. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1255. CardInfo: card_info,
  1256. VerifyNumber: token,
  1257. }
  1258. service.CreateHisPsn(psn)
  1259. c.ServeSuccessJSON(map[string]interface{}{
  1260. "patient": patient,
  1261. "number": token,
  1262. })
  1263. }
  1264. }
  1265. } else {
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1267. return
  1268. }
  1269. } else { //读卡失败
  1270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1271. return
  1272. }
  1273. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1274. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1275. cardnum = DeleteExtraSpaceTwo(cardnum)
  1276. cardCode = DeleteExtraSpaceTwo(cardCode)
  1277. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1278. name = DeleteExtraSpaceTwo(name)
  1279. errmsg = DeleteExtraSpaceTwo(errmsg)
  1280. cardnum = Remove0000(cardnum)
  1281. cardCode = Remove0000(cardCode)
  1282. id_card_no = Remove0000(id_card_no)
  1283. name = Remove0000(name)
  1284. errmsg = Remove0000(errmsg)
  1285. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1286. 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)
  1287. saveLog(result, requestLog, "1101", "获取人员信息")
  1288. fmt.Println(errMsgLog)
  1289. if len(errMsgLog) > 0 {
  1290. } else {
  1291. var dat map[string]interface{}
  1292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1293. fmt.Println(dat)
  1294. } else {
  1295. fmt.Println(err)
  1296. }
  1297. userJSONBytes, _ := json.Marshal(dat)
  1298. var res ResultTwo
  1299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1300. utils.ErrorLog("解析失败:%v", err)
  1301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1302. return
  1303. }
  1304. res.ErrMsg = errMsgLog
  1305. if res.Infcode == 0 {
  1306. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1307. if err == gorm.ErrRecordNotFound {
  1308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1309. return
  1310. } else if err != nil {
  1311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1312. return
  1313. } else {
  1314. fmt.Println(res)
  1315. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1316. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1317. infoStr := string(Iinfos)
  1318. idetinfoStr := string(Idetinfos)
  1319. psn := &models.HisPsn{
  1320. PsnNo: res.Output.Baseinfo.PsnNo,
  1321. Age: res.Output.Baseinfo.Age,
  1322. PatientId: patient.ID,
  1323. Certno: res.Output.Baseinfo.Certno,
  1324. Brdy: res.Output.Baseinfo.Brdy,
  1325. Gend: res.Output.Baseinfo.Gend,
  1326. Naty: res.Output.Baseinfo.Naty,
  1327. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1328. PsnName: res.Output.Baseinfo.PsnName,
  1329. Idetinfo: idetinfoStr,
  1330. Insuinfo: infoStr,
  1331. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1332. CardInfo: basStr,
  1333. VerifyNumber: "",
  1334. }
  1335. service.CreateHisPsn(psn)
  1336. var rf []*ResultFive
  1337. json.Unmarshal([]byte(infoStr), &rf)
  1338. var insutypes []*ResultFive
  1339. var insutype string
  1340. var is390 int = 0
  1341. var is310 int = 0
  1342. for _, item := range rf {
  1343. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1344. insutypes = append(insutypes, item)
  1345. }
  1346. }
  1347. if len(insutypes) == 1 {
  1348. insutype = insutypes[0].Insutype
  1349. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1350. } else {
  1351. for _, i := range insutypes {
  1352. if i.Insutype == "390" {
  1353. is390 = 1
  1354. }
  1355. if i.Insutype == "310" {
  1356. is310 = 1
  1357. }
  1358. }
  1359. }
  1360. if is390 == 1 {
  1361. insutype = "390"
  1362. }
  1363. if is310 == 1 {
  1364. insutype = "310"
  1365. }
  1366. if len(insutypes) == 0 {
  1367. insutype = "310"
  1368. }
  1369. c.ServeSuccessJSON(map[string]interface{}{
  1370. "patient": patient,
  1371. "number": cardnum,
  1372. "insutype": insutype,
  1373. })
  1374. }
  1375. } else {
  1376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1377. return
  1378. }
  1379. }
  1380. } else {
  1381. if initFlag == 0 {
  1382. c.TestGetBasBaseInit()
  1383. }
  1384. basStr := c.GetBasBaseInfo()
  1385. if len(basStr) == 0 {
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1387. return
  1388. }
  1389. fmt.Println(basStr)
  1390. bas := strings.Split(basStr, "|")
  1391. basNumber := bas[1]
  1392. fmt.Println(basNumber)
  1393. card_sn := bas[3]
  1394. fmt.Println(card_sn)
  1395. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1396. var dat map[string]interface{}
  1397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1398. fmt.Println(dat)
  1399. } else {
  1400. fmt.Println(err)
  1401. }
  1402. userJSONBytes, _ := json.Marshal(dat)
  1403. var res ResultTwo
  1404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1405. utils.ErrorLog("解析失败:%v", err)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. return
  1408. }
  1409. if res.Infcode == 0 {
  1410. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1411. if err == gorm.ErrRecordNotFound {
  1412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1413. return
  1414. } else if err != nil {
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1416. return
  1417. } else {
  1418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1420. infoStr := string(Iinfos)
  1421. idetinfoStr := string(Idetinfos)
  1422. psn := &models.HisPsn{
  1423. PsnNo: res.Output.Baseinfo.PsnNo,
  1424. Age: res.Output.Baseinfo.Age,
  1425. PatientId: patient.ID,
  1426. Certno: res.Output.Baseinfo.Certno,
  1427. Brdy: res.Output.Baseinfo.Brdy,
  1428. Gend: res.Output.Baseinfo.Gend,
  1429. Naty: res.Output.Baseinfo.Naty,
  1430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1431. PsnName: res.Output.Baseinfo.PsnName,
  1432. Idetinfo: idetinfoStr,
  1433. Insuinfo: infoStr,
  1434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1435. CardInfo: basStr,
  1436. VerifyNumber: "",
  1437. }
  1438. service.CreateHisPsn(psn)
  1439. c.ServeSuccessJSON(map[string]interface{}{
  1440. "patient": patient,
  1441. "number": basNumber,
  1442. })
  1443. }
  1444. } else {
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1446. return
  1447. }
  1448. break
  1449. }
  1450. case 2:
  1451. SFZStr := c.GetSFZBaseInfo()
  1452. id_card_str := strings.Split(SFZStr, "^")
  1453. id_card_number := id_card_str[0]
  1454. card_sn := ""
  1455. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1456. var dat map[string]interface{}
  1457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1458. fmt.Println(dat)
  1459. } else {
  1460. fmt.Println(err)
  1461. }
  1462. userJSONBytes, _ := json.Marshal(dat)
  1463. var res ResultTwo
  1464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1465. utils.ErrorLog("解析失败:%v", err)
  1466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1467. return
  1468. }
  1469. if res.Infcode == 0 {
  1470. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1471. if err == gorm.ErrRecordNotFound {
  1472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1473. return
  1474. } else if err != nil {
  1475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1476. return
  1477. } else {
  1478. c.ServeSuccessJSON(map[string]interface{}{
  1479. "patient": patient,
  1480. "number": id_card_number,
  1481. })
  1482. }
  1483. } else {
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1485. return
  1486. }
  1487. break
  1488. case 3:
  1489. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1490. var api string
  1491. if miConfig.MdtrtareaAdmvs == "320921" {
  1492. 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 +
  1493. "&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
  1494. fmt.Println(api)
  1495. } else {
  1496. 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 +
  1497. "&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)
  1498. }
  1499. resp, requestErr := http.Get(api)
  1500. if requestErr != nil {
  1501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1502. return
  1503. }
  1504. body, ioErr := ioutil.ReadAll(resp.Body)
  1505. if ioErr != nil {
  1506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1508. return
  1509. }
  1510. var respJSON map[string]interface{}
  1511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1514. return
  1515. }
  1516. var status string
  1517. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1518. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1519. var token string
  1520. var res ResultTwo //1101结果
  1521. var res10265 ResultTwo10265 //1101结果
  1522. var card_info string //卡信息
  1523. var busi_card_info string
  1524. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1525. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1526. if status == "0" { //读卡成功
  1527. if card_type == "1" {
  1528. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1529. result, _ := json.Marshal(respJSON)
  1530. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1531. utils.ErrorLog("解析失败:%v", err)
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. return
  1534. }
  1535. res.ErrMsg = res10265.ErrMsg
  1536. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1537. res.Infcode = infocode
  1538. res.Output = res10265.Output
  1539. res.InfRefmsgid = res10265.InfRefmsgid
  1540. } else {
  1541. //var card_info string //卡信息
  1542. //var busi_card_info string
  1543. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1544. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1545. //fmt.Println(card_info)
  1546. //fmt.Println(busi_card_info)
  1547. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1548. result, _ := json.Marshal(respJSON)
  1549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1550. utils.ErrorLog("解析失败:%v", err)
  1551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1552. return
  1553. }
  1554. res.ErrMsg = res10265.ErrMsg
  1555. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1556. res.Infcode = infocode
  1557. res.Output = res10265.Output
  1558. res.InfRefmsgid = res10265.InfRefmsgid
  1559. }
  1560. if res.Infcode == 0 {
  1561. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1562. if err == gorm.ErrRecordNotFound {
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1564. return
  1565. } else if err != nil {
  1566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1567. return
  1568. } else {
  1569. if card_type == "1" {
  1570. bas := strings.Split(card_info, "|")
  1571. basNumber := bas[2]
  1572. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1573. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1574. infoStr := string(Iinfos)
  1575. idetinfoStr := string(Idetinfos)
  1576. psn := &models.HisPsn{
  1577. PsnNo: res.Output.Baseinfo.PsnNo,
  1578. Age: res.Output.Baseinfo.Age,
  1579. PatientId: patient.ID,
  1580. Certno: res.Output.Baseinfo.Certno,
  1581. Brdy: res.Output.Baseinfo.Brdy,
  1582. Gend: res.Output.Baseinfo.Gend,
  1583. Naty: res.Output.Baseinfo.Naty,
  1584. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1585. PsnName: res.Output.Baseinfo.PsnName,
  1586. Idetinfo: idetinfoStr,
  1587. Insuinfo: infoStr,
  1588. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1589. CardInfo: card_info,
  1590. VerifyNumber: busi_card_info,
  1591. }
  1592. service.CreateHisPsn(psn)
  1593. c.ServeSuccessJSON(map[string]interface{}{
  1594. "patient": patient,
  1595. "number": basNumber,
  1596. })
  1597. } else {
  1598. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1599. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1600. infoStr := string(Iinfos)
  1601. idetinfoStr := string(Idetinfos)
  1602. psn := &models.HisPsn{
  1603. PsnNo: res.Output.Baseinfo.PsnNo,
  1604. Age: res.Output.Baseinfo.Age,
  1605. PatientId: patient.ID,
  1606. Certno: res.Output.Baseinfo.Certno,
  1607. Brdy: res.Output.Baseinfo.Brdy,
  1608. Gend: res.Output.Baseinfo.Gend,
  1609. Naty: res.Output.Baseinfo.Naty,
  1610. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1611. PsnName: res.Output.Baseinfo.PsnName,
  1612. Idetinfo: idetinfoStr,
  1613. Insuinfo: infoStr,
  1614. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1615. CardInfo: card_info,
  1616. VerifyNumber: token,
  1617. }
  1618. service.CreateHisPsn(psn)
  1619. var rf []*ResultFive
  1620. json.Unmarshal([]byte(infoStr), &rf)
  1621. var insutypes []*ResultFive
  1622. var insutype string
  1623. var is390 int = 0
  1624. var is310 int = 0
  1625. for _, item := range rf {
  1626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1627. insutypes = append(insutypes, item)
  1628. }
  1629. }
  1630. if len(insutypes) == 1 {
  1631. insutype = insutypes[0].Insutype
  1632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1633. } else {
  1634. for _, i := range insutypes {
  1635. if i.Insutype == "390" {
  1636. is390 = 1
  1637. }
  1638. if i.Insutype == "310" {
  1639. is310 = 1
  1640. }
  1641. }
  1642. }
  1643. if is390 == 1 {
  1644. insutype = "390"
  1645. }
  1646. if is310 == 1 {
  1647. insutype = "310"
  1648. }
  1649. if len(insutypes) == 0 {
  1650. insutype = "310"
  1651. }
  1652. c.ServeSuccessJSON(map[string]interface{}{
  1653. "patient": patient,
  1654. "number": token,
  1655. "insutype": insutype,
  1656. })
  1657. }
  1658. }
  1659. } else {
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1661. return
  1662. }
  1663. } else { //读卡失败
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1665. return
  1666. }
  1667. }
  1668. break
  1669. case 4:
  1670. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1671. var api string
  1672. if miConfig.MdtrtareaAdmvs == "320921" {
  1673. 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 +
  1674. "&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
  1675. fmt.Println(api)
  1676. } else {
  1677. 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 +
  1678. "&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)
  1679. }
  1680. resp, requestErr := http.Get(api)
  1681. if requestErr != nil {
  1682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1683. return
  1684. }
  1685. body, ioErr := ioutil.ReadAll(resp.Body)
  1686. if ioErr != nil {
  1687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1689. return
  1690. }
  1691. var respJSON map[string]interface{}
  1692. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1695. return
  1696. }
  1697. var status string
  1698. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1699. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1700. var token string
  1701. var res ResultTwo //1101结果
  1702. var res10265 ResultTwo10265 //1101结果
  1703. if status == "0" { //读卡成功
  1704. var card_info string //卡信息
  1705. var busi_card_info string
  1706. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1707. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1708. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1709. fmt.Println(card_info)
  1710. fmt.Println(busi_card_info)
  1711. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1712. result, _ := json.Marshal(respJSON)
  1713. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1714. utils.ErrorLog("解析失败:%v", err)
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1716. return
  1717. }
  1718. res.ErrMsg = res10265.ErrMsg
  1719. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1720. res.Infcode = infocode
  1721. res.Output = res10265.Output
  1722. res.InfRefmsgid = res10265.InfRefmsgid
  1723. if res.Infcode == 0 {
  1724. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1725. if err == gorm.ErrRecordNotFound {
  1726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1727. return
  1728. } else if err != nil {
  1729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1730. return
  1731. } else {
  1732. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1733. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1734. infoStr := string(Iinfos)
  1735. idetinfoStr := string(Idetinfos)
  1736. psn := &models.HisPsn{
  1737. PsnNo: res.Output.Baseinfo.PsnNo,
  1738. Age: res.Output.Baseinfo.Age,
  1739. PatientId: patient.ID,
  1740. Certno: res.Output.Baseinfo.Certno,
  1741. Brdy: res.Output.Baseinfo.Brdy,
  1742. Gend: res.Output.Baseinfo.Gend,
  1743. Naty: res.Output.Baseinfo.Naty,
  1744. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1745. PsnName: res.Output.Baseinfo.PsnName,
  1746. Idetinfo: idetinfoStr,
  1747. Insuinfo: infoStr,
  1748. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1749. CardInfo: card_info,
  1750. VerifyNumber: token,
  1751. }
  1752. service.CreateHisPsn(psn)
  1753. c.ServeSuccessJSON(map[string]interface{}{
  1754. "patient": patient,
  1755. "number": token,
  1756. })
  1757. }
  1758. } else {
  1759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1760. return
  1761. }
  1762. } else { //读卡失败
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1764. return
  1765. }
  1766. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1767. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1768. saveLog(result, requestLog, "6101", "电子凭证")
  1769. var ele ELeCertData
  1770. err := json.Unmarshal([]byte(result), &ele)
  1771. if err != nil {
  1772. utils.ErrorLog("解析失败:%v", err)
  1773. }
  1774. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  1775. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1776. var res ResultTwo
  1777. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1778. utils.ErrorLog("解析失败:%v", err)
  1779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1780. return
  1781. }
  1782. if res.Infcode == 0 {
  1783. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  1784. if err == gorm.ErrRecordNotFound {
  1785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1786. return
  1787. } else if err != nil {
  1788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1789. return
  1790. } else {
  1791. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1792. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1793. infoStr := string(Iinfos)
  1794. idetinfoStr := string(Idetinfos)
  1795. psn := &models.HisPsn{
  1796. PsnNo: res.Output.Baseinfo.PsnNo,
  1797. Age: res.Output.Baseinfo.Age,
  1798. PatientId: patient.ID,
  1799. Certno: res.Output.Baseinfo.Certno,
  1800. Brdy: res.Output.Baseinfo.Brdy,
  1801. Gend: res.Output.Baseinfo.Gend,
  1802. Naty: res.Output.Baseinfo.Naty,
  1803. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1804. PsnName: res.Output.Baseinfo.PsnName,
  1805. Idetinfo: idetinfoStr,
  1806. Insuinfo: infoStr,
  1807. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1808. CardInfo: "",
  1809. VerifyNumber: ele.Data.EcToken,
  1810. }
  1811. service.CreateHisPsn(psn)
  1812. c.ServeSuccessJSON(map[string]interface{}{
  1813. "patient": patient,
  1814. "number": ele.Data.EcToken,
  1815. })
  1816. }
  1817. } else {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1819. return
  1820. }
  1821. }
  1822. break
  1823. }
  1824. }
  1825. var initFlag int64 = 0
  1826. func (c *HisApiController) TestGetBasBaseInit() {
  1827. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1828. Iinit := DllDef.MustFindProc("Init")
  1829. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1830. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1831. if ret != 0 {
  1832. fmt.Println("SSCard的报错原因:", err)
  1833. fmt.Println("SSCard的运算结果为:", ret)
  1834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1835. return
  1836. }
  1837. result := int(ret)
  1838. fmt.Println("SSCard的运算结果为1:", result)
  1839. initFlag = 1
  1840. return
  1841. }
  1842. func (c *HisApiController) GetSFZBaseInfo() string {
  1843. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1844. readCard := DllDef.MustFindProc("ReadSFZ")
  1845. if readCard == nil {
  1846. fmt.Println("readcard is nil")
  1847. readCard = DllDef.MustFindProc("ReadSFZ")
  1848. }
  1849. str := make([]byte, 256)
  1850. str1 := make([]byte, 256)
  1851. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1852. fmt.Println(r)
  1853. return string(str)
  1854. }
  1855. func (c *HisApiController) GetBasBaseInfo() string {
  1856. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1857. readCard := DllDef.MustFindProc("ReadCardBas")
  1858. if readCard == nil {
  1859. fmt.Println("readcard is nil")
  1860. readCard = DllDef.MustFindProc("ReadCardBas")
  1861. }
  1862. str := make([]byte, 1024)
  1863. str1 := make([]byte, 1024)
  1864. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1865. fmt.Println(string(str1))
  1866. fmt.Println(string(str))
  1867. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1868. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1869. if ret2 != 0 {
  1870. return ""
  1871. }
  1872. return string(str)
  1873. }
  1874. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1875. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1876. readCard := DllDef.MustFindProc("read_cardinfo")
  1877. if readCard == nil {
  1878. fmt.Println("readcard is nil")
  1879. readCard = DllDef.MustFindProc("read_cardinfo")
  1880. }
  1881. str := make([]byte, 1024) //卡号
  1882. str1 := make([]byte, 1024) //卡识别码
  1883. str2 := make([]byte, 1024) //身份证号
  1884. str3 := make([]byte, 1024) //姓名
  1885. str4 := make([]byte, 1024) //错误信息
  1886. 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])))
  1887. fmt.Println(string(str1))
  1888. fmt.Println(string(str))
  1889. fmt.Println(string(str2))
  1890. fmt.Println(string(str3))
  1891. fmt.Println(string(str4))
  1892. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1893. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1894. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1895. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1896. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1897. if ret2 != 0 {
  1898. return "", "", "", "", ""
  1899. }
  1900. return string(str), string(str1), string(str2), string(str3), string(str4)
  1901. }
  1902. type CustomFundPay struct {
  1903. FundPayType string `json:"fund_pay_type"`
  1904. FundPayamt float64 `json:"fund_payamt"`
  1905. }
  1906. func (c *HisApiController) GetSettleList() {
  1907. order_id, _ := c.GetInt64("order_id")
  1908. admin_user_id, _ := c.GetInt64("admin_user_id")
  1909. order, _ := service.GetHisOrderByIDTwo(order_id)
  1910. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1911. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1912. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1913. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1914. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1915. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1916. if order.ID == 0 {
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1918. return
  1919. }
  1920. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1921. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1922. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1923. fmt.Println(count)
  1924. var zero string
  1925. number := count + 1
  1926. if number >= 1000 {
  1927. zero = "0000" + strconv.FormatInt(number, 10)
  1928. } else if number >= 10000 {
  1929. zero = "000" + strconv.FormatInt(number, 10)
  1930. } else if number >= 100000 {
  1931. zero = "00" + strconv.FormatInt(number, 10)
  1932. } else if number >= 1000000 {
  1933. zero = "0" + strconv.FormatInt(number, 10)
  1934. } else {
  1935. zero = strconv.FormatInt(number, 10)
  1936. }
  1937. fmt.Println(zero)
  1938. struct4101 := service.Struct4101{
  1939. PsnNo: order.PsnNo,
  1940. MdtrtId: order.MdtrtId,
  1941. SetlId: order.SetlId,
  1942. PsnName: order.PsnName,
  1943. Gend: order.Gend,
  1944. Brdy: his.Brdy,
  1945. Age: his.Age,
  1946. Naty: order.Naty,
  1947. PatnCertType: "01",
  1948. Certno: order.Certno,
  1949. Prfs: "90",
  1950. ConerName: roles[0].UserName,
  1951. PatnRlts: "99",
  1952. ConerAddr: miConfig.OrgName,
  1953. ConerTel: admin.Mobile,
  1954. HiType: order.Insutype,
  1955. Insuplc: miConfig.InsuplcAdmdvs,
  1956. MaindiagFlag: "1",
  1957. BillCode: last_order.FaPiaoCode,
  1958. BillNo: zero,
  1959. BizSn: order.Number,
  1960. PsnSelfPay: order.PsnPartAmt,
  1961. PsnOwnPay: order.PsnPartAmt,
  1962. AcctPay: order.AcctPay,
  1963. PsnCashpay: order.PsnCashPay,
  1964. HiPaymtd: "1",
  1965. Hsorg: miConfig.InsuplcAdmdvs,
  1966. HsorgOpter: miConfig.InsuplcAdmdvs,
  1967. MedinsFillPsn: curRoles.UserName,
  1968. MedinsFillDept: depart.Name,
  1969. IptMedType: "2",
  1970. }
  1971. struct4101.SetlBegnDate = order.SetlTime
  1972. struct4101.SetlEndDate = order.SetlTime
  1973. time_arr := strings.Split(order.SetlTime, " ")
  1974. struct4101.AdmTime = time_arr[0]
  1975. struct4101.AdmEndTime = time_arr[0]
  1976. var rf []CustomFundPay
  1977. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1978. var tempFunPays []service.CustomStruct
  1979. for _, item := range rf {
  1980. var tempFunPay service.CustomStruct
  1981. tempFunPay.FundPayamt = item.FundPayamt
  1982. tempFunPay.FundPayType = item.FundPayType
  1983. tempFunPays = append(tempFunPays, tempFunPay)
  1984. }
  1985. struct4101.CustomStruct = tempFunPays
  1986. var tempDiaginfos []service.DiaginfoStructTwo
  1987. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1988. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1989. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1990. var config []*models.HisXtDiagnoseConfig
  1991. for _, item := range diagnosis_ids {
  1992. id, _ := strconv.ParseInt(item, 10, 64)
  1993. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1994. config = append(config, &diagnosisConfig)
  1995. }
  1996. for index, item := range config {
  1997. if index == 0 {
  1998. var tempDiaginfo service.DiaginfoStructTwo
  1999. tempDiaginfo.DiagCode = item.CountryCode
  2000. tempDiaginfo.DiagName = item.CountryContentName
  2001. tempDiaginfo.DiagType = "1"
  2002. tempDiaginfo.MaindiagFlag = "1"
  2003. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2004. } else {
  2005. var tempDiaginfo service.DiaginfoStructTwo
  2006. tempDiaginfo.DiagCode = item.CountryCode
  2007. tempDiaginfo.DiagName = item.CountryContentName
  2008. tempDiaginfo.DiagType = "2"
  2009. tempDiaginfo.MaindiagFlag = "0"
  2010. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2011. }
  2012. }
  2013. struct4101.Diseinfo = tempDiaginfos
  2014. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2015. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2016. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2017. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2018. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2019. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2020. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2021. var iteminfo service.IteminfoStruct
  2022. var bedCostTotal float64 = 0 //床位总费
  2023. var bedCostSelfTotal float64 = 0 //床位自费
  2024. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2025. var operationCostTotal float64 = 0 //手术费
  2026. var operationCostSelfTotal float64 = 0 //手术费
  2027. var operationCostPartSelfTotal float64 = 0 //手术费
  2028. var otherCostTotal float64 = 0 //其他费用
  2029. var otherCostSelfTotal float64 = 0 //其他费用
  2030. var otherCostPartSelfTotal float64 = 0 //其他费用
  2031. var materialCostTotal float64 = 0 //材料费
  2032. var materialCostSelfTotal float64 = 0 //材料费
  2033. var materialCostPartSelfTotal float64 = 0 //材料费
  2034. var westernMedicineCostTotal float64 = 0 //西药费
  2035. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2036. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2037. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2038. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2039. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2040. var checkCostTotal float64 = 0 //检查费
  2041. var checkCostSelfTotal float64 = 0 //检查费
  2042. var checkCostPartSelfTotal float64 = 0 //检查费
  2043. var laboratoryCostTotal float64 = 0 //化验费
  2044. var laboratoryCostSelfTotal float64 = 0 //化验费
  2045. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2046. var treatCostTotal float64 = 0 //治疗费用
  2047. var treatCostSelfTotal float64 = 0 //治疗费用
  2048. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2049. decimal.DivisionPrecision = 2
  2050. var bed_fulamt_ownpay_amt float64 = 0
  2051. var operation_fulamt_ownpay_amt float64 = 0
  2052. var other_fulamt_ownpay_amt float64 = 0
  2053. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2054. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2055. var check_fulamt_ownpay_amt float64 = 0
  2056. var material_fulamt_ownpay_amt float64 = 0
  2057. var laboratory_fulamt_ownpay_amt float64 = 0
  2058. var treat_fulamt_ownpay_amt float64 = 0
  2059. var bed_claa_sunmfee float64 = 0
  2060. var bed_clab_amt float64 = 0
  2061. var bed_other_amt float64 = 0
  2062. var operation_claa_sunmfee float64 = 0
  2063. var operation_clab_amt float64 = 0
  2064. var operation_other_amt float64 = 0
  2065. var other_claa_sunmfee float64 = 0
  2066. var other_clab_amt float64 = 0
  2067. var other_other_amt float64 = 0
  2068. var westernMedicine_claa_sunmfee float64 = 0
  2069. var westernMedicine_clab_amt float64 = 0
  2070. var westernMedicine_other_amt float64 = 0
  2071. var chineseTraditional_claa_sunmfee float64 = 0
  2072. var chineseTraditional_clab_amt float64 = 0
  2073. var chineseTraditional_other_amt float64 = 0
  2074. var check_claa_sunmfee float64 = 0
  2075. var check_clab_amt float64 = 0
  2076. var check_other_amt float64 = 0
  2077. var material_claa_sunmfee float64 = 0
  2078. var material_clab_amt float64 = 0
  2079. var material_other_amt float64 = 0
  2080. var laboratory_claa_sunmfee float64 = 0
  2081. var laboratory_clab_amt float64 = 0
  2082. var laboratory_other_amt float64 = 0
  2083. var treat_claa_sunmfee float64 = 0
  2084. var treat_clab_amt float64 = 0
  2085. var treat_other_amt float64 = 0
  2086. for _, item := range order.HisOrderInfo {
  2087. if item.MedChrgitmType == "01" { //床位费
  2088. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "03" { //检查费
  2103. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. if item.MedChrgitmType == "04" { //化验费
  2118. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2119. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2120. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2121. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2122. if item.ChrgitmLv == "1" {
  2123. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2124. }
  2125. if item.ChrgitmLv == "2" {
  2126. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2127. }
  2128. if item.ChrgitmLv == "3" {
  2129. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2130. }
  2131. }
  2132. if item.MedChrgitmType == "05" { //治疗费
  2133. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2134. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2135. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2136. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2137. if item.ChrgitmLv == "1" {
  2138. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2139. }
  2140. if item.ChrgitmLv == "2" {
  2141. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2142. }
  2143. if item.ChrgitmLv == "3" {
  2144. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2145. }
  2146. }
  2147. if item.MedChrgitmType == "06" { //手术费
  2148. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2149. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2150. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2151. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2152. if item.ChrgitmLv == "1" {
  2153. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2154. }
  2155. if item.ChrgitmLv == "2" {
  2156. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2157. }
  2158. if item.ChrgitmLv == "3" {
  2159. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2160. }
  2161. }
  2162. if item.MedChrgitmType == "08" { //材料费
  2163. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2164. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2165. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2166. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2167. if item.ChrgitmLv == "1" {
  2168. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2169. }
  2170. if item.ChrgitmLv == "2" {
  2171. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2172. }
  2173. if item.ChrgitmLv == "3" {
  2174. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2175. }
  2176. }
  2177. if item.MedChrgitmType == "09" { //西药费
  2178. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2179. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2180. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2181. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2182. if item.ChrgitmLv == "1" {
  2183. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2184. }
  2185. if item.ChrgitmLv == "2" {
  2186. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2187. }
  2188. if item.ChrgitmLv == "3" {
  2189. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2190. }
  2191. }
  2192. if item.MedChrgitmType == "11" { //中成费
  2193. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2194. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2195. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2196. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2197. if item.ChrgitmLv == "1" {
  2198. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2199. }
  2200. if item.ChrgitmLv == "2" {
  2201. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2202. }
  2203. if item.ChrgitmLv == "3" {
  2204. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2205. }
  2206. }
  2207. if item.MedChrgitmType == "14" { //其他费
  2208. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2209. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2210. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2211. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2212. if item.ChrgitmLv == "1" {
  2213. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2214. }
  2215. if item.ChrgitmLv == "2" {
  2216. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2217. }
  2218. if item.ChrgitmLv == "3" {
  2219. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2220. }
  2221. }
  2222. }
  2223. var iteminfoStructs []service.IteminfoStruct
  2224. if bedCostTotal != 0 {
  2225. iteminfo.MedChrgitm = "01"
  2226. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2227. iteminfo.Amt = bedCostTotal
  2228. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2229. iteminfo.ClabAmt = bed_clab_amt
  2230. iteminfo.OthAmt = bed_other_amt
  2231. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2232. }
  2233. if checkCostTotal != 0 {
  2234. iteminfo.MedChrgitm = "03"
  2235. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2236. iteminfo.Amt = checkCostTotal
  2237. iteminfo.ClaaSumfee = check_claa_sunmfee
  2238. iteminfo.ClabAmt = check_clab_amt
  2239. iteminfo.OthAmt = check_other_amt
  2240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2241. }
  2242. if laboratoryCostTotal != 0 {
  2243. iteminfo.MedChrgitm = "04"
  2244. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2245. iteminfo.Amt = laboratoryCostTotal
  2246. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2247. iteminfo.ClabAmt = laboratory_clab_amt
  2248. iteminfo.OthAmt = laboratory_other_amt
  2249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2250. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2251. }
  2252. if treatCostTotal != 0 {
  2253. iteminfo.MedChrgitm = "05"
  2254. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2255. iteminfo.Amt = treatCostTotal
  2256. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2257. iteminfo.ClabAmt = treat_clab_amt
  2258. iteminfo.OthAmt = treat_other_amt
  2259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2260. //(struct4101.IteminfoStruct, iteminfo)
  2261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2262. }
  2263. if operationCostTotal != 0 {
  2264. iteminfo.MedChrgitm = "06"
  2265. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2266. iteminfo.Amt = operationCostTotal
  2267. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2268. iteminfo.ClabAmt = operation_clab_amt
  2269. iteminfo.OthAmt = operation_other_amt
  2270. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2271. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2272. }
  2273. if materialCostTotal != 0 {
  2274. iteminfo.MedChrgitm = "08"
  2275. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2276. iteminfo.Amt = materialCostTotal
  2277. iteminfo.ClaaSumfee = material_claa_sunmfee
  2278. iteminfo.ClabAmt = material_clab_amt
  2279. iteminfo.OthAmt = material_other_amt
  2280. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2281. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2282. }
  2283. if westernMedicineCostTotal != 0 {
  2284. iteminfo.MedChrgitm = "09"
  2285. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2286. iteminfo.Amt = westernMedicineCostTotal
  2287. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2288. iteminfo.ClabAmt = westernMedicine_clab_amt
  2289. iteminfo.OthAmt = westernMedicine_other_amt
  2290. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2291. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2292. }
  2293. if chineseTraditionalMedicineCostTotal != 0 {
  2294. iteminfo.MedChrgitm = "11"
  2295. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2296. iteminfo.Amt = westernMedicineCostTotal
  2297. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2298. iteminfo.ClabAmt = westernMedicine_clab_amt
  2299. iteminfo.OthAmt = westernMedicine_other_amt
  2300. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2301. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2302. }
  2303. if otherCostTotal != 0 {
  2304. iteminfo.MedChrgitm = "14"
  2305. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2306. iteminfo.Amt = otherCostTotal
  2307. iteminfo.ClaaSumfee = other_claa_sunmfee
  2308. iteminfo.ClabAmt = other_clab_amt
  2309. iteminfo.OthAmt = other_other_amt
  2310. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2311. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2312. }
  2313. struct4101.IteminfoStruct = iteminfoStructs
  2314. struct4101.Ntly = "中国"
  2315. struct4101.AdmCaty = "A03.06"
  2316. var res ResultSeventeen
  2317. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2318. var resOther ResultSeventeenOther
  2319. var pp models.PublicParams
  2320. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2321. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2322. pp.FixmedinsName = miConfig.OrgName
  2323. pp.FixmedinsCode = miConfig.Code
  2324. pp.RequestUrl = miConfig.Url
  2325. pp.Cainfo = miConfig.Cainfo
  2326. pp.SecretKey = miConfig.SecretKey
  2327. pp.AccessKey = miConfig.AccessKey
  2328. pp.OpterName = curRoles.UserName
  2329. client := &http.Client{}
  2330. var req *http.Request
  2331. data := make(map[string]interface{})
  2332. data["struct4101"] = struct4101
  2333. data["pp"] = pp
  2334. bytesData, _ := json.Marshal(data)
  2335. if miConfig.MdtrtareaAdmvs == "320921" {
  2336. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2337. } else {
  2338. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2339. }
  2340. resp, _ := client.Do(req)
  2341. defer resp.Body.Close()
  2342. body, ioErr := ioutil.ReadAll(resp.Body)
  2343. if ioErr != nil {
  2344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2346. return
  2347. }
  2348. var respJSON map[string]interface{}
  2349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2352. return
  2353. }
  2354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2355. userJSONBytes, _ := json.Marshal(respJSON)
  2356. fmt.Println("log")
  2357. fmt.Println(string(userJSONBytes))
  2358. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2359. utils.ErrorLog("解析失败:%v", err)
  2360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. return
  2362. }
  2363. res.InfRefmsgid = resOther.InfRefmsgid
  2364. res.Output = resOther.Output
  2365. res.ErrMsg = resOther.ErrMsg
  2366. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2367. res.Infcode = infocode
  2368. } else {
  2369. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2370. var dat map[string]interface{}
  2371. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2372. fmt.Println(dat)
  2373. } else {
  2374. fmt.Println(err)
  2375. }
  2376. userJSONBytes, _ := json.Marshal(dat)
  2377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2378. utils.ErrorLog("解析失败:%v", err)
  2379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. return
  2381. }
  2382. }
  2383. if res.Infcode != 0 {
  2384. c.ServeSuccessJSON(map[string]interface{}{
  2385. "failed_code": -10,
  2386. "msg": res.ErrMsg,
  2387. })
  2388. return
  2389. } else {
  2390. order.FaPiaoNumber = zero
  2391. order.FaPiaoCode = last_order.FaPiaoCode
  2392. service.UpdateOrder(order)
  2393. hisFundSettleListResult := &models.HisFundSettleListResult{
  2394. Number: res.Output.SetlListId,
  2395. Status: 1,
  2396. Ctime: time.Now().Unix(),
  2397. Mtime: time.Now().Unix(),
  2398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2399. IsUpload: 1,
  2400. OrderId: order_id,
  2401. }
  2402. service.CreateUploadRecord(hisFundSettleListResult)
  2403. c.ServeSuccessJSON(map[string]interface{}{
  2404. "msg": "上传成功",
  2405. "result": hisFundSettleListResult,
  2406. })
  2407. return
  2408. }
  2409. }
  2410. func (c *HisApiController) GetSettleListHospital() {
  2411. order_id, _ := c.GetInt64("order_id")
  2412. admin_user_id, _ := c.GetInt64("admin_user_id")
  2413. order, _ := service.GetHisOrderByIDTwo(order_id)
  2414. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2415. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2416. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2417. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2418. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2419. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2420. if order.ID == 0 {
  2421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2422. return
  2423. }
  2424. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2425. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2426. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2427. fmt.Println(count)
  2428. var zero string
  2429. number := count + 1
  2430. if number >= 1000 {
  2431. zero = "0000" + strconv.FormatInt(number, 10)
  2432. } else if number >= 10000 {
  2433. zero = "000" + strconv.FormatInt(number, 10)
  2434. } else if number >= 100000 {
  2435. zero = "00" + strconv.FormatInt(number, 10)
  2436. } else if number >= 1000000 {
  2437. zero = "0" + strconv.FormatInt(number, 10)
  2438. } else {
  2439. zero = strconv.FormatInt(number, 10)
  2440. }
  2441. fmt.Println(zero)
  2442. struct4101 := service.Struct4101{
  2443. PsnNo: order.PsnNo,
  2444. MdtrtId: order.MdtrtId,
  2445. SetlId: order.SetlId,
  2446. PsnName: order.PsnName,
  2447. Gend: order.Gend,
  2448. Brdy: his.Brdy,
  2449. Age: int64(order.Age),
  2450. Naty: order.Naty,
  2451. PatnCertType: "01",
  2452. Certno: order.Certno,
  2453. Prfs: "90",
  2454. ConerName: roles[0].UserName,
  2455. PatnRlts: "99",
  2456. ConerAddr: miConfig.OrgName,
  2457. ConerTel: admin.Mobile,
  2458. HiType: order.Insutype,
  2459. Insuplc: miConfig.InsuplcAdmdvs,
  2460. MaindiagFlag: "1",
  2461. BillCode: last_order.FaPiaoCode,
  2462. BillNo: zero,
  2463. BizSn: order.Number,
  2464. PsnSelfPay: order.PsnPartAmt,
  2465. PsnOwnPay: order.PsnPartAmt,
  2466. AcctPay: order.AcctPay,
  2467. PsnCashpay: order.PsnCashPay,
  2468. HiPaymtd: "1",
  2469. Hsorg: miConfig.InsuplcAdmdvs,
  2470. HsorgOpter: miConfig.InsuplcAdmdvs,
  2471. MedinsFillPsn: curRoles.UserName,
  2472. MedinsFillDept: depart.Name,
  2473. IptMedType: "2",
  2474. AdmTime: his.InHosptialTime,
  2475. AdmEndTime: his.OutHosptialTime,
  2476. }
  2477. struct4101.SetlBegnDate = order.SetlTime
  2478. struct4101.SetlEndDate = order.SetlTime
  2479. var rf []CustomFundPay
  2480. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2481. var tempFunPays []service.CustomStruct
  2482. for _, item := range rf {
  2483. var tempFunPay service.CustomStruct
  2484. tempFunPay.FundPayamt = item.FundPayamt
  2485. tempFunPay.FundPayType = item.FundPayType
  2486. tempFunPays = append(tempFunPays, tempFunPay)
  2487. }
  2488. struct4101.CustomStruct = tempFunPays
  2489. var tempDiaginfos []service.DiaginfoStructTwo
  2490. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2491. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2492. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2493. var config []*models.HisXtDiagnoseConfig
  2494. for _, item := range diagnosis_ids {
  2495. id, _ := strconv.ParseInt(item, 10, 64)
  2496. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2497. config = append(config, &diagnosisConfig)
  2498. }
  2499. for index, item := range config {
  2500. if index == 0 {
  2501. var tempDiaginfo service.DiaginfoStructTwo
  2502. tempDiaginfo.DiagCode = item.CountryCode
  2503. tempDiaginfo.DiagName = item.CountryContentName
  2504. tempDiaginfo.DiagType = "1"
  2505. tempDiaginfo.MaindiagFlag = "1"
  2506. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2507. } else {
  2508. var tempDiaginfo service.DiaginfoStructTwo
  2509. tempDiaginfo.DiagCode = item.CountryCode
  2510. tempDiaginfo.DiagName = item.CountryContentName
  2511. tempDiaginfo.DiagType = "2"
  2512. tempDiaginfo.MaindiagFlag = "0"
  2513. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2514. }
  2515. }
  2516. struct4101.Diseinfo = tempDiaginfos
  2517. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2518. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2519. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2520. tempOpspdiseinfo2.OprnOprtCode = ""
  2521. tempOpspdiseinfo2.OprnOprtName = ""
  2522. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2523. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2524. var iteminfo service.IteminfoStruct
  2525. var bedCostTotal float64 = 0 //床位总费
  2526. var bedCostSelfTotal float64 = 0 //床位自费
  2527. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2528. var operationCostTotal float64 = 0 //手术费
  2529. var operationCostSelfTotal float64 = 0 //手术费
  2530. var operationCostPartSelfTotal float64 = 0 //手术费
  2531. var otherCostTotal float64 = 0 //其他费用
  2532. var otherCostSelfTotal float64 = 0 //其他费用
  2533. var otherCostPartSelfTotal float64 = 0 //其他费用
  2534. var materialCostTotal float64 = 0 //材料费
  2535. var materialCostSelfTotal float64 = 0 //材料费
  2536. var materialCostPartSelfTotal float64 = 0 //材料费
  2537. var westernMedicineCostTotal float64 = 0 //西药费
  2538. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2539. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2540. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2541. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2542. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2543. var checkCostTotal float64 = 0 //检查费
  2544. var checkCostSelfTotal float64 = 0 //检查费
  2545. var checkCostPartSelfTotal float64 = 0 //检查费
  2546. var laboratoryCostTotal float64 = 0 //化验费
  2547. var laboratoryCostSelfTotal float64 = 0 //化验费
  2548. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2549. var treatCostTotal float64 = 0 //治疗费用
  2550. var treatCostSelfTotal float64 = 0 //治疗费用
  2551. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2552. decimal.DivisionPrecision = 2
  2553. var bed_fulamt_ownpay_amt float64 = 0
  2554. var operation_fulamt_ownpay_amt float64 = 0
  2555. var other_fulamt_ownpay_amt float64 = 0
  2556. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2557. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2558. var check_fulamt_ownpay_amt float64 = 0
  2559. var material_fulamt_ownpay_amt float64 = 0
  2560. var laboratory_fulamt_ownpay_amt float64 = 0
  2561. var treat_fulamt_ownpay_amt float64 = 0
  2562. var bed_claa_sunmfee float64 = 0
  2563. var bed_clab_amt float64 = 0
  2564. var bed_other_amt float64 = 0
  2565. var operation_claa_sunmfee float64 = 0
  2566. var operation_clab_amt float64 = 0
  2567. var operation_other_amt float64 = 0
  2568. var other_claa_sunmfee float64 = 0
  2569. var other_clab_amt float64 = 0
  2570. var other_other_amt float64 = 0
  2571. var westernMedicine_claa_sunmfee float64 = 0
  2572. var westernMedicine_clab_amt float64 = 0
  2573. var westernMedicine_other_amt float64 = 0
  2574. var chineseTraditional_claa_sunmfee float64 = 0
  2575. var chineseTraditional_clab_amt float64 = 0
  2576. var chineseTraditional_other_amt float64 = 0
  2577. var check_claa_sunmfee float64 = 0
  2578. var check_clab_amt float64 = 0
  2579. var check_other_amt float64 = 0
  2580. var material_claa_sunmfee float64 = 0
  2581. var material_clab_amt float64 = 0
  2582. var material_other_amt float64 = 0
  2583. var laboratory_claa_sunmfee float64 = 0
  2584. var laboratory_clab_amt float64 = 0
  2585. var laboratory_other_amt float64 = 0
  2586. var treat_claa_sunmfee float64 = 0
  2587. var treat_clab_amt float64 = 0
  2588. var treat_other_amt float64 = 0
  2589. for _, item := range order.HisOrderInfo {
  2590. if item.MedChrgitmType == "01" { //床位费
  2591. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2592. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2593. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2594. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2595. if item.ChrgitmLv == "1" {
  2596. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2597. }
  2598. if item.ChrgitmLv == "2" {
  2599. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2600. }
  2601. if item.ChrgitmLv == "3" {
  2602. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2603. }
  2604. }
  2605. if item.MedChrgitmType == "03" { //检查费
  2606. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2607. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2608. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2609. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2610. if item.ChrgitmLv == "1" {
  2611. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2612. }
  2613. if item.ChrgitmLv == "2" {
  2614. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2615. }
  2616. if item.ChrgitmLv == "3" {
  2617. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2618. }
  2619. }
  2620. if item.MedChrgitmType == "04" { //化验费
  2621. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2622. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2623. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2624. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2625. if item.ChrgitmLv == "1" {
  2626. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2627. }
  2628. if item.ChrgitmLv == "2" {
  2629. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2630. }
  2631. if item.ChrgitmLv == "3" {
  2632. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2633. }
  2634. }
  2635. if item.MedChrgitmType == "05" { //治疗费
  2636. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2637. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2638. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2639. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2640. if item.ChrgitmLv == "1" {
  2641. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2642. }
  2643. if item.ChrgitmLv == "2" {
  2644. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2645. }
  2646. if item.ChrgitmLv == "3" {
  2647. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2648. }
  2649. }
  2650. if item.MedChrgitmType == "06" { //手术费
  2651. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2652. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2653. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2654. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2655. if item.ChrgitmLv == "1" {
  2656. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2657. }
  2658. if item.ChrgitmLv == "2" {
  2659. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2660. }
  2661. if item.ChrgitmLv == "3" {
  2662. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2663. }
  2664. }
  2665. if item.MedChrgitmType == "08" { //材料费
  2666. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2667. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2668. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2669. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2670. if item.ChrgitmLv == "1" {
  2671. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2672. }
  2673. if item.ChrgitmLv == "2" {
  2674. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2675. }
  2676. if item.ChrgitmLv == "3" {
  2677. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2678. }
  2679. }
  2680. if item.MedChrgitmType == "09" { //西药费
  2681. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2682. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2683. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2684. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2685. if item.ChrgitmLv == "1" {
  2686. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2687. }
  2688. if item.ChrgitmLv == "2" {
  2689. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2690. }
  2691. if item.ChrgitmLv == "3" {
  2692. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2693. }
  2694. }
  2695. if item.MedChrgitmType == "11" { //中成费
  2696. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2697. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2698. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2699. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2700. if item.ChrgitmLv == "1" {
  2701. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2702. }
  2703. if item.ChrgitmLv == "2" {
  2704. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2705. }
  2706. if item.ChrgitmLv == "3" {
  2707. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2708. }
  2709. }
  2710. if item.MedChrgitmType == "14" { //其他费
  2711. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2712. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2713. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2714. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2715. if item.ChrgitmLv == "1" {
  2716. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2717. }
  2718. if item.ChrgitmLv == "2" {
  2719. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2720. }
  2721. if item.ChrgitmLv == "3" {
  2722. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2723. }
  2724. }
  2725. }
  2726. var iteminfoStructs []service.IteminfoStruct
  2727. if bedCostTotal != 0 {
  2728. iteminfo.MedChrgitm = "01"
  2729. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2730. iteminfo.Amt = bedCostTotal
  2731. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2732. iteminfo.ClabAmt = bed_clab_amt
  2733. iteminfo.OthAmt = bed_other_amt
  2734. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2735. }
  2736. if checkCostTotal != 0 {
  2737. iteminfo.MedChrgitm = "03"
  2738. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2739. iteminfo.Amt = checkCostTotal
  2740. iteminfo.ClaaSumfee = check_claa_sunmfee
  2741. iteminfo.ClabAmt = check_clab_amt
  2742. iteminfo.OthAmt = check_other_amt
  2743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2744. }
  2745. if laboratoryCostTotal != 0 {
  2746. iteminfo.MedChrgitm = "04"
  2747. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2748. iteminfo.Amt = laboratoryCostTotal
  2749. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2750. iteminfo.ClabAmt = laboratory_clab_amt
  2751. iteminfo.OthAmt = laboratory_other_amt
  2752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2753. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2754. }
  2755. if treatCostTotal != 0 {
  2756. iteminfo.MedChrgitm = "05"
  2757. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2758. iteminfo.Amt = treatCostTotal
  2759. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2760. iteminfo.ClabAmt = treat_clab_amt
  2761. iteminfo.OthAmt = treat_other_amt
  2762. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2763. //(struct4101.IteminfoStruct, iteminfo)
  2764. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2765. }
  2766. if operationCostTotal != 0 {
  2767. iteminfo.MedChrgitm = "06"
  2768. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2769. iteminfo.Amt = operationCostTotal
  2770. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2771. iteminfo.ClabAmt = operation_clab_amt
  2772. iteminfo.OthAmt = operation_other_amt
  2773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2774. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2775. }
  2776. if materialCostTotal != 0 {
  2777. iteminfo.MedChrgitm = "08"
  2778. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2779. iteminfo.Amt = materialCostTotal
  2780. iteminfo.ClaaSumfee = material_claa_sunmfee
  2781. iteminfo.ClabAmt = material_clab_amt
  2782. iteminfo.OthAmt = material_other_amt
  2783. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2784. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2785. }
  2786. if westernMedicineCostTotal != 0 {
  2787. iteminfo.MedChrgitm = "09"
  2788. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2789. iteminfo.Amt = westernMedicineCostTotal
  2790. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2791. iteminfo.ClabAmt = westernMedicine_clab_amt
  2792. iteminfo.OthAmt = westernMedicine_other_amt
  2793. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2795. }
  2796. if chineseTraditionalMedicineCostTotal != 0 {
  2797. iteminfo.MedChrgitm = "11"
  2798. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2799. iteminfo.Amt = westernMedicineCostTotal
  2800. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2801. iteminfo.ClabAmt = westernMedicine_clab_amt
  2802. iteminfo.OthAmt = westernMedicine_other_amt
  2803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2805. }
  2806. if otherCostTotal != 0 {
  2807. iteminfo.MedChrgitm = "14"
  2808. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2809. iteminfo.Amt = otherCostTotal
  2810. iteminfo.ClaaSumfee = other_claa_sunmfee
  2811. iteminfo.ClabAmt = other_clab_amt
  2812. iteminfo.OthAmt = other_other_amt
  2813. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2814. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2815. }
  2816. struct4101.IteminfoStruct = iteminfoStructs
  2817. struct4101.Ntly = "中国"
  2818. struct4101.AdmCaty = "A03.06"
  2819. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2820. fmt.Println(result)
  2821. var dat map[string]interface{}
  2822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2823. fmt.Println(dat)
  2824. } else {
  2825. fmt.Println(err)
  2826. }
  2827. userJSONBytes, _ := json.Marshal(dat)
  2828. var res ResultSeventeen
  2829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2830. utils.ErrorLog("解析失败:%v", err)
  2831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2832. return
  2833. }
  2834. if res.Infcode != 0 {
  2835. c.ServeSuccessJSON(map[string]interface{}{
  2836. "failed_code": -10,
  2837. "msg": res.ErrMsg,
  2838. })
  2839. return
  2840. } else {
  2841. order.FaPiaoNumber = zero
  2842. order.FaPiaoCode = last_order.FaPiaoCode
  2843. service.UpdateOrder(order)
  2844. hisFundSettleListResult := &models.HisFundSettleListResult{
  2845. Number: res.Output.SetlListId,
  2846. Status: 1,
  2847. Ctime: time.Now().Unix(),
  2848. Mtime: time.Now().Unix(),
  2849. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2850. IsUpload: 1,
  2851. OrderId: order_id,
  2852. }
  2853. service.CreateUploadRecord(hisFundSettleListResult)
  2854. c.ServeSuccessJSON(map[string]interface{}{
  2855. "msg": "上传成功",
  2856. "result": hisFundSettleListResult,
  2857. })
  2858. return
  2859. }
  2860. }
  2861. func (c *HisApiController) GetBatchSettleList() {
  2862. orders, _ := service.GetAllHisOrder(10106)
  2863. for _, item := range orders {
  2864. order_id := item.ID
  2865. order, _ := service.GetHisOrderByIDTwo(order_id)
  2866. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2867. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2868. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2869. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2870. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2871. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2872. if order.ID == 0 {
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2874. return
  2875. }
  2876. if his.BalanceAccountsType == 2 {
  2877. continue
  2878. }
  2879. struct4101 := service.Struct4101{
  2880. PsnNo: order.PsnNo,
  2881. MdtrtId: order.MdtrtId,
  2882. SetlId: order.SetlId,
  2883. PsnName: order.PsnName,
  2884. Gend: order.Gend,
  2885. Brdy: his.Brdy,
  2886. Age: his.Age,
  2887. Naty: order.Naty,
  2888. PatnCertType: "01",
  2889. Certno: order.Certno,
  2890. Prfs: "90",
  2891. ConerName: roles[0].UserName,
  2892. PatnRlts: "99",
  2893. ConerAddr: miConfig.OrgName,
  2894. ConerTel: admin.Mobile,
  2895. HiType: order.Insutype,
  2896. Insuplc: his.InsuplcAdmdvs,
  2897. MaindiagFlag: "1",
  2898. BillCode: order.FaPiaoCode,
  2899. BillNo: order.FaPiaoNumber,
  2900. BizSn: order.Number,
  2901. PsnSelfPay: order.PsnPartAmt,
  2902. PsnOwnPay: order.PsnPartAmt,
  2903. AcctPay: order.AcctPay,
  2904. PsnCashpay: order.PsnCashPay,
  2905. HiPaymtd: "1",
  2906. Hsorg: his.InsuplcAdmdvs,
  2907. HsorgOpter: his.InsuplcAdmdvs,
  2908. MedinsFillPsn: curRoles.UserName,
  2909. MedinsFillDept: depart.Name,
  2910. IptMedType: "2",
  2911. }
  2912. struct4101.SetlBegnDate = order.SetlTime
  2913. struct4101.SetlEndDate = order.SetlTime
  2914. //if order.SettleType == 1 {
  2915. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2916. // dateStr := t.Format("2006-01-02")
  2917. // struct4101.SetlBegnDate = dateStr
  2918. // struct4101.SetlEndDate = dateStr
  2919. //} else {
  2920. // t := time.Unix(int64(order.SettleStartTime), 0)
  2921. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2922. // dateStartStr := t.Format("2006-01-02")
  2923. // dateEndStr := t2.Format("2006-01-02")
  2924. // struct4101.SetlBegnDate = dateStartStr
  2925. // struct4101.SetlEndDate = dateEndStr
  2926. //}
  2927. var rf []CustomFundPay
  2928. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2929. var tempFunPays []service.CustomStruct
  2930. var tempFunPay610100 service.CustomStruct
  2931. for _, item := range rf {
  2932. if item.FundPayType == "610100" {
  2933. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2934. tempFunPay610100.FundPayType = item.FundPayType
  2935. } else {
  2936. var tempFunPay service.CustomStruct
  2937. tempFunPay.FundPayamt = item.FundPayamt
  2938. tempFunPay.FundPayType = item.FundPayType
  2939. tempFunPays = append(tempFunPays, tempFunPay)
  2940. }
  2941. }
  2942. tempFunPays = append(tempFunPays, tempFunPay610100)
  2943. struct4101.CustomStruct = tempFunPays
  2944. var tempDiaginfos []service.DiaginfoStructTwo
  2945. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2946. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2947. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2948. var config []*models.HisXtDiagnoseConfig
  2949. for _, item := range diagnosis_ids {
  2950. id, _ := strconv.ParseInt(item, 10, 64)
  2951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2952. config = append(config, &diagnosisConfig)
  2953. }
  2954. for index, item := range config {
  2955. if index == 0 {
  2956. var tempDiaginfo service.DiaginfoStructTwo
  2957. tempDiaginfo.DiagCode = item.CountryCode
  2958. tempDiaginfo.DiagName = item.CountryContentName
  2959. tempDiaginfo.DiagType = "1"
  2960. tempDiaginfo.MaindiagFlag = "1"
  2961. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2962. } else {
  2963. var tempDiaginfo service.DiaginfoStructTwo
  2964. tempDiaginfo.DiagCode = item.CountryCode
  2965. tempDiaginfo.DiagName = item.CountryContentName
  2966. tempDiaginfo.DiagType = "2"
  2967. tempDiaginfo.MaindiagFlag = "0"
  2968. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2969. }
  2970. }
  2971. struct4101.Diseinfo = tempDiaginfos
  2972. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2973. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2974. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2975. tempOpspdiseinfo2.OprnOprtCode = ""
  2976. tempOpspdiseinfo2.OprnOprtName = ""
  2977. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2978. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2979. var iteminfo service.IteminfoStruct
  2980. var bedCostTotal float64 = 0 //床位总费
  2981. var bedCostSelfTotal float64 = 0 //床位自费
  2982. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2983. var examineCostTotal float64 = 0 //诊查总费
  2984. var examineCostSelfTotal float64 = 0 //诊查自费
  2985. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2986. var nursingCostTotal float64 = 0 //护理总费
  2987. var nursingCostSelfTotal float64 = 0 //护理自费
  2988. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2989. var chineseMedicineCostTotal float64 = 0 //中成药
  2990. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2991. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2992. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2993. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2994. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2995. var registerCostTotal float64 = 0 //一般诊疗费
  2996. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2997. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2998. var operationCostTotal float64 = 0 //手术费
  2999. var operationCostSelfTotal float64 = 0 //手术费
  3000. var operationCostPartSelfTotal float64 = 0 //手术费
  3001. var otherCostTotal float64 = 0 //其他费用
  3002. var otherCostSelfTotal float64 = 0 //其他费用
  3003. var otherCostPartSelfTotal float64 = 0 //其他费用
  3004. var materialCostTotal float64 = 0 //材料费
  3005. var materialCostSelfTotal float64 = 0 //材料费
  3006. var materialCostPartSelfTotal float64 = 0 //材料费
  3007. var westernMedicineCostTotal float64 = 0 //西药费
  3008. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3009. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3010. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3011. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3012. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3013. var checkCostTotal float64 = 0 //检查费
  3014. var checkCostSelfTotal float64 = 0 //检查费
  3015. var checkCostPartSelfTotal float64 = 0 //检查费
  3016. var laboratoryCostTotal float64 = 0 //化验费
  3017. var laboratoryCostSelfTotal float64 = 0 //化验费
  3018. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3019. var treatCostTotal float64 = 0 //治疗费用
  3020. var treatCostSelfTotal float64 = 0 //治疗费用
  3021. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3022. decimal.DivisionPrecision = 2
  3023. var bed_fulamt_ownpay_amt float64 = 0
  3024. var examine_fulamt_ownpay_amt float64 = 0
  3025. var nursing_fulamt_ownpay_amt float64 = 0
  3026. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3027. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3028. var register_fulamt_ownpay_amt float64 = 0
  3029. var operation_fulamt_ownpay_amt float64 = 0
  3030. var other_fulamt_ownpay_amt float64 = 0
  3031. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3032. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3033. var check_fulamt_ownpay_amt float64 = 0
  3034. var material_fulamt_ownpay_amt float64 = 0
  3035. var laboratory_fulamt_ownpay_amt float64 = 0
  3036. var treat_fulamt_ownpay_amt float64 = 0
  3037. var bed_claa_sunmfee float64 = 0
  3038. var bed_clab_amt float64 = 0
  3039. var bed_other_amt float64 = 0
  3040. var examine_claa_sunmfee float64 = 0
  3041. var examine_clab_amt float64 = 0
  3042. var examine_other_amt float64 = 0
  3043. var nursing_claa_sunmfee float64 = 0
  3044. var nursing_clab_amt float64 = 0
  3045. var nursing_other_amt float64 = 0
  3046. var chinese_medicine_claa_sunmfee float64 = 0
  3047. var chinese_medicine_clab_amt float64 = 0
  3048. var chinese_medicine_other_amt float64 = 0
  3049. var commonly_treatment_claa_sunmfee float64 = 0
  3050. var commonly_treatment_clab_amt float64 = 0
  3051. var commonly_treatment_other_amt float64 = 0
  3052. var operation_claa_sunmfee float64 = 0
  3053. var operation_clab_amt float64 = 0
  3054. var operation_other_amt float64 = 0
  3055. var other_claa_sunmfee float64 = 0
  3056. var other_clab_amt float64 = 0
  3057. var other_other_amt float64 = 0
  3058. var westernMedicine_claa_sunmfee float64 = 0
  3059. var westernMedicine_clab_amt float64 = 0
  3060. var westernMedicine_other_amt float64 = 0
  3061. var chineseTraditional_claa_sunmfee float64 = 0
  3062. var chineseTraditional_clab_amt float64 = 0
  3063. var chineseTraditional_other_amt float64 = 0
  3064. var check_claa_sunmfee float64 = 0
  3065. var check_clab_amt float64 = 0
  3066. var check_other_amt float64 = 0
  3067. var material_claa_sunmfee float64 = 0
  3068. var material_clab_amt float64 = 0
  3069. var material_other_amt float64 = 0
  3070. var laboratory_claa_sunmfee float64 = 0
  3071. var laboratory_clab_amt float64 = 0
  3072. var laboratory_other_amt float64 = 0
  3073. var treat_claa_sunmfee float64 = 0
  3074. var treat_clab_amt float64 = 0
  3075. var treat_other_amt float64 = 0
  3076. var register_claa_sunmfee float64 = 0
  3077. var register_clab_amt float64 = 0
  3078. var register_other_amt float64 = 0
  3079. for _, item := range order.HisOrderInfo {
  3080. if item.MedChrgitmType == "01" { //床位费
  3081. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3082. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3083. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3084. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3085. if item.ChrgitmLv == "1" {
  3086. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3087. }
  3088. if item.ChrgitmLv == "2" {
  3089. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3090. }
  3091. if item.ChrgitmLv == "3" {
  3092. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3093. }
  3094. }
  3095. if item.MedChrgitmType == "02" { //诊查
  3096. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3097. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3098. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3099. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3100. if item.ChrgitmLv == "1" {
  3101. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3102. }
  3103. if item.ChrgitmLv == "2" {
  3104. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3105. }
  3106. if item.ChrgitmLv == "3" {
  3107. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3108. }
  3109. }
  3110. if item.MedChrgitmType == "03" { //检查费
  3111. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3112. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3113. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3114. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3115. if item.ChrgitmLv == "1" {
  3116. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3117. }
  3118. if item.ChrgitmLv == "2" {
  3119. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3120. }
  3121. if item.ChrgitmLv == "3" {
  3122. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3123. }
  3124. }
  3125. if item.MedChrgitmType == "04" { //化验费
  3126. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3127. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3128. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3129. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3130. if item.ChrgitmLv == "1" {
  3131. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3132. }
  3133. if item.ChrgitmLv == "2" {
  3134. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3135. }
  3136. if item.ChrgitmLv == "3" {
  3137. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3138. }
  3139. }
  3140. if item.MedChrgitmType == "05" { //治疗费
  3141. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3142. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3143. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3144. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3145. if item.ChrgitmLv == "1" {
  3146. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3147. }
  3148. if item.ChrgitmLv == "2" {
  3149. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3150. }
  3151. if item.ChrgitmLv == "3" {
  3152. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3153. }
  3154. }
  3155. if item.MedChrgitmType == "06" { //手术费
  3156. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3157. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3158. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3159. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3160. if item.ChrgitmLv == "1" {
  3161. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3162. }
  3163. if item.ChrgitmLv == "2" {
  3164. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3165. }
  3166. if item.ChrgitmLv == "3" {
  3167. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3168. }
  3169. }
  3170. if item.MedChrgitmType == "07" { //手术费
  3171. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3172. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3173. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3174. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3175. if item.ChrgitmLv == "1" {
  3176. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3177. }
  3178. if item.ChrgitmLv == "2" {
  3179. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3180. }
  3181. if item.ChrgitmLv == "3" {
  3182. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3183. }
  3184. }
  3185. if item.MedChrgitmType == "08" { //材料费
  3186. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3187. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3188. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3189. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3190. if item.ChrgitmLv == "1" {
  3191. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3192. }
  3193. if item.ChrgitmLv == "2" {
  3194. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3195. }
  3196. if item.ChrgitmLv == "3" {
  3197. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3198. }
  3199. }
  3200. if item.MedChrgitmType == "09" { //西药费
  3201. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3202. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3203. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3204. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3205. if item.ChrgitmLv == "1" {
  3206. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3207. }
  3208. if item.ChrgitmLv == "2" {
  3209. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3210. }
  3211. if item.ChrgitmLv == "3" {
  3212. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3213. }
  3214. }
  3215. if item.MedChrgitmType == "10" { //中药饮片
  3216. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3217. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3218. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3219. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3220. if item.ChrgitmLv == "1" {
  3221. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3222. }
  3223. if item.ChrgitmLv == "2" {
  3224. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3225. }
  3226. if item.ChrgitmLv == "3" {
  3227. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3228. }
  3229. }
  3230. if item.MedChrgitmType == "11" { //中成费
  3231. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3232. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3233. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3234. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3235. if item.ChrgitmLv == "1" {
  3236. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3237. }
  3238. if item.ChrgitmLv == "2" {
  3239. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3240. }
  3241. if item.ChrgitmLv == "3" {
  3242. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3243. }
  3244. }
  3245. if item.MedChrgitmType == "12" { //中成费
  3246. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3247. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3248. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3249. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3250. if item.ChrgitmLv == "1" {
  3251. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3252. }
  3253. if item.ChrgitmLv == "2" {
  3254. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3255. }
  3256. if item.ChrgitmLv == "3" {
  3257. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3258. }
  3259. }
  3260. if item.MedChrgitmType == "13" { //中成费
  3261. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3262. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3263. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3264. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3265. if item.ChrgitmLv == "1" {
  3266. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3267. }
  3268. if item.ChrgitmLv == "2" {
  3269. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3270. }
  3271. if item.ChrgitmLv == "3" {
  3272. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3273. }
  3274. }
  3275. if item.MedChrgitmType == "14" { //其他费
  3276. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3277. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3278. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3279. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3280. if item.ChrgitmLv == "1" {
  3281. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3282. }
  3283. if item.ChrgitmLv == "2" {
  3284. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3285. }
  3286. if item.ChrgitmLv == "3" {
  3287. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3288. }
  3289. }
  3290. }
  3291. var iteminfoStructs []service.IteminfoStruct
  3292. if bedCostTotal != 0 {
  3293. iteminfo.MedChrgitm = "01"
  3294. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3295. iteminfo.Amt = bedCostTotal
  3296. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3297. iteminfo.ClabAmt = bed_clab_amt
  3298. iteminfo.OthAmt = bed_other_amt
  3299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3300. }
  3301. if examineCostTotal != 0 {
  3302. iteminfo.MedChrgitm = "02"
  3303. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3304. iteminfo.Amt = examineCostTotal
  3305. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3306. iteminfo.ClabAmt = examine_clab_amt
  3307. iteminfo.OthAmt = examine_other_amt
  3308. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3310. }
  3311. if checkCostTotal != 0 {
  3312. iteminfo.MedChrgitm = "03"
  3313. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3314. iteminfo.Amt = checkCostTotal
  3315. iteminfo.ClaaSumfee = check_claa_sunmfee
  3316. iteminfo.ClabAmt = check_clab_amt
  3317. iteminfo.OthAmt = check_other_amt
  3318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3319. }
  3320. if laboratoryCostTotal != 0 {
  3321. iteminfo.MedChrgitm = "04"
  3322. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3323. iteminfo.Amt = laboratoryCostTotal
  3324. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3325. iteminfo.ClabAmt = laboratory_clab_amt
  3326. iteminfo.OthAmt = laboratory_other_amt
  3327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3328. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3329. }
  3330. if treatCostTotal != 0 {
  3331. iteminfo.MedChrgitm = "05"
  3332. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3333. iteminfo.Amt = treatCostTotal
  3334. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3335. iteminfo.ClabAmt = treat_clab_amt
  3336. iteminfo.OthAmt = treat_other_amt
  3337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3338. //(struct4101.IteminfoStruct, iteminfo)
  3339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3340. }
  3341. if operationCostTotal != 0 {
  3342. iteminfo.MedChrgitm = "06"
  3343. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3344. iteminfo.Amt = operationCostTotal
  3345. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3346. iteminfo.ClabAmt = operation_clab_amt
  3347. iteminfo.OthAmt = operation_other_amt
  3348. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3349. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3350. }
  3351. if nursingCostTotal != 0 {
  3352. iteminfo.MedChrgitm = "07"
  3353. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3354. iteminfo.Amt = nursingCostTotal
  3355. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3356. iteminfo.ClabAmt = nursing_clab_amt
  3357. iteminfo.OthAmt = nursing_other_amt
  3358. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3359. }
  3360. if materialCostTotal != 0 {
  3361. iteminfo.MedChrgitm = "08"
  3362. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3363. iteminfo.Amt = materialCostTotal
  3364. iteminfo.ClaaSumfee = material_claa_sunmfee
  3365. iteminfo.ClabAmt = material_clab_amt
  3366. iteminfo.OthAmt = material_other_amt
  3367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3369. }
  3370. if westernMedicineCostTotal != 0 {
  3371. iteminfo.MedChrgitm = "09"
  3372. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3373. iteminfo.Amt = westernMedicineCostTotal
  3374. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3375. iteminfo.ClabAmt = westernMedicine_clab_amt
  3376. iteminfo.OthAmt = westernMedicine_other_amt
  3377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3379. }
  3380. if chineseMedicineCostTotal != 0 {
  3381. iteminfo.MedChrgitm = "10"
  3382. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3383. iteminfo.Amt = chineseMedicineCostTotal
  3384. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3385. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3386. iteminfo.OthAmt = chinese_medicine_other_amt
  3387. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3388. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3389. }
  3390. if chineseTraditionalMedicineCostTotal != 0 {
  3391. iteminfo.MedChrgitm = "11"
  3392. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3393. iteminfo.Amt = westernMedicineCostTotal
  3394. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3395. iteminfo.ClabAmt = westernMedicine_clab_amt
  3396. iteminfo.OthAmt = westernMedicine_other_amt
  3397. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3398. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3399. }
  3400. if commonlyTreatmentCostTotal != 0 {
  3401. iteminfo.MedChrgitm = "12"
  3402. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3403. iteminfo.Amt = commonlyTreatmentCostTotal
  3404. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3405. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3406. iteminfo.OthAmt = commonly_treatment_other_amt
  3407. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3408. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3409. }
  3410. if registerCostTotal != 0 {
  3411. iteminfo.MedChrgitm = "13"
  3412. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3413. iteminfo.Amt = registerCostTotal
  3414. iteminfo.ClaaSumfee = register_claa_sunmfee
  3415. iteminfo.ClabAmt = register_clab_amt
  3416. iteminfo.OthAmt = register_other_amt
  3417. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3418. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3419. }
  3420. if otherCostTotal != 0 {
  3421. iteminfo.MedChrgitm = "14"
  3422. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3423. iteminfo.Amt = otherCostTotal
  3424. iteminfo.ClaaSumfee = other_claa_sunmfee
  3425. iteminfo.ClabAmt = other_clab_amt
  3426. iteminfo.OthAmt = other_other_amt
  3427. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3428. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3429. }
  3430. struct4101.IteminfoStruct = iteminfoStructs
  3431. struct4101.Ntly = "中国"
  3432. struct4101.AdmCaty = "A03.06"
  3433. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3434. fmt.Println(result)
  3435. var dat map[string]interface{}
  3436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3437. fmt.Println(dat)
  3438. } else {
  3439. fmt.Println(err)
  3440. }
  3441. userJSONBytes, _ := json.Marshal(dat)
  3442. var res ResultSeventeen
  3443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3444. utils.ErrorLog("解析失败:%v", err)
  3445. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3446. adminUser := c.GetAdminUserInfo()
  3447. errlog := &models.HisOrderError{
  3448. UserOrgId: adminUser.CurrentOrgId,
  3449. Ctime: time.Now().Unix(),
  3450. Mtime: time.Now().Unix(),
  3451. ErrMsg: res.ErrMsg + "解析失败",
  3452. Status: 1,
  3453. PatientId: order_id,
  3454. Stage: 10106,
  3455. }
  3456. service.CreateErrMsgLog(errlog)
  3457. continue
  3458. }
  3459. if res.Infcode != 0 {
  3460. adminUser := c.GetAdminUserInfo()
  3461. errlog := &models.HisOrderError{
  3462. UserOrgId: adminUser.CurrentOrgId,
  3463. Ctime: time.Now().Unix(),
  3464. Mtime: time.Now().Unix(),
  3465. ErrMsg: res.ErrMsg,
  3466. Status: 1,
  3467. PatientId: order_id,
  3468. Stage: 10106,
  3469. }
  3470. service.CreateErrMsgLog(errlog)
  3471. continue
  3472. } else {
  3473. hisFundSettleListResult := &models.HisFundSettleListResult{
  3474. Number: res.Output.SetlListId,
  3475. Status: 1,
  3476. Ctime: time.Now().Unix(),
  3477. Mtime: time.Now().Unix(),
  3478. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3479. IsUpload: 1,
  3480. OrderId: order_id,
  3481. }
  3482. service.CreateUploadRecord(hisFundSettleListResult)
  3483. continue
  3484. }
  3485. }
  3486. }
  3487. func (c *HisApiController) GetOrgInfo() {
  3488. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3489. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3490. }
  3491. func (c *HisApiController) GetHisPatientInfo() {
  3492. medical_insurance_card := c.GetString("medical_insurance_card")
  3493. id_card_type, _ := c.GetInt64("id_card_type")
  3494. id_card := c.GetString("id_card")
  3495. adminInfo := c.GetAdminUserInfo()
  3496. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3497. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3498. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3499. IdCardNo := ""
  3500. if id_card_type == 1 {
  3501. IdCardNo = medical_insurance_card
  3502. } else if id_card_type == 2 {
  3503. IdCardNo = id_card
  3504. }
  3505. if config.IsOpen == 1 {
  3506. 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
  3507. resp, requestErr := http.Get(api)
  3508. if requestErr != nil {
  3509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3510. return
  3511. }
  3512. defer resp.Body.Close()
  3513. body, ioErr := ioutil.ReadAll(resp.Body)
  3514. if ioErr != nil {
  3515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3517. return
  3518. }
  3519. var respJSON map[string]interface{}
  3520. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3523. return
  3524. }
  3525. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3526. userJSONBytes, _ := json.Marshal(userJSON)
  3527. var res ResultTwo
  3528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3529. utils.ErrorLog("解析失败:%v", err)
  3530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3531. return
  3532. }
  3533. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3534. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3535. infoStr := string(Iinfos)
  3536. idetinfoStr := string(Idetinfos)
  3537. if res.Infcode == 0 {
  3538. his := models.VMHisPatient{
  3539. Status: 1,
  3540. Ctime: time.Now().Unix(),
  3541. Mtime: time.Now().Unix(),
  3542. PsnNo: res.Output.Baseinfo.PsnNo,
  3543. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3544. Certno: res.Output.Baseinfo.Certno,
  3545. PsnName: res.Output.Baseinfo.PsnName,
  3546. Gend: res.Output.Baseinfo.Gend,
  3547. Naty: res.Output.Baseinfo.Naty,
  3548. Brdy: res.Output.Baseinfo.Brdy,
  3549. Age: res.Output.Baseinfo.Age,
  3550. Iinfo: infoStr,
  3551. Idetinfo: idetinfoStr,
  3552. UserOrgId: adminInfo.CurrentOrgId,
  3553. IsReturn: 1,
  3554. IdCardType: id_card_type,
  3555. }
  3556. c.ServeSuccessJSON(map[string]interface{}{
  3557. "info": his,
  3558. })
  3559. } else {
  3560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3561. return
  3562. }
  3563. }
  3564. }
  3565. //func GetBasBaseInfo() (jsonStr string, err error) {
  3566. //
  3567. // handle := syscall.NewLazyDLL("SSCard.dll")
  3568. // add := handle.NewProc("ReadCardBas")
  3569. // str := make([]byte, 1024)
  3570. // str1 := make([]byte, 1024)
  3571. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3572. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3573. //
  3574. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3575. //
  3576. // fmt.Println("> Add(4,5)的结果为:", ret)
  3577. // handle.Release()
  3578. //
  3579. // return "", nil
  3580. //
  3581. //}
  3582. //func GetQRBaseInfo() (jsonStr string, err error) {
  3583. // handle := syscall.LoadDLL("SSCard.dll")
  3584. // ReadCardBas := handle.FindProc("GetQRBase")
  3585. //
  3586. // str := make([]byte, 256)
  3587. // str1 := make([]byte, 256)
  3588. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3589. //
  3590. // fmt.Println(string(str))
  3591. // fmt.Println(r)
  3592. // return string(str), nil
  3593. //}
  3594. //func CardInit() int {
  3595. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3596. // add := DllTestDef.MustFindProc("Init")
  3597. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3598. // if err != nil {
  3599. // fmt.Println("SSCard的运算结果为:", ret)
  3600. // }
  3601. // result := int(ret)
  3602. // return result
  3603. //}
  3604. //func CardInit() int {
  3605. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3606. // if err != nil {
  3607. // fmt.Println("SSCard的运算结果为:", ret)
  3608. // }
  3609. // fmt.Println(err)
  3610. // result := int(ret)
  3611. // return result
  3612. //}
  3613. func IntPtr(n int) uintptr {
  3614. return uintptr(n)
  3615. }
  3616. func StrPtr(s string) uintptr {
  3617. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3618. }
  3619. type Result2001 struct {
  3620. Cainfo interface{} `json:"cainfo"`
  3621. ErrMsg string `json:"err_msg"`
  3622. InfRefmsgid string `json:"inf_refmsgid"`
  3623. Infcode int64 `json:"infcode"`
  3624. Output struct {
  3625. Trtinfo struct {
  3626. PsnNo string `json:"psn_no"`
  3627. TrtChkType string `json:"trt_chk_type"`
  3628. FundPayType string `json:"fund_pay_type"`
  3629. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3630. Begndate string `json:"begndate"`
  3631. Enddate string `json:"enddate"`
  3632. TrtChkRslt string `json:"trt_chk_rslt"`
  3633. } `json:"trtinfo"`
  3634. } `json:"output"`
  3635. RefmsgTime string `json:"refmsg_time"`
  3636. RespondTime string `json:"respond_time"`
  3637. Signtype interface{} `json:"signtype"`
  3638. WarnMsg interface{} `json:"warn_msg"`
  3639. }
  3640. type Result2001Org10265 struct {
  3641. Cainfo interface{} `json:"cainfo"`
  3642. ErrMsg string `json:"err_msg"`
  3643. InfRefmsgid string `json:"inf_refmsgid"`
  3644. Infcode string `json:"infcode"`
  3645. Output struct {
  3646. Trtinfo struct {
  3647. PsnNo string `json:"psn_no"`
  3648. TrtChkType string `json:"trt_chk_type"`
  3649. FundPayType string `json:"fund_pay_type"`
  3650. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3651. Begndate string `json:"begndate"`
  3652. Enddate string `json:"enddate"`
  3653. TrtChkRslt string `json:"trt_chk_rslt"`
  3654. } `json:"trtinfo"`
  3655. } `json:"output"`
  3656. RefmsgTime string `json:"refmsg_time"`
  3657. RespondTime string `json:"respond_time"`
  3658. Signtype interface{} `json:"signtype"`
  3659. WarnMsg interface{} `json:"warn_msg"`
  3660. }
  3661. type ResultTwo struct {
  3662. ErrMsg string `json:"err_msg"`
  3663. InfRefmsgid string `json:"inf_refmsgid"`
  3664. Infcode int64 `json:"infcode"`
  3665. Output struct {
  3666. Baseinfo struct {
  3667. Age float64 `json:"age"`
  3668. Brdy string `json:"brdy"`
  3669. Certno string `json:"certno"`
  3670. Gend string `json:"gend"`
  3671. Naty string `json:"naty"`
  3672. PsnCertType string `json:"psn_cert_type"`
  3673. PsnName string `json:"psn_name"`
  3674. PsnNo string `json:"psn_no"`
  3675. } `json:"baseinfo"`
  3676. Idetinfo []interface{} `json:"idetinfo"`
  3677. Iinfo []struct {
  3678. Balc float64 `json:"balc"`
  3679. CvlservFlag string `json:"cvlserv_flag"`
  3680. EmpName string `json:"emp_name"`
  3681. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3682. Insutype string `json:"insutype"`
  3683. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3684. PausInsuDate string `json:"paus_insu_date"`
  3685. PsnInsuDate string `json:"psn_insu_date"`
  3686. PsnInsuStas string `json:"psn_insu_stas"`
  3687. PsnType string `json:"psn_type"`
  3688. } `json:"insuinfo"`
  3689. } `json:"output"`
  3690. RefmsgTime string `json:"refmsg_time"`
  3691. RespondTime string `json:"respond_time"`
  3692. Signtype interface{} `json:"signtype"`
  3693. WarnInfo interface{} `json:"warn_info"`
  3694. }
  3695. type ResultTwo10265 struct {
  3696. ErrMsg string `json:"err_msg"`
  3697. InfRefmsgid string `json:"inf_refmsgid"`
  3698. Infcode string `json:"infcode"`
  3699. Output struct {
  3700. Baseinfo struct {
  3701. Age float64 `json:"age"`
  3702. Brdy string `json:"brdy"`
  3703. Certno string `json:"certno"`
  3704. Gend string `json:"gend"`
  3705. Naty string `json:"naty"`
  3706. PsnCertType string `json:"psn_cert_type"`
  3707. PsnName string `json:"psn_name"`
  3708. PsnNo string `json:"psn_no"`
  3709. } `json:"baseinfo"`
  3710. Idetinfo []interface{} `json:"idetinfo"`
  3711. Iinfo []struct {
  3712. Balc float64 `json:"balc"`
  3713. CvlservFlag string `json:"cvlserv_flag"`
  3714. EmpName string `json:"emp_name"`
  3715. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3716. Insutype string `json:"insutype"`
  3717. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3718. PausInsuDate string `json:"paus_insu_date"`
  3719. PsnInsuDate string `json:"psn_insu_date"`
  3720. PsnInsuStas string `json:"psn_insu_stas"`
  3721. PsnType string `json:"psn_type"`
  3722. } `json:"insuinfo"`
  3723. } `json:"output"`
  3724. RefmsgTime string `json:"refmsg_time"`
  3725. RespondTime string `json:"respond_time"`
  3726. Signtype interface{} `json:"signtype"`
  3727. WarnInfo interface{} `json:"warn_info"`
  3728. }
  3729. type ResultThree struct {
  3730. Cainfo interface{} `json:"cainfo"`
  3731. ErrMsg string `json:"err_msg"`
  3732. InfRefmsgid string `json:"inf_refmsgid"`
  3733. Infcode int64 `json:"infcode"`
  3734. Output struct {
  3735. Data struct {
  3736. IptOtpNo string `json:"ipt_otp_no"`
  3737. MdtrtID string `json:"mdtrt_id"`
  3738. PsnNo string `json:"psn_no"`
  3739. } `json:"data"`
  3740. } `json:"output"`
  3741. RefmsgTime string `json:"refmsg_time"`
  3742. RespondTime string `json:"respond_time"`
  3743. Signtype interface{} `json:"signtype"`
  3744. WarnMsg interface{} `json:"warn_msg"`
  3745. }
  3746. type ResultThree10265 struct {
  3747. Cainfo interface{} `json:"cainfo"`
  3748. ErrMsg string `json:"err_msg"`
  3749. InfRefmsgid string `json:"inf_refmsgid"`
  3750. Infcode string `json:"infcode"`
  3751. Output struct {
  3752. Data struct {
  3753. IptOtpNo string `json:"ipt_otp_no"`
  3754. MdtrtID string `json:"mdtrt_id"`
  3755. PsnNo string `json:"psn_no"`
  3756. } `json:"data"`
  3757. } `json:"output"`
  3758. RefmsgTime string `json:"refmsg_time"`
  3759. RespondTime string `json:"respond_time"`
  3760. Signtype interface{} `json:"signtype"`
  3761. WarnMsg interface{} `json:"warn_msg"`
  3762. }
  3763. type ResultFour struct {
  3764. Cainfo string `json:"cainfo"`
  3765. ErrMsg string `json:"err_msg"`
  3766. InfRefmsgid string `json:"inf_refmsgid"`
  3767. Infcode int64 `json:"infcode"`
  3768. Output struct {
  3769. Result []struct {
  3770. BasMednFlag string `json:"bas_medn_flag"`
  3771. ChldMedcFlag string `json:"chld_medc_flag"`
  3772. ChrgitmLv string `json:"chrgitm_lv"`
  3773. Cnt float64 `json:"cnt"`
  3774. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3775. DrtReimFlag string `json:"drt_reim_flag"`
  3776. FeedetlSn string `json:"feedetl_sn"`
  3777. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3778. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3779. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3780. ListSpItemFlag string `json:"list_sp_item_flag"`
  3781. LmtUsedFlag string `json:"lmt_used_flag"`
  3782. MedChrgitmType string `json:"med_chrgitm_type"`
  3783. Memo string `json:"memo"`
  3784. OverlmtAmt float64 `json:"overlmt_amt"`
  3785. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3786. Pric float64 `json:"pric"`
  3787. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3788. SelfpayProp float64 `json:"selfpay_prop"`
  3789. } `json:"result"`
  3790. } `json:"output"`
  3791. RefmsgTime string `json:"refmsg_time"`
  3792. RespondTime string `json:"respond_time"`
  3793. Signtype string `json:"signtype"`
  3794. WarnMsg string `json:"warn_msg"`
  3795. }
  3796. type ResultFour10265 struct {
  3797. Cainfo string `json:"cainfo"`
  3798. ErrMsg string `json:"err_msg"`
  3799. InfRefmsgid string `json:"inf_refmsgid"`
  3800. Infcode string `json:"infcode"`
  3801. Output struct {
  3802. Result []struct {
  3803. BasMednFlag string `json:"bas_medn_flag"`
  3804. ChldMedcFlag string `json:"chld_medc_flag"`
  3805. ChrgitmLv string `json:"chrgitm_lv"`
  3806. Cnt float64 `json:"cnt"`
  3807. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3808. DrtReimFlag string `json:"drt_reim_flag"`
  3809. FeedetlSn string `json:"feedetl_sn"`
  3810. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3811. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3812. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3813. ListSpItemFlag string `json:"list_sp_item_flag"`
  3814. LmtUsedFlag string `json:"lmt_used_flag"`
  3815. MedChrgitmType string `json:"med_chrgitm_type"`
  3816. Memo string `json:"memo"`
  3817. OverlmtAmt float64 `json:"overlmt_amt"`
  3818. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3819. Pric float64 `json:"pric"`
  3820. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3821. SelfpayProp float64 `json:"selfpay_prop"`
  3822. } `json:"result"`
  3823. } `json:"output"`
  3824. RefmsgTime string `json:"refmsg_time"`
  3825. RespondTime string `json:"respond_time"`
  3826. Signtype string `json:"signtype"`
  3827. WarnMsg string `json:"warn_msg"`
  3828. }
  3829. type ResultFive struct {
  3830. Balc float64 `json:"balc"`
  3831. CvlservFlag string `json:"cvlserv_flag"`
  3832. EmpName string `json:"emp_name"`
  3833. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3834. Insutype string `json:"insutype"`
  3835. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3836. PausInsuDate string `json:"paus_insu_date"`
  3837. PsnInsuDate string `json:"psn_insu_date"`
  3838. PsnInsuStas string `json:"psn_insu_stas"`
  3839. PsnType string `json:"psn_type"`
  3840. }
  3841. type ResultSix struct {
  3842. Cainfo interface{} `json:"cainfo"`
  3843. ErrMsg string `json:"err_msg"`
  3844. InfRefmsgid string `json:"inf_refmsgid"`
  3845. Infcode int64 `json:"infcode"`
  3846. Output struct {
  3847. } `json:"output"`
  3848. RefmsgTime string `json:"refmsg_time"`
  3849. RespondTime string `json:"respond_time"`
  3850. Signtype interface{} `json:"signtype"`
  3851. WarnMsg interface{} `json:"warn_msg"`
  3852. }
  3853. type ResultSix10265 struct {
  3854. Cainfo interface{} `json:"cainfo"`
  3855. ErrMsg string `json:"err_msg"`
  3856. InfRefmsgid string `json:"inf_refmsgid"`
  3857. Infcode string `json:"infcode"`
  3858. Output struct {
  3859. } `json:"output"`
  3860. RefmsgTime string `json:"refmsg_time"`
  3861. RespondTime string `json:"respond_time"`
  3862. Signtype interface{} `json:"signtype"`
  3863. WarnMsg interface{} `json:"warn_msg"`
  3864. }
  3865. type ResultSeven struct {
  3866. Cainfo string `json:"cainfo"`
  3867. ErrMsg string `json:"err_msg"`
  3868. InfRefmsgid string `json:"inf_refmsgid"`
  3869. Infcode int64 `json:"infcode"`
  3870. Output struct {
  3871. Setldetail []interface{} `json:"setldetail"`
  3872. Setlinfo struct {
  3873. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3874. AcctPay float64 `json:"acct_pay"`
  3875. ActPayDedc float64 `json:"act_pay_dedc"`
  3876. Age float64 `json:"age"`
  3877. Balc float64 `json:"balc"`
  3878. Brdy string `json:"brdy"`
  3879. Certno string `json:"certno"`
  3880. ClrOptins string `json:"clr_optins"`
  3881. ClrType string `json:"clr_type"`
  3882. ClrWay string `json:"clr_way"`
  3883. CvlservFlag string `json:"cvlserv_flag"`
  3884. CvlservPay float64 `json:"cvlserv_pay"`
  3885. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3886. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3887. Gend string `json:"gend"`
  3888. HifesPay float64 `json:"hifes_pay"`
  3889. HifmiPay float64 `json:"hifmi_pay"`
  3890. HifpPay float64 `json:"hifp_pay"`
  3891. HospPartAmt float64 `json:"hosp_part_amt"`
  3892. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3893. Insutype string `json:"insutype"`
  3894. MafPay float64 `json:"maf_pay"`
  3895. MdtrtCertType string `json:"mdtrt_cert_type"`
  3896. HifobPay float64 `json:"hifob_pay"`
  3897. MdtrtID string `json:"mdtrt_id"`
  3898. MedType string `json:"med_type"`
  3899. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3900. MedinsSetlID string `json:"medins_setl_id"`
  3901. Naty string `json:"naty"`
  3902. OthPay float64 `json:"oth_pay"`
  3903. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3904. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3905. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3906. PsnCashPay float64 `json:"psn_cash_pay"`
  3907. PsnCertType string `json:"psn_cert_type"`
  3908. PsnName string `json:"psn_name"`
  3909. PsnNo string `json:"psn_no"`
  3910. PsnPartAmt float64 `json:"psn_part_amt"`
  3911. PsnType string `json:"psn_type"`
  3912. SetlID string `json:"setl_id"`
  3913. SetlTime string `json:"setl_time"`
  3914. } `json:"setlinfo"`
  3915. } `json:"output"`
  3916. RefmsgTime string `json:"refmsg_time"`
  3917. RespondTime string `json:"respond_time"`
  3918. Signtype interface{} `json:"signtype"`
  3919. WarnMsg interface{} `json:"warn_msg"`
  3920. }
  3921. type ResultSeven10265 struct {
  3922. Cainfo string `json:"cainfo"`
  3923. ErrMsg string `json:"err_msg"`
  3924. InfRefmsgid string `json:"inf_refmsgid"`
  3925. Infcode string `json:"infcode"`
  3926. Output struct {
  3927. Setldetail []interface{} `json:"setldetail"`
  3928. Setlinfo struct {
  3929. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3930. AcctPay float64 `json:"acct_pay"`
  3931. ActPayDedc float64 `json:"act_pay_dedc"`
  3932. Age float64 `json:"age"`
  3933. Balc float64 `json:"balc"`
  3934. Brdy string `json:"brdy"`
  3935. Certno string `json:"certno"`
  3936. ClrOptins string `json:"clr_optins"`
  3937. ClrType string `json:"clr_type"`
  3938. ClrWay string `json:"clr_way"`
  3939. CvlservFlag string `json:"cvlserv_flag"`
  3940. CvlservPay float64 `json:"cvlserv_pay"`
  3941. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3942. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3943. Gend string `json:"gend"`
  3944. HifesPay float64 `json:"hifes_pay"`
  3945. HifmiPay float64 `json:"hifmi_pay"`
  3946. HifpPay float64 `json:"hifp_pay"`
  3947. HospPartAmt float64 `json:"hosp_part_amt"`
  3948. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3949. Insutype string `json:"insutype"`
  3950. MafPay float64 `json:"maf_pay"`
  3951. MdtrtCertType string `json:"mdtrt_cert_type"`
  3952. HifobPay float64 `json:"hifob_pay"`
  3953. MdtrtID string `json:"mdtrt_id"`
  3954. MedType string `json:"med_type"`
  3955. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3956. MedinsSetlID string `json:"medins_setl_id"`
  3957. Naty string `json:"naty"`
  3958. OthPay float64 `json:"oth_pay"`
  3959. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3960. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3961. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. PsnCashPay float64 `json:"psn_cash_pay"`
  3963. PsnCertType string `json:"psn_cert_type"`
  3964. PsnName string `json:"psn_name"`
  3965. PsnNo string `json:"psn_no"`
  3966. PsnPartAmt float64 `json:"psn_part_amt"`
  3967. PsnType string `json:"psn_type"`
  3968. SetlID string `json:"setl_id"`
  3969. SetlTime string `json:"setl_time"`
  3970. } `json:"setlinfo"`
  3971. } `json:"output"`
  3972. RefmsgTime string `json:"refmsg_time"`
  3973. RespondTime string `json:"respond_time"`
  3974. Signtype interface{} `json:"signtype"`
  3975. WarnMsg interface{} `json:"warn_msg"`
  3976. }
  3977. type ResultEight struct {
  3978. Cainfo string `json:"cainfo"`
  3979. ErrMsg string `json:"err_msg"`
  3980. InfRefmsgid string `json:"inf_refmsgid"`
  3981. Infcode int64 `json:"infcode"`
  3982. Output struct {
  3983. Stmtinfo struct {
  3984. SetlOptins string `json:"setl_optins"`
  3985. StmtRslt string `json:"stmt_rslt"`
  3986. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3987. } `json:"stmtinfo"`
  3988. } `json:"output"`
  3989. RefmsgTime string `json:"refmsg_time"`
  3990. RespondTime string `json:"respond_time"`
  3991. Signtype interface{} `json:"signtype"`
  3992. WarnMsg interface{} `json:"warn_msg"`
  3993. }
  3994. type ResultEightFor10188 struct {
  3995. Cainfo string `json:"cainfo"`
  3996. ErrMsg string `json:"err_msg"`
  3997. InfRefmsgid string `json:"inf_refmsgid"`
  3998. Infcode string `json:"infcode"`
  3999. Output struct {
  4000. Stmtinfo struct {
  4001. SetlOptins string `json:"setl_optins"`
  4002. StmtRslt string `json:"stmt_rslt"`
  4003. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4004. } `json:"stmtinfo"`
  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 ResultNine struct {
  4012. Cainfo string `json:"cainfo"`
  4013. ErrMsg string `json:"err_msg"`
  4014. InfRefmsgid string `json:"inf_refmsgid"`
  4015. Infcode int64 `json:"infcode"`
  4016. Output struct {
  4017. FileQuryNo string `json:"file_qury_no"`
  4018. } `json:"output"`
  4019. RefmsgTime string `json:"refmsg_time"`
  4020. RespondTime string `json:"respond_time"`
  4021. Signtype interface{} `json:"signtype"`
  4022. WarnMsg interface{} `json:"warn_msg"`
  4023. }
  4024. type ResultTen struct {
  4025. Cainfo string `json:"cainfo"`
  4026. ErrMsg string `json:"err_msg"`
  4027. InfRefmsgid string `json:"inf_refmsgid"`
  4028. Infcode int64 `json:"infcode"`
  4029. Output struct {
  4030. DldEndtime string `json:"dld_endtime"`
  4031. FileQuryNo string `json:"file_qury_no"`
  4032. Filename string `json:"filename"`
  4033. } `json:"output"`
  4034. RefmsgTime string `json:"refmsg_time"`
  4035. RespondTime string `json:"respond_time"`
  4036. Signtype interface{} `json:"signtype"`
  4037. WarnMsg interface{} `json:"warn_msg"`
  4038. }
  4039. //type Autogenerated struct {
  4040. // Output struct {
  4041. // Setlinfo struct {
  4042. // SetlTime string `json:"setl_time"`
  4043. // CvlservPay float64 `json:"cvlserv_pay"`
  4044. // Year string `json:"year"`
  4045. // MedType string `json:"med_type"`
  4046. // PsnPay float64 `json:"psn_pay"`
  4047. // OpterID string `json:"opter_id"`
  4048. // Begndate string `json:"begndate"`
  4049. // FlxempeFlag string `json:"flxempe_flag"`
  4050. // HifmiPay float64 `json:"hifmi_pay"`
  4051. // PsnNo string `json:"psn_no"`
  4052. // ActPayDedc float64 `json:"act_pay_dedc"`
  4053. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4054. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4055. // ClrWay string `json:"clr_way"`
  4056. // OthPay float64 `json:"oth_pay"`
  4057. // Gend string `json:"gend"`
  4058. // MdtrtID string `json:"mdtrt_id"`
  4059. // AcctPay float64 `json:"acct_pay"`
  4060. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4061. // Insutype string `json:"insutype"`
  4062. // Invono interface{} `json:"invono"`
  4063. // Enddate string `json:"enddate"`
  4064. // CashPayamt float64 `json:"cash_payamt"`
  4065. // PsnType string `json:"psn_type"`
  4066. // FixmedinsName string `json:"fixmedins_name"`
  4067. // HifpPay float64 `json:"hifp_pay"`
  4068. // NewFlag interface{} `json:"new_flag"`
  4069. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4070. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4071. // PayLoc string `json:"pay_loc"`
  4072. // ClrType string `json:"clr_type"`
  4073. // RefdSetlFlag string `json:"refd_setl_flag"`
  4074. // CvlservFlag string `json:"cvlserv_flag"`
  4075. // EmpName string `json:"emp_name"`
  4076. // Brdy string `json:"brdy"`
  4077. // Naty string `json:"naty"`
  4078. // Certno string `json:"certno"`
  4079. // DiseCode string `json:"dise_code"`
  4080. // FixmedinsCode string `json:"fixmedins_code"`
  4081. // DedcHospLv string `json:"dedc_hosp_lv"`
  4082. // OpterName string `json:"opter_name"`
  4083. // Balc float64 `json:"balc"`
  4084. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4085. // PsnCertType string `json:"psn_cert_type"`
  4086. // HifobPay float64 `json:"hifob_pay"`
  4087. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4088. // HifesPay float64 `json:"hifes_pay"`
  4089. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4090. // OptTime string `json:"opt_time"`
  4091. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4092. // SetlID string `json:"setl_id"`
  4093. // MafPay float64 `json:"maf_pay"`
  4094. // PsnName string `json:"psn_name"`
  4095. // InsuOptins interface{} `json:"insu_optins"`
  4096. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4097. // ClrOptins string `json:"clr_optins"`
  4098. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4099. // DiseName string `json:"dise_name"`
  4100. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4101. // Age float64 `json:"age"`
  4102. // DtrtCertType string `json:"dtrt_cert_type"`
  4103. // HospLv string `json:"hosp_lv"`
  4104. // } `json:"setlinfo"`
  4105. // Setldetail []struct {
  4106. // FundPayType string `json:"fund_pay_type"`
  4107. // FundPayamt float64 `json:"fund_payamt"`
  4108. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4109. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4110. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4111. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4112. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4113. // } `json:"setldetail"`
  4114. // } `json:"output"`
  4115. // Infcode int `json:"infcode"`
  4116. // WarnMsg interface{} `json:"warn_msg"`
  4117. // Cainfo interface{} `json:"cainfo"`
  4118. // ErrMsg interface{} `json:"err_msg"`
  4119. // RefmsgTime string `json:"refmsg_time"`
  4120. // Signtype interface{} `json:"signtype"`
  4121. // RespondTime string `json:"respond_time"`
  4122. // InfRefmsgid string `json:"inf_refmsgid"`
  4123. //}
  4124. type ResultEleven struct {
  4125. Cainfo string `json:"cainfo"`
  4126. ErrMsg string `json:"err_msg"`
  4127. InfRefmsgid string `json:"inf_refmsgid"`
  4128. Infcode int64 `json:"infcode"`
  4129. Output struct {
  4130. Setlinfo struct {
  4131. SetlTime string `json:"setl_time"`
  4132. CvlservPay float64 `json:"cvlserv_pay"`
  4133. Year string `json:"year"`
  4134. MedType string `json:"med_type"`
  4135. PsnPay float64 `json:"psn_pay"`
  4136. OpterID string `json:"opter_id"`
  4137. Begndate string `json:"begndate"`
  4138. FlxempeFlag string `json:"flxempe_flag"`
  4139. HifmiPay float64 `json:"hifmi_pay"`
  4140. PsnNo string `json:"psn_no"`
  4141. ActPayDedc float64 `json:"act_pay_dedc"`
  4142. MedinsSetlID interface{} `json:"medins_setl_id"`
  4143. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4144. ClrWay string `json:"clr_way"`
  4145. OthPay float64 `json:"oth_pay"`
  4146. Gend string `json:"gend"`
  4147. MdtrtID string `json:"mdtrt_id"`
  4148. AcctPay float64 `json:"acct_pay"`
  4149. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4150. Insutype string `json:"insutype"`
  4151. Invono interface{} `json:"invono"`
  4152. Enddate string `json:"enddate"`
  4153. CashPayamt float64 `json:"cash_payamt"`
  4154. PsnType string `json:"psn_type"`
  4155. FixmedinsName string `json:"fixmedins_name"`
  4156. HifpPay float64 `json:"hifp_pay"`
  4157. NewFlag interface{} `json:"new_flag"`
  4158. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4159. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4160. PayLoc string `json:"pay_loc"`
  4161. ClrType string `json:"clr_type"`
  4162. RefdSetlFlag string `json:"refd_setl_flag"`
  4163. CvlservFlag string `json:"cvlserv_flag"`
  4164. EmpName string `json:"emp_name"`
  4165. Brdy string `json:"brdy"`
  4166. Naty string `json:"naty"`
  4167. Certno string `json:"certno"`
  4168. DiseCode string `json:"dise_code"`
  4169. FixmedinsCode string `json:"fixmedins_code"`
  4170. DedcHospLv string `json:"dedc_hosp_lv"`
  4171. OpterName string `json:"opter_name"`
  4172. Balc float64 `json:"balc"`
  4173. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4174. PsnCertType string `json:"psn_cert_type"`
  4175. HifobPay float64 `json:"hifob_pay"`
  4176. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4177. HifesPay float64 `json:"hifes_pay"`
  4178. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4179. OptTime string `json:"opt_time"`
  4180. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4181. SetlID string `json:"setl_id"`
  4182. MafPay float64 `json:"maf_pay"`
  4183. PsnName string `json:"psn_name"`
  4184. InsuOptins interface{} `json:"insu_optins"`
  4185. PrefFundPay interface{} `json:"pref_fund_pay"`
  4186. ClrOptins string `json:"clr_optins"`
  4187. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4188. DiseName string `json:"dise_name"`
  4189. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4190. Age float64 `json:"age"`
  4191. DtrtCertType string `json:"dtrt_cert_type"`
  4192. HospLv string `json:"hosp_lv"`
  4193. } `json:"setlinfo"`
  4194. } `json:"output"`
  4195. RefmsgTime string `json:"refmsg_time"`
  4196. RespondTime string `json:"respond_time"`
  4197. Signtype interface{} `json:"signtype"`
  4198. WarnMsg interface{} `json:"warn_msg"`
  4199. }
  4200. type ResultEleven10265 struct {
  4201. Cainfo string `json:"cainfo"`
  4202. ErrMsg string `json:"err_msg"`
  4203. InfRefmsgid string `json:"inf_refmsgid"`
  4204. Infcode string `json:"infcode"`
  4205. Output struct {
  4206. Setlinfo struct {
  4207. SetlTime string `json:"setl_time"`
  4208. CvlservPay float64 `json:"cvlserv_pay"`
  4209. Year string `json:"year"`
  4210. MedType string `json:"med_type"`
  4211. PsnPay float64 `json:"psn_pay"`
  4212. OpterID string `json:"opter_id"`
  4213. Begndate string `json:"begndate"`
  4214. FlxempeFlag string `json:"flxempe_flag"`
  4215. HifmiPay float64 `json:"hifmi_pay"`
  4216. PsnNo string `json:"psn_no"`
  4217. ActPayDedc float64 `json:"act_pay_dedc"`
  4218. MedinsSetlID interface{} `json:"medins_setl_id"`
  4219. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4220. ClrWay string `json:"clr_way"`
  4221. OthPay float64 `json:"oth_pay"`
  4222. Gend string `json:"gend"`
  4223. MdtrtID string `json:"mdtrt_id"`
  4224. AcctPay float64 `json:"acct_pay"`
  4225. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4226. Insutype string `json:"insutype"`
  4227. Invono interface{} `json:"invono"`
  4228. Enddate string `json:"enddate"`
  4229. CashPayamt float64 `json:"cash_payamt"`
  4230. PsnType string `json:"psn_type"`
  4231. FixmedinsName string `json:"fixmedins_name"`
  4232. HifpPay float64 `json:"hifp_pay"`
  4233. NewFlag interface{} `json:"new_flag"`
  4234. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4235. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4236. PayLoc string `json:"pay_loc"`
  4237. ClrType string `json:"clr_type"`
  4238. RefdSetlFlag string `json:"refd_setl_flag"`
  4239. CvlservFlag string `json:"cvlserv_flag"`
  4240. EmpName string `json:"emp_name"`
  4241. Brdy string `json:"brdy"`
  4242. Naty string `json:"naty"`
  4243. Certno string `json:"certno"`
  4244. DiseCode string `json:"dise_code"`
  4245. FixmedinsCode string `json:"fixmedins_code"`
  4246. DedcHospLv string `json:"dedc_hosp_lv"`
  4247. OpterName string `json:"opter_name"`
  4248. Balc float64 `json:"balc"`
  4249. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4250. PsnCertType string `json:"psn_cert_type"`
  4251. HifobPay float64 `json:"hifob_pay"`
  4252. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4253. HifesPay float64 `json:"hifes_pay"`
  4254. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4255. OptTime string `json:"opt_time"`
  4256. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4257. SetlID string `json:"setl_id"`
  4258. MafPay float64 `json:"maf_pay"`
  4259. PsnName string `json:"psn_name"`
  4260. InsuOptins interface{} `json:"insu_optins"`
  4261. PrefFundPay interface{} `json:"pref_fund_pay"`
  4262. ClrOptins string `json:"clr_optins"`
  4263. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4264. DiseName string `json:"dise_name"`
  4265. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4266. Age float64 `json:"age"`
  4267. DtrtCertType string `json:"dtrt_cert_type"`
  4268. HospLv string `json:"hosp_lv"`
  4269. } `json:"setlinfo"`
  4270. } `json:"output"`
  4271. RefmsgTime string `json:"refmsg_time"`
  4272. RespondTime string `json:"respond_time"`
  4273. Signtype interface{} `json:"signtype"`
  4274. WarnMsg interface{} `json:"warn_msg"`
  4275. }
  4276. type ResultTwelve struct {
  4277. Cainfo string `json:"cainfo"`
  4278. ErrMsg string `json:"err_msg"`
  4279. InfRefmsgid string `json:"inf_refmsgid"`
  4280. Infcode int64 `json:"infcode"`
  4281. Output struct {
  4282. MdtrtId string `json:"mdtrt_id"`
  4283. ChrgBchno string `json:"chrg_bchno"`
  4284. PsnNo string `json:"psn_no"`
  4285. } `json:"output"`
  4286. RefmsgTime string `json:"refmsg_time"`
  4287. RespondTime string `json:"respond_time"`
  4288. Signtype interface{} `json:"signtype"`
  4289. WarnMsg interface{} `json:"warn_msg"`
  4290. }
  4291. type ResultThirteen struct {
  4292. ErrMsg string `json:"err_msg"`
  4293. InfRefmsgid string `json:"inf_refmsgid"`
  4294. Infcode int64 `json:"infcode"`
  4295. Output struct {
  4296. Result struct {
  4297. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4298. } `json:"result"`
  4299. } `json:"output"`
  4300. RefmsgTime string `json:"refmsg_time"`
  4301. RespondTime string `json:"respond_time"`
  4302. Signtype interface{} `json:"signtype"`
  4303. WarnInfo interface{} `json:"warn_info"`
  4304. }
  4305. type ResultThirteen10265 struct {
  4306. ErrMsg string `json:"err_msg"`
  4307. InfRefmsgid string `json:"inf_refmsgid"`
  4308. Infcode string `json:"infcode"`
  4309. Output struct {
  4310. Result struct {
  4311. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4312. } `json:"result"`
  4313. } `json:"output"`
  4314. RefmsgTime string `json:"refmsg_time"`
  4315. RespondTime string `json:"respond_time"`
  4316. Signtype interface{} `json:"signtype"`
  4317. WarnInfo interface{} `json:"warn_info"`
  4318. }
  4319. type ResultFourteen struct {
  4320. ErrMsg string `json:"err_msg"`
  4321. InfRefmsgid string `json:"inf_refmsgid"`
  4322. Infcode int64 `json:"infcode"`
  4323. Output struct {
  4324. } `json:"output"`
  4325. RefmsgTime string `json:"refmsg_time"`
  4326. RespondTime string `json:"respond_time"`
  4327. Signtype interface{} `json:"signtype"`
  4328. WarnInfo interface{} `json:"warn_info"`
  4329. }
  4330. type ResultFourteen10265 struct {
  4331. ErrMsg string `json:"err_msg"`
  4332. InfRefmsgid string `json:"inf_refmsgid"`
  4333. Infcode string `json:"infcode"`
  4334. Output struct {
  4335. } `json:"output"`
  4336. RefmsgTime string `json:"refmsg_time"`
  4337. RespondTime string `json:"respond_time"`
  4338. Signtype interface{} `json:"signtype"`
  4339. WarnInfo interface{} `json:"warn_info"`
  4340. }
  4341. type ResultSixteen struct {
  4342. Cainfo string `json:"cainfo"`
  4343. ErrMsg string `json:"err_msg"`
  4344. InfRefmsgid string `json:"inf_refmsgid"`
  4345. Infcode int64 `json:"infcode"`
  4346. Output struct {
  4347. Setldetail []interface{} `json:"setldetail"`
  4348. Setlinfo struct {
  4349. MdtrtID string `json:"mdtrt_id"`
  4350. SetlID string `json:"setl_id"`
  4351. ClrOptins string `json:"clr_optins"`
  4352. SetlTime string `json:"setl_time"`
  4353. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4354. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4355. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4356. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4357. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4358. ActPayDedc float64 `json:"act_pay_dedc"`
  4359. HifpPay float64 `json:"hifp_pay"`
  4360. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4361. Lfpay float64 `json:"selfpay"`
  4362. CvlservPay float64 `json:"cvlserv_pay"`
  4363. HifesPay float64 `json:"hifes_pay"`
  4364. HifmiPay float64 `json:"hifmi_pay"`
  4365. HifobPay float64 `json:"hifob_pay"`
  4366. MafPay float64 `json:"maf_pay"`
  4367. OthPay float64 `json:"oth_pay"`
  4368. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4369. PsnPartAmt float64 `json:"psn_part_amt"`
  4370. AcctPay float64 `json:"acct_pay"`
  4371. Balc float64 `json:"balc"`
  4372. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4373. HospPartAmt float64 `json:"hosp_part_amt"`
  4374. MedinsSetlID string `json:"medins_setl_id"`
  4375. PdnCashPay string `json:"pdn_cash_pay"`
  4376. } `json:"setlinfo"`
  4377. } `json:"output"`
  4378. RefmsgTime string `json:"refmsg_time"`
  4379. RespondTime string `json:"respond_time"`
  4380. Signtype interface{} `json:"signtype"`
  4381. WarnMsg interface{} `json:"warn_msg"`
  4382. }
  4383. type ResultSixteen10265 struct {
  4384. Cainfo string `json:"cainfo"`
  4385. ErrMsg string `json:"err_msg"`
  4386. InfRefmsgid string `json:"inf_refmsgid"`
  4387. Infcode string `json:"infcode"`
  4388. Output struct {
  4389. Setldetail []interface{} `json:"setldetail"`
  4390. Setlinfo struct {
  4391. MdtrtID string `json:"mdtrt_id"`
  4392. SetlID string `json:"setl_id"`
  4393. ClrOptins string `json:"clr_optins"`
  4394. SetlTime string `json:"setl_time"`
  4395. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4396. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4397. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4398. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4399. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4400. ActPayDedc float64 `json:"act_pay_dedc"`
  4401. HifpPay float64 `json:"hifp_pay"`
  4402. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4403. Lfpay float64 `json:"selfpay"`
  4404. CvlservPay float64 `json:"cvlserv_pay"`
  4405. HifesPay float64 `json:"hifes_pay"`
  4406. HifmiPay float64 `json:"hifmi_pay"`
  4407. HifobPay float64 `json:"hifob_pay"`
  4408. MafPay float64 `json:"maf_pay"`
  4409. OthPay float64 `json:"oth_pay"`
  4410. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4411. PsnPartAmt float64 `json:"psn_part_amt"`
  4412. AcctPay float64 `json:"acct_pay"`
  4413. Balc float64 `json:"balc"`
  4414. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4415. HospPartAmt float64 `json:"hosp_part_amt"`
  4416. MedinsSetlID string `json:"medins_setl_id"`
  4417. PdnCashPay string `json:"pdn_cash_pay"`
  4418. } `json:"setlinfo"`
  4419. } `json:"output"`
  4420. RefmsgTime string `json:"refmsg_time"`
  4421. RespondTime string `json:"respond_time"`
  4422. Signtype interface{} `json:"signtype"`
  4423. WarnMsg interface{} `json:"warn_msg"`
  4424. }
  4425. type ResultSeventeen struct {
  4426. ErrMsg string `json:"err_msg"`
  4427. InfRefmsgid string `json:"inf_refmsgid"`
  4428. Infcode int64 `json:"infcode"`
  4429. Output struct {
  4430. SetlListId string `json:"setl_list_id"`
  4431. } `json:"output"`
  4432. RefmsgTime string `json:"refmsg_time"`
  4433. RespondTime string `json:"respond_time"`
  4434. Signtype string `json:"signtype"`
  4435. WarnInfo string `json:"warn_info"`
  4436. }
  4437. type ResultSeventeenOther struct {
  4438. ErrMsg string `json:"err_msg"`
  4439. InfRefmsgid string `json:"inf_refmsgid"`
  4440. Infcode string `json:"infcode"`
  4441. Output struct {
  4442. SetlListId string `json:"setl_list_id"`
  4443. } `json:"output"`
  4444. RefmsgTime string `json:"refmsg_time"`
  4445. RespondTime string `json:"respond_time"`
  4446. Signtype string `json:"signtype"`
  4447. WarnInfo string `json:"warn_info"`
  4448. }
  4449. type Result90991 struct {
  4450. ErrMsg string `json:"err_msg"`
  4451. InfRefmsgid string `json:"inf_refmsgid"`
  4452. Infcode int64 `json:"infcode"`
  4453. Output struct {
  4454. Result struct {
  4455. PsnNo string `json:"psn_no"`
  4456. CardStat string `json:"card_stat"`
  4457. Certno string `json:"certno"`
  4458. PsnName string `json:"psn_name"`
  4459. CheckStat string `json:"check_stat"`
  4460. SscnoCheckStat string `json:"sscno_check_stat"`
  4461. } `json:"result"`
  4462. } `json:"output"`
  4463. RefmsgTime string `json:"refmsg_time"`
  4464. RespondTime string `json:"respond_time"`
  4465. Signtype interface{} `json:"signtype"`
  4466. WarnInfo interface{} `json:"warn_info"`
  4467. }
  4468. type Result90100 struct {
  4469. ErrMsg string `json:"err_msg"`
  4470. InfRefmsgid string `json:"inf_refmsgid"`
  4471. Infcode int64 `json:"infcode"`
  4472. Output struct {
  4473. PoolareaNo string `json:"poolarea_no"`
  4474. PoolareaNoName string `json:"poolarea_no_name"`
  4475. Insutype string `json:"insutype"`
  4476. InsutypeName string `json:"insutype_name"`
  4477. ClctType string `json:"clct_type"`
  4478. ClctTypeName string `json:"clct_type_name"`
  4479. ClctFlag string `json:"clct_flag"`
  4480. ClctFlagName string `json:"clct_flag_name"`
  4481. AccrymBegn string `json:"accrym_begn"`
  4482. AccrymEnd string `json:"accrym_end"`
  4483. ClctTime string `json:"clct_time"`
  4484. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4485. } `json:"output"`
  4486. RefmsgTime string `json:"refmsg_time"`
  4487. RespondTime string `json:"respond_time"`
  4488. Signtype interface{} `json:"signtype"`
  4489. WarnInfo interface{} `json:"warn_info"`
  4490. }
  4491. type Custom struct {
  4492. DetItemFeeSumamt string
  4493. Cut string
  4494. FeedetlSn string
  4495. Price string
  4496. MedListCodg string
  4497. Type int64
  4498. AdviceId int64
  4499. ProjectId int64
  4500. ItemId int64
  4501. }
  4502. type Result5301 struct {
  4503. ErrMsg string `json:"err_msg"`
  4504. InfRefmsgid string `json:"inf_refmsgid"`
  4505. Infcode int64 `json:"infcode"`
  4506. Output struct {
  4507. Result []struct {
  4508. OpspDiseCode string `json:"opsp_dise_code"`
  4509. OpspDiseName string `json:"opsp_dise_name"`
  4510. Begndate string `json:"begndate"`
  4511. Enddate string `json:"enddate"`
  4512. } `json:"feedetail"`
  4513. } `json:"output"`
  4514. RefmsgTime string `json:"refmsg_time"`
  4515. RespondTime string `json:"respond_time"`
  4516. Signtype interface{} `json:"signtype"`
  4517. WarnInfo interface{} `json:"warn_info"`
  4518. }
  4519. type Result5301For10265 struct {
  4520. ErrMsg string `json:"err_msg"`
  4521. InfRefmsgid string `json:"inf_refmsgid"`
  4522. Infcode string `json:"infcode"`
  4523. Output struct {
  4524. Result []struct {
  4525. OpspDiseCode string `json:"opsp_dise_code"`
  4526. OpspDiseName string `json:"opsp_dise_name"`
  4527. Begndate string `json:"begndate"`
  4528. Enddate string `json:"enddate"`
  4529. } `json:"feedetail"`
  4530. } `json:"output"`
  4531. RefmsgTime string `json:"refmsg_time"`
  4532. RespondTime string `json:"respond_time"`
  4533. Signtype interface{} `json:"signtype"`
  4534. WarnInfo interface{} `json:"warn_info"`
  4535. }
  4536. //获取个人信息----挂号-----上传就诊信息
  4537. func (c *HisApiController) GetRegisterInfo() {
  4538. id, _ := c.GetInt64("id")
  4539. record_time := c.GetString("record_time")
  4540. settlementValue, _ := c.GetInt64("settlement_value")
  4541. medical_insurance_card := c.GetString("medical_insurance_card")
  4542. name := c.GetString("name")
  4543. id_card_type, _ := c.GetInt64("id_card_type")
  4544. certificates, _ := c.GetInt64("certificates")
  4545. medical_care, _ := c.GetInt64("medical_care")
  4546. birthday := c.GetString("birthday")
  4547. id_card := c.GetString("id_card")
  4548. register_type, _ := c.GetInt64("register")
  4549. doctor, _ := c.GetInt64("doctor")
  4550. department, _ := c.GetInt64("department")
  4551. gender, _ := c.GetInt64("sex")
  4552. registration_fee, _ := c.GetFloat("registration_fee")
  4553. medical_expenses, _ := c.GetFloat("medical_expenses")
  4554. social_type, _ := c.GetInt64("social_type")
  4555. med_type := c.GetString("social_type")
  4556. admin_user_id, _ := c.GetInt64("admin_user_id")
  4557. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4558. timeLayout := "2006-01-02"
  4559. loc, _ := time.LoadLocation("Local")
  4560. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4561. birthUnix := birthdays.Unix()
  4562. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4563. if err != nil {
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4565. return
  4566. }
  4567. recordDateTime := theTime.Unix()
  4568. adminInfo := c.GetAdminUserInfo()
  4569. var patient service.Patients
  4570. if id == 0 {
  4571. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4572. } else {
  4573. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4574. }
  4575. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4576. if patientPrescription.ID == 0 {
  4577. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4578. }
  4579. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4580. if patient.ID == 0 {
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4582. return
  4583. }
  4584. if len(patient.IdCardNo) == 0 {
  4585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4586. return
  4587. }
  4588. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4589. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4590. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4591. //就诊结算未完成,不能进行二次挂号
  4592. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4593. if len(his) >= 1 {
  4594. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4595. if len(his) >= 1 && order.ID == 0 {
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4597. return
  4598. }
  4599. }
  4600. //var register_log string
  4601. if config.IsOpen == 1 {
  4602. var res ResultTwo
  4603. var res10265 ResultTwo10265
  4604. var PsnNo string
  4605. var PsnCertType string
  4606. var Certno string
  4607. var PsnName string
  4608. var Gend string
  4609. var Naty string
  4610. var Brdy string
  4611. var Age float64
  4612. var infoStr string
  4613. var idetinfoStr string
  4614. var infocode int64
  4615. var verify_number string
  4616. fmt.Println(verify_number)
  4617. if miConfig.MdtrtareaAdmvs == "421300" {
  4618. psn_info, _ := service.GetPsnByPatientId(id)
  4619. PsnNo = psn_info.PsnNo
  4620. PsnCertType = psn_info.PsnCertType
  4621. Certno = psn_info.Certno
  4622. PsnName = psn_info.PsnName
  4623. Gend = psn_info.Gend
  4624. Naty = psn_info.Naty
  4625. Brdy = psn_info.Brdy
  4626. Age = psn_info.Age
  4627. infoStr = psn_info.Insuinfo
  4628. idetinfoStr = psn_info.Idetinfo
  4629. infocode = 0
  4630. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4631. psn_info, _ := service.GetPsnByPatientId(id)
  4632. PsnNo = psn_info.PsnNo
  4633. PsnCertType = psn_info.PsnCertType
  4634. Certno = psn_info.Certno
  4635. PsnName = psn_info.PsnName
  4636. Gend = psn_info.Gend
  4637. Naty = psn_info.Naty
  4638. Brdy = psn_info.Brdy
  4639. Age = psn_info.Age
  4640. infoStr = psn_info.Insuinfo
  4641. idetinfoStr = psn_info.Idetinfo
  4642. infocode = 0
  4643. verify_number = psn_info.VerifyNumber
  4644. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4645. if id_card_type == 1 {
  4646. psn_info, _ := service.GetPsnByPatientId(id)
  4647. PsnNo = psn_info.PsnNo
  4648. PsnCertType = psn_info.PsnCertType
  4649. Certno = psn_info.Certno
  4650. PsnName = psn_info.PsnName
  4651. Gend = psn_info.Gend
  4652. Naty = psn_info.Naty
  4653. Brdy = psn_info.Brdy
  4654. Age = psn_info.Age
  4655. infoStr = psn_info.Insuinfo
  4656. idetinfoStr = psn_info.Idetinfo
  4657. infocode = 0
  4658. verify_number = psn_info.VerifyNumber
  4659. } else if id_card_type == 2 {
  4660. 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)
  4661. fmt.Println(errMsgLog)
  4662. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4664. utils.ErrorLog("解析失败:%v", err)
  4665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4666. return
  4667. }
  4668. PsnNo = res.Output.Baseinfo.PsnNo
  4669. PsnCertType = res.Output.Baseinfo.PsnCertType
  4670. Certno = res.Output.Baseinfo.Certno
  4671. PsnName = res.Output.Baseinfo.PsnName
  4672. Gend = res.Output.Baseinfo.Gend
  4673. Naty = res.Output.Baseinfo.Naty
  4674. Brdy = res.Output.Baseinfo.Brdy
  4675. Age = res.Output.Baseinfo.Age
  4676. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4677. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4678. infoStr = string(Iinfos)
  4679. idetinfoStr = string(Idetinfos)
  4680. infocode = res.Infcode
  4681. }
  4682. } else {
  4683. var result string
  4684. var requestLog string
  4685. if miConfig.UserOrgId == 10138 {
  4686. if id_card_type == 4 {
  4687. psn_info, _ := service.GetPsnByPatientId(id)
  4688. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  4689. } else {
  4690. 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)
  4691. }
  4692. } else {
  4693. 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)
  4694. }
  4695. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4696. if miConfig.Code == "H15049901371" {
  4697. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4698. utils.ErrorLog("解析失败:%v", err)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. return
  4701. }
  4702. res.ErrMsg = res10265.ErrMsg
  4703. res.Output = res10265.Output
  4704. res.InfRefmsgid = res10265.InfRefmsgid
  4705. } else {
  4706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4707. utils.ErrorLog("解析失败:%v", err)
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. return
  4710. }
  4711. }
  4712. PsnNo = res.Output.Baseinfo.PsnNo
  4713. PsnCertType = res.Output.Baseinfo.PsnCertType
  4714. Certno = res.Output.Baseinfo.Certno
  4715. PsnName = res.Output.Baseinfo.PsnName
  4716. Gend = res.Output.Baseinfo.Gend
  4717. Naty = res.Output.Baseinfo.Naty
  4718. Brdy = res.Output.Baseinfo.Brdy
  4719. Age = res.Output.Baseinfo.Age
  4720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4722. infoStr = string(Iinfos)
  4723. idetinfoStr = string(Idetinfos)
  4724. if miConfig.Code == "H15049901371" {
  4725. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4726. } else {
  4727. infocode = res.Infcode
  4728. }
  4729. }
  4730. if infocode == 0 {
  4731. his := models.VMHisPatient{
  4732. Name: name,
  4733. Gender: gender,
  4734. Birthday: birthUnix,
  4735. MedicalTreatmentType: medical_care,
  4736. IdType: certificates,
  4737. IdCardNo: id_card,
  4738. BalanceAccountsType: settlementValue,
  4739. SocialType: social_type,
  4740. MedicalInsuranceNumber: medical_insurance_card,
  4741. RegisterType: register_type,
  4742. RegisterCost: registration_fee,
  4743. TreatmentCost: medical_expenses,
  4744. Status: 1,
  4745. Ctime: time.Now().Unix(),
  4746. Mtime: time.Now().Unix(),
  4747. PsnNo: PsnNo,
  4748. PsnCertType: PsnCertType,
  4749. Certno: Certno,
  4750. PsnName: PsnName,
  4751. Gend: Gend,
  4752. Naty: Naty,
  4753. Brdy: Brdy,
  4754. Age: Age,
  4755. Iinfo: infoStr,
  4756. Idetinfo: idetinfoStr,
  4757. PatientId: patient.ID,
  4758. RecordDate: theTime.Unix(),
  4759. UserOrgId: adminInfo.CurrentOrgId,
  4760. AdminUserId: admin_user_id,
  4761. IsReturn: 1,
  4762. IdCardType: id_card_type,
  4763. Doctor: doctor,
  4764. Departments: department,
  4765. }
  4766. timestamp := time.Now().Unix()
  4767. tempTime := time.Unix(timestamp, 0)
  4768. timeFormat := tempTime.Format("20060102150405")
  4769. chrgBchno := rand.Intn(100000) + 10000
  4770. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4771. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4772. department, _ := service.GetDepartMentDetail(department)
  4773. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  4774. IdCardNo := ""
  4775. if id_card_type == 1 {
  4776. // IdCardNo = medical_insurance_card
  4777. IdCardNo = patient.IdCardNo
  4778. } else {
  4779. IdCardNo = patient.IdCardNo
  4780. }
  4781. var rf []*ResultFive
  4782. json.Unmarshal([]byte(his.Iinfo), &rf)
  4783. var insutypes []*ResultFive
  4784. var insutype string
  4785. var insuplc_admdvs_temp string
  4786. var is390 int = 0
  4787. var is310 int = 0
  4788. for _, item := range rf {
  4789. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4790. insutypes = append(insutypes, item)
  4791. }
  4792. }
  4793. if len(insutypes) == 1 {
  4794. insutype = insutypes[0].Insutype
  4795. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4796. } else {
  4797. for _, i := range insutypes {
  4798. if i.Insutype == "390" {
  4799. is390 = 1
  4800. }
  4801. if i.Insutype == "310" {
  4802. is310 = 1
  4803. }
  4804. }
  4805. }
  4806. if is390 == 1 {
  4807. insutype = "390"
  4808. }
  4809. if is310 == 1 {
  4810. insutype = "310"
  4811. }
  4812. if len(insutypes) == 0 {
  4813. insutype = "310"
  4814. }
  4815. if len(insutypes) == 2 {
  4816. insutype = med_type
  4817. }
  4818. if len(med_type) > 0 {
  4819. insutype = med_type
  4820. }
  4821. //for _, item := range rf {
  4822. // if item.Insutype == insutype {
  4823. // insuplc_admdvs = item.InsuplcAdmdvs
  4824. // }
  4825. //}
  4826. var infocode int64
  4827. var resThree ResultThree
  4828. var resThree10265 ResultThree10265
  4829. if len(insuplc_admdvs) == 0 {
  4830. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4831. } else {
  4832. insuplc_admdvs_temp = insuplc_admdvs
  4833. }
  4834. if miConfig.MdtrtareaAdmvs == "421300" {
  4835. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4836. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4837. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4838. "&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
  4839. resp, requestErr := http.Get(api)
  4840. if requestErr != nil {
  4841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4842. return
  4843. }
  4844. body, ioErr := ioutil.ReadAll(resp.Body)
  4845. if ioErr != nil {
  4846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. var respJSON map[string]interface{}
  4851. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4854. return
  4855. }
  4856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4857. result, _ := json.Marshal(respJSON)
  4858. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4859. utils.ErrorLog("解析失败:%v", err)
  4860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4861. return
  4862. }
  4863. infocode = resThree.Infcode
  4864. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4865. psn_info, _ := service.GetPsnByPatientId(id)
  4866. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4867. var cert_no string
  4868. if id_card_type == 3 {
  4869. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4870. cert_no = IdCardNo
  4871. } else if id_card_type == 4 {
  4872. cert_no = IdCardNo
  4873. psn_info.VerifyNumber = psn_info.VerifyNumber
  4874. } else {
  4875. bas := strings.Split(psn_info.CardInfo, "|")
  4876. cert_no = bas[2]
  4877. }
  4878. var api string
  4879. if miConfig.MdtrtareaAdmvs == "320921" {
  4880. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4881. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4882. "&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
  4883. } else {
  4884. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4885. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4886. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4887. }
  4888. resp, requestErr := http.Get(api)
  4889. if requestErr != nil {
  4890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. return
  4892. }
  4893. body, ioErr := ioutil.ReadAll(resp.Body)
  4894. if ioErr != nil {
  4895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. return
  4898. }
  4899. var respJSON map[string]interface{}
  4900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. return
  4904. }
  4905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4906. result, _ := json.Marshal(respJSON)
  4907. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4908. utils.ErrorLog("解析失败:%v", err)
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. return
  4911. }
  4912. resThree.ErrMsg = resThree10265.ErrMsg
  4913. resThree.Output = resThree10265.Output
  4914. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4915. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4916. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4917. psn_info, _ := service.GetPsnByPatientId(id)
  4918. var cert_no string
  4919. if id_card_type == 1 {
  4920. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4921. } else {
  4922. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  4923. }
  4924. fmt.Println(cert_no)
  4925. 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)
  4926. saveLog(result, requestLog, "2201", "挂号")
  4927. if miConfig.Code == "H15049901371" {
  4928. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4929. utils.ErrorLog("解析失败:%v", err)
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4931. return
  4932. }
  4933. resThree.ErrMsg = resThree10265.ErrMsg
  4934. resThree.Output = resThree10265.Output
  4935. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4936. } else {
  4937. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4938. utils.ErrorLog("解析失败:%v", err)
  4939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4940. return
  4941. }
  4942. }
  4943. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4944. } else {
  4945. psn_info, _ := service.GetPsnByPatientId(id)
  4946. 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)
  4947. saveLog(result, requestLog, "2201A", "挂号")
  4948. if miConfig.Code == "H15049901371" {
  4949. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4950. utils.ErrorLog("解析失败:%v", err)
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4952. return
  4953. }
  4954. resThree.ErrMsg = resThree10265.ErrMsg
  4955. resThree.Output = resThree10265.Output
  4956. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4957. } else {
  4958. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4959. utils.ErrorLog("解析失败:%v", err)
  4960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4961. return
  4962. }
  4963. }
  4964. if miConfig.Code == "H15049901371" {
  4965. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4966. } else {
  4967. infocode = resThree.Infcode
  4968. }
  4969. }
  4970. if infocode != 0 {
  4971. adminUser := c.GetAdminUserInfo()
  4972. errlog := &models.HisOrderError{
  4973. UserOrgId: adminUser.CurrentOrgId,
  4974. Ctime: time.Now().Unix(),
  4975. Mtime: time.Now().Unix(),
  4976. ErrMsg: resThree.ErrMsg,
  4977. Status: 1,
  4978. PatientId: id,
  4979. RecordTime: recordDateTime,
  4980. Stage: 2,
  4981. }
  4982. service.CreateErrMsgLog(errlog)
  4983. c.ServeSuccessJSON(map[string]interface{}{
  4984. "failed_code": -10,
  4985. "msg": resThree.ErrMsg,
  4986. })
  4987. return
  4988. }
  4989. his.Number = resThree.Output.Data.MdtrtID
  4990. his.PsnNo = resThree.Output.Data.PsnNo
  4991. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4992. his.IdCardNo = patient.IdCardNo
  4993. his.PhoneNumber = patient.Phone
  4994. his.UserOrgId = adminInfo.CurrentOrgId
  4995. his.Insutype = insutype
  4996. his.Ctime = time.Now().Unix()
  4997. his.Mtime = time.Now().Unix()
  4998. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4999. his.Status = 1
  5000. service.UpdateHisPatientStatus(&his)
  5001. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5002. c.ServeSuccessJSON(map[string]interface{}{
  5003. "his_info": his,
  5004. })
  5005. } else {
  5006. adminUser := c.GetAdminUserInfo()
  5007. errlog := &models.HisOrderError{
  5008. UserOrgId: adminUser.CurrentOrgId,
  5009. Ctime: time.Now().Unix(),
  5010. Mtime: time.Now().Unix(),
  5011. ErrMsg: res.ErrMsg,
  5012. Status: 1,
  5013. PatientId: id,
  5014. RecordTime: recordDateTime,
  5015. Stage: 1,
  5016. }
  5017. service.CreateErrMsgLog(errlog)
  5018. c.ServeSuccessJSON(map[string]interface{}{
  5019. "failed_code": -10,
  5020. "msg": res.ErrMsg,
  5021. })
  5022. return
  5023. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5024. }
  5025. }
  5026. }
  5027. //上传明细----预结算----确认订单
  5028. func (c *HisApiController) GetUploadInfo() {
  5029. id, _ := c.GetInt64("id")
  5030. record_time := c.GetString("record_time")
  5031. his_patient_id, _ := c.GetInt64("his_patient_id")
  5032. order_id, _ := c.GetInt64("order_id")
  5033. pay_way, _ := c.GetInt64("pay_way")
  5034. pay_price, _ := c.GetFloat("pay_price")
  5035. pay_card_no := c.GetString("pay_card_no")
  5036. token := c.GetString("token")
  5037. discount_price, _ := c.GetFloat("discount_price")
  5038. preferential_price, _ := c.GetFloat("preferential_price")
  5039. reality_price, _ := c.GetFloat("reality_price")
  5040. found_price, _ := c.GetFloat("found_price")
  5041. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5042. private_price, _ := c.GetFloat("private_price")
  5043. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5044. admin_user_id, _ := c.GetInt64("admin_user_id")
  5045. fapiao_code := c.GetString("fapiao_code")
  5046. fapiao_number := c.GetString("fapiao_number")
  5047. diagnosis_id := c.GetString("diagnosis")
  5048. sick_type, _ := c.GetInt64("sick_type")
  5049. reg_type, _ := c.GetInt64("p_type")
  5050. begin_time := c.GetString("begin_time")
  5051. id_str := c.GetString("ids")
  5052. ids_arr := strings.Split(id_str, ",")
  5053. timeLayout := "2006-01-02"
  5054. loc, _ := time.LoadLocation("Local")
  5055. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5056. if err != nil {
  5057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5058. return
  5059. }
  5060. recordDateTime := theTime.Unix()
  5061. adminUser := c.GetAdminUserInfo()
  5062. var tempOrder models.HisOrder
  5063. tempOrder, _ = service.GetHisOrderByID(order_id)
  5064. var prescriptions []*models.HisPrescription
  5065. var start_time int64
  5066. var end_time int64
  5067. //押金模块
  5068. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5069. tmp_decimal := c.GetString("tmp_decimal")
  5070. var decimal float64 //本次使用的押金
  5071. var errmsg error
  5072. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5073. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5074. return
  5075. }
  5076. if len(tmp_decimal) > 0 {
  5077. if tmp_decimal[0] == 45 {
  5078. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5079. return
  5080. }
  5081. }
  5082. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5083. fmt.Println(errs)
  5084. decimal = tt
  5085. //if adminUser.CurrentOrgId == 10106{
  5086. // if len(fapiao_code) == 0{
  5087. // fapiao_code = "144072080589"
  5088. // }
  5089. // if len(fapiao_number) == 0{
  5090. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5091. // if order.ID == 0{
  5092. // fapiao_number = "00001520"
  5093. // }else{
  5094. // //fapiao_code = "00001520"
  5095. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5096. // var zero string
  5097. // if fpNumber >= 1000{
  5098. // zero = "0000" + strconv.Itoa(fpNumber)
  5099. // }else if fpNumber >= 10000{
  5100. // zero = "000" + strconv.Itoa(fpNumber)
  5101. // } else if fpNumber >= 100000{
  5102. // zero = "00" + strconv.Itoa(fpNumber)
  5103. // } else if fpNumber >= 1000000{
  5104. // zero = "0" + strconv.Itoa(fpNumber)
  5105. // }else {
  5106. // zero = strconv.Itoa(fpNumber)
  5107. // }
  5108. // fapiao_number = zero
  5109. // }
  5110. // }
  5111. //}
  5112. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5113. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5114. var patientPrescription models.HisPrescriptionInfo
  5115. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5116. if patientPrescription.ID == 0 {
  5117. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5118. }
  5119. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5120. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5122. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5123. var config []*models.HisXtDiagnoseConfig
  5124. for _, item := range diagnosis_ids {
  5125. id, _ := strconv.ParseInt(item, 10, 64)
  5126. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5127. config = append(config, &diagnosisConfig)
  5128. }
  5129. sickConfig, _ := service.FindSickById(sick_type)
  5130. //if tempOrder.ID == 0 {
  5131. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5132. //}
  5133. if tempOrder.ID == 0 {
  5134. var result string
  5135. var requestLog string
  5136. var res2 ResultSix
  5137. var ressix10265 ResultSix10265
  5138. if miConfig.MdtrtareaAdmvs == "421300" {
  5139. data := make(map[string]interface{})
  5140. client := &http.Client{}
  5141. data["psn_no"] = his.PsnNo
  5142. data["mdtrt_id"] = his.Number
  5143. data["opter"] = roles.UserName
  5144. data["org_name"] = miConfig.OrgName
  5145. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5146. data["doctor_id"] = doctor_info.DoctorNumber
  5147. data["doctor_name"] = doctor_info.UserName
  5148. data["department"] = department.Name
  5149. data["fixmedins_code"] = miConfig.Code
  5150. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5151. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5152. data["secret_key"] = miConfig.SecretKey
  5153. data["sick_code"] = sickConfig.CountryCode
  5154. data["sick_name"] = sickConfig.ClassName
  5155. data["dept"] = strconv.FormatInt(department.ID, 10)
  5156. data["config"] = config
  5157. data["begin_time"] = begin_time
  5158. bytesData, _ := json.Marshal(data)
  5159. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5160. resp, _ := client.Do(req)
  5161. defer resp.Body.Close()
  5162. body, ioErr := ioutil.ReadAll(resp.Body)
  5163. if ioErr != nil {
  5164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. return
  5167. }
  5168. var respJSON map[string]interface{}
  5169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5172. return
  5173. }
  5174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5175. userJSONBytes, _ := json.Marshal(respJSON)
  5176. fmt.Println("log")
  5177. fmt.Println(string(userJSONBytes))
  5178. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5179. utils.ErrorLog("解析失败:%v", err)
  5180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5181. return
  5182. }
  5183. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5184. //江苏地区国家医保医疗类别
  5185. //职工透析:医疗类别选特殊情况门诊9933
  5186. //居民血透门慢: 医疗类别选门诊慢病1402
  5187. //var med_type string
  5188. //if his.Insutype == "310" {
  5189. // if reg_type == 14 {
  5190. // med_type = "9933"
  5191. // } else if reg_type == 11 {
  5192. // med_type = "11"
  5193. //
  5194. // }
  5195. //} else if his.Insutype == "390" {
  5196. // if reg_type == 14 {
  5197. // med_type = "1402"
  5198. // } else if reg_type == 11 {
  5199. // med_type = "11"
  5200. // }
  5201. //}
  5202. data := make(map[string]interface{})
  5203. client := &http.Client{}
  5204. data["psn_no"] = his.PsnNo
  5205. data["mdtrt_id"] = his.Number
  5206. data["doctor"] = roles.UserName
  5207. data["department"] = department.Name
  5208. data["org_name"] = miConfig.OrgName
  5209. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5210. data["doctor_id"] = doctor_info.DoctorNumber
  5211. data["new_doctor_name"] = doctor_info.UserName
  5212. data["fixmedins_code"] = miConfig.Code
  5213. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5214. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5215. data["secret_key"] = miConfig.SecretKey
  5216. data["sick_code"] = sickConfig.CountryCode
  5217. data["sick_name"] = sickConfig.ClassName
  5218. data["url"] = miConfig.Url
  5219. data["ak"] = miConfig.AccessKey
  5220. data["begin_time"] = begin_time
  5221. data["cainfo"] = miConfig.Cainfo
  5222. data["dept"] = strconv.FormatInt(department.ID, 10)
  5223. data["config"] = config
  5224. bytesData, _ := json.Marshal(data)
  5225. var req *http.Request
  5226. if miConfig.MdtrtareaAdmvs == "320921" {
  5227. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5228. //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 +
  5229. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5230. } else {
  5231. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5232. }
  5233. resp, _ := client.Do(req)
  5234. defer resp.Body.Close()
  5235. body, ioErr := ioutil.ReadAll(resp.Body)
  5236. if ioErr != nil {
  5237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5239. return
  5240. }
  5241. var respJSON map[string]interface{}
  5242. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5245. return
  5246. }
  5247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5248. userJSONBytes, _ := json.Marshal(respJSON)
  5249. fmt.Println("log")
  5250. fmt.Println(string(userJSONBytes))
  5251. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5252. utils.ErrorLog("解析失败:%v", err)
  5253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5254. return
  5255. }
  5256. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5257. res2.Output = ressix10265.Output
  5258. res2.ErrMsg = ressix10265.ErrMsg
  5259. res2.Cainfo = ressix10265.Cainfo
  5260. res2.WarnMsg = ressix10265.WarnMsg
  5261. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5262. res2.Infcode = infocode
  5263. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5264. 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)
  5265. saveLog(result, requestLog, "2203", "上传就诊信息")
  5266. var respJSON2 map[string]interface{}
  5267. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. userJSONBytes2, _ := json.Marshal(respJSON2)
  5273. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5274. utils.ErrorLog("解析失败:%v", err)
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return
  5277. }
  5278. } else {
  5279. if miConfig.MdtrtareaAdmvs == "440781" { //
  5280. 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)
  5281. } else {
  5282. if miConfig.Code == "H15049901371" {
  5283. //赤峰地区国家医保医疗类别
  5284. //职工透析:医疗类别选特殊情况门诊990502
  5285. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5286. var med_type string
  5287. if his.Insutype == "390" {
  5288. if reg_type == 14 {
  5289. med_type = "9933"
  5290. } else if reg_type == 11 {
  5291. med_type = "11"
  5292. }
  5293. } else if his.Insutype == "310" {
  5294. if reg_type == 14 {
  5295. med_type = "990502"
  5296. } else if reg_type == 11 {
  5297. med_type = "11"
  5298. }
  5299. }
  5300. 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)
  5301. } else {
  5302. 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)
  5303. }
  5304. }
  5305. saveLog(result, requestLog, "2203", "上传就诊信息")
  5306. var respJSON2 map[string]interface{}
  5307. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5310. return
  5311. }
  5312. userJSONBytes2, _ := json.Marshal(respJSON2)
  5313. if miConfig.Code == "H15049901371" {
  5314. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5315. utils.ErrorLog("解析失败:%v", err)
  5316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5317. return
  5318. }
  5319. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5320. res2.Output = ressix10265.Output
  5321. res2.ErrMsg = ressix10265.ErrMsg
  5322. res2.Cainfo = ressix10265.Cainfo
  5323. res2.WarnMsg = ressix10265.WarnMsg
  5324. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5325. res2.Infcode = infocode
  5326. } else {
  5327. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5328. utils.ErrorLog("解析失败:%v", err)
  5329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5330. return
  5331. }
  5332. }
  5333. }
  5334. if res2.Infcode != 0 {
  5335. adminUser := c.GetAdminUserInfo()
  5336. errlog := &models.HisOrderError{
  5337. UserOrgId: adminUser.CurrentOrgId,
  5338. Ctime: time.Now().Unix(),
  5339. Mtime: time.Now().Unix(),
  5340. ErrMsg: res2.ErrMsg,
  5341. Status: 1,
  5342. PatientId: id,
  5343. RecordTime: recordDateTime,
  5344. Stage: 3,
  5345. }
  5346. service.CreateErrMsgLog(errlog)
  5347. c.ServeSuccessJSON(map[string]interface{}{
  5348. "failed_code": -10,
  5349. "msg": res2.ErrMsg,
  5350. })
  5351. return
  5352. } else {
  5353. his.Diagnosis = diagnosis_id
  5354. his.SickType = sickConfig.ID
  5355. //var p_type int64
  5356. //if reg_type == 1111 || reg_type == 1112 {
  5357. // p_type = 11
  5358. //
  5359. //}
  5360. his.PType = fmt.Sprintf("%d", reg_type)
  5361. service.UpdateHisPatientThree(&his)
  5362. data := make(map[string]interface{})
  5363. if settle_accounts_type == 1 { //日结
  5364. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5365. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5366. } else {
  5367. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5368. }
  5369. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5370. data["pre"] = prescriptions
  5371. } else { //月结
  5372. start_time_str := c.GetString("start_time")
  5373. end_time_str := c.GetString("end_time")
  5374. timeLayout := "2006-01-02"
  5375. loc, _ := time.LoadLocation("Local")
  5376. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5377. if err != nil {
  5378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5379. return
  5380. }
  5381. recordStartTime := theStartTime.Unix()
  5382. start_time = recordStartTime
  5383. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5384. if err != nil {
  5385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5386. return
  5387. }
  5388. recordEndTime := theEndTime.Unix()
  5389. end_time = recordEndTime
  5390. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5391. data["pre"] = prescriptions
  5392. }
  5393. timestamp := time.Now().Unix()
  5394. tempTime := time.Unix(timestamp, 0)
  5395. timeFormat := tempTime.Format("20060102150405")
  5396. chrgBchno := rand.Intn(100000) + 10000
  5397. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5398. strconv.FormatInt(his.PatientId, 10)
  5399. client := &http.Client{}
  5400. data["psn_no"] = his.PsnNo
  5401. data["mdtrt_id"] = his.Number
  5402. data["chrg_bchno"] = chrg_bchno
  5403. data["org_name"] = miConfig.OrgName
  5404. data["doctor"] = doctor_info.UserName
  5405. data["doctor_id"] = doctor_info.DoctorNumber
  5406. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5407. data["fixmedins_code"] = miConfig.Code
  5408. data["opter"] = roles.UserName
  5409. data["dept_code"] = department.Number
  5410. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5411. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5412. data["secret_key"] = miConfig.SecretKey
  5413. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5414. data["url"] = miConfig.Url
  5415. data["ak"] = miConfig.AccessKey
  5416. data["new_doctor_name"] = patientPrescription.Doctor
  5417. data["diag_code"] = sickConfig.CountryCode
  5418. data["cainfo"] = miConfig.Cainfo
  5419. var ids []int64
  5420. for _, item := range prescriptions {
  5421. ids = append(ids, item.ID)
  5422. }
  5423. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5424. if config.IsOpen == 1 { //对接了医保,走医保流程
  5425. var res ResultFour
  5426. var resFour10265 ResultFour10265
  5427. if miConfig.MdtrtareaAdmvs == "421300" {
  5428. bytesData, _ := json.Marshal(data)
  5429. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5430. resp, _ := client.Do(req)
  5431. defer resp.Body.Close()
  5432. body, ioErr := ioutil.ReadAll(resp.Body)
  5433. if ioErr != nil {
  5434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5436. return
  5437. }
  5438. var respJSON map[string]interface{}
  5439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5442. return
  5443. }
  5444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5445. userJSONBytes, _ := json.Marshal(respJSON)
  5446. fmt.Println("log")
  5447. fmt.Println(string(userJSONBytes))
  5448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5449. utils.ErrorLog("解析失败:%v", err)
  5450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5451. return
  5452. }
  5453. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5454. bytesData, _ := json.Marshal(data)
  5455. var req *http.Request
  5456. if miConfig.MdtrtareaAdmvs == "320921" {
  5457. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5458. } else {
  5459. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5460. }
  5461. resp, _ := client.Do(req)
  5462. defer resp.Body.Close()
  5463. body, ioErr := ioutil.ReadAll(resp.Body)
  5464. if ioErr != nil {
  5465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5467. return
  5468. }
  5469. var respJSON map[string]interface{}
  5470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5473. return
  5474. }
  5475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5476. userJSONBytes, _ := json.Marshal(respJSON)
  5477. fmt.Println("log")
  5478. fmt.Println(string(userJSONBytes))
  5479. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5480. utils.ErrorLog("解析失败:%v", err)
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5482. return
  5483. }
  5484. res.InfRefmsgid = resFour10265.InfRefmsgid
  5485. res.Output = resFour10265.Output
  5486. res.ErrMsg = resFour10265.ErrMsg
  5487. res.Cainfo = resFour10265.Cainfo
  5488. res.WarnMsg = resFour10265.WarnMsg
  5489. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5490. res.Infcode = infocode
  5491. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5492. 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)
  5493. var dat map[string]interface{}
  5494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5495. fmt.Println(dat)
  5496. } else {
  5497. fmt.Println(err)
  5498. }
  5499. saveLog(result, request_log, "2204", "上传费用明细")
  5500. userJSONBytes, _ := json.Marshal(dat)
  5501. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5502. utils.ErrorLog("解析失败:%v", err)
  5503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5504. return
  5505. }
  5506. res.InfRefmsgid = resFour10265.InfRefmsgid
  5507. res.Output = resFour10265.Output
  5508. res.ErrMsg = resFour10265.ErrMsg
  5509. res.Cainfo = resFour10265.Cainfo
  5510. res.WarnMsg = resFour10265.WarnMsg
  5511. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5512. res.Infcode = infocode
  5513. } else {
  5514. if miConfig.Code == "H15049901371" {
  5515. 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)
  5516. var dat map[string]interface{}
  5517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5518. fmt.Println(dat)
  5519. } else {
  5520. fmt.Println(err)
  5521. }
  5522. saveLog(result, request_log, "2204", "上传费用明细")
  5523. userJSONBytes, _ := json.Marshal(dat)
  5524. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5525. utils.ErrorLog("解析失败:%v", err)
  5526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5527. return
  5528. }
  5529. res.InfRefmsgid = resFour10265.InfRefmsgid
  5530. res.Output = resFour10265.Output
  5531. res.ErrMsg = resFour10265.ErrMsg
  5532. res.Cainfo = resFour10265.Cainfo
  5533. res.WarnMsg = resFour10265.WarnMsg
  5534. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5535. res.Infcode = infocode
  5536. } else {
  5537. 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)
  5538. var dat map[string]interface{}
  5539. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5540. fmt.Println(dat)
  5541. } else {
  5542. fmt.Println(err)
  5543. }
  5544. saveLog(result, request_log, "2204", "上传费用明细")
  5545. userJSONBytes, _ := json.Marshal(dat)
  5546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5547. utils.ErrorLog("解析失败:%v", err)
  5548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5549. return
  5550. }
  5551. }
  5552. }
  5553. if res.Infcode == 0 {
  5554. order := &models.HisOrder{
  5555. UserOrgId: adminUser.CurrentOrgId,
  5556. HisPatientId: his.ID,
  5557. PatientId: his.PatientId,
  5558. SettleAccountsDate: recordDateTime,
  5559. MdtrtId: his.Number,
  5560. PsnNo: his.PsnNo,
  5561. MedType: strconv.FormatInt(reg_type, 10),
  5562. Ctime: time.Now().Unix(),
  5563. Mtime: time.Now().Unix(),
  5564. Status: 1,
  5565. Number: chrg_bchno,
  5566. Infcode: res.Infcode,
  5567. WarnMsg: res.WarnMsg,
  5568. Cainfo: res.Cainfo,
  5569. ErrMsg: res.ErrMsg,
  5570. RespondTime: res.RefmsgTime,
  5571. InfRefmsgid: res.InfRefmsgid,
  5572. OrderStatus: 1,
  5573. PayWay: pay_way,
  5574. PayPrice: pay_price,
  5575. PayCardNo: pay_card_no,
  5576. DiscountPrice: discount_price,
  5577. PreferentialPrice: preferential_price,
  5578. RealityPrice: reality_price,
  5579. FoundPrice: found_price,
  5580. MedicalInsurancePrice: medical_insurance_price,
  5581. PrivatePrice: private_price,
  5582. IsMedicineInsurance: 1,
  5583. SettleType: settle_accounts_type,
  5584. SettleStartTime: start_time,
  5585. SettleEndTime: end_time,
  5586. Creator: roles.AdminUserId,
  5587. Modify: roles.AdminUserId,
  5588. FaPiaoNumber: fapiao_number,
  5589. FaPiaoCode: fapiao_code,
  5590. PType: 2,
  5591. Diagnosis: diagnosis_id,
  5592. }
  5593. err = service.CreateOrder(order)
  5594. if err != nil {
  5595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5596. return
  5597. }
  5598. for _, item := range res.Output.Result {
  5599. temp := strings.Split(item.FeedetlSn, "-")
  5600. var advice_id int64 = 0
  5601. var project_id int64 = 0
  5602. var types int64 = 0
  5603. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5604. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5605. if temp[1] == "1" {
  5606. advice_id = id
  5607. project_id = 0
  5608. } else if temp[1] == "2" {
  5609. advice_id = 0
  5610. project_id = id
  5611. }
  5612. info := &models.HisOrderInfo{
  5613. OrderNumber: order.Number,
  5614. FeedetlSn: item.FeedetlSn,
  5615. UploadDate: time.Now().Unix(),
  5616. AdviceId: advice_id,
  5617. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5618. Cnt: item.Cnt,
  5619. Pric: float64(item.Pric),
  5620. PatientId: his.PatientId,
  5621. PricUplmtAmt: item.PricUplmtAmt,
  5622. SelfpayProp: item.SelfpayProp,
  5623. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5624. OverlmtAmt: item.OverlmtAmt,
  5625. PreselfpayAmt: item.PreselfpayAmt,
  5626. BasMednFlag: item.BasMednFlag,
  5627. MedChrgitmType: item.MedChrgitmType,
  5628. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5629. Status: 1,
  5630. Memo: item.Memo,
  5631. Mtime: time.Now().Unix(),
  5632. InscpScpAmt: item.InscpScpAmt,
  5633. DrtReimFlag: item.DrtReimFlag,
  5634. Ctime: time.Now().Unix(),
  5635. ListSpItemFlag: item.ListSpItemFlag,
  5636. ChldMedcFlag: item.ChldMedcFlag,
  5637. LmtUsedFlag: item.LmtUsedFlag,
  5638. ChrgitmLv: item.ChrgitmLv,
  5639. UserOrgId: adminUser.CurrentOrgId,
  5640. HisPatientId: his.ID,
  5641. OrderId: order.ID,
  5642. ProjectId: project_id,
  5643. Type: types,
  5644. }
  5645. service.CreateOrderInfo(info)
  5646. }
  5647. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5648. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5649. var total float64
  5650. for _, item := range prescriptions {
  5651. if item.Type == 1 { //药品
  5652. for _, subItem := range item.HisDoctorAdviceInfo {
  5653. total = total + (subItem.Price * subItem.PrescribingNumber)
  5654. }
  5655. }
  5656. if item.Type == 2 { //项目
  5657. for _, subItem := range item.HisPrescriptionProject {
  5658. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5659. total = total + (subItem.Price * cnt)
  5660. }
  5661. }
  5662. }
  5663. for _, item := range prescriptions {
  5664. for _, subItem := range item.HisAdditionalCharge {
  5665. total = total + (subItem.Price * float64(subItem.Count))
  5666. }
  5667. }
  5668. var allTotal string
  5669. if adminUser.CurrentOrgId == 9919 {
  5670. allTotal = fmt.Sprintf("%.4f", total)
  5671. } else {
  5672. allTotal = fmt.Sprintf("%.4f", total)
  5673. }
  5674. if res.Infcode == 0 {
  5675. var rf []*ResultFive
  5676. json.Unmarshal([]byte(his.Iinfo), &rf)
  5677. chrg_bchno := chrg_bchno
  5678. cert_no := his.Certno
  5679. var insutypes []string
  5680. var insutype string
  5681. var is390 int = 0
  5682. var is310 int = 0
  5683. for _, item := range rf {
  5684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5685. insutypes = append(insutypes, item.Insutype)
  5686. }
  5687. }
  5688. if len(insutypes) == 1 {
  5689. insutype = insutypes[0]
  5690. } else {
  5691. for _, i := range insutypes {
  5692. if i == "390" {
  5693. is390 = 1
  5694. }
  5695. if i == "310" {
  5696. is310 = 1
  5697. }
  5698. }
  5699. }
  5700. if is390 == 1 {
  5701. insutype = "390"
  5702. }
  5703. if is310 == 1 {
  5704. insutype = "310"
  5705. }
  5706. if len(insutypes) == 0 {
  5707. insutype = "310"
  5708. }
  5709. if len(insutypes) == 2 {
  5710. insutype = strconv.FormatInt(his.SocialType, 10)
  5711. }
  5712. insutype = strconv.FormatInt(his.SocialType, 10)
  5713. //insutype = "390"
  5714. if his.IdCardType == 1 {
  5715. // cert_no = his.MedicalInsuranceNumber
  5716. cert_no = his.Certno
  5717. } else {
  5718. cert_no = his.Certno
  5719. }
  5720. var res ResultSeven
  5721. var resSeven10265 ResultSeven10265
  5722. var src_resquest string
  5723. var result2 string
  5724. var acct_used_flag string
  5725. fmt.Println("pay_way")
  5726. fmt.Println(pay_way)
  5727. fmt.Println("pay_way")
  5728. if pay_way == 4 {
  5729. acct_used_flag = "1"
  5730. } else {
  5731. acct_used_flag = "0"
  5732. }
  5733. if miConfig.MdtrtareaAdmvs == "421300" {
  5734. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5735. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5736. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5737. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5738. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5739. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5740. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5741. resp, requestErr := http.Get(api)
  5742. if requestErr != nil {
  5743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5744. return
  5745. }
  5746. body, ioErr := ioutil.ReadAll(resp.Body)
  5747. if ioErr != nil {
  5748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5750. return
  5751. }
  5752. var respJSON map[string]interface{}
  5753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5756. return
  5757. }
  5758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5759. result, _ := json.Marshal(respJSON)
  5760. if miConfig.Code == "H15049901371" {
  5761. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5762. utils.ErrorLog("解析失败:%v", err)
  5763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5764. return
  5765. }
  5766. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5767. res.Output = resSeven10265.Output
  5768. res.ErrMsg = resSeven10265.ErrMsg
  5769. res.Cainfo = resSeven10265.Cainfo
  5770. res.WarnMsg = resSeven10265.WarnMsg
  5771. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5772. res.Infcode = infocode
  5773. } else {
  5774. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5775. utils.ErrorLog("解析失败:%v", err)
  5776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5777. return
  5778. }
  5779. }
  5780. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5781. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5782. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5783. bas := strings.Split(psn_info.CardInfo, "|")
  5784. if his.IdCardType == 1 {
  5785. cert_no = bas[2]
  5786. } else if his.IdCardType == 3 {
  5787. cert_no = his.Certno
  5788. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5789. } else if his.IdCardType == 4 {
  5790. cert_no = his.Certno
  5791. psn_info.VerifyNumber = token
  5792. }
  5793. var api string
  5794. if miConfig.MdtrtareaAdmvs == "320921" {
  5795. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5796. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5797. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5799. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5800. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5801. "&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
  5802. } else {
  5803. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5804. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5805. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5806. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5807. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5808. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5809. "&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
  5810. }
  5811. resp, requestErr := http.Get(api)
  5812. if requestErr != nil {
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. return
  5815. }
  5816. body, ioErr := ioutil.ReadAll(resp.Body)
  5817. if ioErr != nil {
  5818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5820. return
  5821. }
  5822. var respJSON map[string]interface{}
  5823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5826. return
  5827. }
  5828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5829. result, _ := json.Marshal(respJSON)
  5830. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5831. utils.ErrorLog("解析失败:%v", err)
  5832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5833. return
  5834. }
  5835. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5836. res.Output = resSeven10265.Output
  5837. res.ErrMsg = resSeven10265.ErrMsg
  5838. res.Cainfo = resSeven10265.Cainfo
  5839. res.WarnMsg = resSeven10265.WarnMsg
  5840. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5841. res.Infcode = infocode
  5842. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5843. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5844. var cert_no string
  5845. if his.IdCardType == 1 {
  5846. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5847. }
  5848. fmt.Println(cert_no)
  5849. 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)
  5850. //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)
  5851. var dat map[string]interface{}
  5852. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5853. fmt.Println(dat)
  5854. } else {
  5855. fmt.Println(err)
  5856. }
  5857. saveLog(result2, src_resquest, "2207", "结算")
  5858. userJSONBytes, _ := json.Marshal(dat)
  5859. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5860. utils.ErrorLog("解析失败:%v", err)
  5861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5862. return
  5863. }
  5864. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5865. res.Output = resSeven10265.Output
  5866. res.ErrMsg = resSeven10265.ErrMsg
  5867. res.Cainfo = resSeven10265.Cainfo
  5868. res.WarnMsg = resSeven10265.WarnMsg
  5869. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5870. res.Infcode = infocode
  5871. } else {
  5872. if miConfig.Code == "H15049901371" {
  5873. //赤峰地区国家医保医疗类别
  5874. //职工透析:医疗类别选特殊情况门诊990502
  5875. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5876. var med_type string
  5877. if his.Insutype == "390" {
  5878. if reg_type == 14 {
  5879. med_type = "9933"
  5880. } else if reg_type == 11 {
  5881. med_type = "11"
  5882. }
  5883. } else if his.Insutype == "310" {
  5884. if reg_type == 14 {
  5885. med_type = "990502"
  5886. } else if reg_type == 11 {
  5887. med_type = "11"
  5888. }
  5889. }
  5890. 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)
  5891. } else {
  5892. 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)
  5893. }
  5894. //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)
  5895. var dat map[string]interface{}
  5896. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5897. fmt.Println(dat)
  5898. } else {
  5899. fmt.Println(err)
  5900. }
  5901. saveLog(result2, src_resquest, "2207", "结算")
  5902. userJSONBytes, _ := json.Marshal(dat)
  5903. if miConfig.Code == "H15049901371" {
  5904. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5905. utils.ErrorLog("解析失败:%v", err)
  5906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5907. return
  5908. }
  5909. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5910. res.Output = resSeven10265.Output
  5911. res.ErrMsg = resSeven10265.ErrMsg
  5912. res.Cainfo = resSeven10265.Cainfo
  5913. res.WarnMsg = resSeven10265.WarnMsg
  5914. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5915. res.Infcode = infocode
  5916. } else {
  5917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5918. utils.ErrorLog("解析失败:%v", err)
  5919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5920. return
  5921. }
  5922. }
  5923. }
  5924. if res.Infcode != 0 {
  5925. errlog := &models.HisOrderError{
  5926. UserOrgId: adminUser.CurrentOrgId,
  5927. Ctime: time.Now().Unix(),
  5928. Mtime: time.Now().Unix(),
  5929. Number: chrg_bchno,
  5930. ErrMsg: res.ErrMsg,
  5931. Status: 1,
  5932. PatientId: id,
  5933. RecordTime: recordDateTime,
  5934. Stage: 6,
  5935. }
  5936. service.CreateErrMsgLog(errlog)
  5937. c.ServeSuccessJSON(map[string]interface{}{
  5938. "failed_code": -10,
  5939. "msg": res.ErrMsg,
  5940. })
  5941. return
  5942. } else {
  5943. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5944. order.OrderStatus = 2
  5945. order.Status = 1
  5946. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5947. order.SetlId = res.Output.Setlinfo.SetlID
  5948. order.PsnNo = res.Output.Setlinfo.PsnNo
  5949. order.PsnName = res.Output.Setlinfo.PsnName
  5950. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5951. order.Certno = res.Output.Setlinfo.Certno
  5952. order.Gend = res.Output.Setlinfo.Gend
  5953. order.Naty = res.Output.Setlinfo.Naty
  5954. order.Age = res.Output.Setlinfo.Age
  5955. order.Insutype = res.Output.Setlinfo.Insutype
  5956. order.PsnType = res.Output.Setlinfo.PsnType
  5957. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5958. order.SetlTime = res.Output.Setlinfo.SetlTime
  5959. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5960. if res.Output.Setlinfo.MedType == "140101" {
  5961. order.MedType = "14"
  5962. } else {
  5963. order.MedType = res.Output.Setlinfo.MedType
  5964. }
  5965. if reg_type == 1112 {
  5966. order.MedType = "1112"
  5967. }
  5968. if reg_type == 1111 {
  5969. order.MedType = "1111"
  5970. }
  5971. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5972. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5973. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5974. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5975. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5976. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5977. order.HifpPay = res.Output.Setlinfo.HifpPay
  5978. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5979. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5980. order.HifesPay = res.Output.Setlinfo.HifesPay
  5981. order.HifobPay = res.Output.Setlinfo.HifobPay
  5982. order.MafPay = res.Output.Setlinfo.MafPay
  5983. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5984. order.OthPay = res.Output.Setlinfo.OthPay
  5985. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5986. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5987. order.AcctPay = res.Output.Setlinfo.AcctPay
  5988. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5989. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5990. order.Balc = res.Output.Setlinfo.Balc
  5991. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5992. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5993. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5994. order.ClrType = res.Output.Setlinfo.ClrType
  5995. order.ClrWay = res.Output.Setlinfo.ClrWay
  5996. order.Creator = order.Creator
  5997. order.Modify = roles.AdminUserId
  5998. order.RequestLog = src_resquest
  5999. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6000. detailStr := string(setlDetail)
  6001. order.SetlDetail = detailStr
  6002. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6003. err = service.UpDateOrder(order)
  6004. if err == nil {
  6005. //判断是否使用了押金
  6006. if dec_way == "true" {
  6007. tmpstring := strconv.FormatInt(order.ID, 10)
  6008. order.Decimal = decimal
  6009. service.UpDateOrder(order)
  6010. //扣押金
  6011. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6012. if errmsg != nil {
  6013. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6014. return
  6015. }
  6016. }
  6017. c.ServeSuccessJSON(map[string]interface{}{
  6018. "msg": "结算成功",
  6019. })
  6020. } else {
  6021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6022. return
  6023. }
  6024. }
  6025. } else {
  6026. adminUser := c.GetAdminUserInfo()
  6027. errlog := &models.HisOrderError{
  6028. UserOrgId: adminUser.CurrentOrgId,
  6029. Ctime: time.Now().Unix(),
  6030. Mtime: time.Now().Unix(),
  6031. ErrMsg: res.ErrMsg,
  6032. Status: 1,
  6033. PatientId: id,
  6034. RecordTime: recordDateTime,
  6035. Stage: 4,
  6036. }
  6037. service.CreateErrMsgLog(errlog)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6039. return
  6040. }
  6041. } else {
  6042. adminUser := c.GetAdminUserInfo()
  6043. errlog := &models.HisOrderError{
  6044. UserOrgId: adminUser.CurrentOrgId,
  6045. Ctime: time.Now().Unix(),
  6046. Mtime: time.Now().Unix(),
  6047. ErrMsg: res.ErrMsg,
  6048. Status: 1,
  6049. PatientId: id,
  6050. RecordTime: recordDateTime,
  6051. Stage: 4,
  6052. }
  6053. service.CreateErrMsgLog(errlog)
  6054. c.ServeSuccessJSON(map[string]interface{}{
  6055. "failed_code": -10,
  6056. "msg": res.ErrMsg,
  6057. })
  6058. return
  6059. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6060. //return
  6061. }
  6062. }
  6063. }
  6064. } else if tempOrder.ID > 0 {
  6065. if tempOrder.IsPre == 1 {
  6066. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6067. var rf []*ResultFive
  6068. json.Unmarshal([]byte(his.Iinfo), &rf)
  6069. chrg_bchno := tempOrder.Number
  6070. cert_no := his.Certno
  6071. var insutypes []string
  6072. var insutype string
  6073. var is390 int = 0
  6074. var is310 int = 0
  6075. for _, item := range rf {
  6076. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6077. insutypes = append(insutypes, item.Insutype)
  6078. }
  6079. }
  6080. if len(insutypes) == 1 {
  6081. insutype = insutypes[0]
  6082. } else {
  6083. for _, i := range insutypes {
  6084. if i == "390" {
  6085. is390 = 1
  6086. }
  6087. if i == "310" {
  6088. is310 = 1
  6089. }
  6090. }
  6091. }
  6092. if is390 == 1 {
  6093. insutype = "390"
  6094. }
  6095. if is310 == 1 {
  6096. insutype = "310"
  6097. }
  6098. if len(insutypes) == 0 {
  6099. insutype = "310"
  6100. }
  6101. if len(insutypes) == 2 {
  6102. insutype = strconv.FormatInt(his.SocialType, 64)
  6103. }
  6104. //insutype = "390"
  6105. if his.IdCardType == 1 {
  6106. // cert_no = his.MedicalInsuranceNumber
  6107. cert_no = his.Certno
  6108. } else {
  6109. cert_no = his.Certno
  6110. }
  6111. var res ResultSeven
  6112. var resSeven10265 ResultSeven10265
  6113. var src_resquest string
  6114. var result2 string
  6115. var acct_used_flag string
  6116. fmt.Println("pay_way")
  6117. fmt.Println(pay_way)
  6118. fmt.Println("pay_way")
  6119. if pay_way == 4 {
  6120. acct_used_flag = "1"
  6121. } else {
  6122. acct_used_flag = "0"
  6123. }
  6124. if miConfig.MdtrtareaAdmvs == "421300" {
  6125. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6126. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6127. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6129. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6130. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6131. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6132. resp, requestErr := http.Get(api)
  6133. if requestErr != nil {
  6134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6135. return
  6136. }
  6137. body, ioErr := ioutil.ReadAll(resp.Body)
  6138. if ioErr != nil {
  6139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6141. return
  6142. }
  6143. var respJSON map[string]interface{}
  6144. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6147. return
  6148. }
  6149. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6150. result, _ := json.Marshal(respJSON)
  6151. fmt.Println("log")
  6152. fmt.Println(string(result))
  6153. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6154. utils.ErrorLog("解析失败:%v", err)
  6155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6156. return
  6157. }
  6158. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6159. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6160. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6161. //psn_info, _ := service.GetPsnByPatientId(id)
  6162. bas := strings.Split(psn_info.CardInfo, "|")
  6163. if his.IdCardType == 1 {
  6164. cert_no = bas[2]
  6165. } else {
  6166. cert_no = bas[1]
  6167. }
  6168. //江苏地区国家医保医疗类别
  6169. //职工透析:医疗类别选特殊情况门诊9933
  6170. //居民血透门慢: 医疗类别选门诊慢病1402
  6171. //var med_type string
  6172. //if his.Insutype == "310" {
  6173. // if reg_type == 14 {
  6174. // med_type = "9933"
  6175. // } else if reg_type == 11 {
  6176. // med_type = "11"
  6177. //
  6178. // }
  6179. //} else if his.Insutype == "390" {
  6180. // if reg_type == 14 {
  6181. // med_type = "1402"
  6182. // } else if reg_type == 11 {
  6183. // med_type = "11"
  6184. // }
  6185. //}
  6186. var api string
  6187. if miConfig.MdtrtareaAdmvs == "320921" {
  6188. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6189. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6190. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6191. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6192. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6193. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6194. "&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
  6195. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6196. } else {
  6197. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6198. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6199. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6200. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6201. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6202. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6203. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6204. "&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
  6205. }
  6206. resp, requestErr := http.Get(api)
  6207. if requestErr != nil {
  6208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6209. return
  6210. }
  6211. body, ioErr := ioutil.ReadAll(resp.Body)
  6212. if ioErr != nil {
  6213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6215. return
  6216. }
  6217. var respJSON map[string]interface{}
  6218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. return
  6222. }
  6223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6224. result, _ := json.Marshal(respJSON)
  6225. fmt.Println("log")
  6226. fmt.Println(string(result))
  6227. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6228. utils.ErrorLog("解析失败:%v", err)
  6229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6230. return
  6231. }
  6232. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6233. res.Output = resSeven10265.Output
  6234. res.ErrMsg = resSeven10265.ErrMsg
  6235. res.Cainfo = resSeven10265.Cainfo
  6236. res.WarnMsg = resSeven10265.WarnMsg
  6237. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6238. res.Infcode = infocode
  6239. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6240. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6241. var cert_no string
  6242. if his.IdCardType == 1 {
  6243. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6244. }
  6245. fmt.Println(cert_no)
  6246. 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)
  6247. var dat map[string]interface{}
  6248. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6249. fmt.Println(dat)
  6250. } else {
  6251. fmt.Println(err)
  6252. }
  6253. saveLog(result2, src_resquest, "2207", "结算")
  6254. userJSONBytes, _ := json.Marshal(dat)
  6255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6256. utils.ErrorLog("解析失败:%v", err)
  6257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6258. return
  6259. }
  6260. } else {
  6261. var src_resquest string
  6262. if miConfig.Code == "H15049901371" {
  6263. //赤峰地区国家医保医疗类别
  6264. //职工透析:医疗类别选特殊情况门诊990502
  6265. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6266. var med_type string
  6267. if his.Insutype == "390" {
  6268. if reg_type == 14 {
  6269. med_type = "9933"
  6270. } else if reg_type == 11 {
  6271. med_type = "11"
  6272. }
  6273. } else if his.Insutype == "310" {
  6274. if reg_type == 14 {
  6275. med_type = "990502"
  6276. } else if reg_type == 11 {
  6277. med_type = "11"
  6278. }
  6279. }
  6280. 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)
  6281. } else {
  6282. 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)
  6283. }
  6284. var dat map[string]interface{}
  6285. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6286. fmt.Println(dat)
  6287. } else {
  6288. fmt.Println(err)
  6289. }
  6290. saveLog(result2, src_resquest, "2207", "结算")
  6291. userJSONBytes, _ := json.Marshal(dat)
  6292. if miConfig.Code == "H15049901371" {
  6293. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6294. utils.ErrorLog("解析失败:%v", err)
  6295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6296. return
  6297. }
  6298. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6299. res.Output = resSeven10265.Output
  6300. res.ErrMsg = resSeven10265.ErrMsg
  6301. res.Cainfo = resSeven10265.Cainfo
  6302. res.WarnMsg = resSeven10265.WarnMsg
  6303. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6304. res.Infcode = infocode
  6305. } else {
  6306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6307. utils.ErrorLog("解析失败:%v", err)
  6308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6309. return
  6310. }
  6311. }
  6312. }
  6313. if res.Infcode != 0 {
  6314. errlog := &models.HisOrderError{
  6315. UserOrgId: adminUser.CurrentOrgId,
  6316. Ctime: time.Now().Unix(),
  6317. Mtime: time.Now().Unix(),
  6318. Number: chrg_bchno,
  6319. ErrMsg: res.ErrMsg,
  6320. Status: 1,
  6321. PatientId: id,
  6322. RecordTime: recordDateTime,
  6323. Stage: 6,
  6324. }
  6325. service.CreateErrMsgLog(errlog)
  6326. c.ServeSuccessJSON(map[string]interface{}{
  6327. "failed_code": -10,
  6328. "msg": res.ErrMsg,
  6329. })
  6330. return
  6331. } else {
  6332. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6333. order.OrderStatus = 2
  6334. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6335. order.SetlId = res.Output.Setlinfo.SetlID
  6336. order.PsnNo = res.Output.Setlinfo.PsnNo
  6337. order.PsnName = res.Output.Setlinfo.PsnName
  6338. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6339. order.Certno = res.Output.Setlinfo.Certno
  6340. order.Gend = res.Output.Setlinfo.Gend
  6341. order.Naty = res.Output.Setlinfo.Naty
  6342. order.Age = res.Output.Setlinfo.Age
  6343. order.Insutype = res.Output.Setlinfo.Insutype
  6344. order.PsnType = res.Output.Setlinfo.PsnType
  6345. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6346. order.SetlTime = res.Output.Setlinfo.SetlTime
  6347. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6348. //order.MedType = res.Output.Setlinfo.MedType
  6349. if reg_type == 1112 {
  6350. order.MedType = "1112"
  6351. }
  6352. if reg_type == 1111 {
  6353. order.MedType = "1111"
  6354. }
  6355. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6356. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6357. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6358. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6359. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6360. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6361. order.HifpPay = res.Output.Setlinfo.HifpPay
  6362. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6363. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6364. order.HifesPay = res.Output.Setlinfo.HifesPay
  6365. order.HifobPay = res.Output.Setlinfo.HifobPay
  6366. order.MafPay = res.Output.Setlinfo.MafPay
  6367. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6368. order.OthPay = res.Output.Setlinfo.OthPay
  6369. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6370. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6371. order.AcctPay = res.Output.Setlinfo.AcctPay
  6372. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6373. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6374. order.Balc = res.Output.Setlinfo.Balc
  6375. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6376. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6377. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6378. order.ClrWay = res.Output.Setlinfo.ClrWay
  6379. order.Creator = order.Creator
  6380. order.Modify = roles.AdminUserId
  6381. order.RequestLog = src_resquest
  6382. order.Diagnosis = diagnosis_id
  6383. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6384. detailStr := string(setlDetail)
  6385. order.SetlDetail = detailStr
  6386. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6387. err = service.UpDateOrder(order)
  6388. if err == nil {
  6389. //判断是否使用了押金
  6390. if dec_way == "true" {
  6391. tmpstring := strconv.FormatInt(order.ID, 10)
  6392. //扣押金
  6393. order.Decimal = decimal
  6394. service.UpDateOrder(order)
  6395. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6396. if errmsg != nil {
  6397. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6398. return
  6399. }
  6400. }
  6401. c.ServeSuccessJSON(map[string]interface{}{
  6402. "msg": "结算成功",
  6403. })
  6404. } else {
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6406. return
  6407. }
  6408. }
  6409. }
  6410. }
  6411. }
  6412. //func (c *HisApiController) GetPreUploadInfo() {
  6413. // id, _ := c.GetInt64("id")
  6414. // record_time := c.GetString("record_time")
  6415. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6416. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6417. //
  6418. // timeLayout := "2006-01-02"
  6419. // loc, _ := time.LoadLocation("Local")
  6420. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6421. // if err != nil {
  6422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6423. // return
  6424. // }
  6425. // recordDateTime := theTime.Unix()
  6426. // adminUser := c.GetAdminUserInfo()
  6427. //
  6428. // var prescriptions []*models.HisPrescription
  6429. //
  6430. // var start_time int64
  6431. // var end_time int64
  6432. //
  6433. // data := make(map[string]interface{})
  6434. // if settle_accounts_type == 1 { //日结
  6435. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6436. // data["pre"] = prescriptions
  6437. //
  6438. // } else { //月结
  6439. // start_time_str := c.GetString("start_time")
  6440. // end_time_str := c.GetString("end_time")
  6441. // timeLayout := "2006-01-02"
  6442. // loc, _ := time.LoadLocation("Local")
  6443. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6444. // if err != nil {
  6445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6446. // return
  6447. // }
  6448. // recordStartTime := theStartTime.Unix()
  6449. // start_time = recordStartTime
  6450. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6451. // if err != nil {
  6452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6453. // return
  6454. // }
  6455. // recordEndTime := theEndTime.Unix()
  6456. // end_time = recordEndTime
  6457. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6458. // data["pre"] = prescriptions
  6459. //
  6460. // }
  6461. //
  6462. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6463. //
  6464. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6465. // timestamp := time.Now().Unix()
  6466. // tempTime := time.Unix(timestamp, 0)
  6467. // timeFormat := tempTime.Format("20060102150405")
  6468. // chrgBchno := rand.Intn(100000) + 10000
  6469. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6470. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6471. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6472. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6473. // strconv.FormatInt(his.PatientId, 10)
  6474. // client := &http.Client{}
  6475. // data["psn_no"] = his.PsnNo
  6476. // data["mdtrt_id"] = his.Number
  6477. // data["chrg_bchno"] = chrg_bchno
  6478. // data["org_name"] = miConfig.OrgName
  6479. // data["doctor"] = roles.UserName
  6480. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6481. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6482. // data["fixmedins_code"] = miConfig.Code
  6483. // data["dept_code"] = department.Number
  6484. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6485. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6486. // data["secret_key"] = miConfig.SecretKey
  6487. // var ids []int64
  6488. //
  6489. // for _, item := range prescriptions {
  6490. // ids = append(ids, item.ID)
  6491. // }
  6492. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6493. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6494. // bytesData, _ := json.Marshal(data)
  6495. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6496. // resp, _ := client.Do(req)
  6497. // defer resp.Body.Close()
  6498. // body, ioErr := ioutil.ReadAll(resp.Body)
  6499. // if ioErr != nil {
  6500. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6502. // return
  6503. // }
  6504. // var respJSON map[string]interface{}
  6505. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6508. // return
  6509. // }
  6510. //
  6511. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6512. // userJSONBytes, _ := json.Marshal(respJSON)
  6513. // var res ResultFour
  6514. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6515. // utils.ErrorLog("解析失败:%v", err)
  6516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6517. // return
  6518. // }
  6519. //
  6520. // if res.Infcode == 0 {
  6521. // order := &models.HisOrder{
  6522. // UserOrgId: adminUser.CurrentOrgId,
  6523. // HisPatientId: his.ID,
  6524. // PatientId: his.PatientId,
  6525. // SettleAccountsDate: recordDateTime,
  6526. // Ctime: time.Now().Unix(),
  6527. // Mtime: time.Now().Unix(),
  6528. // Status: 1,
  6529. // Number: chrg_bchno,
  6530. // Infcode: res.Infcode,
  6531. // WarnMsg: res.WarnMsg,
  6532. // Cainfo: res.Cainfo,
  6533. // ErrMsg: res.ErrMsg,
  6534. // RespondTime: res.RefmsgTime,
  6535. // InfRefmsgid: res.InfRefmsgid,
  6536. // OrderStatus: 1,
  6537. // IsMedicineInsurance: 1,
  6538. // SettleType: settle_accounts_type,
  6539. // SettleStartTime: start_time,
  6540. // SettleEndTime: end_time,
  6541. // Creator: roles.ID,
  6542. // Modify: roles.ID,
  6543. // PType: 2,
  6544. // }
  6545. // err = service.CreateOrder(order)
  6546. // if err != nil {
  6547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6548. // return
  6549. // }
  6550. //
  6551. // for _, item := range res.Output.Result {
  6552. // temp := strings.Split(item.FeedetlSn, "-")
  6553. // var advice_id int64 = 0
  6554. // var project_id int64 = 0
  6555. // var types int64 = 0
  6556. //
  6557. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6558. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6559. //
  6560. // if temp[1] == "1" {
  6561. // advice_id = id
  6562. // project_id = 0
  6563. // } else if temp[1] == "2" {
  6564. // advice_id = 0
  6565. // project_id = id
  6566. // }
  6567. //
  6568. // info := &models.HisOrderInfo{
  6569. // OrderNumber: order.Number,
  6570. // FeedetlSn: item.FeedetlSn,
  6571. // UploadDate: time.Now().Unix(),
  6572. // AdviceId: advice_id,
  6573. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6574. // Cnt: item.Cnt,
  6575. // Pric: float64(item.Pric),
  6576. // PatientId: his.PatientId,
  6577. // PricUplmtAmt: item.PricUplmtAmt,
  6578. // SelfpayProp: item.SelfpayProp,
  6579. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6580. // OverlmtAmt: item.OverlmtAmt,
  6581. // PreselfpayAmt: item.PreselfpayAmt,
  6582. // BasMednFlag: item.BasMednFlag,
  6583. // MedChrgitmType: item.MedChrgitmType,
  6584. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6585. // Status: 1,
  6586. // Memo: item.Memo,
  6587. // Mtime: time.Now().Unix(),
  6588. // InscpScpAmt: item.InscpScpAmt,
  6589. // DrtReimFlag: item.DrtReimFlag,
  6590. // Ctime: time.Now().Unix(),
  6591. // ListSpItemFlag: item.ListSpItemFlag,
  6592. // ChldMedcFlag: item.ChldMedcFlag,
  6593. // LmtUsedFlag: item.LmtUsedFlag,
  6594. // ChrgitmLv: item.ChrgitmLv,
  6595. // UserOrgId: adminUser.CurrentOrgId,
  6596. // HisPatientId: his.ID,
  6597. // OrderId: order.ID,
  6598. // ProjectId: project_id,
  6599. // Type: types,
  6600. // }
  6601. // service.CreateOrderInfo(info)
  6602. //
  6603. // }
  6604. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6605. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6606. //
  6607. // var total float64
  6608. // for _, item := range prescriptions {
  6609. // if item.Type == 1 { //药品
  6610. // for _, subItem := range item.HisDoctorAdviceInfo {
  6611. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6612. // }
  6613. // }
  6614. // if item.Type == 2 { //项目
  6615. // for _, subItem := range item.HisPrescriptionProject {
  6616. // total = total + (subItem.Price * float64(subItem.Count))
  6617. // }
  6618. // }
  6619. // }
  6620. //
  6621. // for _, item := range prescriptions {
  6622. // for _, subItem := range item.HisAdditionalCharge {
  6623. // total = total + (subItem.Price * float64(subItem.Count))
  6624. // }
  6625. // }
  6626. //
  6627. // allTotal := fmt.Sprintf("%.2f", total)
  6628. // if res.Infcode == 0 {
  6629. // var rf []*ResultFive
  6630. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6631. // psn_no := his.PsnNo
  6632. // mdtrt_id := his.Number
  6633. // chrg_bchno := chrg_bchno
  6634. // cert_no := his.Certno
  6635. // insutype := rf[0].Insutype
  6636. //
  6637. // if his.IdCardType == 1 {
  6638. // cert_no = his.MedicalInsuranceNumber
  6639. //
  6640. // } else {
  6641. //
  6642. // cert_no = his.Certno
  6643. //
  6644. // }
  6645. //
  6646. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6647. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6648. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6649. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6650. // resp, requestErr := http.Get(api)
  6651. // if requestErr != nil {
  6652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6653. // return
  6654. // }
  6655. // defer resp.Body.Close()
  6656. // body, ioErr := ioutil.ReadAll(resp.Body)
  6657. // if ioErr != nil {
  6658. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6660. // return
  6661. // }
  6662. // var respJSON map[string]interface{}
  6663. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6664. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6666. // return
  6667. // }
  6668. // fmt.Println(respJSON)
  6669. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6670. // userJSONBytes, _ := json.Marshal(respJSON)
  6671. // var res ResultSeven
  6672. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6673. // utils.ErrorLog("解析失败:%v", err)
  6674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. // return
  6676. // }
  6677. // if res.Infcode != 0 {
  6678. // errlog := &models.HisOrderError{
  6679. // UserOrgId: adminUser.CurrentOrgId,
  6680. // Ctime: time.Now().Unix(),
  6681. // Mtime: time.Now().Unix(),
  6682. // Number: chrg_bchno,
  6683. // ErrMsg: res.ErrMsg,
  6684. // Status: 1,
  6685. // PatientId: id,
  6686. // RecordTime: recordDateTime,
  6687. // Stage: 7,
  6688. // }
  6689. // service.CreateErrMsgLog(errlog)
  6690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6691. // return
  6692. // } else {
  6693. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6694. // order.OrderStatus = 1
  6695. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6696. // order.SetlId = res.Output.Setlinfo.SetlID
  6697. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6698. // order.PsnName = res.Output.Setlinfo.PsnName
  6699. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6700. // order.Certno = res.Output.Setlinfo.Certno
  6701. // order.Gend = res.Output.Setlinfo.Gend
  6702. // order.Naty = res.Output.Setlinfo.Naty
  6703. // order.Age = res.Output.Setlinfo.Age
  6704. // order.Insutype = res.Output.Setlinfo.Insutype
  6705. // order.PsnType = res.Output.Setlinfo.PsnType
  6706. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6707. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6708. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6709. // order.MedType = res.Output.Setlinfo.MedType
  6710. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6711. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6712. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6713. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6714. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6715. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6716. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6717. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6718. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6719. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6720. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6721. // order.MafPay = res.Output.Setlinfo.MafPay
  6722. // order.OthPay = res.Output.Setlinfo.OthPay
  6723. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6724. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6725. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6726. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6727. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6728. // order.Balc = res.Output.Setlinfo.Balc
  6729. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6730. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6731. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6732. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6733. // order.Creator = order.Creator
  6734. // order.Modify = roles.ID
  6735. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6736. // detailStr := string(setlDetail)
  6737. // order.SetlDetail = detailStr
  6738. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6739. // err = service.UpDateOrder(order)
  6740. // if err == nil {
  6741. // c.ServeSuccessJSON(map[string]interface{}{
  6742. // "msg": "预结算成功",
  6743. // })
  6744. // } else {
  6745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6746. // return
  6747. // }
  6748. // }
  6749. // } else {
  6750. // adminUser := c.GetAdminUserInfo()
  6751. // errlog := &models.HisOrderError{
  6752. // UserOrgId: adminUser.CurrentOrgId,
  6753. // Ctime: time.Now().Unix(),
  6754. // Mtime: time.Now().Unix(),
  6755. // ErrMsg: res.ErrMsg,
  6756. // Status: 1,
  6757. // PatientId: id,
  6758. // RecordTime: recordDateTime,
  6759. // Stage: 4,
  6760. // }
  6761. // service.CreateErrMsgLog(errlog)
  6762. //
  6763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6764. // return
  6765. // }
  6766. // } else {
  6767. // adminUser := c.GetAdminUserInfo()
  6768. // errlog := &models.HisOrderError{
  6769. // UserOrgId: adminUser.CurrentOrgId,
  6770. // Ctime: time.Now().Unix(),
  6771. // Mtime: time.Now().Unix(),
  6772. // ErrMsg: res.ErrMsg,
  6773. // Status: 1,
  6774. // PatientId: id,
  6775. // RecordTime: recordDateTime,
  6776. // Stage: 4,
  6777. // }
  6778. // service.CreateErrMsgLog(errlog)
  6779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6780. // return
  6781. // }
  6782. //
  6783. // } else {
  6784. // var total float64
  6785. // for _, item := range prescriptions {
  6786. // if item.Type == 1 { //药品
  6787. // for _, subItem := range item.HisDoctorAdviceInfo {
  6788. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6789. // }
  6790. // }
  6791. // if item.Type == 2 { //项目
  6792. // for _, subItem := range item.HisPrescriptionProject {
  6793. // total = total + (subItem.Price * float64(subItem.Count))
  6794. // }
  6795. // }
  6796. //
  6797. // for _, subItem := range item.HisAdditionalCharge {
  6798. // total = total + (subItem.Price * float64(subItem.Count))
  6799. // }
  6800. // }
  6801. //
  6802. // allTotal := fmt.Sprintf("%.2f", total)
  6803. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6804. // order := &models.HisOrder{
  6805. // UserOrgId: adminUser.CurrentOrgId,
  6806. // HisPatientId: his.ID,
  6807. // PatientId: id,
  6808. // SettleAccountsDate: recordDateTime,
  6809. // Ctime: time.Now().Unix(),
  6810. // Mtime: time.Now().Unix(),
  6811. // Status: 1,
  6812. // OrderStatus: 2,
  6813. // Number: chrg_bchno,
  6814. // MedfeeSumamt: totals,
  6815. // }
  6816. // err = service.CreateOrder(order)
  6817. // if err != nil {
  6818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6819. // return
  6820. // }
  6821. //
  6822. // var customs []*Custom
  6823. // for _, item := range prescriptions {
  6824. //
  6825. // if item.Type == 1 { //药品
  6826. // for _, subItem := range item.HisDoctorAdviceInfo {
  6827. // cus := &Custom{
  6828. // AdviceId: subItem.ID,
  6829. // ProjectId: 0,
  6830. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6831. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6832. // FeedetlSn: subItem.FeedetlSn,
  6833. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6834. // MedListCodg: subItem.MedListCodg,
  6835. // Type: 1,
  6836. // }
  6837. // customs = append(customs, cus)
  6838. // }
  6839. // }
  6840. //
  6841. // if item.Type == 2 { //项目
  6842. // for _, subItem := range item.HisPrescriptionProject {
  6843. //
  6844. // cus := &Custom{
  6845. // AdviceId: 0,
  6846. // ProjectId: subItem.ID,
  6847. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6848. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6849. // FeedetlSn: subItem.FeedetlSn,
  6850. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6851. // MedListCodg: subItem.MedListCodg,
  6852. // Type: 2,
  6853. // }
  6854. //
  6855. // customs = append(customs, cus)
  6856. // }
  6857. // }
  6858. //
  6859. // for _, item := range item.HisAdditionalCharge {
  6860. // cus := &Custom{
  6861. // ItemId: item.ID,
  6862. // AdviceId: 0,
  6863. // ProjectId: 0,
  6864. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6865. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6866. // FeedetlSn: item.FeedetlSn,
  6867. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6868. // MedListCodg: item.XtHisAddtionConfig.Code,
  6869. // Type: 3,
  6870. // }
  6871. //
  6872. // customs = append(customs, cus)
  6873. // }
  6874. //
  6875. // }
  6876. //
  6877. // for _, item := range customs {
  6878. // var advice_id int64 = 0
  6879. // var project_id int64 = 0
  6880. // var item_id int64 = 0
  6881. //
  6882. // var types int64 = 0
  6883. //
  6884. // if item.Type == 1 {
  6885. // advice_id = item.AdviceId
  6886. // project_id = 0
  6887. // item_id = 0
  6888. // } else if item.Type == 2 {
  6889. // advice_id = 0
  6890. // item_id = 0
  6891. //
  6892. // project_id = item.ProjectId
  6893. // } else if item.Type == 3 {
  6894. // advice_id = 0
  6895. // item_id = item.ItemId
  6896. // project_id = 0
  6897. // }
  6898. //
  6899. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6900. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6901. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6902. //
  6903. // info := &models.HisOrderInfo{
  6904. // OrderNumber: order.Number,
  6905. // UploadDate: time.Now().Unix(),
  6906. // AdviceId: advice_id,
  6907. // DetItemFeeSumamt: detItemFeeSumamt,
  6908. // Cnt: cut,
  6909. // Pric: pric,
  6910. // PatientId: id,
  6911. // Status: 1,
  6912. // Mtime: time.Now().Unix(),
  6913. // Ctime: time.Now().Unix(),
  6914. // UserOrgId: adminUser.CurrentOrgId,
  6915. // HisPatientId: his.ID,
  6916. // OrderId: order.ID,
  6917. // ProjectId: project_id,
  6918. // Type: types,
  6919. // ItemId: item_id,
  6920. // }
  6921. // service.CreateOrderInfo(info)
  6922. // }
  6923. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6924. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6925. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6926. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6927. // if err == nil {
  6928. // c.ServeSuccessJSON(map[string]interface{}{
  6929. // "msg": "结算成功",
  6930. // })
  6931. // } else {
  6932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6933. // return
  6934. // }
  6935. // }
  6936. //}
  6937. //上传明细-预结算-
  6938. func (c *HisApiController) GetPreUploadInfo() {
  6939. id, _ := c.GetInt64("id")
  6940. record_time := c.GetString("record_time")
  6941. his_patient_id, _ := c.GetInt64("his_patient_id")
  6942. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6943. admin_user_id, _ := c.GetInt64("admin_user_id")
  6944. diagnosis_id := c.GetString("diagnosis")
  6945. sick_type, _ := c.GetInt64("sick_type")
  6946. reg_type, _ := c.GetInt64("p_type")
  6947. begin_time := c.GetString("begin_time")
  6948. id_str := c.GetString("ids")
  6949. ids_arr := strings.Split(id_str, ",")
  6950. timeLayout := "2006-01-02"
  6951. loc, _ := time.LoadLocation("Local")
  6952. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6953. if err != nil {
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6955. return
  6956. }
  6957. recordDateTime := theTime.Unix()
  6958. adminUser := c.GetAdminUserInfo()
  6959. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6960. var config []*models.HisXtDiagnoseConfig
  6961. for _, item := range diagnosis_ids {
  6962. id, _ := strconv.ParseInt(item, 10, 64)
  6963. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6964. config = append(config, &diagnosisConfig)
  6965. }
  6966. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6967. sickConfig, _ := service.FindSickById(sick_type)
  6968. var prescriptions []*models.HisPrescription
  6969. var start_time int64
  6970. var end_time int64
  6971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6972. fmt.Println(his_patient_id)
  6973. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6974. timestamp := time.Now().Unix()
  6975. tempTime := time.Unix(timestamp, 0)
  6976. timeFormat := tempTime.Format("20060102150405")
  6977. chrgBchno := rand.Intn(100000) + 10000
  6978. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6980. var patientPrescription models.HisPrescriptionInfo
  6981. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6982. if patientPrescription.ID == 0 {
  6983. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6984. }
  6985. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6986. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6987. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6988. strconv.FormatInt(his.PatientId, 10)
  6989. var res2 ResultSix
  6990. var resSix10265 ResultSix10265
  6991. var time_stamp string
  6992. if miConfig.MdtrtareaAdmvs == "421300" {
  6993. data := make(map[string]interface{})
  6994. client := &http.Client{}
  6995. data["psn_no"] = his.PsnNo
  6996. data["mdtrt_id"] = his.Number
  6997. data["department"] = department.Name
  6998. data["org_name"] = miConfig.OrgName
  6999. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7000. data["doctor_id"] = doctor_info.DoctorNumber
  7001. data["doctor_name"] = roles.UserName
  7002. data["fixmedins_code"] = miConfig.Code
  7003. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7004. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7005. data["secret_key"] = miConfig.SecretKey
  7006. data["sick_code"] = sickConfig.CountryCode
  7007. data["sick_name"] = sickConfig.ClassName
  7008. data["begin_time"] = begin_time
  7009. data["dept"] = strconv.FormatInt(department.ID, 10)
  7010. data["config"] = config
  7011. data["opter"] = roles.UserName
  7012. fmt.Println(data)
  7013. bytesData, _ := json.Marshal(data)
  7014. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7015. resp, _ := client.Do(req)
  7016. defer resp.Body.Close()
  7017. body, ioErr := ioutil.ReadAll(resp.Body)
  7018. if ioErr != nil {
  7019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7021. return
  7022. }
  7023. var respJSON map[string]interface{}
  7024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. return
  7028. }
  7029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7030. userJSONBytes, _ := json.Marshal(respJSON)
  7031. fmt.Println("log")
  7032. fmt.Println(string(userJSONBytes))
  7033. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7034. utils.ErrorLog("解析失败:%v", err)
  7035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7036. return
  7037. }
  7038. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7039. data := make(map[string]interface{})
  7040. client := &http.Client{}
  7041. data["psn_no"] = his.PsnNo
  7042. data["mdtrt_id"] = his.Number
  7043. data["doctor"] = roles.UserName
  7044. data["department"] = department.Name
  7045. data["org_name"] = miConfig.OrgName
  7046. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7047. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7048. data["fixmedins_code"] = miConfig.Code
  7049. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7050. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7051. data["secret_key"] = miConfig.SecretKey
  7052. data["sick_code"] = sickConfig.CountryCode
  7053. data["sick_name"] = sickConfig.ClassName
  7054. data["begin_time"] = begin_time
  7055. data["dept"] = strconv.FormatInt(department.ID, 10)
  7056. data["config"] = config
  7057. data["url"] = miConfig.Url
  7058. data["ak"] = miConfig.AccessKey
  7059. data["cainfo"] = miConfig.Cainfo
  7060. bytesData, _ := json.Marshal(data)
  7061. var req *http.Request
  7062. if miConfig.MdtrtareaAdmvs == "320921" {
  7063. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7064. //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 +
  7065. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7066. } else {
  7067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7068. }
  7069. resp, _ := client.Do(req)
  7070. defer resp.Body.Close()
  7071. body, ioErr := ioutil.ReadAll(resp.Body)
  7072. if ioErr != nil {
  7073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. var respJSON map[string]interface{}
  7078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7084. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7085. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7087. userJSONBytes, _ := json.Marshal(respJSON)
  7088. fmt.Println("log")
  7089. fmt.Println(string(userJSONBytes))
  7090. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7091. utils.ErrorLog("解析失败:%v", err)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. return
  7094. }
  7095. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7096. res2.Output = resSix10265.Output
  7097. res2.ErrMsg = resSix10265.ErrMsg
  7098. res2.Cainfo = resSix10265.Cainfo
  7099. res2.WarnMsg = resSix10265.WarnMsg
  7100. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7101. res2.Infcode = infocode
  7102. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7103. 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)
  7104. saveLog(result, requestLog, "2203", "上传就诊信息")
  7105. var respJSON2 map[string]interface{}
  7106. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. return
  7110. }
  7111. userJSONBytes2, _ := json.Marshal(respJSON2)
  7112. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7113. utils.ErrorLog("解析失败:%v", err)
  7114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7115. return
  7116. }
  7117. } else {
  7118. var result string
  7119. var requestLog string
  7120. if miConfig.MdtrtareaAdmvs == "440781" { //
  7121. 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)
  7122. } else {
  7123. if miConfig.Code == "H15049901371" {
  7124. //赤峰地区国家医保医疗类别
  7125. //职工透析:医疗类别选特殊情况门诊990502
  7126. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7127. var med_type string
  7128. if his.Insutype == "390" {
  7129. if reg_type == 14 {
  7130. med_type = "9933"
  7131. } else if reg_type == 11 {
  7132. med_type = "11"
  7133. }
  7134. } else if his.Insutype == "310" {
  7135. if reg_type == 14 {
  7136. med_type = "990502"
  7137. } else if reg_type == 11 {
  7138. med_type = "11"
  7139. }
  7140. }
  7141. 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)
  7142. } else {
  7143. 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)
  7144. }
  7145. saveLog(result, requestLog, "2203", "上传就诊信息")
  7146. var respJSON2 map[string]interface{}
  7147. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7150. return
  7151. }
  7152. userJSONBytes2, _ := json.Marshal(respJSON2)
  7153. if miConfig.Code == "H15049901371" {
  7154. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7155. utils.ErrorLog("解析失败:%v", err)
  7156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7157. return
  7158. }
  7159. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7160. res2.Output = resSix10265.Output
  7161. res2.ErrMsg = resSix10265.ErrMsg
  7162. res2.Cainfo = resSix10265.Cainfo
  7163. res2.WarnMsg = resSix10265.WarnMsg
  7164. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7165. res2.Infcode = infocode
  7166. } else {
  7167. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7168. utils.ErrorLog("解析失败:%v", err)
  7169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7170. return
  7171. }
  7172. }
  7173. }
  7174. }
  7175. if res2.Infcode != 0 {
  7176. adminUser := c.GetAdminUserInfo()
  7177. errlog := &models.HisOrderError{
  7178. UserOrgId: adminUser.CurrentOrgId,
  7179. Ctime: time.Now().Unix(),
  7180. Mtime: time.Now().Unix(),
  7181. ErrMsg: res2.ErrMsg,
  7182. Status: 1,
  7183. PatientId: id,
  7184. RecordTime: recordDateTime,
  7185. Stage: 3,
  7186. }
  7187. service.CreateErrMsgLog(errlog)
  7188. c.ServeSuccessJSON(map[string]interface{}{
  7189. "failed_code": -10,
  7190. "msg": res2.ErrMsg,
  7191. })
  7192. return
  7193. } else {
  7194. his.Diagnosis = diagnosis_id
  7195. his.SickType = sickConfig.ID
  7196. his.PType = fmt.Sprintf("%d", reg_type)
  7197. service.UpdateHisPatientThree(&his)
  7198. data := make(map[string]interface{})
  7199. if settle_accounts_type == 1 { //日结
  7200. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7201. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7202. } else {
  7203. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7204. }
  7205. data["pre"] = prescriptions
  7206. } else { //月结
  7207. start_time_str := c.GetString("start_time")
  7208. end_time_str := c.GetString("end_time")
  7209. timeLayout := "2006-01-02"
  7210. loc, _ := time.LoadLocation("Local")
  7211. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7212. if err != nil {
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7214. return
  7215. }
  7216. recordStartTime := theStartTime.Unix()
  7217. start_time = recordStartTime
  7218. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7219. if err != nil {
  7220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7221. return
  7222. }
  7223. recordEndTime := theEndTime.Unix()
  7224. end_time = recordEndTime
  7225. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7226. data["pre"] = prescriptions
  7227. }
  7228. client := &http.Client{}
  7229. data["psn_no"] = his.PsnNo
  7230. data["mdtrt_id"] = his.Number
  7231. data["chrg_bchno"] = chrg_bchno
  7232. data["org_name"] = miConfig.OrgName
  7233. data["doctor"] = roles.UserName
  7234. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7235. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7236. data["fixmedins_code"] = miConfig.Code
  7237. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7238. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7239. data["dept_code"] = "15"
  7240. } else {
  7241. data["dept_code"] = department.Number
  7242. }
  7243. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7244. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7245. data["secret_key"] = miConfig.SecretKey
  7246. data["url"] = miConfig.Url
  7247. data["ak"] = miConfig.AccessKey
  7248. data["new_doctor_name"] = patientPrescription.Doctor
  7249. data["diag_code"] = sickConfig.CountryCode
  7250. data["time_stamp"] = time_stamp
  7251. data["cainfo"] = miConfig.Cainfo
  7252. var ids []int64
  7253. for _, item := range prescriptions {
  7254. ids = append(ids, item.ID)
  7255. }
  7256. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7257. if config.IsOpen == 1 { //对接了医保,走医保流程
  7258. var res ResultFour
  7259. var resFour10265 ResultFour10265
  7260. if miConfig.MdtrtareaAdmvs == "421300" {
  7261. bytesData, _ := json.Marshal(data)
  7262. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7263. resp, _ := client.Do(req)
  7264. defer resp.Body.Close()
  7265. body, ioErr := ioutil.ReadAll(resp.Body)
  7266. if ioErr != nil {
  7267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7269. return
  7270. }
  7271. var respJSON map[string]interface{}
  7272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7275. return
  7276. }
  7277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7278. userJSONBytes, _ := json.Marshal(respJSON)
  7279. fmt.Println("log")
  7280. fmt.Println(string(userJSONBytes))
  7281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7282. utils.ErrorLog("解析失败:%v", err)
  7283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7284. return
  7285. }
  7286. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7287. bytesData, _ := json.Marshal(data)
  7288. var req *http.Request
  7289. if miConfig.MdtrtareaAdmvs == "320921" {
  7290. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7291. } else {
  7292. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7293. }
  7294. resp, _ := client.Do(req)
  7295. defer resp.Body.Close()
  7296. body, ioErr := ioutil.ReadAll(resp.Body)
  7297. if ioErr != nil {
  7298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7300. return
  7301. }
  7302. var respJSON map[string]interface{}
  7303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7306. return
  7307. }
  7308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7309. userJSONBytes, _ := json.Marshal(respJSON)
  7310. fmt.Println("log")
  7311. fmt.Println(string(userJSONBytes))
  7312. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7313. utils.ErrorLog("解析失败:%v", err)
  7314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7315. return
  7316. }
  7317. res.InfRefmsgid = resFour10265.InfRefmsgid
  7318. res.Output = resFour10265.Output
  7319. res.ErrMsg = resFour10265.ErrMsg
  7320. res.Cainfo = resFour10265.Cainfo
  7321. res.WarnMsg = resFour10265.WarnMsg
  7322. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7323. res.Infcode = infocode
  7324. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7325. 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)
  7326. var dat map[string]interface{}
  7327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7328. fmt.Println(dat)
  7329. } else {
  7330. fmt.Println(err)
  7331. }
  7332. saveLog(result, request_log, "2204", "上传费用明细")
  7333. userJSONBytes, _ := json.Marshal(dat)
  7334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7335. utils.ErrorLog("解析失败:%v", err)
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. return
  7338. }
  7339. } else {
  7340. if miConfig.Code == "H15049901371" {
  7341. 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)
  7342. var dat map[string]interface{}
  7343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7344. fmt.Println(dat)
  7345. } else {
  7346. fmt.Println(err)
  7347. }
  7348. saveLog(result, request_log, "2204", "上传费用明细")
  7349. userJSONBytes, _ := json.Marshal(dat)
  7350. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7351. utils.ErrorLog("解析失败:%v", err)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. return
  7354. }
  7355. res.InfRefmsgid = resFour10265.InfRefmsgid
  7356. res.Output = resFour10265.Output
  7357. res.ErrMsg = resFour10265.ErrMsg
  7358. res.Cainfo = resFour10265.Cainfo
  7359. res.WarnMsg = resFour10265.WarnMsg
  7360. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7361. res.Infcode = infocode
  7362. } else {
  7363. 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)
  7364. var dat map[string]interface{}
  7365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7366. fmt.Println(dat)
  7367. } else {
  7368. fmt.Println(err)
  7369. }
  7370. saveLog(result, request_log, "2204", "上传费用明细")
  7371. userJSONBytes, _ := json.Marshal(dat)
  7372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7373. utils.ErrorLog("解析失败:%v", err)
  7374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7375. return
  7376. }
  7377. }
  7378. }
  7379. if res.Infcode == 0 {
  7380. order := &models.HisOrder{
  7381. UserOrgId: adminUser.CurrentOrgId,
  7382. HisPatientId: his.ID,
  7383. PatientId: his.PatientId,
  7384. SettleAccountsDate: recordDateTime,
  7385. Ctime: time.Now().Unix(),
  7386. Mtime: time.Now().Unix(),
  7387. MdtrtId: his.Number,
  7388. PsnNo: his.PsnNo,
  7389. MedType: strconv.FormatInt(reg_type, 10),
  7390. Status: 1,
  7391. Number: chrg_bchno,
  7392. Infcode: res.Infcode,
  7393. WarnMsg: res.WarnMsg,
  7394. Cainfo: res.Cainfo,
  7395. ErrMsg: res.ErrMsg,
  7396. RespondTime: res.RefmsgTime,
  7397. InfRefmsgid: res.InfRefmsgid,
  7398. OrderStatus: 1,
  7399. IsMedicineInsurance: 1,
  7400. SettleType: settle_accounts_type,
  7401. SettleStartTime: start_time,
  7402. SettleEndTime: end_time,
  7403. Creator: roles.AdminUserId,
  7404. Modify: roles.AdminUserId,
  7405. PType: 2,
  7406. Diagnosis: diagnosis_id,
  7407. }
  7408. err = service.CreateOrder(order)
  7409. if err != nil {
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7411. return
  7412. }
  7413. for _, item := range res.Output.Result {
  7414. temp := strings.Split(item.FeedetlSn, "-")
  7415. var advice_id int64 = 0
  7416. var project_id int64 = 0
  7417. var types int64 = 0
  7418. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7419. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7420. if temp[1] == "1" {
  7421. advice_id = id
  7422. project_id = 0
  7423. } else if temp[1] == "2" {
  7424. advice_id = 0
  7425. project_id = id
  7426. }
  7427. info := &models.HisOrderInfo{
  7428. OrderNumber: order.Number,
  7429. FeedetlSn: item.FeedetlSn,
  7430. UploadDate: time.Now().Unix(),
  7431. AdviceId: advice_id,
  7432. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7433. Cnt: item.Cnt,
  7434. Pric: float64(item.Pric),
  7435. PatientId: his.PatientId,
  7436. PricUplmtAmt: item.PricUplmtAmt,
  7437. SelfpayProp: item.SelfpayProp,
  7438. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7439. OverlmtAmt: item.OverlmtAmt,
  7440. PreselfpayAmt: item.PreselfpayAmt,
  7441. BasMednFlag: item.BasMednFlag,
  7442. MedChrgitmType: item.MedChrgitmType,
  7443. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7444. Status: 1,
  7445. Memo: item.Memo,
  7446. Mtime: time.Now().Unix(),
  7447. InscpScpAmt: item.InscpScpAmt,
  7448. DrtReimFlag: item.DrtReimFlag,
  7449. Ctime: time.Now().Unix(),
  7450. ListSpItemFlag: item.ListSpItemFlag,
  7451. ChldMedcFlag: item.ChldMedcFlag,
  7452. LmtUsedFlag: item.LmtUsedFlag,
  7453. ChrgitmLv: item.ChrgitmLv,
  7454. UserOrgId: adminUser.CurrentOrgId,
  7455. HisPatientId: his.ID,
  7456. OrderId: order.ID,
  7457. ProjectId: project_id,
  7458. Type: types,
  7459. }
  7460. service.CreateOrderInfo(info)
  7461. }
  7462. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7463. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7464. var total float64
  7465. for _, item := range prescriptions {
  7466. if item.Type == 1 { //药品
  7467. for _, subItem := range item.HisDoctorAdviceInfo {
  7468. total = total + (subItem.Price * subItem.PrescribingNumber)
  7469. }
  7470. }
  7471. if item.Type == 2 { //项目
  7472. for _, subItem := range item.HisPrescriptionProject {
  7473. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7474. total = total + (subItem.Price * cnt)
  7475. }
  7476. }
  7477. }
  7478. for _, item := range prescriptions {
  7479. for _, subItem := range item.HisAdditionalCharge {
  7480. total = total + (subItem.Price * float64(subItem.Count))
  7481. }
  7482. }
  7483. allTotal := fmt.Sprintf("%.4f", total)
  7484. if res.Infcode == 0 {
  7485. var rf []*ResultFive
  7486. json.Unmarshal([]byte(his.Iinfo), &rf)
  7487. chrg_bchno := chrg_bchno
  7488. cert_no := his.Certno
  7489. var insutypes []string
  7490. var insutype string
  7491. var is390 int = 0
  7492. var is310 int = 0
  7493. for _, item := range rf {
  7494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7495. insutypes = append(insutypes, item.Insutype)
  7496. }
  7497. }
  7498. if len(insutypes) == 1 {
  7499. insutype = insutypes[0]
  7500. } else {
  7501. for _, i := range insutypes {
  7502. if i == "390" {
  7503. is390 = 1
  7504. }
  7505. if i == "310" {
  7506. is310 = 1
  7507. }
  7508. }
  7509. }
  7510. if is390 == 1 {
  7511. insutype = "390"
  7512. }
  7513. if is310 == 1 {
  7514. insutype = "310"
  7515. }
  7516. if len(insutypes) == 0 {
  7517. insutype = "310"
  7518. }
  7519. if len(insutypes) == 2 {
  7520. insutype = strconv.FormatInt(his.SocialType, 64)
  7521. }
  7522. //insutype = "390"
  7523. if his.IdCardType == 1 {
  7524. cert_no = his.MedicalInsuranceNumber
  7525. } else {
  7526. cert_no = his.Certno
  7527. }
  7528. var res ResultSeven
  7529. var resSeven10265 ResultSeven10265
  7530. if miConfig.MdtrtareaAdmvs == "421300" {
  7531. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7532. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7533. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7535. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7536. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7537. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7538. resp, requestErr := http.Get(api)
  7539. if requestErr != nil {
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. body, ioErr := ioutil.ReadAll(resp.Body)
  7544. if ioErr != nil {
  7545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. var respJSON map[string]interface{}
  7550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7556. result, _ := json.Marshal(respJSON)
  7557. fmt.Println("log")
  7558. fmt.Println(string(result))
  7559. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7560. utils.ErrorLog("解析失败:%v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7565. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7566. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7567. bas := strings.Split(psn_info.CardInfo, "|")
  7568. if his.IdCardType == 1 {
  7569. cert_no = bas[2]
  7570. } else {
  7571. cert_no = bas[1]
  7572. }
  7573. //江苏地区国家医保医疗类别
  7574. //职工透析:医疗类别选特殊情况门诊9933
  7575. //居民血透门慢: 医疗类别选门诊慢病1402
  7576. //var med_type string
  7577. //if his.Insutype == "310" {
  7578. // if reg_type == 14 {
  7579. // med_type = "9933"
  7580. // } else if reg_type == 11 {
  7581. // med_type = "11"
  7582. //
  7583. // }
  7584. //} else if his.Insutype == "390" {
  7585. // if reg_type == 14 {
  7586. // med_type = "1402"
  7587. // } else if reg_type == 11 {
  7588. // med_type = "11"
  7589. // }
  7590. //}
  7591. var api string
  7592. if miConfig.MdtrtareaAdmvs == "320921" {
  7593. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7594. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7595. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7596. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7597. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7598. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7599. "&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
  7600. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7601. } else {
  7602. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7603. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7604. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7605. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7607. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7608. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7609. "&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
  7610. }
  7611. resp, requestErr := http.Get(api)
  7612. if requestErr != nil {
  7613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7614. return
  7615. }
  7616. body, ioErr := ioutil.ReadAll(resp.Body)
  7617. if ioErr != nil {
  7618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7620. return
  7621. }
  7622. var respJSON map[string]interface{}
  7623. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7626. return
  7627. }
  7628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7629. result, _ := json.Marshal(respJSON)
  7630. fmt.Println("log")
  7631. fmt.Println(string(result))
  7632. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7633. utils.ErrorLog("解析失败:%v", err)
  7634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7635. return
  7636. }
  7637. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7638. res.Output = resSeven10265.Output
  7639. res.ErrMsg = resSeven10265.ErrMsg
  7640. res.Cainfo = resSeven10265.Cainfo
  7641. res.WarnMsg = resSeven10265.WarnMsg
  7642. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7643. res.Infcode = infocode
  7644. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7645. 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)
  7646. var dat map[string]interface{}
  7647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7648. fmt.Println(dat)
  7649. } else {
  7650. fmt.Println(err)
  7651. }
  7652. saveLog(result, request_log, "2206", "预结算")
  7653. userJSONBytes, _ := json.Marshal(dat)
  7654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7655. utils.ErrorLog("解析失败:%v", err)
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7657. return
  7658. }
  7659. } else {
  7660. var result string
  7661. var request_log string
  7662. if miConfig.Code == "H15049901371" {
  7663. //赤峰地区国家医保医疗类别
  7664. //职工透析:医疗类别选特殊情况门诊990502
  7665. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7666. var med_type string
  7667. if his.Insutype == "390" {
  7668. if reg_type == 14 {
  7669. med_type = "9933"
  7670. } else if reg_type == 11 {
  7671. med_type = "11"
  7672. }
  7673. } else if his.Insutype == "310" {
  7674. if reg_type == 14 {
  7675. med_type = "990502"
  7676. } else if reg_type == 11 {
  7677. med_type = "11"
  7678. }
  7679. }
  7680. 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)
  7681. } else {
  7682. 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)
  7683. }
  7684. var dat map[string]interface{}
  7685. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7686. fmt.Println(dat)
  7687. } else {
  7688. fmt.Println(err)
  7689. }
  7690. saveLog(result, request_log, "2206", "预结算")
  7691. //userJSONBytes, _ := json.Marshal(dat)
  7692. //
  7693. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7694. // utils.ErrorLog("解析失败:%v", err)
  7695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7696. // return
  7697. //}
  7698. userJSONBytes, _ := json.Marshal(dat)
  7699. if miConfig.Code == "H15049901371" {
  7700. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7701. utils.ErrorLog("解析失败:%v", err)
  7702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7703. return
  7704. }
  7705. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7706. res.Output = resSeven10265.Output
  7707. res.ErrMsg = resSeven10265.ErrMsg
  7708. res.Cainfo = resSeven10265.Cainfo
  7709. res.WarnMsg = resSeven10265.WarnMsg
  7710. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7711. res.Infcode = infocode
  7712. } else {
  7713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7714. utils.ErrorLog("解析失败:%v", err)
  7715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7716. return
  7717. }
  7718. }
  7719. }
  7720. if res.Infcode != 0 {
  7721. errlog := &models.HisOrderError{
  7722. UserOrgId: adminUser.CurrentOrgId,
  7723. Ctime: time.Now().Unix(),
  7724. Mtime: time.Now().Unix(),
  7725. Number: chrg_bchno,
  7726. ErrMsg: res.ErrMsg,
  7727. Status: 1,
  7728. PatientId: id,
  7729. RecordTime: recordDateTime,
  7730. Stage: 20,
  7731. }
  7732. service.CreateErrMsgLog(errlog)
  7733. c.ServeSuccessJSON(map[string]interface{}{
  7734. "failed_code": -10,
  7735. "msg": res.ErrMsg,
  7736. })
  7737. return
  7738. } else {
  7739. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7740. order.OrderStatus = 1
  7741. order.IsPre = 1
  7742. order.Status = 1
  7743. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7744. order.SetlId = res.Output.Setlinfo.SetlID
  7745. order.PsnNo = res.Output.Setlinfo.PsnNo
  7746. order.PsnName = res.Output.Setlinfo.PsnName
  7747. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7748. order.Certno = res.Output.Setlinfo.Certno
  7749. order.Gend = res.Output.Setlinfo.Gend
  7750. order.Naty = res.Output.Setlinfo.Naty
  7751. order.Age = res.Output.Setlinfo.Age
  7752. order.Insutype = res.Output.Setlinfo.Insutype
  7753. order.PsnType = res.Output.Setlinfo.PsnType
  7754. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7755. order.SetlTime = res.Output.Setlinfo.SetlTime
  7756. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7757. if res.Output.Setlinfo.MedType == "140101" {
  7758. order.MedType = "14"
  7759. } else {
  7760. order.MedType = res.Output.Setlinfo.MedType
  7761. }
  7762. if reg_type == 1112 {
  7763. order.MedType = "1112"
  7764. }
  7765. if reg_type == 1111 {
  7766. order.MedType = "1111"
  7767. }
  7768. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7769. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7770. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7771. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7772. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7773. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7774. order.HifpPay = res.Output.Setlinfo.HifpPay
  7775. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7776. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7777. order.HifesPay = res.Output.Setlinfo.HifesPay
  7778. order.HifobPay = res.Output.Setlinfo.HifobPay
  7779. order.MafPay = res.Output.Setlinfo.MafPay
  7780. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7781. order.OthPay = res.Output.Setlinfo.OthPay
  7782. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7783. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7784. order.AcctPay = res.Output.Setlinfo.AcctPay
  7785. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7786. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7787. order.Balc = res.Output.Setlinfo.Balc
  7788. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7789. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7790. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7791. order.ClrWay = res.Output.Setlinfo.ClrWay
  7792. order.Creator = order.Creator
  7793. order.Modify = roles.AdminUserId
  7794. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7795. detailStr := string(setlDetail)
  7796. order.SetlDetail = detailStr
  7797. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7798. err = service.UpDateOrder(order)
  7799. if err == nil {
  7800. c.ServeSuccessJSON(map[string]interface{}{
  7801. "msg": "预结算成功",
  7802. })
  7803. } else {
  7804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7805. return
  7806. }
  7807. }
  7808. } else {
  7809. adminUser := c.GetAdminUserInfo()
  7810. errlog := &models.HisOrderError{
  7811. UserOrgId: adminUser.CurrentOrgId,
  7812. Ctime: time.Now().Unix(),
  7813. Mtime: time.Now().Unix(),
  7814. ErrMsg: res.ErrMsg,
  7815. Status: 1,
  7816. PatientId: id,
  7817. RecordTime: recordDateTime,
  7818. Stage: 4,
  7819. }
  7820. service.CreateErrMsgLog(errlog)
  7821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7822. return
  7823. }
  7824. } else {
  7825. adminUser := c.GetAdminUserInfo()
  7826. errlog := &models.HisOrderError{
  7827. UserOrgId: adminUser.CurrentOrgId,
  7828. Ctime: time.Now().Unix(),
  7829. Mtime: time.Now().Unix(),
  7830. ErrMsg: res.ErrMsg,
  7831. Status: 1,
  7832. PatientId: id,
  7833. RecordTime: recordDateTime,
  7834. Stage: 4,
  7835. }
  7836. service.CreateErrMsgLog(errlog)
  7837. c.ServeSuccessJSON(map[string]interface{}{
  7838. "failed_code": -10,
  7839. "msg": res.ErrMsg,
  7840. })
  7841. return
  7842. }
  7843. }
  7844. }
  7845. }
  7846. //退款
  7847. func (c *HisApiController) Refund() {
  7848. order_id, _ := c.GetInt64("order_id")
  7849. admin_user_id, _ := c.GetInt64("admin_user_id")
  7850. adminUser := c.GetAdminUserInfo()
  7851. var order models.HisOrder
  7852. order, _ = service.GetHisOrderByID(order_id)
  7853. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7854. if order.ID == 0 {
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7856. return
  7857. }
  7858. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7859. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7860. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7861. if config.IsOpen == 1 { //对接了医保,走医保流程
  7862. var res ResultSixteen
  7863. var resSixteen10265 ResultSixteen10265
  7864. var src_resquest string
  7865. var result string
  7866. if miConfig.MdtrtareaAdmvs == "421300" {
  7867. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7868. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7869. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7870. resp3, requestErr3 := http.Get(api3)
  7871. if requestErr3 != nil {
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7876. if ioErr3 != nil {
  7877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. return
  7880. }
  7881. var respJSON3 map[string]interface{}
  7882. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7885. return
  7886. }
  7887. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7888. userJSONBytes3, _ := json.Marshal(respJSON3)
  7889. fmt.Println("log")
  7890. fmt.Println(string(userJSONBytes3))
  7891. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7892. utils.ErrorLog("解析失败:%v", err)
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7894. return
  7895. }
  7896. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7897. var api3 string
  7898. if miConfig.MdtrtareaAdmvs == "320921" {
  7899. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7900. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7901. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7902. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7903. } else {
  7904. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7905. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7906. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7907. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7908. }
  7909. resp3, requestErr3 := http.Get(api3)
  7910. if requestErr3 != nil {
  7911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7912. return
  7913. }
  7914. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7915. if ioErr3 != nil {
  7916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7918. return
  7919. }
  7920. var respJSON3 map[string]interface{}
  7921. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7924. return
  7925. }
  7926. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7927. userJSONBytes3, _ := json.Marshal(respJSON3)
  7928. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7929. utils.ErrorLog("解析失败:%v", err)
  7930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7931. return
  7932. }
  7933. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7934. res.Output = resSixteen10265.Output
  7935. res.ErrMsg = resSixteen10265.ErrMsg
  7936. res.Cainfo = resSixteen10265.Cainfo
  7937. res.WarnMsg = resSixteen10265.WarnMsg
  7938. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7939. res.Infcode = infocode
  7940. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7941. 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)
  7942. var dat map[string]interface{}
  7943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7944. fmt.Println(dat)
  7945. } else {
  7946. fmt.Println(err)
  7947. }
  7948. saveLog(result, src_resquest, "2208", "退费")
  7949. userJSONBytes, _ := json.Marshal(dat)
  7950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7951. utils.ErrorLog("解析失败:%v", err)
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7953. return
  7954. }
  7955. } else {
  7956. if miConfig.Code == "H15049901371" {
  7957. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7958. var dat map[string]interface{}
  7959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7960. fmt.Println(dat)
  7961. } else {
  7962. fmt.Println(err)
  7963. }
  7964. saveLog(result, src_resquest, "2208", "退费")
  7965. userJSONBytes, _ := json.Marshal(dat)
  7966. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7967. utils.ErrorLog("解析失败:%v", err)
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7972. res.Output = resSixteen10265.Output
  7973. res.ErrMsg = resSixteen10265.ErrMsg
  7974. res.Cainfo = resSixteen10265.Cainfo
  7975. res.WarnMsg = resSixteen10265.WarnMsg
  7976. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7977. res.Infcode = infocode
  7978. } else {
  7979. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7980. var dat map[string]interface{}
  7981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7982. fmt.Println(dat)
  7983. } else {
  7984. fmt.Println(err)
  7985. }
  7986. saveLog(result, src_resquest, "2208", "退费")
  7987. userJSONBytes, _ := json.Marshal(dat)
  7988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7989. utils.ErrorLog("解析失败:%v", err)
  7990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. return
  7992. }
  7993. }
  7994. }
  7995. if res.Infcode == 0 {
  7996. var res2 ResultSix
  7997. var resSix10265 ResultSix10265
  7998. if miConfig.MdtrtareaAdmvs == "421300" {
  7999. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8000. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8001. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8002. resp3, requestErr3 := http.Get(api3)
  8003. if requestErr3 != nil {
  8004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8005. return
  8006. }
  8007. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8008. if ioErr3 != nil {
  8009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8011. return
  8012. }
  8013. var respJSON3 map[string]interface{}
  8014. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8017. return
  8018. }
  8019. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8020. userJSONBytes3, _ := json.Marshal(respJSON3)
  8021. fmt.Println("log")
  8022. fmt.Println(string(userJSONBytes3))
  8023. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8024. utils.ErrorLog("解析失败:%v", err)
  8025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8026. return
  8027. }
  8028. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8029. var api3 string
  8030. if miConfig.MdtrtareaAdmvs == "320921" {
  8031. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8032. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8034. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8035. } else {
  8036. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8037. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8038. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8039. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8040. }
  8041. resp3, requestErr3 := http.Get(api3)
  8042. if requestErr3 != nil {
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8044. return
  8045. }
  8046. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8047. if ioErr3 != nil {
  8048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. return
  8051. }
  8052. var respJSON3 map[string]interface{}
  8053. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8059. userJSONBytes3, _ := json.Marshal(respJSON3)
  8060. fmt.Println("log")
  8061. fmt.Println(string(userJSONBytes3))
  8062. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8063. utils.ErrorLog("解析失败:%v", err)
  8064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8065. return
  8066. }
  8067. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8068. res2.Output = resSix10265.Output
  8069. res2.ErrMsg = resSix10265.ErrMsg
  8070. res2.Cainfo = resSix10265.Cainfo
  8071. res2.WarnMsg = resSix10265.WarnMsg
  8072. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8073. res2.Infcode = infocode
  8074. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8075. 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)
  8076. var dat map[string]interface{}
  8077. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8078. fmt.Println(dat)
  8079. } else {
  8080. fmt.Println(err)
  8081. }
  8082. saveLog(result2, src_request, "2205", "撤销明细")
  8083. userJSONBytes, _ := json.Marshal(dat)
  8084. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8085. utils.ErrorLog("解析失败:%v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. } else {
  8090. if miConfig.Code == "H15049901371" {
  8091. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8092. var dat map[string]interface{}
  8093. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8094. fmt.Println(dat)
  8095. } else {
  8096. fmt.Println(err)
  8097. }
  8098. saveLog(result2, src_request, "2205", "撤销明细")
  8099. userJSONBytes, _ := json.Marshal(dat)
  8100. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8101. utils.ErrorLog("解析失败:%v", err)
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8106. res2.Output = resSix10265.Output
  8107. res2.ErrMsg = resSix10265.ErrMsg
  8108. res2.Cainfo = resSix10265.Cainfo
  8109. res2.WarnMsg = resSix10265.WarnMsg
  8110. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8111. res2.Infcode = infocode
  8112. } else {
  8113. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8114. var dat map[string]interface{}
  8115. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8116. fmt.Println(dat)
  8117. } else {
  8118. fmt.Println(err)
  8119. }
  8120. saveLog(result2, src_request, "2205", "撤销明细")
  8121. userJSONBytes, _ := json.Marshal(dat)
  8122. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8123. utils.ErrorLog("解析失败:%v", err)
  8124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. return
  8126. }
  8127. }
  8128. }
  8129. if res2.Infcode == 0 {
  8130. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8131. if err == nil {
  8132. //当押金不为零时产生退费记录
  8133. if order.Decimal != 0 {
  8134. tmp := strconv.FormatInt(order.ID, 10)
  8135. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8136. if err != nil {
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. return
  8139. }
  8140. }
  8141. c.ServeSuccessJSON(map[string]interface{}{
  8142. "msg": "退费成功",
  8143. })
  8144. } else {
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. } else {
  8149. c.ServeSuccessJSON(map[string]interface{}{
  8150. "code": -10,
  8151. "msg": res2.ErrMsg,
  8152. })
  8153. }
  8154. } else {
  8155. c.ServeSuccessJSON(map[string]interface{}{
  8156. "code": -10,
  8157. "msg": res.ErrMsg,
  8158. })
  8159. }
  8160. }
  8161. }
  8162. func (c *HisApiController) RefundNumber() {
  8163. record_time := c.GetString("record_time")
  8164. //patient_id, _ := c.GetInt64("patient_id")
  8165. admin_user_id, _ := c.GetInt64("admin_user_id")
  8166. his_patient_id, _ := c.GetInt64("id")
  8167. timeLayout := "2006-01-02"
  8168. loc, _ := time.LoadLocation("Local")
  8169. adminUser := c.GetAdminUserInfo()
  8170. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8171. fmt.Println(err)
  8172. if err != nil {
  8173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8174. return
  8175. }
  8176. recordDateTime := theTime.Unix()
  8177. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8178. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8179. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8180. //order, _ := service.GetHisOrderByID(order_id)
  8181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8182. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8183. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8184. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8185. if count > 0 {
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8187. return
  8188. }
  8189. if config.IsOpen == 1 { //对接了医保,走医保流程
  8190. var res2 ResultSix
  8191. var resSix10265 ResultSix10265
  8192. if miConfig.MdtrtareaAdmvs == "421300" {
  8193. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8194. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8195. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8196. resp3, requestErr3 := http.Get(api3)
  8197. if requestErr3 != nil {
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8202. if ioErr3 != nil {
  8203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. var respJSON3 map[string]interface{}
  8208. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8214. userJSONBytes3, _ := json.Marshal(respJSON3)
  8215. fmt.Println("log")
  8216. fmt.Println(string(userJSONBytes3))
  8217. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8218. utils.ErrorLog("解析失败:%v", err)
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8220. return
  8221. }
  8222. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8223. var api3 string
  8224. if miConfig.MdtrtareaAdmvs == "320921" {
  8225. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8226. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8228. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8229. } else {
  8230. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8231. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8232. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8233. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8234. }
  8235. resp3, requestErr3 := http.Get(api3)
  8236. if requestErr3 != nil {
  8237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8238. return
  8239. }
  8240. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8241. if ioErr3 != nil {
  8242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8244. return
  8245. }
  8246. var respJSON3 map[string]interface{}
  8247. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8253. userJSONBytes3, _ := json.Marshal(respJSON3)
  8254. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8255. utils.ErrorLog("解析失败:%v", err)
  8256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8257. return
  8258. }
  8259. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8260. res2.Output = resSix10265.Output
  8261. res2.ErrMsg = resSix10265.ErrMsg
  8262. res2.Cainfo = resSix10265.Cainfo
  8263. res2.WarnMsg = resSix10265.WarnMsg
  8264. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8265. res2.Infcode = infocode
  8266. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8267. 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)
  8268. var dat map[string]interface{}
  8269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8270. fmt.Println(dat)
  8271. } else {
  8272. fmt.Println(err)
  8273. }
  8274. saveLog(result, request, "2202", "退号")
  8275. userJSONBytes, _ := json.Marshal(dat)
  8276. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8277. utils.ErrorLog("解析失败:%v", err)
  8278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. return
  8280. }
  8281. } else {
  8282. var api3 string
  8283. if miConfig.Code == "H15049901371" {
  8284. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8285. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8286. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8287. } else {
  8288. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8289. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8290. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8291. }
  8292. resp3, requestErr3 := http.Get(api3)
  8293. if requestErr3 != nil {
  8294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8295. return
  8296. }
  8297. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8298. if ioErr3 != nil {
  8299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8301. return
  8302. }
  8303. var respJSON3 map[string]interface{}
  8304. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8307. return
  8308. }
  8309. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8310. userJSONBytes3, _ := json.Marshal(respJSON3)
  8311. if miConfig.Code == "H15049901371" {
  8312. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8313. utils.ErrorLog("解析失败:%v", err)
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8318. res2.Output = resSix10265.Output
  8319. res2.ErrMsg = resSix10265.ErrMsg
  8320. res2.Cainfo = resSix10265.Cainfo
  8321. res2.WarnMsg = resSix10265.WarnMsg
  8322. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8323. res2.Infcode = infocode
  8324. } else {
  8325. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8326. utils.ErrorLog("解析失败:%v", err)
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8328. return
  8329. }
  8330. }
  8331. }
  8332. if res2.Infcode == 0 {
  8333. if err == nil {
  8334. c.ServeSuccessJSON(map[string]interface{}{
  8335. "msg": "退号成功",
  8336. })
  8337. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8338. } else {
  8339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8340. return
  8341. }
  8342. } else {
  8343. c.ServeSuccessJSON(map[string]interface{}{
  8344. "code": -10,
  8345. "msg": res2.ErrMsg,
  8346. })
  8347. }
  8348. } else {
  8349. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8350. //if err == nil {
  8351. // c.ServeSuccessJSON(map[string]interface{}{
  8352. // "msg": "退费成功",
  8353. // })
  8354. //} else {
  8355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8356. // return
  8357. //}
  8358. }
  8359. }
  8360. func (c *HisApiController) RefundDetail() {
  8361. order_id, _ := c.GetInt64("order_id")
  8362. admin_user_id, _ := c.GetInt64("admin_user_id")
  8363. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8364. number := c.GetString("number")
  8365. record_time := c.GetString("record_time")
  8366. patient_id, _ := c.GetInt64("patient_id")
  8367. //med_type, _ := c.GetInt64("med_type")
  8368. timeLayout := "2006-01-02"
  8369. loc, _ := time.LoadLocation("Local")
  8370. adminUser := c.GetAdminUserInfo()
  8371. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8372. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8373. fmt.Println(err)
  8374. if err != nil {
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8376. return
  8377. }
  8378. recordDateTime := theTime.Unix()
  8379. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8380. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8382. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8383. var order models.HisOrder
  8384. order, _ = service.GetHisOrderByID(order_id)
  8385. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8386. if config.IsOpen == 1 { //对接了医保,走医保流程
  8387. var res2 ResultSix
  8388. if miConfig.MdtrtareaAdmvs == "421300" {
  8389. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8390. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8391. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8392. resp3, requestErr3 := http.Get(api3)
  8393. if requestErr3 != nil {
  8394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8395. return
  8396. }
  8397. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8398. if ioErr3 != nil {
  8399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8401. return
  8402. }
  8403. var respJSON3 map[string]interface{}
  8404. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8407. return
  8408. }
  8409. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8410. userJSONBytes3, _ := json.Marshal(respJSON3)
  8411. fmt.Println("log")
  8412. fmt.Println(string(userJSONBytes3))
  8413. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8414. utils.ErrorLog("解析失败:%v", err)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8419. if err == nil {
  8420. c.ServeSuccessJSON(map[string]interface{}{
  8421. "msg": "撤销明细成功",
  8422. })
  8423. return
  8424. } else {
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8429. var resSix10265 ResultSix10265
  8430. var api3 string
  8431. if miConfig.MdtrtareaAdmvs == "320921" {
  8432. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8433. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8434. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8435. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8436. } else {
  8437. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8438. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8439. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8441. }
  8442. resp3, requestErr3 := http.Get(api3)
  8443. if requestErr3 != nil {
  8444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8445. return
  8446. }
  8447. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8448. if ioErr3 != nil {
  8449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8451. return
  8452. }
  8453. var respJSON3 map[string]interface{}
  8454. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8460. userJSONBytes3, _ := json.Marshal(respJSON3)
  8461. fmt.Println("log")
  8462. fmt.Println(string(userJSONBytes3))
  8463. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8464. utils.ErrorLog("解析失败:%v", err)
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8469. res2.Output = resSix10265.Output
  8470. res2.ErrMsg = resSix10265.ErrMsg
  8471. res2.Cainfo = resSix10265.Cainfo
  8472. res2.WarnMsg = resSix10265.WarnMsg
  8473. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8474. res2.Infcode = infocode
  8475. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8476. if err == nil {
  8477. c.ServeSuccessJSON(map[string]interface{}{
  8478. "msg": "撤销明细成功",
  8479. })
  8480. return
  8481. } else {
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8486. 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)
  8487. var dat map[string]interface{}
  8488. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8489. fmt.Println(dat)
  8490. } else {
  8491. fmt.Println(err)
  8492. }
  8493. saveLog(result2, src_request, "2205", "撤销明细")
  8494. userJSONBytes, _ := json.Marshal(dat)
  8495. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8496. utils.ErrorLog("解析失败:%v", err)
  8497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8498. return
  8499. }
  8500. if res2.Infcode == 0 {
  8501. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8502. if err == nil {
  8503. c.ServeSuccessJSON(map[string]interface{}{
  8504. "msg": "撤销明细成功",
  8505. })
  8506. return
  8507. } else {
  8508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8509. return
  8510. }
  8511. } else {
  8512. c.ServeSuccessJSON(map[string]interface{}{
  8513. "code": -10,
  8514. "msg": res2.ErrMsg,
  8515. })
  8516. }
  8517. } else {
  8518. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8519. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8520. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8521. resp2, requestErr2 := http.Get(api2)
  8522. if requestErr2 != nil {
  8523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8524. return
  8525. }
  8526. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8527. if ioErr2 != nil {
  8528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8530. return
  8531. }
  8532. var respJSON2 map[string]interface{}
  8533. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8536. return
  8537. }
  8538. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8539. if err == nil {
  8540. c.ServeSuccessJSON(map[string]interface{}{
  8541. "msg": "撤销明细成功",
  8542. })
  8543. return
  8544. } else {
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. }
  8549. } else {
  8550. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8551. if err == nil {
  8552. c.ServeSuccessJSON(map[string]interface{}{
  8553. "msg": "退费成功",
  8554. })
  8555. } else {
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. }
  8560. }
  8561. //对账
  8562. func (c *HisApiController) GetCheckAccount() {
  8563. start_time := c.GetString("start_time")
  8564. end_time := c.GetString("end_time")
  8565. insutype := c.GetString("insutype")
  8566. clr_type := c.GetString("clr_type")
  8567. clr_org := c.GetString("clr_optins")
  8568. admin_user_id, _ := c.GetInt64("admin_user_id")
  8569. adminUser := c.GetAdminUserInfo()
  8570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8571. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8572. if len(clr_org) == 0 {
  8573. clr_org = miConfig.MdtrtareaAdmvs
  8574. }
  8575. timeLayout := "2006-01-02"
  8576. loc, _ := time.LoadLocation("Local")
  8577. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8578. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8579. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8580. fixmedins_setl_cnt := int64(len(orders))
  8581. var medfee_sumamt float64
  8582. var acct_pay float64
  8583. var fund_pay_sumamt float64
  8584. for _, item := range orders {
  8585. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8586. acct_pay = acct_pay + item.AcctPay
  8587. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8588. }
  8589. var user_name string
  8590. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8591. if role.ID == 0 {
  8592. user_name = "xxx"
  8593. } else {
  8594. user_name = role.UserName
  8595. }
  8596. var res ResultEight
  8597. var res10188 ResultEightFor10188
  8598. if config.IsOpen == 1 {
  8599. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8600. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8601. "insutype=" + insutype +
  8602. "&clr_type=" + clr_type +
  8603. "&setl_optins=" + clr_org +
  8604. "&stmt_begndate=" + start_time +
  8605. "&stm_enddate=" + end_time +
  8606. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8607. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8608. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8609. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8610. "&fixmedins_code=" + miConfig.Code +
  8611. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8612. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8613. "&secret_key=" + miConfig.SecretKey +
  8614. "&org_name=" + miConfig.OrgName +
  8615. "&doctor=" + user_name +
  8616. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8617. fmt.Println(api)
  8618. resp, requestErr := http.Get(api)
  8619. if requestErr != nil {
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8621. return
  8622. }
  8623. body, ioErr := ioutil.ReadAll(resp.Body)
  8624. fmt.Println(body)
  8625. if ioErr != nil {
  8626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. var respJSON map[string]interface{}
  8631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8634. return
  8635. }
  8636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8637. userJSONBytes, _ := json.Marshal(respJSON)
  8638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8639. utils.ErrorLog("解析失败:%v", err)
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8641. return
  8642. }
  8643. res.InfRefmsgid = res10188.InfRefmsgid
  8644. res.Output = res10188.Output
  8645. res.ErrMsg = res10188.ErrMsg
  8646. res.Cainfo = res10188.Cainfo
  8647. res.WarnMsg = res10188.WarnMsg
  8648. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8649. res.Infcode = infocode
  8650. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8651. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8652. "insutype=" + insutype +
  8653. "&clr_type=" + clr_type +
  8654. "&setl_optins=" + clr_org +
  8655. "&stmt_begndate=" + start_time +
  8656. "&stm_enddate=" + end_time +
  8657. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8658. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8659. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8660. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8661. "&fixmedins_code=" + miConfig.Code +
  8662. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8663. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8664. "&secret_key=" + miConfig.SecretKey +
  8665. "&org_name=" + miConfig.OrgName +
  8666. "&doctor=" + user_name
  8667. resp, requestErr := http.Get(api)
  8668. if requestErr != nil {
  8669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8670. return
  8671. }
  8672. body, ioErr := ioutil.ReadAll(resp.Body)
  8673. if ioErr != nil {
  8674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8676. return
  8677. }
  8678. var respJSON map[string]interface{}
  8679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8682. return
  8683. }
  8684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8685. result, _ := json.Marshal(respJSON)
  8686. fmt.Println("log")
  8687. fmt.Println(string(result))
  8688. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8689. utils.ErrorLog("解析失败:%v", err)
  8690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8691. return
  8692. }
  8693. res.InfRefmsgid = res10188.InfRefmsgid
  8694. res.Output = res10188.Output
  8695. res.ErrMsg = res10188.ErrMsg
  8696. res.Cainfo = res10188.Cainfo
  8697. res.WarnMsg = res10188.WarnMsg
  8698. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8699. res.Infcode = infocode
  8700. } else {
  8701. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8702. "insutype=" + insutype +
  8703. "&clr_type=" + clr_type +
  8704. "&setl_optins=" + clr_org +
  8705. "&stmt_begndate=" + start_time +
  8706. "&stm_enddate=" + end_time +
  8707. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8708. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8709. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8710. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8711. "&fixmedins_code=" + miConfig.Code +
  8712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8713. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8714. "&secret_key=" + miConfig.SecretKey +
  8715. "&org_name=" + miConfig.OrgName +
  8716. "&doctor=" + user_name
  8717. fmt.Println(api)
  8718. resp, requestErr := http.Get(api)
  8719. if requestErr != nil {
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. body, ioErr := ioutil.ReadAll(resp.Body)
  8724. fmt.Println(body)
  8725. if ioErr != nil {
  8726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8728. return
  8729. }
  8730. var respJSON map[string]interface{}
  8731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8734. return
  8735. }
  8736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8737. userJSONBytes, _ := json.Marshal(respJSON)
  8738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8739. utils.ErrorLog("解析失败:%v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. }
  8744. if res.Infcode == 0 {
  8745. if res.Output.Stmtinfo.StmtRslt == "0" {
  8746. micc := &models.MedicalInsuranceCostCompare{
  8747. StartTime: startime.Unix(),
  8748. EndTime: endtime.Unix(),
  8749. Insutype: insutype,
  8750. CheckType: 1,
  8751. Num: fixmedins_setl_cnt,
  8752. Mtime: time.Now().Unix(),
  8753. Status: 1,
  8754. UserOrgId: adminUser.CurrentOrgId,
  8755. CostTotal: medfee_sumamt,
  8756. FuncTotal: fund_pay_sumamt,
  8757. PsnPay: acct_pay,
  8758. Creator: admin_user_id,
  8759. Ctime: time.Now().Unix(),
  8760. ClrType: clr_type,
  8761. }
  8762. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8763. if err == nil {
  8764. c.ServeSuccessJSON(map[string]interface{}{
  8765. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8766. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8767. })
  8768. } else {
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. }
  8771. } else {
  8772. c.ServeSuccessJSON(map[string]interface{}{
  8773. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8774. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8775. })
  8776. }
  8777. } else {
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "code": -10,
  8780. "msg": res.ErrMsg,
  8781. })
  8782. }
  8783. }
  8784. }
  8785. func (c *HisApiController) Check310() {
  8786. adminUser := c.GetAdminUserInfo()
  8787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8788. var user_name string
  8789. user_name = "高慧裕"
  8790. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8791. "insutype=" + "310" +
  8792. "&clr_type=" + "" +
  8793. "&setl_optins=" + "441202" +
  8794. "&stmt_begndate=" + "2022-03-01" +
  8795. "&stm_enddate=" + "2022-03-31" +
  8796. "&medfee_sumamt=" + "194930.12" +
  8797. "&fund_pay_sumamt=" + "188741.46" +
  8798. "&acct_pay=" + "0" +
  8799. "&fixmedins_setl_cnt=" + "452" +
  8800. "&fixmedins_code=" + miConfig.Code +
  8801. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8802. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8803. "&secret_key=" + miConfig.SecretKey +
  8804. "&org_name=" + miConfig.OrgName +
  8805. "&doctor=" + user_name
  8806. fmt.Println(api)
  8807. resp, requestErr := http.Get(api)
  8808. if requestErr != nil {
  8809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8810. return
  8811. }
  8812. body, ioErr := ioutil.ReadAll(resp.Body)
  8813. fmt.Println(body)
  8814. if ioErr != nil {
  8815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8817. return
  8818. }
  8819. var respJSON map[string]interface{}
  8820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8823. return
  8824. }
  8825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8826. userJSONBytes, _ := json.Marshal(respJSON)
  8827. var res ResultEight
  8828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8829. utils.ErrorLog("解析失败:%v", err)
  8830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8831. return
  8832. }
  8833. }
  8834. func (c *HisApiController) Check390() {
  8835. adminUser := c.GetAdminUserInfo()
  8836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8837. var user_name string
  8838. user_name = "高慧裕"
  8839. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8840. "insutype=" + "390" +
  8841. "&clr_type=" + "" +
  8842. "&setl_optins=" + "441202" +
  8843. "&stmt_begndate=" + "2022-03-01" +
  8844. "&stm_enddate=" + "2022-03-31" +
  8845. "&medfee_sumamt=" + "1068448.89" +
  8846. "&fund_pay_sumamt=" + "1014677.62" +
  8847. "&acct_pay=" + "0" +
  8848. "&fixmedins_setl_cnt=" + "1950" +
  8849. "&fixmedins_code=" + miConfig.Code +
  8850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8851. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8852. "&secret_key=" + miConfig.SecretKey +
  8853. "&org_name=" + miConfig.OrgName +
  8854. "&doctor=" + user_name
  8855. fmt.Println(api)
  8856. resp, requestErr := http.Get(api)
  8857. if requestErr != nil {
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. body, ioErr := ioutil.ReadAll(resp.Body)
  8862. fmt.Println(body)
  8863. if ioErr != nil {
  8864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. var respJSON map[string]interface{}
  8869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8875. userJSONBytes, _ := json.Marshal(respJSON)
  8876. var res ResultEight
  8877. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8878. utils.ErrorLog("解析失败:%v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. }
  8883. //对账明细
  8884. func (c *HisApiController) GetCheckDetailAccount() {
  8885. start_time := c.GetString("start_time")
  8886. end_time := c.GetString("end_time")
  8887. admin_user_id, _ := c.GetInt64("admin_user_id")
  8888. adminUser := c.GetAdminUserInfo()
  8889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8891. timeLayout := "2006-01-02"
  8892. loc, _ := time.LoadLocation("Local")
  8893. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8894. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8895. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8896. rand.Seed(time.Now().UnixNano())
  8897. num := rand.Intn(30000)
  8898. Mkdir(miConfig.OrgName)
  8899. file := strconv.FormatInt(int64(num), 10)
  8900. file_name := file + ".txt"
  8901. zip_name := file + ".zip"
  8902. zip_path := miConfig.OrgName + "/" + zip_name
  8903. file_path := miConfig.OrgName + "/" + file_name
  8904. decimal.DivisionPrecision = 2
  8905. var medfee_sumamt float64
  8906. var psn_cash_pay float64
  8907. var fund_pay_sumamt float64
  8908. fixmedins_setl_cnt := int64(len(orders))
  8909. for _, item := range orders {
  8910. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8911. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8912. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8913. }
  8914. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8915. defer f.Close()
  8916. if err != nil {
  8917. fmt.Println(err.Error())
  8918. } else {
  8919. for _, item := range orders {
  8920. var refd_setl_flag string
  8921. if item.OrderStatus == 2 {
  8922. refd_setl_flag = "0"
  8923. var str string
  8924. str = item.SetlId + " " +
  8925. item.MdtrtId + " " +
  8926. item.PsnNo + " " +
  8927. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8928. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8929. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8930. _, err = f.Write([]byte(str))
  8931. }
  8932. if item.OrderStatus == 3 {
  8933. var str string
  8934. str = item.SetlId + " " +
  8935. item.MdtrtId + " " +
  8936. item.PsnNo + " " +
  8937. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8938. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8939. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8940. _, err = f.Write([]byte(str))
  8941. var str2 string
  8942. str2 = item.SetlId + " " +
  8943. item.MdtrtId + " " +
  8944. item.PsnNo + " " +
  8945. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8946. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8947. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8948. _, err = f.Write([]byte(str2))
  8949. }
  8950. }
  8951. }
  8952. Zip(file_path, zip_path)
  8953. fmt.Println(ReadFile(zip_path))
  8954. fmt.Println(string(ReadFile(zip_path)))
  8955. if config.IsOpen == 1 {
  8956. var user_name string
  8957. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8958. if role.ID == 0 {
  8959. user_name = "管理员"
  8960. } else {
  8961. user_name = role.UserName
  8962. }
  8963. baseParams := models.BaseParams{
  8964. SecretKey: miConfig.SecretKey,
  8965. FixmedinsCode: miConfig.Code,
  8966. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8967. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8968. OrgName: miConfig.OrgName,
  8969. Doctor: user_name,
  8970. }
  8971. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8972. var dat map[string]interface{}
  8973. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8974. fmt.Println(dat)
  8975. } else {
  8976. fmt.Println(err)
  8977. }
  8978. userJSONBytes, _ := json.Marshal(dat)
  8979. var res ResultNine
  8980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8981. utils.ErrorLog("解析失败:%v", err)
  8982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8983. return
  8984. }
  8985. if res.Infcode == 0 {
  8986. fileNo := res.Output.FileQuryNo
  8987. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8988. "file_qury_no=" + fileNo +
  8989. "&setl_optins=" + "定点医保中心" +
  8990. "&stmt_begndate=" + start_time +
  8991. "&stm_enddate=" + end_time +
  8992. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8993. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8994. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8995. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8996. "&fixmedins_code=" + miConfig.Code +
  8997. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8998. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8999. "&secret_key=" + miConfig.SecretKey +
  9000. "&org_name=" + miConfig.OrgName +
  9001. "&doctor=" + user_name
  9002. resp, requestErr := http.Get(api)
  9003. if requestErr != nil {
  9004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9005. return
  9006. }
  9007. body, ioErr := ioutil.ReadAll(resp.Body)
  9008. if ioErr != nil {
  9009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. return
  9012. }
  9013. var respJSON map[string]interface{}
  9014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9017. return
  9018. }
  9019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9020. userJSONBytes, _ := json.Marshal(respJSON)
  9021. var res ResultTen
  9022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9023. utils.ErrorLog("解析失败:%v", err)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. if res.Infcode == 0 {
  9028. service.Gdyb9102(baseParams, zip_name, fileNo)
  9029. micc := &models.MedicalInsuranceCostCompare{
  9030. StartTime: startime.Unix(),
  9031. EndTime: endtime.Unix(),
  9032. Insutype: "0",
  9033. CheckType: 2,
  9034. Num: fixmedins_setl_cnt,
  9035. Mtime: time.Now().Unix(),
  9036. Status: 1,
  9037. UserOrgId: adminUser.CurrentOrgId,
  9038. CostTotal: medfee_sumamt,
  9039. FuncTotal: fund_pay_sumamt,
  9040. PsnPay: psn_cash_pay,
  9041. Creator: admin_user_id,
  9042. Ctime: time.Now().Unix(),
  9043. }
  9044. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9045. c.ServeSuccessJSON(map[string]interface{}{
  9046. "msg": "明细对账成功",
  9047. })
  9048. }
  9049. } else {
  9050. }
  9051. }
  9052. }
  9053. type CustomOrderInfo struct {
  9054. Name string
  9055. Spec string
  9056. Unit string
  9057. Count float64
  9058. Price float64
  9059. Total float64
  9060. }
  9061. func (c *HisApiController) GetSettleAccounts() {
  9062. //id, _ := c.GetInt64("id")
  9063. //record_time := c.GetString("record_time")
  9064. order_id, _ := c.GetInt64("order_id")
  9065. admin_user_id, _ := c.GetInt64("admin_user_id")
  9066. //timeLayout := "2006-01-02"
  9067. //loc, _ := time.LoadLocation("Local")
  9068. //
  9069. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9070. //if err != nil {
  9071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9072. // return
  9073. //}
  9074. //recordDateTime := theTime.Unix()
  9075. adminUser := c.GetAdminUserInfo()
  9076. order, _ := service.GetHisOrderByID(order_id)
  9077. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9078. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9079. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9080. orderInfos = append(orderInfos, orderInfos_two...)
  9081. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9082. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9083. var diagnosis_ids []string
  9084. if his.ID > 0 {
  9085. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9086. } else {
  9087. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9088. }
  9089. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9090. var dia_config []*models.HisXtDiagnoseConfig
  9091. var name string
  9092. for _, item := range diagnosis_ids {
  9093. id, _ := strconv.ParseInt(item, 10, 64)
  9094. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9095. dia_config = append(dia_config, &diagnosisConfig)
  9096. if len(name) == 0 {
  9097. name = diagnosisConfig.ClassName
  9098. } else {
  9099. name = name + "," + diagnosisConfig.ClassName
  9100. }
  9101. }
  9102. var bedCostTotal float64 = 0 //床位总费
  9103. var bedCostSelfTotal float64 = 0 //床位自费
  9104. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9105. var operationCostTotal float64 = 0 //手术费
  9106. var operationCostSelfTotal float64 = 0 //手术费
  9107. var operationCostPartSelfTotal float64 = 0 //手术费
  9108. var otherCostTotal float64 = 0 //其他费用
  9109. var otherCostSelfTotal float64 = 0 //其他费用
  9110. var otherCostPartSelfTotal float64 = 0 //其他费用
  9111. var materialCostTotal float64 = 0 //材料费
  9112. var materialCostSelfTotal float64 = 0 //材料费
  9113. var materialCostPartSelfTotal float64 = 0 //材料费
  9114. var westernMedicineCostTotal float64 = 0 //西药费
  9115. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9116. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9117. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9118. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9119. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9120. var checkCostTotal float64 = 0 //检查费
  9121. var checkCostSelfTotal float64 = 0 //检查费
  9122. var checkCostPartSelfTotal float64 = 0 //检查费
  9123. var laboratoryCostTotal float64 = 0 //化验费
  9124. var laboratoryCostSelfTotal float64 = 0 //化验费
  9125. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9126. var treatCostTotal float64 = 0 //治疗费用
  9127. var treatCostSelfTotal float64 = 0 //治疗费用
  9128. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9129. decimal.DivisionPrecision = 2
  9130. for _, item := range orderInfos {
  9131. if item.MedChrgitmType == "01" { //床位费
  9132. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9133. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9134. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9135. }
  9136. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9137. if item.MedChrgitmType == "03" { //检查费
  9138. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9139. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9140. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9141. }
  9142. } else {
  9143. if item.MedChrgitmType == "03" { //检查费
  9144. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9145. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9146. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9147. }
  9148. }
  9149. if item.MedChrgitmType == "04" { //化验费
  9150. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9151. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9152. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9153. }
  9154. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9155. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9156. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9157. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9158. }
  9159. if item.MedChrgitmType == "06" { //手术费
  9160. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9161. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9162. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9163. }
  9164. if item.MedChrgitmType == "08" { //材料费
  9165. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9166. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9167. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9168. }
  9169. if item.MedChrgitmType == "09" { //西药费
  9170. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9171. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9172. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9173. }
  9174. if item.MedChrgitmType == "11" { //中成费
  9175. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9176. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9177. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9178. }
  9179. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9180. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9181. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9182. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9183. }
  9184. }
  9185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9186. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9187. var user_name string
  9188. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9189. if role.ID == 0 {
  9190. user_name = "管理员"
  9191. } else {
  9192. user_name = role.UserName
  9193. }
  9194. baseParams := models.BaseParams{
  9195. SecretKey: miConfig.SecretKey,
  9196. FixmedinsCode: miConfig.Code,
  9197. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9198. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9199. OrgName: miConfig.OrgName,
  9200. Doctor: user_name,
  9201. }
  9202. businessParams := models.BusinessParams{
  9203. PsnNo: order.PsnNo,
  9204. MdtrtId: order.MdtrtId,
  9205. SetlId: order.SetlId,
  9206. }
  9207. var res ResultEleven
  9208. var resEleven10265 ResultEleven10265
  9209. if config.IsOpen == 1 {
  9210. if miConfig.MdtrtareaAdmvs == "421300" {
  9211. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9212. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9213. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9214. resp, requestErr := http.Get(api)
  9215. if requestErr != nil {
  9216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9217. return
  9218. }
  9219. body, ioErr := ioutil.ReadAll(resp.Body)
  9220. if ioErr != nil {
  9221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9223. return
  9224. }
  9225. var respJSON map[string]interface{}
  9226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9229. return
  9230. }
  9231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9232. result, _ := json.Marshal(respJSON)
  9233. fmt.Println("log")
  9234. fmt.Println(string(result))
  9235. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9236. utils.ErrorLog("解析失败:%v", err)
  9237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9238. return
  9239. }
  9240. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9241. var api string
  9242. if miConfig.MdtrtareaAdmvs == "320921" {
  9243. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9244. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9246. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9247. } else {
  9248. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9249. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9250. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9251. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9252. }
  9253. resp, requestErr := http.Get(api)
  9254. if requestErr != nil {
  9255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9256. return
  9257. }
  9258. body, ioErr := ioutil.ReadAll(resp.Body)
  9259. if ioErr != nil {
  9260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9262. return
  9263. }
  9264. var respJSON map[string]interface{}
  9265. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9268. return
  9269. }
  9270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9271. result, _ := json.Marshal(respJSON)
  9272. fmt.Println("log")
  9273. fmt.Println(string(result))
  9274. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9275. utils.ErrorLog("解析失败:%v", err)
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9280. res.Output = resEleven10265.Output
  9281. res.ErrMsg = resEleven10265.ErrMsg
  9282. res.Cainfo = resEleven10265.Cainfo
  9283. res.WarnMsg = resEleven10265.WarnMsg
  9284. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9285. res.Infcode = infocode
  9286. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9287. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9288. saveLog(result, requestLog, "5203", "结算单")
  9289. var dat map[string]interface{}
  9290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9291. fmt.Println(dat)
  9292. } else {
  9293. fmt.Println(err)
  9294. }
  9295. userJSONBytes, _ := json.Marshal(dat)
  9296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9297. utils.ErrorLog("解析失败:%v", err)
  9298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9299. return
  9300. }
  9301. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9302. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9303. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9304. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9305. resp, requestErr := http.Get(api)
  9306. if requestErr != nil {
  9307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9308. return
  9309. }
  9310. body, ioErr := ioutil.ReadAll(resp.Body)
  9311. if ioErr != nil {
  9312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9314. return
  9315. }
  9316. var respJSON map[string]interface{}
  9317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9320. return
  9321. }
  9322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9323. result, _ := json.Marshal(respJSON)
  9324. fmt.Println("log")
  9325. fmt.Println(string(result))
  9326. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9327. utils.ErrorLog("解析失败:%v", err)
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9329. return
  9330. }
  9331. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9332. res.Output = resEleven10265.Output
  9333. res.ErrMsg = resEleven10265.ErrMsg
  9334. res.Cainfo = resEleven10265.Cainfo
  9335. res.WarnMsg = resEleven10265.WarnMsg
  9336. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9337. res.Infcode = infocode
  9338. } else {
  9339. result := service.Gdyb5203(baseParams, businessParams)
  9340. //service.Gdyb5204(baseParams, businessParams)
  9341. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9342. var dat map[string]interface{}
  9343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9344. fmt.Println(dat)
  9345. } else {
  9346. fmt.Println(err)
  9347. }
  9348. userJSONBytes, _ := json.Marshal(dat)
  9349. if miConfig.Code == "H15049901371" {
  9350. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9351. utils.ErrorLog("解析失败:%v", err)
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. return
  9354. }
  9355. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9356. res.Output = resEleven10265.Output
  9357. res.ErrMsg = resEleven10265.ErrMsg
  9358. res.Cainfo = resEleven10265.Cainfo
  9359. res.WarnMsg = resEleven10265.WarnMsg
  9360. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9361. res.Infcode = infocode
  9362. } else {
  9363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9364. utils.ErrorLog("解析失败:%v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. }
  9369. }
  9370. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9371. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9372. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9373. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9374. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9375. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9376. var doctor_name string
  9377. if roles.ID == 0 {
  9378. doctor_name = "管理员"
  9379. } else {
  9380. doctor_name = roles.UserName
  9381. }
  9382. yiliao_leibie := ""
  9383. switch order.MedType {
  9384. case "11":
  9385. yiliao_leibie = "普通门诊"
  9386. break
  9387. case "12":
  9388. yiliao_leibie = "门诊挂号"
  9389. break
  9390. case "13":
  9391. yiliao_leibie = "急诊"
  9392. break
  9393. case "14":
  9394. yiliao_leibie = "门诊特殊病"
  9395. break
  9396. case "15":
  9397. yiliao_leibie = "门诊统筹"
  9398. break
  9399. case "16":
  9400. yiliao_leibie = "门诊慢性病"
  9401. break
  9402. case "21":
  9403. yiliao_leibie = "普通住院"
  9404. break
  9405. }
  9406. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9407. if res.Infcode == 0 {
  9408. c.ServeSuccessJSON(map[string]interface{}{
  9409. "diagnosis": name,
  9410. "order_infos": orderInfos,
  9411. "number": order.MdtrtId,
  9412. "date": order.SettleAccountsDate,
  9413. "charge_admin": charge_admin,
  9414. "printor_admin": printor_admin,
  9415. "info": res.Output.Setlinfo,
  9416. "order": order,
  9417. "bedCostTotal": bedCostTotal,
  9418. "bedCostSelfTotal": bedCostSelfTotal,
  9419. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9420. "operationCostTotal": operationCostTotal,
  9421. "operationCostSelfTotal": operationCostSelfTotal,
  9422. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9423. "otherCostTotal": otherCostTotal,
  9424. "otherCostSelfTotal": otherCostSelfTotal,
  9425. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9426. "materialCostTotal": materialCostTotal,
  9427. "materialCostSelfTotal": materialCostSelfTotal,
  9428. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9429. "westernMedicineCostTotal": westernMedicineCostTotal,
  9430. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9431. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9432. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9433. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9434. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9435. "checkCostTotal": checkCostTotal,
  9436. "checkCostSelfTotal": checkCostSelfTotal,
  9437. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9438. "laboratoryCostTotal": laboratoryCostTotal,
  9439. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9440. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9441. "treatCostTotal": treatCostTotal,
  9442. "treatCostSelfTotal": treatCostSelfTotal,
  9443. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9444. "doctor_info": doctor_info,
  9445. "doctor_code": adminRole_two.DoctorCode,
  9446. "doctor_name": doctor_name,
  9447. "health_card_no": order.PsnNo,
  9448. "department": departments.Name,
  9449. "yiliao_leibie": yiliao_leibie,
  9450. "after_money": order.AccountPrice,
  9451. "patient": patient,
  9452. "org_name": miConfig.OrgName,
  9453. "org_code": miConfig.Code,
  9454. "order_number": order.Number,
  9455. "his_hospital": his_hospital,
  9456. "his": his,
  9457. "dia_config": dia_config,
  9458. //"check_order_info": cus_slice,
  9459. })
  9460. }
  9461. }
  9462. }
  9463. func (c *HisApiController) CheckTreatment() {
  9464. patient_id, _ := c.GetInt64("patient_id")
  9465. id_card_no := c.GetString("id_card_no")
  9466. insutype := c.GetString("insutype")
  9467. med_type := c.GetString("med_type")
  9468. admin_user_id, _ := c.GetInt64("admin_user_id")
  9469. adminUser := c.GetAdminUserInfo()
  9470. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9471. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9472. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9473. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9474. if miConfig.MdtrtareaAdmvs == "421300" {
  9475. var res ResultTwo
  9476. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9477. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9478. "&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)
  9479. resp, requestErr := http.Get(api)
  9480. if requestErr != nil {
  9481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9482. return
  9483. }
  9484. body, ioErr := ioutil.ReadAll(resp.Body)
  9485. if ioErr != nil {
  9486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9488. return
  9489. }
  9490. var respJSON map[string]interface{}
  9491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9494. return
  9495. }
  9496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9497. result, _ := json.Marshal(respJSON)
  9498. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9499. utils.ErrorLog("解析失败:%v", err)
  9500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9501. return
  9502. }
  9503. if res.Infcode == 0 {
  9504. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9505. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9506. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9507. resp, requestErr := http.Get(api)
  9508. if requestErr != nil {
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return
  9511. }
  9512. body, ioErr := ioutil.ReadAll(resp.Body)
  9513. if ioErr != nil {
  9514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. var respJSON map[string]interface{}
  9519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9522. return
  9523. }
  9524. var res Result2001
  9525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9526. result2, _ := json.Marshal(respJSON)
  9527. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9528. utils.ErrorLog("解析失败:%v", err)
  9529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9530. return
  9531. }
  9532. if res.Infcode == 0 {
  9533. c.ServeSuccessJSON(map[string]interface{}{
  9534. "msg": res.Output.Trtinfo,
  9535. })
  9536. }
  9537. } else {
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9539. return
  9540. }
  9541. } else {
  9542. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9543. var dat map[string]interface{}
  9544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9545. fmt.Println(dat)
  9546. } else {
  9547. fmt.Println(err)
  9548. }
  9549. userJSONBytes, _ := json.Marshal(dat)
  9550. var res ResultTwo
  9551. var res10265 ResultTwo10265
  9552. if miConfig.Code == "H15049901371" {
  9553. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9554. utils.ErrorLog("解析失败:%v", err)
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9556. return
  9557. }
  9558. res.ErrMsg = res10265.ErrMsg
  9559. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9560. res.Infcode = infocode
  9561. res.Output = res10265.Output
  9562. res.InfRefmsgid = res10265.InfRefmsgid
  9563. } else {
  9564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9565. utils.ErrorLog("解析失败:%v", err)
  9566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9567. return
  9568. }
  9569. }
  9570. var user_name string
  9571. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9572. if role.ID == 0 {
  9573. user_name = "xxx"
  9574. } else {
  9575. user_name = role.UserName
  9576. }
  9577. baseParams := models.BaseParams{
  9578. SecretKey: miConfig.SecretKey,
  9579. FixmedinsCode: miConfig.Code,
  9580. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9581. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9582. OrgName: miConfig.OrgName,
  9583. Doctor: user_name,
  9584. }
  9585. if config.IsOpen == 1 {
  9586. if miConfig.Code == "H15049901371" {
  9587. if med_type == "14" {
  9588. if insutype == "390" {
  9589. med_type = "9933"
  9590. } else if insutype == "310" {
  9591. med_type = "990502"
  9592. }
  9593. } else if med_type == "11" {
  9594. med_type = "11"
  9595. }
  9596. }
  9597. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9598. var dat map[string]interface{}
  9599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9600. fmt.Println(dat)
  9601. } else {
  9602. fmt.Println(err)
  9603. }
  9604. var res Result2001
  9605. var res10265 Result2001Org10265
  9606. if miConfig.Code == "H15049901371" {
  9607. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9608. utils.ErrorLog("解析失败:%v", err)
  9609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9610. return
  9611. }
  9612. res.ErrMsg = res10265.ErrMsg
  9613. res.Output = res10265.Output
  9614. res.InfRefmsgid = res10265.InfRefmsgid
  9615. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9616. res.Infcode = infocode
  9617. } else {
  9618. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9619. utils.ErrorLog("解析失败:%v", err)
  9620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9621. return
  9622. }
  9623. }
  9624. if res.Infcode == 0 {
  9625. c.ServeSuccessJSON(map[string]interface{}{
  9626. "msg": res.Output.Trtinfo,
  9627. })
  9628. }
  9629. }
  9630. }
  9631. }
  9632. //func (c *HisApiController) PutRecord() {
  9633. // id, _ := c.GetInt64("id")
  9634. // record_time := c.GetString("record_time")
  9635. // timeLayout := "2006-01-02"
  9636. // loc, _ := time.LoadLocation("Local")
  9637. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9638. // if err != nil {
  9639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9640. // return
  9641. // }
  9642. // recordDateTime := theTime.Unix()
  9643. //
  9644. // adminInfo := c.GetAdminUserInfo()
  9645. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9646. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9647. //
  9648. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9649. //
  9650. // fmt.Println(miConfig.SecretKey)
  9651. //
  9652. // if patient == nil {
  9653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9654. // return
  9655. // }
  9656. // if len(patient.IdCardNo) == 0 {
  9657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9658. // return
  9659. // }
  9660. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9661. // if config.IsOpen == 1 {
  9662. // 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
  9663. // resp, requestErr := http.Get(api)
  9664. // if requestErr != nil {
  9665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. // return
  9667. // }
  9668. // defer resp.Body.Close()
  9669. // body, ioErr := ioutil.ReadAll(resp.Body)
  9670. // if ioErr != nil {
  9671. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. // return
  9674. // }
  9675. // var respJSON map[string]interface{}
  9676. //
  9677. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9678. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9680. // return
  9681. // }
  9682. //
  9683. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9684. // userJSONBytes, _ := json.Marshal(userJSON)
  9685. // var res ResultTwo
  9686. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9687. // utils.ErrorLog("解析失败:%v", err)
  9688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9689. // return
  9690. // }
  9691. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9692. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9693. // infoStr := string(Iinfos)
  9694. // idetinfoStr := string(Idetinfos)
  9695. //
  9696. // if res.Infcode == 0 {
  9697. // his := models.VMHisPatient{
  9698. // Status: 1,
  9699. // Ctime: time.Now().Unix(),
  9700. // Mtime: time.Now().Unix(),
  9701. // PsnNo: res.Output.Baseinfo.PsnNo,
  9702. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9703. // Certno: res.Output.Baseinfo.Certno,
  9704. // PsnName: res.Output.Baseinfo.PsnName,
  9705. // Gend: res.Output.Baseinfo.Gend,
  9706. // Naty: res.Output.Baseinfo.Naty,
  9707. // Brdy: res.Output.Baseinfo.Brdy,
  9708. // Age: res.Output.Baseinfo.Age,
  9709. // Iinfo: infoStr,
  9710. // Idetinfo: idetinfoStr,
  9711. // PatientId: patient.ID,
  9712. // RecordDate: theTime.Unix(),
  9713. // UserOrgId: adminInfo.CurrentOrgId,
  9714. // AdminUserId: adminInfo.AdminUser.Id,
  9715. // IsReturn: 1,
  9716. // }
  9717. //
  9718. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9719. // //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")
  9720. // //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")
  9721. //
  9722. // //var dat map[string]interface{}
  9723. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9724. // // fmt.Println(dat)
  9725. // //} else {
  9726. // // fmt.Println(err)
  9727. // //}
  9728. //
  9729. // var dat2 map[string]interface{}
  9730. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9731. // fmt.Println(dat2)
  9732. // } else {
  9733. // fmt.Println(err)
  9734. // }
  9735. //
  9736. // } else {
  9737. // adminUser := c.GetAdminUserInfo()
  9738. // errlog := &models.HisOrderError{
  9739. // UserOrgId: adminUser.CurrentOrgId,
  9740. // Ctime: time.Now().Unix(),
  9741. // Mtime: time.Now().Unix(),
  9742. // ErrMsg: res.ErrMsg,
  9743. // Status: 1,
  9744. // PatientId: id,
  9745. // RecordTime: recordDateTime,
  9746. // Stage: 1,
  9747. // }
  9748. // service.CreateErrMsgLog(errlog)
  9749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9750. // return
  9751. // }
  9752. // }
  9753. //
  9754. //}
  9755. //func (c *HisApiController) GetUploadDiag() {
  9756. // id, _ := c.GetInt64("id")
  9757. // record_time := c.GetString("record_time")
  9758. //
  9759. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9760. // sick_type, _ := c.GetInt64("sick_type")
  9761. // reg_type, _ := c.GetInt64("reg_type")
  9762. //
  9763. // timeLayout := "2006-01-02"
  9764. // loc, _ := time.LoadLocation("Local")
  9765. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9766. // if err != nil {
  9767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9768. // return
  9769. // }
  9770. //
  9771. // var patientPrescription models.HisPrescriptionInfo
  9772. // recordDateTime := theTime.Unix()
  9773. // adminInfo := c.GetAdminUserInfo()
  9774. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9775. //
  9776. // if patientPrescription.ID == 0 {
  9777. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9778. // }
  9779. //
  9780. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9781. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9782. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9783. // sickConfig, _ := service.FindSickById(sick_type)
  9784. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9785. //
  9786. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9787. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9788. // "&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 +
  9789. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9790. // resp2, requestErr2 := http.Get(api2)
  9791. // if requestErr2 != nil {
  9792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9793. // return
  9794. // }
  9795. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9796. // if ioErr2 != nil {
  9797. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. // return
  9800. // }
  9801. // var respJSON2 map[string]interface{}
  9802. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9803. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9805. // return
  9806. // }
  9807. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9808. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9809. //
  9810. // var res2 ResultSix
  9811. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9812. // utils.ErrorLog("解析失败:%v", err)
  9813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9814. // return
  9815. // }
  9816. // if res2.Infcode != 0 {
  9817. // adminUser := c.GetAdminUserInfo()
  9818. // errlog := &models.HisOrderError{
  9819. // UserOrgId: adminUser.CurrentOrgId,
  9820. // Ctime: time.Now().Unix(),
  9821. // Mtime: time.Now().Unix(),
  9822. // ErrMsg: res2.ErrMsg,
  9823. // Status: 1,
  9824. // PatientId: id,
  9825. // RecordTime: recordDateTime,
  9826. // Stage: 3,
  9827. // }
  9828. // service.CreateErrMsgLog(errlog)
  9829. //
  9830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9831. // return
  9832. // }
  9833. //
  9834. // c.ServeSuccessJSON(map[string]interface{}{
  9835. // "msg": "上传成功",
  9836. // })
  9837. //
  9838. //}
  9839. type QueryResult struct {
  9840. ID int64
  9841. Name string
  9842. Code string
  9843. List_type_code string
  9844. }
  9845. func (c *HisApiController) GetCheckCode() {
  9846. ids_str := c.GetString("ids")
  9847. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9848. ids_arr := strings.Split(ids_str, ",")
  9849. var queryResult []QueryResult
  9850. ids := make([]int64, 0)
  9851. for _, item := range ids_arr {
  9852. id, _ := strconv.ParseInt(item, 10, 64)
  9853. ids = append(ids, id)
  9854. }
  9855. if record_type == 1 {
  9856. drugs, _ := service.GetBatchDrugList(ids)
  9857. for _, item := range drugs {
  9858. result := QueryResult{
  9859. ID: item.ID,
  9860. Name: item.DrugName,
  9861. Code: item.MedicalInsuranceNumber,
  9862. List_type_code: "101",
  9863. }
  9864. queryResult = append(queryResult, result)
  9865. }
  9866. } else if record_type == 2 {
  9867. goods, _ := service.GetBatchGoodInformationList(ids)
  9868. for _, item := range goods {
  9869. result := QueryResult{
  9870. ID: item.ID,
  9871. Name: item.GoodName,
  9872. Code: item.MedicalInsuranceNumber,
  9873. List_type_code: "301",
  9874. }
  9875. queryResult = append(queryResult, result)
  9876. }
  9877. } else if record_type == 3 {
  9878. projects, _ := service.GetBathchMyPorjecgList(ids)
  9879. for _, item := range projects {
  9880. result := QueryResult{
  9881. ID: item.ID,
  9882. Name: item.ProjectName,
  9883. Code: item.MedicalCode,
  9884. List_type_code: "201",
  9885. }
  9886. queryResult = append(queryResult, result)
  9887. }
  9888. }
  9889. admin_user_id, _ := c.GetInt64("admin_user_id")
  9890. adminUser := c.GetAdminUserInfo()
  9891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9892. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9893. var user_name string
  9894. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9895. if role.ID == 0 {
  9896. user_name = "xxx"
  9897. } else {
  9898. user_name = role.UserName
  9899. }
  9900. baseParams := &models.BaseParams{
  9901. SecretKey: miConfig.SecretKey,
  9902. FixmedinsCode: miConfig.Code,
  9903. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9904. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9905. OrgName: miConfig.OrgName,
  9906. Doctor: user_name,
  9907. }
  9908. if config.IsOpen == 1 {
  9909. for _, item := range queryResult {
  9910. var result string
  9911. if record_type == 1 {
  9912. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9913. } else if record_type == 2 {
  9914. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9915. } else if record_type == 3 {
  9916. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9917. }
  9918. var dat map[string]interface{}
  9919. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9920. fmt.Println(dat)
  9921. } else {
  9922. fmt.Println(err)
  9923. }
  9924. userJSONBytes, _ := json.Marshal(dat)
  9925. var res ResultSix
  9926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9927. utils.ErrorLog("解析失败:%v", err)
  9928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9929. return
  9930. }
  9931. if res.Infcode == 0 {
  9932. if record_type == 1 {
  9933. service.UpdateBaseDrugById(item.ID)
  9934. } else if record_type == 2 {
  9935. service.UpdateGoodInformaitonByDetail(item.ID)
  9936. } else if record_type == 3 {
  9937. service.UpdateProjectById(item.ID)
  9938. }
  9939. c.ServeSuccessJSON(map[string]interface{}{
  9940. "failed_code": 0,
  9941. "msg": "目录对照成功",
  9942. })
  9943. } else {
  9944. c.ServeSuccessJSON(map[string]interface{}{
  9945. "failed_code": -10,
  9946. "msg": res.ErrMsg,
  9947. })
  9948. }
  9949. }
  9950. }
  9951. }
  9952. func (c *HisApiController) UnCheckCode() {
  9953. ids_str := c.GetString("ids")
  9954. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9955. admin_user_id, _ := c.GetInt64("admin_user_id")
  9956. ids_arr := strings.Split(ids_str, ",")
  9957. var queryResult []QueryResult
  9958. ids := make([]int64, 0)
  9959. for _, item := range ids_arr {
  9960. id, _ := strconv.ParseInt(item, 10, 64)
  9961. ids = append(ids, id)
  9962. }
  9963. if record_type == 1 {
  9964. drugs, _ := service.GetBatchDrugList(ids)
  9965. for _, item := range drugs {
  9966. result := QueryResult{
  9967. ID: item.ID,
  9968. Name: item.DrugName,
  9969. Code: item.MedicalInsuranceNumber,
  9970. List_type_code: "101",
  9971. }
  9972. queryResult = append(queryResult, result)
  9973. }
  9974. } else if record_type == 2 {
  9975. goods, _ := service.GetBatchGoodInformationList(ids)
  9976. for _, item := range goods {
  9977. result := QueryResult{
  9978. ID: item.ID,
  9979. Name: item.GoodName,
  9980. Code: item.MedicalInsuranceNumber,
  9981. List_type_code: "301",
  9982. }
  9983. queryResult = append(queryResult, result)
  9984. }
  9985. } else if record_type == 3 {
  9986. projects, _ := service.GetBathchMyPorjecgList(ids)
  9987. for _, item := range projects {
  9988. result := QueryResult{
  9989. ID: item.ID,
  9990. Name: item.ProjectName,
  9991. Code: item.MedicalCode,
  9992. List_type_code: "201",
  9993. }
  9994. queryResult = append(queryResult, result)
  9995. }
  9996. }
  9997. adminUser := c.GetAdminUserInfo()
  9998. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9999. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10000. var user_name string
  10001. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10002. if role.ID == 0 {
  10003. user_name = "xxx"
  10004. } else {
  10005. user_name = role.UserName
  10006. }
  10007. baseParams := &models.BaseParams{
  10008. SecretKey: miConfig.SecretKey,
  10009. FixmedinsCode: miConfig.Code,
  10010. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10011. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10012. OrgName: miConfig.OrgName,
  10013. Doctor: user_name,
  10014. }
  10015. if config.IsOpen == 1 {
  10016. for _, item := range queryResult {
  10017. var result string
  10018. if record_type == 1 {
  10019. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10020. } else if record_type == 2 {
  10021. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10022. } else if record_type == 3 {
  10023. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10024. }
  10025. var dat2 map[string]interface{}
  10026. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10027. fmt.Println(dat2)
  10028. } else {
  10029. fmt.Println(err)
  10030. }
  10031. userJSONBytes, _ := json.Marshal(dat2)
  10032. var res ResultSix
  10033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10034. utils.ErrorLog("解析失败:%v", err)
  10035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10036. return
  10037. }
  10038. if res.Infcode == 0 {
  10039. if record_type == 1 {
  10040. service.UpdateDrugByIdDetail(item.ID)
  10041. } else if record_type == 2 {
  10042. service.UpdateGoodInfoById(item.ID)
  10043. } else if record_type == 3 {
  10044. service.UpdateMyProjectById(item.ID)
  10045. }
  10046. c.ServeSuccessJSON(map[string]interface{}{
  10047. "failed_code": 0,
  10048. "msg": "撤销目录对照成功",
  10049. })
  10050. } else {
  10051. c.ServeSuccessJSON(map[string]interface{}{
  10052. "failed_code": -10,
  10053. "msg": res.ErrMsg,
  10054. })
  10055. }
  10056. }
  10057. }
  10058. }
  10059. func (c *HisApiController) GetPatientInfo() {
  10060. id_card_no := c.GetString("id_card_no")
  10061. admin_user_id, _ := c.GetInt64("admin_user_id")
  10062. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10063. if patient.ID == 0 {
  10064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10065. return
  10066. }
  10067. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10068. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10069. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10070. if config.IsOpen == 1 {
  10071. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10072. var dat map[string]interface{}
  10073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10074. fmt.Println(dat)
  10075. } else {
  10076. fmt.Println(err)
  10077. }
  10078. userJSONBytes, _ := json.Marshal(dat)
  10079. var res ResultTwo
  10080. var res10265 ResultTwo10265
  10081. if miConfig.Code == "H15049901371" {
  10082. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10083. utils.ErrorLog("解析失败:%v", err)
  10084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10085. return
  10086. }
  10087. res.ErrMsg = res10265.ErrMsg
  10088. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10089. res.Infcode = infocode
  10090. res.Output = res10265.Output
  10091. res.InfRefmsgid = res10265.InfRefmsgid
  10092. } else {
  10093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10094. utils.ErrorLog("解析失败:%v", err)
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10096. return
  10097. }
  10098. }
  10099. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10100. // utils.ErrorLog("解析失败:%v", err)
  10101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10102. // return
  10103. //}
  10104. if res.Infcode != 0 {
  10105. c.ServeSuccessJSON(map[string]interface{}{
  10106. "failed_code": -10,
  10107. "msg": res.ErrMsg,
  10108. })
  10109. } else {
  10110. c.ServeSuccessJSON(map[string]interface{}{
  10111. "failed_code": 0,
  10112. "info": res,
  10113. })
  10114. }
  10115. }
  10116. }
  10117. func (c *HisApiController) PsnPutOnRecord() {
  10118. record_type, _ := c.GetInt64("type")
  10119. patient_id, _ := c.GetInt64("patient_id")
  10120. admin_user_id, _ := c.GetInt64("admin_user_id")
  10121. start_time := c.GetString("start_time")
  10122. end_time := c.GetString("end_time")
  10123. adminUser := c.GetAdminUserInfo()
  10124. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10125. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10126. var patients []*models.Patients
  10127. if record_type == 1 { //全部备案
  10128. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10129. patients = append(patients, patient...)
  10130. } else { //单个备案
  10131. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10132. patients = append(patients, patient)
  10133. }
  10134. var user_name string
  10135. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10136. if role.ID == 0 {
  10137. user_name = "xxx"
  10138. } else {
  10139. user_name = role.UserName
  10140. }
  10141. if config.IsOpen == 1 {
  10142. for _, item := range patients {
  10143. 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
  10144. resp, requestErr := http.Get(api)
  10145. if requestErr != nil {
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10147. return
  10148. }
  10149. defer resp.Body.Close()
  10150. body, ioErr := ioutil.ReadAll(resp.Body)
  10151. if ioErr != nil {
  10152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10154. return
  10155. }
  10156. var respJSON map[string]interface{}
  10157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10160. return
  10161. }
  10162. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10163. userJSONBytes, _ := json.Marshal(userJSON)
  10164. var res ResultTwo
  10165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10166. utils.ErrorLog("解析失败:%v", err)
  10167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10168. return
  10169. }
  10170. if res.Infcode == 0 {
  10171. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10172. var dat map[string]interface{}
  10173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10174. fmt.Println(dat)
  10175. } else {
  10176. fmt.Println(err)
  10177. }
  10178. userJSONBytes, _ := json.Marshal(dat)
  10179. var res2 ResultThirteen
  10180. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10181. utils.ErrorLog("解析失败:%v", err)
  10182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10183. return
  10184. }
  10185. if res2.Infcode == 0 {
  10186. psnResult := &models.GdybPsnRecord{
  10187. UserOrgId: adminUser.CurrentOrgId,
  10188. PatientId: item.ID,
  10189. PsnNo: res.Output.Baseinfo.PsnNo,
  10190. Ctime: time.Now().Unix(),
  10191. Mtime: time.Now().Unix(),
  10192. Status: 1,
  10193. IsCancel: 1,
  10194. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10195. }
  10196. service.CreatePsnRecord(psnResult)
  10197. } else {
  10198. c.ServeSuccessJSON(map[string]interface{}{
  10199. "failed_code": -10,
  10200. "msg": res2.ErrMsg,
  10201. })
  10202. return
  10203. }
  10204. }
  10205. }
  10206. }
  10207. }
  10208. func (c *HisApiController) PsnUnPutOnRecord() {
  10209. id, _ := c.GetInt64("id")
  10210. //record_type, _ := c.GetInt64("type")
  10211. admin_user_id, _ := c.GetInt64("admin_user_id")
  10212. adminUser := c.GetAdminUserInfo()
  10213. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10214. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10215. var user_name string
  10216. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10217. if role.ID == 0 {
  10218. user_name = "xxx"
  10219. } else {
  10220. user_name = role.UserName
  10221. }
  10222. psn_record, _ := service.GetPsnRecordById(id)
  10223. if psn_record.ID == 0 {
  10224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10225. return
  10226. }
  10227. if config.IsOpen == 1 {
  10228. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10229. var dat map[string]interface{}
  10230. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10231. fmt.Println(dat)
  10232. } else {
  10233. fmt.Println(err)
  10234. }
  10235. userJSONBytes, _ := json.Marshal(dat)
  10236. var res ResultFourteen
  10237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10238. utils.ErrorLog("解析失败:%v", err)
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10240. return
  10241. }
  10242. if res.Infcode == 0 {
  10243. psn_record.IsCancel = 2
  10244. service.CreatePsnRecord(&psn_record)
  10245. } else {
  10246. c.ServeSuccessJSON(map[string]interface{}{
  10247. "failed_code": -10,
  10248. "msg": res.ErrMsg,
  10249. })
  10250. return
  10251. }
  10252. }
  10253. }
  10254. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10255. patient_id, _ := c.GetInt64("patient_id")
  10256. insutype_two := c.GetString("insutype")
  10257. psn_no := c.GetString("psn_no")
  10258. doctor_id, _ := c.GetInt64("doctor_id")
  10259. sick_id, _ := c.GetInt64("sick_id")
  10260. department_id, _ := c.GetInt64("department_id")
  10261. start_time := c.GetString("start_time")
  10262. end_time := c.GetString("end_time")
  10263. check_time := c.GetString("check_time")
  10264. adminUser := c.GetAdminUserInfo()
  10265. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10266. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10267. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10268. sick, _ := service.FindSickById(sick_id)
  10269. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10270. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10271. var res ResultTwo
  10272. var res10265 ResultTwo10265
  10273. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10274. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10275. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10276. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10277. "&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
  10278. resp, requestErr := http.Get(api)
  10279. if requestErr != nil {
  10280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10281. return
  10282. }
  10283. body, ioErr := ioutil.ReadAll(resp.Body)
  10284. if ioErr != nil {
  10285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10287. return
  10288. }
  10289. var respJSON map[string]interface{}
  10290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. return
  10294. }
  10295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10296. result, _ := json.Marshal(respJSON)
  10297. fmt.Println("log")
  10298. fmt.Println(string(result))
  10299. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10300. utils.ErrorLog("解析失败:%v", err)
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10302. return
  10303. }
  10304. res.ErrMsg = res10265.ErrMsg
  10305. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10306. res.Infcode = infocode
  10307. res.Output = res10265.Output
  10308. res.InfRefmsgid = res10265.InfRefmsgid
  10309. } else {
  10310. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10311. if miConfig.Code == "H15049901371" {
  10312. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10313. utils.ErrorLog("解析失败:%v", err)
  10314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10315. return
  10316. }
  10317. res.ErrMsg = res10265.ErrMsg
  10318. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10319. res.Infcode = infocode
  10320. res.Output = res10265.Output
  10321. res.InfRefmsgid = res10265.InfRefmsgid
  10322. } else {
  10323. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10324. utils.ErrorLog("解析失败:%v", err)
  10325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10326. return
  10327. }
  10328. }
  10329. }
  10330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10331. infoStr := string(Iinfos)
  10332. var rf []*ResultFive
  10333. json.Unmarshal([]byte(infoStr), &rf)
  10334. var insuplc_admdvs string
  10335. var insutype string
  10336. var is390 int = 0
  10337. var is310 int = 0
  10338. var insutypes []*ResultFive
  10339. for _, item := range rf {
  10340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10341. insutypes = append(insutypes, item)
  10342. }
  10343. }
  10344. if len(insutypes) == 1 {
  10345. insutype = insutypes[0].Insutype
  10346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10347. } else {
  10348. for _, i := range insutypes {
  10349. if i.Insutype == "390" {
  10350. is390 = 1
  10351. }
  10352. if i.Insutype == "310" {
  10353. is310 = 1
  10354. }
  10355. }
  10356. }
  10357. if is390 == 1 {
  10358. insutype = "390"
  10359. }
  10360. if is310 == 1 {
  10361. insutype = "310"
  10362. }
  10363. if len(insutypes) == 2 {
  10364. insutype = insutype_two
  10365. }
  10366. if len(insutypes) == 0 {
  10367. insutype = "310"
  10368. }
  10369. insutype = insutype_two
  10370. fmt.Println(insutype)
  10371. for _, item := range rf {
  10372. fmt.Println(item.Insutype)
  10373. fmt.Println(insutype)
  10374. if item.Insutype == insutype {
  10375. fmt.Println(item.Insutype)
  10376. fmt.Println(insutype)
  10377. insuplc_admdvs = item.InsuplcAdmdvs
  10378. }
  10379. }
  10380. fmt.Println(insuplc_admdvs)
  10381. var res2 ResultThirteen
  10382. var res10265_2 ResultThirteen10265
  10383. if config.IsOpen == 1 {
  10384. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10385. } else {
  10386. 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)
  10387. var dat map[string]interface{}
  10388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10389. fmt.Println(dat)
  10390. } else {
  10391. fmt.Println(err)
  10392. }
  10393. userJSONBytes, _ := json.Marshal(dat)
  10394. if miConfig.Code == "H15049901371" {
  10395. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10396. utils.ErrorLog("解析失败:%v", err)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10398. return
  10399. }
  10400. res2.ErrMsg = res10265_2.ErrMsg
  10401. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10402. res2.Infcode = infocode
  10403. res2.Output = res10265_2.Output
  10404. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10405. } else {
  10406. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10407. utils.ErrorLog("解析失败:%v", err)
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10409. return
  10410. }
  10411. }
  10412. }
  10413. if res2.Infcode == 0 {
  10414. psnResult := &models.GdybPsnNcdsRecord{
  10415. UserOrgId: adminUser.CurrentOrgId,
  10416. PatientId: patient.ID,
  10417. PsnNo: psn_no,
  10418. DoctorId: doctor.AdminUserId,
  10419. DepartmentId: department_id,
  10420. SickType: sick_id,
  10421. Insutype: insutype,
  10422. Ctime: time.Now().Unix(),
  10423. Mtime: time.Now().Unix(),
  10424. Status: 1,
  10425. IsCancel: 1,
  10426. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10427. }
  10428. service.CreatePsnNCDSRecord(psnResult)
  10429. c.ServeSuccessJSON(map[string]interface{}{
  10430. "failed_code": 0,
  10431. "msg": "备案成功",
  10432. "result": psnResult,
  10433. })
  10434. } else {
  10435. c.ServeSuccessJSON(map[string]interface{}{
  10436. "failed_code": -10,
  10437. "msg": res2.ErrMsg,
  10438. })
  10439. return
  10440. }
  10441. }
  10442. }
  10443. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10444. id, _ := c.GetInt64("id")
  10445. admin_user_id, _ := c.GetInt64("admin_user_id")
  10446. adminUser := c.GetAdminUserInfo()
  10447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10448. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10449. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10450. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10451. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10452. //var user_name string
  10453. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10454. //if role.ID == 0 {
  10455. // user_name = "xxx"
  10456. //} else {
  10457. // user_name = role.UserName
  10458. //}
  10459. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10460. if psn_record.ID == 0 {
  10461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10462. return
  10463. }
  10464. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10465. var res ResultTwo
  10466. var res10265 ResultTwo10265
  10467. if miConfig.Code == "H15049901371" {
  10468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10469. utils.ErrorLog("解析失败:%v", err)
  10470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10471. return
  10472. }
  10473. res.ErrMsg = res10265.ErrMsg
  10474. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10475. res.Infcode = infocode
  10476. res.Output = res10265.Output
  10477. res.InfRefmsgid = res10265.InfRefmsgid
  10478. } else {
  10479. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10480. utils.ErrorLog("解析失败:%v", err)
  10481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10482. return
  10483. }
  10484. }
  10485. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10486. infoStr := string(Iinfos)
  10487. var rf []*ResultFive
  10488. json.Unmarshal([]byte(infoStr), &rf)
  10489. var insuplc_admdvs string
  10490. var insutype string
  10491. var is390 int = 0
  10492. var is310 int = 0
  10493. var insutypes []*ResultFive
  10494. for _, item := range rf {
  10495. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10496. insutypes = append(insutypes, item)
  10497. }
  10498. }
  10499. if len(insutypes) == 1 {
  10500. insutype = insutypes[0].Insutype
  10501. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10502. } else {
  10503. for _, i := range insutypes {
  10504. if i.Insutype == "390" {
  10505. is390 = 1
  10506. }
  10507. if i.Insutype == "310" {
  10508. is310 = 1
  10509. }
  10510. }
  10511. }
  10512. if is390 == 1 {
  10513. insutype = "390"
  10514. }
  10515. if is310 == 1 {
  10516. insutype = "310"
  10517. }
  10518. if len(insutypes) == 0 {
  10519. insutype = "310"
  10520. }
  10521. insutype = psn_record.Insutype
  10522. for _, item := range rf {
  10523. if item.Insutype == insutype {
  10524. insuplc_admdvs = item.InsuplcAdmdvs
  10525. }
  10526. }
  10527. if config.IsOpen == 1 {
  10528. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10529. var dat map[string]interface{}
  10530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10531. fmt.Println(dat)
  10532. } else {
  10533. fmt.Println(err)
  10534. }
  10535. userJSONBytes, _ := json.Marshal(dat)
  10536. var res ResultFourteen
  10537. var res10265 ResultFourteen10265
  10538. if miConfig.Code == "H15049901371" {
  10539. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10540. utils.ErrorLog("解析失败:%v", err)
  10541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10542. return
  10543. }
  10544. res.ErrMsg = res10265.ErrMsg
  10545. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10546. res.Infcode = infocode
  10547. res.Output = res10265.Output
  10548. res.InfRefmsgid = res10265.InfRefmsgid
  10549. } else {
  10550. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10551. utils.ErrorLog("解析失败:%v", err)
  10552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10553. return
  10554. }
  10555. }
  10556. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10557. // utils.ErrorLog("解析失败:%v", err)
  10558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10559. // return
  10560. //}
  10561. if res.Infcode == 0 {
  10562. psn_record.IsCancel = 2
  10563. service.CreatePsnNCDSRecord(&psn_record)
  10564. c.ServeSuccessJSON(map[string]interface{}{
  10565. "failed_code": 0,
  10566. "msg": "撤销备案成功",
  10567. })
  10568. } else {
  10569. c.ServeSuccessJSON(map[string]interface{}{
  10570. "failed_code": -10,
  10571. "msg": res.ErrMsg,
  10572. })
  10573. return
  10574. }
  10575. }
  10576. }
  10577. func (c *HisApiController) TestTest() {
  10578. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10579. fmt.Println(patient.Iinfo)
  10580. }
  10581. type CustomData struct {
  10582. MsgId string
  10583. PsnNo string
  10584. Info string
  10585. }
  10586. func (c *HisApiController) ReversalData() {
  10587. var customData []*CustomData
  10588. custom := &CustomData{
  10589. MsgId: "H44022900158202103301714472004",
  10590. PsnNo: "44020000001101329945",
  10591. Info: "2207",
  10592. }
  10593. customData = append(customData, custom)
  10594. custom1 := &CustomData{
  10595. MsgId: "H4402290015820210330172057803",
  10596. PsnNo: "44020000001101161813",
  10597. Info: "2207",
  10598. }
  10599. customData = append(customData, custom1)
  10600. custom2 := &CustomData{
  10601. MsgId: "H44022900158202103301705198813",
  10602. PsnNo: "44190000133097375417",
  10603. Info: "2207",
  10604. }
  10605. customData = append(customData, custom2)
  10606. custom3 := &CustomData{
  10607. MsgId: "H44022900158202103301715524756",
  10608. PsnNo: "44020000001100187221",
  10609. Info: "2207",
  10610. }
  10611. customData = append(customData, custom3)
  10612. custom4 := &CustomData{
  10613. MsgId: "H44022900158202103301730376224",
  10614. PsnNo: "44020000001101959155",
  10615. Info: "2207",
  10616. }
  10617. customData = append(customData, custom4)
  10618. custom5 := &CustomData{
  10619. MsgId: "H44022900158202103301748008725",
  10620. PsnNo: "44020000001104246641",
  10621. Info: "2207",
  10622. }
  10623. customData = append(customData, custom5)
  10624. custom6 := &CustomData{
  10625. MsgId: "H44022900158202103301718096755",
  10626. PsnNo: "44020000001102211860",
  10627. Info: "2207",
  10628. }
  10629. customData = append(customData, custom6)
  10630. custom7 := &CustomData{
  10631. MsgId: "H44022900158202103301736551640",
  10632. PsnNo: "44020000001102687718",
  10633. Info: "2207",
  10634. }
  10635. customData = append(customData, custom7)
  10636. custom8 := &CustomData{
  10637. MsgId: "H44022900158202103301743097676",
  10638. PsnNo: "44020000001102127785",
  10639. Info: "2207",
  10640. }
  10641. customData = append(customData, custom8)
  10642. custom9 := &CustomData{
  10643. MsgId: "H44022900158202103301712304203",
  10644. PsnNo: "44020000001101518097",
  10645. Info: "2207",
  10646. }
  10647. customData = append(customData, custom9)
  10648. custom10 := &CustomData{
  10649. MsgId: "H44022900158202103301738448785",
  10650. PsnNo: "44020000001100500813",
  10651. Info: "2207",
  10652. }
  10653. customData = append(customData, custom10)
  10654. custom11 := &CustomData{
  10655. MsgId: "H44022900158202103301732455843",
  10656. PsnNo: "44020000001102690557",
  10657. Info: "2207",
  10658. }
  10659. customData = append(customData, custom11)
  10660. custom12 := &CustomData{
  10661. MsgId: "H44022900158202103301745421708",
  10662. PsnNo: "44020000001102211928",
  10663. Info: "2207",
  10664. }
  10665. customData = append(customData, custom12)
  10666. custom1212 := &CustomData{
  10667. MsgId: "H440229001582021033017351627",
  10668. PsnNo: "44020000001102481733",
  10669. Info: "2207",
  10670. }
  10671. customData = append(customData, custom1212)
  10672. custom13 := &CustomData{
  10673. MsgId: "H44022900158202103301740327951",
  10674. PsnNo: "44020000001103174866",
  10675. Info: "2207",
  10676. }
  10677. customData = append(customData, custom13)
  10678. custom14 := &CustomData{
  10679. MsgId: "H4402290015820210330174922668",
  10680. PsnNo: "44020000001102927272",
  10681. Info: "2207",
  10682. }
  10683. customData = append(customData, custom14)
  10684. custom15 := &CustomData{
  10685. MsgId: "H44022900158202103301752362273",
  10686. PsnNo: "44020000001102942890",
  10687. Info: "2207",
  10688. }
  10689. customData = append(customData, custom15)
  10690. custom16 := &CustomData{
  10691. MsgId: "H44022900158202103301751082917",
  10692. PsnNo: "44020000001101662162",
  10693. Info: "2207",
  10694. }
  10695. customData = append(customData, custom16)
  10696. custom17 := &CustomData{
  10697. MsgId: "H44022900158202103301754147728",
  10698. PsnNo: "44020000000229014511",
  10699. Info: "2207",
  10700. }
  10701. customData = append(customData, custom17)
  10702. adminUser := c.GetAdminUserInfo()
  10703. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10704. for _, item := range customData {
  10705. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10706. fmt.Println(result)
  10707. }
  10708. }
  10709. //func (c *HisApiController) GetAllopatry() {
  10710. // year := c.GetString("year")
  10711. // month := c.GetString("month")
  10712. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10713. // adminUser := c.GetAdminUserInfo()
  10714. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10715. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10716. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10717. //
  10718. // var dat map[string]interface{}
  10719. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10720. // fmt.Println(dat)
  10721. // } else {
  10722. // fmt.Println(err)
  10723. // }
  10724. // userJSONBytes, _ := json.Marshal(dat)
  10725. // var res models.Result9001
  10726. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10727. // utils.ErrorLog("解析失败:%v", err)
  10728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10729. // return
  10730. // }
  10731. //
  10732. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10733. // var dat2 map[string]interface{}
  10734. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10735. // fmt.Println(dat)
  10736. // } else {
  10737. // fmt.Println(err)
  10738. // }
  10739. // userJSONBytes2, _ := json.Marshal(dat2)
  10740. // var res2 models.Result3260
  10741. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10742. // utils.ErrorLog("解析失败:%v", err)
  10743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10744. // return
  10745. // }
  10746. // if res2.Infcode == 0 {
  10747. // c.ServeSuccessJSON(map[string]interface{}{
  10748. // "list": res2.Output.Data,
  10749. // })
  10750. // return
  10751. // } else {
  10752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. // return
  10754. // }
  10755. //
  10756. //}
  10757. //func (c *HisApiController) ComfirmAllopatry() {
  10758. // year := c.GetString("year")
  10759. // month := c.GetString("month")
  10760. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10761. // adminUser := c.GetAdminUserInfo()
  10762. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10763. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10764. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10765. // var dat map[string]interface{}
  10766. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10767. // fmt.Println(dat)
  10768. // } else {
  10769. // fmt.Println(err)
  10770. // }
  10771. // userJSONBytes, _ := json.Marshal(dat)
  10772. // var res models.Result9001
  10773. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10774. // utils.ErrorLog("解析失败:%v", err)
  10775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10776. // return
  10777. // }
  10778. //
  10779. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10780. // var dat2 map[string]interface{}
  10781. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10782. // fmt.Println(dat)
  10783. // } else {
  10784. // fmt.Println(err)
  10785. // }
  10786. // userJSONBytes2, _ := json.Marshal(dat2)
  10787. // var res2 models.Result3260
  10788. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10789. // utils.ErrorLog("解析失败:%v", err)
  10790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10791. // return
  10792. // }
  10793. //
  10794. // if res2.Infcode == 0 {
  10795. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10796. // var dat map[string]interface{}
  10797. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10798. // fmt.Println(dat)
  10799. // } else {
  10800. // fmt.Println(err)
  10801. // }
  10802. // userJSONBytes, _ := json.Marshal(dat)
  10803. // var res3 models.Result3261
  10804. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10805. // utils.ErrorLog("解析失败:%v", err)
  10806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10807. // return
  10808. // }
  10809. //
  10810. // if res3.Infcode == 0 {
  10811. // record := &models.HisYidiClearRecord{
  10812. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10813. // Ctime: time.Now().Unix(),
  10814. // Mtime: time.Now().Unix(),
  10815. // Status: 1,
  10816. // MsgId: msgId,
  10817. // }
  10818. // service.SaveClearRecord(record)
  10819. // c.ServeSuccessJSON(map[string]interface{}{
  10820. // "msg": "提取成功",
  10821. // })
  10822. // }
  10823. // }
  10824. //}
  10825. func (c *HisApiController) RefundAllopatry() {
  10826. year := c.GetString("year")
  10827. month := c.GetString("month")
  10828. id, _ := c.GetInt64("id")
  10829. admin_user_id, _ := c.GetInt64("admin_user_id")
  10830. adminUser := c.GetAdminUserInfo()
  10831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10832. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10833. record, _ := service.GetClearRecordById(id)
  10834. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10835. var dat map[string]interface{}
  10836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10837. fmt.Println(dat)
  10838. } else {
  10839. fmt.Println(err)
  10840. }
  10841. userJSONBytes, _ := json.Marshal(dat)
  10842. var empty ResultFourteen
  10843. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10844. utils.ErrorLog("解析失败:%v", err)
  10845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10846. return
  10847. }
  10848. if empty.Infcode == 0 {
  10849. c.ServeSuccessJSON(map[string]interface{}{
  10850. "msg": "撤销成功",
  10851. })
  10852. return
  10853. }
  10854. }
  10855. func (c *HisApiController) ReversalOtherData() {
  10856. var customData []*CustomData
  10857. custom := &CustomData{
  10858. MsgId: "H44022900158202103301714472004",
  10859. PsnNo: "44020000001101329945",
  10860. Info: "2208",
  10861. }
  10862. customData = append(customData, custom)
  10863. custom1 := &CustomData{
  10864. MsgId: "H4402290015820210330172057803",
  10865. PsnNo: "44020000001101161813",
  10866. Info: "2208",
  10867. }
  10868. customData = append(customData, custom1)
  10869. custom2 := &CustomData{
  10870. MsgId: "H44022900158202103301705198813",
  10871. PsnNo: "44190000133097375417",
  10872. Info: "2208",
  10873. }
  10874. customData = append(customData, custom2)
  10875. custom3 := &CustomData{
  10876. MsgId: "H44022900158202103301715524756",
  10877. PsnNo: "44020000001100187221",
  10878. Info: "2208",
  10879. }
  10880. customData = append(customData, custom3)
  10881. custom4 := &CustomData{
  10882. MsgId: "H44022900158202103301730376224",
  10883. PsnNo: "44020000001101959155",
  10884. Info: "2208",
  10885. }
  10886. customData = append(customData, custom4)
  10887. custom5 := &CustomData{
  10888. MsgId: "H44022900158202103301748008725",
  10889. PsnNo: "44020000001104246641",
  10890. Info: "2208",
  10891. }
  10892. customData = append(customData, custom5)
  10893. custom6 := &CustomData{
  10894. MsgId: "H44022900158202103301718096755",
  10895. PsnNo: "44020000001102211860",
  10896. Info: "2208",
  10897. }
  10898. customData = append(customData, custom6)
  10899. custom7 := &CustomData{
  10900. MsgId: "H44022900158202103301736551640",
  10901. PsnNo: "44020000001102687718",
  10902. Info: "2208",
  10903. }
  10904. customData = append(customData, custom7)
  10905. custom8 := &CustomData{
  10906. MsgId: "H44022900158202103301743097676",
  10907. PsnNo: "44020000001102127785",
  10908. Info: "2208",
  10909. }
  10910. customData = append(customData, custom8)
  10911. custom9 := &CustomData{
  10912. MsgId: "H44022900158202103301712304203",
  10913. PsnNo: "44020000001101518097",
  10914. Info: "2208",
  10915. }
  10916. customData = append(customData, custom9)
  10917. custom10 := &CustomData{
  10918. MsgId: "H44022900158202103301738448785",
  10919. PsnNo: "44020000001100500813",
  10920. Info: "2208",
  10921. }
  10922. customData = append(customData, custom10)
  10923. custom11 := &CustomData{
  10924. MsgId: "H44022900158202103301732455843",
  10925. PsnNo: "44020000001102690557",
  10926. Info: "2208",
  10927. }
  10928. customData = append(customData, custom11)
  10929. custom12 := &CustomData{
  10930. MsgId: "H44022900158202103301745421708",
  10931. PsnNo: "44020000001102211928",
  10932. Info: "2208",
  10933. }
  10934. customData = append(customData, custom12)
  10935. custom1212 := &CustomData{
  10936. MsgId: "H440229001582021033017351627",
  10937. PsnNo: "44020000001102481733",
  10938. Info: "2208",
  10939. }
  10940. customData = append(customData, custom1212)
  10941. custom13 := &CustomData{
  10942. MsgId: "H44022900158202103301740327951",
  10943. PsnNo: "44020000001103174866",
  10944. Info: "2208",
  10945. }
  10946. customData = append(customData, custom13)
  10947. custom14 := &CustomData{
  10948. MsgId: "H4402290015820210330174922668",
  10949. PsnNo: "44020000001102927272",
  10950. Info: "2208",
  10951. }
  10952. customData = append(customData, custom14)
  10953. custom15 := &CustomData{
  10954. MsgId: "H44022900158202103301752362273",
  10955. PsnNo: "44020000001102942890",
  10956. Info: "2208",
  10957. }
  10958. customData = append(customData, custom15)
  10959. custom16 := &CustomData{
  10960. MsgId: "H44022900158202103301751082917",
  10961. PsnNo: "44020000001101662162",
  10962. Info: "2208",
  10963. }
  10964. customData = append(customData, custom16)
  10965. custom17 := &CustomData{
  10966. MsgId: "H44022900158202103301754147728",
  10967. PsnNo: "44020000000229014511",
  10968. Info: "2208",
  10969. }
  10970. customData = append(customData, custom17)
  10971. adminUser := c.GetAdminUserInfo()
  10972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10973. for _, item := range customData {
  10974. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10975. fmt.Println(result)
  10976. }
  10977. }
  10978. func PathExists(path string) (bool, error) {
  10979. _, err := os.Stat(path)
  10980. if err == nil {
  10981. return true, nil
  10982. }
  10983. if os.IsNotExist(err) {
  10984. return false, nil
  10985. }
  10986. return false, err
  10987. }
  10988. //创建文件夹
  10989. func Mkdir(dir string) {
  10990. // 创建文件夹
  10991. exist, err := PathExists(dir)
  10992. if err != nil {
  10993. fmt.Println(err.Error())
  10994. } else {
  10995. if exist {
  10996. fmt.Println(dir + "文件夹已存在!")
  10997. } else {
  10998. // 文件夹名称,权限
  10999. err := os.Mkdir(dir, os.ModePerm)
  11000. if err != nil {
  11001. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11002. } else {
  11003. fmt.Println(dir + "文件夹创建成功!")
  11004. }
  11005. }
  11006. }
  11007. }
  11008. //压缩文件
  11009. func Zip(srcFile string, destZip string) error {
  11010. zipfile, err := os.Create(destZip)
  11011. if err != nil {
  11012. return err
  11013. }
  11014. defer zipfile.Close()
  11015. archive := zip.NewWriter(zipfile)
  11016. defer archive.Close()
  11017. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11018. if err != nil {
  11019. return err
  11020. }
  11021. header, err := zip.FileInfoHeader(info)
  11022. if err != nil {
  11023. return err
  11024. }
  11025. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11026. // header.Name = path
  11027. if info.IsDir() {
  11028. header.Name += "/"
  11029. } else {
  11030. header.Method = zip.Deflate
  11031. }
  11032. writer, err := archive.CreateHeader(header)
  11033. if err != nil {
  11034. return err
  11035. }
  11036. if !info.IsDir() {
  11037. file, err := os.Open(path)
  11038. if err != nil {
  11039. return err
  11040. }
  11041. defer file.Close()
  11042. _, err = io.Copy(writer, file)
  11043. }
  11044. return err
  11045. })
  11046. return err
  11047. }
  11048. func ReadFile(filePath string) []byte {
  11049. f, err := os.Open(filePath)
  11050. if err != nil {
  11051. fmt.Println("read file fail", err)
  11052. return nil
  11053. }
  11054. defer f.Close()
  11055. fd, err := ioutil.ReadAll(f)
  11056. if err != nil {
  11057. fmt.Println("read to fd fail", err)
  11058. return nil
  11059. }
  11060. return fd
  11061. }
  11062. func saveLog(result string, request string, infno string, desc string) {
  11063. org_id, _ := beego.AppConfig.Int64("org_id")
  11064. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11065. dir := miConfig.OrgName + "日志"
  11066. utils.Mkdir(dir)
  11067. month := time.Unix(1557042972, 0).Format("1")
  11068. year := time.Now().Format("2006")
  11069. month = time.Now().Format("01")
  11070. day := time.Now().Format("02")
  11071. hour := time.Now().Format("15")
  11072. min := time.Now().Format("04")
  11073. sec := time.Now().Format("05")
  11074. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11075. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11076. file_name := file + ".txt"
  11077. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11078. exist, _ := utils.PathExists(file_path)
  11079. if exist { //存在
  11080. fmt.Println("存在")
  11081. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11082. if err != nil {
  11083. fmt.Println("read fail")
  11084. }
  11085. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11086. n, _ := f.Seek(0, 2)
  11087. _, err = f.WriteAt([]byte(content), n)
  11088. } else { //不存在
  11089. fmt.Println("文件不存在,创建文件")
  11090. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11091. defer f.Close()
  11092. if err != nil {
  11093. } else {
  11094. _, err = f.Write([]byte("记录日志"))
  11095. }
  11096. }
  11097. }
  11098. type Charset string
  11099. const (
  11100. UTF8 = Charset("UTF-8")
  11101. GB18030 = Charset("GB18030")
  11102. )
  11103. func ConvertToString(src string, srcCode string, tagCode string) string {
  11104. srcCoder := mahonia.NewDecoder(srcCode)
  11105. srcResult := srcCoder.ConvertString(src)
  11106. tagCoder := mahonia.NewDecoder(tagCode)
  11107. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11108. result := string(cdata)
  11109. return result
  11110. }
  11111. func (c *HisApiController) ReadEleCard() {
  11112. id_card_type, _ := c.GetInt64("id_card_type")
  11113. admin_user_id, _ := c.GetInt64("admin_user_id")
  11114. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11115. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11116. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11117. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11118. var api string
  11119. if miConfig.MdtrtareaAdmvs == "320921" {
  11120. 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 +
  11121. "&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
  11122. fmt.Println(api)
  11123. } else {
  11124. 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 +
  11125. "&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
  11126. }
  11127. resp, requestErr := http.Get(api)
  11128. if requestErr != nil {
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return
  11131. }
  11132. body, ioErr := ioutil.ReadAll(resp.Body)
  11133. if ioErr != nil {
  11134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11136. return
  11137. }
  11138. var respJSON map[string]interface{}
  11139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11142. return
  11143. }
  11144. var status string
  11145. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11146. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11147. var token string
  11148. var res ResultTwo //1101结果
  11149. var res10265 ResultTwo10265 //1101结果
  11150. if status == "0" { //读卡成功
  11151. var card_info string //卡信息
  11152. var busi_card_info string
  11153. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11154. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11155. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11156. fmt.Println(card_info)
  11157. fmt.Println(busi_card_info)
  11158. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11159. result, _ := json.Marshal(respJSON)
  11160. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11161. utils.ErrorLog("解析失败:%v", err)
  11162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11163. return
  11164. }
  11165. res.ErrMsg = res10265.ErrMsg
  11166. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11167. res.Infcode = infocode
  11168. res.Output = res10265.Output
  11169. res.InfRefmsgid = res10265.InfRefmsgid
  11170. if res.Infcode == 0 {
  11171. c.ServeSuccessJSON(map[string]interface{}{
  11172. "number": token,
  11173. })
  11174. }
  11175. } else {
  11176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11177. return
  11178. }
  11179. } else { //读卡失败
  11180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11181. return
  11182. }
  11183. }
  11184. func DeleteExtraSpaceTwo(s string) string {
  11185. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11186. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11187. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11188. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11189. s2 := make([]byte, len(s1)) //定义字符数组切片
  11190. copy(s2, s1) //将字符串复制到切片
  11191. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11192. for len(spc_index) > 0 { //找到适配项
  11193. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11194. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11195. }
  11196. return string(s2)
  11197. }
  11198. func Remove0000(s string) string {
  11199. str := make([]rune, 0, len(s))
  11200. for _, v := range []rune(s) {
  11201. if v == 0 {
  11202. continue
  11203. }
  11204. str = append(str, v)
  11205. }
  11206. return string(str)
  11207. }
  11208. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11209. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11210. readCard := DllDef.MustFindProc("EcQuery")
  11211. pCardInfo := make([]byte, 8192)
  11212. pBusiCardInfo := make([]byte, 8192)
  11213. data := make(map[string]interface{})
  11214. //pData := make(map[string]interface{})
  11215. inputData := make(map[string]interface{})
  11216. inputData["orgId"] = code
  11217. inputData["businessType"] = "01101"
  11218. inputData["operatorId"] = operator_id
  11219. inputData["operatorName"] = operator_name
  11220. inputData["officeId"] = "001"
  11221. inputData["officeName"] = "血透室"
  11222. //
  11223. data["data"] = inputData
  11224. data["transType"] = "ec.query"
  11225. data["orgId"] = code
  11226. bytesData, _ := json.Marshal(data)
  11227. pCardInfo = bytesData
  11228. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11229. fmt.Println(ret2)
  11230. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11231. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11232. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11233. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11234. if ret2 != 0 {
  11235. return "", ""
  11236. }
  11237. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11238. }
  11239. func DeleteExtraSpace(s string) string {
  11240. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11241. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11242. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11243. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11244. s2 := make([]byte, len(s1)) //定义字符数组切片
  11245. copy(s2, s1) //将字符串复制到切片
  11246. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11247. for len(spc_index) > 0 { //找到适配项
  11248. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11249. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11250. }
  11251. return string(s2)
  11252. }