his_api_controller.go 422KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553
  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. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := c.GetString("trig_scen")
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.FixmedinsCode = miConfig.Code
  109. pp.RequestUrl = miConfig.Url
  110. pp.Cainfo = miConfig.Cainfo
  111. pp.SecretKey = miConfig.SecretKey
  112. pp.AccessKey = miConfig.AccessKey
  113. pp.OpterName = roles.UserName
  114. var config []*models.HisXtDiagnoseConfig
  115. for _, item := range diagnosis_ids {
  116. id, _ := strconv.ParseInt(item, 10, 64)
  117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  118. config = append(config, &diagnosisConfig)
  119. }
  120. var pd models.PatientDtos
  121. pd.PatnID = his.PsnNo
  122. pd.PatnName = his.Name
  123. pd.Gend = his.Gend
  124. pd.Brdy = his.Brdy
  125. pd.Poolarea = his.InsuplcAdmdvs
  126. pd.CurrMdtrtID = his.Number
  127. var fed models.FsiEncounterDtos
  128. fed.MdtrtID = his.Number
  129. fed.MedinsID = miConfig.Code
  130. fed.MedinsName = miConfig.OrgName
  131. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  132. fed.MedMdtrtType = "1"
  133. fed.MedinsLv = "11"
  134. tm := time.Unix(his.RecordDate, 0)
  135. s_tm := tm.Format("2006-01-02 15:04:05")
  136. fed.AdmDate = s_tm
  137. fed.DscgDate = s_tm
  138. fed.DscgMainDiseCodg = config[0].CountryCode
  139. fed.DscgMainDiseName = config[0].CountryContentName
  140. //诊断信息
  141. var fdds []*models.FsiDiagnoseDtos
  142. for index, item := range config {
  143. if index == 0 {
  144. var fdd models.FsiDiagnoseDtos
  145. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  146. fdd.InoutDiseType = "1"
  147. fdd.MaindiseFlag = "1"
  148. fdd.DiseDate = s_tm
  149. fdd.DiasSrtNo = "1"
  150. fdd.DiseName = item.CountryContentName
  151. fdd.DiseCodg = item.CountryCode
  152. fdds = append(fdds, &fdd)
  153. } else {
  154. var fdd models.FsiDiagnoseDtos
  155. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  156. fdd.InoutDiseType = "1"
  157. fdd.MaindiseFlag = "1"
  158. fdd.DiseDate = s_tm
  159. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  160. fdd.DiseName = item.CountryContentName
  161. fdd.DiseCodg = item.CountryCode
  162. fdds = append(fdds, &fdd)
  163. }
  164. }
  165. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  166. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  167. fed.AdmDeptName = department.Name
  168. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  169. fed.DscgDeptName = department.Name
  170. fed.MedMdtrtType = ""
  171. if his.Insutype == "390" {
  172. fed.MedType = "1402"
  173. } else {
  174. fed.MedType = "9933"
  175. }
  176. var orders []*models.FsiOrderDtos
  177. if trig_scen == "2" {
  178. //处方医嘱信息
  179. for _, item := range prescriptions {
  180. for _, subItem := range item.HisDoctorAdviceInfo {
  181. var order models.FsiOrderDtos
  182. order.RxID = strconv.FormatInt(item.ID, 10)
  183. order.Rxno = strconv.FormatInt(item.ID, 10)
  184. order.LongDrordFlag = "0"
  185. order.HilistType = "1"
  186. order.ChrgType = "1"
  187. order.DrordBhvr = "-"
  188. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  189. order.HosplistName = subItem.BaseDrugLib.DrugName
  190. order.HilistLv = "1"
  191. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  192. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  193. order.HosplistName = subItem.BaseDrugLib.DrugName
  194. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  195. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  196. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  197. order.OwnpayAmt = ""
  198. order.SelfpayAmt = ""
  199. order.Spec = ""
  200. order.SpecUnt = ""
  201. order.DrordBegnDate = s_tm
  202. order.DrordStopDate = ""
  203. order.DrordDrCodg = "1"
  204. order.DrordDeptName = department.Name
  205. order.DrordDrCodg = "1"
  206. order.DrordDrName = doctor_info.UserName
  207. order.DrordDrProfttl = ""
  208. order.CurrDrordFlag = "1"
  209. orders = append(orders, &order)
  210. }
  211. for _, subItem := range item.HisPrescriptionProject {
  212. if subItem.Type == 2 {
  213. var order models.FsiOrderDtos
  214. order.RxID = strconv.FormatInt(item.ID, 10)
  215. order.Rxno = strconv.FormatInt(item.ID, 10)
  216. order.LongDrordFlag = "0"
  217. order.HilistType = "1"
  218. order.ChrgType = "1"
  219. order.DrordBhvr = "-"
  220. order.HilistCode = subItem.HisProject.MedicalCode
  221. order.HosplistName = subItem.HisProject.ProjectName
  222. order.HilistLv = "1"
  223. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  224. order.HosplistCode = subItem.HisProject.MedicalCode
  225. order.HosplistName = subItem.HisProject.ProjectName
  226. order.Cnt = subItem.Count
  227. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  228. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  229. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  230. order.OwnpayAmt = ""
  231. order.SelfpayAmt = ""
  232. order.Spec = ""
  233. order.SpecUnt = ""
  234. order.DrordBegnDate = s_tm
  235. order.DrordStopDate = ""
  236. order.DrordDrCodg = "1"
  237. order.DrordDeptName = department.Name
  238. order.DrordDrCodg = "1"
  239. order.DrordDrName = doctor_info.UserName
  240. order.DrordDrProfttl = ""
  241. order.CurrDrordFlag = "1"
  242. orders = append(orders, &order)
  243. }
  244. if subItem.Type == 3 {
  245. var order models.FsiOrderDtos
  246. order.RxID = strconv.FormatInt(item.ID, 10)
  247. order.Rxno = strconv.FormatInt(item.ID, 10)
  248. order.LongDrordFlag = "0"
  249. order.HilistType = "1"
  250. order.ChrgType = "1"
  251. order.DrordBhvr = "-"
  252. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  253. order.HosplistName = subItem.GoodInfo.GoodName
  254. order.HilistLv = "1"
  255. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  256. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  257. order.HosplistName = subItem.GoodInfo.GoodName
  258. order.Cnt = subItem.Count
  259. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  260. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  261. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  262. order.OwnpayAmt = ""
  263. order.SelfpayAmt = ""
  264. order.Spec = ""
  265. order.SpecUnt = ""
  266. order.DrordBegnDate = s_tm
  267. order.DrordStopDate = ""
  268. order.DrordDrCodg = "1"
  269. order.DrordDeptName = department.Name
  270. order.DrordDrCodg = "1"
  271. order.DrordDrName = doctor_info.UserName
  272. order.DrordDrProfttl = ""
  273. order.CurrDrordFlag = "1"
  274. orders = append(orders, &order)
  275. }
  276. }
  277. }
  278. //处方医嘱信息
  279. }
  280. fed.MatnStas = "0"
  281. fed.MedfeeSumamt = "0"
  282. fed.OwnpayAmt = "0"
  283. fed.SelfpayAmt = "0"
  284. fed.AcctPayamt = "0"
  285. fed.MaAmt = "0"
  286. fed.HifpPayamt = "0"
  287. fed.SetlTotlnum = "0"
  288. fed.Insutype = his.Insutype
  289. fed.ReimFlag = "0"
  290. fed.OutSetlFlag = "0"
  291. var fopd []*models.FsiOperationDtosData
  292. data := make(map[string]interface{})
  293. data["fed"] = fed
  294. data["fdd"] = fdds
  295. data["fod"] = orders
  296. data["pd"] = pd
  297. data["pp"] = pp
  298. data["fopd"] = fopd
  299. data["trig_scen"] = trig_scen
  300. fmt.Println(data)
  301. fmt.Println(fed)
  302. fmt.Println(fdds)
  303. fmt.Println(orders)
  304. fmt.Println(pd)
  305. fmt.Println(pp)
  306. fmt.Println(fopd)
  307. client := &http.Client{}
  308. bytesData, _ := json.Marshal(data)
  309. var req *http.Request
  310. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  311. resp, _ := client.Do(req)
  312. defer resp.Body.Close()
  313. body, ioErr := ioutil.ReadAll(resp.Body)
  314. if ioErr != nil {
  315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  317. return
  318. }
  319. var respJSON map[string]interface{}
  320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  323. return
  324. }
  325. //手术操作集合
  326. //手术操作集合
  327. }
  328. func (c *HisApiController) Check3102() {
  329. patient_id, _ := c.GetInt64("patient_id")
  330. order_id, _ := c.GetInt64("order_id")
  331. his_patient_id, _ := c.GetInt64("his_patient_id")
  332. admin_user_id, _ := c.GetInt64("admin_user_id")
  333. trig_scen := c.GetString("trig_scen")
  334. adminUser := c.GetAdminUserInfo()
  335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  336. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  338. record_time := c.GetString("record_time")
  339. order, _ := service.GetHisOrderByID(order_id)
  340. timeLayout := "2006-01-02"
  341. loc, _ := time.LoadLocation("Local")
  342. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  343. if err != nil {
  344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  345. return
  346. }
  347. recordDateTime := theTime.Unix()
  348. var patientPrescription models.HisPrescriptionInfo
  349. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  350. if patientPrescription.ID == 0 {
  351. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  352. }
  353. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  354. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  355. //
  356. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  357. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  358. var pp models.PublicParams
  359. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  360. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  361. pp.FixmedinsName = miConfig.OrgName
  362. pp.FixmedinsCode = miConfig.Code
  363. pp.RequestUrl = miConfig.Url
  364. pp.Cainfo = miConfig.Cainfo
  365. pp.SecretKey = miConfig.SecretKey
  366. pp.AccessKey = miConfig.AccessKey
  367. pp.OpterName = roles.UserName
  368. var config []*models.HisXtDiagnoseConfig
  369. for _, item := range diagnosis_ids {
  370. id, _ := strconv.ParseInt(item, 10, 64)
  371. diagnosisConfig, _ := service.FindDiagnoseById(id)
  372. config = append(config, &diagnosisConfig)
  373. }
  374. var pd models.PatientDtos
  375. pd.PatnID = his.PsnNo
  376. pd.PatnName = his.Name
  377. pd.Gend = his.Gend
  378. pd.Brdy = his.Brdy
  379. pd.Poolarea = his.InsuplcAdmdvs
  380. pd.CurrMdtrtID = his.Number
  381. var fed models.FsiEncounterDtos
  382. fed.MdtrtID = his.Number
  383. fed.MedinsID = miConfig.Code
  384. fed.MedinsName = miConfig.OrgName
  385. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  386. fed.MedMdtrtType = "1"
  387. fed.MedinsType = "1"
  388. fed.MedinsLv = "11"
  389. tm := time.Unix(his.RecordDate, 0)
  390. s_tm := tm.Format("2006-01-02 15:04:05")
  391. fed.AdmDate = s_tm
  392. fed.DscgDate = s_tm
  393. fed.DscgMainDiseCodg = config[0].CountryCode
  394. fed.DscgMainDiseName = config[0].CountryContentName
  395. //诊断信息
  396. var fdds []*models.FsiDiagnoseDtos
  397. for index, item := range config {
  398. if index == 0 {
  399. var fdd models.FsiDiagnoseDtos
  400. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  401. fdd.InoutDiseType = "1"
  402. fdd.MaindiseFlag = "1"
  403. fdd.DiseDate = s_tm
  404. fdd.DiasSrtNo = "1"
  405. fdd.DiseName = item.CountryContentName
  406. fdd.DiseCodg = item.CountryCode
  407. fdds = append(fdds, &fdd)
  408. } else {
  409. var fdd models.FsiDiagnoseDtos
  410. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  411. fdd.InoutDiseType = "1"
  412. fdd.MaindiseFlag = "1"
  413. fdd.DiseDate = s_tm
  414. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  415. fdd.DiseName = item.CountryContentName
  416. fdd.DiseCodg = item.CountryCode
  417. fdds = append(fdds, &fdd)
  418. }
  419. }
  420. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  421. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  422. fed.AdmDeptName = department.Name
  423. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  424. fed.DscgDeptName = department.Name
  425. fed.MedMdtrtType = ""
  426. fed.MedType = order.MedType
  427. //处方医嘱信息
  428. var orders []*models.FsiOrderDtos
  429. for _, item := range prescriptions {
  430. for _, subItem := range item.HisDoctorAdviceInfo {
  431. var order models.FsiOrderDtos
  432. order.RxID = strconv.FormatInt(item.ID, 10)
  433. order.Rxno = strconv.FormatInt(item.ID, 10)
  434. order.LongDrordFlag = "0"
  435. order.HilistType = "1"
  436. order.ChrgType = "1"
  437. order.DrordBhvr = "-"
  438. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  439. order.HosplistName = subItem.BaseDrugLib.DrugName
  440. order.HilistLv = "1"
  441. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  442. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  443. order.HosplistName = subItem.BaseDrugLib.DrugName
  444. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  445. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  446. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  447. order.OwnpayAmt = ""
  448. order.SelfpayAmt = ""
  449. order.Spec = ""
  450. order.SpecUnt = ""
  451. order.DrordBegnDate = s_tm
  452. order.DrordStopDate = ""
  453. order.DrordDrCodg = "1"
  454. order.DrordDeptName = department.Name
  455. order.DrordDrCodg = "1"
  456. order.DrordDrName = doctor_info.UserName
  457. order.DrordDrProfttl = ""
  458. order.CurrDrordFlag = "1"
  459. orders = append(orders, &order)
  460. }
  461. for _, subItem := range item.HisPrescriptionProject {
  462. if subItem.Type == 2 {
  463. var order models.FsiOrderDtos
  464. order.RxID = strconv.FormatInt(item.ID, 10)
  465. order.Rxno = strconv.FormatInt(item.ID, 10)
  466. order.LongDrordFlag = "0"
  467. order.HilistType = "1"
  468. order.ChrgType = "1"
  469. order.DrordBhvr = "-"
  470. order.HilistCode = subItem.HisProject.MedicalCode
  471. order.HosplistName = subItem.HisProject.ProjectName
  472. order.HilistLv = "1"
  473. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. order.HosplistCode = subItem.HisProject.MedicalCode
  475. order.HosplistName = subItem.HisProject.ProjectName
  476. order.Cnt = subItem.Count
  477. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  478. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  479. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  480. order.OwnpayAmt = ""
  481. order.SelfpayAmt = ""
  482. order.Spec = ""
  483. order.SpecUnt = ""
  484. order.DrordBegnDate = s_tm
  485. order.DrordStopDate = ""
  486. order.DrordDrCodg = "1"
  487. order.DrordDeptName = department.Name
  488. order.DrordDrCodg = "1"
  489. order.DrordDrName = doctor_info.UserName
  490. order.DrordDrProfttl = ""
  491. order.CurrDrordFlag = "1"
  492. orders = append(orders, &order)
  493. }
  494. if subItem.Type == 3 {
  495. var order models.FsiOrderDtos
  496. order.RxID = strconv.FormatInt(item.ID, 10)
  497. order.Rxno = strconv.FormatInt(item.ID, 10)
  498. order.LongDrordFlag = "0"
  499. order.HilistType = "1"
  500. order.ChrgType = "1"
  501. order.DrordBhvr = "-"
  502. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  503. order.HosplistName = subItem.GoodInfo.GoodName
  504. order.HilistLv = "1"
  505. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  507. order.HosplistName = subItem.GoodInfo.GoodName
  508. order.Cnt = subItem.Count
  509. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  511. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  512. order.OwnpayAmt = ""
  513. order.SelfpayAmt = ""
  514. order.Spec = ""
  515. order.SpecUnt = ""
  516. order.DrordBegnDate = s_tm
  517. order.DrordStopDate = ""
  518. order.DrordDrCodg = "1"
  519. order.DrordDeptName = department.Name
  520. order.DrordDrCodg = "1"
  521. order.DrordDrName = doctor_info.UserName
  522. order.DrordDrProfttl = ""
  523. order.CurrDrordFlag = "1"
  524. orders = append(orders, &order)
  525. }
  526. }
  527. }
  528. //处方医嘱信息
  529. fed.MatnStas = "0"
  530. fed.MedfeeSumamt = strconv.FormatFloat(order.MedfeeSumamt, 'E', -1, 64)
  531. fed.OwnpayAmt = strconv.FormatFloat(order.FulamtOwnpayAmt, 'E', -1, 64)
  532. fed.SelfpayAmt = strconv.FormatFloat(order.PreselfpayAmt, 'E', -1, 64)
  533. fed.AcctPayamt = strconv.FormatFloat(order.AcctPay, 'E', -1, 64)
  534. fed.MaAmt = strconv.FormatFloat(order.MafPay, 'E', -1, 64)
  535. fed.HifpPayamt = strconv.FormatFloat(order.HifpPay, 'E', -1, 64)
  536. fed.SetlTotlnum = "1"
  537. fed.Insutype = his.Insutype
  538. fed.ReimFlag = "0"
  539. fed.OutSetlFlag = "0"
  540. var fopd []*models.FsiOperationDtosData
  541. data := make(map[string]interface{})
  542. data["fed"] = fed
  543. data["fdd"] = fdds
  544. data["fod"] = orders
  545. data["pd"] = pd
  546. data["pp"] = pp
  547. data["fopd"] = fopd
  548. data["trig_scen"] = trig_scen
  549. fmt.Println(data)
  550. fmt.Println(fed)
  551. fmt.Println(fdds)
  552. fmt.Println(orders)
  553. fmt.Println(pd)
  554. fmt.Println(pp)
  555. fmt.Println(fopd)
  556. client := &http.Client{}
  557. bytesData, _ := json.Marshal(data)
  558. var req *http.Request
  559. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  560. resp, _ := client.Do(req)
  561. defer resp.Body.Close()
  562. body, ioErr := ioutil.ReadAll(resp.Body)
  563. if ioErr != nil {
  564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. var respJSON map[string]interface{}
  569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. //手术操作集合
  575. //手术操作集合
  576. }
  577. func (c *HisApiController) Check() {
  578. psn_no := c.GetString("psn_no")
  579. in := c.GetString("in")
  580. mt := c.GetString("mt")
  581. baseParams := models.BaseParams{
  582. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  583. FixmedinsCode: "H15049901371",
  584. InsuplcAdmdvs: "150499",
  585. MdtrtareaAdmvs: "150499",
  586. OrgName: "赤峰费森血液透析中心",
  587. Doctor: "1111",
  588. }
  589. service.Gdyb2001(baseParams, psn_no, in, mt)
  590. }
  591. func (c *HisApiController) GetPsnNcdsInfo() {
  592. admin_user_id, _ := c.GetInt64("admin_user_id")
  593. patient_id, _ := c.GetInt64("patient_id")
  594. id, _ := c.GetInt64("id")
  595. adminUser := c.GetAdminUserInfo()
  596. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  597. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  598. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  599. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  600. psn_record, _ := service.GetPsnNCDSRecordById(id)
  601. //
  602. //if psn_record.ID == 0 {
  603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  604. // return
  605. //}
  606. var res Result5301
  607. var res10265 Result5301For10265
  608. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  609. psn_info, _ := service.GetPsnByPatientId(patient_id)
  610. var api string
  611. if miConfig.MdtrtareaAdmvs == "320921" {
  612. 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 +
  613. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  614. } else {
  615. 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 +
  616. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  617. }
  618. resp, requestErr := http.Get(api)
  619. if requestErr != nil {
  620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  621. return
  622. }
  623. body, ioErr := ioutil.ReadAll(resp.Body)
  624. if ioErr != nil {
  625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  627. return
  628. }
  629. var respJSON map[string]interface{}
  630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  633. return
  634. }
  635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  636. result, _ := json.Marshal(respJSON)
  637. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  638. utils.ErrorLog("解析失败:%v", err)
  639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  640. return
  641. }
  642. res.ErrMsg = res10265.ErrMsg
  643. res.Output = res10265.Output
  644. res.InfRefmsgid = res10265.InfRefmsgid
  645. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  646. res.Infcode = infocode
  647. } else {
  648. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  649. var dat map[string]interface{}
  650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  651. fmt.Println(dat)
  652. } else {
  653. fmt.Println(err)
  654. }
  655. userJSONBytes, _ := json.Marshal(dat)
  656. if miConfig.Code == "H15049901371" {
  657. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  658. utils.ErrorLog("解析失败:%v", err)
  659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  660. return
  661. }
  662. res.InfRefmsgid = res10265.InfRefmsgid
  663. res.Output = res10265.Output
  664. res.ErrMsg = res10265.ErrMsg
  665. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  666. res.Infcode = infocode
  667. } else {
  668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  669. utils.ErrorLog("解析失败:%v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. }
  674. }
  675. if res.Infcode == 0 {
  676. c.ServeSuccessJSON(map[string]interface{}{
  677. "result": res.Output.Result,
  678. })
  679. }
  680. }
  681. func (c *HisApiController) CheckInsutype() {
  682. his_patient_id, _ := c.GetInt64("his_patient_id")
  683. admin_user_id, _ := c.GetInt64("admin_user_id")
  684. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  685. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  686. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  687. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  688. var dat map[string]interface{}
  689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  690. fmt.Println(dat)
  691. } else {
  692. fmt.Println(err)
  693. }
  694. userJSONBytes, _ := json.Marshal(dat)
  695. var res Result90100
  696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  697. utils.ErrorLog("解析失败:%v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return
  700. }
  701. if res.Infcode != 0 {
  702. c.ServeSuccessJSON(map[string]interface{}{
  703. "failed_code": -10,
  704. "msg": res.ErrMsg,
  705. })
  706. return
  707. } else {
  708. fmt.Println(res)
  709. }
  710. }
  711. func (c *HisApiController) CheckCardPWD() {
  712. card_pwd := c.GetString("card_pwd")
  713. his_patient_id, _ := c.GetInt64("his_patient_id")
  714. admin_user_id, _ := c.GetInt64("admin_user_id")
  715. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  717. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  718. psn, _ := service.GetPsnByPatientId(his.PatientId)
  719. bas := strings.Split(psn.CardInfo, "|")
  720. basNumber := bas[2]
  721. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  722. var dat map[string]interface{}
  723. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  724. fmt.Println(dat)
  725. } else {
  726. fmt.Println(err)
  727. }
  728. userJSONBytes, _ := json.Marshal(dat)
  729. var res Result90991
  730. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  731. utils.ErrorLog("解析失败:%v", err)
  732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  733. return
  734. }
  735. if res.Infcode != 0 {
  736. c.ServeSuccessJSON(map[string]interface{}{
  737. "failed_code": -10,
  738. "msg": res.ErrMsg,
  739. })
  740. return
  741. } else {
  742. if res.Output.Result.CheckStat == "0" {
  743. var msg string
  744. switch res.Output.Result.CardStat {
  745. case "00":
  746. msg = "未激活"
  747. break
  748. case "10":
  749. msg = "激活"
  750. break
  751. case "20":
  752. msg = "窗口挂失"
  753. break
  754. case "21":
  755. msg = "电话挂失"
  756. break
  757. case "22":
  758. msg = "单位网上申报挂失"
  759. break
  760. case "23":
  761. msg = "保健办挂失"
  762. break
  763. case "24":
  764. msg = "个人网上挂失"
  765. break
  766. case "25":
  767. msg = "网上服务大厅挂失"
  768. break
  769. case "30":
  770. msg = "注销"
  771. break
  772. case "40":
  773. msg = "回收"
  774. break
  775. case "99":
  776. msg = "制卡中(无效卡)"
  777. break
  778. }
  779. c.ServeSuccessJSON(map[string]interface{}{
  780. "failed_code": -10,
  781. "msg": msg,
  782. })
  783. return
  784. } else {
  785. c.ServeSuccessJSON(map[string]interface{}{
  786. "msg": "校验成功",
  787. })
  788. return
  789. }
  790. }
  791. }
  792. func (c *HisApiController) ReadCard() {
  793. id_card_type, _ := c.GetInt64("id_card_type")
  794. admin_user_id, _ := c.GetInt64("admin_user_id")
  795. certificates, _ := c.GetInt64("certificates")
  796. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  797. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  798. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  799. switch id_card_type {
  800. case 1:
  801. if miConfig.MdtrtareaAdmvs == "421300" {
  802. var res ResultTwo
  803. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  804. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  805. "&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)
  806. resp, requestErr := http.Get(api)
  807. if requestErr != nil {
  808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  809. return
  810. }
  811. body, ioErr := ioutil.ReadAll(resp.Body)
  812. if ioErr != nil {
  813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  815. return
  816. }
  817. var respJSON map[string]interface{}
  818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  821. return
  822. }
  823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  824. result, _ := json.Marshal(respJSON)
  825. fmt.Println("log")
  826. fmt.Println(string(result))
  827. if err := json.Unmarshal([]byte(result), &res); err != nil {
  828. utils.ErrorLog("解析失败:%v", err)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return
  831. }
  832. if res.Infcode == 0 {
  833. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  834. if err == gorm.ErrRecordNotFound {
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  836. return
  837. } else if err != nil {
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  839. return
  840. } else {
  841. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  842. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  843. infoStr := string(Iinfos)
  844. idetinfoStr := string(Idetinfos)
  845. psn := &models.HisPsn{
  846. PsnNo: res.Output.Baseinfo.PsnNo,
  847. Age: res.Output.Baseinfo.Age,
  848. PatientId: patient.ID,
  849. Certno: res.Output.Baseinfo.Certno,
  850. Brdy: res.Output.Baseinfo.Brdy,
  851. Gend: res.Output.Baseinfo.Gend,
  852. Naty: res.Output.Baseinfo.Naty,
  853. PsnCertType: res.Output.Baseinfo.PsnCertType,
  854. PsnName: res.Output.Baseinfo.PsnName,
  855. Idetinfo: idetinfoStr,
  856. Insuinfo: infoStr,
  857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  858. }
  859. service.CreateHisPsn(psn)
  860. c.ServeSuccessJSON(map[string]interface{}{
  861. "patient": patient,
  862. "number": res.Output.Baseinfo.Certno,
  863. })
  864. }
  865. } else {
  866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  867. return
  868. }
  869. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  870. var api string
  871. if miConfig.MdtrtareaAdmvs == "320921" {
  872. 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 +
  873. "&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
  874. fmt.Println(api)
  875. } else {
  876. 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 +
  877. "&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)
  878. }
  879. resp, requestErr := http.Get(api)
  880. if requestErr != nil {
  881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  882. return
  883. }
  884. body, ioErr := ioutil.ReadAll(resp.Body)
  885. if ioErr != nil {
  886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  888. return
  889. }
  890. var respJSON map[string]interface{}
  891. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  894. return
  895. }
  896. var status string
  897. status = respJSON["data"].(map[string]interface{})["status"].(string)
  898. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  899. //console.log()
  900. fmt.Println("type===")
  901. fmt.Println(card_type)
  902. var token string
  903. var res ResultTwo //1101结果
  904. var res10265 ResultTwo10265 //1101结果
  905. var card_info string //卡信息
  906. var busi_card_info string
  907. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  908. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  909. if status == "0" { //读卡成功
  910. if card_type == "1" {
  911. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  912. result, _ := json.Marshal(respJSON)
  913. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  914. utils.ErrorLog("解析失败:%v", err)
  915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. }
  918. res.ErrMsg = res10265.ErrMsg
  919. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  920. res.Infcode = infocode
  921. res.Output = res10265.Output
  922. res.InfRefmsgid = res10265.InfRefmsgid
  923. } else {
  924. //var card_info string //卡信息
  925. //var busi_card_info string
  926. token = respJSON["data"].(map[string]interface{})["token"].(string)
  927. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  928. //fmt.Println(card_info)
  929. //fmt.Println(busi_card_info)
  930. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  931. result, _ := json.Marshal(respJSON)
  932. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  933. utils.ErrorLog("解析失败:%v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. res.ErrMsg = res10265.ErrMsg
  938. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  939. res.Infcode = infocode
  940. res.Output = res10265.Output
  941. res.InfRefmsgid = res10265.InfRefmsgid
  942. }
  943. if res.Infcode == 0 {
  944. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  945. if err == gorm.ErrRecordNotFound {
  946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  947. return
  948. } else if err != nil {
  949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  950. return
  951. } else {
  952. if card_type == "1" {
  953. bas := strings.Split(card_info, "|")
  954. basNumber := bas[2]
  955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  957. infoStr := string(Iinfos)
  958. idetinfoStr := string(Idetinfos)
  959. psn := &models.HisPsn{
  960. PsnNo: res.Output.Baseinfo.PsnNo,
  961. Age: res.Output.Baseinfo.Age,
  962. PatientId: patient.ID,
  963. Certno: res.Output.Baseinfo.Certno,
  964. Brdy: res.Output.Baseinfo.Brdy,
  965. Gend: res.Output.Baseinfo.Gend,
  966. Naty: res.Output.Baseinfo.Naty,
  967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  968. PsnName: res.Output.Baseinfo.PsnName,
  969. Idetinfo: idetinfoStr,
  970. Insuinfo: infoStr,
  971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  972. CardInfo: card_info,
  973. VerifyNumber: busi_card_info,
  974. }
  975. service.CreateHisPsn(psn)
  976. c.ServeSuccessJSON(map[string]interface{}{
  977. "patient": patient,
  978. "number": basNumber,
  979. })
  980. } else {
  981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  983. infoStr := string(Iinfos)
  984. idetinfoStr := string(Idetinfos)
  985. psn := &models.HisPsn{
  986. PsnNo: res.Output.Baseinfo.PsnNo,
  987. Age: res.Output.Baseinfo.Age,
  988. PatientId: patient.ID,
  989. Certno: res.Output.Baseinfo.Certno,
  990. Brdy: res.Output.Baseinfo.Brdy,
  991. Gend: res.Output.Baseinfo.Gend,
  992. Naty: res.Output.Baseinfo.Naty,
  993. PsnCertType: res.Output.Baseinfo.PsnCertType,
  994. PsnName: res.Output.Baseinfo.PsnName,
  995. Idetinfo: idetinfoStr,
  996. Insuinfo: infoStr,
  997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  998. CardInfo: card_info,
  999. VerifyNumber: token,
  1000. }
  1001. service.CreateHisPsn(psn)
  1002. c.ServeSuccessJSON(map[string]interface{}{
  1003. "patient": patient,
  1004. "number": token,
  1005. })
  1006. }
  1007. }
  1008. } else {
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1010. return
  1011. }
  1012. } else { //读卡失败
  1013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1014. return
  1015. }
  1016. } else {
  1017. if initFlag == 0 {
  1018. c.TestGetBasBaseInit()
  1019. }
  1020. basStr := c.GetBasBaseInfo()
  1021. if len(basStr) == 0 {
  1022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1023. return
  1024. }
  1025. fmt.Println(basStr)
  1026. bas := strings.Split(basStr, "|")
  1027. basNumber := bas[1]
  1028. fmt.Println(basNumber)
  1029. card_sn := bas[3]
  1030. fmt.Println(card_sn)
  1031. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1032. var dat map[string]interface{}
  1033. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1034. fmt.Println(dat)
  1035. } else {
  1036. fmt.Println(err)
  1037. }
  1038. userJSONBytes, _ := json.Marshal(dat)
  1039. var res ResultTwo
  1040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1041. utils.ErrorLog("解析失败:%v", err)
  1042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1043. return
  1044. }
  1045. if res.Infcode == 0 {
  1046. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1047. if err == gorm.ErrRecordNotFound {
  1048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1049. return
  1050. } else if err != nil {
  1051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1052. return
  1053. } else {
  1054. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1055. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1056. infoStr := string(Iinfos)
  1057. idetinfoStr := string(Idetinfos)
  1058. psn := &models.HisPsn{
  1059. PsnNo: res.Output.Baseinfo.PsnNo,
  1060. Age: res.Output.Baseinfo.Age,
  1061. PatientId: patient.ID,
  1062. Certno: res.Output.Baseinfo.Certno,
  1063. Brdy: res.Output.Baseinfo.Brdy,
  1064. Gend: res.Output.Baseinfo.Gend,
  1065. Naty: res.Output.Baseinfo.Naty,
  1066. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1067. PsnName: res.Output.Baseinfo.PsnName,
  1068. Idetinfo: idetinfoStr,
  1069. Insuinfo: infoStr,
  1070. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1071. CardInfo: basStr,
  1072. VerifyNumber: "",
  1073. }
  1074. service.CreateHisPsn(psn)
  1075. c.ServeSuccessJSON(map[string]interface{}{
  1076. "patient": patient,
  1077. "number": basNumber,
  1078. })
  1079. }
  1080. } else {
  1081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1082. return
  1083. }
  1084. break
  1085. }
  1086. case 2:
  1087. SFZStr := c.GetSFZBaseInfo()
  1088. id_card_str := strings.Split(SFZStr, "^")
  1089. id_card_number := id_card_str[0]
  1090. card_sn := ""
  1091. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1092. var dat map[string]interface{}
  1093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1094. fmt.Println(dat)
  1095. } else {
  1096. fmt.Println(err)
  1097. }
  1098. userJSONBytes, _ := json.Marshal(dat)
  1099. var res ResultTwo
  1100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1101. utils.ErrorLog("解析失败:%v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. if res.Infcode == 0 {
  1106. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1107. if err == gorm.ErrRecordNotFound {
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1109. return
  1110. } else if err != nil {
  1111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1112. return
  1113. } else {
  1114. c.ServeSuccessJSON(map[string]interface{}{
  1115. "patient": patient,
  1116. "number": id_card_number,
  1117. })
  1118. }
  1119. } else {
  1120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1121. return
  1122. }
  1123. break
  1124. case 3:
  1125. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1126. var api string
  1127. if miConfig.MdtrtareaAdmvs == "320921" {
  1128. 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 +
  1129. "&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
  1130. fmt.Println(api)
  1131. } else {
  1132. 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 +
  1133. "&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)
  1134. }
  1135. resp, requestErr := http.Get(api)
  1136. if requestErr != nil {
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. body, ioErr := ioutil.ReadAll(resp.Body)
  1141. if ioErr != nil {
  1142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. var respJSON map[string]interface{}
  1147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1150. return
  1151. }
  1152. var status string
  1153. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1154. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1155. var token string
  1156. var res ResultTwo //1101结果
  1157. var res10265 ResultTwo10265 //1101结果
  1158. var card_info string //卡信息
  1159. var busi_card_info string
  1160. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1161. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1162. if status == "0" { //读卡成功
  1163. if card_type == "1" {
  1164. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1165. result, _ := json.Marshal(respJSON)
  1166. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1167. utils.ErrorLog("解析失败:%v", err)
  1168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1169. return
  1170. }
  1171. res.ErrMsg = res10265.ErrMsg
  1172. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1173. res.Infcode = infocode
  1174. res.Output = res10265.Output
  1175. res.InfRefmsgid = res10265.InfRefmsgid
  1176. } else {
  1177. //var card_info string //卡信息
  1178. //var busi_card_info string
  1179. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1180. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1181. //fmt.Println(card_info)
  1182. //fmt.Println(busi_card_info)
  1183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1184. result, _ := json.Marshal(respJSON)
  1185. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1186. utils.ErrorLog("解析失败:%v", err)
  1187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1188. return
  1189. }
  1190. res.ErrMsg = res10265.ErrMsg
  1191. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1192. res.Infcode = infocode
  1193. res.Output = res10265.Output
  1194. res.InfRefmsgid = res10265.InfRefmsgid
  1195. }
  1196. if res.Infcode == 0 {
  1197. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1198. if err == gorm.ErrRecordNotFound {
  1199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1200. return
  1201. } else if err != nil {
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1203. return
  1204. } else {
  1205. if card_type == "1" {
  1206. bas := strings.Split(card_info, "|")
  1207. basNumber := bas[2]
  1208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1210. infoStr := string(Iinfos)
  1211. idetinfoStr := string(Idetinfos)
  1212. psn := &models.HisPsn{
  1213. PsnNo: res.Output.Baseinfo.PsnNo,
  1214. Age: res.Output.Baseinfo.Age,
  1215. PatientId: patient.ID,
  1216. Certno: res.Output.Baseinfo.Certno,
  1217. Brdy: res.Output.Baseinfo.Brdy,
  1218. Gend: res.Output.Baseinfo.Gend,
  1219. Naty: res.Output.Baseinfo.Naty,
  1220. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1221. PsnName: res.Output.Baseinfo.PsnName,
  1222. Idetinfo: idetinfoStr,
  1223. Insuinfo: infoStr,
  1224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1225. CardInfo: card_info,
  1226. VerifyNumber: busi_card_info,
  1227. }
  1228. service.CreateHisPsn(psn)
  1229. c.ServeSuccessJSON(map[string]interface{}{
  1230. "patient": patient,
  1231. "number": basNumber,
  1232. })
  1233. } else {
  1234. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1235. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1236. infoStr := string(Iinfos)
  1237. idetinfoStr := string(Idetinfos)
  1238. psn := &models.HisPsn{
  1239. PsnNo: res.Output.Baseinfo.PsnNo,
  1240. Age: res.Output.Baseinfo.Age,
  1241. PatientId: patient.ID,
  1242. Certno: res.Output.Baseinfo.Certno,
  1243. Brdy: res.Output.Baseinfo.Brdy,
  1244. Gend: res.Output.Baseinfo.Gend,
  1245. Naty: res.Output.Baseinfo.Naty,
  1246. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1247. PsnName: res.Output.Baseinfo.PsnName,
  1248. Idetinfo: idetinfoStr,
  1249. Insuinfo: infoStr,
  1250. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1251. CardInfo: card_info,
  1252. VerifyNumber: token,
  1253. }
  1254. service.CreateHisPsn(psn)
  1255. c.ServeSuccessJSON(map[string]interface{}{
  1256. "patient": patient,
  1257. "number": token,
  1258. })
  1259. }
  1260. }
  1261. } else {
  1262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1263. return
  1264. }
  1265. } else { //读卡失败
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1267. return
  1268. }
  1269. }
  1270. break
  1271. case 4:
  1272. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1273. var api string
  1274. if miConfig.MdtrtareaAdmvs == "320921" {
  1275. 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 +
  1276. "&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
  1277. fmt.Println(api)
  1278. } else {
  1279. 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 +
  1280. "&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)
  1281. }
  1282. resp, requestErr := http.Get(api)
  1283. if requestErr != nil {
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1285. return
  1286. }
  1287. body, ioErr := ioutil.ReadAll(resp.Body)
  1288. if ioErr != nil {
  1289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1291. return
  1292. }
  1293. var respJSON map[string]interface{}
  1294. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. var status string
  1300. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1301. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1302. var token string
  1303. var res ResultTwo //1101结果
  1304. var res10265 ResultTwo10265 //1101结果
  1305. if status == "0" { //读卡成功
  1306. var card_info string //卡信息
  1307. var busi_card_info string
  1308. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1309. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1310. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1311. fmt.Println(card_info)
  1312. fmt.Println(busi_card_info)
  1313. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1314. result, _ := json.Marshal(respJSON)
  1315. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1316. utils.ErrorLog("解析失败:%v", err)
  1317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1318. return
  1319. }
  1320. res.ErrMsg = res10265.ErrMsg
  1321. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1322. res.Infcode = infocode
  1323. res.Output = res10265.Output
  1324. res.InfRefmsgid = res10265.InfRefmsgid
  1325. if res.Infcode == 0 {
  1326. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1327. if err == gorm.ErrRecordNotFound {
  1328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1329. return
  1330. } else if err != nil {
  1331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1332. return
  1333. } else {
  1334. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1335. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1336. infoStr := string(Iinfos)
  1337. idetinfoStr := string(Idetinfos)
  1338. psn := &models.HisPsn{
  1339. PsnNo: res.Output.Baseinfo.PsnNo,
  1340. Age: res.Output.Baseinfo.Age,
  1341. PatientId: patient.ID,
  1342. Certno: res.Output.Baseinfo.Certno,
  1343. Brdy: res.Output.Baseinfo.Brdy,
  1344. Gend: res.Output.Baseinfo.Gend,
  1345. Naty: res.Output.Baseinfo.Naty,
  1346. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1347. PsnName: res.Output.Baseinfo.PsnName,
  1348. Idetinfo: idetinfoStr,
  1349. Insuinfo: infoStr,
  1350. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1351. CardInfo: card_info,
  1352. VerifyNumber: token,
  1353. }
  1354. service.CreateHisPsn(psn)
  1355. c.ServeSuccessJSON(map[string]interface{}{
  1356. "patient": patient,
  1357. "number": token,
  1358. })
  1359. }
  1360. } else {
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1362. return
  1363. }
  1364. } else { //读卡失败
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1366. return
  1367. }
  1368. }
  1369. break
  1370. }
  1371. }
  1372. var initFlag int64 = 0
  1373. func (c *HisApiController) TestGetBasBaseInit() {
  1374. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1375. Iinit := DllDef.MustFindProc("Init")
  1376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1377. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1378. if ret != 0 {
  1379. fmt.Println("SSCard的报错原因:", err)
  1380. fmt.Println("SSCard的运算结果为:", ret)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1382. return
  1383. }
  1384. result := int(ret)
  1385. fmt.Println("SSCard的运算结果为1:", result)
  1386. initFlag = 1
  1387. return
  1388. }
  1389. func (c *HisApiController) GetSFZBaseInfo() string {
  1390. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1391. readCard := DllDef.MustFindProc("ReadSFZ")
  1392. if readCard == nil {
  1393. fmt.Println("readcard is nil")
  1394. readCard = DllDef.MustFindProc("ReadSFZ")
  1395. }
  1396. str := make([]byte, 256)
  1397. str1 := make([]byte, 256)
  1398. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1399. fmt.Println(r)
  1400. return string(str)
  1401. }
  1402. func (c *HisApiController) GetBasBaseInfo() string {
  1403. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1404. readCard := DllDef.MustFindProc("ReadCardBas")
  1405. if readCard == nil {
  1406. fmt.Println("readcard is nil")
  1407. readCard = DllDef.MustFindProc("ReadCardBas")
  1408. }
  1409. str := make([]byte, 1024)
  1410. str1 := make([]byte, 1024)
  1411. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1412. fmt.Println(string(str1))
  1413. fmt.Println(string(str))
  1414. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1415. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1416. if ret2 != 0 {
  1417. return ""
  1418. }
  1419. return string(str)
  1420. }
  1421. type CustomFundPay struct {
  1422. FundPayType string `json:"fund_pay_type"`
  1423. FundPayamt float64 `json:"fund_payamt"`
  1424. }
  1425. func (c *HisApiController) GetSettleList() {
  1426. order_id, _ := c.GetInt64("order_id")
  1427. admin_user_id, _ := c.GetInt64("admin_user_id")
  1428. order, _ := service.GetHisOrderByIDTwo(order_id)
  1429. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1430. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1431. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1432. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1433. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1435. if order.ID == 0 {
  1436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1437. return
  1438. }
  1439. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1440. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1441. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1442. fmt.Println(count)
  1443. var zero string
  1444. number := count + 1
  1445. if number >= 1000 {
  1446. zero = "0000" + strconv.FormatInt(number, 10)
  1447. } else if number >= 10000 {
  1448. zero = "000" + strconv.FormatInt(number, 10)
  1449. } else if number >= 100000 {
  1450. zero = "00" + strconv.FormatInt(number, 10)
  1451. } else if number >= 1000000 {
  1452. zero = "0" + strconv.FormatInt(number, 10)
  1453. } else {
  1454. zero = strconv.FormatInt(number, 10)
  1455. }
  1456. fmt.Println(zero)
  1457. struct4101 := service.Struct4101{
  1458. PsnNo: order.PsnNo,
  1459. MdtrtId: order.MdtrtId,
  1460. SetlId: order.SetlId,
  1461. PsnName: order.PsnName,
  1462. Gend: order.Gend,
  1463. Brdy: his.Brdy,
  1464. Age: his.Age,
  1465. Naty: order.Naty,
  1466. PatnCertType: "01",
  1467. Certno: order.Certno,
  1468. Prfs: "90",
  1469. ConerName: roles[0].UserName,
  1470. PatnRlts: "99",
  1471. ConerAddr: miConfig.OrgName,
  1472. ConerTel: admin.Mobile,
  1473. HiType: order.Insutype,
  1474. Insuplc: miConfig.InsuplcAdmdvs,
  1475. MaindiagFlag: "1",
  1476. BillCode: last_order.FaPiaoCode,
  1477. BillNo: zero,
  1478. BizSn: order.Number,
  1479. PsnSelfPay: order.PsnPartAmt,
  1480. PsnOwnPay: order.PsnPartAmt,
  1481. AcctPay: order.AcctPay,
  1482. PsnCashpay: order.PsnCashPay,
  1483. HiPaymtd: "1",
  1484. Hsorg: miConfig.InsuplcAdmdvs,
  1485. HsorgOpter: miConfig.InsuplcAdmdvs,
  1486. MedinsFillPsn: curRoles.UserName,
  1487. MedinsFillDept: depart.Name,
  1488. IptMedType: "2",
  1489. }
  1490. struct4101.SetlBegnDate = order.SetlTime
  1491. struct4101.SetlEndDate = order.SetlTime
  1492. time_arr := strings.Split(order.SetlTime, " ")
  1493. struct4101.AdmTime = time_arr[0]
  1494. struct4101.AdmEndTime = time_arr[0]
  1495. var rf []CustomFundPay
  1496. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1497. var tempFunPays []service.CustomStruct
  1498. for _, item := range rf {
  1499. var tempFunPay service.CustomStruct
  1500. tempFunPay.FundPayamt = item.FundPayamt
  1501. tempFunPay.FundPayType = item.FundPayType
  1502. tempFunPays = append(tempFunPays, tempFunPay)
  1503. }
  1504. struct4101.CustomStruct = tempFunPays
  1505. var tempDiaginfos []service.DiaginfoStructTwo
  1506. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1507. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1508. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1509. var config []*models.HisXtDiagnoseConfig
  1510. for _, item := range diagnosis_ids {
  1511. id, _ := strconv.ParseInt(item, 10, 64)
  1512. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1513. config = append(config, &diagnosisConfig)
  1514. }
  1515. for index, item := range config {
  1516. if index == 0 {
  1517. var tempDiaginfo service.DiaginfoStructTwo
  1518. tempDiaginfo.DiagCode = item.CountryCode
  1519. tempDiaginfo.DiagName = item.CountryContentName
  1520. tempDiaginfo.DiagType = "1"
  1521. tempDiaginfo.MaindiagFlag = "1"
  1522. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1523. } else {
  1524. var tempDiaginfo service.DiaginfoStructTwo
  1525. tempDiaginfo.DiagCode = item.CountryCode
  1526. tempDiaginfo.DiagName = item.CountryContentName
  1527. tempDiaginfo.DiagType = "2"
  1528. tempDiaginfo.MaindiagFlag = "0"
  1529. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1530. }
  1531. }
  1532. struct4101.Diseinfo = tempDiaginfos
  1533. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1534. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1535. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1536. tempOpspdiseinfo2.OprnOprtCode = ""
  1537. tempOpspdiseinfo2.OprnOprtName = ""
  1538. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1539. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1540. var iteminfo service.IteminfoStruct
  1541. var bedCostTotal float64 = 0 //床位总费
  1542. var bedCostSelfTotal float64 = 0 //床位自费
  1543. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1544. var operationCostTotal float64 = 0 //手术费
  1545. var operationCostSelfTotal float64 = 0 //手术费
  1546. var operationCostPartSelfTotal float64 = 0 //手术费
  1547. var otherCostTotal float64 = 0 //其他费用
  1548. var otherCostSelfTotal float64 = 0 //其他费用
  1549. var otherCostPartSelfTotal float64 = 0 //其他费用
  1550. var materialCostTotal float64 = 0 //材料费
  1551. var materialCostSelfTotal float64 = 0 //材料费
  1552. var materialCostPartSelfTotal float64 = 0 //材料费
  1553. var westernMedicineCostTotal float64 = 0 //西药费
  1554. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1555. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1556. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1557. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1558. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1559. var checkCostTotal float64 = 0 //检查费
  1560. var checkCostSelfTotal float64 = 0 //检查费
  1561. var checkCostPartSelfTotal float64 = 0 //检查费
  1562. var laboratoryCostTotal float64 = 0 //化验费
  1563. var laboratoryCostSelfTotal float64 = 0 //化验费
  1564. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1565. var treatCostTotal float64 = 0 //治疗费用
  1566. var treatCostSelfTotal float64 = 0 //治疗费用
  1567. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1568. decimal.DivisionPrecision = 2
  1569. var bed_fulamt_ownpay_amt float64 = 0
  1570. var operation_fulamt_ownpay_amt float64 = 0
  1571. var other_fulamt_ownpay_amt float64 = 0
  1572. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1573. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1574. var check_fulamt_ownpay_amt float64 = 0
  1575. var material_fulamt_ownpay_amt float64 = 0
  1576. var laboratory_fulamt_ownpay_amt float64 = 0
  1577. var treat_fulamt_ownpay_amt float64 = 0
  1578. var bed_claa_sunmfee float64 = 0
  1579. var bed_clab_amt float64 = 0
  1580. var bed_other_amt float64 = 0
  1581. var operation_claa_sunmfee float64 = 0
  1582. var operation_clab_amt float64 = 0
  1583. var operation_other_amt float64 = 0
  1584. var other_claa_sunmfee float64 = 0
  1585. var other_clab_amt float64 = 0
  1586. var other_other_amt float64 = 0
  1587. var westernMedicine_claa_sunmfee float64 = 0
  1588. var westernMedicine_clab_amt float64 = 0
  1589. var westernMedicine_other_amt float64 = 0
  1590. var chineseTraditional_claa_sunmfee float64 = 0
  1591. var chineseTraditional_clab_amt float64 = 0
  1592. var chineseTraditional_other_amt float64 = 0
  1593. var check_claa_sunmfee float64 = 0
  1594. var check_clab_amt float64 = 0
  1595. var check_other_amt float64 = 0
  1596. var material_claa_sunmfee float64 = 0
  1597. var material_clab_amt float64 = 0
  1598. var material_other_amt float64 = 0
  1599. var laboratory_claa_sunmfee float64 = 0
  1600. var laboratory_clab_amt float64 = 0
  1601. var laboratory_other_amt float64 = 0
  1602. var treat_claa_sunmfee float64 = 0
  1603. var treat_clab_amt float64 = 0
  1604. var treat_other_amt float64 = 0
  1605. for _, item := range order.HisOrderInfo {
  1606. if item.MedChrgitmType == "01" { //床位费
  1607. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1608. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1609. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1610. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1611. if item.ChrgitmLv == "1" {
  1612. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1613. }
  1614. if item.ChrgitmLv == "2" {
  1615. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1616. }
  1617. if item.ChrgitmLv == "3" {
  1618. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1619. }
  1620. }
  1621. if item.MedChrgitmType == "03" { //检查费
  1622. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1623. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1624. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1625. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1626. if item.ChrgitmLv == "1" {
  1627. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1628. }
  1629. if item.ChrgitmLv == "2" {
  1630. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1631. }
  1632. if item.ChrgitmLv == "3" {
  1633. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1634. }
  1635. }
  1636. if item.MedChrgitmType == "04" { //化验费
  1637. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1638. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1639. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1640. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1641. if item.ChrgitmLv == "1" {
  1642. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1643. }
  1644. if item.ChrgitmLv == "2" {
  1645. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1646. }
  1647. if item.ChrgitmLv == "3" {
  1648. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1649. }
  1650. }
  1651. if item.MedChrgitmType == "05" { //治疗费
  1652. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1653. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1654. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1655. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1656. if item.ChrgitmLv == "1" {
  1657. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1658. }
  1659. if item.ChrgitmLv == "2" {
  1660. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1661. }
  1662. if item.ChrgitmLv == "3" {
  1663. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1664. }
  1665. }
  1666. if item.MedChrgitmType == "06" { //手术费
  1667. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1668. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1669. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1670. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1671. if item.ChrgitmLv == "1" {
  1672. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1673. }
  1674. if item.ChrgitmLv == "2" {
  1675. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1676. }
  1677. if item.ChrgitmLv == "3" {
  1678. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1679. }
  1680. }
  1681. if item.MedChrgitmType == "08" { //材料费
  1682. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1683. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1684. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1685. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1686. if item.ChrgitmLv == "1" {
  1687. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1688. }
  1689. if item.ChrgitmLv == "2" {
  1690. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1691. }
  1692. if item.ChrgitmLv == "3" {
  1693. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1694. }
  1695. }
  1696. if item.MedChrgitmType == "09" { //西药费
  1697. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1698. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1699. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1700. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1701. if item.ChrgitmLv == "1" {
  1702. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1703. }
  1704. if item.ChrgitmLv == "2" {
  1705. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1706. }
  1707. if item.ChrgitmLv == "3" {
  1708. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1709. }
  1710. }
  1711. if item.MedChrgitmType == "11" { //中成费
  1712. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1713. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1714. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1715. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1716. if item.ChrgitmLv == "1" {
  1717. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1718. }
  1719. if item.ChrgitmLv == "2" {
  1720. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1721. }
  1722. if item.ChrgitmLv == "3" {
  1723. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1724. }
  1725. }
  1726. if item.MedChrgitmType == "14" { //其他费
  1727. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1728. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1729. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1730. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1731. if item.ChrgitmLv == "1" {
  1732. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1733. }
  1734. if item.ChrgitmLv == "2" {
  1735. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1736. }
  1737. if item.ChrgitmLv == "3" {
  1738. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1739. }
  1740. }
  1741. }
  1742. var iteminfoStructs []service.IteminfoStruct
  1743. if bedCostTotal != 0 {
  1744. iteminfo.MedChrgitm = "01"
  1745. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1746. iteminfo.Amt = bedCostTotal
  1747. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1748. iteminfo.ClabAmt = bed_clab_amt
  1749. iteminfo.OthAmt = bed_other_amt
  1750. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1751. }
  1752. if checkCostTotal != 0 {
  1753. iteminfo.MedChrgitm = "03"
  1754. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1755. iteminfo.Amt = checkCostTotal
  1756. iteminfo.ClaaSumfee = check_claa_sunmfee
  1757. iteminfo.ClabAmt = check_clab_amt
  1758. iteminfo.OthAmt = check_other_amt
  1759. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1760. }
  1761. if laboratoryCostTotal != 0 {
  1762. iteminfo.MedChrgitm = "04"
  1763. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1764. iteminfo.Amt = laboratoryCostTotal
  1765. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1766. iteminfo.ClabAmt = laboratory_clab_amt
  1767. iteminfo.OthAmt = laboratory_other_amt
  1768. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1769. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1770. }
  1771. if treatCostTotal != 0 {
  1772. iteminfo.MedChrgitm = "05"
  1773. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1774. iteminfo.Amt = treatCostTotal
  1775. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1776. iteminfo.ClabAmt = treat_clab_amt
  1777. iteminfo.OthAmt = treat_other_amt
  1778. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1779. //(struct4101.IteminfoStruct, iteminfo)
  1780. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1781. }
  1782. if operationCostTotal != 0 {
  1783. iteminfo.MedChrgitm = "06"
  1784. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1785. iteminfo.Amt = operationCostTotal
  1786. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1787. iteminfo.ClabAmt = operation_clab_amt
  1788. iteminfo.OthAmt = operation_other_amt
  1789. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1790. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1791. }
  1792. if materialCostTotal != 0 {
  1793. iteminfo.MedChrgitm = "08"
  1794. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1795. iteminfo.Amt = materialCostTotal
  1796. iteminfo.ClaaSumfee = material_claa_sunmfee
  1797. iteminfo.ClabAmt = material_clab_amt
  1798. iteminfo.OthAmt = material_other_amt
  1799. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1800. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1801. }
  1802. if westernMedicineCostTotal != 0 {
  1803. iteminfo.MedChrgitm = "09"
  1804. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1805. iteminfo.Amt = westernMedicineCostTotal
  1806. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1807. iteminfo.ClabAmt = westernMedicine_clab_amt
  1808. iteminfo.OthAmt = westernMedicine_other_amt
  1809. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1811. }
  1812. if chineseTraditionalMedicineCostTotal != 0 {
  1813. iteminfo.MedChrgitm = "11"
  1814. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1815. iteminfo.Amt = westernMedicineCostTotal
  1816. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1817. iteminfo.ClabAmt = westernMedicine_clab_amt
  1818. iteminfo.OthAmt = westernMedicine_other_amt
  1819. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1821. }
  1822. if otherCostTotal != 0 {
  1823. iteminfo.MedChrgitm = "14"
  1824. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1825. iteminfo.Amt = otherCostTotal
  1826. iteminfo.ClaaSumfee = other_claa_sunmfee
  1827. iteminfo.ClabAmt = other_clab_amt
  1828. iteminfo.OthAmt = other_other_amt
  1829. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1830. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1831. }
  1832. struct4101.IteminfoStruct = iteminfoStructs
  1833. struct4101.Ntly = "中国"
  1834. struct4101.AdmCaty = "A03.06"
  1835. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1836. fmt.Println(result)
  1837. var dat map[string]interface{}
  1838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1839. fmt.Println(dat)
  1840. } else {
  1841. fmt.Println(err)
  1842. }
  1843. userJSONBytes, _ := json.Marshal(dat)
  1844. var res ResultSeventeen
  1845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1846. utils.ErrorLog("解析失败:%v", err)
  1847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1848. return
  1849. }
  1850. if res.Infcode != 0 {
  1851. c.ServeSuccessJSON(map[string]interface{}{
  1852. "failed_code": -10,
  1853. "msg": res.ErrMsg,
  1854. })
  1855. return
  1856. } else {
  1857. order.FaPiaoNumber = zero
  1858. order.FaPiaoCode = last_order.FaPiaoCode
  1859. service.UpdateOrder(order)
  1860. hisFundSettleListResult := &models.HisFundSettleListResult{
  1861. Number: res.Output.SetlListId,
  1862. Status: 1,
  1863. Ctime: time.Now().Unix(),
  1864. Mtime: time.Now().Unix(),
  1865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1866. IsUpload: 1,
  1867. OrderId: order_id,
  1868. }
  1869. service.CreateUploadRecord(hisFundSettleListResult)
  1870. c.ServeSuccessJSON(map[string]interface{}{
  1871. "msg": "上传成功",
  1872. "result": hisFundSettleListResult,
  1873. })
  1874. return
  1875. }
  1876. }
  1877. func (c *HisApiController) GetSettleListHospital() {
  1878. order_id, _ := c.GetInt64("order_id")
  1879. admin_user_id, _ := c.GetInt64("admin_user_id")
  1880. order, _ := service.GetHisOrderByIDTwo(order_id)
  1881. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1882. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1883. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1884. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1885. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1886. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1887. if order.ID == 0 {
  1888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1889. return
  1890. }
  1891. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1892. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1893. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1894. fmt.Println(count)
  1895. var zero string
  1896. number := count + 1
  1897. if number >= 1000 {
  1898. zero = "0000" + strconv.FormatInt(number, 10)
  1899. } else if number >= 10000 {
  1900. zero = "000" + strconv.FormatInt(number, 10)
  1901. } else if number >= 100000 {
  1902. zero = "00" + strconv.FormatInt(number, 10)
  1903. } else if number >= 1000000 {
  1904. zero = "0" + strconv.FormatInt(number, 10)
  1905. } else {
  1906. zero = strconv.FormatInt(number, 10)
  1907. }
  1908. fmt.Println(zero)
  1909. struct4101 := service.Struct4101{
  1910. PsnNo: order.PsnNo,
  1911. MdtrtId: order.MdtrtId,
  1912. SetlId: order.SetlId,
  1913. PsnName: order.PsnName,
  1914. Gend: order.Gend,
  1915. Brdy: his.Brdy,
  1916. Age: int64(order.Age),
  1917. Naty: order.Naty,
  1918. PatnCertType: "01",
  1919. Certno: order.Certno,
  1920. Prfs: "90",
  1921. ConerName: roles[0].UserName,
  1922. PatnRlts: "99",
  1923. ConerAddr: miConfig.OrgName,
  1924. ConerTel: admin.Mobile,
  1925. HiType: order.Insutype,
  1926. Insuplc: miConfig.InsuplcAdmdvs,
  1927. MaindiagFlag: "1",
  1928. BillCode: last_order.FaPiaoCode,
  1929. BillNo: zero,
  1930. BizSn: order.Number,
  1931. PsnSelfPay: order.PsnPartAmt,
  1932. PsnOwnPay: order.PsnPartAmt,
  1933. AcctPay: order.AcctPay,
  1934. PsnCashpay: order.PsnCashPay,
  1935. HiPaymtd: "1",
  1936. Hsorg: miConfig.InsuplcAdmdvs,
  1937. HsorgOpter: miConfig.InsuplcAdmdvs,
  1938. MedinsFillPsn: curRoles.UserName,
  1939. MedinsFillDept: depart.Name,
  1940. IptMedType: "2",
  1941. AdmTime: his.InHosptialTime,
  1942. AdmEndTime: his.OutHosptialTime,
  1943. }
  1944. struct4101.SetlBegnDate = order.SetlTime
  1945. struct4101.SetlEndDate = order.SetlTime
  1946. var rf []CustomFundPay
  1947. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1948. var tempFunPays []service.CustomStruct
  1949. for _, item := range rf {
  1950. var tempFunPay service.CustomStruct
  1951. tempFunPay.FundPayamt = item.FundPayamt
  1952. tempFunPay.FundPayType = item.FundPayType
  1953. tempFunPays = append(tempFunPays, tempFunPay)
  1954. }
  1955. struct4101.CustomStruct = tempFunPays
  1956. var tempDiaginfos []service.DiaginfoStructTwo
  1957. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1958. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1959. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1960. var config []*models.HisXtDiagnoseConfig
  1961. for _, item := range diagnosis_ids {
  1962. id, _ := strconv.ParseInt(item, 10, 64)
  1963. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1964. config = append(config, &diagnosisConfig)
  1965. }
  1966. for index, item := range config {
  1967. if index == 0 {
  1968. var tempDiaginfo service.DiaginfoStructTwo
  1969. tempDiaginfo.DiagCode = item.CountryCode
  1970. tempDiaginfo.DiagName = item.CountryContentName
  1971. tempDiaginfo.DiagType = "1"
  1972. tempDiaginfo.MaindiagFlag = "1"
  1973. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1974. } else {
  1975. var tempDiaginfo service.DiaginfoStructTwo
  1976. tempDiaginfo.DiagCode = item.CountryCode
  1977. tempDiaginfo.DiagName = item.CountryContentName
  1978. tempDiaginfo.DiagType = "2"
  1979. tempDiaginfo.MaindiagFlag = "0"
  1980. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1981. }
  1982. }
  1983. struct4101.Diseinfo = tempDiaginfos
  1984. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1985. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1986. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1987. tempOpspdiseinfo2.OprnOprtCode = ""
  1988. tempOpspdiseinfo2.OprnOprtName = ""
  1989. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1990. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1991. var iteminfo service.IteminfoStruct
  1992. var bedCostTotal float64 = 0 //床位总费
  1993. var bedCostSelfTotal float64 = 0 //床位自费
  1994. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1995. var operationCostTotal float64 = 0 //手术费
  1996. var operationCostSelfTotal float64 = 0 //手术费
  1997. var operationCostPartSelfTotal float64 = 0 //手术费
  1998. var otherCostTotal float64 = 0 //其他费用
  1999. var otherCostSelfTotal float64 = 0 //其他费用
  2000. var otherCostPartSelfTotal float64 = 0 //其他费用
  2001. var materialCostTotal float64 = 0 //材料费
  2002. var materialCostSelfTotal float64 = 0 //材料费
  2003. var materialCostPartSelfTotal float64 = 0 //材料费
  2004. var westernMedicineCostTotal float64 = 0 //西药费
  2005. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2006. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2007. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2008. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2009. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2010. var checkCostTotal float64 = 0 //检查费
  2011. var checkCostSelfTotal float64 = 0 //检查费
  2012. var checkCostPartSelfTotal float64 = 0 //检查费
  2013. var laboratoryCostTotal float64 = 0 //化验费
  2014. var laboratoryCostSelfTotal float64 = 0 //化验费
  2015. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2016. var treatCostTotal float64 = 0 //治疗费用
  2017. var treatCostSelfTotal float64 = 0 //治疗费用
  2018. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2019. decimal.DivisionPrecision = 2
  2020. var bed_fulamt_ownpay_amt float64 = 0
  2021. var operation_fulamt_ownpay_amt float64 = 0
  2022. var other_fulamt_ownpay_amt float64 = 0
  2023. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2024. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2025. var check_fulamt_ownpay_amt float64 = 0
  2026. var material_fulamt_ownpay_amt float64 = 0
  2027. var laboratory_fulamt_ownpay_amt float64 = 0
  2028. var treat_fulamt_ownpay_amt float64 = 0
  2029. var bed_claa_sunmfee float64 = 0
  2030. var bed_clab_amt float64 = 0
  2031. var bed_other_amt float64 = 0
  2032. var operation_claa_sunmfee float64 = 0
  2033. var operation_clab_amt float64 = 0
  2034. var operation_other_amt float64 = 0
  2035. var other_claa_sunmfee float64 = 0
  2036. var other_clab_amt float64 = 0
  2037. var other_other_amt float64 = 0
  2038. var westernMedicine_claa_sunmfee float64 = 0
  2039. var westernMedicine_clab_amt float64 = 0
  2040. var westernMedicine_other_amt float64 = 0
  2041. var chineseTraditional_claa_sunmfee float64 = 0
  2042. var chineseTraditional_clab_amt float64 = 0
  2043. var chineseTraditional_other_amt float64 = 0
  2044. var check_claa_sunmfee float64 = 0
  2045. var check_clab_amt float64 = 0
  2046. var check_other_amt float64 = 0
  2047. var material_claa_sunmfee float64 = 0
  2048. var material_clab_amt float64 = 0
  2049. var material_other_amt float64 = 0
  2050. var laboratory_claa_sunmfee float64 = 0
  2051. var laboratory_clab_amt float64 = 0
  2052. var laboratory_other_amt float64 = 0
  2053. var treat_claa_sunmfee float64 = 0
  2054. var treat_clab_amt float64 = 0
  2055. var treat_other_amt float64 = 0
  2056. for _, item := range order.HisOrderInfo {
  2057. if item.MedChrgitmType == "01" { //床位费
  2058. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "03" { //检查费
  2073. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "04" { //化验费
  2088. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "05" { //治疗费
  2103. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. if item.MedChrgitmType == "06" { //手术费
  2118. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2119. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2120. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2121. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2122. if item.ChrgitmLv == "1" {
  2123. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2124. }
  2125. if item.ChrgitmLv == "2" {
  2126. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2127. }
  2128. if item.ChrgitmLv == "3" {
  2129. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2130. }
  2131. }
  2132. if item.MedChrgitmType == "08" { //材料费
  2133. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2134. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2135. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2136. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2137. if item.ChrgitmLv == "1" {
  2138. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2139. }
  2140. if item.ChrgitmLv == "2" {
  2141. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2142. }
  2143. if item.ChrgitmLv == "3" {
  2144. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2145. }
  2146. }
  2147. if item.MedChrgitmType == "09" { //西药费
  2148. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2149. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2150. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2151. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2152. if item.ChrgitmLv == "1" {
  2153. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2154. }
  2155. if item.ChrgitmLv == "2" {
  2156. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2157. }
  2158. if item.ChrgitmLv == "3" {
  2159. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2160. }
  2161. }
  2162. if item.MedChrgitmType == "11" { //中成费
  2163. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2164. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2165. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2166. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2167. if item.ChrgitmLv == "1" {
  2168. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2169. }
  2170. if item.ChrgitmLv == "2" {
  2171. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2172. }
  2173. if item.ChrgitmLv == "3" {
  2174. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2175. }
  2176. }
  2177. if item.MedChrgitmType == "14" { //其他费
  2178. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2179. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2180. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2181. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2182. if item.ChrgitmLv == "1" {
  2183. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2184. }
  2185. if item.ChrgitmLv == "2" {
  2186. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2187. }
  2188. if item.ChrgitmLv == "3" {
  2189. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2190. }
  2191. }
  2192. }
  2193. var iteminfoStructs []service.IteminfoStruct
  2194. if bedCostTotal != 0 {
  2195. iteminfo.MedChrgitm = "01"
  2196. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2197. iteminfo.Amt = bedCostTotal
  2198. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2199. iteminfo.ClabAmt = bed_clab_amt
  2200. iteminfo.OthAmt = bed_other_amt
  2201. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2202. }
  2203. if checkCostTotal != 0 {
  2204. iteminfo.MedChrgitm = "03"
  2205. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2206. iteminfo.Amt = checkCostTotal
  2207. iteminfo.ClaaSumfee = check_claa_sunmfee
  2208. iteminfo.ClabAmt = check_clab_amt
  2209. iteminfo.OthAmt = check_other_amt
  2210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2211. }
  2212. if laboratoryCostTotal != 0 {
  2213. iteminfo.MedChrgitm = "04"
  2214. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2215. iteminfo.Amt = laboratoryCostTotal
  2216. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2217. iteminfo.ClabAmt = laboratory_clab_amt
  2218. iteminfo.OthAmt = laboratory_other_amt
  2219. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2220. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2221. }
  2222. if treatCostTotal != 0 {
  2223. iteminfo.MedChrgitm = "05"
  2224. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2225. iteminfo.Amt = treatCostTotal
  2226. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2227. iteminfo.ClabAmt = treat_clab_amt
  2228. iteminfo.OthAmt = treat_other_amt
  2229. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2230. //(struct4101.IteminfoStruct, iteminfo)
  2231. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2232. }
  2233. if operationCostTotal != 0 {
  2234. iteminfo.MedChrgitm = "06"
  2235. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2236. iteminfo.Amt = operationCostTotal
  2237. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2238. iteminfo.ClabAmt = operation_clab_amt
  2239. iteminfo.OthAmt = operation_other_amt
  2240. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2241. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2242. }
  2243. if materialCostTotal != 0 {
  2244. iteminfo.MedChrgitm = "08"
  2245. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2246. iteminfo.Amt = materialCostTotal
  2247. iteminfo.ClaaSumfee = material_claa_sunmfee
  2248. iteminfo.ClabAmt = material_clab_amt
  2249. iteminfo.OthAmt = material_other_amt
  2250. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2251. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2252. }
  2253. if westernMedicineCostTotal != 0 {
  2254. iteminfo.MedChrgitm = "09"
  2255. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2256. iteminfo.Amt = westernMedicineCostTotal
  2257. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2258. iteminfo.ClabAmt = westernMedicine_clab_amt
  2259. iteminfo.OthAmt = westernMedicine_other_amt
  2260. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2261. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2262. }
  2263. if chineseTraditionalMedicineCostTotal != 0 {
  2264. iteminfo.MedChrgitm = "11"
  2265. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2266. iteminfo.Amt = westernMedicineCostTotal
  2267. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2268. iteminfo.ClabAmt = westernMedicine_clab_amt
  2269. iteminfo.OthAmt = westernMedicine_other_amt
  2270. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2271. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2272. }
  2273. if otherCostTotal != 0 {
  2274. iteminfo.MedChrgitm = "14"
  2275. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2276. iteminfo.Amt = otherCostTotal
  2277. iteminfo.ClaaSumfee = other_claa_sunmfee
  2278. iteminfo.ClabAmt = other_clab_amt
  2279. iteminfo.OthAmt = other_other_amt
  2280. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2281. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2282. }
  2283. struct4101.IteminfoStruct = iteminfoStructs
  2284. struct4101.Ntly = "中国"
  2285. struct4101.AdmCaty = "A03.06"
  2286. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2287. fmt.Println(result)
  2288. var dat map[string]interface{}
  2289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2290. fmt.Println(dat)
  2291. } else {
  2292. fmt.Println(err)
  2293. }
  2294. userJSONBytes, _ := json.Marshal(dat)
  2295. var res ResultSeventeen
  2296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2297. utils.ErrorLog("解析失败:%v", err)
  2298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2299. return
  2300. }
  2301. if res.Infcode != 0 {
  2302. c.ServeSuccessJSON(map[string]interface{}{
  2303. "failed_code": -10,
  2304. "msg": res.ErrMsg,
  2305. })
  2306. return
  2307. } else {
  2308. order.FaPiaoNumber = zero
  2309. order.FaPiaoCode = last_order.FaPiaoCode
  2310. service.UpdateOrder(order)
  2311. hisFundSettleListResult := &models.HisFundSettleListResult{
  2312. Number: res.Output.SetlListId,
  2313. Status: 1,
  2314. Ctime: time.Now().Unix(),
  2315. Mtime: time.Now().Unix(),
  2316. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2317. IsUpload: 1,
  2318. OrderId: order_id,
  2319. }
  2320. service.CreateUploadRecord(hisFundSettleListResult)
  2321. c.ServeSuccessJSON(map[string]interface{}{
  2322. "msg": "上传成功",
  2323. "result": hisFundSettleListResult,
  2324. })
  2325. return
  2326. }
  2327. }
  2328. func (c *HisApiController) GetBatchSettleList() {
  2329. orders, _ := service.GetAllHisOrder(10106)
  2330. for _, item := range orders {
  2331. order_id := item.ID
  2332. order, _ := service.GetHisOrderByIDTwo(order_id)
  2333. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2334. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2335. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2336. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2337. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2339. if order.ID == 0 {
  2340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2341. return
  2342. }
  2343. if his.BalanceAccountsType == 2 {
  2344. continue
  2345. }
  2346. struct4101 := service.Struct4101{
  2347. PsnNo: order.PsnNo,
  2348. MdtrtId: order.MdtrtId,
  2349. SetlId: order.SetlId,
  2350. PsnName: order.PsnName,
  2351. Gend: order.Gend,
  2352. Brdy: his.Brdy,
  2353. Age: his.Age,
  2354. Naty: order.Naty,
  2355. PatnCertType: "01",
  2356. Certno: order.Certno,
  2357. Prfs: "90",
  2358. ConerName: roles[0].UserName,
  2359. PatnRlts: "99",
  2360. ConerAddr: miConfig.OrgName,
  2361. ConerTel: admin.Mobile,
  2362. HiType: order.Insutype,
  2363. Insuplc: his.InsuplcAdmdvs,
  2364. MaindiagFlag: "1",
  2365. BillCode: order.FaPiaoCode,
  2366. BillNo: order.FaPiaoNumber,
  2367. BizSn: order.Number,
  2368. PsnSelfPay: order.PsnPartAmt,
  2369. PsnOwnPay: order.PsnPartAmt,
  2370. AcctPay: order.AcctPay,
  2371. PsnCashpay: order.PsnCashPay,
  2372. HiPaymtd: "1",
  2373. Hsorg: his.InsuplcAdmdvs,
  2374. HsorgOpter: his.InsuplcAdmdvs,
  2375. MedinsFillPsn: curRoles.UserName,
  2376. MedinsFillDept: depart.Name,
  2377. IptMedType: "2",
  2378. }
  2379. struct4101.SetlBegnDate = order.SetlTime
  2380. struct4101.SetlEndDate = order.SetlTime
  2381. //if order.SettleType == 1 {
  2382. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2383. // dateStr := t.Format("2006-01-02")
  2384. // struct4101.SetlBegnDate = dateStr
  2385. // struct4101.SetlEndDate = dateStr
  2386. //} else {
  2387. // t := time.Unix(int64(order.SettleStartTime), 0)
  2388. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2389. // dateStartStr := t.Format("2006-01-02")
  2390. // dateEndStr := t2.Format("2006-01-02")
  2391. // struct4101.SetlBegnDate = dateStartStr
  2392. // struct4101.SetlEndDate = dateEndStr
  2393. //}
  2394. var rf []CustomFundPay
  2395. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2396. var tempFunPays []service.CustomStruct
  2397. var tempFunPay610100 service.CustomStruct
  2398. for _, item := range rf {
  2399. if item.FundPayType == "610100" {
  2400. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2401. tempFunPay610100.FundPayType = item.FundPayType
  2402. } else {
  2403. var tempFunPay service.CustomStruct
  2404. tempFunPay.FundPayamt = item.FundPayamt
  2405. tempFunPay.FundPayType = item.FundPayType
  2406. tempFunPays = append(tempFunPays, tempFunPay)
  2407. }
  2408. }
  2409. tempFunPays = append(tempFunPays, tempFunPay610100)
  2410. struct4101.CustomStruct = tempFunPays
  2411. var tempDiaginfos []service.DiaginfoStructTwo
  2412. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2413. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2414. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2415. var config []*models.HisXtDiagnoseConfig
  2416. for _, item := range diagnosis_ids {
  2417. id, _ := strconv.ParseInt(item, 10, 64)
  2418. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2419. config = append(config, &diagnosisConfig)
  2420. }
  2421. for index, item := range config {
  2422. if index == 0 {
  2423. var tempDiaginfo service.DiaginfoStructTwo
  2424. tempDiaginfo.DiagCode = item.CountryCode
  2425. tempDiaginfo.DiagName = item.CountryContentName
  2426. tempDiaginfo.DiagType = "1"
  2427. tempDiaginfo.MaindiagFlag = "1"
  2428. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2429. } else {
  2430. var tempDiaginfo service.DiaginfoStructTwo
  2431. tempDiaginfo.DiagCode = item.CountryCode
  2432. tempDiaginfo.DiagName = item.CountryContentName
  2433. tempDiaginfo.DiagType = "2"
  2434. tempDiaginfo.MaindiagFlag = "0"
  2435. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2436. }
  2437. }
  2438. struct4101.Diseinfo = tempDiaginfos
  2439. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2440. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2441. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2442. tempOpspdiseinfo2.OprnOprtCode = ""
  2443. tempOpspdiseinfo2.OprnOprtName = ""
  2444. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2445. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2446. var iteminfo service.IteminfoStruct
  2447. var bedCostTotal float64 = 0 //床位总费
  2448. var bedCostSelfTotal float64 = 0 //床位自费
  2449. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2450. var examineCostTotal float64 = 0 //诊查总费
  2451. var examineCostSelfTotal float64 = 0 //诊查自费
  2452. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2453. var nursingCostTotal float64 = 0 //护理总费
  2454. var nursingCostSelfTotal float64 = 0 //护理自费
  2455. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2456. var chineseMedicineCostTotal float64 = 0 //中成药
  2457. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2458. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2459. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2460. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2461. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2462. var registerCostTotal float64 = 0 //一般诊疗费
  2463. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2464. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2465. var operationCostTotal float64 = 0 //手术费
  2466. var operationCostSelfTotal float64 = 0 //手术费
  2467. var operationCostPartSelfTotal float64 = 0 //手术费
  2468. var otherCostTotal float64 = 0 //其他费用
  2469. var otherCostSelfTotal float64 = 0 //其他费用
  2470. var otherCostPartSelfTotal float64 = 0 //其他费用
  2471. var materialCostTotal float64 = 0 //材料费
  2472. var materialCostSelfTotal float64 = 0 //材料费
  2473. var materialCostPartSelfTotal float64 = 0 //材料费
  2474. var westernMedicineCostTotal float64 = 0 //西药费
  2475. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2476. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2477. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2478. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2479. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2480. var checkCostTotal float64 = 0 //检查费
  2481. var checkCostSelfTotal float64 = 0 //检查费
  2482. var checkCostPartSelfTotal float64 = 0 //检查费
  2483. var laboratoryCostTotal float64 = 0 //化验费
  2484. var laboratoryCostSelfTotal float64 = 0 //化验费
  2485. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2486. var treatCostTotal float64 = 0 //治疗费用
  2487. var treatCostSelfTotal float64 = 0 //治疗费用
  2488. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2489. decimal.DivisionPrecision = 2
  2490. var bed_fulamt_ownpay_amt float64 = 0
  2491. var examine_fulamt_ownpay_amt float64 = 0
  2492. var nursing_fulamt_ownpay_amt float64 = 0
  2493. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2494. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2495. var register_fulamt_ownpay_amt float64 = 0
  2496. var operation_fulamt_ownpay_amt float64 = 0
  2497. var other_fulamt_ownpay_amt float64 = 0
  2498. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2499. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2500. var check_fulamt_ownpay_amt float64 = 0
  2501. var material_fulamt_ownpay_amt float64 = 0
  2502. var laboratory_fulamt_ownpay_amt float64 = 0
  2503. var treat_fulamt_ownpay_amt float64 = 0
  2504. var bed_claa_sunmfee float64 = 0
  2505. var bed_clab_amt float64 = 0
  2506. var bed_other_amt float64 = 0
  2507. var examine_claa_sunmfee float64 = 0
  2508. var examine_clab_amt float64 = 0
  2509. var examine_other_amt float64 = 0
  2510. var nursing_claa_sunmfee float64 = 0
  2511. var nursing_clab_amt float64 = 0
  2512. var nursing_other_amt float64 = 0
  2513. var chinese_medicine_claa_sunmfee float64 = 0
  2514. var chinese_medicine_clab_amt float64 = 0
  2515. var chinese_medicine_other_amt float64 = 0
  2516. var commonly_treatment_claa_sunmfee float64 = 0
  2517. var commonly_treatment_clab_amt float64 = 0
  2518. var commonly_treatment_other_amt float64 = 0
  2519. var operation_claa_sunmfee float64 = 0
  2520. var operation_clab_amt float64 = 0
  2521. var operation_other_amt float64 = 0
  2522. var other_claa_sunmfee float64 = 0
  2523. var other_clab_amt float64 = 0
  2524. var other_other_amt float64 = 0
  2525. var westernMedicine_claa_sunmfee float64 = 0
  2526. var westernMedicine_clab_amt float64 = 0
  2527. var westernMedicine_other_amt float64 = 0
  2528. var chineseTraditional_claa_sunmfee float64 = 0
  2529. var chineseTraditional_clab_amt float64 = 0
  2530. var chineseTraditional_other_amt float64 = 0
  2531. var check_claa_sunmfee float64 = 0
  2532. var check_clab_amt float64 = 0
  2533. var check_other_amt float64 = 0
  2534. var material_claa_sunmfee float64 = 0
  2535. var material_clab_amt float64 = 0
  2536. var material_other_amt float64 = 0
  2537. var laboratory_claa_sunmfee float64 = 0
  2538. var laboratory_clab_amt float64 = 0
  2539. var laboratory_other_amt float64 = 0
  2540. var treat_claa_sunmfee float64 = 0
  2541. var treat_clab_amt float64 = 0
  2542. var treat_other_amt float64 = 0
  2543. var register_claa_sunmfee float64 = 0
  2544. var register_clab_amt float64 = 0
  2545. var register_other_amt float64 = 0
  2546. for _, item := range order.HisOrderInfo {
  2547. if item.MedChrgitmType == "01" { //床位费
  2548. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2549. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2550. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2551. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2552. if item.ChrgitmLv == "1" {
  2553. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2554. }
  2555. if item.ChrgitmLv == "2" {
  2556. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2557. }
  2558. if item.ChrgitmLv == "3" {
  2559. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2560. }
  2561. }
  2562. if item.MedChrgitmType == "02" { //诊查
  2563. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2564. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2565. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2566. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2567. if item.ChrgitmLv == "1" {
  2568. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2569. }
  2570. if item.ChrgitmLv == "2" {
  2571. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2572. }
  2573. if item.ChrgitmLv == "3" {
  2574. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2575. }
  2576. }
  2577. if item.MedChrgitmType == "03" { //检查费
  2578. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2579. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2580. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2581. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2582. if item.ChrgitmLv == "1" {
  2583. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2584. }
  2585. if item.ChrgitmLv == "2" {
  2586. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2587. }
  2588. if item.ChrgitmLv == "3" {
  2589. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2590. }
  2591. }
  2592. if item.MedChrgitmType == "04" { //化验费
  2593. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2594. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2595. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2596. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2597. if item.ChrgitmLv == "1" {
  2598. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2599. }
  2600. if item.ChrgitmLv == "2" {
  2601. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2602. }
  2603. if item.ChrgitmLv == "3" {
  2604. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2605. }
  2606. }
  2607. if item.MedChrgitmType == "05" { //治疗费
  2608. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2609. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2610. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2611. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2612. if item.ChrgitmLv == "1" {
  2613. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2614. }
  2615. if item.ChrgitmLv == "2" {
  2616. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2617. }
  2618. if item.ChrgitmLv == "3" {
  2619. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2620. }
  2621. }
  2622. if item.MedChrgitmType == "06" { //手术费
  2623. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2624. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2625. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2626. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2627. if item.ChrgitmLv == "1" {
  2628. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2629. }
  2630. if item.ChrgitmLv == "2" {
  2631. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2632. }
  2633. if item.ChrgitmLv == "3" {
  2634. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2635. }
  2636. }
  2637. if item.MedChrgitmType == "07" { //手术费
  2638. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2639. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2640. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2641. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2642. if item.ChrgitmLv == "1" {
  2643. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2644. }
  2645. if item.ChrgitmLv == "2" {
  2646. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2647. }
  2648. if item.ChrgitmLv == "3" {
  2649. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2650. }
  2651. }
  2652. if item.MedChrgitmType == "08" { //材料费
  2653. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2654. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2655. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2656. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2657. if item.ChrgitmLv == "1" {
  2658. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2659. }
  2660. if item.ChrgitmLv == "2" {
  2661. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2662. }
  2663. if item.ChrgitmLv == "3" {
  2664. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2665. }
  2666. }
  2667. if item.MedChrgitmType == "09" { //西药费
  2668. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2669. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2670. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2671. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2672. if item.ChrgitmLv == "1" {
  2673. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2674. }
  2675. if item.ChrgitmLv == "2" {
  2676. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2677. }
  2678. if item.ChrgitmLv == "3" {
  2679. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2680. }
  2681. }
  2682. if item.MedChrgitmType == "10" { //中药饮片
  2683. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2684. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2685. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2686. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2687. if item.ChrgitmLv == "1" {
  2688. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2689. }
  2690. if item.ChrgitmLv == "2" {
  2691. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2692. }
  2693. if item.ChrgitmLv == "3" {
  2694. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2695. }
  2696. }
  2697. if item.MedChrgitmType == "11" { //中成费
  2698. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2699. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2700. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2701. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2702. if item.ChrgitmLv == "1" {
  2703. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2704. }
  2705. if item.ChrgitmLv == "2" {
  2706. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2707. }
  2708. if item.ChrgitmLv == "3" {
  2709. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2710. }
  2711. }
  2712. if item.MedChrgitmType == "12" { //中成费
  2713. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2714. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2715. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2716. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2717. if item.ChrgitmLv == "1" {
  2718. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2719. }
  2720. if item.ChrgitmLv == "2" {
  2721. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2722. }
  2723. if item.ChrgitmLv == "3" {
  2724. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2725. }
  2726. }
  2727. if item.MedChrgitmType == "13" { //中成费
  2728. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2729. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2730. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2731. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2732. if item.ChrgitmLv == "1" {
  2733. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2734. }
  2735. if item.ChrgitmLv == "2" {
  2736. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2737. }
  2738. if item.ChrgitmLv == "3" {
  2739. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2740. }
  2741. }
  2742. if item.MedChrgitmType == "14" { //其他费
  2743. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2744. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2745. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2746. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2747. if item.ChrgitmLv == "1" {
  2748. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2749. }
  2750. if item.ChrgitmLv == "2" {
  2751. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2752. }
  2753. if item.ChrgitmLv == "3" {
  2754. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2755. }
  2756. }
  2757. }
  2758. var iteminfoStructs []service.IteminfoStruct
  2759. if bedCostTotal != 0 {
  2760. iteminfo.MedChrgitm = "01"
  2761. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2762. iteminfo.Amt = bedCostTotal
  2763. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2764. iteminfo.ClabAmt = bed_clab_amt
  2765. iteminfo.OthAmt = bed_other_amt
  2766. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2767. }
  2768. if examineCostTotal != 0 {
  2769. iteminfo.MedChrgitm = "02"
  2770. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2771. iteminfo.Amt = examineCostTotal
  2772. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2773. iteminfo.ClabAmt = examine_clab_amt
  2774. iteminfo.OthAmt = examine_other_amt
  2775. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2776. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2777. }
  2778. if checkCostTotal != 0 {
  2779. iteminfo.MedChrgitm = "03"
  2780. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2781. iteminfo.Amt = checkCostTotal
  2782. iteminfo.ClaaSumfee = check_claa_sunmfee
  2783. iteminfo.ClabAmt = check_clab_amt
  2784. iteminfo.OthAmt = check_other_amt
  2785. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2786. }
  2787. if laboratoryCostTotal != 0 {
  2788. iteminfo.MedChrgitm = "04"
  2789. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2790. iteminfo.Amt = laboratoryCostTotal
  2791. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2792. iteminfo.ClabAmt = laboratory_clab_amt
  2793. iteminfo.OthAmt = laboratory_other_amt
  2794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2795. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2796. }
  2797. if treatCostTotal != 0 {
  2798. iteminfo.MedChrgitm = "05"
  2799. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2800. iteminfo.Amt = treatCostTotal
  2801. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2802. iteminfo.ClabAmt = treat_clab_amt
  2803. iteminfo.OthAmt = treat_other_amt
  2804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2805. //(struct4101.IteminfoStruct, iteminfo)
  2806. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2807. }
  2808. if operationCostTotal != 0 {
  2809. iteminfo.MedChrgitm = "06"
  2810. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2811. iteminfo.Amt = operationCostTotal
  2812. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2813. iteminfo.ClabAmt = operation_clab_amt
  2814. iteminfo.OthAmt = operation_other_amt
  2815. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2816. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2817. }
  2818. if nursingCostTotal != 0 {
  2819. iteminfo.MedChrgitm = "07"
  2820. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2821. iteminfo.Amt = nursingCostTotal
  2822. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2823. iteminfo.ClabAmt = nursing_clab_amt
  2824. iteminfo.OthAmt = nursing_other_amt
  2825. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2826. }
  2827. if materialCostTotal != 0 {
  2828. iteminfo.MedChrgitm = "08"
  2829. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2830. iteminfo.Amt = materialCostTotal
  2831. iteminfo.ClaaSumfee = material_claa_sunmfee
  2832. iteminfo.ClabAmt = material_clab_amt
  2833. iteminfo.OthAmt = material_other_amt
  2834. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2835. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2836. }
  2837. if westernMedicineCostTotal != 0 {
  2838. iteminfo.MedChrgitm = "09"
  2839. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2840. iteminfo.Amt = westernMedicineCostTotal
  2841. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2842. iteminfo.ClabAmt = westernMedicine_clab_amt
  2843. iteminfo.OthAmt = westernMedicine_other_amt
  2844. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2845. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2846. }
  2847. if chineseMedicineCostTotal != 0 {
  2848. iteminfo.MedChrgitm = "10"
  2849. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2850. iteminfo.Amt = chineseMedicineCostTotal
  2851. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2852. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2853. iteminfo.OthAmt = chinese_medicine_other_amt
  2854. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2856. }
  2857. if chineseTraditionalMedicineCostTotal != 0 {
  2858. iteminfo.MedChrgitm = "11"
  2859. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2860. iteminfo.Amt = westernMedicineCostTotal
  2861. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2862. iteminfo.ClabAmt = westernMedicine_clab_amt
  2863. iteminfo.OthAmt = westernMedicine_other_amt
  2864. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2865. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2866. }
  2867. if commonlyTreatmentCostTotal != 0 {
  2868. iteminfo.MedChrgitm = "12"
  2869. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2870. iteminfo.Amt = commonlyTreatmentCostTotal
  2871. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2872. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2873. iteminfo.OthAmt = commonly_treatment_other_amt
  2874. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2875. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2876. }
  2877. if registerCostTotal != 0 {
  2878. iteminfo.MedChrgitm = "13"
  2879. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2880. iteminfo.Amt = registerCostTotal
  2881. iteminfo.ClaaSumfee = register_claa_sunmfee
  2882. iteminfo.ClabAmt = register_clab_amt
  2883. iteminfo.OthAmt = register_other_amt
  2884. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2885. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2886. }
  2887. if otherCostTotal != 0 {
  2888. iteminfo.MedChrgitm = "14"
  2889. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2890. iteminfo.Amt = otherCostTotal
  2891. iteminfo.ClaaSumfee = other_claa_sunmfee
  2892. iteminfo.ClabAmt = other_clab_amt
  2893. iteminfo.OthAmt = other_other_amt
  2894. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2895. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2896. }
  2897. struct4101.IteminfoStruct = iteminfoStructs
  2898. struct4101.Ntly = "中国"
  2899. struct4101.AdmCaty = "A03.06"
  2900. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2901. fmt.Println(result)
  2902. var dat map[string]interface{}
  2903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2904. fmt.Println(dat)
  2905. } else {
  2906. fmt.Println(err)
  2907. }
  2908. userJSONBytes, _ := json.Marshal(dat)
  2909. var res ResultSeventeen
  2910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. adminUser := c.GetAdminUserInfo()
  2914. errlog := &models.HisOrderError{
  2915. UserOrgId: adminUser.CurrentOrgId,
  2916. Ctime: time.Now().Unix(),
  2917. Mtime: time.Now().Unix(),
  2918. ErrMsg: res.ErrMsg + "解析失败",
  2919. Status: 1,
  2920. PatientId: order_id,
  2921. Stage: 10106,
  2922. }
  2923. service.CreateErrMsgLog(errlog)
  2924. continue
  2925. }
  2926. if res.Infcode != 0 {
  2927. adminUser := c.GetAdminUserInfo()
  2928. errlog := &models.HisOrderError{
  2929. UserOrgId: adminUser.CurrentOrgId,
  2930. Ctime: time.Now().Unix(),
  2931. Mtime: time.Now().Unix(),
  2932. ErrMsg: res.ErrMsg,
  2933. Status: 1,
  2934. PatientId: order_id,
  2935. Stage: 10106,
  2936. }
  2937. service.CreateErrMsgLog(errlog)
  2938. continue
  2939. } else {
  2940. hisFundSettleListResult := &models.HisFundSettleListResult{
  2941. Number: res.Output.SetlListId,
  2942. Status: 1,
  2943. Ctime: time.Now().Unix(),
  2944. Mtime: time.Now().Unix(),
  2945. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2946. IsUpload: 1,
  2947. OrderId: order_id,
  2948. }
  2949. service.CreateUploadRecord(hisFundSettleListResult)
  2950. continue
  2951. }
  2952. }
  2953. }
  2954. func (c *HisApiController) GetOrgInfo() {
  2955. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2956. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2957. }
  2958. func (c *HisApiController) GetHisPatientInfo() {
  2959. medical_insurance_card := c.GetString("medical_insurance_card")
  2960. id_card_type, _ := c.GetInt64("id_card_type")
  2961. id_card := c.GetString("id_card")
  2962. adminInfo := c.GetAdminUserInfo()
  2963. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2964. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2965. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2966. IdCardNo := ""
  2967. if id_card_type == 1 {
  2968. IdCardNo = medical_insurance_card
  2969. } else if id_card_type == 2 {
  2970. IdCardNo = id_card
  2971. }
  2972. if config.IsOpen == 1 {
  2973. 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
  2974. resp, requestErr := http.Get(api)
  2975. if requestErr != nil {
  2976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2977. return
  2978. }
  2979. defer resp.Body.Close()
  2980. body, ioErr := ioutil.ReadAll(resp.Body)
  2981. if ioErr != nil {
  2982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2984. return
  2985. }
  2986. var respJSON map[string]interface{}
  2987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2993. userJSONBytes, _ := json.Marshal(userJSON)
  2994. var res ResultTwo
  2995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2996. utils.ErrorLog("解析失败:%v", err)
  2997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2998. return
  2999. }
  3000. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3001. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3002. infoStr := string(Iinfos)
  3003. idetinfoStr := string(Idetinfos)
  3004. if res.Infcode == 0 {
  3005. his := models.VMHisPatient{
  3006. Status: 1,
  3007. Ctime: time.Now().Unix(),
  3008. Mtime: time.Now().Unix(),
  3009. PsnNo: res.Output.Baseinfo.PsnNo,
  3010. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3011. Certno: res.Output.Baseinfo.Certno,
  3012. PsnName: res.Output.Baseinfo.PsnName,
  3013. Gend: res.Output.Baseinfo.Gend,
  3014. Naty: res.Output.Baseinfo.Naty,
  3015. Brdy: res.Output.Baseinfo.Brdy,
  3016. Age: res.Output.Baseinfo.Age,
  3017. Iinfo: infoStr,
  3018. Idetinfo: idetinfoStr,
  3019. UserOrgId: adminInfo.CurrentOrgId,
  3020. IsReturn: 1,
  3021. IdCardType: id_card_type,
  3022. }
  3023. c.ServeSuccessJSON(map[string]interface{}{
  3024. "info": his,
  3025. })
  3026. } else {
  3027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3028. return
  3029. }
  3030. }
  3031. }
  3032. //func GetBasBaseInfo() (jsonStr string, err error) {
  3033. //
  3034. // handle := syscall.NewLazyDLL("SSCard.dll")
  3035. // add := handle.NewProc("ReadCardBas")
  3036. // str := make([]byte, 1024)
  3037. // str1 := make([]byte, 1024)
  3038. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3039. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3040. //
  3041. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3042. //
  3043. // fmt.Println("> Add(4,5)的结果为:", ret)
  3044. // handle.Release()
  3045. //
  3046. // return "", nil
  3047. //
  3048. //}
  3049. //func GetQRBaseInfo() (jsonStr string, err error) {
  3050. // handle := syscall.LoadDLL("SSCard.dll")
  3051. // ReadCardBas := handle.FindProc("GetQRBase")
  3052. //
  3053. // str := make([]byte, 256)
  3054. // str1 := make([]byte, 256)
  3055. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3056. //
  3057. // fmt.Println(string(str))
  3058. // fmt.Println(r)
  3059. // return string(str), nil
  3060. //}
  3061. //func CardInit() int {
  3062. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3063. // add := DllTestDef.MustFindProc("Init")
  3064. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3065. // if err != nil {
  3066. // fmt.Println("SSCard的运算结果为:", ret)
  3067. // }
  3068. // result := int(ret)
  3069. // return result
  3070. //}
  3071. //func CardInit() int {
  3072. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3073. // if err != nil {
  3074. // fmt.Println("SSCard的运算结果为:", ret)
  3075. // }
  3076. // fmt.Println(err)
  3077. // result := int(ret)
  3078. // return result
  3079. //}
  3080. func IntPtr(n int) uintptr {
  3081. return uintptr(n)
  3082. }
  3083. func StrPtr(s string) uintptr {
  3084. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3085. }
  3086. type Result2001 struct {
  3087. Cainfo interface{} `json:"cainfo"`
  3088. ErrMsg string `json:"err_msg"`
  3089. InfRefmsgid string `json:"inf_refmsgid"`
  3090. Infcode int64 `json:"infcode"`
  3091. Output struct {
  3092. Trtinfo struct {
  3093. PsnNo string `json:"psn_no"`
  3094. TrtChkType string `json:"trt_chk_type"`
  3095. FundPayType string `json:"fund_pay_type"`
  3096. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3097. Begndate string `json:"begndate"`
  3098. Enddate string `json:"enddate"`
  3099. TrtChkRslt string `json:"trt_chk_rslt"`
  3100. } `json:"trtinfo"`
  3101. } `json:"output"`
  3102. RefmsgTime string `json:"refmsg_time"`
  3103. RespondTime string `json:"respond_time"`
  3104. Signtype interface{} `json:"signtype"`
  3105. WarnMsg interface{} `json:"warn_msg"`
  3106. }
  3107. type Result2001Org10265 struct {
  3108. Cainfo interface{} `json:"cainfo"`
  3109. ErrMsg string `json:"err_msg"`
  3110. InfRefmsgid string `json:"inf_refmsgid"`
  3111. Infcode string `json:"infcode"`
  3112. Output struct {
  3113. Trtinfo struct {
  3114. PsnNo string `json:"psn_no"`
  3115. TrtChkType string `json:"trt_chk_type"`
  3116. FundPayType string `json:"fund_pay_type"`
  3117. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3118. Begndate string `json:"begndate"`
  3119. Enddate string `json:"enddate"`
  3120. TrtChkRslt string `json:"trt_chk_rslt"`
  3121. } `json:"trtinfo"`
  3122. } `json:"output"`
  3123. RefmsgTime string `json:"refmsg_time"`
  3124. RespondTime string `json:"respond_time"`
  3125. Signtype interface{} `json:"signtype"`
  3126. WarnMsg interface{} `json:"warn_msg"`
  3127. }
  3128. type ResultTwo struct {
  3129. ErrMsg string `json:"err_msg"`
  3130. InfRefmsgid string `json:"inf_refmsgid"`
  3131. Infcode int64 `json:"infcode"`
  3132. Output struct {
  3133. Baseinfo struct {
  3134. Age float64 `json:"age"`
  3135. Brdy string `json:"brdy"`
  3136. Certno string `json:"certno"`
  3137. Gend string `json:"gend"`
  3138. Naty string `json:"naty"`
  3139. PsnCertType string `json:"psn_cert_type"`
  3140. PsnName string `json:"psn_name"`
  3141. PsnNo string `json:"psn_no"`
  3142. } `json:"baseinfo"`
  3143. Idetinfo []interface{} `json:"idetinfo"`
  3144. Iinfo []struct {
  3145. Balc float64 `json:"balc"`
  3146. CvlservFlag string `json:"cvlserv_flag"`
  3147. EmpName string `json:"emp_name"`
  3148. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3149. Insutype string `json:"insutype"`
  3150. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3151. PausInsuDate string `json:"paus_insu_date"`
  3152. PsnInsuDate string `json:"psn_insu_date"`
  3153. PsnInsuStas string `json:"psn_insu_stas"`
  3154. PsnType string `json:"psn_type"`
  3155. } `json:"insuinfo"`
  3156. } `json:"output"`
  3157. RefmsgTime string `json:"refmsg_time"`
  3158. RespondTime string `json:"respond_time"`
  3159. Signtype interface{} `json:"signtype"`
  3160. WarnInfo interface{} `json:"warn_info"`
  3161. }
  3162. type ResultTwo10265 struct {
  3163. ErrMsg string `json:"err_msg"`
  3164. InfRefmsgid string `json:"inf_refmsgid"`
  3165. Infcode string `json:"infcode"`
  3166. Output struct {
  3167. Baseinfo struct {
  3168. Age float64 `json:"age"`
  3169. Brdy string `json:"brdy"`
  3170. Certno string `json:"certno"`
  3171. Gend string `json:"gend"`
  3172. Naty string `json:"naty"`
  3173. PsnCertType string `json:"psn_cert_type"`
  3174. PsnName string `json:"psn_name"`
  3175. PsnNo string `json:"psn_no"`
  3176. } `json:"baseinfo"`
  3177. Idetinfo []interface{} `json:"idetinfo"`
  3178. Iinfo []struct {
  3179. Balc float64 `json:"balc"`
  3180. CvlservFlag string `json:"cvlserv_flag"`
  3181. EmpName string `json:"emp_name"`
  3182. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3183. Insutype string `json:"insutype"`
  3184. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3185. PausInsuDate string `json:"paus_insu_date"`
  3186. PsnInsuDate string `json:"psn_insu_date"`
  3187. PsnInsuStas string `json:"psn_insu_stas"`
  3188. PsnType string `json:"psn_type"`
  3189. } `json:"insuinfo"`
  3190. } `json:"output"`
  3191. RefmsgTime string `json:"refmsg_time"`
  3192. RespondTime string `json:"respond_time"`
  3193. Signtype interface{} `json:"signtype"`
  3194. WarnInfo interface{} `json:"warn_info"`
  3195. }
  3196. type ResultThree struct {
  3197. Cainfo interface{} `json:"cainfo"`
  3198. ErrMsg string `json:"err_msg"`
  3199. InfRefmsgid string `json:"inf_refmsgid"`
  3200. Infcode int64 `json:"infcode"`
  3201. Output struct {
  3202. Data struct {
  3203. IptOtpNo string `json:"ipt_otp_no"`
  3204. MdtrtID string `json:"mdtrt_id"`
  3205. PsnNo string `json:"psn_no"`
  3206. } `json:"data"`
  3207. } `json:"output"`
  3208. RefmsgTime string `json:"refmsg_time"`
  3209. RespondTime string `json:"respond_time"`
  3210. Signtype interface{} `json:"signtype"`
  3211. WarnMsg interface{} `json:"warn_msg"`
  3212. }
  3213. type ResultThree10265 struct {
  3214. Cainfo interface{} `json:"cainfo"`
  3215. ErrMsg string `json:"err_msg"`
  3216. InfRefmsgid string `json:"inf_refmsgid"`
  3217. Infcode string `json:"infcode"`
  3218. Output struct {
  3219. Data struct {
  3220. IptOtpNo string `json:"ipt_otp_no"`
  3221. MdtrtID string `json:"mdtrt_id"`
  3222. PsnNo string `json:"psn_no"`
  3223. } `json:"data"`
  3224. } `json:"output"`
  3225. RefmsgTime string `json:"refmsg_time"`
  3226. RespondTime string `json:"respond_time"`
  3227. Signtype interface{} `json:"signtype"`
  3228. WarnMsg interface{} `json:"warn_msg"`
  3229. }
  3230. type ResultFour struct {
  3231. Cainfo string `json:"cainfo"`
  3232. ErrMsg string `json:"err_msg"`
  3233. InfRefmsgid string `json:"inf_refmsgid"`
  3234. Infcode int64 `json:"infcode"`
  3235. Output struct {
  3236. Result []struct {
  3237. BasMednFlag string `json:"bas_medn_flag"`
  3238. ChldMedcFlag string `json:"chld_medc_flag"`
  3239. ChrgitmLv string `json:"chrgitm_lv"`
  3240. Cnt float64 `json:"cnt"`
  3241. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3242. DrtReimFlag string `json:"drt_reim_flag"`
  3243. FeedetlSn string `json:"feedetl_sn"`
  3244. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3245. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3246. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3247. ListSpItemFlag string `json:"list_sp_item_flag"`
  3248. LmtUsedFlag string `json:"lmt_used_flag"`
  3249. MedChrgitmType string `json:"med_chrgitm_type"`
  3250. Memo string `json:"memo"`
  3251. OverlmtAmt float64 `json:"overlmt_amt"`
  3252. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3253. Pric float64 `json:"pric"`
  3254. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3255. SelfpayProp float64 `json:"selfpay_prop"`
  3256. } `json:"result"`
  3257. } `json:"output"`
  3258. RefmsgTime string `json:"refmsg_time"`
  3259. RespondTime string `json:"respond_time"`
  3260. Signtype string `json:"signtype"`
  3261. WarnMsg string `json:"warn_msg"`
  3262. }
  3263. type ResultFour10265 struct {
  3264. Cainfo string `json:"cainfo"`
  3265. ErrMsg string `json:"err_msg"`
  3266. InfRefmsgid string `json:"inf_refmsgid"`
  3267. Infcode string `json:"infcode"`
  3268. Output struct {
  3269. Result []struct {
  3270. BasMednFlag string `json:"bas_medn_flag"`
  3271. ChldMedcFlag string `json:"chld_medc_flag"`
  3272. ChrgitmLv string `json:"chrgitm_lv"`
  3273. Cnt float64 `json:"cnt"`
  3274. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3275. DrtReimFlag string `json:"drt_reim_flag"`
  3276. FeedetlSn string `json:"feedetl_sn"`
  3277. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3278. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3279. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3280. ListSpItemFlag string `json:"list_sp_item_flag"`
  3281. LmtUsedFlag string `json:"lmt_used_flag"`
  3282. MedChrgitmType string `json:"med_chrgitm_type"`
  3283. Memo string `json:"memo"`
  3284. OverlmtAmt float64 `json:"overlmt_amt"`
  3285. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3286. Pric float64 `json:"pric"`
  3287. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3288. SelfpayProp float64 `json:"selfpay_prop"`
  3289. } `json:"result"`
  3290. } `json:"output"`
  3291. RefmsgTime string `json:"refmsg_time"`
  3292. RespondTime string `json:"respond_time"`
  3293. Signtype string `json:"signtype"`
  3294. WarnMsg string `json:"warn_msg"`
  3295. }
  3296. type ResultFive struct {
  3297. Balc float64 `json:"balc"`
  3298. CvlservFlag string `json:"cvlserv_flag"`
  3299. EmpName string `json:"emp_name"`
  3300. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3301. Insutype string `json:"insutype"`
  3302. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3303. PausInsuDate string `json:"paus_insu_date"`
  3304. PsnInsuDate string `json:"psn_insu_date"`
  3305. PsnInsuStas string `json:"psn_insu_stas"`
  3306. PsnType string `json:"psn_type"`
  3307. }
  3308. type ResultSix struct {
  3309. Cainfo interface{} `json:"cainfo"`
  3310. ErrMsg string `json:"err_msg"`
  3311. InfRefmsgid string `json:"inf_refmsgid"`
  3312. Infcode int64 `json:"infcode"`
  3313. Output struct {
  3314. } `json:"output"`
  3315. RefmsgTime string `json:"refmsg_time"`
  3316. RespondTime string `json:"respond_time"`
  3317. Signtype interface{} `json:"signtype"`
  3318. WarnMsg interface{} `json:"warn_msg"`
  3319. }
  3320. type ResultSix10265 struct {
  3321. Cainfo interface{} `json:"cainfo"`
  3322. ErrMsg string `json:"err_msg"`
  3323. InfRefmsgid string `json:"inf_refmsgid"`
  3324. Infcode string `json:"infcode"`
  3325. Output struct {
  3326. } `json:"output"`
  3327. RefmsgTime string `json:"refmsg_time"`
  3328. RespondTime string `json:"respond_time"`
  3329. Signtype interface{} `json:"signtype"`
  3330. WarnMsg interface{} `json:"warn_msg"`
  3331. }
  3332. type ResultSeven struct {
  3333. Cainfo string `json:"cainfo"`
  3334. ErrMsg string `json:"err_msg"`
  3335. InfRefmsgid string `json:"inf_refmsgid"`
  3336. Infcode int64 `json:"infcode"`
  3337. Output struct {
  3338. Setldetail []interface{} `json:"setldetail"`
  3339. Setlinfo struct {
  3340. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3341. AcctPay float64 `json:"acct_pay"`
  3342. ActPayDedc float64 `json:"act_pay_dedc"`
  3343. Age float64 `json:"age"`
  3344. Balc float64 `json:"balc"`
  3345. Brdy string `json:"brdy"`
  3346. Certno string `json:"certno"`
  3347. ClrOptins string `json:"clr_optins"`
  3348. ClrType string `json:"clr_type"`
  3349. ClrWay string `json:"clr_way"`
  3350. CvlservFlag string `json:"cvlserv_flag"`
  3351. CvlservPay float64 `json:"cvlserv_pay"`
  3352. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3353. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3354. Gend string `json:"gend"`
  3355. HifesPay float64 `json:"hifes_pay"`
  3356. HifmiPay float64 `json:"hifmi_pay"`
  3357. HifpPay float64 `json:"hifp_pay"`
  3358. HospPartAmt float64 `json:"hosp_part_amt"`
  3359. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3360. Insutype string `json:"insutype"`
  3361. MafPay float64 `json:"maf_pay"`
  3362. MdtrtCertType string `json:"mdtrt_cert_type"`
  3363. HifobPay float64 `json:"hifob_pay"`
  3364. MdtrtID string `json:"mdtrt_id"`
  3365. MedType string `json:"med_type"`
  3366. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3367. MedinsSetlID string `json:"medins_setl_id"`
  3368. Naty string `json:"naty"`
  3369. OthPay float64 `json:"oth_pay"`
  3370. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3371. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3372. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3373. PsnCashPay float64 `json:"psn_cash_pay"`
  3374. PsnCertType string `json:"psn_cert_type"`
  3375. PsnName string `json:"psn_name"`
  3376. PsnNo string `json:"psn_no"`
  3377. PsnPartAmt float64 `json:"psn_part_amt"`
  3378. PsnType string `json:"psn_type"`
  3379. SetlID string `json:"setl_id"`
  3380. SetlTime string `json:"setl_time"`
  3381. } `json:"setlinfo"`
  3382. } `json:"output"`
  3383. RefmsgTime string `json:"refmsg_time"`
  3384. RespondTime string `json:"respond_time"`
  3385. Signtype interface{} `json:"signtype"`
  3386. WarnMsg interface{} `json:"warn_msg"`
  3387. }
  3388. type ResultSeven10265 struct {
  3389. Cainfo string `json:"cainfo"`
  3390. ErrMsg string `json:"err_msg"`
  3391. InfRefmsgid string `json:"inf_refmsgid"`
  3392. Infcode string `json:"infcode"`
  3393. Output struct {
  3394. Setldetail []interface{} `json:"setldetail"`
  3395. Setlinfo struct {
  3396. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3397. AcctPay float64 `json:"acct_pay"`
  3398. ActPayDedc float64 `json:"act_pay_dedc"`
  3399. Age float64 `json:"age"`
  3400. Balc float64 `json:"balc"`
  3401. Brdy string `json:"brdy"`
  3402. Certno string `json:"certno"`
  3403. ClrOptins string `json:"clr_optins"`
  3404. ClrType string `json:"clr_type"`
  3405. ClrWay string `json:"clr_way"`
  3406. CvlservFlag string `json:"cvlserv_flag"`
  3407. CvlservPay float64 `json:"cvlserv_pay"`
  3408. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3409. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3410. Gend string `json:"gend"`
  3411. HifesPay float64 `json:"hifes_pay"`
  3412. HifmiPay float64 `json:"hifmi_pay"`
  3413. HifpPay float64 `json:"hifp_pay"`
  3414. HospPartAmt float64 `json:"hosp_part_amt"`
  3415. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3416. Insutype string `json:"insutype"`
  3417. MafPay float64 `json:"maf_pay"`
  3418. MdtrtCertType string `json:"mdtrt_cert_type"`
  3419. HifobPay float64 `json:"hifob_pay"`
  3420. MdtrtID string `json:"mdtrt_id"`
  3421. MedType string `json:"med_type"`
  3422. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3423. MedinsSetlID string `json:"medins_setl_id"`
  3424. Naty string `json:"naty"`
  3425. OthPay float64 `json:"oth_pay"`
  3426. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3427. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3428. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3429. PsnCashPay float64 `json:"psn_cash_pay"`
  3430. PsnCertType string `json:"psn_cert_type"`
  3431. PsnName string `json:"psn_name"`
  3432. PsnNo string `json:"psn_no"`
  3433. PsnPartAmt float64 `json:"psn_part_amt"`
  3434. PsnType string `json:"psn_type"`
  3435. SetlID string `json:"setl_id"`
  3436. SetlTime string `json:"setl_time"`
  3437. } `json:"setlinfo"`
  3438. } `json:"output"`
  3439. RefmsgTime string `json:"refmsg_time"`
  3440. RespondTime string `json:"respond_time"`
  3441. Signtype interface{} `json:"signtype"`
  3442. WarnMsg interface{} `json:"warn_msg"`
  3443. }
  3444. type ResultEight struct {
  3445. Cainfo string `json:"cainfo"`
  3446. ErrMsg string `json:"err_msg"`
  3447. InfRefmsgid string `json:"inf_refmsgid"`
  3448. Infcode int64 `json:"infcode"`
  3449. Output struct {
  3450. Stmtinfo struct {
  3451. SetlOptins string `json:"setl_optins"`
  3452. StmtRslt string `json:"stmt_rslt"`
  3453. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3454. } `json:"stmtinfo"`
  3455. } `json:"output"`
  3456. RefmsgTime string `json:"refmsg_time"`
  3457. RespondTime string `json:"respond_time"`
  3458. Signtype interface{} `json:"signtype"`
  3459. WarnMsg interface{} `json:"warn_msg"`
  3460. }
  3461. type ResultEightFor10188 struct {
  3462. Cainfo string `json:"cainfo"`
  3463. ErrMsg string `json:"err_msg"`
  3464. InfRefmsgid string `json:"inf_refmsgid"`
  3465. Infcode string `json:"infcode"`
  3466. Output struct {
  3467. Stmtinfo struct {
  3468. SetlOptins string `json:"setl_optins"`
  3469. StmtRslt string `json:"stmt_rslt"`
  3470. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3471. } `json:"stmtinfo"`
  3472. } `json:"output"`
  3473. RefmsgTime string `json:"refmsg_time"`
  3474. RespondTime string `json:"respond_time"`
  3475. Signtype interface{} `json:"signtype"`
  3476. WarnMsg interface{} `json:"warn_msg"`
  3477. }
  3478. type ResultNine struct {
  3479. Cainfo string `json:"cainfo"`
  3480. ErrMsg string `json:"err_msg"`
  3481. InfRefmsgid string `json:"inf_refmsgid"`
  3482. Infcode int64 `json:"infcode"`
  3483. Output struct {
  3484. FileQuryNo string `json:"file_qury_no"`
  3485. } `json:"output"`
  3486. RefmsgTime string `json:"refmsg_time"`
  3487. RespondTime string `json:"respond_time"`
  3488. Signtype interface{} `json:"signtype"`
  3489. WarnMsg interface{} `json:"warn_msg"`
  3490. }
  3491. type ResultTen struct {
  3492. Cainfo string `json:"cainfo"`
  3493. ErrMsg string `json:"err_msg"`
  3494. InfRefmsgid string `json:"inf_refmsgid"`
  3495. Infcode int64 `json:"infcode"`
  3496. Output struct {
  3497. DldEndtime string `json:"dld_endtime"`
  3498. FileQuryNo string `json:"file_qury_no"`
  3499. Filename string `json:"filename"`
  3500. } `json:"output"`
  3501. RefmsgTime string `json:"refmsg_time"`
  3502. RespondTime string `json:"respond_time"`
  3503. Signtype interface{} `json:"signtype"`
  3504. WarnMsg interface{} `json:"warn_msg"`
  3505. }
  3506. //type Autogenerated struct {
  3507. // Output struct {
  3508. // Setlinfo struct {
  3509. // SetlTime string `json:"setl_time"`
  3510. // CvlservPay float64 `json:"cvlserv_pay"`
  3511. // Year string `json:"year"`
  3512. // MedType string `json:"med_type"`
  3513. // PsnPay float64 `json:"psn_pay"`
  3514. // OpterID string `json:"opter_id"`
  3515. // Begndate string `json:"begndate"`
  3516. // FlxempeFlag string `json:"flxempe_flag"`
  3517. // HifmiPay float64 `json:"hifmi_pay"`
  3518. // PsnNo string `json:"psn_no"`
  3519. // ActPayDedc float64 `json:"act_pay_dedc"`
  3520. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3521. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3522. // ClrWay string `json:"clr_way"`
  3523. // OthPay float64 `json:"oth_pay"`
  3524. // Gend string `json:"gend"`
  3525. // MdtrtID string `json:"mdtrt_id"`
  3526. // AcctPay float64 `json:"acct_pay"`
  3527. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3528. // Insutype string `json:"insutype"`
  3529. // Invono interface{} `json:"invono"`
  3530. // Enddate string `json:"enddate"`
  3531. // CashPayamt float64 `json:"cash_payamt"`
  3532. // PsnType string `json:"psn_type"`
  3533. // FixmedinsName string `json:"fixmedins_name"`
  3534. // HifpPay float64 `json:"hifp_pay"`
  3535. // NewFlag interface{} `json:"new_flag"`
  3536. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3537. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3538. // PayLoc string `json:"pay_loc"`
  3539. // ClrType string `json:"clr_type"`
  3540. // RefdSetlFlag string `json:"refd_setl_flag"`
  3541. // CvlservFlag string `json:"cvlserv_flag"`
  3542. // EmpName string `json:"emp_name"`
  3543. // Brdy string `json:"brdy"`
  3544. // Naty string `json:"naty"`
  3545. // Certno string `json:"certno"`
  3546. // DiseCode string `json:"dise_code"`
  3547. // FixmedinsCode string `json:"fixmedins_code"`
  3548. // DedcHospLv string `json:"dedc_hosp_lv"`
  3549. // OpterName string `json:"opter_name"`
  3550. // Balc float64 `json:"balc"`
  3551. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3552. // PsnCertType string `json:"psn_cert_type"`
  3553. // HifobPay float64 `json:"hifob_pay"`
  3554. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3555. // HifesPay float64 `json:"hifes_pay"`
  3556. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3557. // OptTime string `json:"opt_time"`
  3558. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3559. // SetlID string `json:"setl_id"`
  3560. // MafPay float64 `json:"maf_pay"`
  3561. // PsnName string `json:"psn_name"`
  3562. // InsuOptins interface{} `json:"insu_optins"`
  3563. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3564. // ClrOptins string `json:"clr_optins"`
  3565. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3566. // DiseName string `json:"dise_name"`
  3567. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3568. // Age float64 `json:"age"`
  3569. // DtrtCertType string `json:"dtrt_cert_type"`
  3570. // HospLv string `json:"hosp_lv"`
  3571. // } `json:"setlinfo"`
  3572. // Setldetail []struct {
  3573. // FundPayType string `json:"fund_pay_type"`
  3574. // FundPayamt float64 `json:"fund_payamt"`
  3575. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3576. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3577. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3578. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3579. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3580. // } `json:"setldetail"`
  3581. // } `json:"output"`
  3582. // Infcode int `json:"infcode"`
  3583. // WarnMsg interface{} `json:"warn_msg"`
  3584. // Cainfo interface{} `json:"cainfo"`
  3585. // ErrMsg interface{} `json:"err_msg"`
  3586. // RefmsgTime string `json:"refmsg_time"`
  3587. // Signtype interface{} `json:"signtype"`
  3588. // RespondTime string `json:"respond_time"`
  3589. // InfRefmsgid string `json:"inf_refmsgid"`
  3590. //}
  3591. type ResultEleven struct {
  3592. Cainfo string `json:"cainfo"`
  3593. ErrMsg string `json:"err_msg"`
  3594. InfRefmsgid string `json:"inf_refmsgid"`
  3595. Infcode int64 `json:"infcode"`
  3596. Output struct {
  3597. Setlinfo struct {
  3598. SetlTime string `json:"setl_time"`
  3599. CvlservPay float64 `json:"cvlserv_pay"`
  3600. Year string `json:"year"`
  3601. MedType string `json:"med_type"`
  3602. PsnPay float64 `json:"psn_pay"`
  3603. OpterID string `json:"opter_id"`
  3604. Begndate string `json:"begndate"`
  3605. FlxempeFlag string `json:"flxempe_flag"`
  3606. HifmiPay float64 `json:"hifmi_pay"`
  3607. PsnNo string `json:"psn_no"`
  3608. ActPayDedc float64 `json:"act_pay_dedc"`
  3609. MedinsSetlID interface{} `json:"medins_setl_id"`
  3610. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3611. ClrWay string `json:"clr_way"`
  3612. OthPay float64 `json:"oth_pay"`
  3613. Gend string `json:"gend"`
  3614. MdtrtID string `json:"mdtrt_id"`
  3615. AcctPay float64 `json:"acct_pay"`
  3616. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3617. Insutype string `json:"insutype"`
  3618. Invono interface{} `json:"invono"`
  3619. Enddate string `json:"enddate"`
  3620. CashPayamt float64 `json:"cash_payamt"`
  3621. PsnType string `json:"psn_type"`
  3622. FixmedinsName string `json:"fixmedins_name"`
  3623. HifpPay float64 `json:"hifp_pay"`
  3624. NewFlag interface{} `json:"new_flag"`
  3625. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3626. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3627. PayLoc string `json:"pay_loc"`
  3628. ClrType string `json:"clr_type"`
  3629. RefdSetlFlag string `json:"refd_setl_flag"`
  3630. CvlservFlag string `json:"cvlserv_flag"`
  3631. EmpName string `json:"emp_name"`
  3632. Brdy string `json:"brdy"`
  3633. Naty string `json:"naty"`
  3634. Certno string `json:"certno"`
  3635. DiseCode string `json:"dise_code"`
  3636. FixmedinsCode string `json:"fixmedins_code"`
  3637. DedcHospLv string `json:"dedc_hosp_lv"`
  3638. OpterName string `json:"opter_name"`
  3639. Balc float64 `json:"balc"`
  3640. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3641. PsnCertType string `json:"psn_cert_type"`
  3642. HifobPay float64 `json:"hifob_pay"`
  3643. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3644. HifesPay float64 `json:"hifes_pay"`
  3645. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3646. OptTime string `json:"opt_time"`
  3647. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3648. SetlID string `json:"setl_id"`
  3649. MafPay float64 `json:"maf_pay"`
  3650. PsnName string `json:"psn_name"`
  3651. InsuOptins interface{} `json:"insu_optins"`
  3652. PrefFundPay interface{} `json:"pref_fund_pay"`
  3653. ClrOptins string `json:"clr_optins"`
  3654. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3655. DiseName string `json:"dise_name"`
  3656. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3657. Age float64 `json:"age"`
  3658. DtrtCertType string `json:"dtrt_cert_type"`
  3659. HospLv string `json:"hosp_lv"`
  3660. } `json:"setlinfo"`
  3661. } `json:"output"`
  3662. RefmsgTime string `json:"refmsg_time"`
  3663. RespondTime string `json:"respond_time"`
  3664. Signtype interface{} `json:"signtype"`
  3665. WarnMsg interface{} `json:"warn_msg"`
  3666. }
  3667. type ResultEleven10265 struct {
  3668. Cainfo string `json:"cainfo"`
  3669. ErrMsg string `json:"err_msg"`
  3670. InfRefmsgid string `json:"inf_refmsgid"`
  3671. Infcode string `json:"infcode"`
  3672. Output struct {
  3673. Setlinfo struct {
  3674. SetlTime string `json:"setl_time"`
  3675. CvlservPay float64 `json:"cvlserv_pay"`
  3676. Year string `json:"year"`
  3677. MedType string `json:"med_type"`
  3678. PsnPay float64 `json:"psn_pay"`
  3679. OpterID string `json:"opter_id"`
  3680. Begndate string `json:"begndate"`
  3681. FlxempeFlag string `json:"flxempe_flag"`
  3682. HifmiPay float64 `json:"hifmi_pay"`
  3683. PsnNo string `json:"psn_no"`
  3684. ActPayDedc float64 `json:"act_pay_dedc"`
  3685. MedinsSetlID interface{} `json:"medins_setl_id"`
  3686. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3687. ClrWay string `json:"clr_way"`
  3688. OthPay float64 `json:"oth_pay"`
  3689. Gend string `json:"gend"`
  3690. MdtrtID string `json:"mdtrt_id"`
  3691. AcctPay float64 `json:"acct_pay"`
  3692. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3693. Insutype string `json:"insutype"`
  3694. Invono interface{} `json:"invono"`
  3695. Enddate string `json:"enddate"`
  3696. CashPayamt float64 `json:"cash_payamt"`
  3697. PsnType string `json:"psn_type"`
  3698. FixmedinsName string `json:"fixmedins_name"`
  3699. HifpPay float64 `json:"hifp_pay"`
  3700. NewFlag interface{} `json:"new_flag"`
  3701. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3702. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3703. PayLoc string `json:"pay_loc"`
  3704. ClrType string `json:"clr_type"`
  3705. RefdSetlFlag string `json:"refd_setl_flag"`
  3706. CvlservFlag string `json:"cvlserv_flag"`
  3707. EmpName string `json:"emp_name"`
  3708. Brdy string `json:"brdy"`
  3709. Naty string `json:"naty"`
  3710. Certno string `json:"certno"`
  3711. DiseCode string `json:"dise_code"`
  3712. FixmedinsCode string `json:"fixmedins_code"`
  3713. DedcHospLv string `json:"dedc_hosp_lv"`
  3714. OpterName string `json:"opter_name"`
  3715. Balc float64 `json:"balc"`
  3716. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3717. PsnCertType string `json:"psn_cert_type"`
  3718. HifobPay float64 `json:"hifob_pay"`
  3719. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3720. HifesPay float64 `json:"hifes_pay"`
  3721. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3722. OptTime string `json:"opt_time"`
  3723. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3724. SetlID string `json:"setl_id"`
  3725. MafPay float64 `json:"maf_pay"`
  3726. PsnName string `json:"psn_name"`
  3727. InsuOptins interface{} `json:"insu_optins"`
  3728. PrefFundPay interface{} `json:"pref_fund_pay"`
  3729. ClrOptins string `json:"clr_optins"`
  3730. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3731. DiseName string `json:"dise_name"`
  3732. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3733. Age float64 `json:"age"`
  3734. DtrtCertType string `json:"dtrt_cert_type"`
  3735. HospLv string `json:"hosp_lv"`
  3736. } `json:"setlinfo"`
  3737. } `json:"output"`
  3738. RefmsgTime string `json:"refmsg_time"`
  3739. RespondTime string `json:"respond_time"`
  3740. Signtype interface{} `json:"signtype"`
  3741. WarnMsg interface{} `json:"warn_msg"`
  3742. }
  3743. type ResultTwelve struct {
  3744. Cainfo string `json:"cainfo"`
  3745. ErrMsg string `json:"err_msg"`
  3746. InfRefmsgid string `json:"inf_refmsgid"`
  3747. Infcode int64 `json:"infcode"`
  3748. Output struct {
  3749. MdtrtId string `json:"mdtrt_id"`
  3750. ChrgBchno string `json:"chrg_bchno"`
  3751. PsnNo string `json:"psn_no"`
  3752. } `json:"output"`
  3753. RefmsgTime string `json:"refmsg_time"`
  3754. RespondTime string `json:"respond_time"`
  3755. Signtype interface{} `json:"signtype"`
  3756. WarnMsg interface{} `json:"warn_msg"`
  3757. }
  3758. type ResultThirteen struct {
  3759. ErrMsg string `json:"err_msg"`
  3760. InfRefmsgid string `json:"inf_refmsgid"`
  3761. Infcode int64 `json:"infcode"`
  3762. Output struct {
  3763. Result struct {
  3764. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3765. } `json:"result"`
  3766. } `json:"output"`
  3767. RefmsgTime string `json:"refmsg_time"`
  3768. RespondTime string `json:"respond_time"`
  3769. Signtype interface{} `json:"signtype"`
  3770. WarnInfo interface{} `json:"warn_info"`
  3771. }
  3772. type ResultThirteen10265 struct {
  3773. ErrMsg string `json:"err_msg"`
  3774. InfRefmsgid string `json:"inf_refmsgid"`
  3775. Infcode string `json:"infcode"`
  3776. Output struct {
  3777. Result struct {
  3778. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3779. } `json:"result"`
  3780. } `json:"output"`
  3781. RefmsgTime string `json:"refmsg_time"`
  3782. RespondTime string `json:"respond_time"`
  3783. Signtype interface{} `json:"signtype"`
  3784. WarnInfo interface{} `json:"warn_info"`
  3785. }
  3786. type ResultFourteen struct {
  3787. ErrMsg string `json:"err_msg"`
  3788. InfRefmsgid string `json:"inf_refmsgid"`
  3789. Infcode int64 `json:"infcode"`
  3790. Output struct {
  3791. } `json:"output"`
  3792. RefmsgTime string `json:"refmsg_time"`
  3793. RespondTime string `json:"respond_time"`
  3794. Signtype interface{} `json:"signtype"`
  3795. WarnInfo interface{} `json:"warn_info"`
  3796. }
  3797. type ResultFourteen10265 struct {
  3798. ErrMsg string `json:"err_msg"`
  3799. InfRefmsgid string `json:"inf_refmsgid"`
  3800. Infcode string `json:"infcode"`
  3801. Output struct {
  3802. } `json:"output"`
  3803. RefmsgTime string `json:"refmsg_time"`
  3804. RespondTime string `json:"respond_time"`
  3805. Signtype interface{} `json:"signtype"`
  3806. WarnInfo interface{} `json:"warn_info"`
  3807. }
  3808. type ResultSixteen struct {
  3809. Cainfo string `json:"cainfo"`
  3810. ErrMsg string `json:"err_msg"`
  3811. InfRefmsgid string `json:"inf_refmsgid"`
  3812. Infcode int64 `json:"infcode"`
  3813. Output struct {
  3814. Setldetail []interface{} `json:"setldetail"`
  3815. Setlinfo struct {
  3816. MdtrtID string `json:"mdtrt_id"`
  3817. SetlID string `json:"setl_id"`
  3818. ClrOptins string `json:"clr_optins"`
  3819. SetlTime string `json:"setl_time"`
  3820. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3821. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3822. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3823. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3824. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3825. ActPayDedc float64 `json:"act_pay_dedc"`
  3826. HifpPay float64 `json:"hifp_pay"`
  3827. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3828. Lfpay float64 `json:"selfpay"`
  3829. CvlservPay float64 `json:"cvlserv_pay"`
  3830. HifesPay float64 `json:"hifes_pay"`
  3831. HifmiPay float64 `json:"hifmi_pay"`
  3832. HifobPay float64 `json:"hifob_pay"`
  3833. MafPay float64 `json:"maf_pay"`
  3834. OthPay float64 `json:"oth_pay"`
  3835. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3836. PsnPartAmt float64 `json:"psn_part_amt"`
  3837. AcctPay float64 `json:"acct_pay"`
  3838. Balc float64 `json:"balc"`
  3839. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3840. HospPartAmt float64 `json:"hosp_part_amt"`
  3841. MedinsSetlID string `json:"medins_setl_id"`
  3842. PdnCashPay string `json:"pdn_cash_pay"`
  3843. } `json:"setlinfo"`
  3844. } `json:"output"`
  3845. RefmsgTime string `json:"refmsg_time"`
  3846. RespondTime string `json:"respond_time"`
  3847. Signtype interface{} `json:"signtype"`
  3848. WarnMsg interface{} `json:"warn_msg"`
  3849. }
  3850. type ResultSixteen10265 struct {
  3851. Cainfo string `json:"cainfo"`
  3852. ErrMsg string `json:"err_msg"`
  3853. InfRefmsgid string `json:"inf_refmsgid"`
  3854. Infcode string `json:"infcode"`
  3855. Output struct {
  3856. Setldetail []interface{} `json:"setldetail"`
  3857. Setlinfo struct {
  3858. MdtrtID string `json:"mdtrt_id"`
  3859. SetlID string `json:"setl_id"`
  3860. ClrOptins string `json:"clr_optins"`
  3861. SetlTime string `json:"setl_time"`
  3862. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3863. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3864. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3865. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3866. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3867. ActPayDedc float64 `json:"act_pay_dedc"`
  3868. HifpPay float64 `json:"hifp_pay"`
  3869. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3870. Lfpay float64 `json:"selfpay"`
  3871. CvlservPay float64 `json:"cvlserv_pay"`
  3872. HifesPay float64 `json:"hifes_pay"`
  3873. HifmiPay float64 `json:"hifmi_pay"`
  3874. HifobPay float64 `json:"hifob_pay"`
  3875. MafPay float64 `json:"maf_pay"`
  3876. OthPay float64 `json:"oth_pay"`
  3877. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3878. PsnPartAmt float64 `json:"psn_part_amt"`
  3879. AcctPay float64 `json:"acct_pay"`
  3880. Balc float64 `json:"balc"`
  3881. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3882. HospPartAmt float64 `json:"hosp_part_amt"`
  3883. MedinsSetlID string `json:"medins_setl_id"`
  3884. PdnCashPay string `json:"pdn_cash_pay"`
  3885. } `json:"setlinfo"`
  3886. } `json:"output"`
  3887. RefmsgTime string `json:"refmsg_time"`
  3888. RespondTime string `json:"respond_time"`
  3889. Signtype interface{} `json:"signtype"`
  3890. WarnMsg interface{} `json:"warn_msg"`
  3891. }
  3892. type ResultSeventeen struct {
  3893. ErrMsg string `json:"err_msg"`
  3894. InfRefmsgid string `json:"inf_refmsgid"`
  3895. Infcode int64 `json:"infcode"`
  3896. Output struct {
  3897. SetlListId string `json:"setl_list_id"`
  3898. } `json:"output"`
  3899. RefmsgTime string `json:"refmsg_time"`
  3900. RespondTime string `json:"respond_time"`
  3901. Signtype string `json:"signtype"`
  3902. WarnInfo string `json:"warn_info"`
  3903. }
  3904. type Result90991 struct {
  3905. ErrMsg string `json:"err_msg"`
  3906. InfRefmsgid string `json:"inf_refmsgid"`
  3907. Infcode int64 `json:"infcode"`
  3908. Output struct {
  3909. Result struct {
  3910. PsnNo string `json:"psn_no"`
  3911. CardStat string `json:"card_stat"`
  3912. Certno string `json:"certno"`
  3913. PsnName string `json:"psn_name"`
  3914. CheckStat string `json:"check_stat"`
  3915. } `json:"result"`
  3916. } `json:"output"`
  3917. RefmsgTime string `json:"refmsg_time"`
  3918. RespondTime string `json:"respond_time"`
  3919. Signtype interface{} `json:"signtype"`
  3920. WarnInfo interface{} `json:"warn_info"`
  3921. }
  3922. type Result90100 struct {
  3923. ErrMsg string `json:"err_msg"`
  3924. InfRefmsgid string `json:"inf_refmsgid"`
  3925. Infcode int64 `json:"infcode"`
  3926. Output struct {
  3927. PoolareaNo string `json:"poolarea_no"`
  3928. PoolareaNoName string `json:"poolarea_no_name"`
  3929. Insutype string `json:"insutype"`
  3930. InsutypeName string `json:"insutype_name"`
  3931. ClctType string `json:"clct_type"`
  3932. ClctTypeName string `json:"clct_type_name"`
  3933. ClctFlag string `json:"clct_flag"`
  3934. ClctFlagName string `json:"clct_flag_name"`
  3935. AccrymBegn string `json:"accrym_begn"`
  3936. AccrymEnd string `json:"accrym_end"`
  3937. ClctTime string `json:"clct_time"`
  3938. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3939. } `json:"output"`
  3940. RefmsgTime string `json:"refmsg_time"`
  3941. RespondTime string `json:"respond_time"`
  3942. Signtype interface{} `json:"signtype"`
  3943. WarnInfo interface{} `json:"warn_info"`
  3944. }
  3945. type Custom struct {
  3946. DetItemFeeSumamt string
  3947. Cut string
  3948. FeedetlSn string
  3949. Price string
  3950. MedListCodg string
  3951. Type int64
  3952. AdviceId int64
  3953. ProjectId int64
  3954. ItemId int64
  3955. }
  3956. type Result5301 struct {
  3957. ErrMsg string `json:"err_msg"`
  3958. InfRefmsgid string `json:"inf_refmsgid"`
  3959. Infcode int64 `json:"infcode"`
  3960. Output struct {
  3961. Result []struct {
  3962. OpspDiseCode string `json:"opsp_dise_code"`
  3963. OpspDiseName string `json:"opsp_dise_name"`
  3964. Begndate string `json:"begndate"`
  3965. Enddate string `json:"enddate"`
  3966. } `json:"feedetail"`
  3967. } `json:"output"`
  3968. RefmsgTime string `json:"refmsg_time"`
  3969. RespondTime string `json:"respond_time"`
  3970. Signtype interface{} `json:"signtype"`
  3971. WarnInfo interface{} `json:"warn_info"`
  3972. }
  3973. type Result5301For10265 struct {
  3974. ErrMsg string `json:"err_msg"`
  3975. InfRefmsgid string `json:"inf_refmsgid"`
  3976. Infcode string `json:"infcode"`
  3977. Output struct {
  3978. Result []struct {
  3979. OpspDiseCode string `json:"opsp_dise_code"`
  3980. OpspDiseName string `json:"opsp_dise_name"`
  3981. Begndate string `json:"begndate"`
  3982. Enddate string `json:"enddate"`
  3983. } `json:"feedetail"`
  3984. } `json:"output"`
  3985. RefmsgTime string `json:"refmsg_time"`
  3986. RespondTime string `json:"respond_time"`
  3987. Signtype interface{} `json:"signtype"`
  3988. WarnInfo interface{} `json:"warn_info"`
  3989. }
  3990. //获取个人信息----挂号-----上传就诊信息
  3991. func (c *HisApiController) GetRegisterInfo() {
  3992. id, _ := c.GetInt64("id")
  3993. record_time := c.GetString("record_time")
  3994. settlementValue, _ := c.GetInt64("settlement_value")
  3995. medical_insurance_card := c.GetString("medical_insurance_card")
  3996. name := c.GetString("name")
  3997. id_card_type, _ := c.GetInt64("id_card_type")
  3998. certificates, _ := c.GetInt64("certificates")
  3999. medical_care, _ := c.GetInt64("medical_care")
  4000. birthday := c.GetString("birthday")
  4001. id_card := c.GetString("id_card")
  4002. register_type, _ := c.GetInt64("register")
  4003. doctor, _ := c.GetInt64("doctor")
  4004. department, _ := c.GetInt64("department")
  4005. gender, _ := c.GetInt64("sex")
  4006. registration_fee, _ := c.GetFloat("registration_fee")
  4007. medical_expenses, _ := c.GetFloat("medical_expenses")
  4008. social_type, _ := c.GetInt64("social_type")
  4009. med_type := c.GetString("social_type")
  4010. admin_user_id, _ := c.GetInt64("admin_user_id")
  4011. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4012. timeLayout := "2006-01-02"
  4013. loc, _ := time.LoadLocation("Local")
  4014. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4015. birthUnix := birthdays.Unix()
  4016. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4017. if err != nil {
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4019. return
  4020. }
  4021. recordDateTime := theTime.Unix()
  4022. adminInfo := c.GetAdminUserInfo()
  4023. var patient service.Patients
  4024. if id == 0 {
  4025. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4026. } else {
  4027. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4028. }
  4029. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4030. if patientPrescription.ID == 0 {
  4031. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4032. }
  4033. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4034. if patient.ID == 0 {
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4036. return
  4037. }
  4038. if len(patient.IdCardNo) == 0 {
  4039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4040. return
  4041. }
  4042. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4043. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4044. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4045. //就诊结算未完成,不能进行二次挂号
  4046. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4047. if len(his) >= 1 {
  4048. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4049. if len(his) >= 1 && order.ID == 0 {
  4050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4051. return
  4052. }
  4053. }
  4054. //var register_log string
  4055. if config.IsOpen == 1 {
  4056. var res ResultTwo
  4057. var res10265 ResultTwo10265
  4058. var PsnNo string
  4059. var PsnCertType string
  4060. var Certno string
  4061. var PsnName string
  4062. var Gend string
  4063. var Naty string
  4064. var Brdy string
  4065. var Age float64
  4066. var infoStr string
  4067. var idetinfoStr string
  4068. var infocode int64
  4069. var verify_number string
  4070. fmt.Println(verify_number)
  4071. if miConfig.MdtrtareaAdmvs == "421300" {
  4072. psn_info, _ := service.GetPsnByPatientId(id)
  4073. PsnNo = psn_info.PsnNo
  4074. PsnCertType = psn_info.PsnCertType
  4075. Certno = psn_info.Certno
  4076. PsnName = psn_info.PsnName
  4077. Gend = psn_info.Gend
  4078. Naty = psn_info.Naty
  4079. Brdy = psn_info.Brdy
  4080. Age = psn_info.Age
  4081. infoStr = psn_info.Insuinfo
  4082. idetinfoStr = psn_info.Idetinfo
  4083. infocode = 0
  4084. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4085. psn_info, _ := service.GetPsnByPatientId(id)
  4086. PsnNo = psn_info.PsnNo
  4087. PsnCertType = psn_info.PsnCertType
  4088. Certno = psn_info.Certno
  4089. PsnName = psn_info.PsnName
  4090. Gend = psn_info.Gend
  4091. Naty = psn_info.Naty
  4092. Brdy = psn_info.Brdy
  4093. Age = psn_info.Age
  4094. infoStr = psn_info.Insuinfo
  4095. idetinfoStr = psn_info.Idetinfo
  4096. infocode = 0
  4097. verify_number = psn_info.VerifyNumber
  4098. } else {
  4099. var result string
  4100. var requestLog string
  4101. if miConfig.UserOrgId == 10138 {
  4102. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4103. } else {
  4104. 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)
  4105. }
  4106. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4107. if miConfig.Code == "H15049901371" {
  4108. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4109. utils.ErrorLog("解析失败:%v", err)
  4110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4111. return
  4112. }
  4113. res.ErrMsg = res10265.ErrMsg
  4114. res.Output = res10265.Output
  4115. res.InfRefmsgid = res10265.InfRefmsgid
  4116. } else {
  4117. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4118. utils.ErrorLog("解析失败:%v", err)
  4119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4120. return
  4121. }
  4122. }
  4123. PsnNo = res.Output.Baseinfo.PsnNo
  4124. PsnCertType = res.Output.Baseinfo.PsnCertType
  4125. Certno = res.Output.Baseinfo.Certno
  4126. PsnName = res.Output.Baseinfo.PsnName
  4127. Gend = res.Output.Baseinfo.Gend
  4128. Naty = res.Output.Baseinfo.Naty
  4129. Brdy = res.Output.Baseinfo.Brdy
  4130. Age = res.Output.Baseinfo.Age
  4131. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4132. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4133. infoStr = string(Iinfos)
  4134. idetinfoStr = string(Idetinfos)
  4135. if miConfig.Code == "H15049901371" {
  4136. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4137. } else {
  4138. infocode = res.Infcode
  4139. }
  4140. }
  4141. if infocode == 0 {
  4142. his := models.VMHisPatient{
  4143. Name: name,
  4144. Gender: gender,
  4145. Birthday: birthUnix,
  4146. MedicalTreatmentType: medical_care,
  4147. IdType: certificates,
  4148. IdCardNo: id_card,
  4149. BalanceAccountsType: settlementValue,
  4150. SocialType: social_type,
  4151. MedicalInsuranceNumber: medical_insurance_card,
  4152. RegisterType: register_type,
  4153. RegisterCost: registration_fee,
  4154. TreatmentCost: medical_expenses,
  4155. Status: 1,
  4156. Ctime: time.Now().Unix(),
  4157. Mtime: time.Now().Unix(),
  4158. PsnNo: PsnNo,
  4159. PsnCertType: PsnCertType,
  4160. Certno: Certno,
  4161. PsnName: PsnName,
  4162. Gend: Gend,
  4163. Naty: Naty,
  4164. Brdy: Brdy,
  4165. Age: Age,
  4166. Iinfo: infoStr,
  4167. Idetinfo: idetinfoStr,
  4168. PatientId: patient.ID,
  4169. RecordDate: theTime.Unix(),
  4170. UserOrgId: adminInfo.CurrentOrgId,
  4171. AdminUserId: admin_user_id,
  4172. IsReturn: 1,
  4173. IdCardType: id_card_type,
  4174. Doctor: doctor,
  4175. Departments: department,
  4176. }
  4177. timestamp := time.Now().Unix()
  4178. tempTime := time.Unix(timestamp, 0)
  4179. timeFormat := tempTime.Format("20060102150405")
  4180. chrgBchno := rand.Intn(100000) + 10000
  4181. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4182. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4183. department, _ := service.GetDepartMentDetail(department)
  4184. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4185. IdCardNo := ""
  4186. if id_card_type == 1 {
  4187. // IdCardNo = medical_insurance_card
  4188. IdCardNo = patient.IdCardNo
  4189. } else {
  4190. IdCardNo = patient.IdCardNo
  4191. }
  4192. var rf []*ResultFive
  4193. json.Unmarshal([]byte(his.Iinfo), &rf)
  4194. var insutypes []*ResultFive
  4195. var insutype string
  4196. var insuplc_admdvs_temp string
  4197. var is390 int = 0
  4198. var is310 int = 0
  4199. for _, item := range rf {
  4200. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4201. insutypes = append(insutypes, item)
  4202. }
  4203. }
  4204. if len(insutypes) == 1 {
  4205. insutype = insutypes[0].Insutype
  4206. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4207. } else {
  4208. for _, i := range insutypes {
  4209. if i.Insutype == "390" {
  4210. is390 = 1
  4211. }
  4212. if i.Insutype == "310" {
  4213. is310 = 1
  4214. }
  4215. }
  4216. }
  4217. if is390 == 1 {
  4218. insutype = "390"
  4219. }
  4220. if is310 == 1 {
  4221. insutype = "310"
  4222. }
  4223. if len(insutypes) == 0 {
  4224. insutype = "310"
  4225. }
  4226. if len(insutypes) == 2 {
  4227. insutype = med_type
  4228. }
  4229. if len(med_type) > 0 {
  4230. insutype = med_type
  4231. }
  4232. //for _, item := range rf {
  4233. // if item.Insutype == insutype {
  4234. // insuplc_admdvs = item.InsuplcAdmdvs
  4235. // }
  4236. //}
  4237. var infocode int64
  4238. var resThree ResultThree
  4239. var resThree10265 ResultThree10265
  4240. if len(insuplc_admdvs) == 0 {
  4241. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4242. } else {
  4243. insuplc_admdvs_temp = insuplc_admdvs
  4244. }
  4245. if miConfig.MdtrtareaAdmvs == "421300" {
  4246. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4247. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4248. "&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
  4249. resp, requestErr := http.Get(api)
  4250. if requestErr != nil {
  4251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. return
  4253. }
  4254. body, ioErr := ioutil.ReadAll(resp.Body)
  4255. if ioErr != nil {
  4256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4258. return
  4259. }
  4260. var respJSON map[string]interface{}
  4261. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4264. return
  4265. }
  4266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4267. result, _ := json.Marshal(respJSON)
  4268. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4269. utils.ErrorLog("解析失败:%v", err)
  4270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4271. return
  4272. }
  4273. infocode = resThree.Infcode
  4274. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4275. psn_info, _ := service.GetPsnByPatientId(id)
  4276. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4277. var cert_no string
  4278. if id_card_type == 3 {
  4279. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4280. cert_no = IdCardNo
  4281. } else {
  4282. bas := strings.Split(psn_info.CardInfo, "|")
  4283. cert_no = bas[2]
  4284. }
  4285. var api string
  4286. if miConfig.MdtrtareaAdmvs == "320921" {
  4287. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4288. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4289. "&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
  4290. } else {
  4291. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4292. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4293. "&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
  4294. }
  4295. resp, requestErr := http.Get(api)
  4296. if requestErr != nil {
  4297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4298. return
  4299. }
  4300. body, ioErr := ioutil.ReadAll(resp.Body)
  4301. if ioErr != nil {
  4302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4304. return
  4305. }
  4306. var respJSON map[string]interface{}
  4307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4310. return
  4311. }
  4312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4313. result, _ := json.Marshal(respJSON)
  4314. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4315. utils.ErrorLog("解析失败:%v", err)
  4316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4317. return
  4318. }
  4319. resThree.ErrMsg = resThree10265.ErrMsg
  4320. resThree.Output = resThree10265.Output
  4321. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4322. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4323. } else {
  4324. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4325. saveLog(result, requestLog, "2201A", "挂号")
  4326. if miConfig.Code == "H15049901371" {
  4327. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4328. utils.ErrorLog("解析失败:%v", err)
  4329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4330. return
  4331. }
  4332. resThree.ErrMsg = resThree10265.ErrMsg
  4333. resThree.Output = resThree10265.Output
  4334. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4335. } else {
  4336. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4337. utils.ErrorLog("解析失败:%v", err)
  4338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4339. return
  4340. }
  4341. }
  4342. if miConfig.Code == "H15049901371" {
  4343. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4344. } else {
  4345. infocode = resThree.Infcode
  4346. }
  4347. }
  4348. if infocode != 0 {
  4349. adminUser := c.GetAdminUserInfo()
  4350. errlog := &models.HisOrderError{
  4351. UserOrgId: adminUser.CurrentOrgId,
  4352. Ctime: time.Now().Unix(),
  4353. Mtime: time.Now().Unix(),
  4354. ErrMsg: resThree.ErrMsg,
  4355. Status: 1,
  4356. PatientId: id,
  4357. RecordTime: recordDateTime,
  4358. Stage: 2,
  4359. }
  4360. service.CreateErrMsgLog(errlog)
  4361. c.ServeSuccessJSON(map[string]interface{}{
  4362. "failed_code": -10,
  4363. "msg": resThree.ErrMsg,
  4364. })
  4365. return
  4366. }
  4367. his.Number = resThree.Output.Data.MdtrtID
  4368. his.PsnNo = resThree.Output.Data.PsnNo
  4369. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4370. his.IdCardNo = patient.IdCardNo
  4371. his.PhoneNumber = patient.Phone
  4372. his.UserOrgId = adminInfo.CurrentOrgId
  4373. his.Insutype = insutype
  4374. his.Ctime = time.Now().Unix()
  4375. his.Mtime = time.Now().Unix()
  4376. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4377. his.Status = 1
  4378. service.UpdateHisPatientStatus(&his)
  4379. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4380. c.ServeSuccessJSON(map[string]interface{}{
  4381. "his_info": his,
  4382. })
  4383. } else {
  4384. adminUser := c.GetAdminUserInfo()
  4385. errlog := &models.HisOrderError{
  4386. UserOrgId: adminUser.CurrentOrgId,
  4387. Ctime: time.Now().Unix(),
  4388. Mtime: time.Now().Unix(),
  4389. ErrMsg: res.ErrMsg,
  4390. Status: 1,
  4391. PatientId: id,
  4392. RecordTime: recordDateTime,
  4393. Stage: 1,
  4394. }
  4395. service.CreateErrMsgLog(errlog)
  4396. c.ServeSuccessJSON(map[string]interface{}{
  4397. "failed_code": -10,
  4398. "msg": res.ErrMsg,
  4399. })
  4400. return
  4401. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4402. }
  4403. }
  4404. }
  4405. //上传明细----预结算----确认订单
  4406. func (c *HisApiController) GetUploadInfo() {
  4407. id, _ := c.GetInt64("id")
  4408. record_time := c.GetString("record_time")
  4409. his_patient_id, _ := c.GetInt64("his_patient_id")
  4410. order_id, _ := c.GetInt64("order_id")
  4411. pay_way, _ := c.GetInt64("pay_way")
  4412. pay_price, _ := c.GetFloat("pay_price")
  4413. pay_card_no := c.GetString("pay_card_no")
  4414. discount_price, _ := c.GetFloat("discount_price")
  4415. preferential_price, _ := c.GetFloat("preferential_price")
  4416. reality_price, _ := c.GetFloat("reality_price")
  4417. found_price, _ := c.GetFloat("found_price")
  4418. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4419. private_price, _ := c.GetFloat("private_price")
  4420. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4421. admin_user_id, _ := c.GetInt64("admin_user_id")
  4422. fapiao_code := c.GetString("fapiao_code")
  4423. fapiao_number := c.GetString("fapiao_number")
  4424. diagnosis_id := c.GetString("diagnosis")
  4425. sick_type, _ := c.GetInt64("sick_type")
  4426. reg_type, _ := c.GetInt64("p_type")
  4427. begin_time := c.GetString("begin_time")
  4428. id_str := c.GetString("ids")
  4429. ids_arr := strings.Split(id_str, ",")
  4430. timeLayout := "2006-01-02"
  4431. loc, _ := time.LoadLocation("Local")
  4432. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4433. if err != nil {
  4434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4435. return
  4436. }
  4437. recordDateTime := theTime.Unix()
  4438. adminUser := c.GetAdminUserInfo()
  4439. var tempOrder models.HisOrder
  4440. tempOrder, _ = service.GetHisOrderByID(order_id)
  4441. var prescriptions []*models.HisPrescription
  4442. var start_time int64
  4443. var end_time int64
  4444. //if adminUser.CurrentOrgId == 10106{
  4445. // if len(fapiao_code) == 0{
  4446. // fapiao_code = "144072080589"
  4447. // }
  4448. // if len(fapiao_number) == 0{
  4449. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4450. // if order.ID == 0{
  4451. // fapiao_number = "00001520"
  4452. // }else{
  4453. // //fapiao_code = "00001520"
  4454. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4455. // var zero string
  4456. // if fpNumber >= 1000{
  4457. // zero = "0000" + strconv.Itoa(fpNumber)
  4458. // }else if fpNumber >= 10000{
  4459. // zero = "000" + strconv.Itoa(fpNumber)
  4460. // } else if fpNumber >= 100000{
  4461. // zero = "00" + strconv.Itoa(fpNumber)
  4462. // } else if fpNumber >= 1000000{
  4463. // zero = "0" + strconv.Itoa(fpNumber)
  4464. // }else {
  4465. // zero = strconv.Itoa(fpNumber)
  4466. // }
  4467. // fapiao_number = zero
  4468. // }
  4469. // }
  4470. //}
  4471. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4472. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4473. var patientPrescription models.HisPrescriptionInfo
  4474. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4475. if patientPrescription.ID == 0 {
  4476. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4477. }
  4478. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4479. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4480. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4481. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4482. var config []*models.HisXtDiagnoseConfig
  4483. for _, item := range diagnosis_ids {
  4484. id, _ := strconv.ParseInt(item, 10, 64)
  4485. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4486. config = append(config, &diagnosisConfig)
  4487. }
  4488. sickConfig, _ := service.FindSickById(sick_type)
  4489. //if tempOrder.ID == 0 {
  4490. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4491. //}
  4492. if tempOrder.ID == 0 {
  4493. var result string
  4494. var requestLog string
  4495. var res2 ResultSix
  4496. var ressix10265 ResultSix10265
  4497. if miConfig.MdtrtareaAdmvs == "421300" {
  4498. data := make(map[string]interface{})
  4499. client := &http.Client{}
  4500. data["psn_no"] = his.PsnNo
  4501. data["mdtrt_id"] = his.Number
  4502. data["doctor"] = roles.UserName
  4503. data["department"] = department.Name
  4504. data["org_name"] = miConfig.OrgName
  4505. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4506. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4507. data["fixmedins_code"] = miConfig.Code
  4508. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4509. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4510. data["secret_key"] = miConfig.SecretKey
  4511. data["sick_code"] = sickConfig.CountryCode
  4512. data["sick_name"] = sickConfig.ClassName
  4513. data["dept"] = strconv.FormatInt(department.ID, 10)
  4514. data["config"] = config
  4515. data["begin_time"] = begin_time
  4516. bytesData, _ := json.Marshal(data)
  4517. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4518. resp, _ := client.Do(req)
  4519. defer resp.Body.Close()
  4520. body, ioErr := ioutil.ReadAll(resp.Body)
  4521. if ioErr != nil {
  4522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4524. return
  4525. }
  4526. var respJSON map[string]interface{}
  4527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4533. userJSONBytes, _ := json.Marshal(respJSON)
  4534. fmt.Println("log")
  4535. fmt.Println(string(userJSONBytes))
  4536. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4537. utils.ErrorLog("解析失败:%v", err)
  4538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4539. return
  4540. }
  4541. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4542. //江苏地区国家医保医疗类别
  4543. //职工透析:医疗类别选特殊情况门诊9933
  4544. //居民血透门慢: 医疗类别选门诊慢病1402
  4545. //var med_type string
  4546. //if his.Insutype == "310" {
  4547. // if reg_type == 14 {
  4548. // med_type = "9933"
  4549. // } else if reg_type == 11 {
  4550. // med_type = "11"
  4551. //
  4552. // }
  4553. //} else if his.Insutype == "390" {
  4554. // if reg_type == 14 {
  4555. // med_type = "1402"
  4556. // } else if reg_type == 11 {
  4557. // med_type = "11"
  4558. // }
  4559. //}
  4560. data := make(map[string]interface{})
  4561. client := &http.Client{}
  4562. data["psn_no"] = his.PsnNo
  4563. data["mdtrt_id"] = his.Number
  4564. data["doctor"] = roles.UserName
  4565. data["department"] = department.Name
  4566. data["org_name"] = miConfig.OrgName
  4567. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4568. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4569. data["fixmedins_code"] = miConfig.Code
  4570. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4571. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4572. data["secret_key"] = miConfig.SecretKey
  4573. data["sick_code"] = sickConfig.CountryCode
  4574. data["sick_name"] = sickConfig.ClassName
  4575. data["url"] = miConfig.Url
  4576. data["ak"] = miConfig.AccessKey
  4577. data["begin_time"] = begin_time
  4578. data["cainfo"] = miConfig.Cainfo
  4579. data["dept"] = strconv.FormatInt(department.ID, 10)
  4580. data["config"] = config
  4581. bytesData, _ := json.Marshal(data)
  4582. var req *http.Request
  4583. if miConfig.MdtrtareaAdmvs == "320921" {
  4584. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4585. //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 +
  4586. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4587. } else {
  4588. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4589. }
  4590. resp, _ := client.Do(req)
  4591. defer resp.Body.Close()
  4592. body, ioErr := ioutil.ReadAll(resp.Body)
  4593. if ioErr != nil {
  4594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4596. return
  4597. }
  4598. var respJSON map[string]interface{}
  4599. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4602. return
  4603. }
  4604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4605. userJSONBytes, _ := json.Marshal(respJSON)
  4606. fmt.Println("log")
  4607. fmt.Println(string(userJSONBytes))
  4608. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4609. utils.ErrorLog("解析失败:%v", err)
  4610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4611. return
  4612. }
  4613. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4614. res2.Output = ressix10265.Output
  4615. res2.ErrMsg = ressix10265.ErrMsg
  4616. res2.Cainfo = ressix10265.Cainfo
  4617. res2.WarnMsg = ressix10265.WarnMsg
  4618. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4619. res2.Infcode = infocode
  4620. } else {
  4621. if miConfig.MdtrtareaAdmvs == "440781" { //
  4622. 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)
  4623. } else {
  4624. if miConfig.Code == "H15049901371" {
  4625. //赤峰地区国家医保医疗类别
  4626. //职工透析:医疗类别选特殊情况门诊990502
  4627. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4628. var med_type string
  4629. if his.Insutype == "390" {
  4630. if reg_type == 14 {
  4631. med_type = "9933"
  4632. } else if reg_type == 11 {
  4633. med_type = "11"
  4634. }
  4635. } else if his.Insutype == "310" {
  4636. if reg_type == 14 {
  4637. med_type = "990502"
  4638. } else if reg_type == 11 {
  4639. med_type = "11"
  4640. }
  4641. }
  4642. 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)
  4643. } else {
  4644. 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)
  4645. }
  4646. }
  4647. saveLog(result, requestLog, "2203", "上传就诊信息")
  4648. var respJSON2 map[string]interface{}
  4649. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4652. return
  4653. }
  4654. userJSONBytes2, _ := json.Marshal(respJSON2)
  4655. if miConfig.Code == "H15049901371" {
  4656. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4657. utils.ErrorLog("解析失败:%v", err)
  4658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4659. return
  4660. }
  4661. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4662. res2.Output = ressix10265.Output
  4663. res2.ErrMsg = ressix10265.ErrMsg
  4664. res2.Cainfo = ressix10265.Cainfo
  4665. res2.WarnMsg = ressix10265.WarnMsg
  4666. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4667. res2.Infcode = infocode
  4668. } else {
  4669. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4670. utils.ErrorLog("解析失败:%v", err)
  4671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4672. return
  4673. }
  4674. }
  4675. }
  4676. if res2.Infcode != 0 {
  4677. adminUser := c.GetAdminUserInfo()
  4678. errlog := &models.HisOrderError{
  4679. UserOrgId: adminUser.CurrentOrgId,
  4680. Ctime: time.Now().Unix(),
  4681. Mtime: time.Now().Unix(),
  4682. ErrMsg: res2.ErrMsg,
  4683. Status: 1,
  4684. PatientId: id,
  4685. RecordTime: recordDateTime,
  4686. Stage: 3,
  4687. }
  4688. service.CreateErrMsgLog(errlog)
  4689. c.ServeSuccessJSON(map[string]interface{}{
  4690. "failed_code": -10,
  4691. "msg": res2.ErrMsg,
  4692. })
  4693. return
  4694. } else {
  4695. his.Diagnosis = diagnosis_id
  4696. his.SickType = sickConfig.ID
  4697. //var p_type int64
  4698. //if reg_type == 1111 || reg_type == 1112 {
  4699. // p_type = 11
  4700. //
  4701. //}
  4702. his.PType = fmt.Sprintf("%d", reg_type)
  4703. service.UpdateHisPatientThree(&his)
  4704. data := make(map[string]interface{})
  4705. if settle_accounts_type == 1 { //日结
  4706. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4707. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4708. } else {
  4709. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4710. }
  4711. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4712. data["pre"] = prescriptions
  4713. } else { //月结
  4714. start_time_str := c.GetString("start_time")
  4715. end_time_str := c.GetString("end_time")
  4716. timeLayout := "2006-01-02"
  4717. loc, _ := time.LoadLocation("Local")
  4718. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4719. if err != nil {
  4720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4721. return
  4722. }
  4723. recordStartTime := theStartTime.Unix()
  4724. start_time = recordStartTime
  4725. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4726. if err != nil {
  4727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4728. return
  4729. }
  4730. recordEndTime := theEndTime.Unix()
  4731. end_time = recordEndTime
  4732. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4733. data["pre"] = prescriptions
  4734. }
  4735. timestamp := time.Now().Unix()
  4736. tempTime := time.Unix(timestamp, 0)
  4737. timeFormat := tempTime.Format("20060102150405")
  4738. chrgBchno := rand.Intn(100000) + 10000
  4739. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4740. strconv.FormatInt(his.PatientId, 10)
  4741. client := &http.Client{}
  4742. data["psn_no"] = his.PsnNo
  4743. data["mdtrt_id"] = his.Number
  4744. data["chrg_bchno"] = chrg_bchno
  4745. data["org_name"] = miConfig.OrgName
  4746. data["doctor"] = roles.UserName
  4747. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4748. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4749. data["fixmedins_code"] = miConfig.Code
  4750. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4751. // data["dept_code"] = "15"
  4752. //} else {
  4753. data["dept_code"] = department.Number
  4754. //}
  4755. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4756. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4757. data["secret_key"] = miConfig.SecretKey
  4758. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4759. data["url"] = miConfig.Url
  4760. data["ak"] = miConfig.AccessKey
  4761. data["new_doctor_name"] = patientPrescription.Doctor
  4762. data["diag_code"] = sickConfig.CountryCode
  4763. data["cainfo"] = miConfig.Cainfo
  4764. var ids []int64
  4765. for _, item := range prescriptions {
  4766. ids = append(ids, item.ID)
  4767. }
  4768. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4769. if config.IsOpen == 1 { //对接了医保,走医保流程
  4770. var res ResultFour
  4771. var resFour10265 ResultFour10265
  4772. if miConfig.MdtrtareaAdmvs == "421300" {
  4773. bytesData, _ := json.Marshal(data)
  4774. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4775. resp, _ := client.Do(req)
  4776. defer resp.Body.Close()
  4777. body, ioErr := ioutil.ReadAll(resp.Body)
  4778. if ioErr != nil {
  4779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. var respJSON map[string]interface{}
  4784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4787. return
  4788. }
  4789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4790. userJSONBytes, _ := json.Marshal(respJSON)
  4791. fmt.Println("log")
  4792. fmt.Println(string(userJSONBytes))
  4793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4794. utils.ErrorLog("解析失败:%v", err)
  4795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4796. return
  4797. }
  4798. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4799. bytesData, _ := json.Marshal(data)
  4800. var req *http.Request
  4801. if miConfig.MdtrtareaAdmvs == "320921" {
  4802. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4803. } else {
  4804. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4805. }
  4806. resp, _ := client.Do(req)
  4807. defer resp.Body.Close()
  4808. body, ioErr := ioutil.ReadAll(resp.Body)
  4809. if ioErr != nil {
  4810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4812. return
  4813. }
  4814. var respJSON map[string]interface{}
  4815. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4821. userJSONBytes, _ := json.Marshal(respJSON)
  4822. fmt.Println("log")
  4823. fmt.Println(string(userJSONBytes))
  4824. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4825. utils.ErrorLog("解析失败:%v", err)
  4826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4827. return
  4828. }
  4829. res.InfRefmsgid = resFour10265.InfRefmsgid
  4830. res.Output = resFour10265.Output
  4831. res.ErrMsg = resFour10265.ErrMsg
  4832. res.Cainfo = resFour10265.Cainfo
  4833. res.WarnMsg = resFour10265.WarnMsg
  4834. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4835. res.Infcode = infocode
  4836. } else {
  4837. if miConfig.Code == "H15049901371" {
  4838. 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)
  4839. var dat map[string]interface{}
  4840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4841. fmt.Println(dat)
  4842. } else {
  4843. fmt.Println(err)
  4844. }
  4845. saveLog(result, request_log, "2204", "上传费用明细")
  4846. userJSONBytes, _ := json.Marshal(dat)
  4847. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4848. utils.ErrorLog("解析失败:%v", err)
  4849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4850. return
  4851. }
  4852. res.InfRefmsgid = resFour10265.InfRefmsgid
  4853. res.Output = resFour10265.Output
  4854. res.ErrMsg = resFour10265.ErrMsg
  4855. res.Cainfo = resFour10265.Cainfo
  4856. res.WarnMsg = resFour10265.WarnMsg
  4857. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4858. res.Infcode = infocode
  4859. } else {
  4860. 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)
  4861. var dat map[string]interface{}
  4862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4863. fmt.Println(dat)
  4864. } else {
  4865. fmt.Println(err)
  4866. }
  4867. saveLog(result, request_log, "2204", "上传费用明细")
  4868. userJSONBytes, _ := json.Marshal(dat)
  4869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4870. utils.ErrorLog("解析失败:%v", err)
  4871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4872. return
  4873. }
  4874. }
  4875. }
  4876. if res.Infcode == 0 {
  4877. order := &models.HisOrder{
  4878. UserOrgId: adminUser.CurrentOrgId,
  4879. HisPatientId: his.ID,
  4880. PatientId: his.PatientId,
  4881. SettleAccountsDate: recordDateTime,
  4882. MdtrtId: his.Number,
  4883. PsnNo: his.PsnNo,
  4884. MedType: strconv.FormatInt(reg_type, 10),
  4885. Ctime: time.Now().Unix(),
  4886. Mtime: time.Now().Unix(),
  4887. Status: 1,
  4888. Number: chrg_bchno,
  4889. Infcode: res.Infcode,
  4890. WarnMsg: res.WarnMsg,
  4891. Cainfo: res.Cainfo,
  4892. ErrMsg: res.ErrMsg,
  4893. RespondTime: res.RefmsgTime,
  4894. InfRefmsgid: res.InfRefmsgid,
  4895. OrderStatus: 1,
  4896. PayWay: pay_way,
  4897. PayPrice: pay_price,
  4898. PayCardNo: pay_card_no,
  4899. DiscountPrice: discount_price,
  4900. PreferentialPrice: preferential_price,
  4901. RealityPrice: reality_price,
  4902. FoundPrice: found_price,
  4903. MedicalInsurancePrice: medical_insurance_price,
  4904. PrivatePrice: private_price,
  4905. IsMedicineInsurance: 1,
  4906. SettleType: settle_accounts_type,
  4907. SettleStartTime: start_time,
  4908. SettleEndTime: end_time,
  4909. Creator: roles.AdminUserId,
  4910. Modify: roles.AdminUserId,
  4911. FaPiaoNumber: fapiao_number,
  4912. FaPiaoCode: fapiao_code,
  4913. PType: 2,
  4914. Diagnosis: diagnosis_id,
  4915. }
  4916. err = service.CreateOrder(order)
  4917. if err != nil {
  4918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4919. return
  4920. }
  4921. for _, item := range res.Output.Result {
  4922. temp := strings.Split(item.FeedetlSn, "-")
  4923. var advice_id int64 = 0
  4924. var project_id int64 = 0
  4925. var types int64 = 0
  4926. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4927. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4928. if temp[1] == "1" {
  4929. advice_id = id
  4930. project_id = 0
  4931. } else if temp[1] == "2" {
  4932. advice_id = 0
  4933. project_id = id
  4934. }
  4935. info := &models.HisOrderInfo{
  4936. OrderNumber: order.Number,
  4937. FeedetlSn: item.FeedetlSn,
  4938. UploadDate: time.Now().Unix(),
  4939. AdviceId: advice_id,
  4940. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4941. Cnt: item.Cnt,
  4942. Pric: float64(item.Pric),
  4943. PatientId: his.PatientId,
  4944. PricUplmtAmt: item.PricUplmtAmt,
  4945. SelfpayProp: item.SelfpayProp,
  4946. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4947. OverlmtAmt: item.OverlmtAmt,
  4948. PreselfpayAmt: item.PreselfpayAmt,
  4949. BasMednFlag: item.BasMednFlag,
  4950. MedChrgitmType: item.MedChrgitmType,
  4951. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4952. Status: 1,
  4953. Memo: item.Memo,
  4954. Mtime: time.Now().Unix(),
  4955. InscpScpAmt: item.InscpScpAmt,
  4956. DrtReimFlag: item.DrtReimFlag,
  4957. Ctime: time.Now().Unix(),
  4958. ListSpItemFlag: item.ListSpItemFlag,
  4959. ChldMedcFlag: item.ChldMedcFlag,
  4960. LmtUsedFlag: item.LmtUsedFlag,
  4961. ChrgitmLv: item.ChrgitmLv,
  4962. UserOrgId: adminUser.CurrentOrgId,
  4963. HisPatientId: his.ID,
  4964. OrderId: order.ID,
  4965. ProjectId: project_id,
  4966. Type: types,
  4967. }
  4968. service.CreateOrderInfo(info)
  4969. }
  4970. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4971. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4972. var total float64
  4973. for _, item := range prescriptions {
  4974. if item.Type == 1 { //药品
  4975. for _, subItem := range item.HisDoctorAdviceInfo {
  4976. total = total + (subItem.Price * subItem.PrescribingNumber)
  4977. }
  4978. }
  4979. if item.Type == 2 { //项目
  4980. for _, subItem := range item.HisPrescriptionProject {
  4981. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4982. total = total + (subItem.Price * cnt)
  4983. }
  4984. }
  4985. }
  4986. for _, item := range prescriptions {
  4987. for _, subItem := range item.HisAdditionalCharge {
  4988. total = total + (subItem.Price * float64(subItem.Count))
  4989. }
  4990. }
  4991. var allTotal string
  4992. if adminUser.CurrentOrgId == 9919 {
  4993. allTotal = fmt.Sprintf("%.4f", total)
  4994. } else {
  4995. allTotal = fmt.Sprintf("%.4f", total)
  4996. }
  4997. if res.Infcode == 0 {
  4998. var rf []*ResultFive
  4999. json.Unmarshal([]byte(his.Iinfo), &rf)
  5000. chrg_bchno := chrg_bchno
  5001. cert_no := his.Certno
  5002. var insutypes []string
  5003. var insutype string
  5004. var is390 int = 0
  5005. var is310 int = 0
  5006. for _, item := range rf {
  5007. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5008. insutypes = append(insutypes, item.Insutype)
  5009. }
  5010. }
  5011. if len(insutypes) == 1 {
  5012. insutype = insutypes[0]
  5013. } else {
  5014. for _, i := range insutypes {
  5015. if i == "390" {
  5016. is390 = 1
  5017. }
  5018. if i == "310" {
  5019. is310 = 1
  5020. }
  5021. }
  5022. }
  5023. if is390 == 1 {
  5024. insutype = "390"
  5025. }
  5026. if is310 == 1 {
  5027. insutype = "310"
  5028. }
  5029. if len(insutypes) == 0 {
  5030. insutype = "310"
  5031. }
  5032. if len(insutypes) == 2 {
  5033. insutype = strconv.FormatInt(his.SocialType, 10)
  5034. }
  5035. insutype = strconv.FormatInt(his.SocialType, 10)
  5036. //insutype = "390"
  5037. if his.IdCardType == 1 {
  5038. // cert_no = his.MedicalInsuranceNumber
  5039. cert_no = his.Certno
  5040. } else {
  5041. cert_no = his.Certno
  5042. }
  5043. var res ResultSeven
  5044. var resSeven10265 ResultSeven10265
  5045. var src_resquest string
  5046. var result2 string
  5047. var acct_used_flag string
  5048. fmt.Println("pay_way")
  5049. fmt.Println(pay_way)
  5050. fmt.Println("pay_way")
  5051. if pay_way == 4 {
  5052. acct_used_flag = "1"
  5053. } else {
  5054. acct_used_flag = "0"
  5055. }
  5056. if miConfig.MdtrtareaAdmvs == "421300" {
  5057. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5058. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5059. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5060. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5061. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5062. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5063. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5064. resp, requestErr := http.Get(api)
  5065. if requestErr != nil {
  5066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5067. return
  5068. }
  5069. body, ioErr := ioutil.ReadAll(resp.Body)
  5070. if ioErr != nil {
  5071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5073. return
  5074. }
  5075. var respJSON map[string]interface{}
  5076. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5079. return
  5080. }
  5081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5082. result, _ := json.Marshal(respJSON)
  5083. if miConfig.Code == "H15049901371" {
  5084. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5085. utils.ErrorLog("解析失败:%v", err)
  5086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5087. return
  5088. }
  5089. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5090. res.Output = resSeven10265.Output
  5091. res.ErrMsg = resSeven10265.ErrMsg
  5092. res.Cainfo = resSeven10265.Cainfo
  5093. res.WarnMsg = resSeven10265.WarnMsg
  5094. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5095. res.Infcode = infocode
  5096. } else {
  5097. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5098. utils.ErrorLog("解析失败:%v", err)
  5099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5100. return
  5101. }
  5102. }
  5103. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5104. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5105. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5106. //psn_info, _ := service.GetPsnByPatientId(id)
  5107. bas := strings.Split(psn_info.CardInfo, "|")
  5108. if his.IdCardType == 1 {
  5109. cert_no = bas[2]
  5110. } else if his.IdCardType == 3 {
  5111. cert_no = his.Certno
  5112. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5113. } else {
  5114. cert_no = bas[1]
  5115. }
  5116. //江苏地区国家医保医疗类别
  5117. //职工透析:医疗类别选特殊情况门诊9933
  5118. //居民血透门慢: 医疗类别选门诊慢病1402
  5119. //var med_type string
  5120. //if his.Insutype == "310" {
  5121. // if reg_type == 14 {
  5122. // med_type = "9933"
  5123. // } else if reg_type == 11 {
  5124. // med_type = "11"
  5125. //
  5126. // }
  5127. //} else if his.Insutype == "390" {
  5128. // if reg_type == 14 {
  5129. // med_type = "1402"
  5130. // } else if reg_type == 11 {
  5131. // med_type = "11"
  5132. // }
  5133. //}
  5134. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5135. var api string
  5136. if miConfig.MdtrtareaAdmvs == "320921" {
  5137. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5138. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5139. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5140. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5141. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5142. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5143. "&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
  5144. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5145. } else {
  5146. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5147. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5148. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5149. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5150. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5151. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5152. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5153. "&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
  5154. }
  5155. resp, requestErr := http.Get(api)
  5156. if requestErr != nil {
  5157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5158. return
  5159. }
  5160. body, ioErr := ioutil.ReadAll(resp.Body)
  5161. if ioErr != nil {
  5162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5164. return
  5165. }
  5166. var respJSON map[string]interface{}
  5167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5173. result, _ := json.Marshal(respJSON)
  5174. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5175. utils.ErrorLog("解析失败:%v", err)
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5177. return
  5178. }
  5179. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5180. res.Output = resSeven10265.Output
  5181. res.ErrMsg = resSeven10265.ErrMsg
  5182. res.Cainfo = resSeven10265.Cainfo
  5183. res.WarnMsg = resSeven10265.WarnMsg
  5184. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5185. res.Infcode = infocode
  5186. } else {
  5187. if miConfig.Code == "H15049901371" {
  5188. //赤峰地区国家医保医疗类别
  5189. //职工透析:医疗类别选特殊情况门诊990502
  5190. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5191. var med_type string
  5192. if his.Insutype == "390" {
  5193. if reg_type == 14 {
  5194. med_type = "9933"
  5195. } else if reg_type == 11 {
  5196. med_type = "11"
  5197. }
  5198. } else if his.Insutype == "310" {
  5199. if reg_type == 14 {
  5200. med_type = "990502"
  5201. } else if reg_type == 11 {
  5202. med_type = "11"
  5203. }
  5204. }
  5205. 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)
  5206. } else {
  5207. 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)
  5208. }
  5209. //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)
  5210. var dat map[string]interface{}
  5211. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5212. fmt.Println(dat)
  5213. } else {
  5214. fmt.Println(err)
  5215. }
  5216. saveLog(result2, src_resquest, "2207", "结算")
  5217. userJSONBytes, _ := json.Marshal(dat)
  5218. if miConfig.Code == "H15049901371" {
  5219. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5220. utils.ErrorLog("解析失败:%v", err)
  5221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5222. return
  5223. }
  5224. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5225. res.Output = resSeven10265.Output
  5226. res.ErrMsg = resSeven10265.ErrMsg
  5227. res.Cainfo = resSeven10265.Cainfo
  5228. res.WarnMsg = resSeven10265.WarnMsg
  5229. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5230. res.Infcode = infocode
  5231. } else {
  5232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5233. utils.ErrorLog("解析失败:%v", err)
  5234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5235. return
  5236. }
  5237. }
  5238. }
  5239. if res.Infcode != 0 {
  5240. errlog := &models.HisOrderError{
  5241. UserOrgId: adminUser.CurrentOrgId,
  5242. Ctime: time.Now().Unix(),
  5243. Mtime: time.Now().Unix(),
  5244. Number: chrg_bchno,
  5245. ErrMsg: res.ErrMsg,
  5246. Status: 1,
  5247. PatientId: id,
  5248. RecordTime: recordDateTime,
  5249. Stage: 6,
  5250. }
  5251. service.CreateErrMsgLog(errlog)
  5252. c.ServeSuccessJSON(map[string]interface{}{
  5253. "failed_code": -10,
  5254. "msg": res.ErrMsg,
  5255. })
  5256. return
  5257. } else {
  5258. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5259. order.OrderStatus = 2
  5260. order.Status = 1
  5261. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5262. order.SetlId = res.Output.Setlinfo.SetlID
  5263. order.PsnNo = res.Output.Setlinfo.PsnNo
  5264. order.PsnName = res.Output.Setlinfo.PsnName
  5265. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5266. order.Certno = res.Output.Setlinfo.Certno
  5267. order.Gend = res.Output.Setlinfo.Gend
  5268. order.Naty = res.Output.Setlinfo.Naty
  5269. order.Age = res.Output.Setlinfo.Age
  5270. order.Insutype = res.Output.Setlinfo.Insutype
  5271. order.PsnType = res.Output.Setlinfo.PsnType
  5272. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5273. order.SetlTime = res.Output.Setlinfo.SetlTime
  5274. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5275. if res.Output.Setlinfo.MedType == "140101" {
  5276. order.MedType = "14"
  5277. } else {
  5278. order.MedType = res.Output.Setlinfo.MedType
  5279. }
  5280. if reg_type == 1112 {
  5281. order.MedType = "1112"
  5282. }
  5283. if reg_type == 1111 {
  5284. order.MedType = "1111"
  5285. }
  5286. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5287. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5288. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5289. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5290. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5291. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5292. order.HifpPay = res.Output.Setlinfo.HifpPay
  5293. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5294. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5295. order.HifesPay = res.Output.Setlinfo.HifesPay
  5296. order.HifobPay = res.Output.Setlinfo.HifobPay
  5297. order.MafPay = res.Output.Setlinfo.MafPay
  5298. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5299. order.OthPay = res.Output.Setlinfo.OthPay
  5300. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5301. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5302. order.AcctPay = res.Output.Setlinfo.AcctPay
  5303. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5304. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5305. order.Balc = res.Output.Setlinfo.Balc
  5306. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5307. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5308. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5309. order.ClrType = res.Output.Setlinfo.ClrType
  5310. order.ClrWay = res.Output.Setlinfo.ClrWay
  5311. order.Creator = order.Creator
  5312. order.Modify = roles.AdminUserId
  5313. order.RequestLog = src_resquest
  5314. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5315. detailStr := string(setlDetail)
  5316. order.SetlDetail = detailStr
  5317. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5318. err = service.UpDateOrder(order)
  5319. if err == nil {
  5320. c.ServeSuccessJSON(map[string]interface{}{
  5321. "msg": "结算成功",
  5322. })
  5323. } else {
  5324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5325. return
  5326. }
  5327. }
  5328. } else {
  5329. adminUser := c.GetAdminUserInfo()
  5330. errlog := &models.HisOrderError{
  5331. UserOrgId: adminUser.CurrentOrgId,
  5332. Ctime: time.Now().Unix(),
  5333. Mtime: time.Now().Unix(),
  5334. ErrMsg: res.ErrMsg,
  5335. Status: 1,
  5336. PatientId: id,
  5337. RecordTime: recordDateTime,
  5338. Stage: 4,
  5339. }
  5340. service.CreateErrMsgLog(errlog)
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5342. return
  5343. }
  5344. } else {
  5345. adminUser := c.GetAdminUserInfo()
  5346. errlog := &models.HisOrderError{
  5347. UserOrgId: adminUser.CurrentOrgId,
  5348. Ctime: time.Now().Unix(),
  5349. Mtime: time.Now().Unix(),
  5350. ErrMsg: res.ErrMsg,
  5351. Status: 1,
  5352. PatientId: id,
  5353. RecordTime: recordDateTime,
  5354. Stage: 4,
  5355. }
  5356. service.CreateErrMsgLog(errlog)
  5357. c.ServeSuccessJSON(map[string]interface{}{
  5358. "failed_code": -10,
  5359. "msg": res.ErrMsg,
  5360. })
  5361. return
  5362. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5363. //return
  5364. }
  5365. }
  5366. }
  5367. } else if tempOrder.ID > 0 {
  5368. if tempOrder.IsPre == 1 {
  5369. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5370. var rf []*ResultFive
  5371. json.Unmarshal([]byte(his.Iinfo), &rf)
  5372. chrg_bchno := tempOrder.Number
  5373. cert_no := his.Certno
  5374. var insutypes []string
  5375. var insutype string
  5376. var is390 int = 0
  5377. var is310 int = 0
  5378. for _, item := range rf {
  5379. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5380. insutypes = append(insutypes, item.Insutype)
  5381. }
  5382. }
  5383. if len(insutypes) == 1 {
  5384. insutype = insutypes[0]
  5385. } else {
  5386. for _, i := range insutypes {
  5387. if i == "390" {
  5388. is390 = 1
  5389. }
  5390. if i == "310" {
  5391. is310 = 1
  5392. }
  5393. }
  5394. }
  5395. if is390 == 1 {
  5396. insutype = "390"
  5397. }
  5398. if is310 == 1 {
  5399. insutype = "310"
  5400. }
  5401. if len(insutypes) == 0 {
  5402. insutype = "310"
  5403. }
  5404. if len(insutypes) == 2 {
  5405. insutype = strconv.FormatInt(his.SocialType, 64)
  5406. }
  5407. //insutype = "390"
  5408. if his.IdCardType == 1 {
  5409. // cert_no = his.MedicalInsuranceNumber
  5410. cert_no = his.Certno
  5411. } else {
  5412. cert_no = his.Certno
  5413. }
  5414. var res ResultSeven
  5415. var resSeven10265 ResultSeven10265
  5416. var src_resquest string
  5417. var result2 string
  5418. var acct_used_flag string
  5419. fmt.Println("pay_way")
  5420. fmt.Println(pay_way)
  5421. fmt.Println("pay_way")
  5422. if pay_way == 4 {
  5423. acct_used_flag = "1"
  5424. } else {
  5425. acct_used_flag = "0"
  5426. }
  5427. if miConfig.MdtrtareaAdmvs == "421300" {
  5428. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5429. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5430. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5432. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5433. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5434. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5435. resp, requestErr := http.Get(api)
  5436. if requestErr != nil {
  5437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5438. return
  5439. }
  5440. body, ioErr := ioutil.ReadAll(resp.Body)
  5441. if ioErr != nil {
  5442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5444. return
  5445. }
  5446. var respJSON map[string]interface{}
  5447. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5450. return
  5451. }
  5452. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5453. result, _ := json.Marshal(respJSON)
  5454. fmt.Println("log")
  5455. fmt.Println(string(result))
  5456. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5457. utils.ErrorLog("解析失败:%v", err)
  5458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5459. return
  5460. }
  5461. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5462. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5463. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5464. //psn_info, _ := service.GetPsnByPatientId(id)
  5465. bas := strings.Split(psn_info.CardInfo, "|")
  5466. if his.IdCardType == 1 {
  5467. cert_no = bas[2]
  5468. } else {
  5469. cert_no = bas[1]
  5470. }
  5471. //江苏地区国家医保医疗类别
  5472. //职工透析:医疗类别选特殊情况门诊9933
  5473. //居民血透门慢: 医疗类别选门诊慢病1402
  5474. //var med_type string
  5475. //if his.Insutype == "310" {
  5476. // if reg_type == 14 {
  5477. // med_type = "9933"
  5478. // } else if reg_type == 11 {
  5479. // med_type = "11"
  5480. //
  5481. // }
  5482. //} else if his.Insutype == "390" {
  5483. // if reg_type == 14 {
  5484. // med_type = "1402"
  5485. // } else if reg_type == 11 {
  5486. // med_type = "11"
  5487. // }
  5488. //}
  5489. var api string
  5490. if miConfig.MdtrtareaAdmvs == "320921" {
  5491. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5492. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5493. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5495. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5496. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5497. "&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
  5498. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5499. } else {
  5500. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5501. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5507. "&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
  5508. }
  5509. resp, requestErr := http.Get(api)
  5510. if requestErr != nil {
  5511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5512. return
  5513. }
  5514. body, ioErr := ioutil.ReadAll(resp.Body)
  5515. if ioErr != nil {
  5516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5518. return
  5519. }
  5520. var respJSON map[string]interface{}
  5521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5527. result, _ := json.Marshal(respJSON)
  5528. fmt.Println("log")
  5529. fmt.Println(string(result))
  5530. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5531. utils.ErrorLog("解析失败:%v", err)
  5532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5533. return
  5534. }
  5535. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5536. res.Output = resSeven10265.Output
  5537. res.ErrMsg = resSeven10265.ErrMsg
  5538. res.Cainfo = resSeven10265.Cainfo
  5539. res.WarnMsg = resSeven10265.WarnMsg
  5540. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5541. res.Infcode = infocode
  5542. } else {
  5543. var src_resquest string
  5544. if miConfig.Code == "H15049901371" {
  5545. //赤峰地区国家医保医疗类别
  5546. //职工透析:医疗类别选特殊情况门诊990502
  5547. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5548. var med_type string
  5549. if his.Insutype == "390" {
  5550. if reg_type == 14 {
  5551. med_type = "9933"
  5552. } else if reg_type == 11 {
  5553. med_type = "11"
  5554. }
  5555. } else if his.Insutype == "310" {
  5556. if reg_type == 14 {
  5557. med_type = "990502"
  5558. } else if reg_type == 11 {
  5559. med_type = "11"
  5560. }
  5561. }
  5562. 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)
  5563. } else {
  5564. 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)
  5565. }
  5566. var dat map[string]interface{}
  5567. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5568. fmt.Println(dat)
  5569. } else {
  5570. fmt.Println(err)
  5571. }
  5572. saveLog(result2, src_resquest, "2207", "结算")
  5573. userJSONBytes, _ := json.Marshal(dat)
  5574. if miConfig.Code == "H15049901371" {
  5575. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5576. utils.ErrorLog("解析失败:%v", err)
  5577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5578. return
  5579. }
  5580. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5581. res.Output = resSeven10265.Output
  5582. res.ErrMsg = resSeven10265.ErrMsg
  5583. res.Cainfo = resSeven10265.Cainfo
  5584. res.WarnMsg = resSeven10265.WarnMsg
  5585. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5586. res.Infcode = infocode
  5587. } else {
  5588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5589. utils.ErrorLog("解析失败:%v", err)
  5590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5591. return
  5592. }
  5593. }
  5594. }
  5595. if res.Infcode != 0 {
  5596. errlog := &models.HisOrderError{
  5597. UserOrgId: adminUser.CurrentOrgId,
  5598. Ctime: time.Now().Unix(),
  5599. Mtime: time.Now().Unix(),
  5600. Number: chrg_bchno,
  5601. ErrMsg: res.ErrMsg,
  5602. Status: 1,
  5603. PatientId: id,
  5604. RecordTime: recordDateTime,
  5605. Stage: 6,
  5606. }
  5607. service.CreateErrMsgLog(errlog)
  5608. c.ServeSuccessJSON(map[string]interface{}{
  5609. "failed_code": -10,
  5610. "msg": res.ErrMsg,
  5611. })
  5612. return
  5613. } else {
  5614. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5615. order.OrderStatus = 2
  5616. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5617. order.SetlId = res.Output.Setlinfo.SetlID
  5618. order.PsnNo = res.Output.Setlinfo.PsnNo
  5619. order.PsnName = res.Output.Setlinfo.PsnName
  5620. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5621. order.Certno = res.Output.Setlinfo.Certno
  5622. order.Gend = res.Output.Setlinfo.Gend
  5623. order.Naty = res.Output.Setlinfo.Naty
  5624. order.Age = res.Output.Setlinfo.Age
  5625. order.Insutype = res.Output.Setlinfo.Insutype
  5626. order.PsnType = res.Output.Setlinfo.PsnType
  5627. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5628. order.SetlTime = res.Output.Setlinfo.SetlTime
  5629. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5630. //order.MedType = res.Output.Setlinfo.MedType
  5631. if reg_type == 1112 {
  5632. order.MedType = "1112"
  5633. }
  5634. if reg_type == 1111 {
  5635. order.MedType = "1111"
  5636. }
  5637. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5638. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5639. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5640. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5641. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5642. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5643. order.HifpPay = res.Output.Setlinfo.HifpPay
  5644. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5645. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5646. order.HifesPay = res.Output.Setlinfo.HifesPay
  5647. order.HifobPay = res.Output.Setlinfo.HifobPay
  5648. order.MafPay = res.Output.Setlinfo.MafPay
  5649. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5650. order.OthPay = res.Output.Setlinfo.OthPay
  5651. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5652. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5653. order.AcctPay = res.Output.Setlinfo.AcctPay
  5654. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5655. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5656. order.Balc = res.Output.Setlinfo.Balc
  5657. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5658. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5659. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5660. order.ClrWay = res.Output.Setlinfo.ClrWay
  5661. order.Creator = order.Creator
  5662. order.Modify = roles.AdminUserId
  5663. order.RequestLog = src_resquest
  5664. order.Diagnosis = diagnosis_id
  5665. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5666. detailStr := string(setlDetail)
  5667. order.SetlDetail = detailStr
  5668. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5669. err = service.UpDateOrder(order)
  5670. if err == nil {
  5671. c.ServeSuccessJSON(map[string]interface{}{
  5672. "msg": "结算成功",
  5673. })
  5674. } else {
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5676. return
  5677. }
  5678. }
  5679. }
  5680. }
  5681. }
  5682. //func (c *HisApiController) GetPreUploadInfo() {
  5683. // id, _ := c.GetInt64("id")
  5684. // record_time := c.GetString("record_time")
  5685. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5686. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5687. //
  5688. // timeLayout := "2006-01-02"
  5689. // loc, _ := time.LoadLocation("Local")
  5690. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5691. // if err != nil {
  5692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5693. // return
  5694. // }
  5695. // recordDateTime := theTime.Unix()
  5696. // adminUser := c.GetAdminUserInfo()
  5697. //
  5698. // var prescriptions []*models.HisPrescription
  5699. //
  5700. // var start_time int64
  5701. // var end_time int64
  5702. //
  5703. // data := make(map[string]interface{})
  5704. // if settle_accounts_type == 1 { //日结
  5705. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5706. // data["pre"] = prescriptions
  5707. //
  5708. // } else { //月结
  5709. // start_time_str := c.GetString("start_time")
  5710. // end_time_str := c.GetString("end_time")
  5711. // timeLayout := "2006-01-02"
  5712. // loc, _ := time.LoadLocation("Local")
  5713. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5714. // if err != nil {
  5715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5716. // return
  5717. // }
  5718. // recordStartTime := theStartTime.Unix()
  5719. // start_time = recordStartTime
  5720. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5721. // if err != nil {
  5722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5723. // return
  5724. // }
  5725. // recordEndTime := theEndTime.Unix()
  5726. // end_time = recordEndTime
  5727. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5728. // data["pre"] = prescriptions
  5729. //
  5730. // }
  5731. //
  5732. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5733. //
  5734. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5735. // timestamp := time.Now().Unix()
  5736. // tempTime := time.Unix(timestamp, 0)
  5737. // timeFormat := tempTime.Format("20060102150405")
  5738. // chrgBchno := rand.Intn(100000) + 10000
  5739. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5740. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5741. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5742. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5743. // strconv.FormatInt(his.PatientId, 10)
  5744. // client := &http.Client{}
  5745. // data["psn_no"] = his.PsnNo
  5746. // data["mdtrt_id"] = his.Number
  5747. // data["chrg_bchno"] = chrg_bchno
  5748. // data["org_name"] = miConfig.OrgName
  5749. // data["doctor"] = roles.UserName
  5750. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5751. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5752. // data["fixmedins_code"] = miConfig.Code
  5753. // data["dept_code"] = department.Number
  5754. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5755. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5756. // data["secret_key"] = miConfig.SecretKey
  5757. // var ids []int64
  5758. //
  5759. // for _, item := range prescriptions {
  5760. // ids = append(ids, item.ID)
  5761. // }
  5762. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5763. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5764. // bytesData, _ := json.Marshal(data)
  5765. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5766. // resp, _ := client.Do(req)
  5767. // defer resp.Body.Close()
  5768. // body, ioErr := ioutil.ReadAll(resp.Body)
  5769. // if ioErr != nil {
  5770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5772. // return
  5773. // }
  5774. // var respJSON map[string]interface{}
  5775. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5776. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5778. // return
  5779. // }
  5780. //
  5781. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5782. // userJSONBytes, _ := json.Marshal(respJSON)
  5783. // var res ResultFour
  5784. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5785. // utils.ErrorLog("解析失败:%v", err)
  5786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5787. // return
  5788. // }
  5789. //
  5790. // if res.Infcode == 0 {
  5791. // order := &models.HisOrder{
  5792. // UserOrgId: adminUser.CurrentOrgId,
  5793. // HisPatientId: his.ID,
  5794. // PatientId: his.PatientId,
  5795. // SettleAccountsDate: recordDateTime,
  5796. // Ctime: time.Now().Unix(),
  5797. // Mtime: time.Now().Unix(),
  5798. // Status: 1,
  5799. // Number: chrg_bchno,
  5800. // Infcode: res.Infcode,
  5801. // WarnMsg: res.WarnMsg,
  5802. // Cainfo: res.Cainfo,
  5803. // ErrMsg: res.ErrMsg,
  5804. // RespondTime: res.RefmsgTime,
  5805. // InfRefmsgid: res.InfRefmsgid,
  5806. // OrderStatus: 1,
  5807. // IsMedicineInsurance: 1,
  5808. // SettleType: settle_accounts_type,
  5809. // SettleStartTime: start_time,
  5810. // SettleEndTime: end_time,
  5811. // Creator: roles.ID,
  5812. // Modify: roles.ID,
  5813. // PType: 2,
  5814. // }
  5815. // err = service.CreateOrder(order)
  5816. // if err != nil {
  5817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5818. // return
  5819. // }
  5820. //
  5821. // for _, item := range res.Output.Result {
  5822. // temp := strings.Split(item.FeedetlSn, "-")
  5823. // var advice_id int64 = 0
  5824. // var project_id int64 = 0
  5825. // var types int64 = 0
  5826. //
  5827. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5828. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5829. //
  5830. // if temp[1] == "1" {
  5831. // advice_id = id
  5832. // project_id = 0
  5833. // } else if temp[1] == "2" {
  5834. // advice_id = 0
  5835. // project_id = id
  5836. // }
  5837. //
  5838. // info := &models.HisOrderInfo{
  5839. // OrderNumber: order.Number,
  5840. // FeedetlSn: item.FeedetlSn,
  5841. // UploadDate: time.Now().Unix(),
  5842. // AdviceId: advice_id,
  5843. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5844. // Cnt: item.Cnt,
  5845. // Pric: float64(item.Pric),
  5846. // PatientId: his.PatientId,
  5847. // PricUplmtAmt: item.PricUplmtAmt,
  5848. // SelfpayProp: item.SelfpayProp,
  5849. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5850. // OverlmtAmt: item.OverlmtAmt,
  5851. // PreselfpayAmt: item.PreselfpayAmt,
  5852. // BasMednFlag: item.BasMednFlag,
  5853. // MedChrgitmType: item.MedChrgitmType,
  5854. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5855. // Status: 1,
  5856. // Memo: item.Memo,
  5857. // Mtime: time.Now().Unix(),
  5858. // InscpScpAmt: item.InscpScpAmt,
  5859. // DrtReimFlag: item.DrtReimFlag,
  5860. // Ctime: time.Now().Unix(),
  5861. // ListSpItemFlag: item.ListSpItemFlag,
  5862. // ChldMedcFlag: item.ChldMedcFlag,
  5863. // LmtUsedFlag: item.LmtUsedFlag,
  5864. // ChrgitmLv: item.ChrgitmLv,
  5865. // UserOrgId: adminUser.CurrentOrgId,
  5866. // HisPatientId: his.ID,
  5867. // OrderId: order.ID,
  5868. // ProjectId: project_id,
  5869. // Type: types,
  5870. // }
  5871. // service.CreateOrderInfo(info)
  5872. //
  5873. // }
  5874. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5875. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5876. //
  5877. // var total float64
  5878. // for _, item := range prescriptions {
  5879. // if item.Type == 1 { //药品
  5880. // for _, subItem := range item.HisDoctorAdviceInfo {
  5881. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5882. // }
  5883. // }
  5884. // if item.Type == 2 { //项目
  5885. // for _, subItem := range item.HisPrescriptionProject {
  5886. // total = total + (subItem.Price * float64(subItem.Count))
  5887. // }
  5888. // }
  5889. // }
  5890. //
  5891. // for _, item := range prescriptions {
  5892. // for _, subItem := range item.HisAdditionalCharge {
  5893. // total = total + (subItem.Price * float64(subItem.Count))
  5894. // }
  5895. // }
  5896. //
  5897. // allTotal := fmt.Sprintf("%.2f", total)
  5898. // if res.Infcode == 0 {
  5899. // var rf []*ResultFive
  5900. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5901. // psn_no := his.PsnNo
  5902. // mdtrt_id := his.Number
  5903. // chrg_bchno := chrg_bchno
  5904. // cert_no := his.Certno
  5905. // insutype := rf[0].Insutype
  5906. //
  5907. // if his.IdCardType == 1 {
  5908. // cert_no = his.MedicalInsuranceNumber
  5909. //
  5910. // } else {
  5911. //
  5912. // cert_no = his.Certno
  5913. //
  5914. // }
  5915. //
  5916. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5917. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5918. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5919. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5920. // resp, requestErr := http.Get(api)
  5921. // if requestErr != nil {
  5922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. // return
  5924. // }
  5925. // defer resp.Body.Close()
  5926. // body, ioErr := ioutil.ReadAll(resp.Body)
  5927. // if ioErr != nil {
  5928. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5930. // return
  5931. // }
  5932. // var respJSON map[string]interface{}
  5933. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. // return
  5937. // }
  5938. // fmt.Println(respJSON)
  5939. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5940. // userJSONBytes, _ := json.Marshal(respJSON)
  5941. // var res ResultSeven
  5942. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5943. // utils.ErrorLog("解析失败:%v", err)
  5944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5945. // return
  5946. // }
  5947. // if res.Infcode != 0 {
  5948. // errlog := &models.HisOrderError{
  5949. // UserOrgId: adminUser.CurrentOrgId,
  5950. // Ctime: time.Now().Unix(),
  5951. // Mtime: time.Now().Unix(),
  5952. // Number: chrg_bchno,
  5953. // ErrMsg: res.ErrMsg,
  5954. // Status: 1,
  5955. // PatientId: id,
  5956. // RecordTime: recordDateTime,
  5957. // Stage: 7,
  5958. // }
  5959. // service.CreateErrMsgLog(errlog)
  5960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5961. // return
  5962. // } else {
  5963. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5964. // order.OrderStatus = 1
  5965. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5966. // order.SetlId = res.Output.Setlinfo.SetlID
  5967. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5968. // order.PsnName = res.Output.Setlinfo.PsnName
  5969. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5970. // order.Certno = res.Output.Setlinfo.Certno
  5971. // order.Gend = res.Output.Setlinfo.Gend
  5972. // order.Naty = res.Output.Setlinfo.Naty
  5973. // order.Age = res.Output.Setlinfo.Age
  5974. // order.Insutype = res.Output.Setlinfo.Insutype
  5975. // order.PsnType = res.Output.Setlinfo.PsnType
  5976. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5977. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5978. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5979. // order.MedType = res.Output.Setlinfo.MedType
  5980. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5981. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5982. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5983. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5984. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5985. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5986. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5987. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5988. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5989. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5990. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5991. // order.MafPay = res.Output.Setlinfo.MafPay
  5992. // order.OthPay = res.Output.Setlinfo.OthPay
  5993. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5994. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5995. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5996. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5997. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5998. // order.Balc = res.Output.Setlinfo.Balc
  5999. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6000. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6001. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6002. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6003. // order.Creator = order.Creator
  6004. // order.Modify = roles.ID
  6005. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6006. // detailStr := string(setlDetail)
  6007. // order.SetlDetail = detailStr
  6008. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6009. // err = service.UpDateOrder(order)
  6010. // if err == nil {
  6011. // c.ServeSuccessJSON(map[string]interface{}{
  6012. // "msg": "预结算成功",
  6013. // })
  6014. // } else {
  6015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6016. // return
  6017. // }
  6018. // }
  6019. // } else {
  6020. // adminUser := c.GetAdminUserInfo()
  6021. // errlog := &models.HisOrderError{
  6022. // UserOrgId: adminUser.CurrentOrgId,
  6023. // Ctime: time.Now().Unix(),
  6024. // Mtime: time.Now().Unix(),
  6025. // ErrMsg: res.ErrMsg,
  6026. // Status: 1,
  6027. // PatientId: id,
  6028. // RecordTime: recordDateTime,
  6029. // Stage: 4,
  6030. // }
  6031. // service.CreateErrMsgLog(errlog)
  6032. //
  6033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6034. // return
  6035. // }
  6036. // } else {
  6037. // adminUser := c.GetAdminUserInfo()
  6038. // errlog := &models.HisOrderError{
  6039. // UserOrgId: adminUser.CurrentOrgId,
  6040. // Ctime: time.Now().Unix(),
  6041. // Mtime: time.Now().Unix(),
  6042. // ErrMsg: res.ErrMsg,
  6043. // Status: 1,
  6044. // PatientId: id,
  6045. // RecordTime: recordDateTime,
  6046. // Stage: 4,
  6047. // }
  6048. // service.CreateErrMsgLog(errlog)
  6049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6050. // return
  6051. // }
  6052. //
  6053. // } else {
  6054. // var total float64
  6055. // for _, item := range prescriptions {
  6056. // if item.Type == 1 { //药品
  6057. // for _, subItem := range item.HisDoctorAdviceInfo {
  6058. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6059. // }
  6060. // }
  6061. // if item.Type == 2 { //项目
  6062. // for _, subItem := range item.HisPrescriptionProject {
  6063. // total = total + (subItem.Price * float64(subItem.Count))
  6064. // }
  6065. // }
  6066. //
  6067. // for _, subItem := range item.HisAdditionalCharge {
  6068. // total = total + (subItem.Price * float64(subItem.Count))
  6069. // }
  6070. // }
  6071. //
  6072. // allTotal := fmt.Sprintf("%.2f", total)
  6073. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6074. // order := &models.HisOrder{
  6075. // UserOrgId: adminUser.CurrentOrgId,
  6076. // HisPatientId: his.ID,
  6077. // PatientId: id,
  6078. // SettleAccountsDate: recordDateTime,
  6079. // Ctime: time.Now().Unix(),
  6080. // Mtime: time.Now().Unix(),
  6081. // Status: 1,
  6082. // OrderStatus: 2,
  6083. // Number: chrg_bchno,
  6084. // MedfeeSumamt: totals,
  6085. // }
  6086. // err = service.CreateOrder(order)
  6087. // if err != nil {
  6088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6089. // return
  6090. // }
  6091. //
  6092. // var customs []*Custom
  6093. // for _, item := range prescriptions {
  6094. //
  6095. // if item.Type == 1 { //药品
  6096. // for _, subItem := range item.HisDoctorAdviceInfo {
  6097. // cus := &Custom{
  6098. // AdviceId: subItem.ID,
  6099. // ProjectId: 0,
  6100. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6101. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6102. // FeedetlSn: subItem.FeedetlSn,
  6103. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6104. // MedListCodg: subItem.MedListCodg,
  6105. // Type: 1,
  6106. // }
  6107. // customs = append(customs, cus)
  6108. // }
  6109. // }
  6110. //
  6111. // if item.Type == 2 { //项目
  6112. // for _, subItem := range item.HisPrescriptionProject {
  6113. //
  6114. // cus := &Custom{
  6115. // AdviceId: 0,
  6116. // ProjectId: subItem.ID,
  6117. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6118. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6119. // FeedetlSn: subItem.FeedetlSn,
  6120. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6121. // MedListCodg: subItem.MedListCodg,
  6122. // Type: 2,
  6123. // }
  6124. //
  6125. // customs = append(customs, cus)
  6126. // }
  6127. // }
  6128. //
  6129. // for _, item := range item.HisAdditionalCharge {
  6130. // cus := &Custom{
  6131. // ItemId: item.ID,
  6132. // AdviceId: 0,
  6133. // ProjectId: 0,
  6134. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6135. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6136. // FeedetlSn: item.FeedetlSn,
  6137. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6138. // MedListCodg: item.XtHisAddtionConfig.Code,
  6139. // Type: 3,
  6140. // }
  6141. //
  6142. // customs = append(customs, cus)
  6143. // }
  6144. //
  6145. // }
  6146. //
  6147. // for _, item := range customs {
  6148. // var advice_id int64 = 0
  6149. // var project_id int64 = 0
  6150. // var item_id int64 = 0
  6151. //
  6152. // var types int64 = 0
  6153. //
  6154. // if item.Type == 1 {
  6155. // advice_id = item.AdviceId
  6156. // project_id = 0
  6157. // item_id = 0
  6158. // } else if item.Type == 2 {
  6159. // advice_id = 0
  6160. // item_id = 0
  6161. //
  6162. // project_id = item.ProjectId
  6163. // } else if item.Type == 3 {
  6164. // advice_id = 0
  6165. // item_id = item.ItemId
  6166. // project_id = 0
  6167. // }
  6168. //
  6169. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6170. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6171. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6172. //
  6173. // info := &models.HisOrderInfo{
  6174. // OrderNumber: order.Number,
  6175. // UploadDate: time.Now().Unix(),
  6176. // AdviceId: advice_id,
  6177. // DetItemFeeSumamt: detItemFeeSumamt,
  6178. // Cnt: cut,
  6179. // Pric: pric,
  6180. // PatientId: id,
  6181. // Status: 1,
  6182. // Mtime: time.Now().Unix(),
  6183. // Ctime: time.Now().Unix(),
  6184. // UserOrgId: adminUser.CurrentOrgId,
  6185. // HisPatientId: his.ID,
  6186. // OrderId: order.ID,
  6187. // ProjectId: project_id,
  6188. // Type: types,
  6189. // ItemId: item_id,
  6190. // }
  6191. // service.CreateOrderInfo(info)
  6192. // }
  6193. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6194. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6195. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6196. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6197. // if err == nil {
  6198. // c.ServeSuccessJSON(map[string]interface{}{
  6199. // "msg": "结算成功",
  6200. // })
  6201. // } else {
  6202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6203. // return
  6204. // }
  6205. // }
  6206. //}
  6207. //上传明细-预结算-
  6208. func (c *HisApiController) GetPreUploadInfo() {
  6209. id, _ := c.GetInt64("id")
  6210. record_time := c.GetString("record_time")
  6211. his_patient_id, _ := c.GetInt64("his_patient_id")
  6212. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6213. admin_user_id, _ := c.GetInt64("admin_user_id")
  6214. diagnosis_id := c.GetString("diagnosis")
  6215. sick_type, _ := c.GetInt64("sick_type")
  6216. reg_type, _ := c.GetInt64("p_type")
  6217. begin_time := c.GetString("begin_time")
  6218. id_str := c.GetString("ids")
  6219. ids_arr := strings.Split(id_str, ",")
  6220. timeLayout := "2006-01-02"
  6221. loc, _ := time.LoadLocation("Local")
  6222. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6223. if err != nil {
  6224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6225. return
  6226. }
  6227. recordDateTime := theTime.Unix()
  6228. adminUser := c.GetAdminUserInfo()
  6229. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6230. var config []*models.HisXtDiagnoseConfig
  6231. for _, item := range diagnosis_ids {
  6232. id, _ := strconv.ParseInt(item, 10, 64)
  6233. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6234. config = append(config, &diagnosisConfig)
  6235. }
  6236. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6237. sickConfig, _ := service.FindSickById(sick_type)
  6238. var prescriptions []*models.HisPrescription
  6239. var start_time int64
  6240. var end_time int64
  6241. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6242. fmt.Println(his_patient_id)
  6243. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6244. timestamp := time.Now().Unix()
  6245. tempTime := time.Unix(timestamp, 0)
  6246. timeFormat := tempTime.Format("20060102150405")
  6247. chrgBchno := rand.Intn(100000) + 10000
  6248. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6249. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6250. var patientPrescription models.HisPrescriptionInfo
  6251. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6252. if patientPrescription.ID == 0 {
  6253. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6254. }
  6255. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6256. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6257. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6258. strconv.FormatInt(his.PatientId, 10)
  6259. var res2 ResultSix
  6260. var resSix10265 ResultSix10265
  6261. var time_stamp string
  6262. if miConfig.MdtrtareaAdmvs == "421300" {
  6263. data := make(map[string]interface{})
  6264. client := &http.Client{}
  6265. data["psn_no"] = his.PsnNo
  6266. data["mdtrt_id"] = his.Number
  6267. data["doctor"] = roles.UserName
  6268. data["department"] = department.Name
  6269. data["org_name"] = miConfig.OrgName
  6270. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6271. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6272. data["fixmedins_code"] = miConfig.Code
  6273. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6274. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6275. data["secret_key"] = miConfig.SecretKey
  6276. data["sick_code"] = sickConfig.CountryCode
  6277. data["sick_name"] = sickConfig.ClassName
  6278. data["begin_time"] = begin_time
  6279. data["dept"] = strconv.FormatInt(department.ID, 10)
  6280. data["config"] = config
  6281. fmt.Println(data)
  6282. bytesData, _ := json.Marshal(data)
  6283. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6284. resp, _ := client.Do(req)
  6285. defer resp.Body.Close()
  6286. body, ioErr := ioutil.ReadAll(resp.Body)
  6287. if ioErr != nil {
  6288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6290. return
  6291. }
  6292. var respJSON map[string]interface{}
  6293. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6296. return
  6297. }
  6298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6299. userJSONBytes, _ := json.Marshal(respJSON)
  6300. fmt.Println("log")
  6301. fmt.Println(string(userJSONBytes))
  6302. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6303. utils.ErrorLog("解析失败:%v", err)
  6304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6305. return
  6306. }
  6307. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6308. //江苏地区国家医保医疗类别
  6309. //职工透析:医疗类别选特殊情况门诊9933
  6310. //居民血透门慢: 医疗类别选门诊慢病1402
  6311. //var med_type string
  6312. //if his.Insutype == "310" {
  6313. // if reg_type == 14 {
  6314. // med_type = "9933"
  6315. // } else if reg_type == 11 {
  6316. // med_type = "11"
  6317. //
  6318. // }
  6319. //} else if his.Insutype == "390" {
  6320. // if reg_type == 14 {
  6321. // med_type = "1402"
  6322. // } else if reg_type == 11 {
  6323. // med_type = "11"
  6324. // }
  6325. //}
  6326. data := make(map[string]interface{})
  6327. client := &http.Client{}
  6328. data["psn_no"] = his.PsnNo
  6329. data["mdtrt_id"] = his.Number
  6330. data["doctor"] = roles.UserName
  6331. data["department"] = department.Name
  6332. data["org_name"] = miConfig.OrgName
  6333. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6334. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6335. data["fixmedins_code"] = miConfig.Code
  6336. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6337. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6338. data["secret_key"] = miConfig.SecretKey
  6339. data["sick_code"] = sickConfig.CountryCode
  6340. data["sick_name"] = sickConfig.ClassName
  6341. data["begin_time"] = begin_time
  6342. data["dept"] = strconv.FormatInt(department.ID, 10)
  6343. data["config"] = config
  6344. data["url"] = miConfig.Url
  6345. data["ak"] = miConfig.AccessKey
  6346. data["cainfo"] = miConfig.Cainfo
  6347. bytesData, _ := json.Marshal(data)
  6348. var req *http.Request
  6349. if miConfig.MdtrtareaAdmvs == "320921" {
  6350. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6351. //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 +
  6352. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6353. } else {
  6354. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6355. }
  6356. resp, _ := client.Do(req)
  6357. defer resp.Body.Close()
  6358. body, ioErr := ioutil.ReadAll(resp.Body)
  6359. if ioErr != nil {
  6360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6362. return
  6363. }
  6364. var respJSON map[string]interface{}
  6365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6368. return
  6369. }
  6370. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6371. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6372. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6374. userJSONBytes, _ := json.Marshal(respJSON)
  6375. fmt.Println("log")
  6376. fmt.Println(string(userJSONBytes))
  6377. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6378. utils.ErrorLog("解析失败:%v", err)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. return
  6381. }
  6382. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6383. res2.Output = resSix10265.Output
  6384. res2.ErrMsg = resSix10265.ErrMsg
  6385. res2.Cainfo = resSix10265.Cainfo
  6386. res2.WarnMsg = resSix10265.WarnMsg
  6387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6388. res2.Infcode = infocode
  6389. } else {
  6390. var result string
  6391. var requestLog string
  6392. if miConfig.MdtrtareaAdmvs == "440781" { //
  6393. 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)
  6394. } else {
  6395. if miConfig.Code == "H15049901371" {
  6396. //赤峰地区国家医保医疗类别
  6397. //职工透析:医疗类别选特殊情况门诊990502
  6398. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6399. var med_type string
  6400. if his.Insutype == "390" {
  6401. if reg_type == 14 {
  6402. med_type = "9933"
  6403. } else if reg_type == 11 {
  6404. med_type = "11"
  6405. }
  6406. } else if his.Insutype == "310" {
  6407. if reg_type == 14 {
  6408. med_type = "990502"
  6409. } else if reg_type == 11 {
  6410. med_type = "11"
  6411. }
  6412. }
  6413. 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)
  6414. } else {
  6415. 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)
  6416. }
  6417. saveLog(result, requestLog, "2203", "上传就诊信息")
  6418. var respJSON2 map[string]interface{}
  6419. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6422. return
  6423. }
  6424. userJSONBytes2, _ := json.Marshal(respJSON2)
  6425. if miConfig.Code == "H15049901371" {
  6426. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6427. utils.ErrorLog("解析失败:%v", err)
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. return
  6430. }
  6431. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6432. res2.Output = resSix10265.Output
  6433. res2.ErrMsg = resSix10265.ErrMsg
  6434. res2.Cainfo = resSix10265.Cainfo
  6435. res2.WarnMsg = resSix10265.WarnMsg
  6436. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6437. res2.Infcode = infocode
  6438. } else {
  6439. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6440. utils.ErrorLog("解析失败:%v", err)
  6441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6442. return
  6443. }
  6444. }
  6445. }
  6446. }
  6447. if res2.Infcode != 0 {
  6448. adminUser := c.GetAdminUserInfo()
  6449. errlog := &models.HisOrderError{
  6450. UserOrgId: adminUser.CurrentOrgId,
  6451. Ctime: time.Now().Unix(),
  6452. Mtime: time.Now().Unix(),
  6453. ErrMsg: res2.ErrMsg,
  6454. Status: 1,
  6455. PatientId: id,
  6456. RecordTime: recordDateTime,
  6457. Stage: 3,
  6458. }
  6459. service.CreateErrMsgLog(errlog)
  6460. c.ServeSuccessJSON(map[string]interface{}{
  6461. "failed_code": -10,
  6462. "msg": res2.ErrMsg,
  6463. })
  6464. return
  6465. } else {
  6466. his.Diagnosis = diagnosis_id
  6467. his.SickType = sickConfig.ID
  6468. his.PType = fmt.Sprintf("%d", reg_type)
  6469. service.UpdateHisPatientThree(&his)
  6470. data := make(map[string]interface{})
  6471. if settle_accounts_type == 1 { //日结
  6472. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6473. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6474. } else {
  6475. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6476. }
  6477. data["pre"] = prescriptions
  6478. } else { //月结
  6479. start_time_str := c.GetString("start_time")
  6480. end_time_str := c.GetString("end_time")
  6481. timeLayout := "2006-01-02"
  6482. loc, _ := time.LoadLocation("Local")
  6483. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6484. if err != nil {
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6486. return
  6487. }
  6488. recordStartTime := theStartTime.Unix()
  6489. start_time = recordStartTime
  6490. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6491. if err != nil {
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6493. return
  6494. }
  6495. recordEndTime := theEndTime.Unix()
  6496. end_time = recordEndTime
  6497. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6498. data["pre"] = prescriptions
  6499. }
  6500. client := &http.Client{}
  6501. data["psn_no"] = his.PsnNo
  6502. data["mdtrt_id"] = his.Number
  6503. data["chrg_bchno"] = chrg_bchno
  6504. data["org_name"] = miConfig.OrgName
  6505. data["doctor"] = roles.UserName
  6506. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6507. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6508. data["fixmedins_code"] = miConfig.Code
  6509. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6510. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6511. data["dept_code"] = "15"
  6512. } else {
  6513. data["dept_code"] = department.Number
  6514. }
  6515. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6516. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6517. data["secret_key"] = miConfig.SecretKey
  6518. data["url"] = miConfig.Url
  6519. data["ak"] = miConfig.AccessKey
  6520. data["new_doctor_name"] = patientPrescription.Doctor
  6521. data["diag_code"] = sickConfig.CountryCode
  6522. data["time_stamp"] = time_stamp
  6523. data["cainfo"] = miConfig.Cainfo
  6524. var ids []int64
  6525. for _, item := range prescriptions {
  6526. ids = append(ids, item.ID)
  6527. }
  6528. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6529. if config.IsOpen == 1 { //对接了医保,走医保流程
  6530. var res ResultFour
  6531. var resFour10265 ResultFour10265
  6532. if miConfig.MdtrtareaAdmvs == "421300" {
  6533. bytesData, _ := json.Marshal(data)
  6534. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6535. resp, _ := client.Do(req)
  6536. defer resp.Body.Close()
  6537. body, ioErr := ioutil.ReadAll(resp.Body)
  6538. if ioErr != nil {
  6539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6541. return
  6542. }
  6543. var respJSON map[string]interface{}
  6544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6547. return
  6548. }
  6549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6550. userJSONBytes, _ := json.Marshal(respJSON)
  6551. fmt.Println("log")
  6552. fmt.Println(string(userJSONBytes))
  6553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6554. utils.ErrorLog("解析失败:%v", err)
  6555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. return
  6557. }
  6558. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6559. bytesData, _ := json.Marshal(data)
  6560. var req *http.Request
  6561. if miConfig.MdtrtareaAdmvs == "320921" {
  6562. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6563. } else {
  6564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6565. }
  6566. resp, _ := client.Do(req)
  6567. defer resp.Body.Close()
  6568. body, ioErr := ioutil.ReadAll(resp.Body)
  6569. if ioErr != nil {
  6570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. var respJSON map[string]interface{}
  6575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6578. return
  6579. }
  6580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6581. userJSONBytes, _ := json.Marshal(respJSON)
  6582. fmt.Println("log")
  6583. fmt.Println(string(userJSONBytes))
  6584. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6585. utils.ErrorLog("解析失败:%v", err)
  6586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6587. return
  6588. }
  6589. res.InfRefmsgid = resFour10265.InfRefmsgid
  6590. res.Output = resFour10265.Output
  6591. res.ErrMsg = resFour10265.ErrMsg
  6592. res.Cainfo = resFour10265.Cainfo
  6593. res.WarnMsg = resFour10265.WarnMsg
  6594. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6595. res.Infcode = infocode
  6596. } else {
  6597. if miConfig.Code == "H15049901371" {
  6598. 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)
  6599. var dat map[string]interface{}
  6600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6601. fmt.Println(dat)
  6602. } else {
  6603. fmt.Println(err)
  6604. }
  6605. saveLog(result, request_log, "2204", "上传费用明细")
  6606. userJSONBytes, _ := json.Marshal(dat)
  6607. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6608. utils.ErrorLog("解析失败:%v", err)
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6610. return
  6611. }
  6612. res.InfRefmsgid = resFour10265.InfRefmsgid
  6613. res.Output = resFour10265.Output
  6614. res.ErrMsg = resFour10265.ErrMsg
  6615. res.Cainfo = resFour10265.Cainfo
  6616. res.WarnMsg = resFour10265.WarnMsg
  6617. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6618. res.Infcode = infocode
  6619. } else {
  6620. 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)
  6621. var dat map[string]interface{}
  6622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6623. fmt.Println(dat)
  6624. } else {
  6625. fmt.Println(err)
  6626. }
  6627. saveLog(result, request_log, "2204", "上传费用明细")
  6628. userJSONBytes, _ := json.Marshal(dat)
  6629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6630. utils.ErrorLog("解析失败:%v", err)
  6631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6632. return
  6633. }
  6634. }
  6635. }
  6636. if res.Infcode == 0 {
  6637. order := &models.HisOrder{
  6638. UserOrgId: adminUser.CurrentOrgId,
  6639. HisPatientId: his.ID,
  6640. PatientId: his.PatientId,
  6641. SettleAccountsDate: recordDateTime,
  6642. Ctime: time.Now().Unix(),
  6643. Mtime: time.Now().Unix(),
  6644. MdtrtId: his.Number,
  6645. PsnNo: his.PsnNo,
  6646. MedType: strconv.FormatInt(reg_type, 10),
  6647. Status: 1,
  6648. Number: chrg_bchno,
  6649. Infcode: res.Infcode,
  6650. WarnMsg: res.WarnMsg,
  6651. Cainfo: res.Cainfo,
  6652. ErrMsg: res.ErrMsg,
  6653. RespondTime: res.RefmsgTime,
  6654. InfRefmsgid: res.InfRefmsgid,
  6655. OrderStatus: 1,
  6656. IsMedicineInsurance: 1,
  6657. SettleType: settle_accounts_type,
  6658. SettleStartTime: start_time,
  6659. SettleEndTime: end_time,
  6660. Creator: roles.AdminUserId,
  6661. Modify: roles.AdminUserId,
  6662. PType: 2,
  6663. Diagnosis: diagnosis_id,
  6664. }
  6665. err = service.CreateOrder(order)
  6666. if err != nil {
  6667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6668. return
  6669. }
  6670. for _, item := range res.Output.Result {
  6671. temp := strings.Split(item.FeedetlSn, "-")
  6672. var advice_id int64 = 0
  6673. var project_id int64 = 0
  6674. var types int64 = 0
  6675. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6676. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6677. if temp[1] == "1" {
  6678. advice_id = id
  6679. project_id = 0
  6680. } else if temp[1] == "2" {
  6681. advice_id = 0
  6682. project_id = id
  6683. }
  6684. info := &models.HisOrderInfo{
  6685. OrderNumber: order.Number,
  6686. FeedetlSn: item.FeedetlSn,
  6687. UploadDate: time.Now().Unix(),
  6688. AdviceId: advice_id,
  6689. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6690. Cnt: item.Cnt,
  6691. Pric: float64(item.Pric),
  6692. PatientId: his.PatientId,
  6693. PricUplmtAmt: item.PricUplmtAmt,
  6694. SelfpayProp: item.SelfpayProp,
  6695. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6696. OverlmtAmt: item.OverlmtAmt,
  6697. PreselfpayAmt: item.PreselfpayAmt,
  6698. BasMednFlag: item.BasMednFlag,
  6699. MedChrgitmType: item.MedChrgitmType,
  6700. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6701. Status: 1,
  6702. Memo: item.Memo,
  6703. Mtime: time.Now().Unix(),
  6704. InscpScpAmt: item.InscpScpAmt,
  6705. DrtReimFlag: item.DrtReimFlag,
  6706. Ctime: time.Now().Unix(),
  6707. ListSpItemFlag: item.ListSpItemFlag,
  6708. ChldMedcFlag: item.ChldMedcFlag,
  6709. LmtUsedFlag: item.LmtUsedFlag,
  6710. ChrgitmLv: item.ChrgitmLv,
  6711. UserOrgId: adminUser.CurrentOrgId,
  6712. HisPatientId: his.ID,
  6713. OrderId: order.ID,
  6714. ProjectId: project_id,
  6715. Type: types,
  6716. }
  6717. service.CreateOrderInfo(info)
  6718. }
  6719. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6720. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6721. var total float64
  6722. for _, item := range prescriptions {
  6723. if item.Type == 1 { //药品
  6724. for _, subItem := range item.HisDoctorAdviceInfo {
  6725. total = total + (subItem.Price * subItem.PrescribingNumber)
  6726. }
  6727. }
  6728. if item.Type == 2 { //项目
  6729. for _, subItem := range item.HisPrescriptionProject {
  6730. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6731. total = total + (subItem.Price * cnt)
  6732. }
  6733. }
  6734. }
  6735. for _, item := range prescriptions {
  6736. for _, subItem := range item.HisAdditionalCharge {
  6737. total = total + (subItem.Price * float64(subItem.Count))
  6738. }
  6739. }
  6740. allTotal := fmt.Sprintf("%.4f", total)
  6741. if res.Infcode == 0 {
  6742. var rf []*ResultFive
  6743. json.Unmarshal([]byte(his.Iinfo), &rf)
  6744. chrg_bchno := chrg_bchno
  6745. cert_no := his.Certno
  6746. var insutypes []string
  6747. var insutype string
  6748. var is390 int = 0
  6749. var is310 int = 0
  6750. for _, item := range rf {
  6751. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6752. insutypes = append(insutypes, item.Insutype)
  6753. }
  6754. }
  6755. if len(insutypes) == 1 {
  6756. insutype = insutypes[0]
  6757. } else {
  6758. for _, i := range insutypes {
  6759. if i == "390" {
  6760. is390 = 1
  6761. }
  6762. if i == "310" {
  6763. is310 = 1
  6764. }
  6765. }
  6766. }
  6767. if is390 == 1 {
  6768. insutype = "390"
  6769. }
  6770. if is310 == 1 {
  6771. insutype = "310"
  6772. }
  6773. if len(insutypes) == 0 {
  6774. insutype = "310"
  6775. }
  6776. if len(insutypes) == 2 {
  6777. insutype = strconv.FormatInt(his.SocialType, 64)
  6778. }
  6779. //insutype = "390"
  6780. if his.IdCardType == 1 {
  6781. cert_no = his.MedicalInsuranceNumber
  6782. } else {
  6783. cert_no = his.Certno
  6784. }
  6785. var res ResultSeven
  6786. var resSeven10265 ResultSeven10265
  6787. if miConfig.MdtrtareaAdmvs == "421300" {
  6788. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6789. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6790. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6791. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6792. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6793. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6794. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6795. resp, requestErr := http.Get(api)
  6796. if requestErr != nil {
  6797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6798. return
  6799. }
  6800. body, ioErr := ioutil.ReadAll(resp.Body)
  6801. if ioErr != nil {
  6802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. var respJSON map[string]interface{}
  6807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6810. return
  6811. }
  6812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6813. result, _ := json.Marshal(respJSON)
  6814. fmt.Println("log")
  6815. fmt.Println(string(result))
  6816. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6817. utils.ErrorLog("解析失败:%v", err)
  6818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6819. return
  6820. }
  6821. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6822. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6823. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6824. bas := strings.Split(psn_info.CardInfo, "|")
  6825. if his.IdCardType == 1 {
  6826. cert_no = bas[2]
  6827. } else {
  6828. cert_no = bas[1]
  6829. }
  6830. //江苏地区国家医保医疗类别
  6831. //职工透析:医疗类别选特殊情况门诊9933
  6832. //居民血透门慢: 医疗类别选门诊慢病1402
  6833. //var med_type string
  6834. //if his.Insutype == "310" {
  6835. // if reg_type == 14 {
  6836. // med_type = "9933"
  6837. // } else if reg_type == 11 {
  6838. // med_type = "11"
  6839. //
  6840. // }
  6841. //} else if his.Insutype == "390" {
  6842. // if reg_type == 14 {
  6843. // med_type = "1402"
  6844. // } else if reg_type == 11 {
  6845. // med_type = "11"
  6846. // }
  6847. //}
  6848. var api string
  6849. if miConfig.MdtrtareaAdmvs == "320921" {
  6850. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6856. "&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
  6857. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6858. } else {
  6859. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6860. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6861. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6862. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6863. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6864. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6865. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6866. "&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
  6867. }
  6868. resp, requestErr := http.Get(api)
  6869. if requestErr != nil {
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return
  6872. }
  6873. body, ioErr := ioutil.ReadAll(resp.Body)
  6874. if ioErr != nil {
  6875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6877. return
  6878. }
  6879. var respJSON map[string]interface{}
  6880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. return
  6884. }
  6885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6886. result, _ := json.Marshal(respJSON)
  6887. fmt.Println("log")
  6888. fmt.Println(string(result))
  6889. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6890. utils.ErrorLog("解析失败:%v", err)
  6891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6892. return
  6893. }
  6894. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6895. res.Output = resSeven10265.Output
  6896. res.ErrMsg = resSeven10265.ErrMsg
  6897. res.Cainfo = resSeven10265.Cainfo
  6898. res.WarnMsg = resSeven10265.WarnMsg
  6899. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6900. res.Infcode = infocode
  6901. } else {
  6902. var result string
  6903. var request_log string
  6904. if miConfig.Code == "H15049901371" {
  6905. //赤峰地区国家医保医疗类别
  6906. //职工透析:医疗类别选特殊情况门诊990502
  6907. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6908. var med_type string
  6909. if his.Insutype == "390" {
  6910. if reg_type == 14 {
  6911. med_type = "9933"
  6912. } else if reg_type == 11 {
  6913. med_type = "11"
  6914. }
  6915. } else if his.Insutype == "310" {
  6916. if reg_type == 14 {
  6917. med_type = "990502"
  6918. } else if reg_type == 11 {
  6919. med_type = "11"
  6920. }
  6921. }
  6922. 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)
  6923. } else {
  6924. 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)
  6925. }
  6926. var dat map[string]interface{}
  6927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6928. fmt.Println(dat)
  6929. } else {
  6930. fmt.Println(err)
  6931. }
  6932. saveLog(result, request_log, "2206", "预结算")
  6933. //userJSONBytes, _ := json.Marshal(dat)
  6934. //
  6935. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6936. // utils.ErrorLog("解析失败:%v", err)
  6937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. // return
  6939. //}
  6940. userJSONBytes, _ := json.Marshal(dat)
  6941. if miConfig.Code == "H15049901371" {
  6942. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6943. utils.ErrorLog("解析失败:%v", err)
  6944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6945. return
  6946. }
  6947. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6948. res.Output = resSeven10265.Output
  6949. res.ErrMsg = resSeven10265.ErrMsg
  6950. res.Cainfo = resSeven10265.Cainfo
  6951. res.WarnMsg = resSeven10265.WarnMsg
  6952. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6953. res.Infcode = infocode
  6954. } else {
  6955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6956. utils.ErrorLog("解析失败:%v", err)
  6957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6958. return
  6959. }
  6960. }
  6961. }
  6962. if res.Infcode != 0 {
  6963. errlog := &models.HisOrderError{
  6964. UserOrgId: adminUser.CurrentOrgId,
  6965. Ctime: time.Now().Unix(),
  6966. Mtime: time.Now().Unix(),
  6967. Number: chrg_bchno,
  6968. ErrMsg: res.ErrMsg,
  6969. Status: 1,
  6970. PatientId: id,
  6971. RecordTime: recordDateTime,
  6972. Stage: 20,
  6973. }
  6974. service.CreateErrMsgLog(errlog)
  6975. c.ServeSuccessJSON(map[string]interface{}{
  6976. "failed_code": -10,
  6977. "msg": res.ErrMsg,
  6978. })
  6979. return
  6980. } else {
  6981. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6982. order.OrderStatus = 1
  6983. order.IsPre = 1
  6984. order.Status = 1
  6985. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6986. order.SetlId = res.Output.Setlinfo.SetlID
  6987. order.PsnNo = res.Output.Setlinfo.PsnNo
  6988. order.PsnName = res.Output.Setlinfo.PsnName
  6989. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6990. order.Certno = res.Output.Setlinfo.Certno
  6991. order.Gend = res.Output.Setlinfo.Gend
  6992. order.Naty = res.Output.Setlinfo.Naty
  6993. order.Age = res.Output.Setlinfo.Age
  6994. order.Insutype = res.Output.Setlinfo.Insutype
  6995. order.PsnType = res.Output.Setlinfo.PsnType
  6996. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6997. order.SetlTime = res.Output.Setlinfo.SetlTime
  6998. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6999. if res.Output.Setlinfo.MedType == "140101" {
  7000. order.MedType = "14"
  7001. } else {
  7002. order.MedType = res.Output.Setlinfo.MedType
  7003. }
  7004. if reg_type == 1112 {
  7005. order.MedType = "1112"
  7006. }
  7007. if reg_type == 1111 {
  7008. order.MedType = "1111"
  7009. }
  7010. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7011. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7012. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7013. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7014. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7015. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7016. order.HifpPay = res.Output.Setlinfo.HifpPay
  7017. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7018. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7019. order.HifesPay = res.Output.Setlinfo.HifesPay
  7020. order.HifobPay = res.Output.Setlinfo.HifobPay
  7021. order.MafPay = res.Output.Setlinfo.MafPay
  7022. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7023. order.OthPay = res.Output.Setlinfo.OthPay
  7024. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7025. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7026. order.AcctPay = res.Output.Setlinfo.AcctPay
  7027. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7028. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7029. order.Balc = res.Output.Setlinfo.Balc
  7030. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7031. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7032. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7033. order.ClrWay = res.Output.Setlinfo.ClrWay
  7034. order.Creator = order.Creator
  7035. order.Modify = roles.AdminUserId
  7036. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7037. detailStr := string(setlDetail)
  7038. order.SetlDetail = detailStr
  7039. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7040. err = service.UpDateOrder(order)
  7041. if err == nil {
  7042. c.ServeSuccessJSON(map[string]interface{}{
  7043. "msg": "预结算成功",
  7044. })
  7045. } else {
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7047. return
  7048. }
  7049. }
  7050. } else {
  7051. adminUser := c.GetAdminUserInfo()
  7052. errlog := &models.HisOrderError{
  7053. UserOrgId: adminUser.CurrentOrgId,
  7054. Ctime: time.Now().Unix(),
  7055. Mtime: time.Now().Unix(),
  7056. ErrMsg: res.ErrMsg,
  7057. Status: 1,
  7058. PatientId: id,
  7059. RecordTime: recordDateTime,
  7060. Stage: 4,
  7061. }
  7062. service.CreateErrMsgLog(errlog)
  7063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7064. return
  7065. }
  7066. } else {
  7067. adminUser := c.GetAdminUserInfo()
  7068. errlog := &models.HisOrderError{
  7069. UserOrgId: adminUser.CurrentOrgId,
  7070. Ctime: time.Now().Unix(),
  7071. Mtime: time.Now().Unix(),
  7072. ErrMsg: res.ErrMsg,
  7073. Status: 1,
  7074. PatientId: id,
  7075. RecordTime: recordDateTime,
  7076. Stage: 4,
  7077. }
  7078. service.CreateErrMsgLog(errlog)
  7079. c.ServeSuccessJSON(map[string]interface{}{
  7080. "failed_code": -10,
  7081. "msg": res.ErrMsg,
  7082. })
  7083. return
  7084. }
  7085. }
  7086. }
  7087. }
  7088. //func (c *HisApiController) GetSettleInfo() {
  7089. // id, _ := c.GetInt64("id")
  7090. // order_id, _ := c.GetInt64("order_id")
  7091. //
  7092. // record_time := c.GetString("record_time")
  7093. // pay_way, _ := c.GetInt64("pay_way")
  7094. // pay_price, _ := c.GetFloat("pay_price")
  7095. // pay_card_no := c.GetString("pay_card_no")
  7096. // discount_price, _ := c.GetFloat("discount_price")
  7097. // preferential_price, _ := c.GetFloat("preferential_price")
  7098. // reality_price, _ := c.GetFloat("reality_price")
  7099. // found_price, _ := c.GetFloat("found_price")
  7100. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7101. // private_price, _ := c.GetFloat("private_price")
  7102. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7103. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7104. //
  7105. // timeLayout := "2006-01-02"
  7106. // loc, _ := time.LoadLocation("Local")
  7107. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7108. // if err != nil {
  7109. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7110. // return
  7111. // }
  7112. // recordDateTime := theTime.Unix()
  7113. // adminUser := c.GetAdminUserInfo()
  7114. //
  7115. // var prescriptions []*models.HisPrescription
  7116. //
  7117. // data := make(map[string]interface{})
  7118. // if settle_accounts_type == 1 { //日结
  7119. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7120. // data["pre"] = prescriptions
  7121. //
  7122. // } else { //月结
  7123. // start_time_str := c.GetString("start_time")
  7124. // end_time_str := c.GetString("end_time")
  7125. // timeLayout := "2006-01-02"
  7126. // loc, _ := time.LoadLocation("Local")
  7127. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7128. // if err != nil {
  7129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7130. // return
  7131. // }
  7132. // recordStartTime := theStartTime.Unix()
  7133. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7134. // if err != nil {
  7135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7136. // return
  7137. // }
  7138. // recordEndTime := theEndTime.Unix()
  7139. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7140. // data["pre"] = prescriptions
  7141. //
  7142. // }
  7143. //
  7144. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7145. //
  7146. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7147. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7148. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7149. // strconv.FormatInt(his.PatientId, 10)
  7150. //
  7151. // order_src, _ := service.GetHisOrderByID(order_id)
  7152. //
  7153. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7154. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7155. //
  7156. // var total float64
  7157. // for _, item := range prescriptions {
  7158. // if item.Type == 1 { //药品
  7159. // for _, subItem := range item.HisDoctorAdviceInfo {
  7160. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7161. // }
  7162. // }
  7163. // if item.Type == 2 { //项目
  7164. // for _, subItem := range item.HisPrescriptionProject {
  7165. // total = total + (subItem.Price * float64(subItem.Count))
  7166. // }
  7167. // }
  7168. // }
  7169. //
  7170. // for _, item := range prescriptions {
  7171. // for _, subItem := range item.HisAdditionalCharge {
  7172. // total = total + (subItem.Price * float64(subItem.Count))
  7173. // }
  7174. // }
  7175. //
  7176. // allTotal := fmt.Sprintf("%.2f", total)
  7177. // var rf []*ResultFive
  7178. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7179. // psn_no := order_src.PsnNo
  7180. // mdtrt_id := order_src.MdtrtId
  7181. // chrg_bchno := order_src.Number
  7182. // cert_no := order_src.Certno
  7183. // insutype := rf[0].Insutype
  7184. //
  7185. // if his.IdCardType == 1 {
  7186. // cert_no = his.MedicalInsuranceNumber
  7187. // } else {
  7188. // cert_no = his.Certno
  7189. // }
  7190. //
  7191. // 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)
  7192. // var dat map[string]interface{}
  7193. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7194. // fmt.Println(dat)
  7195. // } else {
  7196. // fmt.Println(err)
  7197. // }
  7198. //
  7199. // userJSONBytes, _ := json.Marshal(dat)
  7200. //
  7201. //
  7202. //
  7203. // var res ResultSeven
  7204. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7205. // utils.ErrorLog("解析失败:%v", err)
  7206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. // return
  7208. // }
  7209. // if res.Infcode == -1 {
  7210. // errlog := &models.HisOrderError{
  7211. // UserOrgId: adminUser.CurrentOrgId,
  7212. // Ctime: time.Now().Unix(),
  7213. // Mtime: time.Now().Unix(),
  7214. // Number: chrg_bchno,
  7215. // ErrMsg: res.ErrMsg,
  7216. // Status: 1,
  7217. // PatientId: id,
  7218. // RecordTime: recordDateTime,
  7219. // Stage: 6,
  7220. // }
  7221. // service.CreateErrMsgLog(errlog)
  7222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7223. // return
  7224. // } else {
  7225. // order_src.OrderStatus = 2
  7226. // order_src.PayWay = pay_way
  7227. // order_src.PayPrice = pay_price
  7228. // order_src.PayCardNo = pay_card_no
  7229. // order_src.DiscountPrice = discount_price
  7230. // order_src.PreferentialPrice = preferential_price
  7231. // order_src.RealityPrice = reality_price
  7232. // order_src.FoundPrice = found_price
  7233. // order_src.MedicalInsurancePrice = medical_insurance_price
  7234. // order_src.PrivatePrice = private_price
  7235. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7236. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7237. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7238. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7239. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7240. // order_src.Certno = res.Output.Setlinfo.Certno
  7241. // order_src.Gend = res.Output.Setlinfo.Gend
  7242. // order_src.Naty = res.Output.Setlinfo.Naty
  7243. // order_src.Age = res.Output.Setlinfo.Age
  7244. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7245. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7246. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7247. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7248. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7249. // order_src.MedType = res.Output.Setlinfo.MedType
  7250. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7251. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7252. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7253. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7254. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7255. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7256. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7257. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7258. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7259. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7260. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7261. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7262. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7263. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7264. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7265. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7266. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7267. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7268. // order_src.Balc = res.Output.Setlinfo.Balc
  7269. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7270. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7271. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7272. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7273. // order_src.Creator = order_src.Creator
  7274. // order_src.Modify = roles.ID
  7275. // order_src.RequestLog = src_resquest
  7276. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7277. // detailStr := string(setlDetail)
  7278. // order_src.SetlDetail = detailStr
  7279. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7280. // err = service.UpDateOrder(order_src)
  7281. //
  7282. // if err == nil {
  7283. // c.ServeSuccessJSON(map[string]interface{}{
  7284. // "msg": "结算成功",
  7285. // })
  7286. // } else {
  7287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7288. // return
  7289. // }
  7290. // }
  7291. // }
  7292. //}
  7293. //退款
  7294. func (c *HisApiController) Refund() {
  7295. order_id, _ := c.GetInt64("order_id")
  7296. admin_user_id, _ := c.GetInt64("admin_user_id")
  7297. adminUser := c.GetAdminUserInfo()
  7298. var order models.HisOrder
  7299. order, _ = service.GetHisOrderByID(order_id)
  7300. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7301. if order.ID == 0 {
  7302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7303. return
  7304. }
  7305. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7306. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7307. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7308. if config.IsOpen == 1 { //对接了医保,走医保流程
  7309. var res ResultSixteen
  7310. var resSixteen10265 ResultSixteen10265
  7311. var src_resquest string
  7312. var result string
  7313. if miConfig.MdtrtareaAdmvs == "421300" {
  7314. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7315. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7316. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7317. resp3, requestErr3 := http.Get(api3)
  7318. if requestErr3 != nil {
  7319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7320. return
  7321. }
  7322. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7323. if ioErr3 != nil {
  7324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7326. return
  7327. }
  7328. var respJSON3 map[string]interface{}
  7329. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7332. return
  7333. }
  7334. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7335. userJSONBytes3, _ := json.Marshal(respJSON3)
  7336. fmt.Println("log")
  7337. fmt.Println(string(userJSONBytes3))
  7338. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7339. utils.ErrorLog("解析失败:%v", err)
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. return
  7342. }
  7343. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7344. var api3 string
  7345. if miConfig.MdtrtareaAdmvs == "320921" {
  7346. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7347. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7348. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7349. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7350. } else {
  7351. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7352. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7353. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7354. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7355. }
  7356. resp3, requestErr3 := http.Get(api3)
  7357. if requestErr3 != nil {
  7358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. return
  7360. }
  7361. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7362. if ioErr3 != nil {
  7363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7365. return
  7366. }
  7367. var respJSON3 map[string]interface{}
  7368. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. return
  7372. }
  7373. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7374. userJSONBytes3, _ := json.Marshal(respJSON3)
  7375. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7376. utils.ErrorLog("解析失败:%v", err)
  7377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. return
  7379. }
  7380. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7381. res.Output = resSixteen10265.Output
  7382. res.ErrMsg = resSixteen10265.ErrMsg
  7383. res.Cainfo = resSixteen10265.Cainfo
  7384. res.WarnMsg = resSixteen10265.WarnMsg
  7385. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7386. res.Infcode = infocode
  7387. } else {
  7388. if miConfig.Code == "H15049901371" {
  7389. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7390. var dat map[string]interface{}
  7391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7392. fmt.Println(dat)
  7393. } else {
  7394. fmt.Println(err)
  7395. }
  7396. saveLog(result, src_resquest, "2208", "退费")
  7397. userJSONBytes, _ := json.Marshal(dat)
  7398. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7399. utils.ErrorLog("解析失败:%v", err)
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. return
  7402. }
  7403. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7404. res.Output = resSixteen10265.Output
  7405. res.ErrMsg = resSixteen10265.ErrMsg
  7406. res.Cainfo = resSixteen10265.Cainfo
  7407. res.WarnMsg = resSixteen10265.WarnMsg
  7408. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7409. res.Infcode = infocode
  7410. } else {
  7411. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7412. var dat map[string]interface{}
  7413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7414. fmt.Println(dat)
  7415. } else {
  7416. fmt.Println(err)
  7417. }
  7418. saveLog(result, src_resquest, "2208", "退费")
  7419. userJSONBytes, _ := json.Marshal(dat)
  7420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7421. utils.ErrorLog("解析失败:%v", err)
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. return
  7424. }
  7425. }
  7426. }
  7427. if res.Infcode == 0 {
  7428. var res2 ResultSix
  7429. var resSix10265 ResultSix10265
  7430. if miConfig.MdtrtareaAdmvs == "421300" {
  7431. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7432. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7433. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7434. resp3, requestErr3 := http.Get(api3)
  7435. if requestErr3 != nil {
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7437. return
  7438. }
  7439. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7440. if ioErr3 != nil {
  7441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7443. return
  7444. }
  7445. var respJSON3 map[string]interface{}
  7446. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7452. userJSONBytes3, _ := json.Marshal(respJSON3)
  7453. fmt.Println("log")
  7454. fmt.Println(string(userJSONBytes3))
  7455. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7456. utils.ErrorLog("解析失败:%v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. return
  7459. }
  7460. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7461. var api3 string
  7462. if miConfig.MdtrtareaAdmvs == "320921" {
  7463. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7464. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7465. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7466. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7467. } else {
  7468. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7469. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7470. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7471. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7472. }
  7473. resp3, requestErr3 := http.Get(api3)
  7474. if requestErr3 != nil {
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7479. if ioErr3 != nil {
  7480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7482. return
  7483. }
  7484. var respJSON3 map[string]interface{}
  7485. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7488. return
  7489. }
  7490. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7491. userJSONBytes3, _ := json.Marshal(respJSON3)
  7492. fmt.Println("log")
  7493. fmt.Println(string(userJSONBytes3))
  7494. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7495. utils.ErrorLog("解析失败:%v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7500. res2.Output = resSix10265.Output
  7501. res2.ErrMsg = resSix10265.ErrMsg
  7502. res2.Cainfo = resSix10265.Cainfo
  7503. res2.WarnMsg = resSix10265.WarnMsg
  7504. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7505. res2.Infcode = infocode
  7506. } else {
  7507. if miConfig.Code == "H15049901371" {
  7508. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7509. var dat map[string]interface{}
  7510. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7511. fmt.Println(dat)
  7512. } else {
  7513. fmt.Println(err)
  7514. }
  7515. saveLog(result2, src_request, "2205", "撤销明细")
  7516. userJSONBytes, _ := json.Marshal(dat)
  7517. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7518. utils.ErrorLog("解析失败:%v", err)
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7520. return
  7521. }
  7522. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7523. res2.Output = resSix10265.Output
  7524. res2.ErrMsg = resSix10265.ErrMsg
  7525. res2.Cainfo = resSix10265.Cainfo
  7526. res2.WarnMsg = resSix10265.WarnMsg
  7527. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7528. res2.Infcode = infocode
  7529. } else {
  7530. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7531. var dat map[string]interface{}
  7532. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7533. fmt.Println(dat)
  7534. } else {
  7535. fmt.Println(err)
  7536. }
  7537. saveLog(result2, src_request, "2205", "撤销明细")
  7538. userJSONBytes, _ := json.Marshal(dat)
  7539. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7540. utils.ErrorLog("解析失败:%v", err)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. }
  7545. }
  7546. if res2.Infcode == 0 {
  7547. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7548. if err == nil {
  7549. c.ServeSuccessJSON(map[string]interface{}{
  7550. "msg": "退费成功",
  7551. })
  7552. } else {
  7553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7554. return
  7555. }
  7556. } else {
  7557. c.ServeSuccessJSON(map[string]interface{}{
  7558. "code": -10,
  7559. "msg": res2.ErrMsg,
  7560. })
  7561. }
  7562. } else {
  7563. c.ServeSuccessJSON(map[string]interface{}{
  7564. "code": -10,
  7565. "msg": res.ErrMsg,
  7566. })
  7567. }
  7568. }
  7569. }
  7570. func (c *HisApiController) RefundNumber() {
  7571. record_time := c.GetString("record_time")
  7572. //patient_id, _ := c.GetInt64("patient_id")
  7573. admin_user_id, _ := c.GetInt64("admin_user_id")
  7574. his_patient_id, _ := c.GetInt64("id")
  7575. timeLayout := "2006-01-02"
  7576. loc, _ := time.LoadLocation("Local")
  7577. adminUser := c.GetAdminUserInfo()
  7578. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7579. fmt.Println(err)
  7580. if err != nil {
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7582. return
  7583. }
  7584. recordDateTime := theTime.Unix()
  7585. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7586. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7587. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7588. //order, _ := service.GetHisOrderByID(order_id)
  7589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7591. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7592. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7593. if count > 0 {
  7594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7595. return
  7596. }
  7597. if config.IsOpen == 1 { //对接了医保,走医保流程
  7598. var res2 ResultSix
  7599. var resSix10265 ResultSix10265
  7600. if miConfig.MdtrtareaAdmvs == "421300" {
  7601. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7602. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7603. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7604. resp3, requestErr3 := http.Get(api3)
  7605. if requestErr3 != nil {
  7606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7607. return
  7608. }
  7609. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7610. if ioErr3 != nil {
  7611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7613. return
  7614. }
  7615. var respJSON3 map[string]interface{}
  7616. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7619. return
  7620. }
  7621. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7622. userJSONBytes3, _ := json.Marshal(respJSON3)
  7623. fmt.Println("log")
  7624. fmt.Println(string(userJSONBytes3))
  7625. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7626. utils.ErrorLog("解析失败:%v", err)
  7627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7628. return
  7629. }
  7630. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7631. var api3 string
  7632. if miConfig.MdtrtareaAdmvs == "320921" {
  7633. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7634. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7636. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7637. } else {
  7638. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7639. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7640. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7641. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7642. }
  7643. resp3, requestErr3 := http.Get(api3)
  7644. if requestErr3 != nil {
  7645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7646. return
  7647. }
  7648. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7649. if ioErr3 != nil {
  7650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. return
  7653. }
  7654. var respJSON3 map[string]interface{}
  7655. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7658. return
  7659. }
  7660. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7661. userJSONBytes3, _ := json.Marshal(respJSON3)
  7662. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7663. utils.ErrorLog("解析失败:%v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. return
  7666. }
  7667. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7668. res2.Output = resSix10265.Output
  7669. res2.ErrMsg = resSix10265.ErrMsg
  7670. res2.Cainfo = resSix10265.Cainfo
  7671. res2.WarnMsg = resSix10265.WarnMsg
  7672. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7673. res2.Infcode = infocode
  7674. } else {
  7675. var api3 string
  7676. if miConfig.Code == "H15049901371" {
  7677. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7678. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7680. } else {
  7681. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7682. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7684. }
  7685. resp3, requestErr3 := http.Get(api3)
  7686. if requestErr3 != nil {
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7688. return
  7689. }
  7690. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7691. if ioErr3 != nil {
  7692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7694. return
  7695. }
  7696. var respJSON3 map[string]interface{}
  7697. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7703. userJSONBytes3, _ := json.Marshal(respJSON3)
  7704. if miConfig.Code == "H15049901371" {
  7705. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7706. utils.ErrorLog("解析失败:%v", err)
  7707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7708. return
  7709. }
  7710. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7711. res2.Output = resSix10265.Output
  7712. res2.ErrMsg = resSix10265.ErrMsg
  7713. res2.Cainfo = resSix10265.Cainfo
  7714. res2.WarnMsg = resSix10265.WarnMsg
  7715. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7716. res2.Infcode = infocode
  7717. } else {
  7718. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7719. utils.ErrorLog("解析失败:%v", err)
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7721. return
  7722. }
  7723. }
  7724. }
  7725. if res2.Infcode == 0 {
  7726. if err == nil {
  7727. c.ServeSuccessJSON(map[string]interface{}{
  7728. "msg": "退号成功",
  7729. })
  7730. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7731. } else {
  7732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7733. return
  7734. }
  7735. } else {
  7736. c.ServeSuccessJSON(map[string]interface{}{
  7737. "code": -10,
  7738. "msg": res2.ErrMsg,
  7739. })
  7740. }
  7741. } else {
  7742. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7743. //if err == nil {
  7744. // c.ServeSuccessJSON(map[string]interface{}{
  7745. // "msg": "退费成功",
  7746. // })
  7747. //} else {
  7748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7749. // return
  7750. //}
  7751. }
  7752. }
  7753. func (c *HisApiController) RefundDetail() {
  7754. order_id, _ := c.GetInt64("order_id")
  7755. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7756. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7757. number := c.GetString("number")
  7758. record_time := c.GetString("record_time")
  7759. patient_id, _ := c.GetInt64("patient_id")
  7760. //med_type, _ := c.GetInt64("med_type")
  7761. timeLayout := "2006-01-02"
  7762. loc, _ := time.LoadLocation("Local")
  7763. adminUser := c.GetAdminUserInfo()
  7764. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7765. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7766. fmt.Println(err)
  7767. if err != nil {
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7769. return
  7770. }
  7771. recordDateTime := theTime.Unix()
  7772. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7773. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7775. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7776. var order models.HisOrder
  7777. order, _ = service.GetHisOrderByID(order_id)
  7778. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7779. if config.IsOpen == 1 { //对接了医保,走医保流程
  7780. var res2 ResultSix
  7781. if miConfig.MdtrtareaAdmvs == "421300" {
  7782. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7783. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7784. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7785. resp3, requestErr3 := http.Get(api3)
  7786. if requestErr3 != nil {
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. return
  7789. }
  7790. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7791. if ioErr3 != nil {
  7792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7794. return
  7795. }
  7796. var respJSON3 map[string]interface{}
  7797. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7800. return
  7801. }
  7802. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7803. userJSONBytes3, _ := json.Marshal(respJSON3)
  7804. fmt.Println("log")
  7805. fmt.Println(string(userJSONBytes3))
  7806. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7807. utils.ErrorLog("解析失败:%v", err)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7812. if err == nil {
  7813. c.ServeSuccessJSON(map[string]interface{}{
  7814. "msg": "撤销明细成功",
  7815. })
  7816. return
  7817. } else {
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7822. var resSix10265 ResultSix10265
  7823. var api3 string
  7824. if miConfig.MdtrtareaAdmvs == "320921" {
  7825. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7826. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7827. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7828. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7829. } else {
  7830. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7831. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7832. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7833. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7834. }
  7835. resp3, requestErr3 := http.Get(api3)
  7836. if requestErr3 != nil {
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7841. if ioErr3 != nil {
  7842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7844. return
  7845. }
  7846. var respJSON3 map[string]interface{}
  7847. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7853. userJSONBytes3, _ := json.Marshal(respJSON3)
  7854. fmt.Println("log")
  7855. fmt.Println(string(userJSONBytes3))
  7856. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7857. utils.ErrorLog("解析失败:%v", err)
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7862. res2.Output = resSix10265.Output
  7863. res2.ErrMsg = resSix10265.ErrMsg
  7864. res2.Cainfo = resSix10265.Cainfo
  7865. res2.WarnMsg = resSix10265.WarnMsg
  7866. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7867. res2.Infcode = infocode
  7868. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7869. if err == nil {
  7870. c.ServeSuccessJSON(map[string]interface{}{
  7871. "msg": "撤销明细成功",
  7872. })
  7873. return
  7874. } else {
  7875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7876. return
  7877. }
  7878. } else {
  7879. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7880. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7881. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7882. resp2, requestErr2 := http.Get(api2)
  7883. if requestErr2 != nil {
  7884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7885. return
  7886. }
  7887. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7888. if ioErr2 != nil {
  7889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7891. return
  7892. }
  7893. var respJSON2 map[string]interface{}
  7894. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7900. if err == nil {
  7901. c.ServeSuccessJSON(map[string]interface{}{
  7902. "msg": "撤销明细成功",
  7903. })
  7904. return
  7905. } else {
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. }
  7910. } else {
  7911. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7912. if err == nil {
  7913. c.ServeSuccessJSON(map[string]interface{}{
  7914. "msg": "退费成功",
  7915. })
  7916. } else {
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7918. return
  7919. }
  7920. }
  7921. }
  7922. //对账
  7923. func (c *HisApiController) GetCheckAccount() {
  7924. start_time := c.GetString("start_time")
  7925. end_time := c.GetString("end_time")
  7926. insutype := c.GetString("insutype")
  7927. clr_type := c.GetString("clr_type")
  7928. clr_org := c.GetString("clr_optins")
  7929. admin_user_id, _ := c.GetInt64("admin_user_id")
  7930. adminUser := c.GetAdminUserInfo()
  7931. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7932. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7933. if len(clr_org) == 0 {
  7934. clr_org = miConfig.MdtrtareaAdmvs
  7935. }
  7936. timeLayout := "2006-01-02"
  7937. loc, _ := time.LoadLocation("Local")
  7938. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7939. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7940. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7941. fixmedins_setl_cnt := int64(len(orders))
  7942. var medfee_sumamt float64
  7943. var acct_pay float64
  7944. var fund_pay_sumamt float64
  7945. for _, item := range orders {
  7946. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7947. acct_pay = acct_pay + item.AcctPay
  7948. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7949. }
  7950. var user_name string
  7951. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7952. if role.ID == 0 {
  7953. user_name = "xxx"
  7954. } else {
  7955. user_name = role.UserName
  7956. }
  7957. var res ResultEight
  7958. var res10188 ResultEightFor10188
  7959. if config.IsOpen == 1 {
  7960. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7961. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7962. "insutype=" + insutype +
  7963. "&clr_type=" + "11" +
  7964. "&setl_optins=" + clr_org +
  7965. "&stmt_begndate=" + start_time +
  7966. "&stm_enddate=" + end_time +
  7967. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7968. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7969. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7970. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7971. "&fixmedins_code=" + miConfig.Code +
  7972. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7973. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7974. "&secret_key=" + miConfig.SecretKey +
  7975. "&org_name=" + miConfig.OrgName +
  7976. "&doctor=" + user_name +
  7977. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7978. fmt.Println(api)
  7979. resp, requestErr := http.Get(api)
  7980. if requestErr != nil {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. body, ioErr := ioutil.ReadAll(resp.Body)
  7985. fmt.Println(body)
  7986. if ioErr != nil {
  7987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. var respJSON map[string]interface{}
  7992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7995. return
  7996. }
  7997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7998. userJSONBytes, _ := json.Marshal(respJSON)
  7999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8000. utils.ErrorLog("解析失败:%v", err)
  8001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8002. return
  8003. }
  8004. res.InfRefmsgid = res10188.InfRefmsgid
  8005. res.Output = res10188.Output
  8006. res.ErrMsg = res10188.ErrMsg
  8007. res.Cainfo = res10188.Cainfo
  8008. res.WarnMsg = res10188.WarnMsg
  8009. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8010. res.Infcode = infocode
  8011. } else {
  8012. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8013. "insutype=" + insutype +
  8014. "&clr_type=" + clr_type +
  8015. "&setl_optins=" + clr_org +
  8016. "&stmt_begndate=" + start_time +
  8017. "&stm_enddate=" + end_time +
  8018. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8019. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8020. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8021. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8022. "&fixmedins_code=" + miConfig.Code +
  8023. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8024. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8025. "&secret_key=" + miConfig.SecretKey +
  8026. "&org_name=" + miConfig.OrgName +
  8027. "&doctor=" + user_name
  8028. fmt.Println(api)
  8029. resp, requestErr := http.Get(api)
  8030. if requestErr != nil {
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8032. return
  8033. }
  8034. body, ioErr := ioutil.ReadAll(resp.Body)
  8035. fmt.Println(body)
  8036. if ioErr != nil {
  8037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8039. return
  8040. }
  8041. var respJSON map[string]interface{}
  8042. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8045. return
  8046. }
  8047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8048. userJSONBytes, _ := json.Marshal(respJSON)
  8049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8050. utils.ErrorLog("解析失败:%v", err)
  8051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8052. return
  8053. }
  8054. }
  8055. if res.Infcode == 0 {
  8056. if res.Output.Stmtinfo.StmtRslt == "0" {
  8057. micc := &models.MedicalInsuranceCostCompare{
  8058. StartTime: startime.Unix(),
  8059. EndTime: endtime.Unix(),
  8060. Insutype: insutype,
  8061. CheckType: 1,
  8062. Num: fixmedins_setl_cnt,
  8063. Mtime: time.Now().Unix(),
  8064. Status: 1,
  8065. UserOrgId: adminUser.CurrentOrgId,
  8066. CostTotal: medfee_sumamt,
  8067. FuncTotal: fund_pay_sumamt,
  8068. PsnPay: acct_pay,
  8069. Creator: admin_user_id,
  8070. Ctime: time.Now().Unix(),
  8071. ClrType: clr_type,
  8072. }
  8073. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8074. if err == nil {
  8075. c.ServeSuccessJSON(map[string]interface{}{
  8076. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8077. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8078. })
  8079. } else {
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. }
  8082. } else {
  8083. c.ServeSuccessJSON(map[string]interface{}{
  8084. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8085. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8086. })
  8087. }
  8088. } else {
  8089. c.ServeSuccessJSON(map[string]interface{}{
  8090. "code": -10,
  8091. "msg": res.ErrMsg,
  8092. })
  8093. }
  8094. }
  8095. }
  8096. func (c *HisApiController) Check310() {
  8097. adminUser := c.GetAdminUserInfo()
  8098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8099. var user_name string
  8100. user_name = "高慧裕"
  8101. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8102. "insutype=" + "310" +
  8103. "&clr_type=" + "" +
  8104. "&setl_optins=" + "441202" +
  8105. "&stmt_begndate=" + "2022-03-01" +
  8106. "&stm_enddate=" + "2022-03-31" +
  8107. "&medfee_sumamt=" + "194930.12" +
  8108. "&fund_pay_sumamt=" + "188741.46" +
  8109. "&acct_pay=" + "0" +
  8110. "&fixmedins_setl_cnt=" + "452" +
  8111. "&fixmedins_code=" + miConfig.Code +
  8112. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8113. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8114. "&secret_key=" + miConfig.SecretKey +
  8115. "&org_name=" + miConfig.OrgName +
  8116. "&doctor=" + user_name
  8117. fmt.Println(api)
  8118. resp, requestErr := http.Get(api)
  8119. if requestErr != nil {
  8120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. return
  8122. }
  8123. body, ioErr := ioutil.ReadAll(resp.Body)
  8124. fmt.Println(body)
  8125. if ioErr != nil {
  8126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8128. return
  8129. }
  8130. var respJSON map[string]interface{}
  8131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8137. userJSONBytes, _ := json.Marshal(respJSON)
  8138. var res ResultEight
  8139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8140. utils.ErrorLog("解析失败:%v", err)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. }
  8145. func (c *HisApiController) Check390() {
  8146. adminUser := c.GetAdminUserInfo()
  8147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8148. var user_name string
  8149. user_name = "高慧裕"
  8150. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8151. "insutype=" + "390" +
  8152. "&clr_type=" + "" +
  8153. "&setl_optins=" + "441202" +
  8154. "&stmt_begndate=" + "2022-03-01" +
  8155. "&stm_enddate=" + "2022-03-31" +
  8156. "&medfee_sumamt=" + "1068448.89" +
  8157. "&fund_pay_sumamt=" + "1014677.62" +
  8158. "&acct_pay=" + "0" +
  8159. "&fixmedins_setl_cnt=" + "1950" +
  8160. "&fixmedins_code=" + miConfig.Code +
  8161. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8162. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8163. "&secret_key=" + miConfig.SecretKey +
  8164. "&org_name=" + miConfig.OrgName +
  8165. "&doctor=" + user_name
  8166. fmt.Println(api)
  8167. resp, requestErr := http.Get(api)
  8168. if requestErr != nil {
  8169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8170. return
  8171. }
  8172. body, ioErr := ioutil.ReadAll(resp.Body)
  8173. fmt.Println(body)
  8174. if ioErr != nil {
  8175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. var respJSON map[string]interface{}
  8180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8183. return
  8184. }
  8185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8186. userJSONBytes, _ := json.Marshal(respJSON)
  8187. var res ResultEight
  8188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8189. utils.ErrorLog("解析失败:%v", err)
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8191. return
  8192. }
  8193. }
  8194. //对账明细
  8195. func (c *HisApiController) GetCheckDetailAccount() {
  8196. start_time := c.GetString("start_time")
  8197. end_time := c.GetString("end_time")
  8198. admin_user_id, _ := c.GetInt64("admin_user_id")
  8199. adminUser := c.GetAdminUserInfo()
  8200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8201. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8202. timeLayout := "2006-01-02"
  8203. loc, _ := time.LoadLocation("Local")
  8204. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8205. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8206. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8207. Mkdir(miConfig.OrgName)
  8208. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8209. file_name := file + ".txt"
  8210. zip_name := file + ".zip"
  8211. zip_path := miConfig.OrgName + "/" + zip_name
  8212. file_path := miConfig.OrgName + "/" + file_name
  8213. decimal.DivisionPrecision = 2
  8214. var medfee_sumamt float64
  8215. var psn_cash_pay float64
  8216. var fund_pay_sumamt float64
  8217. fixmedins_setl_cnt := int64(len(orders))
  8218. for _, item := range orders {
  8219. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8220. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8221. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8222. }
  8223. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8224. defer f.Close()
  8225. if err != nil {
  8226. fmt.Println(err.Error())
  8227. } else {
  8228. for _, item := range orders {
  8229. var refd_setl_flag string
  8230. if item.OrderStatus == 2 {
  8231. refd_setl_flag = "0"
  8232. var str string
  8233. str = item.SetlId + " " +
  8234. item.MdtrtId + " " +
  8235. item.PsnNo + " " +
  8236. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8237. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8238. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8239. _, err = f.Write([]byte(str))
  8240. }
  8241. if item.OrderStatus == 3 {
  8242. var str string
  8243. str = item.SetlId + " " +
  8244. item.MdtrtId + " " +
  8245. item.PsnNo + " " +
  8246. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8247. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8248. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8249. _, err = f.Write([]byte(str))
  8250. var str2 string
  8251. str2 = item.SetlId + " " +
  8252. item.MdtrtId + " " +
  8253. item.PsnNo + " " +
  8254. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8255. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8256. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8257. _, err = f.Write([]byte(str2))
  8258. }
  8259. }
  8260. }
  8261. Zip(file_path, zip_path)
  8262. fmt.Println(ReadFile(zip_path))
  8263. fmt.Println(string(ReadFile(zip_path)))
  8264. if config.IsOpen == 1 {
  8265. var user_name string
  8266. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8267. if role.ID == 0 {
  8268. user_name = "管理员"
  8269. } else {
  8270. user_name = role.UserName
  8271. }
  8272. baseParams := models.BaseParams{
  8273. SecretKey: miConfig.SecretKey,
  8274. FixmedinsCode: miConfig.Code,
  8275. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8276. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8277. OrgName: miConfig.OrgName,
  8278. Doctor: user_name,
  8279. }
  8280. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8281. var dat map[string]interface{}
  8282. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8283. fmt.Println(dat)
  8284. } else {
  8285. fmt.Println(err)
  8286. }
  8287. userJSONBytes, _ := json.Marshal(dat)
  8288. var res ResultNine
  8289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8290. utils.ErrorLog("解析失败:%v", err)
  8291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8292. return
  8293. }
  8294. if res.Infcode == 0 {
  8295. fileNo := res.Output.FileQuryNo
  8296. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8297. "file_qury_no=" + fileNo +
  8298. "&setl_optins=" + "定点医保中心" +
  8299. "&stmt_begndate=" + start_time +
  8300. "&stm_enddate=" + end_time +
  8301. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8302. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8303. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8304. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8305. "&fixmedins_code=" + miConfig.Code +
  8306. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8307. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8308. "&secret_key=" + miConfig.SecretKey +
  8309. "&org_name=" + miConfig.OrgName +
  8310. "&doctor=" + user_name
  8311. resp, requestErr := http.Get(api)
  8312. if requestErr != nil {
  8313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8314. return
  8315. }
  8316. body, ioErr := ioutil.ReadAll(resp.Body)
  8317. if ioErr != nil {
  8318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8320. return
  8321. }
  8322. var respJSON map[string]interface{}
  8323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8326. return
  8327. }
  8328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8329. userJSONBytes, _ := json.Marshal(respJSON)
  8330. var res ResultTen
  8331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8332. utils.ErrorLog("解析失败:%v", err)
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8334. return
  8335. }
  8336. if res.Infcode == 0 {
  8337. service.Gdyb9102(baseParams, zip_name, fileNo)
  8338. micc := &models.MedicalInsuranceCostCompare{
  8339. StartTime: startime.Unix(),
  8340. EndTime: endtime.Unix(),
  8341. Insutype: "0",
  8342. CheckType: 2,
  8343. Num: fixmedins_setl_cnt,
  8344. Mtime: time.Now().Unix(),
  8345. Status: 1,
  8346. UserOrgId: adminUser.CurrentOrgId,
  8347. CostTotal: medfee_sumamt,
  8348. FuncTotal: fund_pay_sumamt,
  8349. PsnPay: psn_cash_pay,
  8350. Creator: admin_user_id,
  8351. Ctime: time.Now().Unix(),
  8352. }
  8353. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8354. c.ServeSuccessJSON(map[string]interface{}{
  8355. "msg": "明细对账成功",
  8356. })
  8357. }
  8358. } else {
  8359. }
  8360. }
  8361. }
  8362. type CustomOrderInfo struct {
  8363. Name string
  8364. Spec string
  8365. Unit string
  8366. Count float64
  8367. Price float64
  8368. Total float64
  8369. }
  8370. func (c *HisApiController) GetSettleAccounts() {
  8371. //id, _ := c.GetInt64("id")
  8372. //record_time := c.GetString("record_time")
  8373. order_id, _ := c.GetInt64("order_id")
  8374. admin_user_id, _ := c.GetInt64("admin_user_id")
  8375. //timeLayout := "2006-01-02"
  8376. //loc, _ := time.LoadLocation("Local")
  8377. //
  8378. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8379. //if err != nil {
  8380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8381. // return
  8382. //}
  8383. //recordDateTime := theTime.Unix()
  8384. adminUser := c.GetAdminUserInfo()
  8385. order, _ := service.GetHisOrderByID(order_id)
  8386. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8387. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8388. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8389. orderInfos = append(orderInfos, orderInfos_two...)
  8390. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8391. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8392. var diagnosis_ids []string
  8393. if his.ID > 0 {
  8394. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8395. } else {
  8396. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8397. }
  8398. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8399. var dia_config []*models.HisXtDiagnoseConfig
  8400. var name string
  8401. for _, item := range diagnosis_ids {
  8402. id, _ := strconv.ParseInt(item, 10, 64)
  8403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8404. dia_config = append(dia_config, &diagnosisConfig)
  8405. if len(name) == 0 {
  8406. name = diagnosisConfig.ClassName
  8407. } else {
  8408. name = name + "," + diagnosisConfig.ClassName
  8409. }
  8410. }
  8411. var bedCostTotal float64 = 0 //床位总费
  8412. var bedCostSelfTotal float64 = 0 //床位自费
  8413. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8414. var operationCostTotal float64 = 0 //手术费
  8415. var operationCostSelfTotal float64 = 0 //手术费
  8416. var operationCostPartSelfTotal float64 = 0 //手术费
  8417. var otherCostTotal float64 = 0 //其他费用
  8418. var otherCostSelfTotal float64 = 0 //其他费用
  8419. var otherCostPartSelfTotal float64 = 0 //其他费用
  8420. var materialCostTotal float64 = 0 //材料费
  8421. var materialCostSelfTotal float64 = 0 //材料费
  8422. var materialCostPartSelfTotal float64 = 0 //材料费
  8423. var westernMedicineCostTotal float64 = 0 //西药费
  8424. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8425. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8426. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8427. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8428. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8429. var checkCostTotal float64 = 0 //检查费
  8430. var checkCostSelfTotal float64 = 0 //检查费
  8431. var checkCostPartSelfTotal float64 = 0 //检查费
  8432. var laboratoryCostTotal float64 = 0 //化验费
  8433. var laboratoryCostSelfTotal float64 = 0 //化验费
  8434. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8435. var treatCostTotal float64 = 0 //治疗费用
  8436. var treatCostSelfTotal float64 = 0 //治疗费用
  8437. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8438. decimal.DivisionPrecision = 2
  8439. for _, item := range orderInfos {
  8440. if item.MedChrgitmType == "01" { //床位费
  8441. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8442. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8443. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8444. }
  8445. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8446. if item.MedChrgitmType == "03" { //检查费
  8447. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8448. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8449. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8450. }
  8451. } else {
  8452. if item.MedChrgitmType == "03" { //检查费
  8453. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8454. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8455. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8456. }
  8457. }
  8458. if item.MedChrgitmType == "04" { //化验费
  8459. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8460. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8461. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8462. }
  8463. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8464. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8465. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8466. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8467. }
  8468. if item.MedChrgitmType == "06" { //手术费
  8469. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8470. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8471. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8472. }
  8473. if item.MedChrgitmType == "08" { //材料费
  8474. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8475. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8476. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8477. }
  8478. if item.MedChrgitmType == "09" { //西药费
  8479. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8480. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8481. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8482. }
  8483. if item.MedChrgitmType == "11" { //中成费
  8484. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8485. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8486. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8487. }
  8488. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8489. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8490. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8491. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8492. }
  8493. }
  8494. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8495. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8496. var user_name string
  8497. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8498. if role.ID == 0 {
  8499. user_name = "管理员"
  8500. } else {
  8501. user_name = role.UserName
  8502. }
  8503. baseParams := models.BaseParams{
  8504. SecretKey: miConfig.SecretKey,
  8505. FixmedinsCode: miConfig.Code,
  8506. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8507. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8508. OrgName: miConfig.OrgName,
  8509. Doctor: user_name,
  8510. }
  8511. businessParams := models.BusinessParams{
  8512. PsnNo: order.PsnNo,
  8513. MdtrtId: order.MdtrtId,
  8514. SetlId: order.SetlId,
  8515. }
  8516. var res ResultEleven
  8517. var resEleven10265 ResultEleven10265
  8518. if config.IsOpen == 1 {
  8519. if miConfig.MdtrtareaAdmvs == "421300" {
  8520. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8521. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8522. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8523. resp, requestErr := http.Get(api)
  8524. if requestErr != nil {
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. body, ioErr := ioutil.ReadAll(resp.Body)
  8529. if ioErr != nil {
  8530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. var respJSON map[string]interface{}
  8535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8538. return
  8539. }
  8540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8541. result, _ := json.Marshal(respJSON)
  8542. fmt.Println("log")
  8543. fmt.Println(string(result))
  8544. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8545. utils.ErrorLog("解析失败:%v", err)
  8546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8547. return
  8548. }
  8549. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8550. var api string
  8551. if miConfig.MdtrtareaAdmvs == "320921" {
  8552. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8553. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8554. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8555. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8556. } else {
  8557. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8558. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8559. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8560. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8561. }
  8562. resp, requestErr := http.Get(api)
  8563. if requestErr != nil {
  8564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8565. return
  8566. }
  8567. body, ioErr := ioutil.ReadAll(resp.Body)
  8568. if ioErr != nil {
  8569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8571. return
  8572. }
  8573. var respJSON map[string]interface{}
  8574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8577. return
  8578. }
  8579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8580. result, _ := json.Marshal(respJSON)
  8581. fmt.Println("log")
  8582. fmt.Println(string(result))
  8583. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8584. utils.ErrorLog("解析失败:%v", err)
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8586. return
  8587. }
  8588. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8589. res.Output = resEleven10265.Output
  8590. res.ErrMsg = resEleven10265.ErrMsg
  8591. res.Cainfo = resEleven10265.Cainfo
  8592. res.WarnMsg = resEleven10265.WarnMsg
  8593. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8594. res.Infcode = infocode
  8595. } else {
  8596. //result2 := service.Gdyb1101()
  8597. //result2 := service.Gdyb5204(baseParams, businessParams)
  8598. //saveLog(result2, "", "5204", "查询")
  8599. result := service.Gdyb5203(baseParams, businessParams)
  8600. var dat map[string]interface{}
  8601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8602. fmt.Println(dat)
  8603. } else {
  8604. fmt.Println(err)
  8605. }
  8606. userJSONBytes, _ := json.Marshal(dat)
  8607. if miConfig.Code == "H15049901371" {
  8608. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8609. utils.ErrorLog("解析失败:%v", err)
  8610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8611. return
  8612. }
  8613. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8614. res.Output = resEleven10265.Output
  8615. res.ErrMsg = resEleven10265.ErrMsg
  8616. res.Cainfo = resEleven10265.Cainfo
  8617. res.WarnMsg = resEleven10265.WarnMsg
  8618. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8619. res.Infcode = infocode
  8620. } else {
  8621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8622. utils.ErrorLog("解析失败:%v", err)
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8624. return
  8625. }
  8626. }
  8627. }
  8628. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8629. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8630. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8631. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8632. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8633. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8634. var doctor_name string
  8635. if roles.ID == 0 {
  8636. doctor_name = "管理员"
  8637. } else {
  8638. doctor_name = roles.UserName
  8639. }
  8640. yiliao_leibie := ""
  8641. switch order.MedType {
  8642. case "11":
  8643. yiliao_leibie = "普通门诊"
  8644. break
  8645. case "12":
  8646. yiliao_leibie = "门诊挂号"
  8647. break
  8648. case "13":
  8649. yiliao_leibie = "急诊"
  8650. break
  8651. case "14":
  8652. yiliao_leibie = "门诊特殊病"
  8653. break
  8654. case "15":
  8655. yiliao_leibie = "门诊统筹"
  8656. break
  8657. case "16":
  8658. yiliao_leibie = "门诊慢性病"
  8659. break
  8660. case "21":
  8661. yiliao_leibie = "普通住院"
  8662. break
  8663. }
  8664. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8665. if res.Infcode == 0 {
  8666. c.ServeSuccessJSON(map[string]interface{}{
  8667. "diagnosis": name,
  8668. "order_infos": orderInfos,
  8669. "number": order.MdtrtId,
  8670. "date": order.SettleAccountsDate,
  8671. "charge_admin": charge_admin,
  8672. "printor_admin": printor_admin,
  8673. "info": res.Output.Setlinfo,
  8674. "order": order,
  8675. "bedCostTotal": bedCostTotal,
  8676. "bedCostSelfTotal": bedCostSelfTotal,
  8677. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8678. "operationCostTotal": operationCostTotal,
  8679. "operationCostSelfTotal": operationCostSelfTotal,
  8680. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8681. "otherCostTotal": otherCostTotal,
  8682. "otherCostSelfTotal": otherCostSelfTotal,
  8683. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8684. "materialCostTotal": materialCostTotal,
  8685. "materialCostSelfTotal": materialCostSelfTotal,
  8686. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8687. "westernMedicineCostTotal": westernMedicineCostTotal,
  8688. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8689. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8690. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8691. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8692. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8693. "checkCostTotal": checkCostTotal,
  8694. "checkCostSelfTotal": checkCostSelfTotal,
  8695. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8696. "laboratoryCostTotal": laboratoryCostTotal,
  8697. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8698. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8699. "treatCostTotal": treatCostTotal,
  8700. "treatCostSelfTotal": treatCostSelfTotal,
  8701. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8702. "doctor_info": doctor_info,
  8703. "doctor_code": adminRole_two.DoctorCode,
  8704. "doctor_name": doctor_name,
  8705. "health_card_no": order.PsnNo,
  8706. "department": departments.Name,
  8707. "yiliao_leibie": yiliao_leibie,
  8708. "after_money": order.AccountPrice,
  8709. "patient": patient,
  8710. "org_name": miConfig.OrgName,
  8711. "org_code": miConfig.Code,
  8712. "order_number": order.Number,
  8713. "his_hospital": his_hospital,
  8714. "his": his,
  8715. "dia_config": dia_config,
  8716. //"check_order_info": cus_slice,
  8717. })
  8718. }
  8719. }
  8720. }
  8721. func (c *HisApiController) CheckTreatment() {
  8722. patient_id, _ := c.GetInt64("patient_id")
  8723. id_card_no := c.GetString("id_card_no")
  8724. insutype := c.GetString("insutype")
  8725. med_type := c.GetString("med_type")
  8726. admin_user_id, _ := c.GetInt64("admin_user_id")
  8727. adminUser := c.GetAdminUserInfo()
  8728. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8730. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8731. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8732. if miConfig.MdtrtareaAdmvs == "421300" {
  8733. var res ResultTwo
  8734. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8735. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8736. "&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)
  8737. resp, requestErr := http.Get(api)
  8738. if requestErr != nil {
  8739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8740. return
  8741. }
  8742. body, ioErr := ioutil.ReadAll(resp.Body)
  8743. if ioErr != nil {
  8744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. var respJSON map[string]interface{}
  8749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8752. return
  8753. }
  8754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8755. result, _ := json.Marshal(respJSON)
  8756. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8757. utils.ErrorLog("解析失败:%v", err)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. if res.Infcode == 0 {
  8762. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8763. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8764. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8765. resp, requestErr := http.Get(api)
  8766. if requestErr != nil {
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. body, ioErr := ioutil.ReadAll(resp.Body)
  8771. if ioErr != nil {
  8772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8774. return
  8775. }
  8776. var respJSON map[string]interface{}
  8777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8780. return
  8781. }
  8782. var res Result2001
  8783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8784. result2, _ := json.Marshal(respJSON)
  8785. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8786. utils.ErrorLog("解析失败:%v", err)
  8787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8788. return
  8789. }
  8790. if res.Infcode == 0 {
  8791. c.ServeSuccessJSON(map[string]interface{}{
  8792. "msg": res.Output.Trtinfo,
  8793. })
  8794. }
  8795. } else {
  8796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8797. return
  8798. }
  8799. } else {
  8800. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8801. var dat map[string]interface{}
  8802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8803. fmt.Println(dat)
  8804. } else {
  8805. fmt.Println(err)
  8806. }
  8807. userJSONBytes, _ := json.Marshal(dat)
  8808. var res ResultTwo
  8809. var res10265 ResultTwo10265
  8810. if miConfig.Code == "H15049901371" {
  8811. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8812. utils.ErrorLog("解析失败:%v", err)
  8813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8814. return
  8815. }
  8816. res.ErrMsg = res10265.ErrMsg
  8817. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8818. res.Infcode = infocode
  8819. res.Output = res10265.Output
  8820. res.InfRefmsgid = res10265.InfRefmsgid
  8821. } else {
  8822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8823. utils.ErrorLog("解析失败:%v", err)
  8824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8825. return
  8826. }
  8827. }
  8828. var user_name string
  8829. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8830. if role.ID == 0 {
  8831. user_name = "xxx"
  8832. } else {
  8833. user_name = role.UserName
  8834. }
  8835. baseParams := models.BaseParams{
  8836. SecretKey: miConfig.SecretKey,
  8837. FixmedinsCode: miConfig.Code,
  8838. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8839. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8840. OrgName: miConfig.OrgName,
  8841. Doctor: user_name,
  8842. }
  8843. if config.IsOpen == 1 {
  8844. if miConfig.Code == "H15049901371" {
  8845. if med_type == "14" {
  8846. if insutype == "390" {
  8847. med_type = "9933"
  8848. } else if insutype == "310" {
  8849. med_type = "990502"
  8850. }
  8851. } else if med_type == "11" {
  8852. med_type = "11"
  8853. }
  8854. }
  8855. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8856. var dat map[string]interface{}
  8857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8858. fmt.Println(dat)
  8859. } else {
  8860. fmt.Println(err)
  8861. }
  8862. var res Result2001
  8863. var res10265 Result2001Org10265
  8864. if miConfig.Code == "H15049901371" {
  8865. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8866. utils.ErrorLog("解析失败:%v", err)
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. res.ErrMsg = res10265.ErrMsg
  8871. res.Output = res10265.Output
  8872. res.InfRefmsgid = res10265.InfRefmsgid
  8873. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8874. res.Infcode = infocode
  8875. } else {
  8876. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8877. utils.ErrorLog("解析失败:%v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. }
  8882. if res.Infcode == 0 {
  8883. c.ServeSuccessJSON(map[string]interface{}{
  8884. "msg": res.Output.Trtinfo,
  8885. })
  8886. }
  8887. }
  8888. }
  8889. }
  8890. //func (c *HisApiController) PutRecord() {
  8891. // id, _ := c.GetInt64("id")
  8892. // record_time := c.GetString("record_time")
  8893. // timeLayout := "2006-01-02"
  8894. // loc, _ := time.LoadLocation("Local")
  8895. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8896. // if err != nil {
  8897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8898. // return
  8899. // }
  8900. // recordDateTime := theTime.Unix()
  8901. //
  8902. // adminInfo := c.GetAdminUserInfo()
  8903. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8904. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8905. //
  8906. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8907. //
  8908. // fmt.Println(miConfig.SecretKey)
  8909. //
  8910. // if patient == nil {
  8911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8912. // return
  8913. // }
  8914. // if len(patient.IdCardNo) == 0 {
  8915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8916. // return
  8917. // }
  8918. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8919. // if config.IsOpen == 1 {
  8920. // 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
  8921. // resp, requestErr := http.Get(api)
  8922. // if requestErr != nil {
  8923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8924. // return
  8925. // }
  8926. // defer resp.Body.Close()
  8927. // body, ioErr := ioutil.ReadAll(resp.Body)
  8928. // if ioErr != nil {
  8929. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8931. // return
  8932. // }
  8933. // var respJSON map[string]interface{}
  8934. //
  8935. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8936. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8938. // return
  8939. // }
  8940. //
  8941. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8942. // userJSONBytes, _ := json.Marshal(userJSON)
  8943. // var res ResultTwo
  8944. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8945. // utils.ErrorLog("解析失败:%v", err)
  8946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8947. // return
  8948. // }
  8949. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8950. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8951. // infoStr := string(Iinfos)
  8952. // idetinfoStr := string(Idetinfos)
  8953. //
  8954. // if res.Infcode == 0 {
  8955. // his := models.VMHisPatient{
  8956. // Status: 1,
  8957. // Ctime: time.Now().Unix(),
  8958. // Mtime: time.Now().Unix(),
  8959. // PsnNo: res.Output.Baseinfo.PsnNo,
  8960. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8961. // Certno: res.Output.Baseinfo.Certno,
  8962. // PsnName: res.Output.Baseinfo.PsnName,
  8963. // Gend: res.Output.Baseinfo.Gend,
  8964. // Naty: res.Output.Baseinfo.Naty,
  8965. // Brdy: res.Output.Baseinfo.Brdy,
  8966. // Age: res.Output.Baseinfo.Age,
  8967. // Iinfo: infoStr,
  8968. // Idetinfo: idetinfoStr,
  8969. // PatientId: patient.ID,
  8970. // RecordDate: theTime.Unix(),
  8971. // UserOrgId: adminInfo.CurrentOrgId,
  8972. // AdminUserId: adminInfo.AdminUser.Id,
  8973. // IsReturn: 1,
  8974. // }
  8975. //
  8976. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8977. // //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")
  8978. // //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")
  8979. //
  8980. // //var dat map[string]interface{}
  8981. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8982. // // fmt.Println(dat)
  8983. // //} else {
  8984. // // fmt.Println(err)
  8985. // //}
  8986. //
  8987. // var dat2 map[string]interface{}
  8988. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8989. // fmt.Println(dat2)
  8990. // } else {
  8991. // fmt.Println(err)
  8992. // }
  8993. //
  8994. // } else {
  8995. // adminUser := c.GetAdminUserInfo()
  8996. // errlog := &models.HisOrderError{
  8997. // UserOrgId: adminUser.CurrentOrgId,
  8998. // Ctime: time.Now().Unix(),
  8999. // Mtime: time.Now().Unix(),
  9000. // ErrMsg: res.ErrMsg,
  9001. // Status: 1,
  9002. // PatientId: id,
  9003. // RecordTime: recordDateTime,
  9004. // Stage: 1,
  9005. // }
  9006. // service.CreateErrMsgLog(errlog)
  9007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9008. // return
  9009. // }
  9010. // }
  9011. //
  9012. //}
  9013. //func (c *HisApiController) GetUploadDiag() {
  9014. // id, _ := c.GetInt64("id")
  9015. // record_time := c.GetString("record_time")
  9016. //
  9017. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9018. // sick_type, _ := c.GetInt64("sick_type")
  9019. // reg_type, _ := c.GetInt64("reg_type")
  9020. //
  9021. // timeLayout := "2006-01-02"
  9022. // loc, _ := time.LoadLocation("Local")
  9023. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9024. // if err != nil {
  9025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9026. // return
  9027. // }
  9028. //
  9029. // var patientPrescription models.HisPrescriptionInfo
  9030. // recordDateTime := theTime.Unix()
  9031. // adminInfo := c.GetAdminUserInfo()
  9032. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9033. //
  9034. // if patientPrescription.ID == 0 {
  9035. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9036. // }
  9037. //
  9038. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9039. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9040. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9041. // sickConfig, _ := service.FindSickById(sick_type)
  9042. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9043. //
  9044. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9045. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9046. // "&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 +
  9047. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9048. // resp2, requestErr2 := http.Get(api2)
  9049. // if requestErr2 != nil {
  9050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9051. // return
  9052. // }
  9053. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9054. // if ioErr2 != nil {
  9055. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9057. // return
  9058. // }
  9059. // var respJSON2 map[string]interface{}
  9060. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9061. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9063. // return
  9064. // }
  9065. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9066. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9067. //
  9068. // var res2 ResultSix
  9069. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9070. // utils.ErrorLog("解析失败:%v", err)
  9071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9072. // return
  9073. // }
  9074. // if res2.Infcode != 0 {
  9075. // adminUser := c.GetAdminUserInfo()
  9076. // errlog := &models.HisOrderError{
  9077. // UserOrgId: adminUser.CurrentOrgId,
  9078. // Ctime: time.Now().Unix(),
  9079. // Mtime: time.Now().Unix(),
  9080. // ErrMsg: res2.ErrMsg,
  9081. // Status: 1,
  9082. // PatientId: id,
  9083. // RecordTime: recordDateTime,
  9084. // Stage: 3,
  9085. // }
  9086. // service.CreateErrMsgLog(errlog)
  9087. //
  9088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9089. // return
  9090. // }
  9091. //
  9092. // c.ServeSuccessJSON(map[string]interface{}{
  9093. // "msg": "上传成功",
  9094. // })
  9095. //
  9096. //}
  9097. type QueryResult struct {
  9098. ID int64
  9099. Name string
  9100. Code string
  9101. List_type_code string
  9102. }
  9103. func (c *HisApiController) GetCheckCode() {
  9104. ids_str := c.GetString("ids")
  9105. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9106. ids_arr := strings.Split(ids_str, ",")
  9107. var queryResult []QueryResult
  9108. ids := make([]int64, 0)
  9109. for _, item := range ids_arr {
  9110. id, _ := strconv.ParseInt(item, 10, 64)
  9111. ids = append(ids, id)
  9112. }
  9113. if record_type == 1 {
  9114. drugs, _ := service.GetBatchDrugList(ids)
  9115. for _, item := range drugs {
  9116. result := QueryResult{
  9117. ID: item.ID,
  9118. Name: item.DrugName,
  9119. Code: item.MedicalInsuranceNumber,
  9120. List_type_code: "101",
  9121. }
  9122. queryResult = append(queryResult, result)
  9123. }
  9124. } else if record_type == 2 {
  9125. goods, _ := service.GetBatchGoodInformationList(ids)
  9126. for _, item := range goods {
  9127. result := QueryResult{
  9128. ID: item.ID,
  9129. Name: item.GoodName,
  9130. Code: item.MedicalInsuranceNumber,
  9131. List_type_code: "301",
  9132. }
  9133. queryResult = append(queryResult, result)
  9134. }
  9135. } else if record_type == 3 {
  9136. projects, _ := service.GetBathchMyPorjecgList(ids)
  9137. for _, item := range projects {
  9138. result := QueryResult{
  9139. ID: item.ID,
  9140. Name: item.ProjectName,
  9141. Code: item.MedicalCode,
  9142. List_type_code: "201",
  9143. }
  9144. queryResult = append(queryResult, result)
  9145. }
  9146. }
  9147. admin_user_id, _ := c.GetInt64("admin_user_id")
  9148. adminUser := c.GetAdminUserInfo()
  9149. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9150. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9151. var user_name string
  9152. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9153. if role.ID == 0 {
  9154. user_name = "xxx"
  9155. } else {
  9156. user_name = role.UserName
  9157. }
  9158. baseParams := &models.BaseParams{
  9159. SecretKey: miConfig.SecretKey,
  9160. FixmedinsCode: miConfig.Code,
  9161. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9162. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9163. OrgName: miConfig.OrgName,
  9164. Doctor: user_name,
  9165. }
  9166. if config.IsOpen == 1 {
  9167. for _, item := range queryResult {
  9168. var result string
  9169. if record_type == 1 {
  9170. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9171. } else if record_type == 2 {
  9172. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9173. } else if record_type == 3 {
  9174. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9175. }
  9176. var dat map[string]interface{}
  9177. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9178. fmt.Println(dat)
  9179. } else {
  9180. fmt.Println(err)
  9181. }
  9182. userJSONBytes, _ := json.Marshal(dat)
  9183. var res ResultSix
  9184. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9185. utils.ErrorLog("解析失败:%v", err)
  9186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9187. return
  9188. }
  9189. if res.Infcode == 0 {
  9190. if record_type == 1 {
  9191. service.UpdateBaseDrugById(item.ID)
  9192. } else if record_type == 2 {
  9193. service.UpdateGoodInformaitonByDetail(item.ID)
  9194. } else if record_type == 3 {
  9195. service.UpdateProjectById(item.ID)
  9196. }
  9197. c.ServeSuccessJSON(map[string]interface{}{
  9198. "failed_code": 0,
  9199. "msg": "目录对照成功",
  9200. })
  9201. } else {
  9202. c.ServeSuccessJSON(map[string]interface{}{
  9203. "failed_code": -10,
  9204. "msg": res.ErrMsg,
  9205. })
  9206. }
  9207. }
  9208. }
  9209. }
  9210. func (c *HisApiController) UnCheckCode() {
  9211. ids_str := c.GetString("ids")
  9212. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9213. admin_user_id, _ := c.GetInt64("admin_user_id")
  9214. ids_arr := strings.Split(ids_str, ",")
  9215. var queryResult []QueryResult
  9216. ids := make([]int64, 0)
  9217. for _, item := range ids_arr {
  9218. id, _ := strconv.ParseInt(item, 10, 64)
  9219. ids = append(ids, id)
  9220. }
  9221. if record_type == 1 {
  9222. drugs, _ := service.GetBatchDrugList(ids)
  9223. for _, item := range drugs {
  9224. result := QueryResult{
  9225. ID: item.ID,
  9226. Name: item.DrugName,
  9227. Code: item.MedicalInsuranceNumber,
  9228. List_type_code: "101",
  9229. }
  9230. queryResult = append(queryResult, result)
  9231. }
  9232. } else if record_type == 2 {
  9233. goods, _ := service.GetBatchGoodInformationList(ids)
  9234. for _, item := range goods {
  9235. result := QueryResult{
  9236. ID: item.ID,
  9237. Name: item.GoodName,
  9238. Code: item.MedicalInsuranceNumber,
  9239. List_type_code: "301",
  9240. }
  9241. queryResult = append(queryResult, result)
  9242. }
  9243. } else if record_type == 3 {
  9244. projects, _ := service.GetBathchMyPorjecgList(ids)
  9245. for _, item := range projects {
  9246. result := QueryResult{
  9247. ID: item.ID,
  9248. Name: item.ProjectName,
  9249. Code: item.MedicalCode,
  9250. List_type_code: "201",
  9251. }
  9252. queryResult = append(queryResult, result)
  9253. }
  9254. }
  9255. adminUser := c.GetAdminUserInfo()
  9256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9257. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9258. var user_name string
  9259. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9260. if role.ID == 0 {
  9261. user_name = "xxx"
  9262. } else {
  9263. user_name = role.UserName
  9264. }
  9265. baseParams := &models.BaseParams{
  9266. SecretKey: miConfig.SecretKey,
  9267. FixmedinsCode: miConfig.Code,
  9268. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9269. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9270. OrgName: miConfig.OrgName,
  9271. Doctor: user_name,
  9272. }
  9273. if config.IsOpen == 1 {
  9274. for _, item := range queryResult {
  9275. var result string
  9276. if record_type == 1 {
  9277. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9278. } else if record_type == 2 {
  9279. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9280. } else if record_type == 3 {
  9281. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9282. }
  9283. var dat2 map[string]interface{}
  9284. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9285. fmt.Println(dat2)
  9286. } else {
  9287. fmt.Println(err)
  9288. }
  9289. userJSONBytes, _ := json.Marshal(dat2)
  9290. var res ResultSix
  9291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9292. utils.ErrorLog("解析失败:%v", err)
  9293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9294. return
  9295. }
  9296. if res.Infcode == 0 {
  9297. if record_type == 1 {
  9298. service.UpdateDrugByIdDetail(item.ID)
  9299. } else if record_type == 2 {
  9300. service.UpdateGoodInfoById(item.ID)
  9301. } else if record_type == 3 {
  9302. service.UpdateMyProjectById(item.ID)
  9303. }
  9304. c.ServeSuccessJSON(map[string]interface{}{
  9305. "failed_code": 0,
  9306. "msg": "撤销目录对照成功",
  9307. })
  9308. } else {
  9309. c.ServeSuccessJSON(map[string]interface{}{
  9310. "failed_code": -10,
  9311. "msg": res.ErrMsg,
  9312. })
  9313. }
  9314. }
  9315. }
  9316. }
  9317. func (c *HisApiController) GetPatientInfo() {
  9318. id_card_no := c.GetString("id_card_no")
  9319. admin_user_id, _ := c.GetInt64("admin_user_id")
  9320. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9321. if patient.ID == 0 {
  9322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9323. return
  9324. }
  9325. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9327. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9328. if config.IsOpen == 1 {
  9329. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9330. var dat map[string]interface{}
  9331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9332. fmt.Println(dat)
  9333. } else {
  9334. fmt.Println(err)
  9335. }
  9336. userJSONBytes, _ := json.Marshal(dat)
  9337. var res ResultTwo
  9338. var res10265 ResultTwo10265
  9339. if miConfig.Code == "H15049901371" {
  9340. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9341. utils.ErrorLog("解析失败:%v", err)
  9342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. return
  9344. }
  9345. res.ErrMsg = res10265.ErrMsg
  9346. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9347. res.Infcode = infocode
  9348. res.Output = res10265.Output
  9349. res.InfRefmsgid = res10265.InfRefmsgid
  9350. } else {
  9351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9352. utils.ErrorLog("解析失败:%v", err)
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9354. return
  9355. }
  9356. }
  9357. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9358. // utils.ErrorLog("解析失败:%v", err)
  9359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9360. // return
  9361. //}
  9362. if res.Infcode != 0 {
  9363. c.ServeSuccessJSON(map[string]interface{}{
  9364. "failed_code": -10,
  9365. "msg": res.ErrMsg,
  9366. })
  9367. } else {
  9368. c.ServeSuccessJSON(map[string]interface{}{
  9369. "failed_code": 0,
  9370. "info": res,
  9371. })
  9372. }
  9373. }
  9374. }
  9375. func (c *HisApiController) PsnPutOnRecord() {
  9376. record_type, _ := c.GetInt64("type")
  9377. patient_id, _ := c.GetInt64("patient_id")
  9378. admin_user_id, _ := c.GetInt64("admin_user_id")
  9379. start_time := c.GetString("start_time")
  9380. end_time := c.GetString("end_time")
  9381. adminUser := c.GetAdminUserInfo()
  9382. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9383. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9384. var patients []*models.Patients
  9385. if record_type == 1 { //全部备案
  9386. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9387. patients = append(patients, patient...)
  9388. } else { //单个备案
  9389. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9390. patients = append(patients, patient)
  9391. }
  9392. var user_name string
  9393. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9394. if role.ID == 0 {
  9395. user_name = "xxx"
  9396. } else {
  9397. user_name = role.UserName
  9398. }
  9399. if config.IsOpen == 1 {
  9400. for _, item := range patients {
  9401. 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
  9402. resp, requestErr := http.Get(api)
  9403. if requestErr != nil {
  9404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9405. return
  9406. }
  9407. defer resp.Body.Close()
  9408. body, ioErr := ioutil.ReadAll(resp.Body)
  9409. if ioErr != nil {
  9410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9412. return
  9413. }
  9414. var respJSON map[string]interface{}
  9415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9421. userJSONBytes, _ := json.Marshal(userJSON)
  9422. var res ResultTwo
  9423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9424. utils.ErrorLog("解析失败:%v", err)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. if res.Infcode == 0 {
  9429. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9430. var dat map[string]interface{}
  9431. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9432. fmt.Println(dat)
  9433. } else {
  9434. fmt.Println(err)
  9435. }
  9436. userJSONBytes, _ := json.Marshal(dat)
  9437. var res2 ResultThirteen
  9438. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9439. utils.ErrorLog("解析失败:%v", err)
  9440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9441. return
  9442. }
  9443. if res2.Infcode == 0 {
  9444. psnResult := &models.GdybPsnRecord{
  9445. UserOrgId: adminUser.CurrentOrgId,
  9446. PatientId: item.ID,
  9447. PsnNo: res.Output.Baseinfo.PsnNo,
  9448. Ctime: time.Now().Unix(),
  9449. Mtime: time.Now().Unix(),
  9450. Status: 1,
  9451. IsCancel: 1,
  9452. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9453. }
  9454. service.CreatePsnRecord(psnResult)
  9455. } else {
  9456. c.ServeSuccessJSON(map[string]interface{}{
  9457. "failed_code": -10,
  9458. "msg": res2.ErrMsg,
  9459. })
  9460. return
  9461. }
  9462. }
  9463. }
  9464. }
  9465. }
  9466. func (c *HisApiController) PsnUnPutOnRecord() {
  9467. id, _ := c.GetInt64("id")
  9468. //record_type, _ := c.GetInt64("type")
  9469. admin_user_id, _ := c.GetInt64("admin_user_id")
  9470. adminUser := c.GetAdminUserInfo()
  9471. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9472. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9473. var user_name string
  9474. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9475. if role.ID == 0 {
  9476. user_name = "xxx"
  9477. } else {
  9478. user_name = role.UserName
  9479. }
  9480. psn_record, _ := service.GetPsnRecordById(id)
  9481. if psn_record.ID == 0 {
  9482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9483. return
  9484. }
  9485. if config.IsOpen == 1 {
  9486. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9487. var dat map[string]interface{}
  9488. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9489. fmt.Println(dat)
  9490. } else {
  9491. fmt.Println(err)
  9492. }
  9493. userJSONBytes, _ := json.Marshal(dat)
  9494. var res ResultFourteen
  9495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9496. utils.ErrorLog("解析失败:%v", err)
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. if res.Infcode == 0 {
  9501. psn_record.IsCancel = 2
  9502. service.CreatePsnRecord(&psn_record)
  9503. } else {
  9504. c.ServeSuccessJSON(map[string]interface{}{
  9505. "failed_code": -10,
  9506. "msg": res.ErrMsg,
  9507. })
  9508. return
  9509. }
  9510. }
  9511. }
  9512. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9513. patient_id, _ := c.GetInt64("patient_id")
  9514. insutype_two := c.GetString("insutype")
  9515. psn_no := c.GetString("psn_no")
  9516. doctor_id, _ := c.GetInt64("doctor_id")
  9517. sick_id, _ := c.GetInt64("sick_id")
  9518. department_id, _ := c.GetInt64("department_id")
  9519. start_time := c.GetString("start_time")
  9520. end_time := c.GetString("end_time")
  9521. check_time := c.GetString("check_time")
  9522. adminUser := c.GetAdminUserInfo()
  9523. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9524. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9525. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9526. sick, _ := service.FindSickById(sick_id)
  9527. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9528. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9529. var res ResultTwo
  9530. var res10265 ResultTwo10265
  9531. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9532. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9533. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9534. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9535. "&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
  9536. resp, requestErr := http.Get(api)
  9537. if requestErr != nil {
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. return
  9540. }
  9541. body, ioErr := ioutil.ReadAll(resp.Body)
  9542. if ioErr != nil {
  9543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. var respJSON map[string]interface{}
  9548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9551. return
  9552. }
  9553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9554. result, _ := json.Marshal(respJSON)
  9555. fmt.Println("log")
  9556. fmt.Println(string(result))
  9557. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9558. utils.ErrorLog("解析失败:%v", err)
  9559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9560. return
  9561. }
  9562. res.ErrMsg = res10265.ErrMsg
  9563. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9564. res.Infcode = infocode
  9565. res.Output = res10265.Output
  9566. res.InfRefmsgid = res10265.InfRefmsgid
  9567. } else {
  9568. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9569. if miConfig.Code == "H15049901371" {
  9570. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9571. utils.ErrorLog("解析失败:%v", err)
  9572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9573. return
  9574. }
  9575. res.ErrMsg = res10265.ErrMsg
  9576. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9577. res.Infcode = infocode
  9578. res.Output = res10265.Output
  9579. res.InfRefmsgid = res10265.InfRefmsgid
  9580. } else {
  9581. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9582. utils.ErrorLog("解析失败:%v", err)
  9583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9584. return
  9585. }
  9586. }
  9587. }
  9588. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9589. infoStr := string(Iinfos)
  9590. var rf []*ResultFive
  9591. json.Unmarshal([]byte(infoStr), &rf)
  9592. var insuplc_admdvs string
  9593. var insutype string
  9594. var is390 int = 0
  9595. var is310 int = 0
  9596. var insutypes []*ResultFive
  9597. for _, item := range rf {
  9598. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9599. insutypes = append(insutypes, item)
  9600. }
  9601. }
  9602. if len(insutypes) == 1 {
  9603. insutype = insutypes[0].Insutype
  9604. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9605. } else {
  9606. for _, i := range insutypes {
  9607. if i.Insutype == "390" {
  9608. is390 = 1
  9609. }
  9610. if i.Insutype == "310" {
  9611. is310 = 1
  9612. }
  9613. }
  9614. }
  9615. if is390 == 1 {
  9616. insutype = "390"
  9617. }
  9618. if is310 == 1 {
  9619. insutype = "310"
  9620. }
  9621. if len(insutypes) == 2 {
  9622. insutype = insutype_two
  9623. }
  9624. if len(insutypes) == 0 {
  9625. insutype = "310"
  9626. }
  9627. insutype = insutype_two
  9628. fmt.Println(insutype)
  9629. for _, item := range rf {
  9630. fmt.Println(item.Insutype)
  9631. fmt.Println(insutype)
  9632. if item.Insutype == insutype {
  9633. fmt.Println(item.Insutype)
  9634. fmt.Println(insutype)
  9635. insuplc_admdvs = item.InsuplcAdmdvs
  9636. }
  9637. }
  9638. fmt.Println(insuplc_admdvs)
  9639. var res2 ResultThirteen
  9640. var res10265_2 ResultThirteen10265
  9641. if config.IsOpen == 1 {
  9642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9643. } else {
  9644. 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)
  9645. var dat map[string]interface{}
  9646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9647. fmt.Println(dat)
  9648. } else {
  9649. fmt.Println(err)
  9650. }
  9651. userJSONBytes, _ := json.Marshal(dat)
  9652. if miConfig.Code == "H15049901371" {
  9653. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9654. utils.ErrorLog("解析失败:%v", err)
  9655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9656. return
  9657. }
  9658. res2.ErrMsg = res10265_2.ErrMsg
  9659. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9660. res2.Infcode = infocode
  9661. res2.Output = res10265_2.Output
  9662. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9663. } else {
  9664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9665. utils.ErrorLog("解析失败:%v", err)
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9667. return
  9668. }
  9669. }
  9670. }
  9671. if res2.Infcode == 0 {
  9672. psnResult := &models.GdybPsnNcdsRecord{
  9673. UserOrgId: adminUser.CurrentOrgId,
  9674. PatientId: patient.ID,
  9675. PsnNo: psn_no,
  9676. DoctorId: doctor.AdminUserId,
  9677. DepartmentId: department_id,
  9678. SickType: sick_id,
  9679. Insutype: insutype,
  9680. Ctime: time.Now().Unix(),
  9681. Mtime: time.Now().Unix(),
  9682. Status: 1,
  9683. IsCancel: 1,
  9684. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9685. }
  9686. service.CreatePsnNCDSRecord(psnResult)
  9687. c.ServeSuccessJSON(map[string]interface{}{
  9688. "failed_code": 0,
  9689. "msg": "备案成功",
  9690. "result": psnResult,
  9691. })
  9692. } else {
  9693. c.ServeSuccessJSON(map[string]interface{}{
  9694. "failed_code": -10,
  9695. "msg": res2.ErrMsg,
  9696. })
  9697. return
  9698. }
  9699. }
  9700. }
  9701. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9702. id, _ := c.GetInt64("id")
  9703. admin_user_id, _ := c.GetInt64("admin_user_id")
  9704. adminUser := c.GetAdminUserInfo()
  9705. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9706. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9707. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9708. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9709. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9710. //var user_name string
  9711. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9712. //if role.ID == 0 {
  9713. // user_name = "xxx"
  9714. //} else {
  9715. // user_name = role.UserName
  9716. //}
  9717. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9718. if psn_record.ID == 0 {
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9720. return
  9721. }
  9722. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9723. var res ResultTwo
  9724. var res10265 ResultTwo10265
  9725. if miConfig.Code == "H15049901371" {
  9726. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9727. utils.ErrorLog("解析失败:%v", err)
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9729. return
  9730. }
  9731. res.ErrMsg = res10265.ErrMsg
  9732. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9733. res.Infcode = infocode
  9734. res.Output = res10265.Output
  9735. res.InfRefmsgid = res10265.InfRefmsgid
  9736. } else {
  9737. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9738. utils.ErrorLog("解析失败:%v", err)
  9739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9740. return
  9741. }
  9742. }
  9743. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9744. infoStr := string(Iinfos)
  9745. var rf []*ResultFive
  9746. json.Unmarshal([]byte(infoStr), &rf)
  9747. var insuplc_admdvs string
  9748. var insutype string
  9749. var is390 int = 0
  9750. var is310 int = 0
  9751. var insutypes []*ResultFive
  9752. for _, item := range rf {
  9753. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9754. insutypes = append(insutypes, item)
  9755. }
  9756. }
  9757. if len(insutypes) == 1 {
  9758. insutype = insutypes[0].Insutype
  9759. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9760. } else {
  9761. for _, i := range insutypes {
  9762. if i.Insutype == "390" {
  9763. is390 = 1
  9764. }
  9765. if i.Insutype == "310" {
  9766. is310 = 1
  9767. }
  9768. }
  9769. }
  9770. if is390 == 1 {
  9771. insutype = "390"
  9772. }
  9773. if is310 == 1 {
  9774. insutype = "310"
  9775. }
  9776. if len(insutypes) == 0 {
  9777. insutype = "310"
  9778. }
  9779. insutype = psn_record.Insutype
  9780. for _, item := range rf {
  9781. if item.Insutype == insutype {
  9782. insuplc_admdvs = item.InsuplcAdmdvs
  9783. }
  9784. }
  9785. if config.IsOpen == 1 {
  9786. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9787. var dat map[string]interface{}
  9788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9789. fmt.Println(dat)
  9790. } else {
  9791. fmt.Println(err)
  9792. }
  9793. userJSONBytes, _ := json.Marshal(dat)
  9794. var res ResultFourteen
  9795. var res10265 ResultFourteen10265
  9796. if miConfig.Code == "H15049901371" {
  9797. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9798. utils.ErrorLog("解析失败:%v", err)
  9799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9800. return
  9801. }
  9802. res.ErrMsg = res10265.ErrMsg
  9803. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9804. res.Infcode = infocode
  9805. res.Output = res10265.Output
  9806. res.InfRefmsgid = res10265.InfRefmsgid
  9807. } else {
  9808. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9809. utils.ErrorLog("解析失败:%v", err)
  9810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9811. return
  9812. }
  9813. }
  9814. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9815. // utils.ErrorLog("解析失败:%v", err)
  9816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9817. // return
  9818. //}
  9819. if res.Infcode == 0 {
  9820. psn_record.IsCancel = 2
  9821. service.CreatePsnNCDSRecord(&psn_record)
  9822. c.ServeSuccessJSON(map[string]interface{}{
  9823. "failed_code": 0,
  9824. "msg": "撤销备案成功",
  9825. })
  9826. } else {
  9827. c.ServeSuccessJSON(map[string]interface{}{
  9828. "failed_code": -10,
  9829. "msg": res.ErrMsg,
  9830. })
  9831. return
  9832. }
  9833. }
  9834. }
  9835. func (c *HisApiController) TestTest() {
  9836. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9837. fmt.Println(patient.Iinfo)
  9838. }
  9839. type CustomData struct {
  9840. MsgId string
  9841. PsnNo string
  9842. Info string
  9843. }
  9844. func (c *HisApiController) ReversalData() {
  9845. var customData []*CustomData
  9846. custom := &CustomData{
  9847. MsgId: "H44022900158202103301714472004",
  9848. PsnNo: "44020000001101329945",
  9849. Info: "2207",
  9850. }
  9851. customData = append(customData, custom)
  9852. custom1 := &CustomData{
  9853. MsgId: "H4402290015820210330172057803",
  9854. PsnNo: "44020000001101161813",
  9855. Info: "2207",
  9856. }
  9857. customData = append(customData, custom1)
  9858. custom2 := &CustomData{
  9859. MsgId: "H44022900158202103301705198813",
  9860. PsnNo: "44190000133097375417",
  9861. Info: "2207",
  9862. }
  9863. customData = append(customData, custom2)
  9864. custom3 := &CustomData{
  9865. MsgId: "H44022900158202103301715524756",
  9866. PsnNo: "44020000001100187221",
  9867. Info: "2207",
  9868. }
  9869. customData = append(customData, custom3)
  9870. custom4 := &CustomData{
  9871. MsgId: "H44022900158202103301730376224",
  9872. PsnNo: "44020000001101959155",
  9873. Info: "2207",
  9874. }
  9875. customData = append(customData, custom4)
  9876. custom5 := &CustomData{
  9877. MsgId: "H44022900158202103301748008725",
  9878. PsnNo: "44020000001104246641",
  9879. Info: "2207",
  9880. }
  9881. customData = append(customData, custom5)
  9882. custom6 := &CustomData{
  9883. MsgId: "H44022900158202103301718096755",
  9884. PsnNo: "44020000001102211860",
  9885. Info: "2207",
  9886. }
  9887. customData = append(customData, custom6)
  9888. custom7 := &CustomData{
  9889. MsgId: "H44022900158202103301736551640",
  9890. PsnNo: "44020000001102687718",
  9891. Info: "2207",
  9892. }
  9893. customData = append(customData, custom7)
  9894. custom8 := &CustomData{
  9895. MsgId: "H44022900158202103301743097676",
  9896. PsnNo: "44020000001102127785",
  9897. Info: "2207",
  9898. }
  9899. customData = append(customData, custom8)
  9900. custom9 := &CustomData{
  9901. MsgId: "H44022900158202103301712304203",
  9902. PsnNo: "44020000001101518097",
  9903. Info: "2207",
  9904. }
  9905. customData = append(customData, custom9)
  9906. custom10 := &CustomData{
  9907. MsgId: "H44022900158202103301738448785",
  9908. PsnNo: "44020000001100500813",
  9909. Info: "2207",
  9910. }
  9911. customData = append(customData, custom10)
  9912. custom11 := &CustomData{
  9913. MsgId: "H44022900158202103301732455843",
  9914. PsnNo: "44020000001102690557",
  9915. Info: "2207",
  9916. }
  9917. customData = append(customData, custom11)
  9918. custom12 := &CustomData{
  9919. MsgId: "H44022900158202103301745421708",
  9920. PsnNo: "44020000001102211928",
  9921. Info: "2207",
  9922. }
  9923. customData = append(customData, custom12)
  9924. custom1212 := &CustomData{
  9925. MsgId: "H440229001582021033017351627",
  9926. PsnNo: "44020000001102481733",
  9927. Info: "2207",
  9928. }
  9929. customData = append(customData, custom1212)
  9930. custom13 := &CustomData{
  9931. MsgId: "H44022900158202103301740327951",
  9932. PsnNo: "44020000001103174866",
  9933. Info: "2207",
  9934. }
  9935. customData = append(customData, custom13)
  9936. custom14 := &CustomData{
  9937. MsgId: "H4402290015820210330174922668",
  9938. PsnNo: "44020000001102927272",
  9939. Info: "2207",
  9940. }
  9941. customData = append(customData, custom14)
  9942. custom15 := &CustomData{
  9943. MsgId: "H44022900158202103301752362273",
  9944. PsnNo: "44020000001102942890",
  9945. Info: "2207",
  9946. }
  9947. customData = append(customData, custom15)
  9948. custom16 := &CustomData{
  9949. MsgId: "H44022900158202103301751082917",
  9950. PsnNo: "44020000001101662162",
  9951. Info: "2207",
  9952. }
  9953. customData = append(customData, custom16)
  9954. custom17 := &CustomData{
  9955. MsgId: "H44022900158202103301754147728",
  9956. PsnNo: "44020000000229014511",
  9957. Info: "2207",
  9958. }
  9959. customData = append(customData, custom17)
  9960. adminUser := c.GetAdminUserInfo()
  9961. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9962. for _, item := range customData {
  9963. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9964. fmt.Println(result)
  9965. }
  9966. }
  9967. func (c *HisApiController) GetAllopatry() {
  9968. year := c.GetString("year")
  9969. month := c.GetString("month")
  9970. admin_user_id, _ := c.GetInt64("admin_user_id")
  9971. adminUser := c.GetAdminUserInfo()
  9972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9973. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9974. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9975. var dat map[string]interface{}
  9976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9977. fmt.Println(dat)
  9978. } else {
  9979. fmt.Println(err)
  9980. }
  9981. userJSONBytes, _ := json.Marshal(dat)
  9982. var res models.Result9001
  9983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9984. utils.ErrorLog("解析失败:%v", err)
  9985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9986. return
  9987. }
  9988. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9989. var dat2 map[string]interface{}
  9990. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9991. fmt.Println(dat)
  9992. } else {
  9993. fmt.Println(err)
  9994. }
  9995. userJSONBytes2, _ := json.Marshal(dat2)
  9996. var res2 models.Result3260
  9997. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9998. utils.ErrorLog("解析失败:%v", err)
  9999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. return
  10001. }
  10002. if res2.Infcode == 0 {
  10003. c.ServeSuccessJSON(map[string]interface{}{
  10004. "list": res2.Output.Data,
  10005. })
  10006. return
  10007. } else {
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. }
  10012. func (c *HisApiController) ComfirmAllopatry() {
  10013. year := c.GetString("year")
  10014. month := c.GetString("month")
  10015. admin_user_id, _ := c.GetInt64("admin_user_id")
  10016. adminUser := c.GetAdminUserInfo()
  10017. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10018. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10019. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10020. var dat map[string]interface{}
  10021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10022. fmt.Println(dat)
  10023. } else {
  10024. fmt.Println(err)
  10025. }
  10026. userJSONBytes, _ := json.Marshal(dat)
  10027. var res models.Result9001
  10028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10029. utils.ErrorLog("解析失败:%v", err)
  10030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10031. return
  10032. }
  10033. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10034. var dat2 map[string]interface{}
  10035. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10036. fmt.Println(dat)
  10037. } else {
  10038. fmt.Println(err)
  10039. }
  10040. userJSONBytes2, _ := json.Marshal(dat2)
  10041. var res2 models.Result3260
  10042. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10043. utils.ErrorLog("解析失败:%v", err)
  10044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10045. return
  10046. }
  10047. if res2.Infcode == 0 {
  10048. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10049. var dat map[string]interface{}
  10050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10051. fmt.Println(dat)
  10052. } else {
  10053. fmt.Println(err)
  10054. }
  10055. userJSONBytes, _ := json.Marshal(dat)
  10056. var res3 models.Result3261
  10057. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10058. utils.ErrorLog("解析失败:%v", err)
  10059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10060. return
  10061. }
  10062. if res3.Infcode == 0 {
  10063. record := &models.HisYidiClearRecord{
  10064. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10065. Ctime: time.Now().Unix(),
  10066. Mtime: time.Now().Unix(),
  10067. Status: 1,
  10068. MsgId: msgId,
  10069. }
  10070. service.SaveClearRecord(record)
  10071. c.ServeSuccessJSON(map[string]interface{}{
  10072. "msg": "提取成功",
  10073. })
  10074. }
  10075. }
  10076. }
  10077. func (c *HisApiController) RefundAllopatry() {
  10078. year := c.GetString("year")
  10079. month := c.GetString("month")
  10080. id, _ := c.GetInt64("id")
  10081. admin_user_id, _ := c.GetInt64("admin_user_id")
  10082. adminUser := c.GetAdminUserInfo()
  10083. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10084. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10085. record, _ := service.GetClearRecordById(id)
  10086. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10087. var dat map[string]interface{}
  10088. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10089. fmt.Println(dat)
  10090. } else {
  10091. fmt.Println(err)
  10092. }
  10093. userJSONBytes, _ := json.Marshal(dat)
  10094. var empty ResultFourteen
  10095. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10096. utils.ErrorLog("解析失败:%v", err)
  10097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10098. return
  10099. }
  10100. if empty.Infcode == 0 {
  10101. c.ServeSuccessJSON(map[string]interface{}{
  10102. "msg": "撤销成功",
  10103. })
  10104. return
  10105. }
  10106. }
  10107. func (c *HisApiController) ReversalOtherData() {
  10108. var customData []*CustomData
  10109. custom := &CustomData{
  10110. MsgId: "H44022900158202103301714472004",
  10111. PsnNo: "44020000001101329945",
  10112. Info: "2208",
  10113. }
  10114. customData = append(customData, custom)
  10115. custom1 := &CustomData{
  10116. MsgId: "H4402290015820210330172057803",
  10117. PsnNo: "44020000001101161813",
  10118. Info: "2208",
  10119. }
  10120. customData = append(customData, custom1)
  10121. custom2 := &CustomData{
  10122. MsgId: "H44022900158202103301705198813",
  10123. PsnNo: "44190000133097375417",
  10124. Info: "2208",
  10125. }
  10126. customData = append(customData, custom2)
  10127. custom3 := &CustomData{
  10128. MsgId: "H44022900158202103301715524756",
  10129. PsnNo: "44020000001100187221",
  10130. Info: "2208",
  10131. }
  10132. customData = append(customData, custom3)
  10133. custom4 := &CustomData{
  10134. MsgId: "H44022900158202103301730376224",
  10135. PsnNo: "44020000001101959155",
  10136. Info: "2208",
  10137. }
  10138. customData = append(customData, custom4)
  10139. custom5 := &CustomData{
  10140. MsgId: "H44022900158202103301748008725",
  10141. PsnNo: "44020000001104246641",
  10142. Info: "2208",
  10143. }
  10144. customData = append(customData, custom5)
  10145. custom6 := &CustomData{
  10146. MsgId: "H44022900158202103301718096755",
  10147. PsnNo: "44020000001102211860",
  10148. Info: "2208",
  10149. }
  10150. customData = append(customData, custom6)
  10151. custom7 := &CustomData{
  10152. MsgId: "H44022900158202103301736551640",
  10153. PsnNo: "44020000001102687718",
  10154. Info: "2208",
  10155. }
  10156. customData = append(customData, custom7)
  10157. custom8 := &CustomData{
  10158. MsgId: "H44022900158202103301743097676",
  10159. PsnNo: "44020000001102127785",
  10160. Info: "2208",
  10161. }
  10162. customData = append(customData, custom8)
  10163. custom9 := &CustomData{
  10164. MsgId: "H44022900158202103301712304203",
  10165. PsnNo: "44020000001101518097",
  10166. Info: "2208",
  10167. }
  10168. customData = append(customData, custom9)
  10169. custom10 := &CustomData{
  10170. MsgId: "H44022900158202103301738448785",
  10171. PsnNo: "44020000001100500813",
  10172. Info: "2208",
  10173. }
  10174. customData = append(customData, custom10)
  10175. custom11 := &CustomData{
  10176. MsgId: "H44022900158202103301732455843",
  10177. PsnNo: "44020000001102690557",
  10178. Info: "2208",
  10179. }
  10180. customData = append(customData, custom11)
  10181. custom12 := &CustomData{
  10182. MsgId: "H44022900158202103301745421708",
  10183. PsnNo: "44020000001102211928",
  10184. Info: "2208",
  10185. }
  10186. customData = append(customData, custom12)
  10187. custom1212 := &CustomData{
  10188. MsgId: "H440229001582021033017351627",
  10189. PsnNo: "44020000001102481733",
  10190. Info: "2208",
  10191. }
  10192. customData = append(customData, custom1212)
  10193. custom13 := &CustomData{
  10194. MsgId: "H44022900158202103301740327951",
  10195. PsnNo: "44020000001103174866",
  10196. Info: "2208",
  10197. }
  10198. customData = append(customData, custom13)
  10199. custom14 := &CustomData{
  10200. MsgId: "H4402290015820210330174922668",
  10201. PsnNo: "44020000001102927272",
  10202. Info: "2208",
  10203. }
  10204. customData = append(customData, custom14)
  10205. custom15 := &CustomData{
  10206. MsgId: "H44022900158202103301752362273",
  10207. PsnNo: "44020000001102942890",
  10208. Info: "2208",
  10209. }
  10210. customData = append(customData, custom15)
  10211. custom16 := &CustomData{
  10212. MsgId: "H44022900158202103301751082917",
  10213. PsnNo: "44020000001101662162",
  10214. Info: "2208",
  10215. }
  10216. customData = append(customData, custom16)
  10217. custom17 := &CustomData{
  10218. MsgId: "H44022900158202103301754147728",
  10219. PsnNo: "44020000000229014511",
  10220. Info: "2208",
  10221. }
  10222. customData = append(customData, custom17)
  10223. adminUser := c.GetAdminUserInfo()
  10224. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10225. for _, item := range customData {
  10226. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10227. fmt.Println(result)
  10228. }
  10229. }
  10230. func PathExists(path string) (bool, error) {
  10231. _, err := os.Stat(path)
  10232. if err == nil {
  10233. return true, nil
  10234. }
  10235. if os.IsNotExist(err) {
  10236. return false, nil
  10237. }
  10238. return false, err
  10239. }
  10240. //创建文件夹
  10241. func Mkdir(dir string) {
  10242. // 创建文件夹
  10243. exist, err := PathExists(dir)
  10244. if err != nil {
  10245. fmt.Println(err.Error())
  10246. } else {
  10247. if exist {
  10248. fmt.Println(dir + "文件夹已存在!")
  10249. } else {
  10250. // 文件夹名称,权限
  10251. err := os.Mkdir(dir, os.ModePerm)
  10252. if err != nil {
  10253. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10254. } else {
  10255. fmt.Println(dir + "文件夹创建成功!")
  10256. }
  10257. }
  10258. }
  10259. }
  10260. //压缩文件
  10261. func Zip(srcFile string, destZip string) error {
  10262. zipfile, err := os.Create(destZip)
  10263. if err != nil {
  10264. return err
  10265. }
  10266. defer zipfile.Close()
  10267. archive := zip.NewWriter(zipfile)
  10268. defer archive.Close()
  10269. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10270. if err != nil {
  10271. return err
  10272. }
  10273. header, err := zip.FileInfoHeader(info)
  10274. if err != nil {
  10275. return err
  10276. }
  10277. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10278. // header.Name = path
  10279. if info.IsDir() {
  10280. header.Name += "/"
  10281. } else {
  10282. header.Method = zip.Deflate
  10283. }
  10284. writer, err := archive.CreateHeader(header)
  10285. if err != nil {
  10286. return err
  10287. }
  10288. if !info.IsDir() {
  10289. file, err := os.Open(path)
  10290. if err != nil {
  10291. return err
  10292. }
  10293. defer file.Close()
  10294. _, err = io.Copy(writer, file)
  10295. }
  10296. return err
  10297. })
  10298. return err
  10299. }
  10300. func ReadFile(filePath string) []byte {
  10301. f, err := os.Open(filePath)
  10302. if err != nil {
  10303. fmt.Println("read file fail", err)
  10304. return nil
  10305. }
  10306. defer f.Close()
  10307. fd, err := ioutil.ReadAll(f)
  10308. if err != nil {
  10309. fmt.Println("read to fd fail", err)
  10310. return nil
  10311. }
  10312. return fd
  10313. }
  10314. func saveLog(result string, request string, infno string, desc string) {
  10315. org_id, _ := beego.AppConfig.Int64("org_id")
  10316. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10317. dir := miConfig.OrgName + "日志"
  10318. utils.Mkdir(dir)
  10319. month := time.Unix(1557042972, 0).Format("1")
  10320. year := time.Now().Format("2006")
  10321. month = time.Now().Format("01")
  10322. day := time.Now().Format("02")
  10323. hour := time.Now().Format("15")
  10324. min := time.Now().Format("04")
  10325. sec := time.Now().Format("05")
  10326. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10327. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10328. file_name := file + ".txt"
  10329. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10330. exist, _ := utils.PathExists(file_path)
  10331. if exist { //存在
  10332. fmt.Println("存在")
  10333. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10334. if err != nil {
  10335. fmt.Println("read fail")
  10336. }
  10337. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10338. n, _ := f.Seek(0, 2)
  10339. _, err = f.WriteAt([]byte(content), n)
  10340. } else { //不存在
  10341. fmt.Println("文件不存在,创建文件")
  10342. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10343. defer f.Close()
  10344. if err != nil {
  10345. } else {
  10346. _, err = f.Write([]byte("记录日志"))
  10347. }
  10348. }
  10349. }
  10350. type Charset string
  10351. const (
  10352. UTF8 = Charset("UTF-8")
  10353. GB18030 = Charset("GB18030")
  10354. )
  10355. func ConvertToString(src string, srcCode string, tagCode string) string {
  10356. srcCoder := mahonia.NewDecoder(srcCode)
  10357. srcResult := srcCoder.ConvertString(src)
  10358. tagCoder := mahonia.NewDecoder(tagCode)
  10359. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10360. result := string(cdata)
  10361. return result
  10362. }