his_api_controller.go 398KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863
  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. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. }
  74. func (c *HisApiController) Check() {
  75. psn_no := c.GetString("psn_no")
  76. in := c.GetString("in")
  77. mt := c.GetString("mt")
  78. baseParams := models.BaseParams{
  79. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  80. FixmedinsCode: "H15049901371",
  81. InsuplcAdmdvs: "150499",
  82. MdtrtareaAdmvs: "150499",
  83. OrgName: "赤峰费森血液透析中心",
  84. Doctor: "1111",
  85. }
  86. service.Gdyb2001(baseParams, psn_no, in, mt)
  87. }
  88. func (c *HisApiController) GetPsnNcdsInfo() {
  89. admin_user_id, _ := c.GetInt64("admin_user_id")
  90. patient_id, _ := c.GetInt64("patient_id")
  91. id, _ := c.GetInt64("id")
  92. adminUser := c.GetAdminUserInfo()
  93. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  94. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  95. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  96. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  97. psn_record, _ := service.GetPsnNCDSRecordById(id)
  98. //
  99. //if psn_record.ID == 0 {
  100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  101. // return
  102. //}
  103. var res Result5301
  104. var res10265 Result5301For10265
  105. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  106. psn_info, _ := service.GetPsnByPatientId(patient_id)
  107. var api string
  108. if miConfig.MdtrtareaAdmvs == "320921" {
  109. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  111. } else {
  112. 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 +
  113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  114. }
  115. resp, requestErr := http.Get(api)
  116. if requestErr != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  118. return
  119. }
  120. body, ioErr := ioutil.ReadAll(resp.Body)
  121. if ioErr != nil {
  122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  124. return
  125. }
  126. var respJSON map[string]interface{}
  127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  133. result, _ := json.Marshal(respJSON)
  134. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  135. utils.ErrorLog("解析失败:%v", err)
  136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  137. return
  138. }
  139. res.ErrMsg = res10265.ErrMsg
  140. res.Output = res10265.Output
  141. res.InfRefmsgid = res10265.InfRefmsgid
  142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  143. res.Infcode = infocode
  144. } else {
  145. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  146. var dat map[string]interface{}
  147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  148. fmt.Println(dat)
  149. } else {
  150. fmt.Println(err)
  151. }
  152. userJSONBytes, _ := json.Marshal(dat)
  153. if miConfig.Code == "H15049901371" {
  154. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  155. utils.ErrorLog("解析失败:%v", err)
  156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  157. return
  158. }
  159. res.InfRefmsgid = res10265.InfRefmsgid
  160. res.Output = res10265.Output
  161. res.ErrMsg = res10265.ErrMsg
  162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  163. res.Infcode = infocode
  164. } else {
  165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  166. utils.ErrorLog("解析失败:%v", err)
  167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  168. return
  169. }
  170. }
  171. }
  172. if res.Infcode == 0 {
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "result": res.Output.Result,
  175. })
  176. }
  177. }
  178. func (c *HisApiController) CheckInsutype() {
  179. his_patient_id, _ := c.GetInt64("his_patient_id")
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  182. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  184. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  185. var dat map[string]interface{}
  186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  187. fmt.Println(dat)
  188. } else {
  189. fmt.Println(err)
  190. }
  191. userJSONBytes, _ := json.Marshal(dat)
  192. var res Result90100
  193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  194. utils.ErrorLog("解析失败:%v", err)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. if res.Infcode != 0 {
  199. c.ServeSuccessJSON(map[string]interface{}{
  200. "failed_code": -10,
  201. "msg": res.ErrMsg,
  202. })
  203. return
  204. } else {
  205. fmt.Println(res)
  206. }
  207. }
  208. func (c *HisApiController) CheckCardPWD() {
  209. card_pwd := c.GetString("card_pwd")
  210. his_patient_id, _ := c.GetInt64("his_patient_id")
  211. admin_user_id, _ := c.GetInt64("admin_user_id")
  212. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  214. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  215. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  216. var dat map[string]interface{}
  217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  218. fmt.Println(dat)
  219. } else {
  220. fmt.Println(err)
  221. }
  222. userJSONBytes, _ := json.Marshal(dat)
  223. var res Result90991
  224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode != 0 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. return
  235. } else {
  236. if res.Output.Result.CheckStat == "0" {
  237. var msg string
  238. switch res.Output.Result.CardStat {
  239. case "00":
  240. msg = "未激活"
  241. break
  242. case "10":
  243. msg = "激活"
  244. break
  245. case "20":
  246. msg = "窗口挂失"
  247. break
  248. case "21":
  249. msg = "电话挂失"
  250. break
  251. case "22":
  252. msg = "单位网上申报挂失"
  253. break
  254. case "23":
  255. msg = "保健办挂失"
  256. break
  257. case "24":
  258. msg = "个人网上挂失"
  259. break
  260. case "25":
  261. msg = "网上服务大厅挂失"
  262. break
  263. case "30":
  264. msg = "注销"
  265. break
  266. case "40":
  267. msg = "回收"
  268. break
  269. case "99":
  270. msg = "制卡中(无效卡)"
  271. break
  272. }
  273. c.ServeSuccessJSON(map[string]interface{}{
  274. "failed_code": -10,
  275. "msg": msg,
  276. })
  277. return
  278. } else {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "msg": "校验成功",
  281. })
  282. return
  283. }
  284. }
  285. }
  286. func (c *HisApiController) ReadCard() {
  287. id_card_type, _ := c.GetInt64("id_card_type")
  288. admin_user_id, _ := c.GetInt64("admin_user_id")
  289. certificates, _ := c.GetInt64("certificates")
  290. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  291. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  293. switch id_card_type {
  294. case 1:
  295. if miConfig.MdtrtareaAdmvs == "421300" {
  296. var res ResultTwo
  297. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  298. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  299. "&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)
  300. resp, requestErr := http.Get(api)
  301. if requestErr != nil {
  302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. body, ioErr := ioutil.ReadAll(resp.Body)
  306. if ioErr != nil {
  307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. var respJSON map[string]interface{}
  312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  315. return
  316. }
  317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  318. result, _ := json.Marshal(respJSON)
  319. fmt.Println("log")
  320. fmt.Println(string(result))
  321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  322. utils.ErrorLog("解析失败:%v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. if res.Infcode == 0 {
  327. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  328. if err == gorm.ErrRecordNotFound {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  330. return
  331. } else if err != nil {
  332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  333. return
  334. } else {
  335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  337. infoStr := string(Iinfos)
  338. idetinfoStr := string(Idetinfos)
  339. psn := &models.HisPsn{
  340. PsnNo: res.Output.Baseinfo.PsnNo,
  341. Age: res.Output.Baseinfo.Age,
  342. PatientId: patient.ID,
  343. Certno: res.Output.Baseinfo.Certno,
  344. Brdy: res.Output.Baseinfo.Brdy,
  345. Gend: res.Output.Baseinfo.Gend,
  346. Naty: res.Output.Baseinfo.Naty,
  347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  348. PsnName: res.Output.Baseinfo.PsnName,
  349. Idetinfo: idetinfoStr,
  350. Insuinfo: infoStr,
  351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  352. }
  353. service.CreateHisPsn(psn)
  354. c.ServeSuccessJSON(map[string]interface{}{
  355. "patient": patient,
  356. "number": res.Output.Baseinfo.Certno,
  357. })
  358. }
  359. } else {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  361. return
  362. }
  363. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  364. var api string
  365. if miConfig.MdtrtareaAdmvs == "320921" {
  366. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  367. "&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
  368. fmt.Println(api)
  369. } else {
  370. 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 +
  371. "&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)
  372. }
  373. resp, requestErr := http.Get(api)
  374. if requestErr != nil {
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. body, ioErr := ioutil.ReadAll(resp.Body)
  379. if ioErr != nil {
  380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  382. return
  383. }
  384. var respJSON map[string]interface{}
  385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  388. return
  389. }
  390. var status string
  391. status = respJSON["data"].(map[string]interface{})["status"].(string)
  392. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  393. //console.log()
  394. fmt.Println("type===")
  395. fmt.Println(card_type)
  396. var token string
  397. var res ResultTwo //1101结果
  398. var res10265 ResultTwo10265 //1101结果
  399. var card_info string //卡信息
  400. var busi_card_info string
  401. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  402. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  403. if status == "0" { //读卡成功
  404. if card_type == "1" {
  405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  406. result, _ := json.Marshal(respJSON)
  407. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. res.ErrMsg = res10265.ErrMsg
  413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  414. res.Infcode = infocode
  415. res.Output = res10265.Output
  416. res.InfRefmsgid = res10265.InfRefmsgid
  417. } else {
  418. //var card_info string //卡信息
  419. //var busi_card_info string
  420. token = respJSON["data"].(map[string]interface{})["token"].(string)
  421. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  422. //fmt.Println(card_info)
  423. //fmt.Println(busi_card_info)
  424. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  425. result, _ := json.Marshal(respJSON)
  426. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  427. utils.ErrorLog("解析失败:%v", err)
  428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  429. return
  430. }
  431. res.ErrMsg = res10265.ErrMsg
  432. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  433. res.Infcode = infocode
  434. res.Output = res10265.Output
  435. res.InfRefmsgid = res10265.InfRefmsgid
  436. }
  437. if res.Infcode == 0 {
  438. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  439. if err == gorm.ErrRecordNotFound {
  440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  441. return
  442. } else if err != nil {
  443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  444. return
  445. } else {
  446. if card_type == "1" {
  447. bas := strings.Split(card_info, "|")
  448. basNumber := bas[2]
  449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  451. infoStr := string(Iinfos)
  452. idetinfoStr := string(Idetinfos)
  453. psn := &models.HisPsn{
  454. PsnNo: res.Output.Baseinfo.PsnNo,
  455. Age: res.Output.Baseinfo.Age,
  456. PatientId: patient.ID,
  457. Certno: res.Output.Baseinfo.Certno,
  458. Brdy: res.Output.Baseinfo.Brdy,
  459. Gend: res.Output.Baseinfo.Gend,
  460. Naty: res.Output.Baseinfo.Naty,
  461. PsnCertType: res.Output.Baseinfo.PsnCertType,
  462. PsnName: res.Output.Baseinfo.PsnName,
  463. Idetinfo: idetinfoStr,
  464. Insuinfo: infoStr,
  465. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  466. CardInfo: card_info,
  467. VerifyNumber: busi_card_info,
  468. }
  469. service.CreateHisPsn(psn)
  470. c.ServeSuccessJSON(map[string]interface{}{
  471. "patient": patient,
  472. "number": basNumber,
  473. })
  474. } else {
  475. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  476. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  477. infoStr := string(Iinfos)
  478. idetinfoStr := string(Idetinfos)
  479. psn := &models.HisPsn{
  480. PsnNo: res.Output.Baseinfo.PsnNo,
  481. Age: res.Output.Baseinfo.Age,
  482. PatientId: patient.ID,
  483. Certno: res.Output.Baseinfo.Certno,
  484. Brdy: res.Output.Baseinfo.Brdy,
  485. Gend: res.Output.Baseinfo.Gend,
  486. Naty: res.Output.Baseinfo.Naty,
  487. PsnCertType: res.Output.Baseinfo.PsnCertType,
  488. PsnName: res.Output.Baseinfo.PsnName,
  489. Idetinfo: idetinfoStr,
  490. Insuinfo: infoStr,
  491. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  492. CardInfo: card_info,
  493. VerifyNumber: token,
  494. }
  495. service.CreateHisPsn(psn)
  496. c.ServeSuccessJSON(map[string]interface{}{
  497. "patient": patient,
  498. "number": token,
  499. })
  500. }
  501. }
  502. } else {
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  504. return
  505. }
  506. } else { //读卡失败
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  508. return
  509. }
  510. } else {
  511. if initFlag == 0 {
  512. c.TestGetBasBaseInit()
  513. }
  514. basStr := c.GetBasBaseInfo()
  515. if len(basStr) == 0 {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  517. return
  518. }
  519. fmt.Println(basStr)
  520. bas := strings.Split(basStr, "|")
  521. basNumber := bas[1]
  522. fmt.Println(basNumber)
  523. card_sn := bas[3]
  524. fmt.Println(card_sn)
  525. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  526. var dat map[string]interface{}
  527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  528. fmt.Println(dat)
  529. } else {
  530. fmt.Println(err)
  531. }
  532. userJSONBytes, _ := json.Marshal(dat)
  533. var res ResultTwo
  534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  535. utils.ErrorLog("解析失败:%v", err)
  536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  537. return
  538. }
  539. if res.Infcode == 0 {
  540. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  541. if err == gorm.ErrRecordNotFound {
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  543. return
  544. } else if err != nil {
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  546. return
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "patient": patient,
  550. "number": basNumber,
  551. })
  552. }
  553. } else {
  554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  555. return
  556. }
  557. break
  558. }
  559. case 2:
  560. SFZStr := c.GetSFZBaseInfo()
  561. id_card_str := strings.Split(SFZStr, "^")
  562. id_card_number := id_card_str[0]
  563. card_sn := ""
  564. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  565. var dat map[string]interface{}
  566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  567. fmt.Println(dat)
  568. } else {
  569. fmt.Println(err)
  570. }
  571. userJSONBytes, _ := json.Marshal(dat)
  572. var res ResultTwo
  573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  574. utils.ErrorLog("解析失败:%v", err)
  575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  576. return
  577. }
  578. if res.Infcode == 0 {
  579. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  580. if err == gorm.ErrRecordNotFound {
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  582. return
  583. } else if err != nil {
  584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  585. return
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "patient": patient,
  589. "number": id_card_number,
  590. })
  591. }
  592. } else {
  593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  594. return
  595. }
  596. break
  597. case 3:
  598. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  599. var api string
  600. if miConfig.MdtrtareaAdmvs == "320921" {
  601. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  602. "&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
  603. fmt.Println(api)
  604. } else {
  605. 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 +
  606. "&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)
  607. }
  608. resp, requestErr := http.Get(api)
  609. if requestErr != nil {
  610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. return
  612. }
  613. body, ioErr := ioutil.ReadAll(resp.Body)
  614. if ioErr != nil {
  615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  617. return
  618. }
  619. var respJSON map[string]interface{}
  620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  623. return
  624. }
  625. var status string
  626. status = respJSON["data"].(map[string]interface{})["status"].(string)
  627. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  628. var token string
  629. var res ResultTwo //1101结果
  630. var res10265 ResultTwo10265 //1101结果
  631. var card_info string //卡信息
  632. var busi_card_info string
  633. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  634. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  635. if status == "0" { //读卡成功
  636. if card_type == "1" {
  637. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  638. result, _ := json.Marshal(respJSON)
  639. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  640. utils.ErrorLog("解析失败:%v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. res.ErrMsg = res10265.ErrMsg
  645. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  646. res.Infcode = infocode
  647. res.Output = res10265.Output
  648. res.InfRefmsgid = res10265.InfRefmsgid
  649. } else {
  650. //var card_info string //卡信息
  651. //var busi_card_info string
  652. token = respJSON["data"].(map[string]interface{})["token"].(string)
  653. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  654. //fmt.Println(card_info)
  655. //fmt.Println(busi_card_info)
  656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  657. result, _ := json.Marshal(respJSON)
  658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  659. utils.ErrorLog("解析失败:%v", err)
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  661. return
  662. }
  663. res.ErrMsg = res10265.ErrMsg
  664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  665. res.Infcode = infocode
  666. res.Output = res10265.Output
  667. res.InfRefmsgid = res10265.InfRefmsgid
  668. }
  669. if res.Infcode == 0 {
  670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  671. if err == gorm.ErrRecordNotFound {
  672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  673. return
  674. } else if err != nil {
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  676. return
  677. } else {
  678. if card_type == "1" {
  679. bas := strings.Split(card_info, "|")
  680. basNumber := bas[2]
  681. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  682. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  683. infoStr := string(Iinfos)
  684. idetinfoStr := string(Idetinfos)
  685. psn := &models.HisPsn{
  686. PsnNo: res.Output.Baseinfo.PsnNo,
  687. Age: res.Output.Baseinfo.Age,
  688. PatientId: patient.ID,
  689. Certno: res.Output.Baseinfo.Certno,
  690. Brdy: res.Output.Baseinfo.Brdy,
  691. Gend: res.Output.Baseinfo.Gend,
  692. Naty: res.Output.Baseinfo.Naty,
  693. PsnCertType: res.Output.Baseinfo.PsnCertType,
  694. PsnName: res.Output.Baseinfo.PsnName,
  695. Idetinfo: idetinfoStr,
  696. Insuinfo: infoStr,
  697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  698. CardInfo: card_info,
  699. VerifyNumber: busi_card_info,
  700. }
  701. service.CreateHisPsn(psn)
  702. c.ServeSuccessJSON(map[string]interface{}{
  703. "patient": patient,
  704. "number": basNumber,
  705. })
  706. } else {
  707. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  708. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  709. infoStr := string(Iinfos)
  710. idetinfoStr := string(Idetinfos)
  711. psn := &models.HisPsn{
  712. PsnNo: res.Output.Baseinfo.PsnNo,
  713. Age: res.Output.Baseinfo.Age,
  714. PatientId: patient.ID,
  715. Certno: res.Output.Baseinfo.Certno,
  716. Brdy: res.Output.Baseinfo.Brdy,
  717. Gend: res.Output.Baseinfo.Gend,
  718. Naty: res.Output.Baseinfo.Naty,
  719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  720. PsnName: res.Output.Baseinfo.PsnName,
  721. Idetinfo: idetinfoStr,
  722. Insuinfo: infoStr,
  723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  724. CardInfo: card_info,
  725. VerifyNumber: token,
  726. }
  727. service.CreateHisPsn(psn)
  728. c.ServeSuccessJSON(map[string]interface{}{
  729. "patient": patient,
  730. "number": token,
  731. })
  732. }
  733. }
  734. } else {
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  736. return
  737. }
  738. } else { //读卡失败
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  740. return
  741. }
  742. }
  743. break
  744. }
  745. }
  746. var initFlag int64 = 0
  747. func (c *HisApiController) TestGetBasBaseInit() {
  748. DllDef := syscall.MustLoadDLL("SSCard.dll")
  749. Iinit := DllDef.MustFindProc("Init")
  750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  751. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  752. if ret != 0 {
  753. fmt.Println("SSCard的报错原因:", err)
  754. fmt.Println("SSCard的运算结果为:", ret)
  755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  756. return
  757. }
  758. result := int(ret)
  759. fmt.Println("SSCard的运算结果为1:", result)
  760. initFlag = 1
  761. return
  762. }
  763. func (c *HisApiController) GetSFZBaseInfo() string {
  764. DllDef := syscall.MustLoadDLL("SSCard.dll")
  765. readCard := DllDef.MustFindProc("ReadSFZ")
  766. if readCard == nil {
  767. fmt.Println("readcard is nil")
  768. readCard = DllDef.MustFindProc("ReadSFZ")
  769. }
  770. str := make([]byte, 256)
  771. str1 := make([]byte, 256)
  772. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  773. fmt.Println(r)
  774. return string(str)
  775. }
  776. func (c *HisApiController) GetBasBaseInfo() string {
  777. DllDef := syscall.MustLoadDLL("SSCard.dll")
  778. readCard := DllDef.MustFindProc("ReadCardBas")
  779. if readCard == nil {
  780. fmt.Println("readcard is nil")
  781. readCard = DllDef.MustFindProc("ReadCardBas")
  782. }
  783. str := make([]byte, 1024)
  784. str1 := make([]byte, 1024)
  785. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  786. fmt.Println(string(str1))
  787. fmt.Println(string(str))
  788. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  789. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  790. if ret2 != 0 {
  791. return ""
  792. }
  793. return string(str)
  794. }
  795. type CustomFundPay struct {
  796. FundPayType string `json:"fund_pay_type"`
  797. FundPayamt float64 `json:"fund_payamt"`
  798. }
  799. func (c *HisApiController) GetSettleList() {
  800. order_id, _ := c.GetInt64("order_id")
  801. admin_user_id, _ := c.GetInt64("admin_user_id")
  802. order, _ := service.GetHisOrderByIDTwo(order_id)
  803. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  804. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  805. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  806. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  807. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  809. if order.ID == 0 {
  810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  811. return
  812. }
  813. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  814. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  815. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  816. fmt.Println(count)
  817. var zero string
  818. number := count + 1
  819. if number >= 1000 {
  820. zero = "0000" + strconv.FormatInt(number, 10)
  821. } else if number >= 10000 {
  822. zero = "000" + strconv.FormatInt(number, 10)
  823. } else if number >= 100000 {
  824. zero = "00" + strconv.FormatInt(number, 10)
  825. } else if number >= 1000000 {
  826. zero = "0" + strconv.FormatInt(number, 10)
  827. } else {
  828. zero = strconv.FormatInt(number, 10)
  829. }
  830. fmt.Println(zero)
  831. struct4101 := service.Struct4101{
  832. PsnNo: order.PsnNo,
  833. MdtrtId: order.MdtrtId,
  834. SetlId: order.SetlId,
  835. PsnName: order.PsnName,
  836. Gend: order.Gend,
  837. Brdy: his.Brdy,
  838. Age: his.Age,
  839. Naty: order.Naty,
  840. PatnCertType: "01",
  841. Certno: order.Certno,
  842. Prfs: "90",
  843. ConerName: roles[0].UserName,
  844. PatnRlts: "99",
  845. ConerAddr: miConfig.OrgName,
  846. ConerTel: admin.Mobile,
  847. HiType: order.Insutype,
  848. Insuplc: miConfig.InsuplcAdmdvs,
  849. MaindiagFlag: "1",
  850. BillCode: last_order.FaPiaoCode,
  851. BillNo: zero,
  852. BizSn: order.Number,
  853. PsnSelfPay: order.PsnPartAmt,
  854. PsnOwnPay: order.PsnPartAmt,
  855. AcctPay: order.AcctPay,
  856. PsnCashpay: order.PsnCashPay,
  857. HiPaymtd: "1",
  858. Hsorg: miConfig.InsuplcAdmdvs,
  859. HsorgOpter: miConfig.InsuplcAdmdvs,
  860. MedinsFillPsn: curRoles.UserName,
  861. MedinsFillDept: depart.Name,
  862. IptMedType: "2",
  863. }
  864. struct4101.SetlBegnDate = order.SetlTime
  865. struct4101.SetlEndDate = order.SetlTime
  866. time_arr := strings.Split(order.SetlTime, " ")
  867. struct4101.AdmTime = time_arr[0]
  868. struct4101.AdmEndTime = time_arr[0]
  869. var rf []CustomFundPay
  870. json.Unmarshal([]byte(order.SetlDetail), &rf)
  871. var tempFunPays []service.CustomStruct
  872. for _, item := range rf {
  873. var tempFunPay service.CustomStruct
  874. tempFunPay.FundPayamt = item.FundPayamt
  875. tempFunPay.FundPayType = item.FundPayType
  876. tempFunPays = append(tempFunPays, tempFunPay)
  877. }
  878. struct4101.CustomStruct = tempFunPays
  879. var tempDiaginfos []service.DiaginfoStructTwo
  880. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  881. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  882. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  883. var config []*models.HisXtDiagnoseConfig
  884. for _, item := range diagnosis_ids {
  885. id, _ := strconv.ParseInt(item, 10, 64)
  886. diagnosisConfig, _ := service.FindDiagnoseById(id)
  887. config = append(config, &diagnosisConfig)
  888. }
  889. for index, item := range config {
  890. if index == 0 {
  891. var tempDiaginfo service.DiaginfoStructTwo
  892. tempDiaginfo.DiagCode = item.CountryCode
  893. tempDiaginfo.DiagName = item.CountryContentName
  894. tempDiaginfo.DiagType = "1"
  895. tempDiaginfo.MaindiagFlag = "1"
  896. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  897. } else {
  898. var tempDiaginfo service.DiaginfoStructTwo
  899. tempDiaginfo.DiagCode = item.CountryCode
  900. tempDiaginfo.DiagName = item.CountryContentName
  901. tempDiaginfo.DiagType = "2"
  902. tempDiaginfo.MaindiagFlag = "0"
  903. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  904. }
  905. }
  906. struct4101.Diseinfo = tempDiaginfos
  907. sickConfigTwo, _ := service.FindSickById(his.SickType)
  908. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  909. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  910. tempOpspdiseinfo2.OprnOprtCode = ""
  911. tempOpspdiseinfo2.OprnOprtName = ""
  912. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  913. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  914. var iteminfo service.IteminfoStruct
  915. var bedCostTotal float64 = 0 //床位总费
  916. var bedCostSelfTotal float64 = 0 //床位自费
  917. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  918. var operationCostTotal float64 = 0 //手术费
  919. var operationCostSelfTotal float64 = 0 //手术费
  920. var operationCostPartSelfTotal float64 = 0 //手术费
  921. var otherCostTotal float64 = 0 //其他费用
  922. var otherCostSelfTotal float64 = 0 //其他费用
  923. var otherCostPartSelfTotal float64 = 0 //其他费用
  924. var materialCostTotal float64 = 0 //材料费
  925. var materialCostSelfTotal float64 = 0 //材料费
  926. var materialCostPartSelfTotal float64 = 0 //材料费
  927. var westernMedicineCostTotal float64 = 0 //西药费
  928. var westernMedicineCostSelfTotal float64 = 0 //西药费
  929. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  930. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  931. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  932. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  933. var checkCostTotal float64 = 0 //检查费
  934. var checkCostSelfTotal float64 = 0 //检查费
  935. var checkCostPartSelfTotal float64 = 0 //检查费
  936. var laboratoryCostTotal float64 = 0 //化验费
  937. var laboratoryCostSelfTotal float64 = 0 //化验费
  938. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  939. var treatCostTotal float64 = 0 //治疗费用
  940. var treatCostSelfTotal float64 = 0 //治疗费用
  941. var treatCostPartSelfTotal float64 = 0 //治疗费用
  942. decimal.DivisionPrecision = 2
  943. var bed_fulamt_ownpay_amt float64 = 0
  944. var operation_fulamt_ownpay_amt float64 = 0
  945. var other_fulamt_ownpay_amt float64 = 0
  946. var westernMedicine_fulamt_ownpay_amt float64 = 0
  947. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  948. var check_fulamt_ownpay_amt float64 = 0
  949. var material_fulamt_ownpay_amt float64 = 0
  950. var laboratory_fulamt_ownpay_amt float64 = 0
  951. var treat_fulamt_ownpay_amt float64 = 0
  952. var bed_claa_sunmfee float64 = 0
  953. var bed_clab_amt float64 = 0
  954. var bed_other_amt float64 = 0
  955. var operation_claa_sunmfee float64 = 0
  956. var operation_clab_amt float64 = 0
  957. var operation_other_amt float64 = 0
  958. var other_claa_sunmfee float64 = 0
  959. var other_clab_amt float64 = 0
  960. var other_other_amt float64 = 0
  961. var westernMedicine_claa_sunmfee float64 = 0
  962. var westernMedicine_clab_amt float64 = 0
  963. var westernMedicine_other_amt float64 = 0
  964. var chineseTraditional_claa_sunmfee float64 = 0
  965. var chineseTraditional_clab_amt float64 = 0
  966. var chineseTraditional_other_amt float64 = 0
  967. var check_claa_sunmfee float64 = 0
  968. var check_clab_amt float64 = 0
  969. var check_other_amt float64 = 0
  970. var material_claa_sunmfee float64 = 0
  971. var material_clab_amt float64 = 0
  972. var material_other_amt float64 = 0
  973. var laboratory_claa_sunmfee float64 = 0
  974. var laboratory_clab_amt float64 = 0
  975. var laboratory_other_amt float64 = 0
  976. var treat_claa_sunmfee float64 = 0
  977. var treat_clab_amt float64 = 0
  978. var treat_other_amt float64 = 0
  979. for _, item := range order.HisOrderInfo {
  980. if item.MedChrgitmType == "01" { //床位费
  981. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  982. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  983. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  984. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  985. if item.ChrgitmLv == "1" {
  986. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  987. }
  988. if item.ChrgitmLv == "2" {
  989. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  990. }
  991. if item.ChrgitmLv == "3" {
  992. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  993. }
  994. }
  995. if item.MedChrgitmType == "03" { //检查费
  996. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  997. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  998. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  999. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1000. if item.ChrgitmLv == "1" {
  1001. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1002. }
  1003. if item.ChrgitmLv == "2" {
  1004. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1005. }
  1006. if item.ChrgitmLv == "3" {
  1007. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1008. }
  1009. }
  1010. if item.MedChrgitmType == "04" { //化验费
  1011. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1012. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1013. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1014. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1015. if item.ChrgitmLv == "1" {
  1016. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1017. }
  1018. if item.ChrgitmLv == "2" {
  1019. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1020. }
  1021. if item.ChrgitmLv == "3" {
  1022. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1023. }
  1024. }
  1025. if item.MedChrgitmType == "05" { //治疗费
  1026. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1027. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1028. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1029. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1030. if item.ChrgitmLv == "1" {
  1031. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1032. }
  1033. if item.ChrgitmLv == "2" {
  1034. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1035. }
  1036. if item.ChrgitmLv == "3" {
  1037. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1038. }
  1039. }
  1040. if item.MedChrgitmType == "06" { //手术费
  1041. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1042. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1043. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1044. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1045. if item.ChrgitmLv == "1" {
  1046. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1047. }
  1048. if item.ChrgitmLv == "2" {
  1049. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1050. }
  1051. if item.ChrgitmLv == "3" {
  1052. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1053. }
  1054. }
  1055. if item.MedChrgitmType == "08" { //材料费
  1056. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1057. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1058. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1059. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1060. if item.ChrgitmLv == "1" {
  1061. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1062. }
  1063. if item.ChrgitmLv == "2" {
  1064. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1065. }
  1066. if item.ChrgitmLv == "3" {
  1067. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1068. }
  1069. }
  1070. if item.MedChrgitmType == "09" { //西药费
  1071. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1072. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1073. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1074. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1075. if item.ChrgitmLv == "1" {
  1076. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1077. }
  1078. if item.ChrgitmLv == "2" {
  1079. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1080. }
  1081. if item.ChrgitmLv == "3" {
  1082. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1083. }
  1084. }
  1085. if item.MedChrgitmType == "11" { //中成费
  1086. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1087. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1088. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1089. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1090. if item.ChrgitmLv == "1" {
  1091. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1092. }
  1093. if item.ChrgitmLv == "2" {
  1094. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1095. }
  1096. if item.ChrgitmLv == "3" {
  1097. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1098. }
  1099. }
  1100. if item.MedChrgitmType == "14" { //其他费
  1101. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1102. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1103. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1104. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1105. if item.ChrgitmLv == "1" {
  1106. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1107. }
  1108. if item.ChrgitmLv == "2" {
  1109. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1110. }
  1111. if item.ChrgitmLv == "3" {
  1112. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1113. }
  1114. }
  1115. }
  1116. var iteminfoStructs []service.IteminfoStruct
  1117. if bedCostTotal != 0 {
  1118. iteminfo.MedChrgitm = "01"
  1119. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1120. iteminfo.Amt = bedCostTotal
  1121. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1122. iteminfo.ClabAmt = bed_clab_amt
  1123. iteminfo.OthAmt = bed_other_amt
  1124. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1125. }
  1126. if checkCostTotal != 0 {
  1127. iteminfo.MedChrgitm = "03"
  1128. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1129. iteminfo.Amt = checkCostTotal
  1130. iteminfo.ClaaSumfee = check_claa_sunmfee
  1131. iteminfo.ClabAmt = check_clab_amt
  1132. iteminfo.OthAmt = check_other_amt
  1133. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1134. }
  1135. if laboratoryCostTotal != 0 {
  1136. iteminfo.MedChrgitm = "04"
  1137. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1138. iteminfo.Amt = laboratoryCostTotal
  1139. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1140. iteminfo.ClabAmt = laboratory_clab_amt
  1141. iteminfo.OthAmt = laboratory_other_amt
  1142. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1143. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1144. }
  1145. if treatCostTotal != 0 {
  1146. iteminfo.MedChrgitm = "05"
  1147. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1148. iteminfo.Amt = treatCostTotal
  1149. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1150. iteminfo.ClabAmt = treat_clab_amt
  1151. iteminfo.OthAmt = treat_other_amt
  1152. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1153. //(struct4101.IteminfoStruct, iteminfo)
  1154. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1155. }
  1156. if operationCostTotal != 0 {
  1157. iteminfo.MedChrgitm = "06"
  1158. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1159. iteminfo.Amt = operationCostTotal
  1160. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1161. iteminfo.ClabAmt = operation_clab_amt
  1162. iteminfo.OthAmt = operation_other_amt
  1163. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1165. }
  1166. if materialCostTotal != 0 {
  1167. iteminfo.MedChrgitm = "08"
  1168. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1169. iteminfo.Amt = materialCostTotal
  1170. iteminfo.ClaaSumfee = material_claa_sunmfee
  1171. iteminfo.ClabAmt = material_clab_amt
  1172. iteminfo.OthAmt = material_other_amt
  1173. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1174. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1175. }
  1176. if westernMedicineCostTotal != 0 {
  1177. iteminfo.MedChrgitm = "09"
  1178. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1179. iteminfo.Amt = westernMedicineCostTotal
  1180. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1181. iteminfo.ClabAmt = westernMedicine_clab_amt
  1182. iteminfo.OthAmt = westernMedicine_other_amt
  1183. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1184. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1185. }
  1186. if chineseTraditionalMedicineCostTotal != 0 {
  1187. iteminfo.MedChrgitm = "11"
  1188. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1189. iteminfo.Amt = westernMedicineCostTotal
  1190. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1191. iteminfo.ClabAmt = westernMedicine_clab_amt
  1192. iteminfo.OthAmt = westernMedicine_other_amt
  1193. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1194. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1195. }
  1196. if otherCostTotal != 0 {
  1197. iteminfo.MedChrgitm = "14"
  1198. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1199. iteminfo.Amt = otherCostTotal
  1200. iteminfo.ClaaSumfee = other_claa_sunmfee
  1201. iteminfo.ClabAmt = other_clab_amt
  1202. iteminfo.OthAmt = other_other_amt
  1203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1205. }
  1206. struct4101.IteminfoStruct = iteminfoStructs
  1207. struct4101.Ntly = "中国"
  1208. struct4101.AdmCaty = "A03.06"
  1209. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1210. fmt.Println(result)
  1211. var dat map[string]interface{}
  1212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1213. fmt.Println(dat)
  1214. } else {
  1215. fmt.Println(err)
  1216. }
  1217. userJSONBytes, _ := json.Marshal(dat)
  1218. var res ResultSeventeen
  1219. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1220. utils.ErrorLog("解析失败:%v", err)
  1221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1222. return
  1223. }
  1224. if res.Infcode != 0 {
  1225. c.ServeSuccessJSON(map[string]interface{}{
  1226. "failed_code": -10,
  1227. "msg": res.ErrMsg,
  1228. })
  1229. return
  1230. } else {
  1231. order.FaPiaoNumber = zero
  1232. order.FaPiaoCode = last_order.FaPiaoCode
  1233. service.UpdateOrder(order)
  1234. hisFundSettleListResult := &models.HisFundSettleListResult{
  1235. Number: res.Output.SetlListId,
  1236. Status: 1,
  1237. Ctime: time.Now().Unix(),
  1238. Mtime: time.Now().Unix(),
  1239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1240. IsUpload: 1,
  1241. OrderId: order_id,
  1242. }
  1243. service.CreateUploadRecord(hisFundSettleListResult)
  1244. c.ServeSuccessJSON(map[string]interface{}{
  1245. "msg": "上传成功",
  1246. "result": hisFundSettleListResult,
  1247. })
  1248. return
  1249. }
  1250. }
  1251. func (c *HisApiController) GetSettleListHospital() {
  1252. order_id, _ := c.GetInt64("order_id")
  1253. admin_user_id, _ := c.GetInt64("admin_user_id")
  1254. order, _ := service.GetHisOrderByIDTwo(order_id)
  1255. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1256. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1257. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1258. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1259. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1260. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1261. if order.ID == 0 {
  1262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1263. return
  1264. }
  1265. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1266. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1267. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1268. fmt.Println(count)
  1269. var zero string
  1270. number := count + 1
  1271. if number >= 1000 {
  1272. zero = "0000" + strconv.FormatInt(number, 10)
  1273. } else if number >= 10000 {
  1274. zero = "000" + strconv.FormatInt(number, 10)
  1275. } else if number >= 100000 {
  1276. zero = "00" + strconv.FormatInt(number, 10)
  1277. } else if number >= 1000000 {
  1278. zero = "0" + strconv.FormatInt(number, 10)
  1279. } else {
  1280. zero = strconv.FormatInt(number, 10)
  1281. }
  1282. fmt.Println(zero)
  1283. struct4101 := service.Struct4101{
  1284. PsnNo: order.PsnNo,
  1285. MdtrtId: order.MdtrtId,
  1286. SetlId: order.SetlId,
  1287. PsnName: order.PsnName,
  1288. Gend: order.Gend,
  1289. Brdy: his.Brdy,
  1290. Age: int64(order.Age),
  1291. Naty: order.Naty,
  1292. PatnCertType: "01",
  1293. Certno: order.Certno,
  1294. Prfs: "90",
  1295. ConerName: roles[0].UserName,
  1296. PatnRlts: "99",
  1297. ConerAddr: miConfig.OrgName,
  1298. ConerTel: admin.Mobile,
  1299. HiType: order.Insutype,
  1300. Insuplc: miConfig.InsuplcAdmdvs,
  1301. MaindiagFlag: "1",
  1302. BillCode: last_order.FaPiaoCode,
  1303. BillNo: zero,
  1304. BizSn: order.Number,
  1305. PsnSelfPay: order.PsnPartAmt,
  1306. PsnOwnPay: order.PsnPartAmt,
  1307. AcctPay: order.AcctPay,
  1308. PsnCashpay: order.PsnCashPay,
  1309. HiPaymtd: "1",
  1310. Hsorg: miConfig.InsuplcAdmdvs,
  1311. HsorgOpter: miConfig.InsuplcAdmdvs,
  1312. MedinsFillPsn: curRoles.UserName,
  1313. MedinsFillDept: depart.Name,
  1314. IptMedType: "2",
  1315. AdmTime: his.InHosptialTime,
  1316. AdmEndTime: his.OutHosptialTime,
  1317. }
  1318. struct4101.SetlBegnDate = order.SetlTime
  1319. struct4101.SetlEndDate = order.SetlTime
  1320. var rf []CustomFundPay
  1321. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1322. var tempFunPays []service.CustomStruct
  1323. for _, item := range rf {
  1324. var tempFunPay service.CustomStruct
  1325. tempFunPay.FundPayamt = item.FundPayamt
  1326. tempFunPay.FundPayType = item.FundPayType
  1327. tempFunPays = append(tempFunPays, tempFunPay)
  1328. }
  1329. struct4101.CustomStruct = tempFunPays
  1330. var tempDiaginfos []service.DiaginfoStructTwo
  1331. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1332. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1333. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1334. var config []*models.HisXtDiagnoseConfig
  1335. for _, item := range diagnosis_ids {
  1336. id, _ := strconv.ParseInt(item, 10, 64)
  1337. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1338. config = append(config, &diagnosisConfig)
  1339. }
  1340. for index, item := range config {
  1341. if index == 0 {
  1342. var tempDiaginfo service.DiaginfoStructTwo
  1343. tempDiaginfo.DiagCode = item.CountryCode
  1344. tempDiaginfo.DiagName = item.CountryContentName
  1345. tempDiaginfo.DiagType = "1"
  1346. tempDiaginfo.MaindiagFlag = "1"
  1347. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1348. } else {
  1349. var tempDiaginfo service.DiaginfoStructTwo
  1350. tempDiaginfo.DiagCode = item.CountryCode
  1351. tempDiaginfo.DiagName = item.CountryContentName
  1352. tempDiaginfo.DiagType = "2"
  1353. tempDiaginfo.MaindiagFlag = "0"
  1354. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1355. }
  1356. }
  1357. struct4101.Diseinfo = tempDiaginfos
  1358. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1359. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1360. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1361. tempOpspdiseinfo2.OprnOprtCode = ""
  1362. tempOpspdiseinfo2.OprnOprtName = ""
  1363. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1364. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1365. var iteminfo service.IteminfoStruct
  1366. var bedCostTotal float64 = 0 //床位总费
  1367. var bedCostSelfTotal float64 = 0 //床位自费
  1368. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1369. var operationCostTotal float64 = 0 //手术费
  1370. var operationCostSelfTotal float64 = 0 //手术费
  1371. var operationCostPartSelfTotal float64 = 0 //手术费
  1372. var otherCostTotal float64 = 0 //其他费用
  1373. var otherCostSelfTotal float64 = 0 //其他费用
  1374. var otherCostPartSelfTotal float64 = 0 //其他费用
  1375. var materialCostTotal float64 = 0 //材料费
  1376. var materialCostSelfTotal float64 = 0 //材料费
  1377. var materialCostPartSelfTotal float64 = 0 //材料费
  1378. var westernMedicineCostTotal float64 = 0 //西药费
  1379. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1380. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1381. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1382. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1383. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1384. var checkCostTotal float64 = 0 //检查费
  1385. var checkCostSelfTotal float64 = 0 //检查费
  1386. var checkCostPartSelfTotal float64 = 0 //检查费
  1387. var laboratoryCostTotal float64 = 0 //化验费
  1388. var laboratoryCostSelfTotal float64 = 0 //化验费
  1389. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1390. var treatCostTotal float64 = 0 //治疗费用
  1391. var treatCostSelfTotal float64 = 0 //治疗费用
  1392. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1393. decimal.DivisionPrecision = 2
  1394. var bed_fulamt_ownpay_amt float64 = 0
  1395. var operation_fulamt_ownpay_amt float64 = 0
  1396. var other_fulamt_ownpay_amt float64 = 0
  1397. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1398. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1399. var check_fulamt_ownpay_amt float64 = 0
  1400. var material_fulamt_ownpay_amt float64 = 0
  1401. var laboratory_fulamt_ownpay_amt float64 = 0
  1402. var treat_fulamt_ownpay_amt float64 = 0
  1403. var bed_claa_sunmfee float64 = 0
  1404. var bed_clab_amt float64 = 0
  1405. var bed_other_amt float64 = 0
  1406. var operation_claa_sunmfee float64 = 0
  1407. var operation_clab_amt float64 = 0
  1408. var operation_other_amt float64 = 0
  1409. var other_claa_sunmfee float64 = 0
  1410. var other_clab_amt float64 = 0
  1411. var other_other_amt float64 = 0
  1412. var westernMedicine_claa_sunmfee float64 = 0
  1413. var westernMedicine_clab_amt float64 = 0
  1414. var westernMedicine_other_amt float64 = 0
  1415. var chineseTraditional_claa_sunmfee float64 = 0
  1416. var chineseTraditional_clab_amt float64 = 0
  1417. var chineseTraditional_other_amt float64 = 0
  1418. var check_claa_sunmfee float64 = 0
  1419. var check_clab_amt float64 = 0
  1420. var check_other_amt float64 = 0
  1421. var material_claa_sunmfee float64 = 0
  1422. var material_clab_amt float64 = 0
  1423. var material_other_amt float64 = 0
  1424. var laboratory_claa_sunmfee float64 = 0
  1425. var laboratory_clab_amt float64 = 0
  1426. var laboratory_other_amt float64 = 0
  1427. var treat_claa_sunmfee float64 = 0
  1428. var treat_clab_amt float64 = 0
  1429. var treat_other_amt float64 = 0
  1430. for _, item := range order.HisOrderInfo {
  1431. if item.MedChrgitmType == "01" { //床位费
  1432. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1433. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1434. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1435. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1436. if item.ChrgitmLv == "1" {
  1437. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1438. }
  1439. if item.ChrgitmLv == "2" {
  1440. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1441. }
  1442. if item.ChrgitmLv == "3" {
  1443. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1444. }
  1445. }
  1446. if item.MedChrgitmType == "03" { //检查费
  1447. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1448. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1449. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1450. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1451. if item.ChrgitmLv == "1" {
  1452. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1453. }
  1454. if item.ChrgitmLv == "2" {
  1455. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1456. }
  1457. if item.ChrgitmLv == "3" {
  1458. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1459. }
  1460. }
  1461. if item.MedChrgitmType == "04" { //化验费
  1462. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1463. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1464. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1465. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1466. if item.ChrgitmLv == "1" {
  1467. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1468. }
  1469. if item.ChrgitmLv == "2" {
  1470. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1471. }
  1472. if item.ChrgitmLv == "3" {
  1473. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1474. }
  1475. }
  1476. if item.MedChrgitmType == "05" { //治疗费
  1477. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1478. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1479. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1480. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1481. if item.ChrgitmLv == "1" {
  1482. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1483. }
  1484. if item.ChrgitmLv == "2" {
  1485. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1486. }
  1487. if item.ChrgitmLv == "3" {
  1488. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1489. }
  1490. }
  1491. if item.MedChrgitmType == "06" { //手术费
  1492. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1493. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1494. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1495. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1496. if item.ChrgitmLv == "1" {
  1497. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1498. }
  1499. if item.ChrgitmLv == "2" {
  1500. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1501. }
  1502. if item.ChrgitmLv == "3" {
  1503. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1504. }
  1505. }
  1506. if item.MedChrgitmType == "08" { //材料费
  1507. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1508. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1509. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1510. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1511. if item.ChrgitmLv == "1" {
  1512. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1513. }
  1514. if item.ChrgitmLv == "2" {
  1515. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1516. }
  1517. if item.ChrgitmLv == "3" {
  1518. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1519. }
  1520. }
  1521. if item.MedChrgitmType == "09" { //西药费
  1522. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1523. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1524. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1525. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1526. if item.ChrgitmLv == "1" {
  1527. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1528. }
  1529. if item.ChrgitmLv == "2" {
  1530. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1531. }
  1532. if item.ChrgitmLv == "3" {
  1533. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1534. }
  1535. }
  1536. if item.MedChrgitmType == "11" { //中成费
  1537. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1538. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1539. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1540. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1541. if item.ChrgitmLv == "1" {
  1542. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1543. }
  1544. if item.ChrgitmLv == "2" {
  1545. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1546. }
  1547. if item.ChrgitmLv == "3" {
  1548. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1549. }
  1550. }
  1551. if item.MedChrgitmType == "14" { //其他费
  1552. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1553. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1554. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1555. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1556. if item.ChrgitmLv == "1" {
  1557. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1558. }
  1559. if item.ChrgitmLv == "2" {
  1560. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1561. }
  1562. if item.ChrgitmLv == "3" {
  1563. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1564. }
  1565. }
  1566. }
  1567. var iteminfoStructs []service.IteminfoStruct
  1568. if bedCostTotal != 0 {
  1569. iteminfo.MedChrgitm = "01"
  1570. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1571. iteminfo.Amt = bedCostTotal
  1572. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1573. iteminfo.ClabAmt = bed_clab_amt
  1574. iteminfo.OthAmt = bed_other_amt
  1575. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1576. }
  1577. if checkCostTotal != 0 {
  1578. iteminfo.MedChrgitm = "03"
  1579. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1580. iteminfo.Amt = checkCostTotal
  1581. iteminfo.ClaaSumfee = check_claa_sunmfee
  1582. iteminfo.ClabAmt = check_clab_amt
  1583. iteminfo.OthAmt = check_other_amt
  1584. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1585. }
  1586. if laboratoryCostTotal != 0 {
  1587. iteminfo.MedChrgitm = "04"
  1588. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1589. iteminfo.Amt = laboratoryCostTotal
  1590. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1591. iteminfo.ClabAmt = laboratory_clab_amt
  1592. iteminfo.OthAmt = laboratory_other_amt
  1593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1594. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1595. }
  1596. if treatCostTotal != 0 {
  1597. iteminfo.MedChrgitm = "05"
  1598. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1599. iteminfo.Amt = treatCostTotal
  1600. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1601. iteminfo.ClabAmt = treat_clab_amt
  1602. iteminfo.OthAmt = treat_other_amt
  1603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1604. //(struct4101.IteminfoStruct, iteminfo)
  1605. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1606. }
  1607. if operationCostTotal != 0 {
  1608. iteminfo.MedChrgitm = "06"
  1609. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1610. iteminfo.Amt = operationCostTotal
  1611. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1612. iteminfo.ClabAmt = operation_clab_amt
  1613. iteminfo.OthAmt = operation_other_amt
  1614. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1615. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1616. }
  1617. if materialCostTotal != 0 {
  1618. iteminfo.MedChrgitm = "08"
  1619. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1620. iteminfo.Amt = materialCostTotal
  1621. iteminfo.ClaaSumfee = material_claa_sunmfee
  1622. iteminfo.ClabAmt = material_clab_amt
  1623. iteminfo.OthAmt = material_other_amt
  1624. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1626. }
  1627. if westernMedicineCostTotal != 0 {
  1628. iteminfo.MedChrgitm = "09"
  1629. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1630. iteminfo.Amt = westernMedicineCostTotal
  1631. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1632. iteminfo.ClabAmt = westernMedicine_clab_amt
  1633. iteminfo.OthAmt = westernMedicine_other_amt
  1634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1636. }
  1637. if chineseTraditionalMedicineCostTotal != 0 {
  1638. iteminfo.MedChrgitm = "11"
  1639. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1640. iteminfo.Amt = westernMedicineCostTotal
  1641. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1642. iteminfo.ClabAmt = westernMedicine_clab_amt
  1643. iteminfo.OthAmt = westernMedicine_other_amt
  1644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1646. }
  1647. if otherCostTotal != 0 {
  1648. iteminfo.MedChrgitm = "14"
  1649. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1650. iteminfo.Amt = otherCostTotal
  1651. iteminfo.ClaaSumfee = other_claa_sunmfee
  1652. iteminfo.ClabAmt = other_clab_amt
  1653. iteminfo.OthAmt = other_other_amt
  1654. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1655. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1656. }
  1657. struct4101.IteminfoStruct = iteminfoStructs
  1658. struct4101.Ntly = "中国"
  1659. struct4101.AdmCaty = "A03.06"
  1660. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1661. fmt.Println(result)
  1662. var dat map[string]interface{}
  1663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1664. fmt.Println(dat)
  1665. } else {
  1666. fmt.Println(err)
  1667. }
  1668. userJSONBytes, _ := json.Marshal(dat)
  1669. var res ResultSeventeen
  1670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1671. utils.ErrorLog("解析失败:%v", err)
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1673. return
  1674. }
  1675. if res.Infcode != 0 {
  1676. c.ServeSuccessJSON(map[string]interface{}{
  1677. "failed_code": -10,
  1678. "msg": res.ErrMsg,
  1679. })
  1680. return
  1681. } else {
  1682. order.FaPiaoNumber = zero
  1683. order.FaPiaoCode = last_order.FaPiaoCode
  1684. service.UpdateOrder(order)
  1685. hisFundSettleListResult := &models.HisFundSettleListResult{
  1686. Number: res.Output.SetlListId,
  1687. Status: 1,
  1688. Ctime: time.Now().Unix(),
  1689. Mtime: time.Now().Unix(),
  1690. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1691. IsUpload: 1,
  1692. OrderId: order_id,
  1693. }
  1694. service.CreateUploadRecord(hisFundSettleListResult)
  1695. c.ServeSuccessJSON(map[string]interface{}{
  1696. "msg": "上传成功",
  1697. "result": hisFundSettleListResult,
  1698. })
  1699. return
  1700. }
  1701. }
  1702. func (c *HisApiController) GetBatchSettleList() {
  1703. orders, _ := service.GetAllHisOrder(10106)
  1704. for _, item := range orders {
  1705. order_id := item.ID
  1706. order, _ := service.GetHisOrderByIDTwo(order_id)
  1707. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1708. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1709. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1710. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1711. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1712. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1713. if order.ID == 0 {
  1714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1715. return
  1716. }
  1717. if his.BalanceAccountsType == 2 {
  1718. continue
  1719. }
  1720. struct4101 := service.Struct4101{
  1721. PsnNo: order.PsnNo,
  1722. MdtrtId: order.MdtrtId,
  1723. SetlId: order.SetlId,
  1724. PsnName: order.PsnName,
  1725. Gend: order.Gend,
  1726. Brdy: his.Brdy,
  1727. Age: his.Age,
  1728. Naty: order.Naty,
  1729. PatnCertType: "01",
  1730. Certno: order.Certno,
  1731. Prfs: "90",
  1732. ConerName: roles[0].UserName,
  1733. PatnRlts: "99",
  1734. ConerAddr: miConfig.OrgName,
  1735. ConerTel: admin.Mobile,
  1736. HiType: order.Insutype,
  1737. Insuplc: his.InsuplcAdmdvs,
  1738. MaindiagFlag: "1",
  1739. BillCode: order.FaPiaoCode,
  1740. BillNo: order.FaPiaoNumber,
  1741. BizSn: order.Number,
  1742. PsnSelfPay: order.PsnPartAmt,
  1743. PsnOwnPay: order.PsnPartAmt,
  1744. AcctPay: order.AcctPay,
  1745. PsnCashpay: order.PsnCashPay,
  1746. HiPaymtd: "1",
  1747. Hsorg: his.InsuplcAdmdvs,
  1748. HsorgOpter: his.InsuplcAdmdvs,
  1749. MedinsFillPsn: curRoles.UserName,
  1750. MedinsFillDept: depart.Name,
  1751. IptMedType: "2",
  1752. }
  1753. struct4101.SetlBegnDate = order.SetlTime
  1754. struct4101.SetlEndDate = order.SetlTime
  1755. //if order.SettleType == 1 {
  1756. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1757. // dateStr := t.Format("2006-01-02")
  1758. // struct4101.SetlBegnDate = dateStr
  1759. // struct4101.SetlEndDate = dateStr
  1760. //} else {
  1761. // t := time.Unix(int64(order.SettleStartTime), 0)
  1762. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1763. // dateStartStr := t.Format("2006-01-02")
  1764. // dateEndStr := t2.Format("2006-01-02")
  1765. // struct4101.SetlBegnDate = dateStartStr
  1766. // struct4101.SetlEndDate = dateEndStr
  1767. //}
  1768. var rf []CustomFundPay
  1769. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1770. var tempFunPays []service.CustomStruct
  1771. var tempFunPay610100 service.CustomStruct
  1772. for _, item := range rf {
  1773. if item.FundPayType == "610100" {
  1774. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1775. tempFunPay610100.FundPayType = item.FundPayType
  1776. } else {
  1777. var tempFunPay service.CustomStruct
  1778. tempFunPay.FundPayamt = item.FundPayamt
  1779. tempFunPay.FundPayType = item.FundPayType
  1780. tempFunPays = append(tempFunPays, tempFunPay)
  1781. }
  1782. }
  1783. tempFunPays = append(tempFunPays, tempFunPay610100)
  1784. struct4101.CustomStruct = tempFunPays
  1785. var tempDiaginfos []service.DiaginfoStructTwo
  1786. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1787. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1788. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1789. var config []*models.HisXtDiagnoseConfig
  1790. for _, item := range diagnosis_ids {
  1791. id, _ := strconv.ParseInt(item, 10, 64)
  1792. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1793. config = append(config, &diagnosisConfig)
  1794. }
  1795. for index, item := range config {
  1796. if index == 0 {
  1797. var tempDiaginfo service.DiaginfoStructTwo
  1798. tempDiaginfo.DiagCode = item.CountryCode
  1799. tempDiaginfo.DiagName = item.CountryContentName
  1800. tempDiaginfo.DiagType = "1"
  1801. tempDiaginfo.MaindiagFlag = "1"
  1802. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1803. } else {
  1804. var tempDiaginfo service.DiaginfoStructTwo
  1805. tempDiaginfo.DiagCode = item.CountryCode
  1806. tempDiaginfo.DiagName = item.CountryContentName
  1807. tempDiaginfo.DiagType = "2"
  1808. tempDiaginfo.MaindiagFlag = "0"
  1809. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1810. }
  1811. }
  1812. struct4101.Diseinfo = tempDiaginfos
  1813. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1814. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1815. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1816. tempOpspdiseinfo2.OprnOprtCode = ""
  1817. tempOpspdiseinfo2.OprnOprtName = ""
  1818. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1819. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1820. var iteminfo service.IteminfoStruct
  1821. var bedCostTotal float64 = 0 //床位总费
  1822. var bedCostSelfTotal float64 = 0 //床位自费
  1823. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1824. var examineCostTotal float64 = 0 //诊查总费
  1825. var examineCostSelfTotal float64 = 0 //诊查自费
  1826. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1827. var nursingCostTotal float64 = 0 //护理总费
  1828. var nursingCostSelfTotal float64 = 0 //护理自费
  1829. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1830. var chineseMedicineCostTotal float64 = 0 //中成药
  1831. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1832. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1833. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1834. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1835. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1836. var registerCostTotal float64 = 0 //一般诊疗费
  1837. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1838. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1839. var operationCostTotal float64 = 0 //手术费
  1840. var operationCostSelfTotal float64 = 0 //手术费
  1841. var operationCostPartSelfTotal float64 = 0 //手术费
  1842. var otherCostTotal float64 = 0 //其他费用
  1843. var otherCostSelfTotal float64 = 0 //其他费用
  1844. var otherCostPartSelfTotal float64 = 0 //其他费用
  1845. var materialCostTotal float64 = 0 //材料费
  1846. var materialCostSelfTotal float64 = 0 //材料费
  1847. var materialCostPartSelfTotal float64 = 0 //材料费
  1848. var westernMedicineCostTotal float64 = 0 //西药费
  1849. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1850. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1851. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1852. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1853. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1854. var checkCostTotal float64 = 0 //检查费
  1855. var checkCostSelfTotal float64 = 0 //检查费
  1856. var checkCostPartSelfTotal float64 = 0 //检查费
  1857. var laboratoryCostTotal float64 = 0 //化验费
  1858. var laboratoryCostSelfTotal float64 = 0 //化验费
  1859. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1860. var treatCostTotal float64 = 0 //治疗费用
  1861. var treatCostSelfTotal float64 = 0 //治疗费用
  1862. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1863. decimal.DivisionPrecision = 2
  1864. var bed_fulamt_ownpay_amt float64 = 0
  1865. var examine_fulamt_ownpay_amt float64 = 0
  1866. var nursing_fulamt_ownpay_amt float64 = 0
  1867. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1868. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1869. var register_fulamt_ownpay_amt float64 = 0
  1870. var operation_fulamt_ownpay_amt float64 = 0
  1871. var other_fulamt_ownpay_amt float64 = 0
  1872. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1873. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1874. var check_fulamt_ownpay_amt float64 = 0
  1875. var material_fulamt_ownpay_amt float64 = 0
  1876. var laboratory_fulamt_ownpay_amt float64 = 0
  1877. var treat_fulamt_ownpay_amt float64 = 0
  1878. var bed_claa_sunmfee float64 = 0
  1879. var bed_clab_amt float64 = 0
  1880. var bed_other_amt float64 = 0
  1881. var examine_claa_sunmfee float64 = 0
  1882. var examine_clab_amt float64 = 0
  1883. var examine_other_amt float64 = 0
  1884. var nursing_claa_sunmfee float64 = 0
  1885. var nursing_clab_amt float64 = 0
  1886. var nursing_other_amt float64 = 0
  1887. var chinese_medicine_claa_sunmfee float64 = 0
  1888. var chinese_medicine_clab_amt float64 = 0
  1889. var chinese_medicine_other_amt float64 = 0
  1890. var commonly_treatment_claa_sunmfee float64 = 0
  1891. var commonly_treatment_clab_amt float64 = 0
  1892. var commonly_treatment_other_amt float64 = 0
  1893. var operation_claa_sunmfee float64 = 0
  1894. var operation_clab_amt float64 = 0
  1895. var operation_other_amt float64 = 0
  1896. var other_claa_sunmfee float64 = 0
  1897. var other_clab_amt float64 = 0
  1898. var other_other_amt float64 = 0
  1899. var westernMedicine_claa_sunmfee float64 = 0
  1900. var westernMedicine_clab_amt float64 = 0
  1901. var westernMedicine_other_amt float64 = 0
  1902. var chineseTraditional_claa_sunmfee float64 = 0
  1903. var chineseTraditional_clab_amt float64 = 0
  1904. var chineseTraditional_other_amt float64 = 0
  1905. var check_claa_sunmfee float64 = 0
  1906. var check_clab_amt float64 = 0
  1907. var check_other_amt float64 = 0
  1908. var material_claa_sunmfee float64 = 0
  1909. var material_clab_amt float64 = 0
  1910. var material_other_amt float64 = 0
  1911. var laboratory_claa_sunmfee float64 = 0
  1912. var laboratory_clab_amt float64 = 0
  1913. var laboratory_other_amt float64 = 0
  1914. var treat_claa_sunmfee float64 = 0
  1915. var treat_clab_amt float64 = 0
  1916. var treat_other_amt float64 = 0
  1917. var register_claa_sunmfee float64 = 0
  1918. var register_clab_amt float64 = 0
  1919. var register_other_amt float64 = 0
  1920. for _, item := range order.HisOrderInfo {
  1921. if item.MedChrgitmType == "01" { //床位费
  1922. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1923. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1924. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1925. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1926. if item.ChrgitmLv == "1" {
  1927. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1928. }
  1929. if item.ChrgitmLv == "2" {
  1930. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1931. }
  1932. if item.ChrgitmLv == "3" {
  1933. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1934. }
  1935. }
  1936. if item.MedChrgitmType == "02" { //诊查
  1937. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1938. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1939. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1940. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1941. if item.ChrgitmLv == "1" {
  1942. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1943. }
  1944. if item.ChrgitmLv == "2" {
  1945. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1946. }
  1947. if item.ChrgitmLv == "3" {
  1948. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1949. }
  1950. }
  1951. if item.MedChrgitmType == "03" { //检查费
  1952. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1953. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1954. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1955. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1956. if item.ChrgitmLv == "1" {
  1957. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1958. }
  1959. if item.ChrgitmLv == "2" {
  1960. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1961. }
  1962. if item.ChrgitmLv == "3" {
  1963. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1964. }
  1965. }
  1966. if item.MedChrgitmType == "04" { //化验费
  1967. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1968. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1969. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1970. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1971. if item.ChrgitmLv == "1" {
  1972. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1973. }
  1974. if item.ChrgitmLv == "2" {
  1975. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1976. }
  1977. if item.ChrgitmLv == "3" {
  1978. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1979. }
  1980. }
  1981. if item.MedChrgitmType == "05" { //治疗费
  1982. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1983. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1984. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1985. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1986. if item.ChrgitmLv == "1" {
  1987. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1988. }
  1989. if item.ChrgitmLv == "2" {
  1990. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1991. }
  1992. if item.ChrgitmLv == "3" {
  1993. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1994. }
  1995. }
  1996. if item.MedChrgitmType == "06" { //手术费
  1997. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1998. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1999. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2000. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2001. if item.ChrgitmLv == "1" {
  2002. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2003. }
  2004. if item.ChrgitmLv == "2" {
  2005. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2006. }
  2007. if item.ChrgitmLv == "3" {
  2008. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2009. }
  2010. }
  2011. if item.MedChrgitmType == "07" { //手术费
  2012. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2013. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2014. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2015. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2016. if item.ChrgitmLv == "1" {
  2017. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2018. }
  2019. if item.ChrgitmLv == "2" {
  2020. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2021. }
  2022. if item.ChrgitmLv == "3" {
  2023. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2024. }
  2025. }
  2026. if item.MedChrgitmType == "08" { //材料费
  2027. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2028. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2029. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2030. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2031. if item.ChrgitmLv == "1" {
  2032. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2033. }
  2034. if item.ChrgitmLv == "2" {
  2035. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2036. }
  2037. if item.ChrgitmLv == "3" {
  2038. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2039. }
  2040. }
  2041. if item.MedChrgitmType == "09" { //西药费
  2042. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2043. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2044. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2045. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2046. if item.ChrgitmLv == "1" {
  2047. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2048. }
  2049. if item.ChrgitmLv == "2" {
  2050. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2051. }
  2052. if item.ChrgitmLv == "3" {
  2053. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2054. }
  2055. }
  2056. if item.MedChrgitmType == "10" { //中药饮片
  2057. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2058. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2059. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2060. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2061. if item.ChrgitmLv == "1" {
  2062. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "2" {
  2065. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2066. }
  2067. if item.ChrgitmLv == "3" {
  2068. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2069. }
  2070. }
  2071. if item.MedChrgitmType == "11" { //中成费
  2072. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2073. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2074. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2075. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2076. if item.ChrgitmLv == "1" {
  2077. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "2" {
  2080. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2081. }
  2082. if item.ChrgitmLv == "3" {
  2083. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2084. }
  2085. }
  2086. if item.MedChrgitmType == "12" { //中成费
  2087. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2088. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2089. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2090. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2091. if item.ChrgitmLv == "1" {
  2092. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "2" {
  2095. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2096. }
  2097. if item.ChrgitmLv == "3" {
  2098. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2099. }
  2100. }
  2101. if item.MedChrgitmType == "13" { //中成费
  2102. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2103. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2104. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2105. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2106. if item.ChrgitmLv == "1" {
  2107. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "2" {
  2110. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2111. }
  2112. if item.ChrgitmLv == "3" {
  2113. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2114. }
  2115. }
  2116. if item.MedChrgitmType == "14" { //其他费
  2117. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2118. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2119. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2120. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2121. if item.ChrgitmLv == "1" {
  2122. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2123. }
  2124. if item.ChrgitmLv == "2" {
  2125. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2126. }
  2127. if item.ChrgitmLv == "3" {
  2128. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2129. }
  2130. }
  2131. }
  2132. var iteminfoStructs []service.IteminfoStruct
  2133. if bedCostTotal != 0 {
  2134. iteminfo.MedChrgitm = "01"
  2135. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2136. iteminfo.Amt = bedCostTotal
  2137. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2138. iteminfo.ClabAmt = bed_clab_amt
  2139. iteminfo.OthAmt = bed_other_amt
  2140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2141. }
  2142. if examineCostTotal != 0 {
  2143. iteminfo.MedChrgitm = "02"
  2144. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2145. iteminfo.Amt = examineCostTotal
  2146. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2147. iteminfo.ClabAmt = examine_clab_amt
  2148. iteminfo.OthAmt = examine_other_amt
  2149. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2151. }
  2152. if checkCostTotal != 0 {
  2153. iteminfo.MedChrgitm = "03"
  2154. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2155. iteminfo.Amt = checkCostTotal
  2156. iteminfo.ClaaSumfee = check_claa_sunmfee
  2157. iteminfo.ClabAmt = check_clab_amt
  2158. iteminfo.OthAmt = check_other_amt
  2159. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2160. }
  2161. if laboratoryCostTotal != 0 {
  2162. iteminfo.MedChrgitm = "04"
  2163. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2164. iteminfo.Amt = laboratoryCostTotal
  2165. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2166. iteminfo.ClabAmt = laboratory_clab_amt
  2167. iteminfo.OthAmt = laboratory_other_amt
  2168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2169. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2170. }
  2171. if treatCostTotal != 0 {
  2172. iteminfo.MedChrgitm = "05"
  2173. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2174. iteminfo.Amt = treatCostTotal
  2175. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2176. iteminfo.ClabAmt = treat_clab_amt
  2177. iteminfo.OthAmt = treat_other_amt
  2178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2179. //(struct4101.IteminfoStruct, iteminfo)
  2180. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2181. }
  2182. if operationCostTotal != 0 {
  2183. iteminfo.MedChrgitm = "06"
  2184. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2185. iteminfo.Amt = operationCostTotal
  2186. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2187. iteminfo.ClabAmt = operation_clab_amt
  2188. iteminfo.OthAmt = operation_other_amt
  2189. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2191. }
  2192. if nursingCostTotal != 0 {
  2193. iteminfo.MedChrgitm = "07"
  2194. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2195. iteminfo.Amt = nursingCostTotal
  2196. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2197. iteminfo.ClabAmt = nursing_clab_amt
  2198. iteminfo.OthAmt = nursing_other_amt
  2199. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2200. }
  2201. if materialCostTotal != 0 {
  2202. iteminfo.MedChrgitm = "08"
  2203. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2204. iteminfo.Amt = materialCostTotal
  2205. iteminfo.ClaaSumfee = material_claa_sunmfee
  2206. iteminfo.ClabAmt = material_clab_amt
  2207. iteminfo.OthAmt = material_other_amt
  2208. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2210. }
  2211. if westernMedicineCostTotal != 0 {
  2212. iteminfo.MedChrgitm = "09"
  2213. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2214. iteminfo.Amt = westernMedicineCostTotal
  2215. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2216. iteminfo.ClabAmt = westernMedicine_clab_amt
  2217. iteminfo.OthAmt = westernMedicine_other_amt
  2218. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2219. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2220. }
  2221. if chineseMedicineCostTotal != 0 {
  2222. iteminfo.MedChrgitm = "10"
  2223. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2224. iteminfo.Amt = chineseMedicineCostTotal
  2225. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2226. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2227. iteminfo.OthAmt = chinese_medicine_other_amt
  2228. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2229. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2230. }
  2231. if chineseTraditionalMedicineCostTotal != 0 {
  2232. iteminfo.MedChrgitm = "11"
  2233. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2234. iteminfo.Amt = westernMedicineCostTotal
  2235. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2236. iteminfo.ClabAmt = westernMedicine_clab_amt
  2237. iteminfo.OthAmt = westernMedicine_other_amt
  2238. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2239. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2240. }
  2241. if commonlyTreatmentCostTotal != 0 {
  2242. iteminfo.MedChrgitm = "12"
  2243. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2244. iteminfo.Amt = commonlyTreatmentCostTotal
  2245. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2246. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2247. iteminfo.OthAmt = commonly_treatment_other_amt
  2248. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2250. }
  2251. if registerCostTotal != 0 {
  2252. iteminfo.MedChrgitm = "13"
  2253. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2254. iteminfo.Amt = registerCostTotal
  2255. iteminfo.ClaaSumfee = register_claa_sunmfee
  2256. iteminfo.ClabAmt = register_clab_amt
  2257. iteminfo.OthAmt = register_other_amt
  2258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2260. }
  2261. if otherCostTotal != 0 {
  2262. iteminfo.MedChrgitm = "14"
  2263. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2264. iteminfo.Amt = otherCostTotal
  2265. iteminfo.ClaaSumfee = other_claa_sunmfee
  2266. iteminfo.ClabAmt = other_clab_amt
  2267. iteminfo.OthAmt = other_other_amt
  2268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2270. }
  2271. struct4101.IteminfoStruct = iteminfoStructs
  2272. struct4101.Ntly = "中国"
  2273. struct4101.AdmCaty = "A03.06"
  2274. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2275. fmt.Println(result)
  2276. var dat map[string]interface{}
  2277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2278. fmt.Println(dat)
  2279. } else {
  2280. fmt.Println(err)
  2281. }
  2282. userJSONBytes, _ := json.Marshal(dat)
  2283. var res ResultSeventeen
  2284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2285. utils.ErrorLog("解析失败:%v", err)
  2286. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2287. adminUser := c.GetAdminUserInfo()
  2288. errlog := &models.HisOrderError{
  2289. UserOrgId: adminUser.CurrentOrgId,
  2290. Ctime: time.Now().Unix(),
  2291. Mtime: time.Now().Unix(),
  2292. ErrMsg: res.ErrMsg + "解析失败",
  2293. Status: 1,
  2294. PatientId: order_id,
  2295. Stage: 10106,
  2296. }
  2297. service.CreateErrMsgLog(errlog)
  2298. continue
  2299. }
  2300. if res.Infcode != 0 {
  2301. adminUser := c.GetAdminUserInfo()
  2302. errlog := &models.HisOrderError{
  2303. UserOrgId: adminUser.CurrentOrgId,
  2304. Ctime: time.Now().Unix(),
  2305. Mtime: time.Now().Unix(),
  2306. ErrMsg: res.ErrMsg,
  2307. Status: 1,
  2308. PatientId: order_id,
  2309. Stage: 10106,
  2310. }
  2311. service.CreateErrMsgLog(errlog)
  2312. continue
  2313. } else {
  2314. hisFundSettleListResult := &models.HisFundSettleListResult{
  2315. Number: res.Output.SetlListId,
  2316. Status: 1,
  2317. Ctime: time.Now().Unix(),
  2318. Mtime: time.Now().Unix(),
  2319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2320. IsUpload: 1,
  2321. OrderId: order_id,
  2322. }
  2323. service.CreateUploadRecord(hisFundSettleListResult)
  2324. continue
  2325. }
  2326. }
  2327. }
  2328. func (c *HisApiController) GetOrgInfo() {
  2329. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2330. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2331. }
  2332. func (c *HisApiController) GetHisPatientInfo() {
  2333. medical_insurance_card := c.GetString("medical_insurance_card")
  2334. id_card_type, _ := c.GetInt64("id_card_type")
  2335. id_card := c.GetString("id_card")
  2336. adminInfo := c.GetAdminUserInfo()
  2337. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2338. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2339. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2340. IdCardNo := ""
  2341. if id_card_type == 1 {
  2342. IdCardNo = medical_insurance_card
  2343. } else if id_card_type == 2 {
  2344. IdCardNo = id_card
  2345. }
  2346. if config.IsOpen == 1 {
  2347. 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
  2348. resp, requestErr := http.Get(api)
  2349. if requestErr != nil {
  2350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2351. return
  2352. }
  2353. defer resp.Body.Close()
  2354. body, ioErr := ioutil.ReadAll(resp.Body)
  2355. if ioErr != nil {
  2356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. var respJSON map[string]interface{}
  2361. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2364. return
  2365. }
  2366. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2367. userJSONBytes, _ := json.Marshal(userJSON)
  2368. var res ResultTwo
  2369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2370. utils.ErrorLog("解析失败:%v", err)
  2371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2372. return
  2373. }
  2374. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2375. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2376. infoStr := string(Iinfos)
  2377. idetinfoStr := string(Idetinfos)
  2378. if res.Infcode == 0 {
  2379. his := models.VMHisPatient{
  2380. Status: 1,
  2381. Ctime: time.Now().Unix(),
  2382. Mtime: time.Now().Unix(),
  2383. PsnNo: res.Output.Baseinfo.PsnNo,
  2384. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2385. Certno: res.Output.Baseinfo.Certno,
  2386. PsnName: res.Output.Baseinfo.PsnName,
  2387. Gend: res.Output.Baseinfo.Gend,
  2388. Naty: res.Output.Baseinfo.Naty,
  2389. Brdy: res.Output.Baseinfo.Brdy,
  2390. Age: res.Output.Baseinfo.Age,
  2391. Iinfo: infoStr,
  2392. Idetinfo: idetinfoStr,
  2393. UserOrgId: adminInfo.CurrentOrgId,
  2394. IsReturn: 1,
  2395. IdCardType: id_card_type,
  2396. }
  2397. c.ServeSuccessJSON(map[string]interface{}{
  2398. "info": his,
  2399. })
  2400. } else {
  2401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2402. return
  2403. }
  2404. }
  2405. }
  2406. //func GetBasBaseInfo() (jsonStr string, err error) {
  2407. //
  2408. // handle := syscall.NewLazyDLL("SSCard.dll")
  2409. // add := handle.NewProc("ReadCardBas")
  2410. // str := make([]byte, 1024)
  2411. // str1 := make([]byte, 1024)
  2412. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2413. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2414. //
  2415. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2416. //
  2417. // fmt.Println("> Add(4,5)的结果为:", ret)
  2418. // handle.Release()
  2419. //
  2420. // return "", nil
  2421. //
  2422. //}
  2423. //func GetQRBaseInfo() (jsonStr string, err error) {
  2424. // handle := syscall.LoadDLL("SSCard.dll")
  2425. // ReadCardBas := handle.FindProc("GetQRBase")
  2426. //
  2427. // str := make([]byte, 256)
  2428. // str1 := make([]byte, 256)
  2429. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2430. //
  2431. // fmt.Println(string(str))
  2432. // fmt.Println(r)
  2433. // return string(str), nil
  2434. //}
  2435. //func CardInit() int {
  2436. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2437. // add := DllTestDef.MustFindProc("Init")
  2438. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2439. // if err != nil {
  2440. // fmt.Println("SSCard的运算结果为:", ret)
  2441. // }
  2442. // result := int(ret)
  2443. // return result
  2444. //}
  2445. //func CardInit() int {
  2446. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2447. // if err != nil {
  2448. // fmt.Println("SSCard的运算结果为:", ret)
  2449. // }
  2450. // fmt.Println(err)
  2451. // result := int(ret)
  2452. // return result
  2453. //}
  2454. func IntPtr(n int) uintptr {
  2455. return uintptr(n)
  2456. }
  2457. func StrPtr(s string) uintptr {
  2458. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2459. }
  2460. type Result2001 struct {
  2461. Cainfo interface{} `json:"cainfo"`
  2462. ErrMsg string `json:"err_msg"`
  2463. InfRefmsgid string `json:"inf_refmsgid"`
  2464. Infcode int64 `json:"infcode"`
  2465. Output struct {
  2466. Trtinfo struct {
  2467. PsnNo string `json:"psn_no"`
  2468. TrtChkType string `json:"trt_chk_type"`
  2469. FundPayType string `json:"fund_pay_type"`
  2470. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2471. Begndate string `json:"begndate"`
  2472. Enddate string `json:"enddate"`
  2473. TrtChkRslt string `json:"trt_chk_rslt"`
  2474. } `json:"trtinfo"`
  2475. } `json:"output"`
  2476. RefmsgTime string `json:"refmsg_time"`
  2477. RespondTime string `json:"respond_time"`
  2478. Signtype interface{} `json:"signtype"`
  2479. WarnMsg interface{} `json:"warn_msg"`
  2480. }
  2481. type Result2001Org10265 struct {
  2482. Cainfo interface{} `json:"cainfo"`
  2483. ErrMsg string `json:"err_msg"`
  2484. InfRefmsgid string `json:"inf_refmsgid"`
  2485. Infcode string `json:"infcode"`
  2486. Output struct {
  2487. Trtinfo struct {
  2488. PsnNo string `json:"psn_no"`
  2489. TrtChkType string `json:"trt_chk_type"`
  2490. FundPayType string `json:"fund_pay_type"`
  2491. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2492. Begndate string `json:"begndate"`
  2493. Enddate string `json:"enddate"`
  2494. TrtChkRslt string `json:"trt_chk_rslt"`
  2495. } `json:"trtinfo"`
  2496. } `json:"output"`
  2497. RefmsgTime string `json:"refmsg_time"`
  2498. RespondTime string `json:"respond_time"`
  2499. Signtype interface{} `json:"signtype"`
  2500. WarnMsg interface{} `json:"warn_msg"`
  2501. }
  2502. type ResultTwo struct {
  2503. ErrMsg string `json:"err_msg"`
  2504. InfRefmsgid string `json:"inf_refmsgid"`
  2505. Infcode int64 `json:"infcode"`
  2506. Output struct {
  2507. Baseinfo struct {
  2508. Age float64 `json:"age"`
  2509. Brdy string `json:"brdy"`
  2510. Certno string `json:"certno"`
  2511. Gend string `json:"gend"`
  2512. Naty string `json:"naty"`
  2513. PsnCertType string `json:"psn_cert_type"`
  2514. PsnName string `json:"psn_name"`
  2515. PsnNo string `json:"psn_no"`
  2516. } `json:"baseinfo"`
  2517. Idetinfo []interface{} `json:"idetinfo"`
  2518. Iinfo []struct {
  2519. Balc float64 `json:"balc"`
  2520. CvlservFlag string `json:"cvlserv_flag"`
  2521. EmpName string `json:"emp_name"`
  2522. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2523. Insutype string `json:"insutype"`
  2524. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2525. PausInsuDate string `json:"paus_insu_date"`
  2526. PsnInsuDate string `json:"psn_insu_date"`
  2527. PsnInsuStas string `json:"psn_insu_stas"`
  2528. PsnType string `json:"psn_type"`
  2529. } `json:"insuinfo"`
  2530. } `json:"output"`
  2531. RefmsgTime string `json:"refmsg_time"`
  2532. RespondTime string `json:"respond_time"`
  2533. Signtype interface{} `json:"signtype"`
  2534. WarnInfo interface{} `json:"warn_info"`
  2535. }
  2536. type ResultTwo10265 struct {
  2537. ErrMsg string `json:"err_msg"`
  2538. InfRefmsgid string `json:"inf_refmsgid"`
  2539. Infcode string `json:"infcode"`
  2540. Output struct {
  2541. Baseinfo struct {
  2542. Age float64 `json:"age"`
  2543. Brdy string `json:"brdy"`
  2544. Certno string `json:"certno"`
  2545. Gend string `json:"gend"`
  2546. Naty string `json:"naty"`
  2547. PsnCertType string `json:"psn_cert_type"`
  2548. PsnName string `json:"psn_name"`
  2549. PsnNo string `json:"psn_no"`
  2550. } `json:"baseinfo"`
  2551. Idetinfo []interface{} `json:"idetinfo"`
  2552. Iinfo []struct {
  2553. Balc float64 `json:"balc"`
  2554. CvlservFlag string `json:"cvlserv_flag"`
  2555. EmpName string `json:"emp_name"`
  2556. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2557. Insutype string `json:"insutype"`
  2558. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2559. PausInsuDate string `json:"paus_insu_date"`
  2560. PsnInsuDate string `json:"psn_insu_date"`
  2561. PsnInsuStas string `json:"psn_insu_stas"`
  2562. PsnType string `json:"psn_type"`
  2563. } `json:"insuinfo"`
  2564. } `json:"output"`
  2565. RefmsgTime string `json:"refmsg_time"`
  2566. RespondTime string `json:"respond_time"`
  2567. Signtype interface{} `json:"signtype"`
  2568. WarnInfo interface{} `json:"warn_info"`
  2569. }
  2570. type ResultThree struct {
  2571. Cainfo interface{} `json:"cainfo"`
  2572. ErrMsg string `json:"err_msg"`
  2573. InfRefmsgid string `json:"inf_refmsgid"`
  2574. Infcode int64 `json:"infcode"`
  2575. Output struct {
  2576. Data struct {
  2577. IptOtpNo string `json:"ipt_otp_no"`
  2578. MdtrtID string `json:"mdtrt_id"`
  2579. PsnNo string `json:"psn_no"`
  2580. } `json:"data"`
  2581. } `json:"output"`
  2582. RefmsgTime string `json:"refmsg_time"`
  2583. RespondTime string `json:"respond_time"`
  2584. Signtype interface{} `json:"signtype"`
  2585. WarnMsg interface{} `json:"warn_msg"`
  2586. }
  2587. type ResultThree10265 struct {
  2588. Cainfo interface{} `json:"cainfo"`
  2589. ErrMsg string `json:"err_msg"`
  2590. InfRefmsgid string `json:"inf_refmsgid"`
  2591. Infcode string `json:"infcode"`
  2592. Output struct {
  2593. Data struct {
  2594. IptOtpNo string `json:"ipt_otp_no"`
  2595. MdtrtID string `json:"mdtrt_id"`
  2596. PsnNo string `json:"psn_no"`
  2597. } `json:"data"`
  2598. } `json:"output"`
  2599. RefmsgTime string `json:"refmsg_time"`
  2600. RespondTime string `json:"respond_time"`
  2601. Signtype interface{} `json:"signtype"`
  2602. WarnMsg interface{} `json:"warn_msg"`
  2603. }
  2604. type ResultFour struct {
  2605. Cainfo string `json:"cainfo"`
  2606. ErrMsg string `json:"err_msg"`
  2607. InfRefmsgid string `json:"inf_refmsgid"`
  2608. Infcode int64 `json:"infcode"`
  2609. Output struct {
  2610. Result []struct {
  2611. BasMednFlag string `json:"bas_medn_flag"`
  2612. ChldMedcFlag string `json:"chld_medc_flag"`
  2613. ChrgitmLv string `json:"chrgitm_lv"`
  2614. Cnt float64 `json:"cnt"`
  2615. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2616. DrtReimFlag string `json:"drt_reim_flag"`
  2617. FeedetlSn string `json:"feedetl_sn"`
  2618. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2619. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2620. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2621. ListSpItemFlag string `json:"list_sp_item_flag"`
  2622. LmtUsedFlag string `json:"lmt_used_flag"`
  2623. MedChrgitmType string `json:"med_chrgitm_type"`
  2624. Memo string `json:"memo"`
  2625. OverlmtAmt float64 `json:"overlmt_amt"`
  2626. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2627. Pric float64 `json:"pric"`
  2628. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2629. SelfpayProp float64 `json:"selfpay_prop"`
  2630. } `json:"result"`
  2631. } `json:"output"`
  2632. RefmsgTime string `json:"refmsg_time"`
  2633. RespondTime string `json:"respond_time"`
  2634. Signtype string `json:"signtype"`
  2635. WarnMsg string `json:"warn_msg"`
  2636. }
  2637. type ResultFour10265 struct {
  2638. Cainfo string `json:"cainfo"`
  2639. ErrMsg string `json:"err_msg"`
  2640. InfRefmsgid string `json:"inf_refmsgid"`
  2641. Infcode string `json:"infcode"`
  2642. Output struct {
  2643. Result []struct {
  2644. BasMednFlag string `json:"bas_medn_flag"`
  2645. ChldMedcFlag string `json:"chld_medc_flag"`
  2646. ChrgitmLv string `json:"chrgitm_lv"`
  2647. Cnt float64 `json:"cnt"`
  2648. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2649. DrtReimFlag string `json:"drt_reim_flag"`
  2650. FeedetlSn string `json:"feedetl_sn"`
  2651. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2652. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2653. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2654. ListSpItemFlag string `json:"list_sp_item_flag"`
  2655. LmtUsedFlag string `json:"lmt_used_flag"`
  2656. MedChrgitmType string `json:"med_chrgitm_type"`
  2657. Memo string `json:"memo"`
  2658. OverlmtAmt float64 `json:"overlmt_amt"`
  2659. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2660. Pric float64 `json:"pric"`
  2661. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2662. SelfpayProp float64 `json:"selfpay_prop"`
  2663. } `json:"result"`
  2664. } `json:"output"`
  2665. RefmsgTime string `json:"refmsg_time"`
  2666. RespondTime string `json:"respond_time"`
  2667. Signtype string `json:"signtype"`
  2668. WarnMsg string `json:"warn_msg"`
  2669. }
  2670. type ResultFive struct {
  2671. Balc float64 `json:"balc"`
  2672. CvlservFlag string `json:"cvlserv_flag"`
  2673. EmpName string `json:"emp_name"`
  2674. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2675. Insutype string `json:"insutype"`
  2676. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2677. PausInsuDate string `json:"paus_insu_date"`
  2678. PsnInsuDate string `json:"psn_insu_date"`
  2679. PsnInsuStas string `json:"psn_insu_stas"`
  2680. PsnType string `json:"psn_type"`
  2681. }
  2682. type ResultSix struct {
  2683. Cainfo interface{} `json:"cainfo"`
  2684. ErrMsg string `json:"err_msg"`
  2685. InfRefmsgid string `json:"inf_refmsgid"`
  2686. Infcode int64 `json:"infcode"`
  2687. Output struct {
  2688. } `json:"output"`
  2689. RefmsgTime string `json:"refmsg_time"`
  2690. RespondTime string `json:"respond_time"`
  2691. Signtype interface{} `json:"signtype"`
  2692. WarnMsg interface{} `json:"warn_msg"`
  2693. }
  2694. type ResultSix10265 struct {
  2695. Cainfo interface{} `json:"cainfo"`
  2696. ErrMsg string `json:"err_msg"`
  2697. InfRefmsgid string `json:"inf_refmsgid"`
  2698. Infcode string `json:"infcode"`
  2699. Output struct {
  2700. } `json:"output"`
  2701. RefmsgTime string `json:"refmsg_time"`
  2702. RespondTime string `json:"respond_time"`
  2703. Signtype interface{} `json:"signtype"`
  2704. WarnMsg interface{} `json:"warn_msg"`
  2705. }
  2706. type ResultSeven struct {
  2707. Cainfo string `json:"cainfo"`
  2708. ErrMsg string `json:"err_msg"`
  2709. InfRefmsgid string `json:"inf_refmsgid"`
  2710. Infcode int64 `json:"infcode"`
  2711. Output struct {
  2712. Setldetail []interface{} `json:"setldetail"`
  2713. Setlinfo struct {
  2714. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2715. AcctPay float64 `json:"acct_pay"`
  2716. ActPayDedc float64 `json:"act_pay_dedc"`
  2717. Age float64 `json:"age"`
  2718. Balc float64 `json:"balc"`
  2719. Brdy string `json:"brdy"`
  2720. Certno string `json:"certno"`
  2721. ClrOptins string `json:"clr_optins"`
  2722. ClrType string `json:"clr_type"`
  2723. ClrWay string `json:"clr_way"`
  2724. CvlservFlag string `json:"cvlserv_flag"`
  2725. CvlservPay float64 `json:"cvlserv_pay"`
  2726. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2727. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2728. Gend string `json:"gend"`
  2729. HifesPay float64 `json:"hifes_pay"`
  2730. HifmiPay float64 `json:"hifmi_pay"`
  2731. HifpPay float64 `json:"hifp_pay"`
  2732. HospPartAmt float64 `json:"hosp_part_amt"`
  2733. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2734. Insutype string `json:"insutype"`
  2735. MafPay float64 `json:"maf_pay"`
  2736. MdtrtCertType string `json:"mdtrt_cert_type"`
  2737. HifobPay float64 `json:"hifob_pay"`
  2738. MdtrtID string `json:"mdtrt_id"`
  2739. MedType string `json:"med_type"`
  2740. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2741. MedinsSetlID string `json:"medins_setl_id"`
  2742. Naty string `json:"naty"`
  2743. OthPay float64 `json:"oth_pay"`
  2744. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2745. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2746. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2747. PsnCashPay float64 `json:"psn_cash_pay"`
  2748. PsnCertType string `json:"psn_cert_type"`
  2749. PsnName string `json:"psn_name"`
  2750. PsnNo string `json:"psn_no"`
  2751. PsnPartAmt float64 `json:"psn_part_amt"`
  2752. PsnType string `json:"psn_type"`
  2753. SetlID string `json:"setl_id"`
  2754. SetlTime string `json:"setl_time"`
  2755. } `json:"setlinfo"`
  2756. } `json:"output"`
  2757. RefmsgTime string `json:"refmsg_time"`
  2758. RespondTime string `json:"respond_time"`
  2759. Signtype interface{} `json:"signtype"`
  2760. WarnMsg interface{} `json:"warn_msg"`
  2761. }
  2762. type ResultSeven10265 struct {
  2763. Cainfo string `json:"cainfo"`
  2764. ErrMsg string `json:"err_msg"`
  2765. InfRefmsgid string `json:"inf_refmsgid"`
  2766. Infcode string `json:"infcode"`
  2767. Output struct {
  2768. Setldetail []interface{} `json:"setldetail"`
  2769. Setlinfo struct {
  2770. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2771. AcctPay float64 `json:"acct_pay"`
  2772. ActPayDedc float64 `json:"act_pay_dedc"`
  2773. Age float64 `json:"age"`
  2774. Balc float64 `json:"balc"`
  2775. Brdy string `json:"brdy"`
  2776. Certno string `json:"certno"`
  2777. ClrOptins string `json:"clr_optins"`
  2778. ClrType string `json:"clr_type"`
  2779. ClrWay string `json:"clr_way"`
  2780. CvlservFlag string `json:"cvlserv_flag"`
  2781. CvlservPay float64 `json:"cvlserv_pay"`
  2782. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2783. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2784. Gend string `json:"gend"`
  2785. HifesPay float64 `json:"hifes_pay"`
  2786. HifmiPay float64 `json:"hifmi_pay"`
  2787. HifpPay float64 `json:"hifp_pay"`
  2788. HospPartAmt float64 `json:"hosp_part_amt"`
  2789. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2790. Insutype string `json:"insutype"`
  2791. MafPay float64 `json:"maf_pay"`
  2792. MdtrtCertType string `json:"mdtrt_cert_type"`
  2793. HifobPay float64 `json:"hifob_pay"`
  2794. MdtrtID string `json:"mdtrt_id"`
  2795. MedType string `json:"med_type"`
  2796. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2797. MedinsSetlID string `json:"medins_setl_id"`
  2798. Naty string `json:"naty"`
  2799. OthPay float64 `json:"oth_pay"`
  2800. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2801. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2802. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2803. PsnCashPay float64 `json:"psn_cash_pay"`
  2804. PsnCertType string `json:"psn_cert_type"`
  2805. PsnName string `json:"psn_name"`
  2806. PsnNo string `json:"psn_no"`
  2807. PsnPartAmt float64 `json:"psn_part_amt"`
  2808. PsnType string `json:"psn_type"`
  2809. SetlID string `json:"setl_id"`
  2810. SetlTime string `json:"setl_time"`
  2811. } `json:"setlinfo"`
  2812. } `json:"output"`
  2813. RefmsgTime string `json:"refmsg_time"`
  2814. RespondTime string `json:"respond_time"`
  2815. Signtype interface{} `json:"signtype"`
  2816. WarnMsg interface{} `json:"warn_msg"`
  2817. }
  2818. type ResultEight struct {
  2819. Cainfo string `json:"cainfo"`
  2820. ErrMsg string `json:"err_msg"`
  2821. InfRefmsgid string `json:"inf_refmsgid"`
  2822. Infcode int64 `json:"infcode"`
  2823. Output struct {
  2824. Stmtinfo struct {
  2825. SetlOptins string `json:"setl_optins"`
  2826. StmtRslt string `json:"stmt_rslt"`
  2827. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2828. } `json:"stmtinfo"`
  2829. } `json:"output"`
  2830. RefmsgTime string `json:"refmsg_time"`
  2831. RespondTime string `json:"respond_time"`
  2832. Signtype interface{} `json:"signtype"`
  2833. WarnMsg interface{} `json:"warn_msg"`
  2834. }
  2835. type ResultEightFor10188 struct {
  2836. Cainfo string `json:"cainfo"`
  2837. ErrMsg string `json:"err_msg"`
  2838. InfRefmsgid string `json:"inf_refmsgid"`
  2839. Infcode string `json:"infcode"`
  2840. Output struct {
  2841. Stmtinfo struct {
  2842. SetlOptins string `json:"setl_optins"`
  2843. StmtRslt string `json:"stmt_rslt"`
  2844. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2845. } `json:"stmtinfo"`
  2846. } `json:"output"`
  2847. RefmsgTime string `json:"refmsg_time"`
  2848. RespondTime string `json:"respond_time"`
  2849. Signtype interface{} `json:"signtype"`
  2850. WarnMsg interface{} `json:"warn_msg"`
  2851. }
  2852. type ResultNine struct {
  2853. Cainfo string `json:"cainfo"`
  2854. ErrMsg string `json:"err_msg"`
  2855. InfRefmsgid string `json:"inf_refmsgid"`
  2856. Infcode int64 `json:"infcode"`
  2857. Output struct {
  2858. FileQuryNo string `json:"file_qury_no"`
  2859. } `json:"output"`
  2860. RefmsgTime string `json:"refmsg_time"`
  2861. RespondTime string `json:"respond_time"`
  2862. Signtype interface{} `json:"signtype"`
  2863. WarnMsg interface{} `json:"warn_msg"`
  2864. }
  2865. type ResultTen struct {
  2866. Cainfo string `json:"cainfo"`
  2867. ErrMsg string `json:"err_msg"`
  2868. InfRefmsgid string `json:"inf_refmsgid"`
  2869. Infcode int64 `json:"infcode"`
  2870. Output struct {
  2871. DldEndtime string `json:"dld_endtime"`
  2872. FileQuryNo string `json:"file_qury_no"`
  2873. Filename string `json:"filename"`
  2874. } `json:"output"`
  2875. RefmsgTime string `json:"refmsg_time"`
  2876. RespondTime string `json:"respond_time"`
  2877. Signtype interface{} `json:"signtype"`
  2878. WarnMsg interface{} `json:"warn_msg"`
  2879. }
  2880. //type Autogenerated struct {
  2881. // Output struct {
  2882. // Setlinfo struct {
  2883. // SetlTime string `json:"setl_time"`
  2884. // CvlservPay float64 `json:"cvlserv_pay"`
  2885. // Year string `json:"year"`
  2886. // MedType string `json:"med_type"`
  2887. // PsnPay float64 `json:"psn_pay"`
  2888. // OpterID string `json:"opter_id"`
  2889. // Begndate string `json:"begndate"`
  2890. // FlxempeFlag string `json:"flxempe_flag"`
  2891. // HifmiPay float64 `json:"hifmi_pay"`
  2892. // PsnNo string `json:"psn_no"`
  2893. // ActPayDedc float64 `json:"act_pay_dedc"`
  2894. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2895. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2896. // ClrWay string `json:"clr_way"`
  2897. // OthPay float64 `json:"oth_pay"`
  2898. // Gend string `json:"gend"`
  2899. // MdtrtID string `json:"mdtrt_id"`
  2900. // AcctPay float64 `json:"acct_pay"`
  2901. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2902. // Insutype string `json:"insutype"`
  2903. // Invono interface{} `json:"invono"`
  2904. // Enddate string `json:"enddate"`
  2905. // CashPayamt float64 `json:"cash_payamt"`
  2906. // PsnType string `json:"psn_type"`
  2907. // FixmedinsName string `json:"fixmedins_name"`
  2908. // HifpPay float64 `json:"hifp_pay"`
  2909. // NewFlag interface{} `json:"new_flag"`
  2910. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2911. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2912. // PayLoc string `json:"pay_loc"`
  2913. // ClrType string `json:"clr_type"`
  2914. // RefdSetlFlag string `json:"refd_setl_flag"`
  2915. // CvlservFlag string `json:"cvlserv_flag"`
  2916. // EmpName string `json:"emp_name"`
  2917. // Brdy string `json:"brdy"`
  2918. // Naty string `json:"naty"`
  2919. // Certno string `json:"certno"`
  2920. // DiseCode string `json:"dise_code"`
  2921. // FixmedinsCode string `json:"fixmedins_code"`
  2922. // DedcHospLv string `json:"dedc_hosp_lv"`
  2923. // OpterName string `json:"opter_name"`
  2924. // Balc float64 `json:"balc"`
  2925. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2926. // PsnCertType string `json:"psn_cert_type"`
  2927. // HifobPay float64 `json:"hifob_pay"`
  2928. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2929. // HifesPay float64 `json:"hifes_pay"`
  2930. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2931. // OptTime string `json:"opt_time"`
  2932. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2933. // SetlID string `json:"setl_id"`
  2934. // MafPay float64 `json:"maf_pay"`
  2935. // PsnName string `json:"psn_name"`
  2936. // InsuOptins interface{} `json:"insu_optins"`
  2937. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2938. // ClrOptins string `json:"clr_optins"`
  2939. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2940. // DiseName string `json:"dise_name"`
  2941. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2942. // Age float64 `json:"age"`
  2943. // DtrtCertType string `json:"dtrt_cert_type"`
  2944. // HospLv string `json:"hosp_lv"`
  2945. // } `json:"setlinfo"`
  2946. // Setldetail []struct {
  2947. // FundPayType string `json:"fund_pay_type"`
  2948. // FundPayamt float64 `json:"fund_payamt"`
  2949. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2950. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2951. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2952. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2953. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2954. // } `json:"setldetail"`
  2955. // } `json:"output"`
  2956. // Infcode int `json:"infcode"`
  2957. // WarnMsg interface{} `json:"warn_msg"`
  2958. // Cainfo interface{} `json:"cainfo"`
  2959. // ErrMsg interface{} `json:"err_msg"`
  2960. // RefmsgTime string `json:"refmsg_time"`
  2961. // Signtype interface{} `json:"signtype"`
  2962. // RespondTime string `json:"respond_time"`
  2963. // InfRefmsgid string `json:"inf_refmsgid"`
  2964. //}
  2965. type ResultEleven struct {
  2966. Cainfo string `json:"cainfo"`
  2967. ErrMsg string `json:"err_msg"`
  2968. InfRefmsgid string `json:"inf_refmsgid"`
  2969. Infcode int64 `json:"infcode"`
  2970. Output struct {
  2971. Setlinfo struct {
  2972. SetlTime string `json:"setl_time"`
  2973. CvlservPay float64 `json:"cvlserv_pay"`
  2974. Year string `json:"year"`
  2975. MedType string `json:"med_type"`
  2976. PsnPay float64 `json:"psn_pay"`
  2977. OpterID string `json:"opter_id"`
  2978. Begndate string `json:"begndate"`
  2979. FlxempeFlag string `json:"flxempe_flag"`
  2980. HifmiPay float64 `json:"hifmi_pay"`
  2981. PsnNo string `json:"psn_no"`
  2982. ActPayDedc float64 `json:"act_pay_dedc"`
  2983. MedinsSetlID interface{} `json:"medins_setl_id"`
  2984. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2985. ClrWay string `json:"clr_way"`
  2986. OthPay float64 `json:"oth_pay"`
  2987. Gend string `json:"gend"`
  2988. MdtrtID string `json:"mdtrt_id"`
  2989. AcctPay float64 `json:"acct_pay"`
  2990. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2991. Insutype string `json:"insutype"`
  2992. Invono interface{} `json:"invono"`
  2993. Enddate string `json:"enddate"`
  2994. CashPayamt float64 `json:"cash_payamt"`
  2995. PsnType string `json:"psn_type"`
  2996. FixmedinsName string `json:"fixmedins_name"`
  2997. HifpPay float64 `json:"hifp_pay"`
  2998. NewFlag interface{} `json:"new_flag"`
  2999. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3000. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3001. PayLoc string `json:"pay_loc"`
  3002. ClrType string `json:"clr_type"`
  3003. RefdSetlFlag string `json:"refd_setl_flag"`
  3004. CvlservFlag string `json:"cvlserv_flag"`
  3005. EmpName string `json:"emp_name"`
  3006. Brdy string `json:"brdy"`
  3007. Naty string `json:"naty"`
  3008. Certno string `json:"certno"`
  3009. DiseCode string `json:"dise_code"`
  3010. FixmedinsCode string `json:"fixmedins_code"`
  3011. DedcHospLv string `json:"dedc_hosp_lv"`
  3012. OpterName string `json:"opter_name"`
  3013. Balc float64 `json:"balc"`
  3014. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3015. PsnCertType string `json:"psn_cert_type"`
  3016. HifobPay float64 `json:"hifob_pay"`
  3017. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3018. HifesPay float64 `json:"hifes_pay"`
  3019. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3020. OptTime string `json:"opt_time"`
  3021. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3022. SetlID string `json:"setl_id"`
  3023. MafPay float64 `json:"maf_pay"`
  3024. PsnName string `json:"psn_name"`
  3025. InsuOptins interface{} `json:"insu_optins"`
  3026. PrefFundPay interface{} `json:"pref_fund_pay"`
  3027. ClrOptins string `json:"clr_optins"`
  3028. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3029. DiseName string `json:"dise_name"`
  3030. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3031. Age float64 `json:"age"`
  3032. DtrtCertType string `json:"dtrt_cert_type"`
  3033. HospLv string `json:"hosp_lv"`
  3034. } `json:"setlinfo"`
  3035. } `json:"output"`
  3036. RefmsgTime string `json:"refmsg_time"`
  3037. RespondTime string `json:"respond_time"`
  3038. Signtype interface{} `json:"signtype"`
  3039. WarnMsg interface{} `json:"warn_msg"`
  3040. }
  3041. type ResultEleven10265 struct {
  3042. Cainfo string `json:"cainfo"`
  3043. ErrMsg string `json:"err_msg"`
  3044. InfRefmsgid string `json:"inf_refmsgid"`
  3045. Infcode string `json:"infcode"`
  3046. Output struct {
  3047. Setlinfo struct {
  3048. SetlTime string `json:"setl_time"`
  3049. CvlservPay float64 `json:"cvlserv_pay"`
  3050. Year string `json:"year"`
  3051. MedType string `json:"med_type"`
  3052. PsnPay float64 `json:"psn_pay"`
  3053. OpterID string `json:"opter_id"`
  3054. Begndate string `json:"begndate"`
  3055. FlxempeFlag string `json:"flxempe_flag"`
  3056. HifmiPay float64 `json:"hifmi_pay"`
  3057. PsnNo string `json:"psn_no"`
  3058. ActPayDedc float64 `json:"act_pay_dedc"`
  3059. MedinsSetlID interface{} `json:"medins_setl_id"`
  3060. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3061. ClrWay string `json:"clr_way"`
  3062. OthPay float64 `json:"oth_pay"`
  3063. Gend string `json:"gend"`
  3064. MdtrtID string `json:"mdtrt_id"`
  3065. AcctPay float64 `json:"acct_pay"`
  3066. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3067. Insutype string `json:"insutype"`
  3068. Invono interface{} `json:"invono"`
  3069. Enddate string `json:"enddate"`
  3070. CashPayamt float64 `json:"cash_payamt"`
  3071. PsnType string `json:"psn_type"`
  3072. FixmedinsName string `json:"fixmedins_name"`
  3073. HifpPay float64 `json:"hifp_pay"`
  3074. NewFlag interface{} `json:"new_flag"`
  3075. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3076. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3077. PayLoc string `json:"pay_loc"`
  3078. ClrType string `json:"clr_type"`
  3079. RefdSetlFlag string `json:"refd_setl_flag"`
  3080. CvlservFlag string `json:"cvlserv_flag"`
  3081. EmpName string `json:"emp_name"`
  3082. Brdy string `json:"brdy"`
  3083. Naty string `json:"naty"`
  3084. Certno string `json:"certno"`
  3085. DiseCode string `json:"dise_code"`
  3086. FixmedinsCode string `json:"fixmedins_code"`
  3087. DedcHospLv string `json:"dedc_hosp_lv"`
  3088. OpterName string `json:"opter_name"`
  3089. Balc float64 `json:"balc"`
  3090. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3091. PsnCertType string `json:"psn_cert_type"`
  3092. HifobPay float64 `json:"hifob_pay"`
  3093. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3094. HifesPay float64 `json:"hifes_pay"`
  3095. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3096. OptTime string `json:"opt_time"`
  3097. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3098. SetlID string `json:"setl_id"`
  3099. MafPay float64 `json:"maf_pay"`
  3100. PsnName string `json:"psn_name"`
  3101. InsuOptins interface{} `json:"insu_optins"`
  3102. PrefFundPay interface{} `json:"pref_fund_pay"`
  3103. ClrOptins string `json:"clr_optins"`
  3104. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3105. DiseName string `json:"dise_name"`
  3106. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3107. Age float64 `json:"age"`
  3108. DtrtCertType string `json:"dtrt_cert_type"`
  3109. HospLv string `json:"hosp_lv"`
  3110. } `json:"setlinfo"`
  3111. } `json:"output"`
  3112. RefmsgTime string `json:"refmsg_time"`
  3113. RespondTime string `json:"respond_time"`
  3114. Signtype interface{} `json:"signtype"`
  3115. WarnMsg interface{} `json:"warn_msg"`
  3116. }
  3117. type ResultTwelve struct {
  3118. Cainfo string `json:"cainfo"`
  3119. ErrMsg string `json:"err_msg"`
  3120. InfRefmsgid string `json:"inf_refmsgid"`
  3121. Infcode int64 `json:"infcode"`
  3122. Output struct {
  3123. MdtrtId string `json:"mdtrt_id"`
  3124. ChrgBchno string `json:"chrg_bchno"`
  3125. PsnNo string `json:"psn_no"`
  3126. } `json:"output"`
  3127. RefmsgTime string `json:"refmsg_time"`
  3128. RespondTime string `json:"respond_time"`
  3129. Signtype interface{} `json:"signtype"`
  3130. WarnMsg interface{} `json:"warn_msg"`
  3131. }
  3132. type ResultThirteen struct {
  3133. ErrMsg string `json:"err_msg"`
  3134. InfRefmsgid string `json:"inf_refmsgid"`
  3135. Infcode int64 `json:"infcode"`
  3136. Output struct {
  3137. Result struct {
  3138. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3139. } `json:"result"`
  3140. } `json:"output"`
  3141. RefmsgTime string `json:"refmsg_time"`
  3142. RespondTime string `json:"respond_time"`
  3143. Signtype interface{} `json:"signtype"`
  3144. WarnInfo interface{} `json:"warn_info"`
  3145. }
  3146. type ResultThirteen10265 struct {
  3147. ErrMsg string `json:"err_msg"`
  3148. InfRefmsgid string `json:"inf_refmsgid"`
  3149. Infcode string `json:"infcode"`
  3150. Output struct {
  3151. Result struct {
  3152. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3153. } `json:"result"`
  3154. } `json:"output"`
  3155. RefmsgTime string `json:"refmsg_time"`
  3156. RespondTime string `json:"respond_time"`
  3157. Signtype interface{} `json:"signtype"`
  3158. WarnInfo interface{} `json:"warn_info"`
  3159. }
  3160. type ResultFourteen struct {
  3161. ErrMsg string `json:"err_msg"`
  3162. InfRefmsgid string `json:"inf_refmsgid"`
  3163. Infcode int64 `json:"infcode"`
  3164. Output struct {
  3165. } `json:"output"`
  3166. RefmsgTime string `json:"refmsg_time"`
  3167. RespondTime string `json:"respond_time"`
  3168. Signtype interface{} `json:"signtype"`
  3169. WarnInfo interface{} `json:"warn_info"`
  3170. }
  3171. type ResultFourteen10265 struct {
  3172. ErrMsg string `json:"err_msg"`
  3173. InfRefmsgid string `json:"inf_refmsgid"`
  3174. Infcode string `json:"infcode"`
  3175. Output struct {
  3176. } `json:"output"`
  3177. RefmsgTime string `json:"refmsg_time"`
  3178. RespondTime string `json:"respond_time"`
  3179. Signtype interface{} `json:"signtype"`
  3180. WarnInfo interface{} `json:"warn_info"`
  3181. }
  3182. type ResultSixteen struct {
  3183. Cainfo string `json:"cainfo"`
  3184. ErrMsg string `json:"err_msg"`
  3185. InfRefmsgid string `json:"inf_refmsgid"`
  3186. Infcode int64 `json:"infcode"`
  3187. Output struct {
  3188. Setldetail []interface{} `json:"setldetail"`
  3189. Setlinfo struct {
  3190. MdtrtID string `json:"mdtrt_id"`
  3191. SetlID string `json:"setl_id"`
  3192. ClrOptins string `json:"clr_optins"`
  3193. SetlTime string `json:"setl_time"`
  3194. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3195. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3196. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3198. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3199. ActPayDedc float64 `json:"act_pay_dedc"`
  3200. HifpPay float64 `json:"hifp_pay"`
  3201. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3202. Lfpay float64 `json:"selfpay"`
  3203. CvlservPay float64 `json:"cvlserv_pay"`
  3204. HifesPay float64 `json:"hifes_pay"`
  3205. HifmiPay float64 `json:"hifmi_pay"`
  3206. HifobPay float64 `json:"hifob_pay"`
  3207. MafPay float64 `json:"maf_pay"`
  3208. OthPay float64 `json:"oth_pay"`
  3209. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3210. PsnPartAmt float64 `json:"psn_part_amt"`
  3211. AcctPay float64 `json:"acct_pay"`
  3212. Balc float64 `json:"balc"`
  3213. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3214. HospPartAmt float64 `json:"hosp_part_amt"`
  3215. MedinsSetlID string `json:"medins_setl_id"`
  3216. PdnCashPay string `json:"pdn_cash_pay"`
  3217. } `json:"setlinfo"`
  3218. } `json:"output"`
  3219. RefmsgTime string `json:"refmsg_time"`
  3220. RespondTime string `json:"respond_time"`
  3221. Signtype interface{} `json:"signtype"`
  3222. WarnMsg interface{} `json:"warn_msg"`
  3223. }
  3224. type ResultSixteen10265 struct {
  3225. Cainfo string `json:"cainfo"`
  3226. ErrMsg string `json:"err_msg"`
  3227. InfRefmsgid string `json:"inf_refmsgid"`
  3228. Infcode string `json:"infcode"`
  3229. Output struct {
  3230. Setldetail []interface{} `json:"setldetail"`
  3231. Setlinfo struct {
  3232. MdtrtID string `json:"mdtrt_id"`
  3233. SetlID string `json:"setl_id"`
  3234. ClrOptins string `json:"clr_optins"`
  3235. SetlTime string `json:"setl_time"`
  3236. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3237. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3238. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3239. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3240. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3241. ActPayDedc float64 `json:"act_pay_dedc"`
  3242. HifpPay float64 `json:"hifp_pay"`
  3243. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3244. Lfpay float64 `json:"selfpay"`
  3245. CvlservPay float64 `json:"cvlserv_pay"`
  3246. HifesPay float64 `json:"hifes_pay"`
  3247. HifmiPay float64 `json:"hifmi_pay"`
  3248. HifobPay float64 `json:"hifob_pay"`
  3249. MafPay float64 `json:"maf_pay"`
  3250. OthPay float64 `json:"oth_pay"`
  3251. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3252. PsnPartAmt float64 `json:"psn_part_amt"`
  3253. AcctPay float64 `json:"acct_pay"`
  3254. Balc float64 `json:"balc"`
  3255. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3256. HospPartAmt float64 `json:"hosp_part_amt"`
  3257. MedinsSetlID string `json:"medins_setl_id"`
  3258. PdnCashPay string `json:"pdn_cash_pay"`
  3259. } `json:"setlinfo"`
  3260. } `json:"output"`
  3261. RefmsgTime string `json:"refmsg_time"`
  3262. RespondTime string `json:"respond_time"`
  3263. Signtype interface{} `json:"signtype"`
  3264. WarnMsg interface{} `json:"warn_msg"`
  3265. }
  3266. type ResultSeventeen struct {
  3267. ErrMsg string `json:"err_msg"`
  3268. InfRefmsgid string `json:"inf_refmsgid"`
  3269. Infcode int64 `json:"infcode"`
  3270. Output struct {
  3271. SetlListId string `json:"setl_list_id"`
  3272. } `json:"output"`
  3273. RefmsgTime string `json:"refmsg_time"`
  3274. RespondTime string `json:"respond_time"`
  3275. Signtype string `json:"signtype"`
  3276. WarnInfo string `json:"warn_info"`
  3277. }
  3278. type Result90991 struct {
  3279. ErrMsg string `json:"err_msg"`
  3280. InfRefmsgid string `json:"inf_refmsgid"`
  3281. Infcode int64 `json:"infcode"`
  3282. Output struct {
  3283. Result struct {
  3284. PsnNo string `json:"psn_no"`
  3285. CardStat string `json:"card_stat"`
  3286. Certno string `json:"certno"`
  3287. PsnName string `json:"psn_name"`
  3288. CheckStat string `json:"check_stat"`
  3289. } `json:"result"`
  3290. } `json:"output"`
  3291. RefmsgTime string `json:"refmsg_time"`
  3292. RespondTime string `json:"respond_time"`
  3293. Signtype interface{} `json:"signtype"`
  3294. WarnInfo interface{} `json:"warn_info"`
  3295. }
  3296. type Result90100 struct {
  3297. ErrMsg string `json:"err_msg"`
  3298. InfRefmsgid string `json:"inf_refmsgid"`
  3299. Infcode int64 `json:"infcode"`
  3300. Output struct {
  3301. PoolareaNo string `json:"poolarea_no"`
  3302. PoolareaNoName string `json:"poolarea_no_name"`
  3303. Insutype string `json:"insutype"`
  3304. InsutypeName string `json:"insutype_name"`
  3305. ClctType string `json:"clct_type"`
  3306. ClctTypeName string `json:"clct_type_name"`
  3307. ClctFlag string `json:"clct_flag"`
  3308. ClctFlagName string `json:"clct_flag_name"`
  3309. AccrymBegn string `json:"accrym_begn"`
  3310. AccrymEnd string `json:"accrym_end"`
  3311. ClctTime string `json:"clct_time"`
  3312. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3313. } `json:"output"`
  3314. RefmsgTime string `json:"refmsg_time"`
  3315. RespondTime string `json:"respond_time"`
  3316. Signtype interface{} `json:"signtype"`
  3317. WarnInfo interface{} `json:"warn_info"`
  3318. }
  3319. type Custom struct {
  3320. DetItemFeeSumamt string
  3321. Cut string
  3322. FeedetlSn string
  3323. Price string
  3324. MedListCodg string
  3325. Type int64
  3326. AdviceId int64
  3327. ProjectId int64
  3328. ItemId int64
  3329. }
  3330. type Result5301 struct {
  3331. ErrMsg string `json:"err_msg"`
  3332. InfRefmsgid string `json:"inf_refmsgid"`
  3333. Infcode int64 `json:"infcode"`
  3334. Output struct {
  3335. Result []struct {
  3336. OpspDiseCode string `json:"opsp_dise_code"`
  3337. OpspDiseName string `json:"opsp_dise_name"`
  3338. Begndate string `json:"begndate"`
  3339. Enddate string `json:"enddate"`
  3340. } `json:"feedetail"`
  3341. } `json:"output"`
  3342. RefmsgTime string `json:"refmsg_time"`
  3343. RespondTime string `json:"respond_time"`
  3344. Signtype interface{} `json:"signtype"`
  3345. WarnInfo interface{} `json:"warn_info"`
  3346. }
  3347. type Result5301For10265 struct {
  3348. ErrMsg string `json:"err_msg"`
  3349. InfRefmsgid string `json:"inf_refmsgid"`
  3350. Infcode string `json:"infcode"`
  3351. Output struct {
  3352. Result []struct {
  3353. OpspDiseCode string `json:"opsp_dise_code"`
  3354. OpspDiseName string `json:"opsp_dise_name"`
  3355. Begndate string `json:"begndate"`
  3356. Enddate string `json:"enddate"`
  3357. } `json:"feedetail"`
  3358. } `json:"output"`
  3359. RefmsgTime string `json:"refmsg_time"`
  3360. RespondTime string `json:"respond_time"`
  3361. Signtype interface{} `json:"signtype"`
  3362. WarnInfo interface{} `json:"warn_info"`
  3363. }
  3364. //获取个人信息----挂号-----上传就诊信息
  3365. func (c *HisApiController) GetRegisterInfo() {
  3366. id, _ := c.GetInt64("id")
  3367. record_time := c.GetString("record_time")
  3368. settlementValue, _ := c.GetInt64("settlement_value")
  3369. medical_insurance_card := c.GetString("medical_insurance_card")
  3370. name := c.GetString("name")
  3371. id_card_type, _ := c.GetInt64("id_card_type")
  3372. certificates, _ := c.GetInt64("certificates")
  3373. medical_care, _ := c.GetInt64("medical_care")
  3374. birthday := c.GetString("birthday")
  3375. id_card := c.GetString("id_card")
  3376. register_type, _ := c.GetInt64("register")
  3377. doctor, _ := c.GetInt64("doctor")
  3378. department, _ := c.GetInt64("department")
  3379. gender, _ := c.GetInt64("sex")
  3380. registration_fee, _ := c.GetFloat("registration_fee")
  3381. medical_expenses, _ := c.GetFloat("medical_expenses")
  3382. social_type, _ := c.GetInt64("social_type")
  3383. med_type := c.GetString("social_type")
  3384. admin_user_id, _ := c.GetInt64("admin_user_id")
  3385. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3386. timeLayout := "2006-01-02"
  3387. loc, _ := time.LoadLocation("Local")
  3388. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3389. birthUnix := birthdays.Unix()
  3390. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3391. if err != nil {
  3392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3393. return
  3394. }
  3395. recordDateTime := theTime.Unix()
  3396. adminInfo := c.GetAdminUserInfo()
  3397. var patient service.Patients
  3398. if id == 0 {
  3399. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3400. } else {
  3401. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3402. }
  3403. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3404. if patientPrescription.ID == 0 {
  3405. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3406. }
  3407. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3408. if patient.ID == 0 {
  3409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3410. return
  3411. }
  3412. if len(patient.IdCardNo) == 0 {
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3414. return
  3415. }
  3416. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3417. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3418. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3419. //就诊结算未完成,不能进行二次挂号
  3420. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3421. if len(his) >= 1 {
  3422. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3423. if len(his) >= 1 && order.ID == 0 {
  3424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3425. return
  3426. }
  3427. }
  3428. //var register_log string
  3429. if config.IsOpen == 1 {
  3430. var res ResultTwo
  3431. var res10265 ResultTwo10265
  3432. var PsnNo string
  3433. var PsnCertType string
  3434. var Certno string
  3435. var PsnName string
  3436. var Gend string
  3437. var Naty string
  3438. var Brdy string
  3439. var Age float64
  3440. var infoStr string
  3441. var idetinfoStr string
  3442. var infocode int64
  3443. var verify_number string
  3444. fmt.Println(verify_number)
  3445. if miConfig.MdtrtareaAdmvs == "421300" {
  3446. psn_info, _ := service.GetPsnByPatientId(id)
  3447. PsnNo = psn_info.PsnNo
  3448. PsnCertType = psn_info.PsnCertType
  3449. Certno = psn_info.Certno
  3450. PsnName = psn_info.PsnName
  3451. Gend = psn_info.Gend
  3452. Naty = psn_info.Naty
  3453. Brdy = psn_info.Brdy
  3454. Age = psn_info.Age
  3455. infoStr = psn_info.Insuinfo
  3456. idetinfoStr = psn_info.Idetinfo
  3457. infocode = 0
  3458. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3459. psn_info, _ := service.GetPsnByPatientId(id)
  3460. PsnNo = psn_info.PsnNo
  3461. PsnCertType = psn_info.PsnCertType
  3462. Certno = psn_info.Certno
  3463. PsnName = psn_info.PsnName
  3464. Gend = psn_info.Gend
  3465. Naty = psn_info.Naty
  3466. Brdy = psn_info.Brdy
  3467. Age = psn_info.Age
  3468. infoStr = psn_info.Insuinfo
  3469. idetinfoStr = psn_info.Idetinfo
  3470. infocode = 0
  3471. verify_number = psn_info.VerifyNumber
  3472. } else {
  3473. var result string
  3474. var requestLog string
  3475. if miConfig.UserOrgId == 10138 {
  3476. 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)
  3477. } else {
  3478. 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)
  3479. }
  3480. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3481. if miConfig.Code == "H15049901371" {
  3482. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3483. utils.ErrorLog("解析失败:%v", err)
  3484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3485. return
  3486. }
  3487. res.ErrMsg = res10265.ErrMsg
  3488. res.Output = res10265.Output
  3489. res.InfRefmsgid = res10265.InfRefmsgid
  3490. } else {
  3491. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3492. utils.ErrorLog("解析失败:%v", err)
  3493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3494. return
  3495. }
  3496. }
  3497. PsnNo = res.Output.Baseinfo.PsnNo
  3498. PsnCertType = res.Output.Baseinfo.PsnCertType
  3499. Certno = res.Output.Baseinfo.Certno
  3500. PsnName = res.Output.Baseinfo.PsnName
  3501. Gend = res.Output.Baseinfo.Gend
  3502. Naty = res.Output.Baseinfo.Naty
  3503. Brdy = res.Output.Baseinfo.Brdy
  3504. Age = res.Output.Baseinfo.Age
  3505. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3506. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3507. infoStr = string(Iinfos)
  3508. idetinfoStr = string(Idetinfos)
  3509. if miConfig.Code == "H15049901371" {
  3510. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3511. } else {
  3512. infocode = res.Infcode
  3513. }
  3514. }
  3515. if infocode == 0 {
  3516. his := models.VMHisPatient{
  3517. Name: name,
  3518. Gender: gender,
  3519. Birthday: birthUnix,
  3520. MedicalTreatmentType: medical_care,
  3521. IdType: certificates,
  3522. IdCardNo: id_card,
  3523. BalanceAccountsType: settlementValue,
  3524. SocialType: social_type,
  3525. MedicalInsuranceNumber: medical_insurance_card,
  3526. RegisterType: register_type,
  3527. RegisterCost: registration_fee,
  3528. TreatmentCost: medical_expenses,
  3529. Status: 1,
  3530. Ctime: time.Now().Unix(),
  3531. Mtime: time.Now().Unix(),
  3532. PsnNo: PsnNo,
  3533. PsnCertType: PsnCertType,
  3534. Certno: Certno,
  3535. PsnName: PsnName,
  3536. Gend: Gend,
  3537. Naty: Naty,
  3538. Brdy: Brdy,
  3539. Age: Age,
  3540. Iinfo: infoStr,
  3541. Idetinfo: idetinfoStr,
  3542. PatientId: patient.ID,
  3543. RecordDate: theTime.Unix(),
  3544. UserOrgId: adminInfo.CurrentOrgId,
  3545. AdminUserId: admin_user_id,
  3546. IsReturn: 1,
  3547. IdCardType: id_card_type,
  3548. Doctor: doctor,
  3549. Departments: department,
  3550. }
  3551. timestamp := time.Now().Unix()
  3552. tempTime := time.Unix(timestamp, 0)
  3553. timeFormat := tempTime.Format("20060102150405")
  3554. chrgBchno := rand.Intn(100000) + 10000
  3555. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3556. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3557. department, _ := service.GetDepartMentDetail(department)
  3558. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3559. IdCardNo := ""
  3560. if id_card_type == 1 {
  3561. // IdCardNo = medical_insurance_card
  3562. IdCardNo = patient.IdCardNo
  3563. } else {
  3564. IdCardNo = patient.IdCardNo
  3565. }
  3566. var rf []*ResultFive
  3567. json.Unmarshal([]byte(his.Iinfo), &rf)
  3568. var insutypes []*ResultFive
  3569. var insutype string
  3570. var insuplc_admdvs_temp string
  3571. var is390 int = 0
  3572. var is310 int = 0
  3573. for _, item := range rf {
  3574. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3575. insutypes = append(insutypes, item)
  3576. }
  3577. }
  3578. if len(insutypes) == 1 {
  3579. insutype = insutypes[0].Insutype
  3580. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3581. } else {
  3582. for _, i := range insutypes {
  3583. if i.Insutype == "390" {
  3584. is390 = 1
  3585. }
  3586. if i.Insutype == "310" {
  3587. is310 = 1
  3588. }
  3589. }
  3590. }
  3591. if is390 == 1 {
  3592. insutype = "390"
  3593. }
  3594. if is310 == 1 {
  3595. insutype = "310"
  3596. }
  3597. if len(insutypes) == 0 {
  3598. insutype = "310"
  3599. }
  3600. if len(insutypes) == 2 {
  3601. insutype = med_type
  3602. }
  3603. if len(med_type) > 0 {
  3604. insutype = med_type
  3605. }
  3606. //for _, item := range rf {
  3607. // if item.Insutype == insutype {
  3608. // insuplc_admdvs = item.InsuplcAdmdvs
  3609. // }
  3610. //}
  3611. var infocode int64
  3612. var resThree ResultThree
  3613. var resThree10265 ResultThree10265
  3614. if len(insuplc_admdvs) == 0 {
  3615. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3616. } else {
  3617. insuplc_admdvs_temp = insuplc_admdvs
  3618. }
  3619. if miConfig.MdtrtareaAdmvs == "421300" {
  3620. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3621. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3622. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3623. resp, requestErr := http.Get(api)
  3624. if requestErr != nil {
  3625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3626. return
  3627. }
  3628. body, ioErr := ioutil.ReadAll(resp.Body)
  3629. if ioErr != nil {
  3630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3632. return
  3633. }
  3634. var respJSON map[string]interface{}
  3635. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3638. return
  3639. }
  3640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3641. result, _ := json.Marshal(respJSON)
  3642. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3643. utils.ErrorLog("解析失败:%v", err)
  3644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3645. return
  3646. }
  3647. infocode = resThree.Infcode
  3648. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3649. psn_info, _ := service.GetPsnByPatientId(id)
  3650. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3651. var cert_no string
  3652. if id_card_type == 3 {
  3653. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  3654. cert_no = IdCardNo
  3655. } else {
  3656. bas := strings.Split(psn_info.CardInfo, "|")
  3657. cert_no = bas[2]
  3658. }
  3659. var api string
  3660. if miConfig.MdtrtareaAdmvs == "320921" {
  3661. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3662. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3663. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3664. } else {
  3665. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3666. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3667. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3668. }
  3669. resp, requestErr := http.Get(api)
  3670. if requestErr != nil {
  3671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. return
  3673. }
  3674. body, ioErr := ioutil.ReadAll(resp.Body)
  3675. if ioErr != nil {
  3676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. var respJSON map[string]interface{}
  3681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3684. return
  3685. }
  3686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3687. result, _ := json.Marshal(respJSON)
  3688. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3689. utils.ErrorLog("解析失败:%v", err)
  3690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3691. return
  3692. }
  3693. resThree.ErrMsg = resThree10265.ErrMsg
  3694. resThree.Output = resThree10265.Output
  3695. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3696. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3697. } else {
  3698. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3699. saveLog(result, requestLog, "2201", "挂号")
  3700. if miConfig.Code == "H15049901371" {
  3701. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3702. utils.ErrorLog("解析失败:%v", err)
  3703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3704. return
  3705. }
  3706. resThree.ErrMsg = resThree10265.ErrMsg
  3707. resThree.Output = resThree10265.Output
  3708. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3709. } else {
  3710. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3711. utils.ErrorLog("解析失败:%v", err)
  3712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3713. return
  3714. }
  3715. }
  3716. if miConfig.Code == "H15049901371" {
  3717. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3718. } else {
  3719. infocode = resThree.Infcode
  3720. }
  3721. }
  3722. if infocode != 0 {
  3723. adminUser := c.GetAdminUserInfo()
  3724. errlog := &models.HisOrderError{
  3725. UserOrgId: adminUser.CurrentOrgId,
  3726. Ctime: time.Now().Unix(),
  3727. Mtime: time.Now().Unix(),
  3728. ErrMsg: resThree.ErrMsg,
  3729. Status: 1,
  3730. PatientId: id,
  3731. RecordTime: recordDateTime,
  3732. Stage: 2,
  3733. }
  3734. service.CreateErrMsgLog(errlog)
  3735. c.ServeSuccessJSON(map[string]interface{}{
  3736. "failed_code": -10,
  3737. "msg": resThree.ErrMsg,
  3738. })
  3739. return
  3740. }
  3741. his.Number = resThree.Output.Data.MdtrtID
  3742. his.PsnNo = resThree.Output.Data.PsnNo
  3743. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3744. his.IdCardNo = patient.IdCardNo
  3745. his.PhoneNumber = patient.Phone
  3746. his.UserOrgId = adminInfo.CurrentOrgId
  3747. his.Insutype = insutype
  3748. his.Ctime = time.Now().Unix()
  3749. his.Mtime = time.Now().Unix()
  3750. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3751. his.Status = 1
  3752. service.UpdateHisPatientStatus(&his)
  3753. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3754. c.ServeSuccessJSON(map[string]interface{}{
  3755. "his_info": his,
  3756. })
  3757. } else {
  3758. adminUser := c.GetAdminUserInfo()
  3759. errlog := &models.HisOrderError{
  3760. UserOrgId: adminUser.CurrentOrgId,
  3761. Ctime: time.Now().Unix(),
  3762. Mtime: time.Now().Unix(),
  3763. ErrMsg: res.ErrMsg,
  3764. Status: 1,
  3765. PatientId: id,
  3766. RecordTime: recordDateTime,
  3767. Stage: 1,
  3768. }
  3769. service.CreateErrMsgLog(errlog)
  3770. c.ServeSuccessJSON(map[string]interface{}{
  3771. "failed_code": -10,
  3772. "msg": res.ErrMsg,
  3773. })
  3774. return
  3775. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3776. }
  3777. }
  3778. }
  3779. //上传明细----预结算----确认订单
  3780. func (c *HisApiController) GetUploadInfo() {
  3781. id, _ := c.GetInt64("id")
  3782. record_time := c.GetString("record_time")
  3783. his_patient_id, _ := c.GetInt64("his_patient_id")
  3784. order_id, _ := c.GetInt64("order_id")
  3785. pay_way, _ := c.GetInt64("pay_way")
  3786. pay_price, _ := c.GetFloat("pay_price")
  3787. pay_card_no := c.GetString("pay_card_no")
  3788. discount_price, _ := c.GetFloat("discount_price")
  3789. preferential_price, _ := c.GetFloat("preferential_price")
  3790. reality_price, _ := c.GetFloat("reality_price")
  3791. found_price, _ := c.GetFloat("found_price")
  3792. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3793. private_price, _ := c.GetFloat("private_price")
  3794. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3795. admin_user_id, _ := c.GetInt64("admin_user_id")
  3796. fapiao_code := c.GetString("fapiao_code")
  3797. fapiao_number := c.GetString("fapiao_number")
  3798. diagnosis_id := c.GetString("diagnosis")
  3799. sick_type, _ := c.GetInt64("sick_type")
  3800. reg_type, _ := c.GetInt64("p_type")
  3801. begin_time := c.GetString("begin_time")
  3802. id_str := c.GetString("ids")
  3803. ids_arr := strings.Split(id_str, ",")
  3804. timeLayout := "2006-01-02"
  3805. loc, _ := time.LoadLocation("Local")
  3806. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3807. if err != nil {
  3808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3809. return
  3810. }
  3811. recordDateTime := theTime.Unix()
  3812. adminUser := c.GetAdminUserInfo()
  3813. var tempOrder models.HisOrder
  3814. tempOrder, _ = service.GetHisOrderByID(order_id)
  3815. var prescriptions []*models.HisPrescription
  3816. var start_time int64
  3817. var end_time int64
  3818. //if adminUser.CurrentOrgId == 10106{
  3819. // if len(fapiao_code) == 0{
  3820. // fapiao_code = "144072080589"
  3821. // }
  3822. // if len(fapiao_number) == 0{
  3823. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3824. // if order.ID == 0{
  3825. // fapiao_number = "00001520"
  3826. // }else{
  3827. // //fapiao_code = "00001520"
  3828. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3829. // var zero string
  3830. // if fpNumber >= 1000{
  3831. // zero = "0000" + strconv.Itoa(fpNumber)
  3832. // }else if fpNumber >= 10000{
  3833. // zero = "000" + strconv.Itoa(fpNumber)
  3834. // } else if fpNumber >= 100000{
  3835. // zero = "00" + strconv.Itoa(fpNumber)
  3836. // } else if fpNumber >= 1000000{
  3837. // zero = "0" + strconv.Itoa(fpNumber)
  3838. // }else {
  3839. // zero = strconv.Itoa(fpNumber)
  3840. // }
  3841. // fapiao_number = zero
  3842. // }
  3843. // }
  3844. //}
  3845. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3846. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3847. var patientPrescription models.HisPrescriptionInfo
  3848. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3849. if patientPrescription.ID == 0 {
  3850. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3851. }
  3852. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3853. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3854. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3855. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3856. var config []*models.HisXtDiagnoseConfig
  3857. for _, item := range diagnosis_ids {
  3858. id, _ := strconv.ParseInt(item, 10, 64)
  3859. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3860. config = append(config, &diagnosisConfig)
  3861. }
  3862. sickConfig, _ := service.FindSickById(sick_type)
  3863. //if tempOrder.ID == 0 {
  3864. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3865. //}
  3866. if tempOrder.ID == 0 {
  3867. var result string
  3868. var requestLog string
  3869. var res2 ResultSix
  3870. var ressix10265 ResultSix10265
  3871. if miConfig.MdtrtareaAdmvs == "421300" {
  3872. data := make(map[string]interface{})
  3873. client := &http.Client{}
  3874. data["psn_no"] = his.PsnNo
  3875. data["mdtrt_id"] = his.Number
  3876. data["doctor"] = roles.UserName
  3877. data["department"] = department.Name
  3878. data["org_name"] = miConfig.OrgName
  3879. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3880. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3881. data["fixmedins_code"] = miConfig.Code
  3882. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3884. data["secret_key"] = miConfig.SecretKey
  3885. data["sick_code"] = sickConfig.CountryCode
  3886. data["sick_name"] = sickConfig.ClassName
  3887. data["dept"] = strconv.FormatInt(department.ID, 10)
  3888. data["config"] = config
  3889. data["begin_time"] = begin_time
  3890. bytesData, _ := json.Marshal(data)
  3891. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3892. resp, _ := client.Do(req)
  3893. defer resp.Body.Close()
  3894. body, ioErr := ioutil.ReadAll(resp.Body)
  3895. if ioErr != nil {
  3896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3898. return
  3899. }
  3900. var respJSON map[string]interface{}
  3901. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3904. return
  3905. }
  3906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3907. userJSONBytes, _ := json.Marshal(respJSON)
  3908. fmt.Println("log")
  3909. fmt.Println(string(userJSONBytes))
  3910. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3911. utils.ErrorLog("解析失败:%v", err)
  3912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. return
  3914. }
  3915. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3916. //江苏地区国家医保医疗类别
  3917. //职工透析:医疗类别选特殊情况门诊9933
  3918. //居民血透门慢: 医疗类别选门诊慢病1402
  3919. //var med_type string
  3920. //if his.Insutype == "310" {
  3921. // if reg_type == 14 {
  3922. // med_type = "9933"
  3923. // } else if reg_type == 11 {
  3924. // med_type = "11"
  3925. //
  3926. // }
  3927. //} else if his.Insutype == "390" {
  3928. // if reg_type == 14 {
  3929. // med_type = "1402"
  3930. // } else if reg_type == 11 {
  3931. // med_type = "11"
  3932. // }
  3933. //}
  3934. data := make(map[string]interface{})
  3935. client := &http.Client{}
  3936. data["psn_no"] = his.PsnNo
  3937. data["mdtrt_id"] = his.Number
  3938. data["doctor"] = roles.UserName
  3939. data["department"] = department.Name
  3940. data["org_name"] = miConfig.OrgName
  3941. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3942. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3943. data["fixmedins_code"] = miConfig.Code
  3944. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3945. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3946. data["secret_key"] = miConfig.SecretKey
  3947. data["sick_code"] = sickConfig.CountryCode
  3948. data["sick_name"] = sickConfig.ClassName
  3949. data["url"] = miConfig.Url
  3950. data["ak"] = miConfig.AccessKey
  3951. data["begin_time"] = begin_time
  3952. data["cainfo"] = miConfig.Cainfo
  3953. data["dept"] = strconv.FormatInt(department.ID, 10)
  3954. data["config"] = config
  3955. bytesData, _ := json.Marshal(data)
  3956. var req *http.Request
  3957. if miConfig.MdtrtareaAdmvs == "320921" {
  3958. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3959. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3960. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3961. } else {
  3962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3963. }
  3964. resp, _ := client.Do(req)
  3965. defer resp.Body.Close()
  3966. body, ioErr := ioutil.ReadAll(resp.Body)
  3967. if ioErr != nil {
  3968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3970. return
  3971. }
  3972. var respJSON map[string]interface{}
  3973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3976. return
  3977. }
  3978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3979. userJSONBytes, _ := json.Marshal(respJSON)
  3980. fmt.Println("log")
  3981. fmt.Println(string(userJSONBytes))
  3982. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3983. utils.ErrorLog("解析失败:%v", err)
  3984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3985. return
  3986. }
  3987. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3988. res2.Output = ressix10265.Output
  3989. res2.ErrMsg = ressix10265.ErrMsg
  3990. res2.Cainfo = ressix10265.Cainfo
  3991. res2.WarnMsg = ressix10265.WarnMsg
  3992. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3993. res2.Infcode = infocode
  3994. } else {
  3995. if miConfig.MdtrtareaAdmvs == "440781" { //
  3996. 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)
  3997. } else {
  3998. if miConfig.Code == "H15049901371" {
  3999. //赤峰地区国家医保医疗类别
  4000. //职工透析:医疗类别选特殊情况门诊990502
  4001. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4002. var med_type string
  4003. if his.Insutype == "390" {
  4004. if reg_type == 14 {
  4005. med_type = "9933"
  4006. } else if reg_type == 11 {
  4007. med_type = "11"
  4008. }
  4009. } else if his.Insutype == "310" {
  4010. if reg_type == 14 {
  4011. med_type = "990502"
  4012. } else if reg_type == 11 {
  4013. med_type = "11"
  4014. }
  4015. }
  4016. 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)
  4017. } else {
  4018. 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)
  4019. }
  4020. }
  4021. saveLog(result, requestLog, "2203", "上传就诊信息")
  4022. var respJSON2 map[string]interface{}
  4023. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4026. return
  4027. }
  4028. userJSONBytes2, _ := json.Marshal(respJSON2)
  4029. if miConfig.Code == "H15049901371" {
  4030. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4031. utils.ErrorLog("解析失败:%v", err)
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4036. res2.Output = ressix10265.Output
  4037. res2.ErrMsg = ressix10265.ErrMsg
  4038. res2.Cainfo = ressix10265.Cainfo
  4039. res2.WarnMsg = ressix10265.WarnMsg
  4040. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4041. res2.Infcode = infocode
  4042. } else {
  4043. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4044. utils.ErrorLog("解析失败:%v", err)
  4045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4046. return
  4047. }
  4048. }
  4049. }
  4050. if res2.Infcode != 0 {
  4051. adminUser := c.GetAdminUserInfo()
  4052. errlog := &models.HisOrderError{
  4053. UserOrgId: adminUser.CurrentOrgId,
  4054. Ctime: time.Now().Unix(),
  4055. Mtime: time.Now().Unix(),
  4056. ErrMsg: res2.ErrMsg,
  4057. Status: 1,
  4058. PatientId: id,
  4059. RecordTime: recordDateTime,
  4060. Stage: 3,
  4061. }
  4062. service.CreateErrMsgLog(errlog)
  4063. c.ServeSuccessJSON(map[string]interface{}{
  4064. "failed_code": -10,
  4065. "msg": res2.ErrMsg,
  4066. })
  4067. return
  4068. } else {
  4069. his.Diagnosis = diagnosis_id
  4070. his.SickType = sickConfig.ID
  4071. //var p_type int64
  4072. //if reg_type == 1111 || reg_type == 1112 {
  4073. // p_type = 11
  4074. //
  4075. //}
  4076. his.PType = fmt.Sprintf("%d", reg_type)
  4077. service.UpdateHisPatientThree(&his)
  4078. data := make(map[string]interface{})
  4079. if settle_accounts_type == 1 { //日结
  4080. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4081. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4082. } else {
  4083. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4084. }
  4085. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4086. data["pre"] = prescriptions
  4087. } else { //月结
  4088. start_time_str := c.GetString("start_time")
  4089. end_time_str := c.GetString("end_time")
  4090. timeLayout := "2006-01-02"
  4091. loc, _ := time.LoadLocation("Local")
  4092. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4093. if err != nil {
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4095. return
  4096. }
  4097. recordStartTime := theStartTime.Unix()
  4098. start_time = recordStartTime
  4099. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4100. if err != nil {
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4102. return
  4103. }
  4104. recordEndTime := theEndTime.Unix()
  4105. end_time = recordEndTime
  4106. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4107. data["pre"] = prescriptions
  4108. }
  4109. timestamp := time.Now().Unix()
  4110. tempTime := time.Unix(timestamp, 0)
  4111. timeFormat := tempTime.Format("20060102150405")
  4112. chrgBchno := rand.Intn(100000) + 10000
  4113. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4114. strconv.FormatInt(his.PatientId, 10)
  4115. client := &http.Client{}
  4116. data["psn_no"] = his.PsnNo
  4117. data["mdtrt_id"] = his.Number
  4118. data["chrg_bchno"] = chrg_bchno
  4119. data["org_name"] = miConfig.OrgName
  4120. data["doctor"] = roles.UserName
  4121. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4122. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4123. data["fixmedins_code"] = miConfig.Code
  4124. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4125. // data["dept_code"] = "15"
  4126. //} else {
  4127. data["dept_code"] = department.Number
  4128. //}
  4129. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4130. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4131. data["secret_key"] = miConfig.SecretKey
  4132. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4133. data["url"] = miConfig.Url
  4134. data["ak"] = miConfig.AccessKey
  4135. data["new_doctor_name"] = patientPrescription.Doctor
  4136. data["diag_code"] = sickConfig.CountryCode
  4137. data["cainfo"] = miConfig.Cainfo
  4138. var ids []int64
  4139. for _, item := range prescriptions {
  4140. ids = append(ids, item.ID)
  4141. }
  4142. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4143. if config.IsOpen == 1 { //对接了医保,走医保流程
  4144. var res ResultFour
  4145. var resFour10265 ResultFour10265
  4146. if miConfig.MdtrtareaAdmvs == "421300" {
  4147. bytesData, _ := json.Marshal(data)
  4148. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4149. resp, _ := client.Do(req)
  4150. defer resp.Body.Close()
  4151. body, ioErr := ioutil.ReadAll(resp.Body)
  4152. if ioErr != nil {
  4153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4155. return
  4156. }
  4157. var respJSON map[string]interface{}
  4158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4164. userJSONBytes, _ := json.Marshal(respJSON)
  4165. fmt.Println("log")
  4166. fmt.Println(string(userJSONBytes))
  4167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4168. utils.ErrorLog("解析失败:%v", err)
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. return
  4171. }
  4172. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4173. bytesData, _ := json.Marshal(data)
  4174. var req *http.Request
  4175. if miConfig.MdtrtareaAdmvs == "320921" {
  4176. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4177. } else {
  4178. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4179. }
  4180. resp, _ := client.Do(req)
  4181. defer resp.Body.Close()
  4182. body, ioErr := ioutil.ReadAll(resp.Body)
  4183. if ioErr != nil {
  4184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4186. return
  4187. }
  4188. var respJSON map[string]interface{}
  4189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. return
  4193. }
  4194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4195. userJSONBytes, _ := json.Marshal(respJSON)
  4196. fmt.Println("log")
  4197. fmt.Println(string(userJSONBytes))
  4198. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4199. utils.ErrorLog("解析失败:%v", err)
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. return
  4202. }
  4203. res.InfRefmsgid = resFour10265.InfRefmsgid
  4204. res.Output = resFour10265.Output
  4205. res.ErrMsg = resFour10265.ErrMsg
  4206. res.Cainfo = resFour10265.Cainfo
  4207. res.WarnMsg = resFour10265.WarnMsg
  4208. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4209. res.Infcode = infocode
  4210. } else {
  4211. if miConfig.Code == "H15049901371" {
  4212. 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)
  4213. var dat map[string]interface{}
  4214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4215. fmt.Println(dat)
  4216. } else {
  4217. fmt.Println(err)
  4218. }
  4219. saveLog(result, request_log, "2204", "上传费用明细")
  4220. userJSONBytes, _ := json.Marshal(dat)
  4221. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4222. utils.ErrorLog("解析失败:%v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. res.InfRefmsgid = resFour10265.InfRefmsgid
  4227. res.Output = resFour10265.Output
  4228. res.ErrMsg = resFour10265.ErrMsg
  4229. res.Cainfo = resFour10265.Cainfo
  4230. res.WarnMsg = resFour10265.WarnMsg
  4231. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4232. res.Infcode = infocode
  4233. } else {
  4234. 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)
  4235. var dat map[string]interface{}
  4236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4237. fmt.Println(dat)
  4238. } else {
  4239. fmt.Println(err)
  4240. }
  4241. saveLog(result, request_log, "2204", "上传费用明细")
  4242. userJSONBytes, _ := json.Marshal(dat)
  4243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4244. utils.ErrorLog("解析失败:%v", err)
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4246. return
  4247. }
  4248. }
  4249. }
  4250. if res.Infcode == 0 {
  4251. order := &models.HisOrder{
  4252. UserOrgId: adminUser.CurrentOrgId,
  4253. HisPatientId: his.ID,
  4254. PatientId: his.PatientId,
  4255. SettleAccountsDate: recordDateTime,
  4256. MdtrtId: his.Number,
  4257. PsnNo: his.PsnNo,
  4258. MedType: strconv.FormatInt(reg_type, 10),
  4259. Ctime: time.Now().Unix(),
  4260. Mtime: time.Now().Unix(),
  4261. Status: 1,
  4262. Number: chrg_bchno,
  4263. Infcode: res.Infcode,
  4264. WarnMsg: res.WarnMsg,
  4265. Cainfo: res.Cainfo,
  4266. ErrMsg: res.ErrMsg,
  4267. RespondTime: res.RefmsgTime,
  4268. InfRefmsgid: res.InfRefmsgid,
  4269. OrderStatus: 1,
  4270. PayWay: pay_way,
  4271. PayPrice: pay_price,
  4272. PayCardNo: pay_card_no,
  4273. DiscountPrice: discount_price,
  4274. PreferentialPrice: preferential_price,
  4275. RealityPrice: reality_price,
  4276. FoundPrice: found_price,
  4277. MedicalInsurancePrice: medical_insurance_price,
  4278. PrivatePrice: private_price,
  4279. IsMedicineInsurance: 1,
  4280. SettleType: settle_accounts_type,
  4281. SettleStartTime: start_time,
  4282. SettleEndTime: end_time,
  4283. Creator: roles.AdminUserId,
  4284. Modify: roles.AdminUserId,
  4285. FaPiaoNumber: fapiao_number,
  4286. FaPiaoCode: fapiao_code,
  4287. PType: 2,
  4288. Diagnosis: diagnosis_id,
  4289. }
  4290. err = service.CreateOrder(order)
  4291. if err != nil {
  4292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4293. return
  4294. }
  4295. for _, item := range res.Output.Result {
  4296. temp := strings.Split(item.FeedetlSn, "-")
  4297. var advice_id int64 = 0
  4298. var project_id int64 = 0
  4299. var types int64 = 0
  4300. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4301. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4302. if temp[1] == "1" {
  4303. advice_id = id
  4304. project_id = 0
  4305. } else if temp[1] == "2" {
  4306. advice_id = 0
  4307. project_id = id
  4308. }
  4309. info := &models.HisOrderInfo{
  4310. OrderNumber: order.Number,
  4311. FeedetlSn: item.FeedetlSn,
  4312. UploadDate: time.Now().Unix(),
  4313. AdviceId: advice_id,
  4314. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4315. Cnt: item.Cnt,
  4316. Pric: float64(item.Pric),
  4317. PatientId: his.PatientId,
  4318. PricUplmtAmt: item.PricUplmtAmt,
  4319. SelfpayProp: item.SelfpayProp,
  4320. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4321. OverlmtAmt: item.OverlmtAmt,
  4322. PreselfpayAmt: item.PreselfpayAmt,
  4323. BasMednFlag: item.BasMednFlag,
  4324. MedChrgitmType: item.MedChrgitmType,
  4325. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4326. Status: 1,
  4327. Memo: item.Memo,
  4328. Mtime: time.Now().Unix(),
  4329. InscpScpAmt: item.InscpScpAmt,
  4330. DrtReimFlag: item.DrtReimFlag,
  4331. Ctime: time.Now().Unix(),
  4332. ListSpItemFlag: item.ListSpItemFlag,
  4333. ChldMedcFlag: item.ChldMedcFlag,
  4334. LmtUsedFlag: item.LmtUsedFlag,
  4335. ChrgitmLv: item.ChrgitmLv,
  4336. UserOrgId: adminUser.CurrentOrgId,
  4337. HisPatientId: his.ID,
  4338. OrderId: order.ID,
  4339. ProjectId: project_id,
  4340. Type: types,
  4341. }
  4342. service.CreateOrderInfo(info)
  4343. }
  4344. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4345. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4346. var total float64
  4347. for _, item := range prescriptions {
  4348. if item.Type == 1 { //药品
  4349. for _, subItem := range item.HisDoctorAdviceInfo {
  4350. total = total + (subItem.Price * subItem.PrescribingNumber)
  4351. }
  4352. }
  4353. if item.Type == 2 { //项目
  4354. for _, subItem := range item.HisPrescriptionProject {
  4355. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4356. total = total + (subItem.Price * cnt)
  4357. }
  4358. }
  4359. }
  4360. for _, item := range prescriptions {
  4361. for _, subItem := range item.HisAdditionalCharge {
  4362. total = total + (subItem.Price * float64(subItem.Count))
  4363. }
  4364. }
  4365. var allTotal string
  4366. if adminUser.CurrentOrgId == 9919 {
  4367. allTotal = fmt.Sprintf("%.4f", total)
  4368. } else {
  4369. allTotal = fmt.Sprintf("%.4f", total)
  4370. }
  4371. if res.Infcode == 0 {
  4372. var rf []*ResultFive
  4373. json.Unmarshal([]byte(his.Iinfo), &rf)
  4374. chrg_bchno := chrg_bchno
  4375. cert_no := his.Certno
  4376. var insutypes []string
  4377. var insutype string
  4378. var is390 int = 0
  4379. var is310 int = 0
  4380. for _, item := range rf {
  4381. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4382. insutypes = append(insutypes, item.Insutype)
  4383. }
  4384. }
  4385. if len(insutypes) == 1 {
  4386. insutype = insutypes[0]
  4387. } else {
  4388. for _, i := range insutypes {
  4389. if i == "390" {
  4390. is390 = 1
  4391. }
  4392. if i == "310" {
  4393. is310 = 1
  4394. }
  4395. }
  4396. }
  4397. if is390 == 1 {
  4398. insutype = "390"
  4399. }
  4400. if is310 == 1 {
  4401. insutype = "310"
  4402. }
  4403. if len(insutypes) == 0 {
  4404. insutype = "310"
  4405. }
  4406. if len(insutypes) == 2 {
  4407. insutype = strconv.FormatInt(his.SocialType, 10)
  4408. }
  4409. insutype = strconv.FormatInt(his.SocialType, 10)
  4410. //insutype = "390"
  4411. if his.IdCardType == 1 {
  4412. // cert_no = his.MedicalInsuranceNumber
  4413. cert_no = his.Certno
  4414. } else {
  4415. cert_no = his.Certno
  4416. }
  4417. var res ResultSeven
  4418. var resSeven10265 ResultSeven10265
  4419. var src_resquest string
  4420. var result2 string
  4421. var acct_used_flag string
  4422. fmt.Println("pay_way")
  4423. fmt.Println(pay_way)
  4424. fmt.Println("pay_way")
  4425. if pay_way == 4 {
  4426. acct_used_flag = "1"
  4427. } else {
  4428. acct_used_flag = "0"
  4429. }
  4430. if miConfig.MdtrtareaAdmvs == "421300" {
  4431. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4432. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4433. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4434. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4435. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4436. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4437. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4438. resp, requestErr := http.Get(api)
  4439. if requestErr != nil {
  4440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4441. return
  4442. }
  4443. body, ioErr := ioutil.ReadAll(resp.Body)
  4444. if ioErr != nil {
  4445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4447. return
  4448. }
  4449. var respJSON map[string]interface{}
  4450. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4453. return
  4454. }
  4455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4456. result, _ := json.Marshal(respJSON)
  4457. if miConfig.Code == "H15049901371" {
  4458. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4459. utils.ErrorLog("解析失败:%v", err)
  4460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4461. return
  4462. }
  4463. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4464. res.Output = resSeven10265.Output
  4465. res.ErrMsg = resSeven10265.ErrMsg
  4466. res.Cainfo = resSeven10265.Cainfo
  4467. res.WarnMsg = resSeven10265.WarnMsg
  4468. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4469. res.Infcode = infocode
  4470. } else {
  4471. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4472. utils.ErrorLog("解析失败:%v", err)
  4473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4474. return
  4475. }
  4476. }
  4477. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4478. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4479. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4480. //psn_info, _ := service.GetPsnByPatientId(id)
  4481. bas := strings.Split(psn_info.CardInfo, "|")
  4482. if his.IdCardType == 1 {
  4483. cert_no = bas[2]
  4484. } else if his.IdCardType == 3 {
  4485. cert_no = his.Certno
  4486. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  4487. } else {
  4488. cert_no = bas[1]
  4489. }
  4490. //江苏地区国家医保医疗类别
  4491. //职工透析:医疗类别选特殊情况门诊9933
  4492. //居民血透门慢: 医疗类别选门诊慢病1402
  4493. //var med_type string
  4494. //if his.Insutype == "310" {
  4495. // if reg_type == 14 {
  4496. // med_type = "9933"
  4497. // } else if reg_type == 11 {
  4498. // med_type = "11"
  4499. //
  4500. // }
  4501. //} else if his.Insutype == "390" {
  4502. // if reg_type == 14 {
  4503. // med_type = "1402"
  4504. // } else if reg_type == 11 {
  4505. // med_type = "11"
  4506. // }
  4507. //}
  4508. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4509. var api string
  4510. if miConfig.MdtrtareaAdmvs == "320921" {
  4511. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4517. "&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
  4518. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4519. } else {
  4520. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4521. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4522. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4523. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4525. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4526. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4527. "&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
  4528. }
  4529. resp, requestErr := http.Get(api)
  4530. if requestErr != nil {
  4531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4532. return
  4533. }
  4534. body, ioErr := ioutil.ReadAll(resp.Body)
  4535. if ioErr != nil {
  4536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4538. return
  4539. }
  4540. var respJSON map[string]interface{}
  4541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4544. return
  4545. }
  4546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4547. result, _ := json.Marshal(respJSON)
  4548. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4549. utils.ErrorLog("解析失败:%v", err)
  4550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. return
  4552. }
  4553. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4554. res.Output = resSeven10265.Output
  4555. res.ErrMsg = resSeven10265.ErrMsg
  4556. res.Cainfo = resSeven10265.Cainfo
  4557. res.WarnMsg = resSeven10265.WarnMsg
  4558. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4559. res.Infcode = infocode
  4560. } else {
  4561. if miConfig.Code == "H15049901371" {
  4562. //赤峰地区国家医保医疗类别
  4563. //职工透析:医疗类别选特殊情况门诊990502
  4564. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4565. var med_type string
  4566. if his.Insutype == "390" {
  4567. if reg_type == 14 {
  4568. med_type = "9933"
  4569. } else if reg_type == 11 {
  4570. med_type = "11"
  4571. }
  4572. } else if his.Insutype == "310" {
  4573. if reg_type == 14 {
  4574. med_type = "990502"
  4575. } else if reg_type == 11 {
  4576. med_type = "11"
  4577. }
  4578. }
  4579. 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)
  4580. } else {
  4581. 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)
  4582. }
  4583. //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)
  4584. var dat map[string]interface{}
  4585. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4586. fmt.Println(dat)
  4587. } else {
  4588. fmt.Println(err)
  4589. }
  4590. saveLog(result2, src_resquest, "2207", "结算")
  4591. userJSONBytes, _ := json.Marshal(dat)
  4592. if miConfig.Code == "H15049901371" {
  4593. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4594. utils.ErrorLog("解析失败:%v", err)
  4595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4596. return
  4597. }
  4598. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4599. res.Output = resSeven10265.Output
  4600. res.ErrMsg = resSeven10265.ErrMsg
  4601. res.Cainfo = resSeven10265.Cainfo
  4602. res.WarnMsg = resSeven10265.WarnMsg
  4603. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4604. res.Infcode = infocode
  4605. } else {
  4606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. }
  4612. }
  4613. if res.Infcode != 0 {
  4614. errlog := &models.HisOrderError{
  4615. UserOrgId: adminUser.CurrentOrgId,
  4616. Ctime: time.Now().Unix(),
  4617. Mtime: time.Now().Unix(),
  4618. Number: chrg_bchno,
  4619. ErrMsg: res.ErrMsg,
  4620. Status: 1,
  4621. PatientId: id,
  4622. RecordTime: recordDateTime,
  4623. Stage: 6,
  4624. }
  4625. service.CreateErrMsgLog(errlog)
  4626. c.ServeSuccessJSON(map[string]interface{}{
  4627. "failed_code": -10,
  4628. "msg": res.ErrMsg,
  4629. })
  4630. return
  4631. } else {
  4632. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4633. order.OrderStatus = 2
  4634. order.Status = 1
  4635. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4636. order.SetlId = res.Output.Setlinfo.SetlID
  4637. order.PsnNo = res.Output.Setlinfo.PsnNo
  4638. order.PsnName = res.Output.Setlinfo.PsnName
  4639. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4640. order.Certno = res.Output.Setlinfo.Certno
  4641. order.Gend = res.Output.Setlinfo.Gend
  4642. order.Naty = res.Output.Setlinfo.Naty
  4643. order.Age = res.Output.Setlinfo.Age
  4644. order.Insutype = res.Output.Setlinfo.Insutype
  4645. order.PsnType = res.Output.Setlinfo.PsnType
  4646. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4647. order.SetlTime = res.Output.Setlinfo.SetlTime
  4648. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4649. if res.Output.Setlinfo.MedType == "140101" {
  4650. order.MedType = "14"
  4651. } else {
  4652. order.MedType = res.Output.Setlinfo.MedType
  4653. }
  4654. if reg_type == 1112 {
  4655. order.MedType = "1112"
  4656. }
  4657. if reg_type == 1111 {
  4658. order.MedType = "1111"
  4659. }
  4660. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4661. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4662. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4663. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4664. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4665. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4666. order.HifpPay = res.Output.Setlinfo.HifpPay
  4667. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4668. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4669. order.HifesPay = res.Output.Setlinfo.HifesPay
  4670. order.HifobPay = res.Output.Setlinfo.HifobPay
  4671. order.MafPay = res.Output.Setlinfo.MafPay
  4672. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4673. order.OthPay = res.Output.Setlinfo.OthPay
  4674. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4675. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4676. order.AcctPay = res.Output.Setlinfo.AcctPay
  4677. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4678. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4679. order.Balc = res.Output.Setlinfo.Balc
  4680. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4681. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4682. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4683. order.ClrType = res.Output.Setlinfo.ClrType
  4684. order.ClrWay = res.Output.Setlinfo.ClrWay
  4685. order.Creator = order.Creator
  4686. order.Modify = roles.AdminUserId
  4687. order.RequestLog = src_resquest
  4688. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4689. detailStr := string(setlDetail)
  4690. order.SetlDetail = detailStr
  4691. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4692. err = service.UpDateOrder(order)
  4693. if err == nil {
  4694. c.ServeSuccessJSON(map[string]interface{}{
  4695. "msg": "结算成功",
  4696. })
  4697. } else {
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4699. return
  4700. }
  4701. }
  4702. } else {
  4703. adminUser := c.GetAdminUserInfo()
  4704. errlog := &models.HisOrderError{
  4705. UserOrgId: adminUser.CurrentOrgId,
  4706. Ctime: time.Now().Unix(),
  4707. Mtime: time.Now().Unix(),
  4708. ErrMsg: res.ErrMsg,
  4709. Status: 1,
  4710. PatientId: id,
  4711. RecordTime: recordDateTime,
  4712. Stage: 4,
  4713. }
  4714. service.CreateErrMsgLog(errlog)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4716. return
  4717. }
  4718. } else {
  4719. adminUser := c.GetAdminUserInfo()
  4720. errlog := &models.HisOrderError{
  4721. UserOrgId: adminUser.CurrentOrgId,
  4722. Ctime: time.Now().Unix(),
  4723. Mtime: time.Now().Unix(),
  4724. ErrMsg: res.ErrMsg,
  4725. Status: 1,
  4726. PatientId: id,
  4727. RecordTime: recordDateTime,
  4728. Stage: 4,
  4729. }
  4730. service.CreateErrMsgLog(errlog)
  4731. c.ServeSuccessJSON(map[string]interface{}{
  4732. "failed_code": -10,
  4733. "msg": res.ErrMsg,
  4734. })
  4735. return
  4736. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4737. //return
  4738. }
  4739. }
  4740. }
  4741. } else if tempOrder.ID > 0 {
  4742. if tempOrder.IsPre == 1 {
  4743. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4744. var rf []*ResultFive
  4745. json.Unmarshal([]byte(his.Iinfo), &rf)
  4746. chrg_bchno := tempOrder.Number
  4747. cert_no := his.Certno
  4748. var insutypes []string
  4749. var insutype string
  4750. var is390 int = 0
  4751. var is310 int = 0
  4752. for _, item := range rf {
  4753. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4754. insutypes = append(insutypes, item.Insutype)
  4755. }
  4756. }
  4757. if len(insutypes) == 1 {
  4758. insutype = insutypes[0]
  4759. } else {
  4760. for _, i := range insutypes {
  4761. if i == "390" {
  4762. is390 = 1
  4763. }
  4764. if i == "310" {
  4765. is310 = 1
  4766. }
  4767. }
  4768. }
  4769. if is390 == 1 {
  4770. insutype = "390"
  4771. }
  4772. if is310 == 1 {
  4773. insutype = "310"
  4774. }
  4775. if len(insutypes) == 0 {
  4776. insutype = "310"
  4777. }
  4778. if len(insutypes) == 2 {
  4779. insutype = strconv.FormatInt(his.SocialType, 64)
  4780. }
  4781. //insutype = "390"
  4782. if his.IdCardType == 1 {
  4783. // cert_no = his.MedicalInsuranceNumber
  4784. cert_no = his.Certno
  4785. } else {
  4786. cert_no = his.Certno
  4787. }
  4788. var res ResultSeven
  4789. var resSeven10265 ResultSeven10265
  4790. var src_resquest string
  4791. var result2 string
  4792. var acct_used_flag string
  4793. fmt.Println("pay_way")
  4794. fmt.Println(pay_way)
  4795. fmt.Println("pay_way")
  4796. if pay_way == 4 {
  4797. acct_used_flag = "1"
  4798. } else {
  4799. acct_used_flag = "0"
  4800. }
  4801. if miConfig.MdtrtareaAdmvs == "421300" {
  4802. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4803. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4804. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4805. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4806. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4807. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4808. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4809. resp, requestErr := http.Get(api)
  4810. if requestErr != nil {
  4811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4812. return
  4813. }
  4814. body, ioErr := ioutil.ReadAll(resp.Body)
  4815. if ioErr != nil {
  4816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. var respJSON map[string]interface{}
  4821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4824. return
  4825. }
  4826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4827. result, _ := json.Marshal(respJSON)
  4828. fmt.Println("log")
  4829. fmt.Println(string(result))
  4830. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4831. utils.ErrorLog("解析失败:%v", err)
  4832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4833. return
  4834. }
  4835. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4836. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4837. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4838. //psn_info, _ := service.GetPsnByPatientId(id)
  4839. bas := strings.Split(psn_info.CardInfo, "|")
  4840. if his.IdCardType == 1 {
  4841. cert_no = bas[2]
  4842. } else {
  4843. cert_no = bas[1]
  4844. }
  4845. //江苏地区国家医保医疗类别
  4846. //职工透析:医疗类别选特殊情况门诊9933
  4847. //居民血透门慢: 医疗类别选门诊慢病1402
  4848. //var med_type string
  4849. //if his.Insutype == "310" {
  4850. // if reg_type == 14 {
  4851. // med_type = "9933"
  4852. // } else if reg_type == 11 {
  4853. // med_type = "11"
  4854. //
  4855. // }
  4856. //} else if his.Insutype == "390" {
  4857. // if reg_type == 14 {
  4858. // med_type = "1402"
  4859. // } else if reg_type == 11 {
  4860. // med_type = "11"
  4861. // }
  4862. //}
  4863. var api string
  4864. if miConfig.MdtrtareaAdmvs == "320921" {
  4865. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4866. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4867. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4869. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4870. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4871. "&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
  4872. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4873. } else {
  4874. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4875. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4876. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4877. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4878. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4879. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4880. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4881. "&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
  4882. }
  4883. resp, requestErr := http.Get(api)
  4884. if requestErr != nil {
  4885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4886. return
  4887. }
  4888. body, ioErr := ioutil.ReadAll(resp.Body)
  4889. if ioErr != nil {
  4890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4892. return
  4893. }
  4894. var respJSON map[string]interface{}
  4895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4898. return
  4899. }
  4900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4901. result, _ := json.Marshal(respJSON)
  4902. fmt.Println("log")
  4903. fmt.Println(string(result))
  4904. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4905. utils.ErrorLog("解析失败:%v", err)
  4906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4907. return
  4908. }
  4909. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4910. res.Output = resSeven10265.Output
  4911. res.ErrMsg = resSeven10265.ErrMsg
  4912. res.Cainfo = resSeven10265.Cainfo
  4913. res.WarnMsg = resSeven10265.WarnMsg
  4914. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4915. res.Infcode = infocode
  4916. } else {
  4917. var src_resquest string
  4918. if miConfig.Code == "H15049901371" {
  4919. //赤峰地区国家医保医疗类别
  4920. //职工透析:医疗类别选特殊情况门诊990502
  4921. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4922. var med_type string
  4923. if his.Insutype == "390" {
  4924. if reg_type == 14 {
  4925. med_type = "9933"
  4926. } else if reg_type == 11 {
  4927. med_type = "11"
  4928. }
  4929. } else if his.Insutype == "310" {
  4930. if reg_type == 14 {
  4931. med_type = "990502"
  4932. } else if reg_type == 11 {
  4933. med_type = "11"
  4934. }
  4935. }
  4936. 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)
  4937. } else {
  4938. 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)
  4939. }
  4940. var dat map[string]interface{}
  4941. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4942. fmt.Println(dat)
  4943. } else {
  4944. fmt.Println(err)
  4945. }
  4946. saveLog(result2, src_resquest, "2207", "结算")
  4947. userJSONBytes, _ := json.Marshal(dat)
  4948. if miConfig.Code == "H15049901371" {
  4949. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4950. utils.ErrorLog("解析失败:%v", err)
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4952. return
  4953. }
  4954. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4955. res.Output = resSeven10265.Output
  4956. res.ErrMsg = resSeven10265.ErrMsg
  4957. res.Cainfo = resSeven10265.Cainfo
  4958. res.WarnMsg = resSeven10265.WarnMsg
  4959. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4960. res.Infcode = infocode
  4961. } else {
  4962. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4963. utils.ErrorLog("解析失败:%v", err)
  4964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4965. return
  4966. }
  4967. }
  4968. }
  4969. if res.Infcode != 0 {
  4970. errlog := &models.HisOrderError{
  4971. UserOrgId: adminUser.CurrentOrgId,
  4972. Ctime: time.Now().Unix(),
  4973. Mtime: time.Now().Unix(),
  4974. Number: chrg_bchno,
  4975. ErrMsg: res.ErrMsg,
  4976. Status: 1,
  4977. PatientId: id,
  4978. RecordTime: recordDateTime,
  4979. Stage: 6,
  4980. }
  4981. service.CreateErrMsgLog(errlog)
  4982. c.ServeSuccessJSON(map[string]interface{}{
  4983. "failed_code": -10,
  4984. "msg": res.ErrMsg,
  4985. })
  4986. return
  4987. } else {
  4988. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4989. order.OrderStatus = 2
  4990. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4991. order.SetlId = res.Output.Setlinfo.SetlID
  4992. order.PsnNo = res.Output.Setlinfo.PsnNo
  4993. order.PsnName = res.Output.Setlinfo.PsnName
  4994. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4995. order.Certno = res.Output.Setlinfo.Certno
  4996. order.Gend = res.Output.Setlinfo.Gend
  4997. order.Naty = res.Output.Setlinfo.Naty
  4998. order.Age = res.Output.Setlinfo.Age
  4999. order.Insutype = res.Output.Setlinfo.Insutype
  5000. order.PsnType = res.Output.Setlinfo.PsnType
  5001. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5002. order.SetlTime = res.Output.Setlinfo.SetlTime
  5003. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5004. //order.MedType = res.Output.Setlinfo.MedType
  5005. if reg_type == 1112 {
  5006. order.MedType = "1112"
  5007. }
  5008. if reg_type == 1111 {
  5009. order.MedType = "1111"
  5010. }
  5011. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5012. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5013. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5014. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5015. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5016. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5017. order.HifpPay = res.Output.Setlinfo.HifpPay
  5018. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5019. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5020. order.HifesPay = res.Output.Setlinfo.HifesPay
  5021. order.HifobPay = res.Output.Setlinfo.HifobPay
  5022. order.MafPay = res.Output.Setlinfo.MafPay
  5023. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5024. order.OthPay = res.Output.Setlinfo.OthPay
  5025. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5026. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5027. order.AcctPay = res.Output.Setlinfo.AcctPay
  5028. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5029. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5030. order.Balc = res.Output.Setlinfo.Balc
  5031. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5032. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5033. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5034. order.ClrWay = res.Output.Setlinfo.ClrWay
  5035. order.Creator = order.Creator
  5036. order.Modify = roles.AdminUserId
  5037. order.RequestLog = src_resquest
  5038. order.Diagnosis = diagnosis_id
  5039. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5040. detailStr := string(setlDetail)
  5041. order.SetlDetail = detailStr
  5042. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5043. err = service.UpDateOrder(order)
  5044. if err == nil {
  5045. c.ServeSuccessJSON(map[string]interface{}{
  5046. "msg": "结算成功",
  5047. })
  5048. } else {
  5049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5050. return
  5051. }
  5052. }
  5053. }
  5054. }
  5055. }
  5056. //func (c *HisApiController) GetPreUploadInfo() {
  5057. // id, _ := c.GetInt64("id")
  5058. // record_time := c.GetString("record_time")
  5059. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5060. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5061. //
  5062. // timeLayout := "2006-01-02"
  5063. // loc, _ := time.LoadLocation("Local")
  5064. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5065. // if err != nil {
  5066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5067. // return
  5068. // }
  5069. // recordDateTime := theTime.Unix()
  5070. // adminUser := c.GetAdminUserInfo()
  5071. //
  5072. // var prescriptions []*models.HisPrescription
  5073. //
  5074. // var start_time int64
  5075. // var end_time int64
  5076. //
  5077. // data := make(map[string]interface{})
  5078. // if settle_accounts_type == 1 { //日结
  5079. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5080. // data["pre"] = prescriptions
  5081. //
  5082. // } else { //月结
  5083. // start_time_str := c.GetString("start_time")
  5084. // end_time_str := c.GetString("end_time")
  5085. // timeLayout := "2006-01-02"
  5086. // loc, _ := time.LoadLocation("Local")
  5087. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5088. // if err != nil {
  5089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5090. // return
  5091. // }
  5092. // recordStartTime := theStartTime.Unix()
  5093. // start_time = recordStartTime
  5094. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5095. // if err != nil {
  5096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5097. // return
  5098. // }
  5099. // recordEndTime := theEndTime.Unix()
  5100. // end_time = recordEndTime
  5101. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5102. // data["pre"] = prescriptions
  5103. //
  5104. // }
  5105. //
  5106. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5107. //
  5108. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5109. // timestamp := time.Now().Unix()
  5110. // tempTime := time.Unix(timestamp, 0)
  5111. // timeFormat := tempTime.Format("20060102150405")
  5112. // chrgBchno := rand.Intn(100000) + 10000
  5113. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5114. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5115. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5116. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5117. // strconv.FormatInt(his.PatientId, 10)
  5118. // client := &http.Client{}
  5119. // data["psn_no"] = his.PsnNo
  5120. // data["mdtrt_id"] = his.Number
  5121. // data["chrg_bchno"] = chrg_bchno
  5122. // data["org_name"] = miConfig.OrgName
  5123. // data["doctor"] = roles.UserName
  5124. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5125. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5126. // data["fixmedins_code"] = miConfig.Code
  5127. // data["dept_code"] = department.Number
  5128. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5129. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5130. // data["secret_key"] = miConfig.SecretKey
  5131. // var ids []int64
  5132. //
  5133. // for _, item := range prescriptions {
  5134. // ids = append(ids, item.ID)
  5135. // }
  5136. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5137. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5138. // bytesData, _ := json.Marshal(data)
  5139. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5140. // resp, _ := client.Do(req)
  5141. // defer resp.Body.Close()
  5142. // body, ioErr := ioutil.ReadAll(resp.Body)
  5143. // if ioErr != nil {
  5144. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5146. // return
  5147. // }
  5148. // var respJSON map[string]interface{}
  5149. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5150. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5152. // return
  5153. // }
  5154. //
  5155. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5156. // userJSONBytes, _ := json.Marshal(respJSON)
  5157. // var res ResultFour
  5158. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5159. // utils.ErrorLog("解析失败:%v", err)
  5160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. // return
  5162. // }
  5163. //
  5164. // if res.Infcode == 0 {
  5165. // order := &models.HisOrder{
  5166. // UserOrgId: adminUser.CurrentOrgId,
  5167. // HisPatientId: his.ID,
  5168. // PatientId: his.PatientId,
  5169. // SettleAccountsDate: recordDateTime,
  5170. // Ctime: time.Now().Unix(),
  5171. // Mtime: time.Now().Unix(),
  5172. // Status: 1,
  5173. // Number: chrg_bchno,
  5174. // Infcode: res.Infcode,
  5175. // WarnMsg: res.WarnMsg,
  5176. // Cainfo: res.Cainfo,
  5177. // ErrMsg: res.ErrMsg,
  5178. // RespondTime: res.RefmsgTime,
  5179. // InfRefmsgid: res.InfRefmsgid,
  5180. // OrderStatus: 1,
  5181. // IsMedicineInsurance: 1,
  5182. // SettleType: settle_accounts_type,
  5183. // SettleStartTime: start_time,
  5184. // SettleEndTime: end_time,
  5185. // Creator: roles.ID,
  5186. // Modify: roles.ID,
  5187. // PType: 2,
  5188. // }
  5189. // err = service.CreateOrder(order)
  5190. // if err != nil {
  5191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5192. // return
  5193. // }
  5194. //
  5195. // for _, item := range res.Output.Result {
  5196. // temp := strings.Split(item.FeedetlSn, "-")
  5197. // var advice_id int64 = 0
  5198. // var project_id int64 = 0
  5199. // var types int64 = 0
  5200. //
  5201. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5202. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5203. //
  5204. // if temp[1] == "1" {
  5205. // advice_id = id
  5206. // project_id = 0
  5207. // } else if temp[1] == "2" {
  5208. // advice_id = 0
  5209. // project_id = id
  5210. // }
  5211. //
  5212. // info := &models.HisOrderInfo{
  5213. // OrderNumber: order.Number,
  5214. // FeedetlSn: item.FeedetlSn,
  5215. // UploadDate: time.Now().Unix(),
  5216. // AdviceId: advice_id,
  5217. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5218. // Cnt: item.Cnt,
  5219. // Pric: float64(item.Pric),
  5220. // PatientId: his.PatientId,
  5221. // PricUplmtAmt: item.PricUplmtAmt,
  5222. // SelfpayProp: item.SelfpayProp,
  5223. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5224. // OverlmtAmt: item.OverlmtAmt,
  5225. // PreselfpayAmt: item.PreselfpayAmt,
  5226. // BasMednFlag: item.BasMednFlag,
  5227. // MedChrgitmType: item.MedChrgitmType,
  5228. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5229. // Status: 1,
  5230. // Memo: item.Memo,
  5231. // Mtime: time.Now().Unix(),
  5232. // InscpScpAmt: item.InscpScpAmt,
  5233. // DrtReimFlag: item.DrtReimFlag,
  5234. // Ctime: time.Now().Unix(),
  5235. // ListSpItemFlag: item.ListSpItemFlag,
  5236. // ChldMedcFlag: item.ChldMedcFlag,
  5237. // LmtUsedFlag: item.LmtUsedFlag,
  5238. // ChrgitmLv: item.ChrgitmLv,
  5239. // UserOrgId: adminUser.CurrentOrgId,
  5240. // HisPatientId: his.ID,
  5241. // OrderId: order.ID,
  5242. // ProjectId: project_id,
  5243. // Type: types,
  5244. // }
  5245. // service.CreateOrderInfo(info)
  5246. //
  5247. // }
  5248. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5249. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5250. //
  5251. // var total float64
  5252. // for _, item := range prescriptions {
  5253. // if item.Type == 1 { //药品
  5254. // for _, subItem := range item.HisDoctorAdviceInfo {
  5255. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5256. // }
  5257. // }
  5258. // if item.Type == 2 { //项目
  5259. // for _, subItem := range item.HisPrescriptionProject {
  5260. // total = total + (subItem.Price * float64(subItem.Count))
  5261. // }
  5262. // }
  5263. // }
  5264. //
  5265. // for _, item := range prescriptions {
  5266. // for _, subItem := range item.HisAdditionalCharge {
  5267. // total = total + (subItem.Price * float64(subItem.Count))
  5268. // }
  5269. // }
  5270. //
  5271. // allTotal := fmt.Sprintf("%.2f", total)
  5272. // if res.Infcode == 0 {
  5273. // var rf []*ResultFive
  5274. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5275. // psn_no := his.PsnNo
  5276. // mdtrt_id := his.Number
  5277. // chrg_bchno := chrg_bchno
  5278. // cert_no := his.Certno
  5279. // insutype := rf[0].Insutype
  5280. //
  5281. // if his.IdCardType == 1 {
  5282. // cert_no = his.MedicalInsuranceNumber
  5283. //
  5284. // } else {
  5285. //
  5286. // cert_no = his.Certno
  5287. //
  5288. // }
  5289. //
  5290. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5291. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5292. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5293. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5294. // resp, requestErr := http.Get(api)
  5295. // if requestErr != nil {
  5296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. // return
  5298. // }
  5299. // defer resp.Body.Close()
  5300. // body, ioErr := ioutil.ReadAll(resp.Body)
  5301. // if ioErr != nil {
  5302. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5304. // return
  5305. // }
  5306. // var respJSON map[string]interface{}
  5307. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5308. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5310. // return
  5311. // }
  5312. // fmt.Println(respJSON)
  5313. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5314. // userJSONBytes, _ := json.Marshal(respJSON)
  5315. // var res ResultSeven
  5316. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5317. // utils.ErrorLog("解析失败:%v", err)
  5318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. // return
  5320. // }
  5321. // if res.Infcode != 0 {
  5322. // errlog := &models.HisOrderError{
  5323. // UserOrgId: adminUser.CurrentOrgId,
  5324. // Ctime: time.Now().Unix(),
  5325. // Mtime: time.Now().Unix(),
  5326. // Number: chrg_bchno,
  5327. // ErrMsg: res.ErrMsg,
  5328. // Status: 1,
  5329. // PatientId: id,
  5330. // RecordTime: recordDateTime,
  5331. // Stage: 7,
  5332. // }
  5333. // service.CreateErrMsgLog(errlog)
  5334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5335. // return
  5336. // } else {
  5337. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5338. // order.OrderStatus = 1
  5339. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5340. // order.SetlId = res.Output.Setlinfo.SetlID
  5341. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5342. // order.PsnName = res.Output.Setlinfo.PsnName
  5343. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5344. // order.Certno = res.Output.Setlinfo.Certno
  5345. // order.Gend = res.Output.Setlinfo.Gend
  5346. // order.Naty = res.Output.Setlinfo.Naty
  5347. // order.Age = res.Output.Setlinfo.Age
  5348. // order.Insutype = res.Output.Setlinfo.Insutype
  5349. // order.PsnType = res.Output.Setlinfo.PsnType
  5350. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5351. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5352. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5353. // order.MedType = res.Output.Setlinfo.MedType
  5354. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5355. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5356. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5357. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5358. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5359. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5360. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5361. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5362. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5363. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5364. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5365. // order.MafPay = res.Output.Setlinfo.MafPay
  5366. // order.OthPay = res.Output.Setlinfo.OthPay
  5367. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5368. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5369. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5370. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5371. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5372. // order.Balc = res.Output.Setlinfo.Balc
  5373. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5374. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5375. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5376. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5377. // order.Creator = order.Creator
  5378. // order.Modify = roles.ID
  5379. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5380. // detailStr := string(setlDetail)
  5381. // order.SetlDetail = detailStr
  5382. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5383. // err = service.UpDateOrder(order)
  5384. // if err == nil {
  5385. // c.ServeSuccessJSON(map[string]interface{}{
  5386. // "msg": "预结算成功",
  5387. // })
  5388. // } else {
  5389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5390. // return
  5391. // }
  5392. // }
  5393. // } else {
  5394. // adminUser := c.GetAdminUserInfo()
  5395. // errlog := &models.HisOrderError{
  5396. // UserOrgId: adminUser.CurrentOrgId,
  5397. // Ctime: time.Now().Unix(),
  5398. // Mtime: time.Now().Unix(),
  5399. // ErrMsg: res.ErrMsg,
  5400. // Status: 1,
  5401. // PatientId: id,
  5402. // RecordTime: recordDateTime,
  5403. // Stage: 4,
  5404. // }
  5405. // service.CreateErrMsgLog(errlog)
  5406. //
  5407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5408. // return
  5409. // }
  5410. // } else {
  5411. // adminUser := c.GetAdminUserInfo()
  5412. // errlog := &models.HisOrderError{
  5413. // UserOrgId: adminUser.CurrentOrgId,
  5414. // Ctime: time.Now().Unix(),
  5415. // Mtime: time.Now().Unix(),
  5416. // ErrMsg: res.ErrMsg,
  5417. // Status: 1,
  5418. // PatientId: id,
  5419. // RecordTime: recordDateTime,
  5420. // Stage: 4,
  5421. // }
  5422. // service.CreateErrMsgLog(errlog)
  5423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5424. // return
  5425. // }
  5426. //
  5427. // } else {
  5428. // var total float64
  5429. // for _, item := range prescriptions {
  5430. // if item.Type == 1 { //药品
  5431. // for _, subItem := range item.HisDoctorAdviceInfo {
  5432. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5433. // }
  5434. // }
  5435. // if item.Type == 2 { //项目
  5436. // for _, subItem := range item.HisPrescriptionProject {
  5437. // total = total + (subItem.Price * float64(subItem.Count))
  5438. // }
  5439. // }
  5440. //
  5441. // for _, subItem := range item.HisAdditionalCharge {
  5442. // total = total + (subItem.Price * float64(subItem.Count))
  5443. // }
  5444. // }
  5445. //
  5446. // allTotal := fmt.Sprintf("%.2f", total)
  5447. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5448. // order := &models.HisOrder{
  5449. // UserOrgId: adminUser.CurrentOrgId,
  5450. // HisPatientId: his.ID,
  5451. // PatientId: id,
  5452. // SettleAccountsDate: recordDateTime,
  5453. // Ctime: time.Now().Unix(),
  5454. // Mtime: time.Now().Unix(),
  5455. // Status: 1,
  5456. // OrderStatus: 2,
  5457. // Number: chrg_bchno,
  5458. // MedfeeSumamt: totals,
  5459. // }
  5460. // err = service.CreateOrder(order)
  5461. // if err != nil {
  5462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5463. // return
  5464. // }
  5465. //
  5466. // var customs []*Custom
  5467. // for _, item := range prescriptions {
  5468. //
  5469. // if item.Type == 1 { //药品
  5470. // for _, subItem := range item.HisDoctorAdviceInfo {
  5471. // cus := &Custom{
  5472. // AdviceId: subItem.ID,
  5473. // ProjectId: 0,
  5474. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5475. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5476. // FeedetlSn: subItem.FeedetlSn,
  5477. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5478. // MedListCodg: subItem.MedListCodg,
  5479. // Type: 1,
  5480. // }
  5481. // customs = append(customs, cus)
  5482. // }
  5483. // }
  5484. //
  5485. // if item.Type == 2 { //项目
  5486. // for _, subItem := range item.HisPrescriptionProject {
  5487. //
  5488. // cus := &Custom{
  5489. // AdviceId: 0,
  5490. // ProjectId: subItem.ID,
  5491. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5492. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5493. // FeedetlSn: subItem.FeedetlSn,
  5494. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5495. // MedListCodg: subItem.MedListCodg,
  5496. // Type: 2,
  5497. // }
  5498. //
  5499. // customs = append(customs, cus)
  5500. // }
  5501. // }
  5502. //
  5503. // for _, item := range item.HisAdditionalCharge {
  5504. // cus := &Custom{
  5505. // ItemId: item.ID,
  5506. // AdviceId: 0,
  5507. // ProjectId: 0,
  5508. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5509. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5510. // FeedetlSn: item.FeedetlSn,
  5511. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5512. // MedListCodg: item.XtHisAddtionConfig.Code,
  5513. // Type: 3,
  5514. // }
  5515. //
  5516. // customs = append(customs, cus)
  5517. // }
  5518. //
  5519. // }
  5520. //
  5521. // for _, item := range customs {
  5522. // var advice_id int64 = 0
  5523. // var project_id int64 = 0
  5524. // var item_id int64 = 0
  5525. //
  5526. // var types int64 = 0
  5527. //
  5528. // if item.Type == 1 {
  5529. // advice_id = item.AdviceId
  5530. // project_id = 0
  5531. // item_id = 0
  5532. // } else if item.Type == 2 {
  5533. // advice_id = 0
  5534. // item_id = 0
  5535. //
  5536. // project_id = item.ProjectId
  5537. // } else if item.Type == 3 {
  5538. // advice_id = 0
  5539. // item_id = item.ItemId
  5540. // project_id = 0
  5541. // }
  5542. //
  5543. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5544. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5545. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5546. //
  5547. // info := &models.HisOrderInfo{
  5548. // OrderNumber: order.Number,
  5549. // UploadDate: time.Now().Unix(),
  5550. // AdviceId: advice_id,
  5551. // DetItemFeeSumamt: detItemFeeSumamt,
  5552. // Cnt: cut,
  5553. // Pric: pric,
  5554. // PatientId: id,
  5555. // Status: 1,
  5556. // Mtime: time.Now().Unix(),
  5557. // Ctime: time.Now().Unix(),
  5558. // UserOrgId: adminUser.CurrentOrgId,
  5559. // HisPatientId: his.ID,
  5560. // OrderId: order.ID,
  5561. // ProjectId: project_id,
  5562. // Type: types,
  5563. // ItemId: item_id,
  5564. // }
  5565. // service.CreateOrderInfo(info)
  5566. // }
  5567. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5568. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5569. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5570. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5571. // if err == nil {
  5572. // c.ServeSuccessJSON(map[string]interface{}{
  5573. // "msg": "结算成功",
  5574. // })
  5575. // } else {
  5576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5577. // return
  5578. // }
  5579. // }
  5580. //}
  5581. //上传明细-预结算-
  5582. func (c *HisApiController) GetPreUploadInfo() {
  5583. id, _ := c.GetInt64("id")
  5584. record_time := c.GetString("record_time")
  5585. his_patient_id, _ := c.GetInt64("his_patient_id")
  5586. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5587. admin_user_id, _ := c.GetInt64("admin_user_id")
  5588. diagnosis_id := c.GetString("diagnosis")
  5589. sick_type, _ := c.GetInt64("sick_type")
  5590. reg_type, _ := c.GetInt64("p_type")
  5591. begin_time := c.GetString("begin_time")
  5592. id_str := c.GetString("ids")
  5593. ids_arr := strings.Split(id_str, ",")
  5594. timeLayout := "2006-01-02"
  5595. loc, _ := time.LoadLocation("Local")
  5596. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5597. if err != nil {
  5598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5599. return
  5600. }
  5601. recordDateTime := theTime.Unix()
  5602. adminUser := c.GetAdminUserInfo()
  5603. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5604. var config []*models.HisXtDiagnoseConfig
  5605. for _, item := range diagnosis_ids {
  5606. id, _ := strconv.ParseInt(item, 10, 64)
  5607. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5608. config = append(config, &diagnosisConfig)
  5609. }
  5610. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5611. sickConfig, _ := service.FindSickById(sick_type)
  5612. var prescriptions []*models.HisPrescription
  5613. var start_time int64
  5614. var end_time int64
  5615. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5616. fmt.Println(his_patient_id)
  5617. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5618. timestamp := time.Now().Unix()
  5619. tempTime := time.Unix(timestamp, 0)
  5620. timeFormat := tempTime.Format("20060102150405")
  5621. chrgBchno := rand.Intn(100000) + 10000
  5622. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5624. var patientPrescription models.HisPrescriptionInfo
  5625. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5626. if patientPrescription.ID == 0 {
  5627. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5628. }
  5629. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5630. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5631. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5632. strconv.FormatInt(his.PatientId, 10)
  5633. var res2 ResultSix
  5634. var resSix10265 ResultSix10265
  5635. var time_stamp string
  5636. if miConfig.MdtrtareaAdmvs == "421300" {
  5637. data := make(map[string]interface{})
  5638. client := &http.Client{}
  5639. data["psn_no"] = his.PsnNo
  5640. data["mdtrt_id"] = his.Number
  5641. data["doctor"] = roles.UserName
  5642. data["department"] = department.Name
  5643. data["org_name"] = miConfig.OrgName
  5644. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5645. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5646. data["fixmedins_code"] = miConfig.Code
  5647. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5648. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5649. data["secret_key"] = miConfig.SecretKey
  5650. data["sick_code"] = sickConfig.CountryCode
  5651. data["sick_name"] = sickConfig.ClassName
  5652. data["begin_time"] = begin_time
  5653. data["dept"] = strconv.FormatInt(department.ID, 10)
  5654. data["config"] = config
  5655. fmt.Println(data)
  5656. bytesData, _ := json.Marshal(data)
  5657. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5658. resp, _ := client.Do(req)
  5659. defer resp.Body.Close()
  5660. body, ioErr := ioutil.ReadAll(resp.Body)
  5661. if ioErr != nil {
  5662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. var respJSON map[string]interface{}
  5667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5670. return
  5671. }
  5672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5673. userJSONBytes, _ := json.Marshal(respJSON)
  5674. fmt.Println("log")
  5675. fmt.Println(string(userJSONBytes))
  5676. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5677. utils.ErrorLog("解析失败:%v", err)
  5678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5679. return
  5680. }
  5681. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5682. //江苏地区国家医保医疗类别
  5683. //职工透析:医疗类别选特殊情况门诊9933
  5684. //居民血透门慢: 医疗类别选门诊慢病1402
  5685. //var med_type string
  5686. //if his.Insutype == "310" {
  5687. // if reg_type == 14 {
  5688. // med_type = "9933"
  5689. // } else if reg_type == 11 {
  5690. // med_type = "11"
  5691. //
  5692. // }
  5693. //} else if his.Insutype == "390" {
  5694. // if reg_type == 14 {
  5695. // med_type = "1402"
  5696. // } else if reg_type == 11 {
  5697. // med_type = "11"
  5698. // }
  5699. //}
  5700. data := make(map[string]interface{})
  5701. client := &http.Client{}
  5702. data["psn_no"] = his.PsnNo
  5703. data["mdtrt_id"] = his.Number
  5704. data["doctor"] = roles.UserName
  5705. data["department"] = department.Name
  5706. data["org_name"] = miConfig.OrgName
  5707. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5708. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5709. data["fixmedins_code"] = miConfig.Code
  5710. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5711. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5712. data["secret_key"] = miConfig.SecretKey
  5713. data["sick_code"] = sickConfig.CountryCode
  5714. data["sick_name"] = sickConfig.ClassName
  5715. data["begin_time"] = begin_time
  5716. data["dept"] = strconv.FormatInt(department.ID, 10)
  5717. data["config"] = config
  5718. data["url"] = miConfig.Url
  5719. data["ak"] = miConfig.AccessKey
  5720. data["cainfo"] = miConfig.Cainfo
  5721. bytesData, _ := json.Marshal(data)
  5722. var req *http.Request
  5723. if miConfig.MdtrtareaAdmvs == "320921" {
  5724. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5725. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5726. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5727. } else {
  5728. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5729. }
  5730. resp, _ := client.Do(req)
  5731. defer resp.Body.Close()
  5732. body, ioErr := ioutil.ReadAll(resp.Body)
  5733. if ioErr != nil {
  5734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5736. return
  5737. }
  5738. var respJSON map[string]interface{}
  5739. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5742. return
  5743. }
  5744. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5745. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5746. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5748. userJSONBytes, _ := json.Marshal(respJSON)
  5749. fmt.Println("log")
  5750. fmt.Println(string(userJSONBytes))
  5751. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5752. utils.ErrorLog("解析失败:%v", err)
  5753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5754. return
  5755. }
  5756. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5757. res2.Output = resSix10265.Output
  5758. res2.ErrMsg = resSix10265.ErrMsg
  5759. res2.Cainfo = resSix10265.Cainfo
  5760. res2.WarnMsg = resSix10265.WarnMsg
  5761. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5762. res2.Infcode = infocode
  5763. } else {
  5764. var result string
  5765. var requestLog string
  5766. if miConfig.MdtrtareaAdmvs == "440781" { //
  5767. 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)
  5768. } else {
  5769. if miConfig.Code == "H15049901371" {
  5770. //赤峰地区国家医保医疗类别
  5771. //职工透析:医疗类别选特殊情况门诊990502
  5772. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5773. var med_type string
  5774. if his.Insutype == "390" {
  5775. if reg_type == 14 {
  5776. med_type = "9933"
  5777. } else if reg_type == 11 {
  5778. med_type = "11"
  5779. }
  5780. } else if his.Insutype == "310" {
  5781. if reg_type == 14 {
  5782. med_type = "990502"
  5783. } else if reg_type == 11 {
  5784. med_type = "11"
  5785. }
  5786. }
  5787. 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)
  5788. } else {
  5789. 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)
  5790. }
  5791. saveLog(result, requestLog, "2203", "上传就诊信息")
  5792. var respJSON2 map[string]interface{}
  5793. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5796. return
  5797. }
  5798. userJSONBytes2, _ := json.Marshal(respJSON2)
  5799. if miConfig.Code == "H15049901371" {
  5800. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5801. utils.ErrorLog("解析失败:%v", err)
  5802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5803. return
  5804. }
  5805. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5806. res2.Output = resSix10265.Output
  5807. res2.ErrMsg = resSix10265.ErrMsg
  5808. res2.Cainfo = resSix10265.Cainfo
  5809. res2.WarnMsg = resSix10265.WarnMsg
  5810. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5811. res2.Infcode = infocode
  5812. } else {
  5813. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5814. utils.ErrorLog("解析失败:%v", err)
  5815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5816. return
  5817. }
  5818. }
  5819. }
  5820. }
  5821. if res2.Infcode != 0 {
  5822. adminUser := c.GetAdminUserInfo()
  5823. errlog := &models.HisOrderError{
  5824. UserOrgId: adminUser.CurrentOrgId,
  5825. Ctime: time.Now().Unix(),
  5826. Mtime: time.Now().Unix(),
  5827. ErrMsg: res2.ErrMsg,
  5828. Status: 1,
  5829. PatientId: id,
  5830. RecordTime: recordDateTime,
  5831. Stage: 3,
  5832. }
  5833. service.CreateErrMsgLog(errlog)
  5834. c.ServeSuccessJSON(map[string]interface{}{
  5835. "failed_code": -10,
  5836. "msg": res2.ErrMsg,
  5837. })
  5838. return
  5839. } else {
  5840. his.Diagnosis = diagnosis_id
  5841. his.SickType = sickConfig.ID
  5842. his.PType = fmt.Sprintf("%d", reg_type)
  5843. service.UpdateHisPatientThree(&his)
  5844. data := make(map[string]interface{})
  5845. if settle_accounts_type == 1 { //日结
  5846. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5847. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5848. } else {
  5849. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5850. }
  5851. data["pre"] = prescriptions
  5852. } else { //月结
  5853. start_time_str := c.GetString("start_time")
  5854. end_time_str := c.GetString("end_time")
  5855. timeLayout := "2006-01-02"
  5856. loc, _ := time.LoadLocation("Local")
  5857. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5858. if err != nil {
  5859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5860. return
  5861. }
  5862. recordStartTime := theStartTime.Unix()
  5863. start_time = recordStartTime
  5864. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5865. if err != nil {
  5866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5867. return
  5868. }
  5869. recordEndTime := theEndTime.Unix()
  5870. end_time = recordEndTime
  5871. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5872. data["pre"] = prescriptions
  5873. }
  5874. client := &http.Client{}
  5875. data["psn_no"] = his.PsnNo
  5876. data["mdtrt_id"] = his.Number
  5877. data["chrg_bchno"] = chrg_bchno
  5878. data["org_name"] = miConfig.OrgName
  5879. data["doctor"] = roles.UserName
  5880. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5881. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5882. data["fixmedins_code"] = miConfig.Code
  5883. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5884. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5885. data["dept_code"] = "15"
  5886. } else {
  5887. data["dept_code"] = department.Number
  5888. }
  5889. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5890. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5891. data["secret_key"] = miConfig.SecretKey
  5892. data["url"] = miConfig.Url
  5893. data["ak"] = miConfig.AccessKey
  5894. data["new_doctor_name"] = patientPrescription.Doctor
  5895. data["diag_code"] = sickConfig.CountryCode
  5896. data["time_stamp"] = time_stamp
  5897. data["cainfo"] = miConfig.Cainfo
  5898. var ids []int64
  5899. for _, item := range prescriptions {
  5900. ids = append(ids, item.ID)
  5901. }
  5902. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5903. if config.IsOpen == 1 { //对接了医保,走医保流程
  5904. var res ResultFour
  5905. var resFour10265 ResultFour10265
  5906. if miConfig.MdtrtareaAdmvs == "421300" {
  5907. bytesData, _ := json.Marshal(data)
  5908. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5909. resp, _ := client.Do(req)
  5910. defer resp.Body.Close()
  5911. body, ioErr := ioutil.ReadAll(resp.Body)
  5912. if ioErr != nil {
  5913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. var respJSON map[string]interface{}
  5918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5924. userJSONBytes, _ := json.Marshal(respJSON)
  5925. fmt.Println("log")
  5926. fmt.Println(string(userJSONBytes))
  5927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5928. utils.ErrorLog("解析失败:%v", err)
  5929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5930. return
  5931. }
  5932. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5933. bytesData, _ := json.Marshal(data)
  5934. var req *http.Request
  5935. if miConfig.MdtrtareaAdmvs == "320921" {
  5936. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5937. } else {
  5938. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5939. }
  5940. resp, _ := client.Do(req)
  5941. defer resp.Body.Close()
  5942. body, ioErr := ioutil.ReadAll(resp.Body)
  5943. if ioErr != nil {
  5944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. return
  5947. }
  5948. var respJSON map[string]interface{}
  5949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5952. return
  5953. }
  5954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5955. userJSONBytes, _ := json.Marshal(respJSON)
  5956. fmt.Println("log")
  5957. fmt.Println(string(userJSONBytes))
  5958. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5959. utils.ErrorLog("解析失败:%v", err)
  5960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5961. return
  5962. }
  5963. res.InfRefmsgid = resFour10265.InfRefmsgid
  5964. res.Output = resFour10265.Output
  5965. res.ErrMsg = resFour10265.ErrMsg
  5966. res.Cainfo = resFour10265.Cainfo
  5967. res.WarnMsg = resFour10265.WarnMsg
  5968. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5969. res.Infcode = infocode
  5970. } else {
  5971. if miConfig.Code == "H15049901371" {
  5972. 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)
  5973. var dat map[string]interface{}
  5974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5975. fmt.Println(dat)
  5976. } else {
  5977. fmt.Println(err)
  5978. }
  5979. saveLog(result, request_log, "2204", "上传费用明细")
  5980. userJSONBytes, _ := json.Marshal(dat)
  5981. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5982. utils.ErrorLog("解析失败:%v", err)
  5983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5984. return
  5985. }
  5986. res.InfRefmsgid = resFour10265.InfRefmsgid
  5987. res.Output = resFour10265.Output
  5988. res.ErrMsg = resFour10265.ErrMsg
  5989. res.Cainfo = resFour10265.Cainfo
  5990. res.WarnMsg = resFour10265.WarnMsg
  5991. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5992. res.Infcode = infocode
  5993. } else {
  5994. 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)
  5995. var dat map[string]interface{}
  5996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5997. fmt.Println(dat)
  5998. } else {
  5999. fmt.Println(err)
  6000. }
  6001. saveLog(result, request_log, "2204", "上传费用明细")
  6002. userJSONBytes, _ := json.Marshal(dat)
  6003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6004. utils.ErrorLog("解析失败:%v", err)
  6005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6006. return
  6007. }
  6008. }
  6009. }
  6010. if res.Infcode == 0 {
  6011. order := &models.HisOrder{
  6012. UserOrgId: adminUser.CurrentOrgId,
  6013. HisPatientId: his.ID,
  6014. PatientId: his.PatientId,
  6015. SettleAccountsDate: recordDateTime,
  6016. Ctime: time.Now().Unix(),
  6017. Mtime: time.Now().Unix(),
  6018. MdtrtId: his.Number,
  6019. PsnNo: his.PsnNo,
  6020. MedType: strconv.FormatInt(reg_type, 10),
  6021. Status: 1,
  6022. Number: chrg_bchno,
  6023. Infcode: res.Infcode,
  6024. WarnMsg: res.WarnMsg,
  6025. Cainfo: res.Cainfo,
  6026. ErrMsg: res.ErrMsg,
  6027. RespondTime: res.RefmsgTime,
  6028. InfRefmsgid: res.InfRefmsgid,
  6029. OrderStatus: 1,
  6030. IsMedicineInsurance: 1,
  6031. SettleType: settle_accounts_type,
  6032. SettleStartTime: start_time,
  6033. SettleEndTime: end_time,
  6034. Creator: roles.AdminUserId,
  6035. Modify: roles.AdminUserId,
  6036. PType: 2,
  6037. Diagnosis: diagnosis_id,
  6038. }
  6039. err = service.CreateOrder(order)
  6040. if err != nil {
  6041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6042. return
  6043. }
  6044. for _, item := range res.Output.Result {
  6045. temp := strings.Split(item.FeedetlSn, "-")
  6046. var advice_id int64 = 0
  6047. var project_id int64 = 0
  6048. var types int64 = 0
  6049. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6050. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6051. if temp[1] == "1" {
  6052. advice_id = id
  6053. project_id = 0
  6054. } else if temp[1] == "2" {
  6055. advice_id = 0
  6056. project_id = id
  6057. }
  6058. info := &models.HisOrderInfo{
  6059. OrderNumber: order.Number,
  6060. FeedetlSn: item.FeedetlSn,
  6061. UploadDate: time.Now().Unix(),
  6062. AdviceId: advice_id,
  6063. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6064. Cnt: item.Cnt,
  6065. Pric: float64(item.Pric),
  6066. PatientId: his.PatientId,
  6067. PricUplmtAmt: item.PricUplmtAmt,
  6068. SelfpayProp: item.SelfpayProp,
  6069. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6070. OverlmtAmt: item.OverlmtAmt,
  6071. PreselfpayAmt: item.PreselfpayAmt,
  6072. BasMednFlag: item.BasMednFlag,
  6073. MedChrgitmType: item.MedChrgitmType,
  6074. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6075. Status: 1,
  6076. Memo: item.Memo,
  6077. Mtime: time.Now().Unix(),
  6078. InscpScpAmt: item.InscpScpAmt,
  6079. DrtReimFlag: item.DrtReimFlag,
  6080. Ctime: time.Now().Unix(),
  6081. ListSpItemFlag: item.ListSpItemFlag,
  6082. ChldMedcFlag: item.ChldMedcFlag,
  6083. LmtUsedFlag: item.LmtUsedFlag,
  6084. ChrgitmLv: item.ChrgitmLv,
  6085. UserOrgId: adminUser.CurrentOrgId,
  6086. HisPatientId: his.ID,
  6087. OrderId: order.ID,
  6088. ProjectId: project_id,
  6089. Type: types,
  6090. }
  6091. service.CreateOrderInfo(info)
  6092. }
  6093. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6094. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6095. var total float64
  6096. for _, item := range prescriptions {
  6097. if item.Type == 1 { //药品
  6098. for _, subItem := range item.HisDoctorAdviceInfo {
  6099. total = total + (subItem.Price * subItem.PrescribingNumber)
  6100. }
  6101. }
  6102. if item.Type == 2 { //项目
  6103. for _, subItem := range item.HisPrescriptionProject {
  6104. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6105. total = total + (subItem.Price * cnt)
  6106. }
  6107. }
  6108. }
  6109. for _, item := range prescriptions {
  6110. for _, subItem := range item.HisAdditionalCharge {
  6111. total = total + (subItem.Price * float64(subItem.Count))
  6112. }
  6113. }
  6114. allTotal := fmt.Sprintf("%.4f", total)
  6115. if res.Infcode == 0 {
  6116. var rf []*ResultFive
  6117. json.Unmarshal([]byte(his.Iinfo), &rf)
  6118. chrg_bchno := chrg_bchno
  6119. cert_no := his.Certno
  6120. var insutypes []string
  6121. var insutype string
  6122. var is390 int = 0
  6123. var is310 int = 0
  6124. for _, item := range rf {
  6125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6126. insutypes = append(insutypes, item.Insutype)
  6127. }
  6128. }
  6129. if len(insutypes) == 1 {
  6130. insutype = insutypes[0]
  6131. } else {
  6132. for _, i := range insutypes {
  6133. if i == "390" {
  6134. is390 = 1
  6135. }
  6136. if i == "310" {
  6137. is310 = 1
  6138. }
  6139. }
  6140. }
  6141. if is390 == 1 {
  6142. insutype = "390"
  6143. }
  6144. if is310 == 1 {
  6145. insutype = "310"
  6146. }
  6147. if len(insutypes) == 0 {
  6148. insutype = "310"
  6149. }
  6150. if len(insutypes) == 2 {
  6151. insutype = strconv.FormatInt(his.SocialType, 64)
  6152. }
  6153. //insutype = "390"
  6154. if his.IdCardType == 1 {
  6155. cert_no = his.MedicalInsuranceNumber
  6156. } else {
  6157. cert_no = his.Certno
  6158. }
  6159. var res ResultSeven
  6160. var resSeven10265 ResultSeven10265
  6161. if miConfig.MdtrtareaAdmvs == "421300" {
  6162. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6163. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6164. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6165. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6166. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6167. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6168. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6169. resp, requestErr := http.Get(api)
  6170. if requestErr != nil {
  6171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6172. return
  6173. }
  6174. body, ioErr := ioutil.ReadAll(resp.Body)
  6175. if ioErr != nil {
  6176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. return
  6179. }
  6180. var respJSON map[string]interface{}
  6181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6184. return
  6185. }
  6186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6187. result, _ := json.Marshal(respJSON)
  6188. fmt.Println("log")
  6189. fmt.Println(string(result))
  6190. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6191. utils.ErrorLog("解析失败:%v", err)
  6192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6193. return
  6194. }
  6195. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6196. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6197. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6198. bas := strings.Split(psn_info.CardInfo, "|")
  6199. if his.IdCardType == 1 {
  6200. cert_no = bas[2]
  6201. } else {
  6202. cert_no = bas[1]
  6203. }
  6204. //江苏地区国家医保医疗类别
  6205. //职工透析:医疗类别选特殊情况门诊9933
  6206. //居民血透门慢: 医疗类别选门诊慢病1402
  6207. //var med_type string
  6208. //if his.Insutype == "310" {
  6209. // if reg_type == 14 {
  6210. // med_type = "9933"
  6211. // } else if reg_type == 11 {
  6212. // med_type = "11"
  6213. //
  6214. // }
  6215. //} else if his.Insutype == "390" {
  6216. // if reg_type == 14 {
  6217. // med_type = "1402"
  6218. // } else if reg_type == 11 {
  6219. // med_type = "11"
  6220. // }
  6221. //}
  6222. var api string
  6223. if miConfig.MdtrtareaAdmvs == "320921" {
  6224. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6225. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6226. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6228. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6229. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6230. "&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
  6231. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6232. } else {
  6233. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6234. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6235. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6236. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6238. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6239. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6240. "&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
  6241. }
  6242. resp, requestErr := http.Get(api)
  6243. if requestErr != nil {
  6244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6245. return
  6246. }
  6247. body, ioErr := ioutil.ReadAll(resp.Body)
  6248. if ioErr != nil {
  6249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6251. return
  6252. }
  6253. var respJSON map[string]interface{}
  6254. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6257. return
  6258. }
  6259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6260. result, _ := json.Marshal(respJSON)
  6261. fmt.Println("log")
  6262. fmt.Println(string(result))
  6263. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6264. utils.ErrorLog("解析失败:%v", err)
  6265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6266. return
  6267. }
  6268. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6269. res.Output = resSeven10265.Output
  6270. res.ErrMsg = resSeven10265.ErrMsg
  6271. res.Cainfo = resSeven10265.Cainfo
  6272. res.WarnMsg = resSeven10265.WarnMsg
  6273. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6274. res.Infcode = infocode
  6275. } else {
  6276. var result string
  6277. var request_log string
  6278. if miConfig.Code == "H15049901371" {
  6279. //赤峰地区国家医保医疗类别
  6280. //职工透析:医疗类别选特殊情况门诊990502
  6281. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6282. var med_type string
  6283. if his.Insutype == "390" {
  6284. if reg_type == 14 {
  6285. med_type = "9933"
  6286. } else if reg_type == 11 {
  6287. med_type = "11"
  6288. }
  6289. } else if his.Insutype == "310" {
  6290. if reg_type == 14 {
  6291. med_type = "990502"
  6292. } else if reg_type == 11 {
  6293. med_type = "11"
  6294. }
  6295. }
  6296. 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)
  6297. } else {
  6298. 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)
  6299. }
  6300. var dat map[string]interface{}
  6301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6302. fmt.Println(dat)
  6303. } else {
  6304. fmt.Println(err)
  6305. }
  6306. saveLog(result, request_log, "2206", "预结算")
  6307. //userJSONBytes, _ := json.Marshal(dat)
  6308. //
  6309. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6310. // utils.ErrorLog("解析失败:%v", err)
  6311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. // return
  6313. //}
  6314. userJSONBytes, _ := json.Marshal(dat)
  6315. if miConfig.Code == "H15049901371" {
  6316. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6317. utils.ErrorLog("解析失败:%v", err)
  6318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6319. return
  6320. }
  6321. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6322. res.Output = resSeven10265.Output
  6323. res.ErrMsg = resSeven10265.ErrMsg
  6324. res.Cainfo = resSeven10265.Cainfo
  6325. res.WarnMsg = resSeven10265.WarnMsg
  6326. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6327. res.Infcode = infocode
  6328. } else {
  6329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6330. utils.ErrorLog("解析失败:%v", err)
  6331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6332. return
  6333. }
  6334. }
  6335. }
  6336. if res.Infcode != 0 {
  6337. errlog := &models.HisOrderError{
  6338. UserOrgId: adminUser.CurrentOrgId,
  6339. Ctime: time.Now().Unix(),
  6340. Mtime: time.Now().Unix(),
  6341. Number: chrg_bchno,
  6342. ErrMsg: res.ErrMsg,
  6343. Status: 1,
  6344. PatientId: id,
  6345. RecordTime: recordDateTime,
  6346. Stage: 20,
  6347. }
  6348. service.CreateErrMsgLog(errlog)
  6349. c.ServeSuccessJSON(map[string]interface{}{
  6350. "failed_code": -10,
  6351. "msg": res.ErrMsg,
  6352. })
  6353. return
  6354. } else {
  6355. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6356. order.OrderStatus = 1
  6357. order.IsPre = 1
  6358. order.Status = 1
  6359. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6360. order.SetlId = res.Output.Setlinfo.SetlID
  6361. order.PsnNo = res.Output.Setlinfo.PsnNo
  6362. order.PsnName = res.Output.Setlinfo.PsnName
  6363. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6364. order.Certno = res.Output.Setlinfo.Certno
  6365. order.Gend = res.Output.Setlinfo.Gend
  6366. order.Naty = res.Output.Setlinfo.Naty
  6367. order.Age = res.Output.Setlinfo.Age
  6368. order.Insutype = res.Output.Setlinfo.Insutype
  6369. order.PsnType = res.Output.Setlinfo.PsnType
  6370. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6371. order.SetlTime = res.Output.Setlinfo.SetlTime
  6372. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6373. if res.Output.Setlinfo.MedType == "140101" {
  6374. order.MedType = "14"
  6375. } else {
  6376. order.MedType = res.Output.Setlinfo.MedType
  6377. }
  6378. if reg_type == 1112 {
  6379. order.MedType = "1112"
  6380. }
  6381. if reg_type == 1111 {
  6382. order.MedType = "1111"
  6383. }
  6384. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6385. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6386. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6387. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6388. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6389. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6390. order.HifpPay = res.Output.Setlinfo.HifpPay
  6391. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6392. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6393. order.HifesPay = res.Output.Setlinfo.HifesPay
  6394. order.HifobPay = res.Output.Setlinfo.HifobPay
  6395. order.MafPay = res.Output.Setlinfo.MafPay
  6396. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6397. order.OthPay = res.Output.Setlinfo.OthPay
  6398. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6399. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6400. order.AcctPay = res.Output.Setlinfo.AcctPay
  6401. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6402. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6403. order.Balc = res.Output.Setlinfo.Balc
  6404. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6405. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6406. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6407. order.ClrWay = res.Output.Setlinfo.ClrWay
  6408. order.Creator = order.Creator
  6409. order.Modify = roles.AdminUserId
  6410. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6411. detailStr := string(setlDetail)
  6412. order.SetlDetail = detailStr
  6413. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6414. err = service.UpDateOrder(order)
  6415. if err == nil {
  6416. c.ServeSuccessJSON(map[string]interface{}{
  6417. "msg": "预结算成功",
  6418. })
  6419. } else {
  6420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6421. return
  6422. }
  6423. }
  6424. } else {
  6425. adminUser := c.GetAdminUserInfo()
  6426. errlog := &models.HisOrderError{
  6427. UserOrgId: adminUser.CurrentOrgId,
  6428. Ctime: time.Now().Unix(),
  6429. Mtime: time.Now().Unix(),
  6430. ErrMsg: res.ErrMsg,
  6431. Status: 1,
  6432. PatientId: id,
  6433. RecordTime: recordDateTime,
  6434. Stage: 4,
  6435. }
  6436. service.CreateErrMsgLog(errlog)
  6437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6438. return
  6439. }
  6440. } else {
  6441. adminUser := c.GetAdminUserInfo()
  6442. errlog := &models.HisOrderError{
  6443. UserOrgId: adminUser.CurrentOrgId,
  6444. Ctime: time.Now().Unix(),
  6445. Mtime: time.Now().Unix(),
  6446. ErrMsg: res.ErrMsg,
  6447. Status: 1,
  6448. PatientId: id,
  6449. RecordTime: recordDateTime,
  6450. Stage: 4,
  6451. }
  6452. service.CreateErrMsgLog(errlog)
  6453. c.ServeSuccessJSON(map[string]interface{}{
  6454. "failed_code": -10,
  6455. "msg": res.ErrMsg,
  6456. })
  6457. return
  6458. }
  6459. }
  6460. }
  6461. }
  6462. //func (c *HisApiController) GetSettleInfo() {
  6463. // id, _ := c.GetInt64("id")
  6464. // order_id, _ := c.GetInt64("order_id")
  6465. //
  6466. // record_time := c.GetString("record_time")
  6467. // pay_way, _ := c.GetInt64("pay_way")
  6468. // pay_price, _ := c.GetFloat("pay_price")
  6469. // pay_card_no := c.GetString("pay_card_no")
  6470. // discount_price, _ := c.GetFloat("discount_price")
  6471. // preferential_price, _ := c.GetFloat("preferential_price")
  6472. // reality_price, _ := c.GetFloat("reality_price")
  6473. // found_price, _ := c.GetFloat("found_price")
  6474. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6475. // private_price, _ := c.GetFloat("private_price")
  6476. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6477. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6478. //
  6479. // timeLayout := "2006-01-02"
  6480. // loc, _ := time.LoadLocation("Local")
  6481. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6482. // if err != nil {
  6483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6484. // return
  6485. // }
  6486. // recordDateTime := theTime.Unix()
  6487. // adminUser := c.GetAdminUserInfo()
  6488. //
  6489. // var prescriptions []*models.HisPrescription
  6490. //
  6491. // data := make(map[string]interface{})
  6492. // if settle_accounts_type == 1 { //日结
  6493. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6494. // data["pre"] = prescriptions
  6495. //
  6496. // } else { //月结
  6497. // start_time_str := c.GetString("start_time")
  6498. // end_time_str := c.GetString("end_time")
  6499. // timeLayout := "2006-01-02"
  6500. // loc, _ := time.LoadLocation("Local")
  6501. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6502. // if err != nil {
  6503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6504. // return
  6505. // }
  6506. // recordStartTime := theStartTime.Unix()
  6507. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6508. // if err != nil {
  6509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6510. // return
  6511. // }
  6512. // recordEndTime := theEndTime.Unix()
  6513. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6514. // data["pre"] = prescriptions
  6515. //
  6516. // }
  6517. //
  6518. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6519. //
  6520. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6521. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6522. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6523. // strconv.FormatInt(his.PatientId, 10)
  6524. //
  6525. // order_src, _ := service.GetHisOrderByID(order_id)
  6526. //
  6527. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6528. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6529. //
  6530. // var total float64
  6531. // for _, item := range prescriptions {
  6532. // if item.Type == 1 { //药品
  6533. // for _, subItem := range item.HisDoctorAdviceInfo {
  6534. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6535. // }
  6536. // }
  6537. // if item.Type == 2 { //项目
  6538. // for _, subItem := range item.HisPrescriptionProject {
  6539. // total = total + (subItem.Price * float64(subItem.Count))
  6540. // }
  6541. // }
  6542. // }
  6543. //
  6544. // for _, item := range prescriptions {
  6545. // for _, subItem := range item.HisAdditionalCharge {
  6546. // total = total + (subItem.Price * float64(subItem.Count))
  6547. // }
  6548. // }
  6549. //
  6550. // allTotal := fmt.Sprintf("%.2f", total)
  6551. // var rf []*ResultFive
  6552. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6553. // psn_no := order_src.PsnNo
  6554. // mdtrt_id := order_src.MdtrtId
  6555. // chrg_bchno := order_src.Number
  6556. // cert_no := order_src.Certno
  6557. // insutype := rf[0].Insutype
  6558. //
  6559. // if his.IdCardType == 1 {
  6560. // cert_no = his.MedicalInsuranceNumber
  6561. // } else {
  6562. // cert_no = his.Certno
  6563. // }
  6564. //
  6565. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  6566. // var dat map[string]interface{}
  6567. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6568. // fmt.Println(dat)
  6569. // } else {
  6570. // fmt.Println(err)
  6571. // }
  6572. //
  6573. // userJSONBytes, _ := json.Marshal(dat)
  6574. //
  6575. //
  6576. //
  6577. // var res ResultSeven
  6578. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6579. // utils.ErrorLog("解析失败:%v", err)
  6580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6581. // return
  6582. // }
  6583. // if res.Infcode == -1 {
  6584. // errlog := &models.HisOrderError{
  6585. // UserOrgId: adminUser.CurrentOrgId,
  6586. // Ctime: time.Now().Unix(),
  6587. // Mtime: time.Now().Unix(),
  6588. // Number: chrg_bchno,
  6589. // ErrMsg: res.ErrMsg,
  6590. // Status: 1,
  6591. // PatientId: id,
  6592. // RecordTime: recordDateTime,
  6593. // Stage: 6,
  6594. // }
  6595. // service.CreateErrMsgLog(errlog)
  6596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6597. // return
  6598. // } else {
  6599. // order_src.OrderStatus = 2
  6600. // order_src.PayWay = pay_way
  6601. // order_src.PayPrice = pay_price
  6602. // order_src.PayCardNo = pay_card_no
  6603. // order_src.DiscountPrice = discount_price
  6604. // order_src.PreferentialPrice = preferential_price
  6605. // order_src.RealityPrice = reality_price
  6606. // order_src.FoundPrice = found_price
  6607. // order_src.MedicalInsurancePrice = medical_insurance_price
  6608. // order_src.PrivatePrice = private_price
  6609. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6610. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6611. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6612. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6613. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6614. // order_src.Certno = res.Output.Setlinfo.Certno
  6615. // order_src.Gend = res.Output.Setlinfo.Gend
  6616. // order_src.Naty = res.Output.Setlinfo.Naty
  6617. // order_src.Age = res.Output.Setlinfo.Age
  6618. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6619. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6620. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6621. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6622. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6623. // order_src.MedType = res.Output.Setlinfo.MedType
  6624. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6625. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6626. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6627. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6628. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6629. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6630. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6631. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6632. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6633. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6634. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6635. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6636. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6637. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6638. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6639. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6640. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6641. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6642. // order_src.Balc = res.Output.Setlinfo.Balc
  6643. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6644. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6645. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6646. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6647. // order_src.Creator = order_src.Creator
  6648. // order_src.Modify = roles.ID
  6649. // order_src.RequestLog = src_resquest
  6650. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6651. // detailStr := string(setlDetail)
  6652. // order_src.SetlDetail = detailStr
  6653. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6654. // err = service.UpDateOrder(order_src)
  6655. //
  6656. // if err == nil {
  6657. // c.ServeSuccessJSON(map[string]interface{}{
  6658. // "msg": "结算成功",
  6659. // })
  6660. // } else {
  6661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6662. // return
  6663. // }
  6664. // }
  6665. // }
  6666. //}
  6667. //退款
  6668. func (c *HisApiController) Refund() {
  6669. order_id, _ := c.GetInt64("order_id")
  6670. admin_user_id, _ := c.GetInt64("admin_user_id")
  6671. adminUser := c.GetAdminUserInfo()
  6672. var order models.HisOrder
  6673. order, _ = service.GetHisOrderByID(order_id)
  6674. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6675. if order.ID == 0 {
  6676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6677. return
  6678. }
  6679. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6681. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6682. if config.IsOpen == 1 { //对接了医保,走医保流程
  6683. var res ResultSixteen
  6684. var resSixteen10265 ResultSixteen10265
  6685. var src_resquest string
  6686. var result string
  6687. if miConfig.MdtrtareaAdmvs == "421300" {
  6688. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6689. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6690. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6691. resp3, requestErr3 := http.Get(api3)
  6692. if requestErr3 != nil {
  6693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. return
  6695. }
  6696. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6697. if ioErr3 != nil {
  6698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. return
  6701. }
  6702. var respJSON3 map[string]interface{}
  6703. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6706. return
  6707. }
  6708. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6709. userJSONBytes3, _ := json.Marshal(respJSON3)
  6710. fmt.Println("log")
  6711. fmt.Println(string(userJSONBytes3))
  6712. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6713. utils.ErrorLog("解析失败:%v", err)
  6714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6715. return
  6716. }
  6717. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6718. var api3 string
  6719. if miConfig.MdtrtareaAdmvs == "320921" {
  6720. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6721. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6722. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6723. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6724. } else {
  6725. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6726. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6727. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6728. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6729. }
  6730. resp3, requestErr3 := http.Get(api3)
  6731. if requestErr3 != nil {
  6732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6733. return
  6734. }
  6735. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6736. if ioErr3 != nil {
  6737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6739. return
  6740. }
  6741. var respJSON3 map[string]interface{}
  6742. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6745. return
  6746. }
  6747. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6748. userJSONBytes3, _ := json.Marshal(respJSON3)
  6749. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6750. utils.ErrorLog("解析失败:%v", err)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. return
  6753. }
  6754. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6755. res.Output = resSixteen10265.Output
  6756. res.ErrMsg = resSixteen10265.ErrMsg
  6757. res.Cainfo = resSixteen10265.Cainfo
  6758. res.WarnMsg = resSixteen10265.WarnMsg
  6759. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6760. res.Infcode = infocode
  6761. } else {
  6762. if miConfig.Code == "H15049901371" {
  6763. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6764. var dat map[string]interface{}
  6765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6766. fmt.Println(dat)
  6767. } else {
  6768. fmt.Println(err)
  6769. }
  6770. saveLog(result, src_resquest, "2208", "退费")
  6771. userJSONBytes, _ := json.Marshal(dat)
  6772. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6773. utils.ErrorLog("解析失败:%v", err)
  6774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6775. return
  6776. }
  6777. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6778. res.Output = resSixteen10265.Output
  6779. res.ErrMsg = resSixteen10265.ErrMsg
  6780. res.Cainfo = resSixteen10265.Cainfo
  6781. res.WarnMsg = resSixteen10265.WarnMsg
  6782. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6783. res.Infcode = infocode
  6784. } else {
  6785. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6786. var dat map[string]interface{}
  6787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6788. fmt.Println(dat)
  6789. } else {
  6790. fmt.Println(err)
  6791. }
  6792. saveLog(result, src_resquest, "2208", "退费")
  6793. userJSONBytes, _ := json.Marshal(dat)
  6794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6795. utils.ErrorLog("解析失败:%v", err)
  6796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6797. return
  6798. }
  6799. }
  6800. }
  6801. if res.Infcode == 0 {
  6802. var res2 ResultSix
  6803. var resSix10265 ResultSix10265
  6804. if miConfig.MdtrtareaAdmvs == "421300" {
  6805. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6806. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6808. resp3, requestErr3 := http.Get(api3)
  6809. if requestErr3 != nil {
  6810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6811. return
  6812. }
  6813. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6814. if ioErr3 != nil {
  6815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. return
  6818. }
  6819. var respJSON3 map[string]interface{}
  6820. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6823. return
  6824. }
  6825. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6826. userJSONBytes3, _ := json.Marshal(respJSON3)
  6827. fmt.Println("log")
  6828. fmt.Println(string(userJSONBytes3))
  6829. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6830. utils.ErrorLog("解析失败:%v", err)
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6832. return
  6833. }
  6834. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6835. var api3 string
  6836. if miConfig.MdtrtareaAdmvs == "320921" {
  6837. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6838. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6840. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6841. } else {
  6842. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6843. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6844. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6845. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6846. }
  6847. resp3, requestErr3 := http.Get(api3)
  6848. if requestErr3 != nil {
  6849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6850. return
  6851. }
  6852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6853. if ioErr3 != nil {
  6854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6856. return
  6857. }
  6858. var respJSON3 map[string]interface{}
  6859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. return
  6863. }
  6864. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6865. userJSONBytes3, _ := json.Marshal(respJSON3)
  6866. fmt.Println("log")
  6867. fmt.Println(string(userJSONBytes3))
  6868. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6869. utils.ErrorLog("解析失败:%v", err)
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return
  6872. }
  6873. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6874. res2.Output = resSix10265.Output
  6875. res2.ErrMsg = resSix10265.ErrMsg
  6876. res2.Cainfo = resSix10265.Cainfo
  6877. res2.WarnMsg = resSix10265.WarnMsg
  6878. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6879. res2.Infcode = infocode
  6880. } else {
  6881. if miConfig.Code == "H15049901371" {
  6882. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6883. var dat map[string]interface{}
  6884. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6885. fmt.Println(dat)
  6886. } else {
  6887. fmt.Println(err)
  6888. }
  6889. saveLog(result2, src_request, "2205", "撤销明细")
  6890. userJSONBytes, _ := json.Marshal(dat)
  6891. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6892. utils.ErrorLog("解析失败:%v", err)
  6893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6894. return
  6895. }
  6896. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6897. res2.Output = resSix10265.Output
  6898. res2.ErrMsg = resSix10265.ErrMsg
  6899. res2.Cainfo = resSix10265.Cainfo
  6900. res2.WarnMsg = resSix10265.WarnMsg
  6901. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6902. res2.Infcode = infocode
  6903. } else {
  6904. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6905. var dat map[string]interface{}
  6906. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6907. fmt.Println(dat)
  6908. } else {
  6909. fmt.Println(err)
  6910. }
  6911. saveLog(result2, src_request, "2205", "撤销明细")
  6912. userJSONBytes, _ := json.Marshal(dat)
  6913. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. }
  6919. }
  6920. if res2.Infcode == 0 {
  6921. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6922. if err == nil {
  6923. c.ServeSuccessJSON(map[string]interface{}{
  6924. "msg": "退费成功",
  6925. })
  6926. } else {
  6927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6928. return
  6929. }
  6930. } else {
  6931. c.ServeSuccessJSON(map[string]interface{}{
  6932. "code": -10,
  6933. "msg": res2.ErrMsg,
  6934. })
  6935. }
  6936. } else {
  6937. c.ServeSuccessJSON(map[string]interface{}{
  6938. "code": -10,
  6939. "msg": res.ErrMsg,
  6940. })
  6941. }
  6942. }
  6943. }
  6944. func (c *HisApiController) RefundNumber() {
  6945. record_time := c.GetString("record_time")
  6946. //patient_id, _ := c.GetInt64("patient_id")
  6947. admin_user_id, _ := c.GetInt64("admin_user_id")
  6948. his_patient_id, _ := c.GetInt64("id")
  6949. timeLayout := "2006-01-02"
  6950. loc, _ := time.LoadLocation("Local")
  6951. adminUser := c.GetAdminUserInfo()
  6952. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6953. fmt.Println(err)
  6954. if err != nil {
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6956. return
  6957. }
  6958. recordDateTime := theTime.Unix()
  6959. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6960. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6961. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6962. //order, _ := service.GetHisOrderByID(order_id)
  6963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6964. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6966. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6967. if count > 0 {
  6968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6969. return
  6970. }
  6971. if config.IsOpen == 1 { //对接了医保,走医保流程
  6972. var res2 ResultSix
  6973. var resSix10265 ResultSix10265
  6974. if miConfig.MdtrtareaAdmvs == "421300" {
  6975. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6976. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6978. resp3, requestErr3 := http.Get(api3)
  6979. if requestErr3 != nil {
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6984. if ioErr3 != nil {
  6985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. return
  6988. }
  6989. var respJSON3 map[string]interface{}
  6990. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6993. return
  6994. }
  6995. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6996. userJSONBytes3, _ := json.Marshal(respJSON3)
  6997. fmt.Println("log")
  6998. fmt.Println(string(userJSONBytes3))
  6999. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7000. utils.ErrorLog("解析失败:%v", err)
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7005. var api3 string
  7006. if miConfig.MdtrtareaAdmvs == "320921" {
  7007. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7008. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7009. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7010. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7011. } else {
  7012. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7013. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7014. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7015. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7016. }
  7017. resp3, requestErr3 := http.Get(api3)
  7018. if requestErr3 != nil {
  7019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7020. return
  7021. }
  7022. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7023. if ioErr3 != nil {
  7024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. return
  7027. }
  7028. var respJSON3 map[string]interface{}
  7029. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7035. userJSONBytes3, _ := json.Marshal(respJSON3)
  7036. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7037. utils.ErrorLog("解析失败:%v", err)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7042. res2.Output = resSix10265.Output
  7043. res2.ErrMsg = resSix10265.ErrMsg
  7044. res2.Cainfo = resSix10265.Cainfo
  7045. res2.WarnMsg = resSix10265.WarnMsg
  7046. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7047. res2.Infcode = infocode
  7048. } else {
  7049. var api3 string
  7050. if miConfig.Code == "H15049901371" {
  7051. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7052. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7054. } else {
  7055. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7056. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7058. }
  7059. resp3, requestErr3 := http.Get(api3)
  7060. if requestErr3 != nil {
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7065. if ioErr3 != nil {
  7066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. var respJSON3 map[string]interface{}
  7071. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7074. return
  7075. }
  7076. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7077. userJSONBytes3, _ := json.Marshal(respJSON3)
  7078. if miConfig.Code == "H15049901371" {
  7079. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7080. utils.ErrorLog("解析失败:%v", err)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. return
  7083. }
  7084. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7085. res2.Output = resSix10265.Output
  7086. res2.ErrMsg = resSix10265.ErrMsg
  7087. res2.Cainfo = resSix10265.Cainfo
  7088. res2.WarnMsg = resSix10265.WarnMsg
  7089. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7090. res2.Infcode = infocode
  7091. } else {
  7092. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7093. utils.ErrorLog("解析失败:%v", err)
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. return
  7096. }
  7097. }
  7098. }
  7099. if res2.Infcode == 0 {
  7100. if err == nil {
  7101. c.ServeSuccessJSON(map[string]interface{}{
  7102. "msg": "退号成功",
  7103. })
  7104. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7105. } else {
  7106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7107. return
  7108. }
  7109. } else {
  7110. c.ServeSuccessJSON(map[string]interface{}{
  7111. "code": -10,
  7112. "msg": res2.ErrMsg,
  7113. })
  7114. }
  7115. } else {
  7116. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7117. //if err == nil {
  7118. // c.ServeSuccessJSON(map[string]interface{}{
  7119. // "msg": "退费成功",
  7120. // })
  7121. //} else {
  7122. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. // return
  7124. //}
  7125. }
  7126. }
  7127. func (c *HisApiController) RefundDetail() {
  7128. order_id, _ := c.GetInt64("order_id")
  7129. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7130. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7131. number := c.GetString("number")
  7132. record_time := c.GetString("record_time")
  7133. patient_id, _ := c.GetInt64("patient_id")
  7134. //med_type, _ := c.GetInt64("med_type")
  7135. timeLayout := "2006-01-02"
  7136. loc, _ := time.LoadLocation("Local")
  7137. adminUser := c.GetAdminUserInfo()
  7138. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7139. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7140. fmt.Println(err)
  7141. if err != nil {
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7143. return
  7144. }
  7145. recordDateTime := theTime.Unix()
  7146. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7147. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7148. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7149. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7150. var order models.HisOrder
  7151. order, _ = service.GetHisOrderByID(order_id)
  7152. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7153. if config.IsOpen == 1 { //对接了医保,走医保流程
  7154. var res2 ResultSix
  7155. if miConfig.MdtrtareaAdmvs == "421300" {
  7156. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7157. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7159. resp3, requestErr3 := http.Get(api3)
  7160. if requestErr3 != nil {
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7165. if ioErr3 != nil {
  7166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. var respJSON3 map[string]interface{}
  7171. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. return
  7175. }
  7176. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7177. userJSONBytes3, _ := json.Marshal(respJSON3)
  7178. fmt.Println("log")
  7179. fmt.Println(string(userJSONBytes3))
  7180. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7181. utils.ErrorLog("解析失败:%v", err)
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. return
  7184. }
  7185. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7186. if err == nil {
  7187. c.ServeSuccessJSON(map[string]interface{}{
  7188. "msg": "撤销明细成功",
  7189. })
  7190. return
  7191. } else {
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7196. var resSix10265 ResultSix10265
  7197. var api3 string
  7198. if miConfig.MdtrtareaAdmvs == "320921" {
  7199. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7200. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7201. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7202. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7203. } else {
  7204. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7205. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7206. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7208. }
  7209. resp3, requestErr3 := http.Get(api3)
  7210. if requestErr3 != nil {
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7215. if ioErr3 != nil {
  7216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. return
  7219. }
  7220. var respJSON3 map[string]interface{}
  7221. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7224. return
  7225. }
  7226. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7227. userJSONBytes3, _ := json.Marshal(respJSON3)
  7228. fmt.Println("log")
  7229. fmt.Println(string(userJSONBytes3))
  7230. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7231. utils.ErrorLog("解析失败:%v", err)
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7236. res2.Output = resSix10265.Output
  7237. res2.ErrMsg = resSix10265.ErrMsg
  7238. res2.Cainfo = resSix10265.Cainfo
  7239. res2.WarnMsg = resSix10265.WarnMsg
  7240. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7241. res2.Infcode = infocode
  7242. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7243. if err == nil {
  7244. c.ServeSuccessJSON(map[string]interface{}{
  7245. "msg": "撤销明细成功",
  7246. })
  7247. return
  7248. } else {
  7249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7250. return
  7251. }
  7252. } else {
  7253. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7254. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7256. resp2, requestErr2 := http.Get(api2)
  7257. if requestErr2 != nil {
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7262. if ioErr2 != nil {
  7263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7265. return
  7266. }
  7267. var respJSON2 map[string]interface{}
  7268. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7271. return
  7272. }
  7273. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7274. if err == nil {
  7275. c.ServeSuccessJSON(map[string]interface{}{
  7276. "msg": "撤销明细成功",
  7277. })
  7278. return
  7279. } else {
  7280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7281. return
  7282. }
  7283. }
  7284. } else {
  7285. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7286. if err == nil {
  7287. c.ServeSuccessJSON(map[string]interface{}{
  7288. "msg": "退费成功",
  7289. })
  7290. } else {
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. }
  7295. }
  7296. //对账
  7297. func (c *HisApiController) GetCheckAccount() {
  7298. start_time := c.GetString("start_time")
  7299. end_time := c.GetString("end_time")
  7300. insutype := c.GetString("insutype")
  7301. clr_type := c.GetString("clr_type")
  7302. clr_org := c.GetString("clr_optins")
  7303. admin_user_id, _ := c.GetInt64("admin_user_id")
  7304. adminUser := c.GetAdminUserInfo()
  7305. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7306. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7307. if len(clr_org) == 0 {
  7308. clr_org = miConfig.MdtrtareaAdmvs
  7309. }
  7310. timeLayout := "2006-01-02"
  7311. loc, _ := time.LoadLocation("Local")
  7312. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7313. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7314. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7315. fixmedins_setl_cnt := int64(len(orders))
  7316. var medfee_sumamt float64
  7317. var acct_pay float64
  7318. var fund_pay_sumamt float64
  7319. for _, item := range orders {
  7320. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7321. acct_pay = acct_pay + item.AcctPay
  7322. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7323. }
  7324. var user_name string
  7325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7326. if role.ID == 0 {
  7327. user_name = "xxx"
  7328. } else {
  7329. user_name = role.UserName
  7330. }
  7331. var res ResultEight
  7332. var res10188 ResultEightFor10188
  7333. if config.IsOpen == 1 {
  7334. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7335. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7336. "insutype=" + insutype +
  7337. "&clr_type=" + "11" +
  7338. "&setl_optins=" + clr_org +
  7339. "&stmt_begndate=" + start_time +
  7340. "&stm_enddate=" + end_time +
  7341. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7342. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7343. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7344. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7345. "&fixmedins_code=" + miConfig.Code +
  7346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7347. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7348. "&secret_key=" + miConfig.SecretKey +
  7349. "&org_name=" + miConfig.OrgName +
  7350. "&doctor=" + user_name +
  7351. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7352. fmt.Println(api)
  7353. resp, requestErr := http.Get(api)
  7354. if requestErr != nil {
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. body, ioErr := ioutil.ReadAll(resp.Body)
  7359. fmt.Println(body)
  7360. if ioErr != nil {
  7361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. return
  7364. }
  7365. var respJSON map[string]interface{}
  7366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7369. return
  7370. }
  7371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7372. userJSONBytes, _ := json.Marshal(respJSON)
  7373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7374. utils.ErrorLog("解析失败:%v", err)
  7375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7376. return
  7377. }
  7378. res.InfRefmsgid = res10188.InfRefmsgid
  7379. res.Output = res10188.Output
  7380. res.ErrMsg = res10188.ErrMsg
  7381. res.Cainfo = res10188.Cainfo
  7382. res.WarnMsg = res10188.WarnMsg
  7383. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7384. res.Infcode = infocode
  7385. } else {
  7386. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7387. "insutype=" + insutype +
  7388. "&clr_type=" + clr_type +
  7389. "&setl_optins=" + clr_org +
  7390. "&stmt_begndate=" + start_time +
  7391. "&stm_enddate=" + end_time +
  7392. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7393. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7394. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7395. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7396. "&fixmedins_code=" + miConfig.Code +
  7397. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7398. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7399. "&secret_key=" + miConfig.SecretKey +
  7400. "&org_name=" + miConfig.OrgName +
  7401. "&doctor=" + user_name
  7402. fmt.Println(api)
  7403. resp, requestErr := http.Get(api)
  7404. if requestErr != nil {
  7405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. return
  7407. }
  7408. body, ioErr := ioutil.ReadAll(resp.Body)
  7409. fmt.Println(body)
  7410. if ioErr != nil {
  7411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7413. return
  7414. }
  7415. var respJSON map[string]interface{}
  7416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7419. return
  7420. }
  7421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7422. userJSONBytes, _ := json.Marshal(respJSON)
  7423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7424. utils.ErrorLog("解析失败:%v", err)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. return
  7427. }
  7428. }
  7429. if res.Infcode == 0 {
  7430. if res.Output.Stmtinfo.StmtRslt == "0" {
  7431. micc := &models.MedicalInsuranceCostCompare{
  7432. StartTime: startime.Unix(),
  7433. EndTime: endtime.Unix(),
  7434. Insutype: insutype,
  7435. CheckType: 1,
  7436. Num: fixmedins_setl_cnt,
  7437. Mtime: time.Now().Unix(),
  7438. Status: 1,
  7439. UserOrgId: adminUser.CurrentOrgId,
  7440. CostTotal: medfee_sumamt,
  7441. FuncTotal: fund_pay_sumamt,
  7442. PsnPay: acct_pay,
  7443. Creator: admin_user_id,
  7444. Ctime: time.Now().Unix(),
  7445. ClrType: clr_type,
  7446. }
  7447. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7448. if err == nil {
  7449. c.ServeSuccessJSON(map[string]interface{}{
  7450. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7451. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7452. })
  7453. } else {
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. }
  7456. } else {
  7457. c.ServeSuccessJSON(map[string]interface{}{
  7458. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7459. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7460. })
  7461. }
  7462. } else {
  7463. c.ServeSuccessJSON(map[string]interface{}{
  7464. "code": -10,
  7465. "msg": res.ErrMsg,
  7466. })
  7467. }
  7468. }
  7469. }
  7470. func (c *HisApiController) Check310() {
  7471. adminUser := c.GetAdminUserInfo()
  7472. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7473. var user_name string
  7474. user_name = "高慧裕"
  7475. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7476. "insutype=" + "310" +
  7477. "&clr_type=" + "" +
  7478. "&setl_optins=" + "441202" +
  7479. "&stmt_begndate=" + "2022-03-01" +
  7480. "&stm_enddate=" + "2022-03-31" +
  7481. "&medfee_sumamt=" + "194930.12" +
  7482. "&fund_pay_sumamt=" + "188741.46" +
  7483. "&acct_pay=" + "0" +
  7484. "&fixmedins_setl_cnt=" + "452" +
  7485. "&fixmedins_code=" + miConfig.Code +
  7486. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7487. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7488. "&secret_key=" + miConfig.SecretKey +
  7489. "&org_name=" + miConfig.OrgName +
  7490. "&doctor=" + user_name
  7491. fmt.Println(api)
  7492. resp, requestErr := http.Get(api)
  7493. if requestErr != nil {
  7494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7495. return
  7496. }
  7497. body, ioErr := ioutil.ReadAll(resp.Body)
  7498. fmt.Println(body)
  7499. if ioErr != nil {
  7500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7502. return
  7503. }
  7504. var respJSON map[string]interface{}
  7505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7508. return
  7509. }
  7510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7511. userJSONBytes, _ := json.Marshal(respJSON)
  7512. var res ResultEight
  7513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7514. utils.ErrorLog("解析失败:%v", err)
  7515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7516. return
  7517. }
  7518. }
  7519. func (c *HisApiController) Check390() {
  7520. adminUser := c.GetAdminUserInfo()
  7521. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7522. var user_name string
  7523. user_name = "高慧裕"
  7524. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7525. "insutype=" + "390" +
  7526. "&clr_type=" + "" +
  7527. "&setl_optins=" + "441202" +
  7528. "&stmt_begndate=" + "2022-03-01" +
  7529. "&stm_enddate=" + "2022-03-31" +
  7530. "&medfee_sumamt=" + "1068448.89" +
  7531. "&fund_pay_sumamt=" + "1014677.62" +
  7532. "&acct_pay=" + "0" +
  7533. "&fixmedins_setl_cnt=" + "1950" +
  7534. "&fixmedins_code=" + miConfig.Code +
  7535. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7536. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7537. "&secret_key=" + miConfig.SecretKey +
  7538. "&org_name=" + miConfig.OrgName +
  7539. "&doctor=" + user_name
  7540. fmt.Println(api)
  7541. resp, requestErr := http.Get(api)
  7542. if requestErr != nil {
  7543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7544. return
  7545. }
  7546. body, ioErr := ioutil.ReadAll(resp.Body)
  7547. fmt.Println(body)
  7548. if ioErr != nil {
  7549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7551. return
  7552. }
  7553. var respJSON map[string]interface{}
  7554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. return
  7558. }
  7559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7560. userJSONBytes, _ := json.Marshal(respJSON)
  7561. var res ResultEight
  7562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7563. utils.ErrorLog("解析失败:%v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. }
  7568. //对账明细
  7569. func (c *HisApiController) GetCheckDetailAccount() {
  7570. start_time := c.GetString("start_time")
  7571. end_time := c.GetString("end_time")
  7572. admin_user_id, _ := c.GetInt64("admin_user_id")
  7573. adminUser := c.GetAdminUserInfo()
  7574. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7575. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7576. timeLayout := "2006-01-02"
  7577. loc, _ := time.LoadLocation("Local")
  7578. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7579. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7580. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7581. Mkdir(miConfig.OrgName)
  7582. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7583. file_name := file + ".txt"
  7584. zip_name := file + ".zip"
  7585. zip_path := miConfig.OrgName + "/" + zip_name
  7586. file_path := miConfig.OrgName + "/" + file_name
  7587. decimal.DivisionPrecision = 2
  7588. var medfee_sumamt float64
  7589. var psn_cash_pay float64
  7590. var fund_pay_sumamt float64
  7591. fixmedins_setl_cnt := int64(len(orders))
  7592. for _, item := range orders {
  7593. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7594. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7595. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7596. }
  7597. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7598. defer f.Close()
  7599. if err != nil {
  7600. fmt.Println(err.Error())
  7601. } else {
  7602. for _, item := range orders {
  7603. var refd_setl_flag string
  7604. if item.OrderStatus == 2 {
  7605. refd_setl_flag = "0"
  7606. var str string
  7607. str = item.SetlId + " " +
  7608. item.MdtrtId + " " +
  7609. item.PsnNo + " " +
  7610. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7611. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7612. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7613. _, err = f.Write([]byte(str))
  7614. }
  7615. if item.OrderStatus == 3 {
  7616. var str string
  7617. str = item.SetlId + " " +
  7618. item.MdtrtId + " " +
  7619. item.PsnNo + " " +
  7620. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7621. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7622. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7623. _, err = f.Write([]byte(str))
  7624. var str2 string
  7625. str2 = item.SetlId + " " +
  7626. item.MdtrtId + " " +
  7627. item.PsnNo + " " +
  7628. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7629. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7630. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7631. _, err = f.Write([]byte(str2))
  7632. }
  7633. }
  7634. }
  7635. Zip(file_path, zip_path)
  7636. fmt.Println(ReadFile(zip_path))
  7637. fmt.Println(string(ReadFile(zip_path)))
  7638. if config.IsOpen == 1 {
  7639. var user_name string
  7640. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7641. if role.ID == 0 {
  7642. user_name = "管理员"
  7643. } else {
  7644. user_name = role.UserName
  7645. }
  7646. baseParams := models.BaseParams{
  7647. SecretKey: miConfig.SecretKey,
  7648. FixmedinsCode: miConfig.Code,
  7649. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7650. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7651. OrgName: miConfig.OrgName,
  7652. Doctor: user_name,
  7653. }
  7654. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7655. var dat map[string]interface{}
  7656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7657. fmt.Println(dat)
  7658. } else {
  7659. fmt.Println(err)
  7660. }
  7661. userJSONBytes, _ := json.Marshal(dat)
  7662. var res ResultNine
  7663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7664. utils.ErrorLog("解析失败:%v", err)
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7666. return
  7667. }
  7668. if res.Infcode == 0 {
  7669. fileNo := res.Output.FileQuryNo
  7670. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7671. "file_qury_no=" + fileNo +
  7672. "&setl_optins=" + "定点医保中心" +
  7673. "&stmt_begndate=" + start_time +
  7674. "&stm_enddate=" + end_time +
  7675. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7676. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7677. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7678. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7679. "&fixmedins_code=" + miConfig.Code +
  7680. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7681. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7682. "&secret_key=" + miConfig.SecretKey +
  7683. "&org_name=" + miConfig.OrgName +
  7684. "&doctor=" + user_name
  7685. resp, requestErr := http.Get(api)
  7686. if requestErr != nil {
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7688. return
  7689. }
  7690. body, ioErr := ioutil.ReadAll(resp.Body)
  7691. if ioErr != nil {
  7692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7694. return
  7695. }
  7696. var respJSON map[string]interface{}
  7697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7703. userJSONBytes, _ := json.Marshal(respJSON)
  7704. var res ResultTen
  7705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7706. utils.ErrorLog("解析失败:%v", err)
  7707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7708. return
  7709. }
  7710. if res.Infcode == 0 {
  7711. service.Gdyb9102(baseParams, zip_name, fileNo)
  7712. micc := &models.MedicalInsuranceCostCompare{
  7713. StartTime: startime.Unix(),
  7714. EndTime: endtime.Unix(),
  7715. Insutype: "0",
  7716. CheckType: 2,
  7717. Num: fixmedins_setl_cnt,
  7718. Mtime: time.Now().Unix(),
  7719. Status: 1,
  7720. UserOrgId: adminUser.CurrentOrgId,
  7721. CostTotal: medfee_sumamt,
  7722. FuncTotal: fund_pay_sumamt,
  7723. PsnPay: psn_cash_pay,
  7724. Creator: admin_user_id,
  7725. Ctime: time.Now().Unix(),
  7726. }
  7727. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7728. c.ServeSuccessJSON(map[string]interface{}{
  7729. "msg": "明细对账成功",
  7730. })
  7731. }
  7732. } else {
  7733. }
  7734. }
  7735. }
  7736. type CustomOrderInfo struct {
  7737. Name string
  7738. Spec string
  7739. Unit string
  7740. Count float64
  7741. Price float64
  7742. Total float64
  7743. }
  7744. func (c *HisApiController) GetSettleAccounts() {
  7745. //id, _ := c.GetInt64("id")
  7746. //record_time := c.GetString("record_time")
  7747. order_id, _ := c.GetInt64("order_id")
  7748. admin_user_id, _ := c.GetInt64("admin_user_id")
  7749. //timeLayout := "2006-01-02"
  7750. //loc, _ := time.LoadLocation("Local")
  7751. //
  7752. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7753. //if err != nil {
  7754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7755. // return
  7756. //}
  7757. //recordDateTime := theTime.Unix()
  7758. adminUser := c.GetAdminUserInfo()
  7759. order, _ := service.GetHisOrderByID(order_id)
  7760. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7761. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7762. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7763. orderInfos = append(orderInfos, orderInfos_two...)
  7764. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7765. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7766. var diagnosis_ids []string
  7767. if his.ID > 0 {
  7768. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  7769. } else {
  7770. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  7771. }
  7772. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7773. var dia_config []*models.HisXtDiagnoseConfig
  7774. var name string
  7775. for _, item := range diagnosis_ids {
  7776. id, _ := strconv.ParseInt(item, 10, 64)
  7777. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7778. dia_config = append(dia_config, &diagnosisConfig)
  7779. if len(name) == 0 {
  7780. name = diagnosisConfig.ClassName
  7781. } else {
  7782. name = name + "," + diagnosisConfig.ClassName
  7783. }
  7784. }
  7785. var bedCostTotal float64 = 0 //床位总费
  7786. var bedCostSelfTotal float64 = 0 //床位自费
  7787. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7788. var operationCostTotal float64 = 0 //手术费
  7789. var operationCostSelfTotal float64 = 0 //手术费
  7790. var operationCostPartSelfTotal float64 = 0 //手术费
  7791. var otherCostTotal float64 = 0 //其他费用
  7792. var otherCostSelfTotal float64 = 0 //其他费用
  7793. var otherCostPartSelfTotal float64 = 0 //其他费用
  7794. var materialCostTotal float64 = 0 //材料费
  7795. var materialCostSelfTotal float64 = 0 //材料费
  7796. var materialCostPartSelfTotal float64 = 0 //材料费
  7797. var westernMedicineCostTotal float64 = 0 //西药费
  7798. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7799. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7800. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7801. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7802. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7803. var checkCostTotal float64 = 0 //检查费
  7804. var checkCostSelfTotal float64 = 0 //检查费
  7805. var checkCostPartSelfTotal float64 = 0 //检查费
  7806. var laboratoryCostTotal float64 = 0 //化验费
  7807. var laboratoryCostSelfTotal float64 = 0 //化验费
  7808. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7809. var treatCostTotal float64 = 0 //治疗费用
  7810. var treatCostSelfTotal float64 = 0 //治疗费用
  7811. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7812. decimal.DivisionPrecision = 2
  7813. for _, item := range orderInfos {
  7814. if item.MedChrgitmType == "01" { //床位费
  7815. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7816. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7817. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7818. }
  7819. if item.MedChrgitmType == "03" { //检查费
  7820. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7821. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7822. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7823. }
  7824. if item.MedChrgitmType == "04" { //化验费
  7825. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7826. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7827. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7828. }
  7829. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7830. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7831. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7832. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7833. }
  7834. if item.MedChrgitmType == "06" { //手术费
  7835. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7836. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7837. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7838. }
  7839. if item.MedChrgitmType == "08" { //材料费
  7840. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7841. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7842. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7843. }
  7844. if item.MedChrgitmType == "09" { //西药费
  7845. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7846. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7847. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7848. }
  7849. if item.MedChrgitmType == "11" { //中成费
  7850. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7851. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7852. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7853. }
  7854. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7855. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7856. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7857. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7858. }
  7859. }
  7860. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7861. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7862. var user_name string
  7863. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7864. if role.ID == 0 {
  7865. user_name = "管理员"
  7866. } else {
  7867. user_name = role.UserName
  7868. }
  7869. baseParams := models.BaseParams{
  7870. SecretKey: miConfig.SecretKey,
  7871. FixmedinsCode: miConfig.Code,
  7872. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7873. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7874. OrgName: miConfig.OrgName,
  7875. Doctor: user_name,
  7876. }
  7877. businessParams := models.BusinessParams{
  7878. PsnNo: order.PsnNo,
  7879. MdtrtId: order.MdtrtId,
  7880. SetlId: order.SetlId,
  7881. }
  7882. var res ResultEleven
  7883. var resEleven10265 ResultEleven10265
  7884. if config.IsOpen == 1 {
  7885. if miConfig.MdtrtareaAdmvs == "421300" {
  7886. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7887. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7888. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7889. resp, requestErr := http.Get(api)
  7890. if requestErr != nil {
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. body, ioErr := ioutil.ReadAll(resp.Body)
  7895. if ioErr != nil {
  7896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. var respJSON map[string]interface{}
  7901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7907. result, _ := json.Marshal(respJSON)
  7908. fmt.Println("log")
  7909. fmt.Println(string(result))
  7910. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7911. utils.ErrorLog("解析失败:%v", err)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7916. var api string
  7917. if miConfig.MdtrtareaAdmvs == "320921" {
  7918. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7919. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7920. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7921. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7922. } else {
  7923. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7924. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7925. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7926. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7927. }
  7928. resp, requestErr := http.Get(api)
  7929. if requestErr != nil {
  7930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7931. return
  7932. }
  7933. body, ioErr := ioutil.ReadAll(resp.Body)
  7934. if ioErr != nil {
  7935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. return
  7938. }
  7939. var respJSON map[string]interface{}
  7940. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. return
  7944. }
  7945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7946. result, _ := json.Marshal(respJSON)
  7947. fmt.Println("log")
  7948. fmt.Println(string(result))
  7949. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7950. utils.ErrorLog("解析失败:%v", err)
  7951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. return
  7953. }
  7954. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7955. res.Output = resEleven10265.Output
  7956. res.ErrMsg = resEleven10265.ErrMsg
  7957. res.Cainfo = resEleven10265.Cainfo
  7958. res.WarnMsg = resEleven10265.WarnMsg
  7959. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7960. res.Infcode = infocode
  7961. } else {
  7962. //result2 := service.Gdyb1101()
  7963. result2 := service.Gdyb5204(baseParams, businessParams)
  7964. saveLog(result2, "", "5204", "查询")
  7965. result := service.Gdyb5203(baseParams, businessParams)
  7966. var dat map[string]interface{}
  7967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7968. fmt.Println(dat)
  7969. } else {
  7970. fmt.Println(err)
  7971. }
  7972. userJSONBytes, _ := json.Marshal(dat)
  7973. if miConfig.Code == "H15049901371" {
  7974. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7975. utils.ErrorLog("解析失败:%v", err)
  7976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. return
  7978. }
  7979. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7980. res.Output = resEleven10265.Output
  7981. res.ErrMsg = resEleven10265.ErrMsg
  7982. res.Cainfo = resEleven10265.Cainfo
  7983. res.WarnMsg = resEleven10265.WarnMsg
  7984. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7985. res.Infcode = infocode
  7986. } else {
  7987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7988. utils.ErrorLog("解析失败:%v", err)
  7989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7990. return
  7991. }
  7992. }
  7993. }
  7994. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7995. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7996. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7997. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7998. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  7999. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8000. var doctor_name string
  8001. if roles.ID == 0 {
  8002. doctor_name = "管理员"
  8003. } else {
  8004. doctor_name = roles.UserName
  8005. }
  8006. yiliao_leibie := ""
  8007. switch order.MedType {
  8008. case "11":
  8009. yiliao_leibie = "普通门诊"
  8010. break
  8011. case "12":
  8012. yiliao_leibie = "门诊挂号"
  8013. break
  8014. case "13":
  8015. yiliao_leibie = "急诊"
  8016. break
  8017. case "14":
  8018. yiliao_leibie = "门诊特殊病"
  8019. break
  8020. case "15":
  8021. yiliao_leibie = "门诊统筹"
  8022. break
  8023. case "16":
  8024. yiliao_leibie = "门诊慢性病"
  8025. break
  8026. case "21":
  8027. yiliao_leibie = "普通住院"
  8028. break
  8029. }
  8030. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8031. if res.Infcode == 0 {
  8032. c.ServeSuccessJSON(map[string]interface{}{
  8033. "diagnosis": name,
  8034. "order_infos": orderInfos,
  8035. "number": order.MdtrtId,
  8036. "date": order.SettleAccountsDate,
  8037. "charge_admin": charge_admin,
  8038. "printor_admin": printor_admin,
  8039. "info": res.Output.Setlinfo,
  8040. "order": order,
  8041. "bedCostTotal": bedCostTotal,
  8042. "bedCostSelfTotal": bedCostSelfTotal,
  8043. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8044. "operationCostTotal": operationCostTotal,
  8045. "operationCostSelfTotal": operationCostSelfTotal,
  8046. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8047. "otherCostTotal": otherCostTotal,
  8048. "otherCostSelfTotal": otherCostSelfTotal,
  8049. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8050. "materialCostTotal": materialCostTotal,
  8051. "materialCostSelfTotal": materialCostSelfTotal,
  8052. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8053. "westernMedicineCostTotal": westernMedicineCostTotal,
  8054. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8055. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8056. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8057. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8058. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8059. "checkCostTotal": checkCostTotal,
  8060. "checkCostSelfTotal": checkCostSelfTotal,
  8061. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8062. "laboratoryCostTotal": laboratoryCostTotal,
  8063. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8064. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8065. "treatCostTotal": treatCostTotal,
  8066. "treatCostSelfTotal": treatCostSelfTotal,
  8067. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8068. "doctor_info": doctor_info,
  8069. "doctor_code": adminRole_two.DoctorCode,
  8070. "doctor_name": doctor_name,
  8071. "health_card_no": order.PsnNo,
  8072. "department": departments.Name,
  8073. "yiliao_leibie": yiliao_leibie,
  8074. "after_money": order.AccountPrice,
  8075. "patient": patient,
  8076. "org_name": miConfig.OrgName,
  8077. "org_code": miConfig.Code,
  8078. "order_number": order.Number,
  8079. "his_hospital": his_hospital,
  8080. "his": his,
  8081. "dia_config": dia_config,
  8082. //"check_order_info": cus_slice,
  8083. })
  8084. }
  8085. }
  8086. }
  8087. func (c *HisApiController) CheckTreatment() {
  8088. patient_id, _ := c.GetInt64("patient_id")
  8089. id_card_no := c.GetString("id_card_no")
  8090. insutype := c.GetString("insutype")
  8091. med_type := c.GetString("med_type")
  8092. admin_user_id, _ := c.GetInt64("admin_user_id")
  8093. adminUser := c.GetAdminUserInfo()
  8094. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8096. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8097. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8098. if miConfig.MdtrtareaAdmvs == "421300" {
  8099. var res ResultTwo
  8100. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8101. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8102. "&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)
  8103. resp, requestErr := http.Get(api)
  8104. if requestErr != nil {
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8106. return
  8107. }
  8108. body, ioErr := ioutil.ReadAll(resp.Body)
  8109. if ioErr != nil {
  8110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8112. return
  8113. }
  8114. var respJSON map[string]interface{}
  8115. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8121. result, _ := json.Marshal(respJSON)
  8122. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8123. utils.ErrorLog("解析失败:%v", err)
  8124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. return
  8126. }
  8127. if res.Infcode == 0 {
  8128. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8129. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8131. resp, requestErr := http.Get(api)
  8132. if requestErr != nil {
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. body, ioErr := ioutil.ReadAll(resp.Body)
  8137. if ioErr != nil {
  8138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. var respJSON map[string]interface{}
  8143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. var res Result2001
  8149. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8150. result2, _ := json.Marshal(respJSON)
  8151. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8152. utils.ErrorLog("解析失败:%v", err)
  8153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. return
  8155. }
  8156. if res.Infcode == 0 {
  8157. c.ServeSuccessJSON(map[string]interface{}{
  8158. "msg": res.Output.Trtinfo,
  8159. })
  8160. }
  8161. } else {
  8162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8163. return
  8164. }
  8165. } else {
  8166. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8167. var dat map[string]interface{}
  8168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8169. fmt.Println(dat)
  8170. } else {
  8171. fmt.Println(err)
  8172. }
  8173. userJSONBytes, _ := json.Marshal(dat)
  8174. var res ResultTwo
  8175. var res10265 ResultTwo10265
  8176. if miConfig.Code == "H15049901371" {
  8177. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8178. utils.ErrorLog("解析失败:%v", err)
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8180. return
  8181. }
  8182. res.ErrMsg = res10265.ErrMsg
  8183. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8184. res.Infcode = infocode
  8185. res.Output = res10265.Output
  8186. res.InfRefmsgid = res10265.InfRefmsgid
  8187. } else {
  8188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8189. utils.ErrorLog("解析失败:%v", err)
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8191. return
  8192. }
  8193. }
  8194. var user_name string
  8195. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8196. if role.ID == 0 {
  8197. user_name = "xxx"
  8198. } else {
  8199. user_name = role.UserName
  8200. }
  8201. baseParams := models.BaseParams{
  8202. SecretKey: miConfig.SecretKey,
  8203. FixmedinsCode: miConfig.Code,
  8204. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8205. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8206. OrgName: miConfig.OrgName,
  8207. Doctor: user_name,
  8208. }
  8209. if config.IsOpen == 1 {
  8210. if miConfig.Code == "H15049901371" {
  8211. if med_type == "14" {
  8212. if insutype == "390" {
  8213. med_type = "9933"
  8214. } else if insutype == "310" {
  8215. med_type = "990502"
  8216. }
  8217. } else if med_type == "11" {
  8218. med_type = "11"
  8219. }
  8220. }
  8221. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8222. var dat map[string]interface{}
  8223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8224. fmt.Println(dat)
  8225. } else {
  8226. fmt.Println(err)
  8227. }
  8228. var res Result2001
  8229. var res10265 Result2001Org10265
  8230. if miConfig.Code == "H15049901371" {
  8231. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8232. utils.ErrorLog("解析失败:%v", err)
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8234. return
  8235. }
  8236. res.ErrMsg = res10265.ErrMsg
  8237. res.Output = res10265.Output
  8238. res.InfRefmsgid = res10265.InfRefmsgid
  8239. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8240. res.Infcode = infocode
  8241. } else {
  8242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8243. utils.ErrorLog("解析失败:%v", err)
  8244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8245. return
  8246. }
  8247. }
  8248. if res.Infcode == 0 {
  8249. c.ServeSuccessJSON(map[string]interface{}{
  8250. "msg": res.Output.Trtinfo,
  8251. })
  8252. }
  8253. }
  8254. }
  8255. }
  8256. //func (c *HisApiController) PutRecord() {
  8257. // id, _ := c.GetInt64("id")
  8258. // record_time := c.GetString("record_time")
  8259. // timeLayout := "2006-01-02"
  8260. // loc, _ := time.LoadLocation("Local")
  8261. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8262. // if err != nil {
  8263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8264. // return
  8265. // }
  8266. // recordDateTime := theTime.Unix()
  8267. //
  8268. // adminInfo := c.GetAdminUserInfo()
  8269. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8270. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8271. //
  8272. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8273. //
  8274. // fmt.Println(miConfig.SecretKey)
  8275. //
  8276. // if patient == nil {
  8277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8278. // return
  8279. // }
  8280. // if len(patient.IdCardNo) == 0 {
  8281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8282. // return
  8283. // }
  8284. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8285. // if config.IsOpen == 1 {
  8286. // 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
  8287. // resp, requestErr := http.Get(api)
  8288. // if requestErr != nil {
  8289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8290. // return
  8291. // }
  8292. // defer resp.Body.Close()
  8293. // body, ioErr := ioutil.ReadAll(resp.Body)
  8294. // if ioErr != nil {
  8295. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. // return
  8298. // }
  8299. // var respJSON map[string]interface{}
  8300. //
  8301. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8302. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. // return
  8305. // }
  8306. //
  8307. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8308. // userJSONBytes, _ := json.Marshal(userJSON)
  8309. // var res ResultTwo
  8310. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8311. // utils.ErrorLog("解析失败:%v", err)
  8312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. // return
  8314. // }
  8315. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8316. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8317. // infoStr := string(Iinfos)
  8318. // idetinfoStr := string(Idetinfos)
  8319. //
  8320. // if res.Infcode == 0 {
  8321. // his := models.VMHisPatient{
  8322. // Status: 1,
  8323. // Ctime: time.Now().Unix(),
  8324. // Mtime: time.Now().Unix(),
  8325. // PsnNo: res.Output.Baseinfo.PsnNo,
  8326. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8327. // Certno: res.Output.Baseinfo.Certno,
  8328. // PsnName: res.Output.Baseinfo.PsnName,
  8329. // Gend: res.Output.Baseinfo.Gend,
  8330. // Naty: res.Output.Baseinfo.Naty,
  8331. // Brdy: res.Output.Baseinfo.Brdy,
  8332. // Age: res.Output.Baseinfo.Age,
  8333. // Iinfo: infoStr,
  8334. // Idetinfo: idetinfoStr,
  8335. // PatientId: patient.ID,
  8336. // RecordDate: theTime.Unix(),
  8337. // UserOrgId: adminInfo.CurrentOrgId,
  8338. // AdminUserId: adminInfo.AdminUser.Id,
  8339. // IsReturn: 1,
  8340. // }
  8341. //
  8342. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8343. // //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")
  8344. // //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")
  8345. //
  8346. // //var dat map[string]interface{}
  8347. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8348. // // fmt.Println(dat)
  8349. // //} else {
  8350. // // fmt.Println(err)
  8351. // //}
  8352. //
  8353. // var dat2 map[string]interface{}
  8354. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8355. // fmt.Println(dat2)
  8356. // } else {
  8357. // fmt.Println(err)
  8358. // }
  8359. //
  8360. // } else {
  8361. // adminUser := c.GetAdminUserInfo()
  8362. // errlog := &models.HisOrderError{
  8363. // UserOrgId: adminUser.CurrentOrgId,
  8364. // Ctime: time.Now().Unix(),
  8365. // Mtime: time.Now().Unix(),
  8366. // ErrMsg: res.ErrMsg,
  8367. // Status: 1,
  8368. // PatientId: id,
  8369. // RecordTime: recordDateTime,
  8370. // Stage: 1,
  8371. // }
  8372. // service.CreateErrMsgLog(errlog)
  8373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8374. // return
  8375. // }
  8376. // }
  8377. //
  8378. //}
  8379. //func (c *HisApiController) GetUploadDiag() {
  8380. // id, _ := c.GetInt64("id")
  8381. // record_time := c.GetString("record_time")
  8382. //
  8383. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8384. // sick_type, _ := c.GetInt64("sick_type")
  8385. // reg_type, _ := c.GetInt64("reg_type")
  8386. //
  8387. // timeLayout := "2006-01-02"
  8388. // loc, _ := time.LoadLocation("Local")
  8389. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8390. // if err != nil {
  8391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8392. // return
  8393. // }
  8394. //
  8395. // var patientPrescription models.HisPrescriptionInfo
  8396. // recordDateTime := theTime.Unix()
  8397. // adminInfo := c.GetAdminUserInfo()
  8398. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8399. //
  8400. // if patientPrescription.ID == 0 {
  8401. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8402. // }
  8403. //
  8404. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8405. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8406. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8407. // sickConfig, _ := service.FindSickById(sick_type)
  8408. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8409. //
  8410. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8411. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8412. // "&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 +
  8413. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8414. // resp2, requestErr2 := http.Get(api2)
  8415. // if requestErr2 != nil {
  8416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. // return
  8418. // }
  8419. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8420. // if ioErr2 != nil {
  8421. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. // return
  8424. // }
  8425. // var respJSON2 map[string]interface{}
  8426. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8427. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. // return
  8430. // }
  8431. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8432. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8433. //
  8434. // var res2 ResultSix
  8435. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8436. // utils.ErrorLog("解析失败:%v", err)
  8437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. // return
  8439. // }
  8440. // if res2.Infcode != 0 {
  8441. // adminUser := c.GetAdminUserInfo()
  8442. // errlog := &models.HisOrderError{
  8443. // UserOrgId: adminUser.CurrentOrgId,
  8444. // Ctime: time.Now().Unix(),
  8445. // Mtime: time.Now().Unix(),
  8446. // ErrMsg: res2.ErrMsg,
  8447. // Status: 1,
  8448. // PatientId: id,
  8449. // RecordTime: recordDateTime,
  8450. // Stage: 3,
  8451. // }
  8452. // service.CreateErrMsgLog(errlog)
  8453. //
  8454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8455. // return
  8456. // }
  8457. //
  8458. // c.ServeSuccessJSON(map[string]interface{}{
  8459. // "msg": "上传成功",
  8460. // })
  8461. //
  8462. //}
  8463. type QueryResult struct {
  8464. ID int64
  8465. Name string
  8466. Code string
  8467. List_type_code string
  8468. }
  8469. func (c *HisApiController) GetCheckCode() {
  8470. ids_str := c.GetString("ids")
  8471. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8472. ids_arr := strings.Split(ids_str, ",")
  8473. var queryResult []QueryResult
  8474. ids := make([]int64, 0)
  8475. for _, item := range ids_arr {
  8476. id, _ := strconv.ParseInt(item, 10, 64)
  8477. ids = append(ids, id)
  8478. }
  8479. if record_type == 1 {
  8480. drugs, _ := service.GetBatchDrugList(ids)
  8481. for _, item := range drugs {
  8482. result := QueryResult{
  8483. ID: item.ID,
  8484. Name: item.DrugName,
  8485. Code: item.MedicalInsuranceNumber,
  8486. List_type_code: "101",
  8487. }
  8488. queryResult = append(queryResult, result)
  8489. }
  8490. } else if record_type == 2 {
  8491. goods, _ := service.GetBatchGoodInformationList(ids)
  8492. for _, item := range goods {
  8493. result := QueryResult{
  8494. ID: item.ID,
  8495. Name: item.GoodName,
  8496. Code: item.MedicalInsuranceNumber,
  8497. List_type_code: "301",
  8498. }
  8499. queryResult = append(queryResult, result)
  8500. }
  8501. } else if record_type == 3 {
  8502. projects, _ := service.GetBathchMyPorjecgList(ids)
  8503. for _, item := range projects {
  8504. result := QueryResult{
  8505. ID: item.ID,
  8506. Name: item.ProjectName,
  8507. Code: item.MedicalCode,
  8508. List_type_code: "201",
  8509. }
  8510. queryResult = append(queryResult, result)
  8511. }
  8512. }
  8513. admin_user_id, _ := c.GetInt64("admin_user_id")
  8514. adminUser := c.GetAdminUserInfo()
  8515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8516. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8517. var user_name string
  8518. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8519. if role.ID == 0 {
  8520. user_name = "xxx"
  8521. } else {
  8522. user_name = role.UserName
  8523. }
  8524. baseParams := &models.BaseParams{
  8525. SecretKey: miConfig.SecretKey,
  8526. FixmedinsCode: miConfig.Code,
  8527. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8528. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8529. OrgName: miConfig.OrgName,
  8530. Doctor: user_name,
  8531. }
  8532. if config.IsOpen == 1 {
  8533. for _, item := range queryResult {
  8534. var result string
  8535. if record_type == 1 {
  8536. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8537. } else if record_type == 2 {
  8538. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8539. } else if record_type == 3 {
  8540. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8541. }
  8542. var dat map[string]interface{}
  8543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8544. fmt.Println(dat)
  8545. } else {
  8546. fmt.Println(err)
  8547. }
  8548. userJSONBytes, _ := json.Marshal(dat)
  8549. var res ResultSix
  8550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8551. utils.ErrorLog("解析失败:%v", err)
  8552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8553. return
  8554. }
  8555. if res.Infcode == 0 {
  8556. if record_type == 1 {
  8557. service.UpdateBaseDrugById(item.ID)
  8558. } else if record_type == 2 {
  8559. service.UpdateGoodInformaitonByDetail(item.ID)
  8560. } else if record_type == 3 {
  8561. service.UpdateProjectById(item.ID)
  8562. }
  8563. c.ServeSuccessJSON(map[string]interface{}{
  8564. "failed_code": 0,
  8565. "msg": "目录对照成功",
  8566. })
  8567. } else {
  8568. c.ServeSuccessJSON(map[string]interface{}{
  8569. "failed_code": -10,
  8570. "msg": res.ErrMsg,
  8571. })
  8572. }
  8573. }
  8574. }
  8575. }
  8576. func (c *HisApiController) UnCheckCode() {
  8577. ids_str := c.GetString("ids")
  8578. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8579. admin_user_id, _ := c.GetInt64("admin_user_id")
  8580. ids_arr := strings.Split(ids_str, ",")
  8581. var queryResult []QueryResult
  8582. ids := make([]int64, 0)
  8583. for _, item := range ids_arr {
  8584. id, _ := strconv.ParseInt(item, 10, 64)
  8585. ids = append(ids, id)
  8586. }
  8587. if record_type == 1 {
  8588. drugs, _ := service.GetBatchDrugList(ids)
  8589. for _, item := range drugs {
  8590. result := QueryResult{
  8591. ID: item.ID,
  8592. Name: item.DrugName,
  8593. Code: item.MedicalInsuranceNumber,
  8594. List_type_code: "101",
  8595. }
  8596. queryResult = append(queryResult, result)
  8597. }
  8598. } else if record_type == 2 {
  8599. goods, _ := service.GetBatchGoodInformationList(ids)
  8600. for _, item := range goods {
  8601. result := QueryResult{
  8602. ID: item.ID,
  8603. Name: item.GoodName,
  8604. Code: item.MedicalInsuranceNumber,
  8605. List_type_code: "301",
  8606. }
  8607. queryResult = append(queryResult, result)
  8608. }
  8609. } else if record_type == 3 {
  8610. projects, _ := service.GetBathchMyPorjecgList(ids)
  8611. for _, item := range projects {
  8612. result := QueryResult{
  8613. ID: item.ID,
  8614. Name: item.ProjectName,
  8615. Code: item.MedicalCode,
  8616. List_type_code: "201",
  8617. }
  8618. queryResult = append(queryResult, result)
  8619. }
  8620. }
  8621. adminUser := c.GetAdminUserInfo()
  8622. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8623. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8624. var user_name string
  8625. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8626. if role.ID == 0 {
  8627. user_name = "xxx"
  8628. } else {
  8629. user_name = role.UserName
  8630. }
  8631. baseParams := &models.BaseParams{
  8632. SecretKey: miConfig.SecretKey,
  8633. FixmedinsCode: miConfig.Code,
  8634. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8635. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8636. OrgName: miConfig.OrgName,
  8637. Doctor: user_name,
  8638. }
  8639. if config.IsOpen == 1 {
  8640. for _, item := range queryResult {
  8641. var result string
  8642. if record_type == 1 {
  8643. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8644. } else if record_type == 2 {
  8645. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8646. } else if record_type == 3 {
  8647. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8648. }
  8649. var dat2 map[string]interface{}
  8650. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8651. fmt.Println(dat2)
  8652. } else {
  8653. fmt.Println(err)
  8654. }
  8655. userJSONBytes, _ := json.Marshal(dat2)
  8656. var res ResultSix
  8657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8658. utils.ErrorLog("解析失败:%v", err)
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. if res.Infcode == 0 {
  8663. if record_type == 1 {
  8664. service.UpdateDrugByIdDetail(item.ID)
  8665. } else if record_type == 2 {
  8666. service.UpdateGoodInfoById(item.ID)
  8667. } else if record_type == 3 {
  8668. service.UpdateMyProjectById(item.ID)
  8669. }
  8670. c.ServeSuccessJSON(map[string]interface{}{
  8671. "failed_code": 0,
  8672. "msg": "撤销目录对照成功",
  8673. })
  8674. } else {
  8675. c.ServeSuccessJSON(map[string]interface{}{
  8676. "failed_code": -10,
  8677. "msg": res.ErrMsg,
  8678. })
  8679. }
  8680. }
  8681. }
  8682. }
  8683. func (c *HisApiController) GetPatientInfo() {
  8684. id_card_no := c.GetString("id_card_no")
  8685. admin_user_id, _ := c.GetInt64("admin_user_id")
  8686. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8687. if patient.ID == 0 {
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8689. return
  8690. }
  8691. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8693. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8694. if config.IsOpen == 1 {
  8695. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8696. var dat map[string]interface{}
  8697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8698. fmt.Println(dat)
  8699. } else {
  8700. fmt.Println(err)
  8701. }
  8702. userJSONBytes, _ := json.Marshal(dat)
  8703. var res ResultTwo
  8704. var res10265 ResultTwo10265
  8705. if miConfig.Code == "H15049901371" {
  8706. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8707. utils.ErrorLog("解析失败:%v", err)
  8708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8709. return
  8710. }
  8711. res.ErrMsg = res10265.ErrMsg
  8712. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8713. res.Infcode = infocode
  8714. res.Output = res10265.Output
  8715. res.InfRefmsgid = res10265.InfRefmsgid
  8716. } else {
  8717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8718. utils.ErrorLog("解析失败:%v", err)
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. }
  8723. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8724. // utils.ErrorLog("解析失败:%v", err)
  8725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. // return
  8727. //}
  8728. if res.Infcode != 0 {
  8729. c.ServeSuccessJSON(map[string]interface{}{
  8730. "failed_code": -10,
  8731. "msg": res.ErrMsg,
  8732. })
  8733. } else {
  8734. c.ServeSuccessJSON(map[string]interface{}{
  8735. "failed_code": 0,
  8736. "info": res,
  8737. })
  8738. }
  8739. }
  8740. }
  8741. func (c *HisApiController) PsnPutOnRecord() {
  8742. record_type, _ := c.GetInt64("type")
  8743. patient_id, _ := c.GetInt64("patient_id")
  8744. admin_user_id, _ := c.GetInt64("admin_user_id")
  8745. start_time := c.GetString("start_time")
  8746. end_time := c.GetString("end_time")
  8747. adminUser := c.GetAdminUserInfo()
  8748. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8749. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8750. var patients []*models.Patients
  8751. if record_type == 1 { //全部备案
  8752. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8753. patients = append(patients, patient...)
  8754. } else { //单个备案
  8755. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8756. patients = append(patients, patient)
  8757. }
  8758. var user_name string
  8759. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8760. if role.ID == 0 {
  8761. user_name = "xxx"
  8762. } else {
  8763. user_name = role.UserName
  8764. }
  8765. if config.IsOpen == 1 {
  8766. for _, item := range patients {
  8767. 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
  8768. resp, requestErr := http.Get(api)
  8769. if requestErr != nil {
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8771. return
  8772. }
  8773. defer resp.Body.Close()
  8774. body, ioErr := ioutil.ReadAll(resp.Body)
  8775. if ioErr != nil {
  8776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. return
  8779. }
  8780. var respJSON map[string]interface{}
  8781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8784. return
  8785. }
  8786. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8787. userJSONBytes, _ := json.Marshal(userJSON)
  8788. var res ResultTwo
  8789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8790. utils.ErrorLog("解析失败:%v", err)
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8792. return
  8793. }
  8794. if res.Infcode == 0 {
  8795. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8796. var dat map[string]interface{}
  8797. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8798. fmt.Println(dat)
  8799. } else {
  8800. fmt.Println(err)
  8801. }
  8802. userJSONBytes, _ := json.Marshal(dat)
  8803. var res2 ResultThirteen
  8804. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8805. utils.ErrorLog("解析失败:%v", err)
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. if res2.Infcode == 0 {
  8810. psnResult := &models.GdybPsnRecord{
  8811. UserOrgId: adminUser.CurrentOrgId,
  8812. PatientId: item.ID,
  8813. PsnNo: res.Output.Baseinfo.PsnNo,
  8814. Ctime: time.Now().Unix(),
  8815. Mtime: time.Now().Unix(),
  8816. Status: 1,
  8817. IsCancel: 1,
  8818. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8819. }
  8820. service.CreatePsnRecord(psnResult)
  8821. } else {
  8822. c.ServeSuccessJSON(map[string]interface{}{
  8823. "failed_code": -10,
  8824. "msg": res2.ErrMsg,
  8825. })
  8826. return
  8827. }
  8828. }
  8829. }
  8830. }
  8831. }
  8832. func (c *HisApiController) PsnUnPutOnRecord() {
  8833. id, _ := c.GetInt64("id")
  8834. //record_type, _ := c.GetInt64("type")
  8835. admin_user_id, _ := c.GetInt64("admin_user_id")
  8836. adminUser := c.GetAdminUserInfo()
  8837. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8838. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8839. var user_name string
  8840. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8841. if role.ID == 0 {
  8842. user_name = "xxx"
  8843. } else {
  8844. user_name = role.UserName
  8845. }
  8846. psn_record, _ := service.GetPsnRecordById(id)
  8847. if psn_record.ID == 0 {
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8849. return
  8850. }
  8851. if config.IsOpen == 1 {
  8852. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8853. var dat map[string]interface{}
  8854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8855. fmt.Println(dat)
  8856. } else {
  8857. fmt.Println(err)
  8858. }
  8859. userJSONBytes, _ := json.Marshal(dat)
  8860. var res ResultFourteen
  8861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8862. utils.ErrorLog("解析失败:%v", err)
  8863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8864. return
  8865. }
  8866. if res.Infcode == 0 {
  8867. psn_record.IsCancel = 2
  8868. service.CreatePsnRecord(&psn_record)
  8869. } else {
  8870. c.ServeSuccessJSON(map[string]interface{}{
  8871. "failed_code": -10,
  8872. "msg": res.ErrMsg,
  8873. })
  8874. return
  8875. }
  8876. }
  8877. }
  8878. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8879. patient_id, _ := c.GetInt64("patient_id")
  8880. insutype_two := c.GetString("insutype")
  8881. psn_no := c.GetString("psn_no")
  8882. doctor_id, _ := c.GetInt64("doctor_id")
  8883. sick_id, _ := c.GetInt64("sick_id")
  8884. department_id, _ := c.GetInt64("department_id")
  8885. start_time := c.GetString("start_time")
  8886. end_time := c.GetString("end_time")
  8887. check_time := c.GetString("check_time")
  8888. adminUser := c.GetAdminUserInfo()
  8889. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8890. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8891. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8892. sick, _ := service.FindSickById(sick_id)
  8893. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8894. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8895. var res ResultTwo
  8896. var res10265 ResultTwo10265
  8897. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8898. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8899. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8900. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8901. "&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
  8902. resp, requestErr := http.Get(api)
  8903. if requestErr != nil {
  8904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8905. return
  8906. }
  8907. body, ioErr := ioutil.ReadAll(resp.Body)
  8908. if ioErr != nil {
  8909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8911. return
  8912. }
  8913. var respJSON map[string]interface{}
  8914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8917. return
  8918. }
  8919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8920. result, _ := json.Marshal(respJSON)
  8921. fmt.Println("log")
  8922. fmt.Println(string(result))
  8923. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8924. utils.ErrorLog("解析失败:%v", err)
  8925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8926. return
  8927. }
  8928. res.ErrMsg = res10265.ErrMsg
  8929. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8930. res.Infcode = infocode
  8931. res.Output = res10265.Output
  8932. res.InfRefmsgid = res10265.InfRefmsgid
  8933. } else {
  8934. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8935. if miConfig.Code == "H15049901371" {
  8936. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8937. utils.ErrorLog("解析失败:%v", err)
  8938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8939. return
  8940. }
  8941. res.ErrMsg = res10265.ErrMsg
  8942. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8943. res.Infcode = infocode
  8944. res.Output = res10265.Output
  8945. res.InfRefmsgid = res10265.InfRefmsgid
  8946. } else {
  8947. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8948. utils.ErrorLog("解析失败:%v", err)
  8949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8950. return
  8951. }
  8952. }
  8953. }
  8954. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8955. infoStr := string(Iinfos)
  8956. var rf []*ResultFive
  8957. json.Unmarshal([]byte(infoStr), &rf)
  8958. var insuplc_admdvs string
  8959. var insutype string
  8960. var is390 int = 0
  8961. var is310 int = 0
  8962. var insutypes []*ResultFive
  8963. for _, item := range rf {
  8964. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8965. insutypes = append(insutypes, item)
  8966. }
  8967. }
  8968. if len(insutypes) == 1 {
  8969. insutype = insutypes[0].Insutype
  8970. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8971. } else {
  8972. for _, i := range insutypes {
  8973. if i.Insutype == "390" {
  8974. is390 = 1
  8975. }
  8976. if i.Insutype == "310" {
  8977. is310 = 1
  8978. }
  8979. }
  8980. }
  8981. if is390 == 1 {
  8982. insutype = "390"
  8983. }
  8984. if is310 == 1 {
  8985. insutype = "310"
  8986. }
  8987. if len(insutypes) == 2 {
  8988. insutype = insutype_two
  8989. }
  8990. if len(insutypes) == 0 {
  8991. insutype = "310"
  8992. }
  8993. insutype = insutype_two
  8994. fmt.Println(insutype)
  8995. for _, item := range rf {
  8996. fmt.Println(item.Insutype)
  8997. fmt.Println(insutype)
  8998. if item.Insutype == insutype {
  8999. fmt.Println(item.Insutype)
  9000. fmt.Println(insutype)
  9001. insuplc_admdvs = item.InsuplcAdmdvs
  9002. }
  9003. }
  9004. fmt.Println(insuplc_admdvs)
  9005. var res2 ResultThirteen
  9006. var res10265_2 ResultThirteen10265
  9007. if config.IsOpen == 1 {
  9008. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9009. } else {
  9010. 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)
  9011. var dat map[string]interface{}
  9012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9013. fmt.Println(dat)
  9014. } else {
  9015. fmt.Println(err)
  9016. }
  9017. userJSONBytes, _ := json.Marshal(dat)
  9018. if miConfig.Code == "H15049901371" {
  9019. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9020. utils.ErrorLog("解析失败:%v", err)
  9021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9022. return
  9023. }
  9024. res2.ErrMsg = res10265_2.ErrMsg
  9025. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9026. res2.Infcode = infocode
  9027. res2.Output = res10265_2.Output
  9028. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9029. } else {
  9030. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9031. utils.ErrorLog("解析失败:%v", err)
  9032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9033. return
  9034. }
  9035. }
  9036. }
  9037. if res2.Infcode == 0 {
  9038. psnResult := &models.GdybPsnNcdsRecord{
  9039. UserOrgId: adminUser.CurrentOrgId,
  9040. PatientId: patient.ID,
  9041. PsnNo: psn_no,
  9042. DoctorId: doctor.AdminUserId,
  9043. DepartmentId: department_id,
  9044. SickType: sick_id,
  9045. Insutype: insutype,
  9046. Ctime: time.Now().Unix(),
  9047. Mtime: time.Now().Unix(),
  9048. Status: 1,
  9049. IsCancel: 1,
  9050. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9051. }
  9052. service.CreatePsnNCDSRecord(psnResult)
  9053. c.ServeSuccessJSON(map[string]interface{}{
  9054. "failed_code": 0,
  9055. "msg": "备案成功",
  9056. "result": psnResult,
  9057. })
  9058. } else {
  9059. c.ServeSuccessJSON(map[string]interface{}{
  9060. "failed_code": -10,
  9061. "msg": res2.ErrMsg,
  9062. })
  9063. return
  9064. }
  9065. }
  9066. }
  9067. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9068. id, _ := c.GetInt64("id")
  9069. admin_user_id, _ := c.GetInt64("admin_user_id")
  9070. adminUser := c.GetAdminUserInfo()
  9071. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9072. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9073. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9074. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9075. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9076. //var user_name string
  9077. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9078. //if role.ID == 0 {
  9079. // user_name = "xxx"
  9080. //} else {
  9081. // user_name = role.UserName
  9082. //}
  9083. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9084. if psn_record.ID == 0 {
  9085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9086. return
  9087. }
  9088. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9089. var res ResultTwo
  9090. var res10265 ResultTwo10265
  9091. if miConfig.Code == "H15049901371" {
  9092. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9093. utils.ErrorLog("解析失败:%v", err)
  9094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9095. return
  9096. }
  9097. res.ErrMsg = res10265.ErrMsg
  9098. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9099. res.Infcode = infocode
  9100. res.Output = res10265.Output
  9101. res.InfRefmsgid = res10265.InfRefmsgid
  9102. } else {
  9103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9104. utils.ErrorLog("解析失败:%v", err)
  9105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9106. return
  9107. }
  9108. }
  9109. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9110. infoStr := string(Iinfos)
  9111. var rf []*ResultFive
  9112. json.Unmarshal([]byte(infoStr), &rf)
  9113. var insuplc_admdvs string
  9114. var insutype string
  9115. var is390 int = 0
  9116. var is310 int = 0
  9117. var insutypes []*ResultFive
  9118. for _, item := range rf {
  9119. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9120. insutypes = append(insutypes, item)
  9121. }
  9122. }
  9123. if len(insutypes) == 1 {
  9124. insutype = insutypes[0].Insutype
  9125. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9126. } else {
  9127. for _, i := range insutypes {
  9128. if i.Insutype == "390" {
  9129. is390 = 1
  9130. }
  9131. if i.Insutype == "310" {
  9132. is310 = 1
  9133. }
  9134. }
  9135. }
  9136. if is390 == 1 {
  9137. insutype = "390"
  9138. }
  9139. if is310 == 1 {
  9140. insutype = "310"
  9141. }
  9142. if len(insutypes) == 0 {
  9143. insutype = "310"
  9144. }
  9145. insutype = psn_record.Insutype
  9146. for _, item := range rf {
  9147. if item.Insutype == insutype {
  9148. insuplc_admdvs = item.InsuplcAdmdvs
  9149. }
  9150. }
  9151. if config.IsOpen == 1 {
  9152. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9153. var dat map[string]interface{}
  9154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9155. fmt.Println(dat)
  9156. } else {
  9157. fmt.Println(err)
  9158. }
  9159. userJSONBytes, _ := json.Marshal(dat)
  9160. var res ResultFourteen
  9161. var res10265 ResultFourteen10265
  9162. if miConfig.Code == "H15049901371" {
  9163. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9164. utils.ErrorLog("解析失败:%v", err)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. res.ErrMsg = res10265.ErrMsg
  9169. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9170. res.Infcode = infocode
  9171. res.Output = res10265.Output
  9172. res.InfRefmsgid = res10265.InfRefmsgid
  9173. } else {
  9174. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9175. utils.ErrorLog("解析失败:%v", err)
  9176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9177. return
  9178. }
  9179. }
  9180. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9181. // utils.ErrorLog("解析失败:%v", err)
  9182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9183. // return
  9184. //}
  9185. if res.Infcode == 0 {
  9186. psn_record.IsCancel = 2
  9187. service.CreatePsnNCDSRecord(&psn_record)
  9188. c.ServeSuccessJSON(map[string]interface{}{
  9189. "failed_code": 0,
  9190. "msg": "撤销备案成功",
  9191. })
  9192. } else {
  9193. c.ServeSuccessJSON(map[string]interface{}{
  9194. "failed_code": -10,
  9195. "msg": res.ErrMsg,
  9196. })
  9197. return
  9198. }
  9199. }
  9200. }
  9201. func (c *HisApiController) TestTest() {
  9202. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9203. fmt.Println(patient.Iinfo)
  9204. }
  9205. type CustomData struct {
  9206. MsgId string
  9207. PsnNo string
  9208. Info string
  9209. }
  9210. func (c *HisApiController) ReversalData() {
  9211. var customData []*CustomData
  9212. custom := &CustomData{
  9213. MsgId: "H44022900158202103301714472004",
  9214. PsnNo: "44020000001101329945",
  9215. Info: "2207",
  9216. }
  9217. customData = append(customData, custom)
  9218. custom1 := &CustomData{
  9219. MsgId: "H4402290015820210330172057803",
  9220. PsnNo: "44020000001101161813",
  9221. Info: "2207",
  9222. }
  9223. customData = append(customData, custom1)
  9224. custom2 := &CustomData{
  9225. MsgId: "H44022900158202103301705198813",
  9226. PsnNo: "44190000133097375417",
  9227. Info: "2207",
  9228. }
  9229. customData = append(customData, custom2)
  9230. custom3 := &CustomData{
  9231. MsgId: "H44022900158202103301715524756",
  9232. PsnNo: "44020000001100187221",
  9233. Info: "2207",
  9234. }
  9235. customData = append(customData, custom3)
  9236. custom4 := &CustomData{
  9237. MsgId: "H44022900158202103301730376224",
  9238. PsnNo: "44020000001101959155",
  9239. Info: "2207",
  9240. }
  9241. customData = append(customData, custom4)
  9242. custom5 := &CustomData{
  9243. MsgId: "H44022900158202103301748008725",
  9244. PsnNo: "44020000001104246641",
  9245. Info: "2207",
  9246. }
  9247. customData = append(customData, custom5)
  9248. custom6 := &CustomData{
  9249. MsgId: "H44022900158202103301718096755",
  9250. PsnNo: "44020000001102211860",
  9251. Info: "2207",
  9252. }
  9253. customData = append(customData, custom6)
  9254. custom7 := &CustomData{
  9255. MsgId: "H44022900158202103301736551640",
  9256. PsnNo: "44020000001102687718",
  9257. Info: "2207",
  9258. }
  9259. customData = append(customData, custom7)
  9260. custom8 := &CustomData{
  9261. MsgId: "H44022900158202103301743097676",
  9262. PsnNo: "44020000001102127785",
  9263. Info: "2207",
  9264. }
  9265. customData = append(customData, custom8)
  9266. custom9 := &CustomData{
  9267. MsgId: "H44022900158202103301712304203",
  9268. PsnNo: "44020000001101518097",
  9269. Info: "2207",
  9270. }
  9271. customData = append(customData, custom9)
  9272. custom10 := &CustomData{
  9273. MsgId: "H44022900158202103301738448785",
  9274. PsnNo: "44020000001100500813",
  9275. Info: "2207",
  9276. }
  9277. customData = append(customData, custom10)
  9278. custom11 := &CustomData{
  9279. MsgId: "H44022900158202103301732455843",
  9280. PsnNo: "44020000001102690557",
  9281. Info: "2207",
  9282. }
  9283. customData = append(customData, custom11)
  9284. custom12 := &CustomData{
  9285. MsgId: "H44022900158202103301745421708",
  9286. PsnNo: "44020000001102211928",
  9287. Info: "2207",
  9288. }
  9289. customData = append(customData, custom12)
  9290. custom1212 := &CustomData{
  9291. MsgId: "H440229001582021033017351627",
  9292. PsnNo: "44020000001102481733",
  9293. Info: "2207",
  9294. }
  9295. customData = append(customData, custom1212)
  9296. custom13 := &CustomData{
  9297. MsgId: "H44022900158202103301740327951",
  9298. PsnNo: "44020000001103174866",
  9299. Info: "2207",
  9300. }
  9301. customData = append(customData, custom13)
  9302. custom14 := &CustomData{
  9303. MsgId: "H4402290015820210330174922668",
  9304. PsnNo: "44020000001102927272",
  9305. Info: "2207",
  9306. }
  9307. customData = append(customData, custom14)
  9308. custom15 := &CustomData{
  9309. MsgId: "H44022900158202103301752362273",
  9310. PsnNo: "44020000001102942890",
  9311. Info: "2207",
  9312. }
  9313. customData = append(customData, custom15)
  9314. custom16 := &CustomData{
  9315. MsgId: "H44022900158202103301751082917",
  9316. PsnNo: "44020000001101662162",
  9317. Info: "2207",
  9318. }
  9319. customData = append(customData, custom16)
  9320. custom17 := &CustomData{
  9321. MsgId: "H44022900158202103301754147728",
  9322. PsnNo: "44020000000229014511",
  9323. Info: "2207",
  9324. }
  9325. customData = append(customData, custom17)
  9326. adminUser := c.GetAdminUserInfo()
  9327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9328. for _, item := range customData {
  9329. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9330. fmt.Println(result)
  9331. }
  9332. }
  9333. func (c *HisApiController) GetAllopatry() {
  9334. year := c.GetString("year")
  9335. month := c.GetString("month")
  9336. admin_user_id, _ := c.GetInt64("admin_user_id")
  9337. adminUser := c.GetAdminUserInfo()
  9338. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9339. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9340. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9341. var dat map[string]interface{}
  9342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9343. fmt.Println(dat)
  9344. } else {
  9345. fmt.Println(err)
  9346. }
  9347. userJSONBytes, _ := json.Marshal(dat)
  9348. var res models.Result9001
  9349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9350. utils.ErrorLog("解析失败:%v", err)
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9352. return
  9353. }
  9354. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9355. var dat2 map[string]interface{}
  9356. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9357. fmt.Println(dat)
  9358. } else {
  9359. fmt.Println(err)
  9360. }
  9361. userJSONBytes2, _ := json.Marshal(dat2)
  9362. var res2 models.Result3260
  9363. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9364. utils.ErrorLog("解析失败:%v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. if res2.Infcode == 0 {
  9369. c.ServeSuccessJSON(map[string]interface{}{
  9370. "list": res2.Output.Data,
  9371. })
  9372. return
  9373. } else {
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9375. return
  9376. }
  9377. }
  9378. func (c *HisApiController) ComfirmAllopatry() {
  9379. year := c.GetString("year")
  9380. month := c.GetString("month")
  9381. admin_user_id, _ := c.GetInt64("admin_user_id")
  9382. adminUser := c.GetAdminUserInfo()
  9383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9384. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9385. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9386. var dat map[string]interface{}
  9387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9388. fmt.Println(dat)
  9389. } else {
  9390. fmt.Println(err)
  9391. }
  9392. userJSONBytes, _ := json.Marshal(dat)
  9393. var res models.Result9001
  9394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9395. utils.ErrorLog("解析失败:%v", err)
  9396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9397. return
  9398. }
  9399. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9400. var dat2 map[string]interface{}
  9401. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9402. fmt.Println(dat)
  9403. } else {
  9404. fmt.Println(err)
  9405. }
  9406. userJSONBytes2, _ := json.Marshal(dat2)
  9407. var res2 models.Result3260
  9408. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9409. utils.ErrorLog("解析失败:%v", err)
  9410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9411. return
  9412. }
  9413. if res2.Infcode == 0 {
  9414. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9415. var dat map[string]interface{}
  9416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9417. fmt.Println(dat)
  9418. } else {
  9419. fmt.Println(err)
  9420. }
  9421. userJSONBytes, _ := json.Marshal(dat)
  9422. var res3 models.Result3261
  9423. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9424. utils.ErrorLog("解析失败:%v", err)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. if res3.Infcode == 0 {
  9429. record := &models.HisYidiClearRecord{
  9430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9431. Ctime: time.Now().Unix(),
  9432. Mtime: time.Now().Unix(),
  9433. Status: 1,
  9434. MsgId: msgId,
  9435. }
  9436. service.SaveClearRecord(record)
  9437. c.ServeSuccessJSON(map[string]interface{}{
  9438. "msg": "提取成功",
  9439. })
  9440. }
  9441. }
  9442. }
  9443. func (c *HisApiController) RefundAllopatry() {
  9444. year := c.GetString("year")
  9445. month := c.GetString("month")
  9446. id, _ := c.GetInt64("id")
  9447. admin_user_id, _ := c.GetInt64("admin_user_id")
  9448. adminUser := c.GetAdminUserInfo()
  9449. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9450. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9451. record, _ := service.GetClearRecordById(id)
  9452. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9453. var dat map[string]interface{}
  9454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9455. fmt.Println(dat)
  9456. } else {
  9457. fmt.Println(err)
  9458. }
  9459. userJSONBytes, _ := json.Marshal(dat)
  9460. var empty ResultFourteen
  9461. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9462. utils.ErrorLog("解析失败:%v", err)
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9464. return
  9465. }
  9466. if empty.Infcode == 0 {
  9467. c.ServeSuccessJSON(map[string]interface{}{
  9468. "msg": "撤销成功",
  9469. })
  9470. return
  9471. }
  9472. }
  9473. func (c *HisApiController) ReversalOtherData() {
  9474. var customData []*CustomData
  9475. custom := &CustomData{
  9476. MsgId: "H44022900158202103301714472004",
  9477. PsnNo: "44020000001101329945",
  9478. Info: "2208",
  9479. }
  9480. customData = append(customData, custom)
  9481. custom1 := &CustomData{
  9482. MsgId: "H4402290015820210330172057803",
  9483. PsnNo: "44020000001101161813",
  9484. Info: "2208",
  9485. }
  9486. customData = append(customData, custom1)
  9487. custom2 := &CustomData{
  9488. MsgId: "H44022900158202103301705198813",
  9489. PsnNo: "44190000133097375417",
  9490. Info: "2208",
  9491. }
  9492. customData = append(customData, custom2)
  9493. custom3 := &CustomData{
  9494. MsgId: "H44022900158202103301715524756",
  9495. PsnNo: "44020000001100187221",
  9496. Info: "2208",
  9497. }
  9498. customData = append(customData, custom3)
  9499. custom4 := &CustomData{
  9500. MsgId: "H44022900158202103301730376224",
  9501. PsnNo: "44020000001101959155",
  9502. Info: "2208",
  9503. }
  9504. customData = append(customData, custom4)
  9505. custom5 := &CustomData{
  9506. MsgId: "H44022900158202103301748008725",
  9507. PsnNo: "44020000001104246641",
  9508. Info: "2208",
  9509. }
  9510. customData = append(customData, custom5)
  9511. custom6 := &CustomData{
  9512. MsgId: "H44022900158202103301718096755",
  9513. PsnNo: "44020000001102211860",
  9514. Info: "2208",
  9515. }
  9516. customData = append(customData, custom6)
  9517. custom7 := &CustomData{
  9518. MsgId: "H44022900158202103301736551640",
  9519. PsnNo: "44020000001102687718",
  9520. Info: "2208",
  9521. }
  9522. customData = append(customData, custom7)
  9523. custom8 := &CustomData{
  9524. MsgId: "H44022900158202103301743097676",
  9525. PsnNo: "44020000001102127785",
  9526. Info: "2208",
  9527. }
  9528. customData = append(customData, custom8)
  9529. custom9 := &CustomData{
  9530. MsgId: "H44022900158202103301712304203",
  9531. PsnNo: "44020000001101518097",
  9532. Info: "2208",
  9533. }
  9534. customData = append(customData, custom9)
  9535. custom10 := &CustomData{
  9536. MsgId: "H44022900158202103301738448785",
  9537. PsnNo: "44020000001100500813",
  9538. Info: "2208",
  9539. }
  9540. customData = append(customData, custom10)
  9541. custom11 := &CustomData{
  9542. MsgId: "H44022900158202103301732455843",
  9543. PsnNo: "44020000001102690557",
  9544. Info: "2208",
  9545. }
  9546. customData = append(customData, custom11)
  9547. custom12 := &CustomData{
  9548. MsgId: "H44022900158202103301745421708",
  9549. PsnNo: "44020000001102211928",
  9550. Info: "2208",
  9551. }
  9552. customData = append(customData, custom12)
  9553. custom1212 := &CustomData{
  9554. MsgId: "H440229001582021033017351627",
  9555. PsnNo: "44020000001102481733",
  9556. Info: "2208",
  9557. }
  9558. customData = append(customData, custom1212)
  9559. custom13 := &CustomData{
  9560. MsgId: "H44022900158202103301740327951",
  9561. PsnNo: "44020000001103174866",
  9562. Info: "2208",
  9563. }
  9564. customData = append(customData, custom13)
  9565. custom14 := &CustomData{
  9566. MsgId: "H4402290015820210330174922668",
  9567. PsnNo: "44020000001102927272",
  9568. Info: "2208",
  9569. }
  9570. customData = append(customData, custom14)
  9571. custom15 := &CustomData{
  9572. MsgId: "H44022900158202103301752362273",
  9573. PsnNo: "44020000001102942890",
  9574. Info: "2208",
  9575. }
  9576. customData = append(customData, custom15)
  9577. custom16 := &CustomData{
  9578. MsgId: "H44022900158202103301751082917",
  9579. PsnNo: "44020000001101662162",
  9580. Info: "2208",
  9581. }
  9582. customData = append(customData, custom16)
  9583. custom17 := &CustomData{
  9584. MsgId: "H44022900158202103301754147728",
  9585. PsnNo: "44020000000229014511",
  9586. Info: "2208",
  9587. }
  9588. customData = append(customData, custom17)
  9589. adminUser := c.GetAdminUserInfo()
  9590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9591. for _, item := range customData {
  9592. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9593. fmt.Println(result)
  9594. }
  9595. }
  9596. func PathExists(path string) (bool, error) {
  9597. _, err := os.Stat(path)
  9598. if err == nil {
  9599. return true, nil
  9600. }
  9601. if os.IsNotExist(err) {
  9602. return false, nil
  9603. }
  9604. return false, err
  9605. }
  9606. //创建文件夹
  9607. func Mkdir(dir string) {
  9608. // 创建文件夹
  9609. exist, err := PathExists(dir)
  9610. if err != nil {
  9611. fmt.Println(err.Error())
  9612. } else {
  9613. if exist {
  9614. fmt.Println(dir + "文件夹已存在!")
  9615. } else {
  9616. // 文件夹名称,权限
  9617. err := os.Mkdir(dir, os.ModePerm)
  9618. if err != nil {
  9619. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9620. } else {
  9621. fmt.Println(dir + "文件夹创建成功!")
  9622. }
  9623. }
  9624. }
  9625. }
  9626. //压缩文件
  9627. func Zip(srcFile string, destZip string) error {
  9628. zipfile, err := os.Create(destZip)
  9629. if err != nil {
  9630. return err
  9631. }
  9632. defer zipfile.Close()
  9633. archive := zip.NewWriter(zipfile)
  9634. defer archive.Close()
  9635. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9636. if err != nil {
  9637. return err
  9638. }
  9639. header, err := zip.FileInfoHeader(info)
  9640. if err != nil {
  9641. return err
  9642. }
  9643. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9644. // header.Name = path
  9645. if info.IsDir() {
  9646. header.Name += "/"
  9647. } else {
  9648. header.Method = zip.Deflate
  9649. }
  9650. writer, err := archive.CreateHeader(header)
  9651. if err != nil {
  9652. return err
  9653. }
  9654. if !info.IsDir() {
  9655. file, err := os.Open(path)
  9656. if err != nil {
  9657. return err
  9658. }
  9659. defer file.Close()
  9660. _, err = io.Copy(writer, file)
  9661. }
  9662. return err
  9663. })
  9664. return err
  9665. }
  9666. func ReadFile(filePath string) []byte {
  9667. f, err := os.Open(filePath)
  9668. if err != nil {
  9669. fmt.Println("read file fail", err)
  9670. return nil
  9671. }
  9672. defer f.Close()
  9673. fd, err := ioutil.ReadAll(f)
  9674. if err != nil {
  9675. fmt.Println("read to fd fail", err)
  9676. return nil
  9677. }
  9678. return fd
  9679. }
  9680. func saveLog(result string, request string, infno string, desc string) {
  9681. org_id, _ := beego.AppConfig.Int64("org_id")
  9682. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9683. dir := miConfig.OrgName + "日志"
  9684. utils.Mkdir(dir)
  9685. month := time.Unix(1557042972, 0).Format("1")
  9686. year := time.Now().Format("2006")
  9687. month = time.Now().Format("01")
  9688. day := time.Now().Format("02")
  9689. hour := time.Now().Format("15")
  9690. min := time.Now().Format("04")
  9691. sec := time.Now().Format("05")
  9692. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9693. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9694. file_name := file + ".txt"
  9695. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9696. exist, _ := utils.PathExists(file_path)
  9697. if exist { //存在
  9698. fmt.Println("存在")
  9699. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9700. if err != nil {
  9701. fmt.Println("read fail")
  9702. }
  9703. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9704. n, _ := f.Seek(0, 2)
  9705. _, err = f.WriteAt([]byte(content), n)
  9706. } else { //不存在
  9707. fmt.Println("文件不存在,创建文件")
  9708. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9709. defer f.Close()
  9710. if err != nil {
  9711. } else {
  9712. _, err = f.Write([]byte("记录日志"))
  9713. }
  9714. }
  9715. }
  9716. type Charset string
  9717. const (
  9718. UTF8 = Charset("UTF-8")
  9719. GB18030 = Charset("GB18030")
  9720. )
  9721. func ConvertToString(src string, srcCode string, tagCode string) string {
  9722. srcCoder := mahonia.NewDecoder(srcCode)
  9723. srcResult := srcCoder.ConvertString(src)
  9724. tagCoder := mahonia.NewDecoder(tagCode)
  9725. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9726. result := string(cdata)
  9727. return result
  9728. }