his_api_controller.go 456KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1082. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1083. fmt.Println(api)
  1084. } else {
  1085. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1086. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1273. saveLog(result, requestLog, "1101", "获取人员信息")
  1274. fmt.Println(errMsgLog)
  1275. var dat map[string]interface{}
  1276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1277. fmt.Println(dat)
  1278. } else {
  1279. fmt.Println(err)
  1280. }
  1281. userJSONBytes, _ := json.Marshal(dat)
  1282. var res ResultTwo
  1283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1284. utils.ErrorLog("解析失败:%v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. res.ErrMsg = errMsgLog
  1289. if res.Infcode == 0 {
  1290. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1291. if err == gorm.ErrRecordNotFound {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1293. return
  1294. } else if err != nil {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1296. return
  1297. } else {
  1298. fmt.Println(res)
  1299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1301. infoStr := string(Iinfos)
  1302. idetinfoStr := string(Idetinfos)
  1303. psn := &models.HisPsn{
  1304. PsnNo: res.Output.Baseinfo.PsnNo,
  1305. Age: res.Output.Baseinfo.Age,
  1306. PatientId: patient.ID,
  1307. Certno: res.Output.Baseinfo.Certno,
  1308. Brdy: res.Output.Baseinfo.Brdy,
  1309. Gend: res.Output.Baseinfo.Gend,
  1310. Naty: res.Output.Baseinfo.Naty,
  1311. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1312. PsnName: res.Output.Baseinfo.PsnName,
  1313. Idetinfo: idetinfoStr,
  1314. Insuinfo: infoStr,
  1315. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1316. CardInfo: basStr,
  1317. VerifyNumber: "",
  1318. }
  1319. service.CreateHisPsn(psn)
  1320. var rf []*ResultFive
  1321. json.Unmarshal([]byte(infoStr), &rf)
  1322. var insutypes []*ResultFive
  1323. var insutype string
  1324. var is390 int = 0
  1325. var is310 int = 0
  1326. for _, item := range rf {
  1327. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1328. insutypes = append(insutypes, item)
  1329. }
  1330. }
  1331. if len(insutypes) == 1 {
  1332. insutype = insutypes[0].Insutype
  1333. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1334. } else {
  1335. for _, i := range insutypes {
  1336. if i.Insutype == "390" {
  1337. is390 = 1
  1338. }
  1339. if i.Insutype == "310" {
  1340. is310 = 1
  1341. }
  1342. }
  1343. }
  1344. if is390 == 1 {
  1345. insutype = "390"
  1346. }
  1347. if is310 == 1 {
  1348. insutype = "310"
  1349. }
  1350. if len(insutypes) == 0 {
  1351. insutype = "310"
  1352. }
  1353. c.ServeSuccessJSON(map[string]interface{}{
  1354. "patient": patient,
  1355. "number": cardnum,
  1356. "insutype": insutype,
  1357. })
  1358. }
  1359. } else {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1361. return
  1362. }
  1363. } else {
  1364. if initFlag == 0 {
  1365. c.TestGetBasBaseInit()
  1366. }
  1367. basStr := c.GetBasBaseInfo()
  1368. if len(basStr) == 0 {
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1370. return
  1371. }
  1372. fmt.Println(basStr)
  1373. bas := strings.Split(basStr, "|")
  1374. basNumber := bas[1]
  1375. fmt.Println(basNumber)
  1376. card_sn := bas[3]
  1377. fmt.Println(card_sn)
  1378. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1379. var dat map[string]interface{}
  1380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1381. fmt.Println(dat)
  1382. } else {
  1383. fmt.Println(err)
  1384. }
  1385. userJSONBytes, _ := json.Marshal(dat)
  1386. var res ResultTwo
  1387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1388. utils.ErrorLog("解析失败:%v", err)
  1389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. return
  1391. }
  1392. if res.Infcode == 0 {
  1393. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1394. if err == gorm.ErrRecordNotFound {
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1396. return
  1397. } else if err != nil {
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1399. return
  1400. } else {
  1401. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1402. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1403. infoStr := string(Iinfos)
  1404. idetinfoStr := string(Idetinfos)
  1405. psn := &models.HisPsn{
  1406. PsnNo: res.Output.Baseinfo.PsnNo,
  1407. Age: res.Output.Baseinfo.Age,
  1408. PatientId: patient.ID,
  1409. Certno: res.Output.Baseinfo.Certno,
  1410. Brdy: res.Output.Baseinfo.Brdy,
  1411. Gend: res.Output.Baseinfo.Gend,
  1412. Naty: res.Output.Baseinfo.Naty,
  1413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1414. PsnName: res.Output.Baseinfo.PsnName,
  1415. Idetinfo: idetinfoStr,
  1416. Insuinfo: infoStr,
  1417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1418. CardInfo: basStr,
  1419. VerifyNumber: "",
  1420. }
  1421. service.CreateHisPsn(psn)
  1422. c.ServeSuccessJSON(map[string]interface{}{
  1423. "patient": patient,
  1424. "number": basNumber,
  1425. })
  1426. }
  1427. } else {
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1429. return
  1430. }
  1431. break
  1432. }
  1433. case 2:
  1434. SFZStr := c.GetSFZBaseInfo()
  1435. id_card_str := strings.Split(SFZStr, "^")
  1436. id_card_number := id_card_str[0]
  1437. card_sn := ""
  1438. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1439. var dat map[string]interface{}
  1440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1441. fmt.Println(dat)
  1442. } else {
  1443. fmt.Println(err)
  1444. }
  1445. userJSONBytes, _ := json.Marshal(dat)
  1446. var res ResultTwo
  1447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1448. utils.ErrorLog("解析失败:%v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. if res.Infcode == 0 {
  1453. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1454. if err == gorm.ErrRecordNotFound {
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1456. return
  1457. } else if err != nil {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1459. return
  1460. } else {
  1461. c.ServeSuccessJSON(map[string]interface{}{
  1462. "patient": patient,
  1463. "number": id_card_number,
  1464. })
  1465. }
  1466. } else {
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1468. return
  1469. }
  1470. break
  1471. case 3:
  1472. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1473. var api string
  1474. if miConfig.MdtrtareaAdmvs == "320921" {
  1475. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1476. "&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
  1477. fmt.Println(api)
  1478. } else {
  1479. 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 +
  1480. "&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)
  1481. }
  1482. resp, requestErr := http.Get(api)
  1483. if requestErr != nil {
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1485. return
  1486. }
  1487. body, ioErr := ioutil.ReadAll(resp.Body)
  1488. if ioErr != nil {
  1489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. return
  1492. }
  1493. var respJSON map[string]interface{}
  1494. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. var status string
  1500. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1501. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1502. var token string
  1503. var res ResultTwo //1101结果
  1504. var res10265 ResultTwo10265 //1101结果
  1505. var card_info string //卡信息
  1506. var busi_card_info string
  1507. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1508. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1509. if status == "0" { //读卡成功
  1510. if card_type == "1" {
  1511. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1512. result, _ := json.Marshal(respJSON)
  1513. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1514. utils.ErrorLog("解析失败:%v", err)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. res.ErrMsg = res10265.ErrMsg
  1519. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1520. res.Infcode = infocode
  1521. res.Output = res10265.Output
  1522. res.InfRefmsgid = res10265.InfRefmsgid
  1523. } else {
  1524. //var card_info string //卡信息
  1525. //var busi_card_info string
  1526. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1527. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1528. //fmt.Println(card_info)
  1529. //fmt.Println(busi_card_info)
  1530. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1531. result, _ := json.Marshal(respJSON)
  1532. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1533. utils.ErrorLog("解析失败:%v", err)
  1534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1535. return
  1536. }
  1537. res.ErrMsg = res10265.ErrMsg
  1538. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1539. res.Infcode = infocode
  1540. res.Output = res10265.Output
  1541. res.InfRefmsgid = res10265.InfRefmsgid
  1542. }
  1543. if res.Infcode == 0 {
  1544. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1545. if err == gorm.ErrRecordNotFound {
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1547. return
  1548. } else if err != nil {
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1550. return
  1551. } else {
  1552. if card_type == "1" {
  1553. bas := strings.Split(card_info, "|")
  1554. basNumber := bas[2]
  1555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1557. infoStr := string(Iinfos)
  1558. idetinfoStr := string(Idetinfos)
  1559. psn := &models.HisPsn{
  1560. PsnNo: res.Output.Baseinfo.PsnNo,
  1561. Age: res.Output.Baseinfo.Age,
  1562. PatientId: patient.ID,
  1563. Certno: res.Output.Baseinfo.Certno,
  1564. Brdy: res.Output.Baseinfo.Brdy,
  1565. Gend: res.Output.Baseinfo.Gend,
  1566. Naty: res.Output.Baseinfo.Naty,
  1567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1568. PsnName: res.Output.Baseinfo.PsnName,
  1569. Idetinfo: idetinfoStr,
  1570. Insuinfo: infoStr,
  1571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1572. CardInfo: card_info,
  1573. VerifyNumber: busi_card_info,
  1574. }
  1575. service.CreateHisPsn(psn)
  1576. c.ServeSuccessJSON(map[string]interface{}{
  1577. "patient": patient,
  1578. "number": basNumber,
  1579. })
  1580. } else {
  1581. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1582. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1583. infoStr := string(Iinfos)
  1584. idetinfoStr := string(Idetinfos)
  1585. psn := &models.HisPsn{
  1586. PsnNo: res.Output.Baseinfo.PsnNo,
  1587. Age: res.Output.Baseinfo.Age,
  1588. PatientId: patient.ID,
  1589. Certno: res.Output.Baseinfo.Certno,
  1590. Brdy: res.Output.Baseinfo.Brdy,
  1591. Gend: res.Output.Baseinfo.Gend,
  1592. Naty: res.Output.Baseinfo.Naty,
  1593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1594. PsnName: res.Output.Baseinfo.PsnName,
  1595. Idetinfo: idetinfoStr,
  1596. Insuinfo: infoStr,
  1597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1598. CardInfo: card_info,
  1599. VerifyNumber: token,
  1600. }
  1601. service.CreateHisPsn(psn)
  1602. var rf []*ResultFive
  1603. json.Unmarshal([]byte(infoStr), &rf)
  1604. var insutypes []*ResultFive
  1605. var insutype string
  1606. var is390 int = 0
  1607. var is310 int = 0
  1608. for _, item := range rf {
  1609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1610. insutypes = append(insutypes, item)
  1611. }
  1612. }
  1613. if len(insutypes) == 1 {
  1614. insutype = insutypes[0].Insutype
  1615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1616. } else {
  1617. for _, i := range insutypes {
  1618. if i.Insutype == "390" {
  1619. is390 = 1
  1620. }
  1621. if i.Insutype == "310" {
  1622. is310 = 1
  1623. }
  1624. }
  1625. }
  1626. if is390 == 1 {
  1627. insutype = "390"
  1628. }
  1629. if is310 == 1 {
  1630. insutype = "310"
  1631. }
  1632. if len(insutypes) == 0 {
  1633. insutype = "310"
  1634. }
  1635. c.ServeSuccessJSON(map[string]interface{}{
  1636. "patient": patient,
  1637. "number": token,
  1638. "insutype": insutype,
  1639. })
  1640. }
  1641. }
  1642. } else {
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1644. return
  1645. }
  1646. } else { //读卡失败
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1648. return
  1649. }
  1650. }
  1651. break
  1652. case 4:
  1653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1654. var api string
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1657. "&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
  1658. fmt.Println(api)
  1659. } else {
  1660. 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 +
  1661. "&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)
  1662. }
  1663. resp, requestErr := http.Get(api)
  1664. if requestErr != nil {
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. body, ioErr := ioutil.ReadAll(resp.Body)
  1669. if ioErr != nil {
  1670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. return
  1673. }
  1674. var respJSON map[string]interface{}
  1675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1678. return
  1679. }
  1680. var status string
  1681. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1682. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1683. var token string
  1684. var res ResultTwo //1101结果
  1685. var res10265 ResultTwo10265 //1101结果
  1686. if status == "0" { //读卡成功
  1687. var card_info string //卡信息
  1688. var busi_card_info string
  1689. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1690. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1691. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1692. fmt.Println(card_info)
  1693. fmt.Println(busi_card_info)
  1694. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1695. result, _ := json.Marshal(respJSON)
  1696. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1697. utils.ErrorLog("解析失败:%v", err)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. return
  1700. }
  1701. res.ErrMsg = res10265.ErrMsg
  1702. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1703. res.Infcode = infocode
  1704. res.Output = res10265.Output
  1705. res.InfRefmsgid = res10265.InfRefmsgid
  1706. if res.Infcode == 0 {
  1707. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1708. if err == gorm.ErrRecordNotFound {
  1709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1710. return
  1711. } else if err != nil {
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1713. return
  1714. } else {
  1715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1717. infoStr := string(Iinfos)
  1718. idetinfoStr := string(Idetinfos)
  1719. psn := &models.HisPsn{
  1720. PsnNo: res.Output.Baseinfo.PsnNo,
  1721. Age: res.Output.Baseinfo.Age,
  1722. PatientId: patient.ID,
  1723. Certno: res.Output.Baseinfo.Certno,
  1724. Brdy: res.Output.Baseinfo.Brdy,
  1725. Gend: res.Output.Baseinfo.Gend,
  1726. Naty: res.Output.Baseinfo.Naty,
  1727. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1728. PsnName: res.Output.Baseinfo.PsnName,
  1729. Idetinfo: idetinfoStr,
  1730. Insuinfo: infoStr,
  1731. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1732. CardInfo: card_info,
  1733. VerifyNumber: token,
  1734. }
  1735. service.CreateHisPsn(psn)
  1736. c.ServeSuccessJSON(map[string]interface{}{
  1737. "patient": patient,
  1738. "number": token,
  1739. })
  1740. }
  1741. } else {
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1743. return
  1744. }
  1745. } else { //读卡失败
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1747. return
  1748. }
  1749. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1750. }
  1751. break
  1752. }
  1753. }
  1754. var initFlag int64 = 0
  1755. func (c *HisApiController) TestGetBasBaseInit() {
  1756. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1757. Iinit := DllDef.MustFindProc("Init")
  1758. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1759. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1760. if ret != 0 {
  1761. fmt.Println("SSCard的报错原因:", err)
  1762. fmt.Println("SSCard的运算结果为:", ret)
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1764. return
  1765. }
  1766. result := int(ret)
  1767. fmt.Println("SSCard的运算结果为1:", result)
  1768. initFlag = 1
  1769. return
  1770. }
  1771. func (c *HisApiController) GetSFZBaseInfo() string {
  1772. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1773. readCard := DllDef.MustFindProc("ReadSFZ")
  1774. if readCard == nil {
  1775. fmt.Println("readcard is nil")
  1776. readCard = DllDef.MustFindProc("ReadSFZ")
  1777. }
  1778. str := make([]byte, 256)
  1779. str1 := make([]byte, 256)
  1780. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1781. fmt.Println(r)
  1782. return string(str)
  1783. }
  1784. func (c *HisApiController) GetBasBaseInfo() string {
  1785. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1786. readCard := DllDef.MustFindProc("ReadCardBas")
  1787. if readCard == nil {
  1788. fmt.Println("readcard is nil")
  1789. readCard = DllDef.MustFindProc("ReadCardBas")
  1790. }
  1791. str := make([]byte, 1024)
  1792. str1 := make([]byte, 1024)
  1793. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1794. fmt.Println(string(str1))
  1795. fmt.Println(string(str))
  1796. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1797. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1798. if ret2 != 0 {
  1799. return ""
  1800. }
  1801. return string(str)
  1802. }
  1803. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1804. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1805. readCard := DllDef.MustFindProc("read_cardinfo")
  1806. if readCard == nil {
  1807. fmt.Println("readcard is nil")
  1808. readCard = DllDef.MustFindProc("read_cardinfo")
  1809. }
  1810. str := make([]byte, 1024) //卡号
  1811. str1 := make([]byte, 1024) //卡识别码
  1812. str2 := make([]byte, 1024) //身份证号
  1813. str3 := make([]byte, 1024) //姓名
  1814. str4 := make([]byte, 1024) //错误信息
  1815. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1816. fmt.Println(string(str1))
  1817. fmt.Println(string(str))
  1818. fmt.Println(string(str2))
  1819. fmt.Println(string(str3))
  1820. fmt.Println(string(str4))
  1821. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1822. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1823. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1824. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1825. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1826. if ret2 != 0 {
  1827. return "", "", "", "", ""
  1828. }
  1829. return string(str), string(str1), string(str2), string(str3), string(str4)
  1830. }
  1831. type CustomFundPay struct {
  1832. FundPayType string `json:"fund_pay_type"`
  1833. FundPayamt float64 `json:"fund_payamt"`
  1834. }
  1835. func (c *HisApiController) GetSettleList() {
  1836. order_id, _ := c.GetInt64("order_id")
  1837. admin_user_id, _ := c.GetInt64("admin_user_id")
  1838. order, _ := service.GetHisOrderByIDTwo(order_id)
  1839. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1840. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1841. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1842. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1843. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1845. if order.ID == 0 {
  1846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1847. return
  1848. }
  1849. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1850. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1851. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1852. fmt.Println(count)
  1853. var zero string
  1854. number := count + 1
  1855. if number >= 1000 {
  1856. zero = "0000" + strconv.FormatInt(number, 10)
  1857. } else if number >= 10000 {
  1858. zero = "000" + strconv.FormatInt(number, 10)
  1859. } else if number >= 100000 {
  1860. zero = "00" + strconv.FormatInt(number, 10)
  1861. } else if number >= 1000000 {
  1862. zero = "0" + strconv.FormatInt(number, 10)
  1863. } else {
  1864. zero = strconv.FormatInt(number, 10)
  1865. }
  1866. fmt.Println(zero)
  1867. struct4101 := service.Struct4101{
  1868. PsnNo: order.PsnNo,
  1869. MdtrtId: order.MdtrtId,
  1870. SetlId: order.SetlId,
  1871. PsnName: order.PsnName,
  1872. Gend: order.Gend,
  1873. Brdy: his.Brdy,
  1874. Age: his.Age,
  1875. Naty: order.Naty,
  1876. PatnCertType: "01",
  1877. Certno: order.Certno,
  1878. Prfs: "90",
  1879. ConerName: roles[0].UserName,
  1880. PatnRlts: "99",
  1881. ConerAddr: miConfig.OrgName,
  1882. ConerTel: admin.Mobile,
  1883. HiType: order.Insutype,
  1884. Insuplc: miConfig.InsuplcAdmdvs,
  1885. MaindiagFlag: "1",
  1886. BillCode: last_order.FaPiaoCode,
  1887. BillNo: zero,
  1888. BizSn: order.Number,
  1889. PsnSelfPay: order.PsnPartAmt,
  1890. PsnOwnPay: order.PsnPartAmt,
  1891. AcctPay: order.AcctPay,
  1892. PsnCashpay: order.PsnCashPay,
  1893. HiPaymtd: "1",
  1894. Hsorg: miConfig.InsuplcAdmdvs,
  1895. HsorgOpter: miConfig.InsuplcAdmdvs,
  1896. MedinsFillPsn: curRoles.UserName,
  1897. MedinsFillDept: depart.Name,
  1898. IptMedType: "2",
  1899. }
  1900. struct4101.SetlBegnDate = order.SetlTime
  1901. struct4101.SetlEndDate = order.SetlTime
  1902. time_arr := strings.Split(order.SetlTime, " ")
  1903. struct4101.AdmTime = time_arr[0]
  1904. struct4101.AdmEndTime = time_arr[0]
  1905. var rf []CustomFundPay
  1906. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1907. var tempFunPays []service.CustomStruct
  1908. for _, item := range rf {
  1909. var tempFunPay service.CustomStruct
  1910. tempFunPay.FundPayamt = item.FundPayamt
  1911. tempFunPay.FundPayType = item.FundPayType
  1912. tempFunPays = append(tempFunPays, tempFunPay)
  1913. }
  1914. struct4101.CustomStruct = tempFunPays
  1915. var tempDiaginfos []service.DiaginfoStructTwo
  1916. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1917. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1918. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1919. var config []*models.HisXtDiagnoseConfig
  1920. for _, item := range diagnosis_ids {
  1921. id, _ := strconv.ParseInt(item, 10, 64)
  1922. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1923. config = append(config, &diagnosisConfig)
  1924. }
  1925. for index, item := range config {
  1926. if index == 0 {
  1927. var tempDiaginfo service.DiaginfoStructTwo
  1928. tempDiaginfo.DiagCode = item.CountryCode
  1929. tempDiaginfo.DiagName = item.CountryContentName
  1930. tempDiaginfo.DiagType = "1"
  1931. tempDiaginfo.MaindiagFlag = "1"
  1932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1933. } else {
  1934. var tempDiaginfo service.DiaginfoStructTwo
  1935. tempDiaginfo.DiagCode = item.CountryCode
  1936. tempDiaginfo.DiagName = item.CountryContentName
  1937. tempDiaginfo.DiagType = "2"
  1938. tempDiaginfo.MaindiagFlag = "0"
  1939. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1940. }
  1941. }
  1942. struct4101.Diseinfo = tempDiaginfos
  1943. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1944. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1945. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1946. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1947. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1948. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1949. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1950. var iteminfo service.IteminfoStruct
  1951. var bedCostTotal float64 = 0 //床位总费
  1952. var bedCostSelfTotal float64 = 0 //床位自费
  1953. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1954. var operationCostTotal float64 = 0 //手术费
  1955. var operationCostSelfTotal float64 = 0 //手术费
  1956. var operationCostPartSelfTotal float64 = 0 //手术费
  1957. var otherCostTotal float64 = 0 //其他费用
  1958. var otherCostSelfTotal float64 = 0 //其他费用
  1959. var otherCostPartSelfTotal float64 = 0 //其他费用
  1960. var materialCostTotal float64 = 0 //材料费
  1961. var materialCostSelfTotal float64 = 0 //材料费
  1962. var materialCostPartSelfTotal float64 = 0 //材料费
  1963. var westernMedicineCostTotal float64 = 0 //西药费
  1964. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1965. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1966. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1967. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1968. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1969. var checkCostTotal float64 = 0 //检查费
  1970. var checkCostSelfTotal float64 = 0 //检查费
  1971. var checkCostPartSelfTotal float64 = 0 //检查费
  1972. var laboratoryCostTotal float64 = 0 //化验费
  1973. var laboratoryCostSelfTotal float64 = 0 //化验费
  1974. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1975. var treatCostTotal float64 = 0 //治疗费用
  1976. var treatCostSelfTotal float64 = 0 //治疗费用
  1977. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1978. decimal.DivisionPrecision = 2
  1979. var bed_fulamt_ownpay_amt float64 = 0
  1980. var operation_fulamt_ownpay_amt float64 = 0
  1981. var other_fulamt_ownpay_amt float64 = 0
  1982. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1983. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1984. var check_fulamt_ownpay_amt float64 = 0
  1985. var material_fulamt_ownpay_amt float64 = 0
  1986. var laboratory_fulamt_ownpay_amt float64 = 0
  1987. var treat_fulamt_ownpay_amt float64 = 0
  1988. var bed_claa_sunmfee float64 = 0
  1989. var bed_clab_amt float64 = 0
  1990. var bed_other_amt float64 = 0
  1991. var operation_claa_sunmfee float64 = 0
  1992. var operation_clab_amt float64 = 0
  1993. var operation_other_amt float64 = 0
  1994. var other_claa_sunmfee float64 = 0
  1995. var other_clab_amt float64 = 0
  1996. var other_other_amt float64 = 0
  1997. var westernMedicine_claa_sunmfee float64 = 0
  1998. var westernMedicine_clab_amt float64 = 0
  1999. var westernMedicine_other_amt float64 = 0
  2000. var chineseTraditional_claa_sunmfee float64 = 0
  2001. var chineseTraditional_clab_amt float64 = 0
  2002. var chineseTraditional_other_amt float64 = 0
  2003. var check_claa_sunmfee float64 = 0
  2004. var check_clab_amt float64 = 0
  2005. var check_other_amt float64 = 0
  2006. var material_claa_sunmfee float64 = 0
  2007. var material_clab_amt float64 = 0
  2008. var material_other_amt float64 = 0
  2009. var laboratory_claa_sunmfee float64 = 0
  2010. var laboratory_clab_amt float64 = 0
  2011. var laboratory_other_amt float64 = 0
  2012. var treat_claa_sunmfee float64 = 0
  2013. var treat_clab_amt float64 = 0
  2014. var treat_other_amt float64 = 0
  2015. for _, item := range order.HisOrderInfo {
  2016. if item.MedChrgitmType == "01" { //床位费
  2017. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2018. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2019. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2020. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2021. if item.ChrgitmLv == "1" {
  2022. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2023. }
  2024. if item.ChrgitmLv == "2" {
  2025. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2026. }
  2027. if item.ChrgitmLv == "3" {
  2028. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2029. }
  2030. }
  2031. if item.MedChrgitmType == "03" { //检查费
  2032. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2033. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2034. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2035. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2036. if item.ChrgitmLv == "1" {
  2037. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2038. }
  2039. if item.ChrgitmLv == "2" {
  2040. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2041. }
  2042. if item.ChrgitmLv == "3" {
  2043. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2044. }
  2045. }
  2046. if item.MedChrgitmType == "04" { //化验费
  2047. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2048. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2049. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2050. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2051. if item.ChrgitmLv == "1" {
  2052. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2053. }
  2054. if item.ChrgitmLv == "2" {
  2055. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2056. }
  2057. if item.ChrgitmLv == "3" {
  2058. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2059. }
  2060. }
  2061. if item.MedChrgitmType == "05" { //治疗费
  2062. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2063. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2064. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2065. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2066. if item.ChrgitmLv == "1" {
  2067. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2068. }
  2069. if item.ChrgitmLv == "2" {
  2070. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2071. }
  2072. if item.ChrgitmLv == "3" {
  2073. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2074. }
  2075. }
  2076. if item.MedChrgitmType == "06" { //手术费
  2077. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2078. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2079. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2080. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2081. if item.ChrgitmLv == "1" {
  2082. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2083. }
  2084. if item.ChrgitmLv == "2" {
  2085. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2086. }
  2087. if item.ChrgitmLv == "3" {
  2088. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2089. }
  2090. }
  2091. if item.MedChrgitmType == "08" { //材料费
  2092. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2093. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2094. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2095. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2096. if item.ChrgitmLv == "1" {
  2097. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2098. }
  2099. if item.ChrgitmLv == "2" {
  2100. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2101. }
  2102. if item.ChrgitmLv == "3" {
  2103. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2104. }
  2105. }
  2106. if item.MedChrgitmType == "09" { //西药费
  2107. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2108. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2109. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2110. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2111. if item.ChrgitmLv == "1" {
  2112. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2113. }
  2114. if item.ChrgitmLv == "2" {
  2115. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2116. }
  2117. if item.ChrgitmLv == "3" {
  2118. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2119. }
  2120. }
  2121. if item.MedChrgitmType == "11" { //中成费
  2122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2126. if item.ChrgitmLv == "1" {
  2127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2128. }
  2129. if item.ChrgitmLv == "2" {
  2130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2131. }
  2132. if item.ChrgitmLv == "3" {
  2133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2134. }
  2135. }
  2136. if item.MedChrgitmType == "14" { //其他费
  2137. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2138. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2139. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2141. if item.ChrgitmLv == "1" {
  2142. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2143. }
  2144. if item.ChrgitmLv == "2" {
  2145. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2146. }
  2147. if item.ChrgitmLv == "3" {
  2148. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2149. }
  2150. }
  2151. }
  2152. var iteminfoStructs []service.IteminfoStruct
  2153. if bedCostTotal != 0 {
  2154. iteminfo.MedChrgitm = "01"
  2155. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2156. iteminfo.Amt = bedCostTotal
  2157. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2158. iteminfo.ClabAmt = bed_clab_amt
  2159. iteminfo.OthAmt = bed_other_amt
  2160. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2161. }
  2162. if checkCostTotal != 0 {
  2163. iteminfo.MedChrgitm = "03"
  2164. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2165. iteminfo.Amt = checkCostTotal
  2166. iteminfo.ClaaSumfee = check_claa_sunmfee
  2167. iteminfo.ClabAmt = check_clab_amt
  2168. iteminfo.OthAmt = check_other_amt
  2169. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2170. }
  2171. if laboratoryCostTotal != 0 {
  2172. iteminfo.MedChrgitm = "04"
  2173. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2174. iteminfo.Amt = laboratoryCostTotal
  2175. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2176. iteminfo.ClabAmt = laboratory_clab_amt
  2177. iteminfo.OthAmt = laboratory_other_amt
  2178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2180. }
  2181. if treatCostTotal != 0 {
  2182. iteminfo.MedChrgitm = "05"
  2183. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2184. iteminfo.Amt = treatCostTotal
  2185. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2186. iteminfo.ClabAmt = treat_clab_amt
  2187. iteminfo.OthAmt = treat_other_amt
  2188. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2189. //(struct4101.IteminfoStruct, iteminfo)
  2190. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2191. }
  2192. if operationCostTotal != 0 {
  2193. iteminfo.MedChrgitm = "06"
  2194. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2195. iteminfo.Amt = operationCostTotal
  2196. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2197. iteminfo.ClabAmt = operation_clab_amt
  2198. iteminfo.OthAmt = operation_other_amt
  2199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2201. }
  2202. if materialCostTotal != 0 {
  2203. iteminfo.MedChrgitm = "08"
  2204. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2205. iteminfo.Amt = materialCostTotal
  2206. iteminfo.ClaaSumfee = material_claa_sunmfee
  2207. iteminfo.ClabAmt = material_clab_amt
  2208. iteminfo.OthAmt = material_other_amt
  2209. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2211. }
  2212. if westernMedicineCostTotal != 0 {
  2213. iteminfo.MedChrgitm = "09"
  2214. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2215. iteminfo.Amt = westernMedicineCostTotal
  2216. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2217. iteminfo.ClabAmt = westernMedicine_clab_amt
  2218. iteminfo.OthAmt = westernMedicine_other_amt
  2219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2221. }
  2222. if chineseTraditionalMedicineCostTotal != 0 {
  2223. iteminfo.MedChrgitm = "11"
  2224. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2225. iteminfo.Amt = westernMedicineCostTotal
  2226. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2227. iteminfo.ClabAmt = westernMedicine_clab_amt
  2228. iteminfo.OthAmt = westernMedicine_other_amt
  2229. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2230. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2231. }
  2232. if otherCostTotal != 0 {
  2233. iteminfo.MedChrgitm = "14"
  2234. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2235. iteminfo.Amt = otherCostTotal
  2236. iteminfo.ClaaSumfee = other_claa_sunmfee
  2237. iteminfo.ClabAmt = other_clab_amt
  2238. iteminfo.OthAmt = other_other_amt
  2239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2241. }
  2242. struct4101.IteminfoStruct = iteminfoStructs
  2243. struct4101.Ntly = "中国"
  2244. struct4101.AdmCaty = "A03.06"
  2245. var res ResultSeventeen
  2246. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2247. var resOther ResultSeventeenOther
  2248. var pp models.PublicParams
  2249. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2251. pp.FixmedinsName = miConfig.OrgName
  2252. pp.FixmedinsCode = miConfig.Code
  2253. pp.RequestUrl = miConfig.Url
  2254. pp.Cainfo = miConfig.Cainfo
  2255. pp.SecretKey = miConfig.SecretKey
  2256. pp.AccessKey = miConfig.AccessKey
  2257. pp.OpterName = curRoles.UserName
  2258. client := &http.Client{}
  2259. var req *http.Request
  2260. data := make(map[string]interface{})
  2261. data["struct4101"] = struct4101
  2262. data["pp"] = pp
  2263. bytesData, _ := json.Marshal(data)
  2264. if miConfig.MdtrtareaAdmvs == "320921" {
  2265. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2266. } else {
  2267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2268. }
  2269. resp, _ := client.Do(req)
  2270. defer resp.Body.Close()
  2271. body, ioErr := ioutil.ReadAll(resp.Body)
  2272. if ioErr != nil {
  2273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. var respJSON map[string]interface{}
  2278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. return
  2282. }
  2283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2284. userJSONBytes, _ := json.Marshal(respJSON)
  2285. fmt.Println("log")
  2286. fmt.Println(string(userJSONBytes))
  2287. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2288. utils.ErrorLog("解析失败:%v", err)
  2289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. return
  2291. }
  2292. res.InfRefmsgid = resOther.InfRefmsgid
  2293. res.Output = resOther.Output
  2294. res.ErrMsg = resOther.ErrMsg
  2295. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2296. res.Infcode = infocode
  2297. } else {
  2298. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2299. var dat map[string]interface{}
  2300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2301. fmt.Println(dat)
  2302. } else {
  2303. fmt.Println(err)
  2304. }
  2305. userJSONBytes, _ := json.Marshal(dat)
  2306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2307. utils.ErrorLog("解析失败:%v", err)
  2308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2309. return
  2310. }
  2311. }
  2312. if res.Infcode != 0 {
  2313. c.ServeSuccessJSON(map[string]interface{}{
  2314. "failed_code": -10,
  2315. "msg": res.ErrMsg,
  2316. })
  2317. return
  2318. } else {
  2319. order.FaPiaoNumber = zero
  2320. order.FaPiaoCode = last_order.FaPiaoCode
  2321. service.UpdateOrder(order)
  2322. hisFundSettleListResult := &models.HisFundSettleListResult{
  2323. Number: res.Output.SetlListId,
  2324. Status: 1,
  2325. Ctime: time.Now().Unix(),
  2326. Mtime: time.Now().Unix(),
  2327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2328. IsUpload: 1,
  2329. OrderId: order_id,
  2330. }
  2331. service.CreateUploadRecord(hisFundSettleListResult)
  2332. c.ServeSuccessJSON(map[string]interface{}{
  2333. "msg": "上传成功",
  2334. "result": hisFundSettleListResult,
  2335. })
  2336. return
  2337. }
  2338. }
  2339. func (c *HisApiController) GetSettleListHospital() {
  2340. order_id, _ := c.GetInt64("order_id")
  2341. admin_user_id, _ := c.GetInt64("admin_user_id")
  2342. order, _ := service.GetHisOrderByIDTwo(order_id)
  2343. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2344. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2345. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2346. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2347. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2348. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2349. if order.ID == 0 {
  2350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2351. return
  2352. }
  2353. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2354. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2355. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2356. fmt.Println(count)
  2357. var zero string
  2358. number := count + 1
  2359. if number >= 1000 {
  2360. zero = "0000" + strconv.FormatInt(number, 10)
  2361. } else if number >= 10000 {
  2362. zero = "000" + strconv.FormatInt(number, 10)
  2363. } else if number >= 100000 {
  2364. zero = "00" + strconv.FormatInt(number, 10)
  2365. } else if number >= 1000000 {
  2366. zero = "0" + strconv.FormatInt(number, 10)
  2367. } else {
  2368. zero = strconv.FormatInt(number, 10)
  2369. }
  2370. fmt.Println(zero)
  2371. struct4101 := service.Struct4101{
  2372. PsnNo: order.PsnNo,
  2373. MdtrtId: order.MdtrtId,
  2374. SetlId: order.SetlId,
  2375. PsnName: order.PsnName,
  2376. Gend: order.Gend,
  2377. Brdy: his.Brdy,
  2378. Age: int64(order.Age),
  2379. Naty: order.Naty,
  2380. PatnCertType: "01",
  2381. Certno: order.Certno,
  2382. Prfs: "90",
  2383. ConerName: roles[0].UserName,
  2384. PatnRlts: "99",
  2385. ConerAddr: miConfig.OrgName,
  2386. ConerTel: admin.Mobile,
  2387. HiType: order.Insutype,
  2388. Insuplc: miConfig.InsuplcAdmdvs,
  2389. MaindiagFlag: "1",
  2390. BillCode: last_order.FaPiaoCode,
  2391. BillNo: zero,
  2392. BizSn: order.Number,
  2393. PsnSelfPay: order.PsnPartAmt,
  2394. PsnOwnPay: order.PsnPartAmt,
  2395. AcctPay: order.AcctPay,
  2396. PsnCashpay: order.PsnCashPay,
  2397. HiPaymtd: "1",
  2398. Hsorg: miConfig.InsuplcAdmdvs,
  2399. HsorgOpter: miConfig.InsuplcAdmdvs,
  2400. MedinsFillPsn: curRoles.UserName,
  2401. MedinsFillDept: depart.Name,
  2402. IptMedType: "2",
  2403. AdmTime: his.InHosptialTime,
  2404. AdmEndTime: his.OutHosptialTime,
  2405. }
  2406. struct4101.SetlBegnDate = order.SetlTime
  2407. struct4101.SetlEndDate = order.SetlTime
  2408. var rf []CustomFundPay
  2409. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2410. var tempFunPays []service.CustomStruct
  2411. for _, item := range rf {
  2412. var tempFunPay service.CustomStruct
  2413. tempFunPay.FundPayamt = item.FundPayamt
  2414. tempFunPay.FundPayType = item.FundPayType
  2415. tempFunPays = append(tempFunPays, tempFunPay)
  2416. }
  2417. struct4101.CustomStruct = tempFunPays
  2418. var tempDiaginfos []service.DiaginfoStructTwo
  2419. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2420. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2421. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2422. var config []*models.HisXtDiagnoseConfig
  2423. for _, item := range diagnosis_ids {
  2424. id, _ := strconv.ParseInt(item, 10, 64)
  2425. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2426. config = append(config, &diagnosisConfig)
  2427. }
  2428. for index, item := range config {
  2429. if index == 0 {
  2430. var tempDiaginfo service.DiaginfoStructTwo
  2431. tempDiaginfo.DiagCode = item.CountryCode
  2432. tempDiaginfo.DiagName = item.CountryContentName
  2433. tempDiaginfo.DiagType = "1"
  2434. tempDiaginfo.MaindiagFlag = "1"
  2435. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2436. } else {
  2437. var tempDiaginfo service.DiaginfoStructTwo
  2438. tempDiaginfo.DiagCode = item.CountryCode
  2439. tempDiaginfo.DiagName = item.CountryContentName
  2440. tempDiaginfo.DiagType = "2"
  2441. tempDiaginfo.MaindiagFlag = "0"
  2442. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2443. }
  2444. }
  2445. struct4101.Diseinfo = tempDiaginfos
  2446. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2447. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2448. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2449. tempOpspdiseinfo2.OprnOprtCode = ""
  2450. tempOpspdiseinfo2.OprnOprtName = ""
  2451. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2452. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2453. var iteminfo service.IteminfoStruct
  2454. var bedCostTotal float64 = 0 //床位总费
  2455. var bedCostSelfTotal float64 = 0 //床位自费
  2456. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2457. var operationCostTotal float64 = 0 //手术费
  2458. var operationCostSelfTotal float64 = 0 //手术费
  2459. var operationCostPartSelfTotal float64 = 0 //手术费
  2460. var otherCostTotal float64 = 0 //其他费用
  2461. var otherCostSelfTotal float64 = 0 //其他费用
  2462. var otherCostPartSelfTotal float64 = 0 //其他费用
  2463. var materialCostTotal float64 = 0 //材料费
  2464. var materialCostSelfTotal float64 = 0 //材料费
  2465. var materialCostPartSelfTotal float64 = 0 //材料费
  2466. var westernMedicineCostTotal float64 = 0 //西药费
  2467. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2468. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2469. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2470. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2471. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2472. var checkCostTotal float64 = 0 //检查费
  2473. var checkCostSelfTotal float64 = 0 //检查费
  2474. var checkCostPartSelfTotal float64 = 0 //检查费
  2475. var laboratoryCostTotal float64 = 0 //化验费
  2476. var laboratoryCostSelfTotal float64 = 0 //化验费
  2477. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2478. var treatCostTotal float64 = 0 //治疗费用
  2479. var treatCostSelfTotal float64 = 0 //治疗费用
  2480. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2481. decimal.DivisionPrecision = 2
  2482. var bed_fulamt_ownpay_amt float64 = 0
  2483. var operation_fulamt_ownpay_amt float64 = 0
  2484. var other_fulamt_ownpay_amt float64 = 0
  2485. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2486. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2487. var check_fulamt_ownpay_amt float64 = 0
  2488. var material_fulamt_ownpay_amt float64 = 0
  2489. var laboratory_fulamt_ownpay_amt float64 = 0
  2490. var treat_fulamt_ownpay_amt float64 = 0
  2491. var bed_claa_sunmfee float64 = 0
  2492. var bed_clab_amt float64 = 0
  2493. var bed_other_amt float64 = 0
  2494. var operation_claa_sunmfee float64 = 0
  2495. var operation_clab_amt float64 = 0
  2496. var operation_other_amt float64 = 0
  2497. var other_claa_sunmfee float64 = 0
  2498. var other_clab_amt float64 = 0
  2499. var other_other_amt float64 = 0
  2500. var westernMedicine_claa_sunmfee float64 = 0
  2501. var westernMedicine_clab_amt float64 = 0
  2502. var westernMedicine_other_amt float64 = 0
  2503. var chineseTraditional_claa_sunmfee float64 = 0
  2504. var chineseTraditional_clab_amt float64 = 0
  2505. var chineseTraditional_other_amt float64 = 0
  2506. var check_claa_sunmfee float64 = 0
  2507. var check_clab_amt float64 = 0
  2508. var check_other_amt float64 = 0
  2509. var material_claa_sunmfee float64 = 0
  2510. var material_clab_amt float64 = 0
  2511. var material_other_amt float64 = 0
  2512. var laboratory_claa_sunmfee float64 = 0
  2513. var laboratory_clab_amt float64 = 0
  2514. var laboratory_other_amt float64 = 0
  2515. var treat_claa_sunmfee float64 = 0
  2516. var treat_clab_amt float64 = 0
  2517. var treat_other_amt float64 = 0
  2518. for _, item := range order.HisOrderInfo {
  2519. if item.MedChrgitmType == "01" { //床位费
  2520. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2521. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2522. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2523. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2524. if item.ChrgitmLv == "1" {
  2525. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2526. }
  2527. if item.ChrgitmLv == "2" {
  2528. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2529. }
  2530. if item.ChrgitmLv == "3" {
  2531. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2532. }
  2533. }
  2534. if item.MedChrgitmType == "03" { //检查费
  2535. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2536. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2537. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2538. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2539. if item.ChrgitmLv == "1" {
  2540. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2541. }
  2542. if item.ChrgitmLv == "2" {
  2543. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2544. }
  2545. if item.ChrgitmLv == "3" {
  2546. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2547. }
  2548. }
  2549. if item.MedChrgitmType == "04" { //化验费
  2550. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2551. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2552. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2553. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2554. if item.ChrgitmLv == "1" {
  2555. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2556. }
  2557. if item.ChrgitmLv == "2" {
  2558. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2559. }
  2560. if item.ChrgitmLv == "3" {
  2561. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2562. }
  2563. }
  2564. if item.MedChrgitmType == "05" { //治疗费
  2565. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2566. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2567. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2568. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2569. if item.ChrgitmLv == "1" {
  2570. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2571. }
  2572. if item.ChrgitmLv == "2" {
  2573. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2574. }
  2575. if item.ChrgitmLv == "3" {
  2576. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2577. }
  2578. }
  2579. if item.MedChrgitmType == "06" { //手术费
  2580. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2581. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2582. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2583. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2584. if item.ChrgitmLv == "1" {
  2585. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2586. }
  2587. if item.ChrgitmLv == "2" {
  2588. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2589. }
  2590. if item.ChrgitmLv == "3" {
  2591. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2592. }
  2593. }
  2594. if item.MedChrgitmType == "08" { //材料费
  2595. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2596. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2597. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2598. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2599. if item.ChrgitmLv == "1" {
  2600. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2601. }
  2602. if item.ChrgitmLv == "2" {
  2603. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2604. }
  2605. if item.ChrgitmLv == "3" {
  2606. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2607. }
  2608. }
  2609. if item.MedChrgitmType == "09" { //西药费
  2610. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2611. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2612. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2613. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2614. if item.ChrgitmLv == "1" {
  2615. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2616. }
  2617. if item.ChrgitmLv == "2" {
  2618. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2619. }
  2620. if item.ChrgitmLv == "3" {
  2621. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2622. }
  2623. }
  2624. if item.MedChrgitmType == "11" { //中成费
  2625. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2626. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2627. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2628. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2629. if item.ChrgitmLv == "1" {
  2630. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2631. }
  2632. if item.ChrgitmLv == "2" {
  2633. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2634. }
  2635. if item.ChrgitmLv == "3" {
  2636. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2637. }
  2638. }
  2639. if item.MedChrgitmType == "14" { //其他费
  2640. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2641. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2642. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2644. if item.ChrgitmLv == "1" {
  2645. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2646. }
  2647. if item.ChrgitmLv == "2" {
  2648. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2649. }
  2650. if item.ChrgitmLv == "3" {
  2651. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2652. }
  2653. }
  2654. }
  2655. var iteminfoStructs []service.IteminfoStruct
  2656. if bedCostTotal != 0 {
  2657. iteminfo.MedChrgitm = "01"
  2658. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2659. iteminfo.Amt = bedCostTotal
  2660. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2661. iteminfo.ClabAmt = bed_clab_amt
  2662. iteminfo.OthAmt = bed_other_amt
  2663. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2664. }
  2665. if checkCostTotal != 0 {
  2666. iteminfo.MedChrgitm = "03"
  2667. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2668. iteminfo.Amt = checkCostTotal
  2669. iteminfo.ClaaSumfee = check_claa_sunmfee
  2670. iteminfo.ClabAmt = check_clab_amt
  2671. iteminfo.OthAmt = check_other_amt
  2672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2673. }
  2674. if laboratoryCostTotal != 0 {
  2675. iteminfo.MedChrgitm = "04"
  2676. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2677. iteminfo.Amt = laboratoryCostTotal
  2678. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2679. iteminfo.ClabAmt = laboratory_clab_amt
  2680. iteminfo.OthAmt = laboratory_other_amt
  2681. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2682. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2683. }
  2684. if treatCostTotal != 0 {
  2685. iteminfo.MedChrgitm = "05"
  2686. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2687. iteminfo.Amt = treatCostTotal
  2688. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2689. iteminfo.ClabAmt = treat_clab_amt
  2690. iteminfo.OthAmt = treat_other_amt
  2691. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2692. //(struct4101.IteminfoStruct, iteminfo)
  2693. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2694. }
  2695. if operationCostTotal != 0 {
  2696. iteminfo.MedChrgitm = "06"
  2697. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2698. iteminfo.Amt = operationCostTotal
  2699. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2700. iteminfo.ClabAmt = operation_clab_amt
  2701. iteminfo.OthAmt = operation_other_amt
  2702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2704. }
  2705. if materialCostTotal != 0 {
  2706. iteminfo.MedChrgitm = "08"
  2707. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2708. iteminfo.Amt = materialCostTotal
  2709. iteminfo.ClaaSumfee = material_claa_sunmfee
  2710. iteminfo.ClabAmt = material_clab_amt
  2711. iteminfo.OthAmt = material_other_amt
  2712. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2714. }
  2715. if westernMedicineCostTotal != 0 {
  2716. iteminfo.MedChrgitm = "09"
  2717. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2718. iteminfo.Amt = westernMedicineCostTotal
  2719. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2720. iteminfo.ClabAmt = westernMedicine_clab_amt
  2721. iteminfo.OthAmt = westernMedicine_other_amt
  2722. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2724. }
  2725. if chineseTraditionalMedicineCostTotal != 0 {
  2726. iteminfo.MedChrgitm = "11"
  2727. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2728. iteminfo.Amt = westernMedicineCostTotal
  2729. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2730. iteminfo.ClabAmt = westernMedicine_clab_amt
  2731. iteminfo.OthAmt = westernMedicine_other_amt
  2732. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2734. }
  2735. if otherCostTotal != 0 {
  2736. iteminfo.MedChrgitm = "14"
  2737. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2738. iteminfo.Amt = otherCostTotal
  2739. iteminfo.ClaaSumfee = other_claa_sunmfee
  2740. iteminfo.ClabAmt = other_clab_amt
  2741. iteminfo.OthAmt = other_other_amt
  2742. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2744. }
  2745. struct4101.IteminfoStruct = iteminfoStructs
  2746. struct4101.Ntly = "中国"
  2747. struct4101.AdmCaty = "A03.06"
  2748. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2749. fmt.Println(result)
  2750. var dat map[string]interface{}
  2751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2752. fmt.Println(dat)
  2753. } else {
  2754. fmt.Println(err)
  2755. }
  2756. userJSONBytes, _ := json.Marshal(dat)
  2757. var res ResultSeventeen
  2758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2759. utils.ErrorLog("解析失败:%v", err)
  2760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2761. return
  2762. }
  2763. if res.Infcode != 0 {
  2764. c.ServeSuccessJSON(map[string]interface{}{
  2765. "failed_code": -10,
  2766. "msg": res.ErrMsg,
  2767. })
  2768. return
  2769. } else {
  2770. order.FaPiaoNumber = zero
  2771. order.FaPiaoCode = last_order.FaPiaoCode
  2772. service.UpdateOrder(order)
  2773. hisFundSettleListResult := &models.HisFundSettleListResult{
  2774. Number: res.Output.SetlListId,
  2775. Status: 1,
  2776. Ctime: time.Now().Unix(),
  2777. Mtime: time.Now().Unix(),
  2778. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2779. IsUpload: 1,
  2780. OrderId: order_id,
  2781. }
  2782. service.CreateUploadRecord(hisFundSettleListResult)
  2783. c.ServeSuccessJSON(map[string]interface{}{
  2784. "msg": "上传成功",
  2785. "result": hisFundSettleListResult,
  2786. })
  2787. return
  2788. }
  2789. }
  2790. func (c *HisApiController) GetBatchSettleList() {
  2791. orders, _ := service.GetAllHisOrder(10106)
  2792. for _, item := range orders {
  2793. order_id := item.ID
  2794. order, _ := service.GetHisOrderByIDTwo(order_id)
  2795. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2796. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2797. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2798. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2799. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2800. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2801. if order.ID == 0 {
  2802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2803. return
  2804. }
  2805. if his.BalanceAccountsType == 2 {
  2806. continue
  2807. }
  2808. struct4101 := service.Struct4101{
  2809. PsnNo: order.PsnNo,
  2810. MdtrtId: order.MdtrtId,
  2811. SetlId: order.SetlId,
  2812. PsnName: order.PsnName,
  2813. Gend: order.Gend,
  2814. Brdy: his.Brdy,
  2815. Age: his.Age,
  2816. Naty: order.Naty,
  2817. PatnCertType: "01",
  2818. Certno: order.Certno,
  2819. Prfs: "90",
  2820. ConerName: roles[0].UserName,
  2821. PatnRlts: "99",
  2822. ConerAddr: miConfig.OrgName,
  2823. ConerTel: admin.Mobile,
  2824. HiType: order.Insutype,
  2825. Insuplc: his.InsuplcAdmdvs,
  2826. MaindiagFlag: "1",
  2827. BillCode: order.FaPiaoCode,
  2828. BillNo: order.FaPiaoNumber,
  2829. BizSn: order.Number,
  2830. PsnSelfPay: order.PsnPartAmt,
  2831. PsnOwnPay: order.PsnPartAmt,
  2832. AcctPay: order.AcctPay,
  2833. PsnCashpay: order.PsnCashPay,
  2834. HiPaymtd: "1",
  2835. Hsorg: his.InsuplcAdmdvs,
  2836. HsorgOpter: his.InsuplcAdmdvs,
  2837. MedinsFillPsn: curRoles.UserName,
  2838. MedinsFillDept: depart.Name,
  2839. IptMedType: "2",
  2840. }
  2841. struct4101.SetlBegnDate = order.SetlTime
  2842. struct4101.SetlEndDate = order.SetlTime
  2843. //if order.SettleType == 1 {
  2844. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2845. // dateStr := t.Format("2006-01-02")
  2846. // struct4101.SetlBegnDate = dateStr
  2847. // struct4101.SetlEndDate = dateStr
  2848. //} else {
  2849. // t := time.Unix(int64(order.SettleStartTime), 0)
  2850. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2851. // dateStartStr := t.Format("2006-01-02")
  2852. // dateEndStr := t2.Format("2006-01-02")
  2853. // struct4101.SetlBegnDate = dateStartStr
  2854. // struct4101.SetlEndDate = dateEndStr
  2855. //}
  2856. var rf []CustomFundPay
  2857. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2858. var tempFunPays []service.CustomStruct
  2859. var tempFunPay610100 service.CustomStruct
  2860. for _, item := range rf {
  2861. if item.FundPayType == "610100" {
  2862. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2863. tempFunPay610100.FundPayType = item.FundPayType
  2864. } else {
  2865. var tempFunPay service.CustomStruct
  2866. tempFunPay.FundPayamt = item.FundPayamt
  2867. tempFunPay.FundPayType = item.FundPayType
  2868. tempFunPays = append(tempFunPays, tempFunPay)
  2869. }
  2870. }
  2871. tempFunPays = append(tempFunPays, tempFunPay610100)
  2872. struct4101.CustomStruct = tempFunPays
  2873. var tempDiaginfos []service.DiaginfoStructTwo
  2874. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2875. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2876. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2877. var config []*models.HisXtDiagnoseConfig
  2878. for _, item := range diagnosis_ids {
  2879. id, _ := strconv.ParseInt(item, 10, 64)
  2880. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2881. config = append(config, &diagnosisConfig)
  2882. }
  2883. for index, item := range config {
  2884. if index == 0 {
  2885. var tempDiaginfo service.DiaginfoStructTwo
  2886. tempDiaginfo.DiagCode = item.CountryCode
  2887. tempDiaginfo.DiagName = item.CountryContentName
  2888. tempDiaginfo.DiagType = "1"
  2889. tempDiaginfo.MaindiagFlag = "1"
  2890. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2891. } else {
  2892. var tempDiaginfo service.DiaginfoStructTwo
  2893. tempDiaginfo.DiagCode = item.CountryCode
  2894. tempDiaginfo.DiagName = item.CountryContentName
  2895. tempDiaginfo.DiagType = "2"
  2896. tempDiaginfo.MaindiagFlag = "0"
  2897. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2898. }
  2899. }
  2900. struct4101.Diseinfo = tempDiaginfos
  2901. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2902. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2903. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2904. tempOpspdiseinfo2.OprnOprtCode = ""
  2905. tempOpspdiseinfo2.OprnOprtName = ""
  2906. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2907. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2908. var iteminfo service.IteminfoStruct
  2909. var bedCostTotal float64 = 0 //床位总费
  2910. var bedCostSelfTotal float64 = 0 //床位自费
  2911. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2912. var examineCostTotal float64 = 0 //诊查总费
  2913. var examineCostSelfTotal float64 = 0 //诊查自费
  2914. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2915. var nursingCostTotal float64 = 0 //护理总费
  2916. var nursingCostSelfTotal float64 = 0 //护理自费
  2917. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2918. var chineseMedicineCostTotal float64 = 0 //中成药
  2919. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2920. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2921. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2922. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2923. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2924. var registerCostTotal float64 = 0 //一般诊疗费
  2925. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2926. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2927. var operationCostTotal float64 = 0 //手术费
  2928. var operationCostSelfTotal float64 = 0 //手术费
  2929. var operationCostPartSelfTotal float64 = 0 //手术费
  2930. var otherCostTotal float64 = 0 //其他费用
  2931. var otherCostSelfTotal float64 = 0 //其他费用
  2932. var otherCostPartSelfTotal float64 = 0 //其他费用
  2933. var materialCostTotal float64 = 0 //材料费
  2934. var materialCostSelfTotal float64 = 0 //材料费
  2935. var materialCostPartSelfTotal float64 = 0 //材料费
  2936. var westernMedicineCostTotal float64 = 0 //西药费
  2937. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2938. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2939. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2940. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2941. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2942. var checkCostTotal float64 = 0 //检查费
  2943. var checkCostSelfTotal float64 = 0 //检查费
  2944. var checkCostPartSelfTotal float64 = 0 //检查费
  2945. var laboratoryCostTotal float64 = 0 //化验费
  2946. var laboratoryCostSelfTotal float64 = 0 //化验费
  2947. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2948. var treatCostTotal float64 = 0 //治疗费用
  2949. var treatCostSelfTotal float64 = 0 //治疗费用
  2950. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2951. decimal.DivisionPrecision = 2
  2952. var bed_fulamt_ownpay_amt float64 = 0
  2953. var examine_fulamt_ownpay_amt float64 = 0
  2954. var nursing_fulamt_ownpay_amt float64 = 0
  2955. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2956. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2957. var register_fulamt_ownpay_amt float64 = 0
  2958. var operation_fulamt_ownpay_amt float64 = 0
  2959. var other_fulamt_ownpay_amt float64 = 0
  2960. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2961. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2962. var check_fulamt_ownpay_amt float64 = 0
  2963. var material_fulamt_ownpay_amt float64 = 0
  2964. var laboratory_fulamt_ownpay_amt float64 = 0
  2965. var treat_fulamt_ownpay_amt float64 = 0
  2966. var bed_claa_sunmfee float64 = 0
  2967. var bed_clab_amt float64 = 0
  2968. var bed_other_amt float64 = 0
  2969. var examine_claa_sunmfee float64 = 0
  2970. var examine_clab_amt float64 = 0
  2971. var examine_other_amt float64 = 0
  2972. var nursing_claa_sunmfee float64 = 0
  2973. var nursing_clab_amt float64 = 0
  2974. var nursing_other_amt float64 = 0
  2975. var chinese_medicine_claa_sunmfee float64 = 0
  2976. var chinese_medicine_clab_amt float64 = 0
  2977. var chinese_medicine_other_amt float64 = 0
  2978. var commonly_treatment_claa_sunmfee float64 = 0
  2979. var commonly_treatment_clab_amt float64 = 0
  2980. var commonly_treatment_other_amt float64 = 0
  2981. var operation_claa_sunmfee float64 = 0
  2982. var operation_clab_amt float64 = 0
  2983. var operation_other_amt float64 = 0
  2984. var other_claa_sunmfee float64 = 0
  2985. var other_clab_amt float64 = 0
  2986. var other_other_amt float64 = 0
  2987. var westernMedicine_claa_sunmfee float64 = 0
  2988. var westernMedicine_clab_amt float64 = 0
  2989. var westernMedicine_other_amt float64 = 0
  2990. var chineseTraditional_claa_sunmfee float64 = 0
  2991. var chineseTraditional_clab_amt float64 = 0
  2992. var chineseTraditional_other_amt float64 = 0
  2993. var check_claa_sunmfee float64 = 0
  2994. var check_clab_amt float64 = 0
  2995. var check_other_amt float64 = 0
  2996. var material_claa_sunmfee float64 = 0
  2997. var material_clab_amt float64 = 0
  2998. var material_other_amt float64 = 0
  2999. var laboratory_claa_sunmfee float64 = 0
  3000. var laboratory_clab_amt float64 = 0
  3001. var laboratory_other_amt float64 = 0
  3002. var treat_claa_sunmfee float64 = 0
  3003. var treat_clab_amt float64 = 0
  3004. var treat_other_amt float64 = 0
  3005. var register_claa_sunmfee float64 = 0
  3006. var register_clab_amt float64 = 0
  3007. var register_other_amt float64 = 0
  3008. for _, item := range order.HisOrderInfo {
  3009. if item.MedChrgitmType == "01" { //床位费
  3010. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3011. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3012. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3013. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3014. if item.ChrgitmLv == "1" {
  3015. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3016. }
  3017. if item.ChrgitmLv == "2" {
  3018. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3019. }
  3020. if item.ChrgitmLv == "3" {
  3021. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3022. }
  3023. }
  3024. if item.MedChrgitmType == "02" { //诊查
  3025. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3026. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3027. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3028. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3029. if item.ChrgitmLv == "1" {
  3030. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3031. }
  3032. if item.ChrgitmLv == "2" {
  3033. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3034. }
  3035. if item.ChrgitmLv == "3" {
  3036. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3037. }
  3038. }
  3039. if item.MedChrgitmType == "03" { //检查费
  3040. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3041. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3042. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3043. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3044. if item.ChrgitmLv == "1" {
  3045. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3046. }
  3047. if item.ChrgitmLv == "2" {
  3048. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3049. }
  3050. if item.ChrgitmLv == "3" {
  3051. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3052. }
  3053. }
  3054. if item.MedChrgitmType == "04" { //化验费
  3055. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3056. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3057. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3058. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3059. if item.ChrgitmLv == "1" {
  3060. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3061. }
  3062. if item.ChrgitmLv == "2" {
  3063. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3064. }
  3065. if item.ChrgitmLv == "3" {
  3066. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3067. }
  3068. }
  3069. if item.MedChrgitmType == "05" { //治疗费
  3070. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3071. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3072. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3073. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3074. if item.ChrgitmLv == "1" {
  3075. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3076. }
  3077. if item.ChrgitmLv == "2" {
  3078. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3079. }
  3080. if item.ChrgitmLv == "3" {
  3081. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3082. }
  3083. }
  3084. if item.MedChrgitmType == "06" { //手术费
  3085. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3086. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3087. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3088. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3089. if item.ChrgitmLv == "1" {
  3090. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3091. }
  3092. if item.ChrgitmLv == "2" {
  3093. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3094. }
  3095. if item.ChrgitmLv == "3" {
  3096. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3097. }
  3098. }
  3099. if item.MedChrgitmType == "07" { //手术费
  3100. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3101. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3102. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3103. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3104. if item.ChrgitmLv == "1" {
  3105. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3106. }
  3107. if item.ChrgitmLv == "2" {
  3108. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3109. }
  3110. if item.ChrgitmLv == "3" {
  3111. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3112. }
  3113. }
  3114. if item.MedChrgitmType == "08" { //材料费
  3115. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3116. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3117. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3118. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3119. if item.ChrgitmLv == "1" {
  3120. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3121. }
  3122. if item.ChrgitmLv == "2" {
  3123. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3124. }
  3125. if item.ChrgitmLv == "3" {
  3126. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3127. }
  3128. }
  3129. if item.MedChrgitmType == "09" { //西药费
  3130. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3131. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3132. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3134. if item.ChrgitmLv == "1" {
  3135. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3136. }
  3137. if item.ChrgitmLv == "2" {
  3138. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3139. }
  3140. if item.ChrgitmLv == "3" {
  3141. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3142. }
  3143. }
  3144. if item.MedChrgitmType == "10" { //中药饮片
  3145. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3146. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3147. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3149. if item.ChrgitmLv == "1" {
  3150. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3151. }
  3152. if item.ChrgitmLv == "2" {
  3153. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3154. }
  3155. if item.ChrgitmLv == "3" {
  3156. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3157. }
  3158. }
  3159. if item.MedChrgitmType == "11" { //中成费
  3160. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3161. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3162. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3164. if item.ChrgitmLv == "1" {
  3165. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3166. }
  3167. if item.ChrgitmLv == "2" {
  3168. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3169. }
  3170. if item.ChrgitmLv == "3" {
  3171. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3172. }
  3173. }
  3174. if item.MedChrgitmType == "12" { //中成费
  3175. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3176. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3177. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3179. if item.ChrgitmLv == "1" {
  3180. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3181. }
  3182. if item.ChrgitmLv == "2" {
  3183. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3184. }
  3185. if item.ChrgitmLv == "3" {
  3186. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3187. }
  3188. }
  3189. if item.MedChrgitmType == "13" { //中成费
  3190. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3191. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3192. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3194. if item.ChrgitmLv == "1" {
  3195. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3196. }
  3197. if item.ChrgitmLv == "2" {
  3198. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3199. }
  3200. if item.ChrgitmLv == "3" {
  3201. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3202. }
  3203. }
  3204. if item.MedChrgitmType == "14" { //其他费
  3205. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3206. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3207. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3209. if item.ChrgitmLv == "1" {
  3210. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3211. }
  3212. if item.ChrgitmLv == "2" {
  3213. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3214. }
  3215. if item.ChrgitmLv == "3" {
  3216. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3217. }
  3218. }
  3219. }
  3220. var iteminfoStructs []service.IteminfoStruct
  3221. if bedCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "01"
  3223. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3224. iteminfo.Amt = bedCostTotal
  3225. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3226. iteminfo.ClabAmt = bed_clab_amt
  3227. iteminfo.OthAmt = bed_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. }
  3230. if examineCostTotal != 0 {
  3231. iteminfo.MedChrgitm = "02"
  3232. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3233. iteminfo.Amt = examineCostTotal
  3234. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3235. iteminfo.ClabAmt = examine_clab_amt
  3236. iteminfo.OthAmt = examine_other_amt
  3237. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3238. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3239. }
  3240. if checkCostTotal != 0 {
  3241. iteminfo.MedChrgitm = "03"
  3242. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3243. iteminfo.Amt = checkCostTotal
  3244. iteminfo.ClaaSumfee = check_claa_sunmfee
  3245. iteminfo.ClabAmt = check_clab_amt
  3246. iteminfo.OthAmt = check_other_amt
  3247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3248. }
  3249. if laboratoryCostTotal != 0 {
  3250. iteminfo.MedChrgitm = "04"
  3251. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3252. iteminfo.Amt = laboratoryCostTotal
  3253. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3254. iteminfo.ClabAmt = laboratory_clab_amt
  3255. iteminfo.OthAmt = laboratory_other_amt
  3256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3257. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3258. }
  3259. if treatCostTotal != 0 {
  3260. iteminfo.MedChrgitm = "05"
  3261. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3262. iteminfo.Amt = treatCostTotal
  3263. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3264. iteminfo.ClabAmt = treat_clab_amt
  3265. iteminfo.OthAmt = treat_other_amt
  3266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3267. //(struct4101.IteminfoStruct, iteminfo)
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. }
  3270. if operationCostTotal != 0 {
  3271. iteminfo.MedChrgitm = "06"
  3272. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3273. iteminfo.Amt = operationCostTotal
  3274. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3275. iteminfo.ClabAmt = operation_clab_amt
  3276. iteminfo.OthAmt = operation_other_amt
  3277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3278. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3279. }
  3280. if nursingCostTotal != 0 {
  3281. iteminfo.MedChrgitm = "07"
  3282. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3283. iteminfo.Amt = nursingCostTotal
  3284. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3285. iteminfo.ClabAmt = nursing_clab_amt
  3286. iteminfo.OthAmt = nursing_other_amt
  3287. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3288. }
  3289. if materialCostTotal != 0 {
  3290. iteminfo.MedChrgitm = "08"
  3291. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3292. iteminfo.Amt = materialCostTotal
  3293. iteminfo.ClaaSumfee = material_claa_sunmfee
  3294. iteminfo.ClabAmt = material_clab_amt
  3295. iteminfo.OthAmt = material_other_amt
  3296. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3298. }
  3299. if westernMedicineCostTotal != 0 {
  3300. iteminfo.MedChrgitm = "09"
  3301. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3302. iteminfo.Amt = westernMedicineCostTotal
  3303. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3304. iteminfo.ClabAmt = westernMedicine_clab_amt
  3305. iteminfo.OthAmt = westernMedicine_other_amt
  3306. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3307. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3308. }
  3309. if chineseMedicineCostTotal != 0 {
  3310. iteminfo.MedChrgitm = "10"
  3311. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3312. iteminfo.Amt = chineseMedicineCostTotal
  3313. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3314. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3315. iteminfo.OthAmt = chinese_medicine_other_amt
  3316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3318. }
  3319. if chineseTraditionalMedicineCostTotal != 0 {
  3320. iteminfo.MedChrgitm = "11"
  3321. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3322. iteminfo.Amt = westernMedicineCostTotal
  3323. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3324. iteminfo.ClabAmt = westernMedicine_clab_amt
  3325. iteminfo.OthAmt = westernMedicine_other_amt
  3326. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3328. }
  3329. if commonlyTreatmentCostTotal != 0 {
  3330. iteminfo.MedChrgitm = "12"
  3331. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3332. iteminfo.Amt = commonlyTreatmentCostTotal
  3333. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3334. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3335. iteminfo.OthAmt = commonly_treatment_other_amt
  3336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3338. }
  3339. if registerCostTotal != 0 {
  3340. iteminfo.MedChrgitm = "13"
  3341. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3342. iteminfo.Amt = registerCostTotal
  3343. iteminfo.ClaaSumfee = register_claa_sunmfee
  3344. iteminfo.ClabAmt = register_clab_amt
  3345. iteminfo.OthAmt = register_other_amt
  3346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3348. }
  3349. if otherCostTotal != 0 {
  3350. iteminfo.MedChrgitm = "14"
  3351. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3352. iteminfo.Amt = otherCostTotal
  3353. iteminfo.ClaaSumfee = other_claa_sunmfee
  3354. iteminfo.ClabAmt = other_clab_amt
  3355. iteminfo.OthAmt = other_other_amt
  3356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3358. }
  3359. struct4101.IteminfoStruct = iteminfoStructs
  3360. struct4101.Ntly = "中国"
  3361. struct4101.AdmCaty = "A03.06"
  3362. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3363. fmt.Println(result)
  3364. var dat map[string]interface{}
  3365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3366. fmt.Println(dat)
  3367. } else {
  3368. fmt.Println(err)
  3369. }
  3370. userJSONBytes, _ := json.Marshal(dat)
  3371. var res ResultSeventeen
  3372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3373. utils.ErrorLog("解析失败:%v", err)
  3374. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3375. adminUser := c.GetAdminUserInfo()
  3376. errlog := &models.HisOrderError{
  3377. UserOrgId: adminUser.CurrentOrgId,
  3378. Ctime: time.Now().Unix(),
  3379. Mtime: time.Now().Unix(),
  3380. ErrMsg: res.ErrMsg + "解析失败",
  3381. Status: 1,
  3382. PatientId: order_id,
  3383. Stage: 10106,
  3384. }
  3385. service.CreateErrMsgLog(errlog)
  3386. continue
  3387. }
  3388. if res.Infcode != 0 {
  3389. adminUser := c.GetAdminUserInfo()
  3390. errlog := &models.HisOrderError{
  3391. UserOrgId: adminUser.CurrentOrgId,
  3392. Ctime: time.Now().Unix(),
  3393. Mtime: time.Now().Unix(),
  3394. ErrMsg: res.ErrMsg,
  3395. Status: 1,
  3396. PatientId: order_id,
  3397. Stage: 10106,
  3398. }
  3399. service.CreateErrMsgLog(errlog)
  3400. continue
  3401. } else {
  3402. hisFundSettleListResult := &models.HisFundSettleListResult{
  3403. Number: res.Output.SetlListId,
  3404. Status: 1,
  3405. Ctime: time.Now().Unix(),
  3406. Mtime: time.Now().Unix(),
  3407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3408. IsUpload: 1,
  3409. OrderId: order_id,
  3410. }
  3411. service.CreateUploadRecord(hisFundSettleListResult)
  3412. continue
  3413. }
  3414. }
  3415. }
  3416. func (c *HisApiController) GetOrgInfo() {
  3417. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3418. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3419. }
  3420. func (c *HisApiController) GetHisPatientInfo() {
  3421. medical_insurance_card := c.GetString("medical_insurance_card")
  3422. id_card_type, _ := c.GetInt64("id_card_type")
  3423. id_card := c.GetString("id_card")
  3424. adminInfo := c.GetAdminUserInfo()
  3425. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3426. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3427. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3428. IdCardNo := ""
  3429. if id_card_type == 1 {
  3430. IdCardNo = medical_insurance_card
  3431. } else if id_card_type == 2 {
  3432. IdCardNo = id_card
  3433. }
  3434. if config.IsOpen == 1 {
  3435. 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
  3436. resp, requestErr := http.Get(api)
  3437. if requestErr != nil {
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. defer resp.Body.Close()
  3442. body, ioErr := ioutil.ReadAll(resp.Body)
  3443. if ioErr != nil {
  3444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3446. return
  3447. }
  3448. var respJSON map[string]interface{}
  3449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3452. return
  3453. }
  3454. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3455. userJSONBytes, _ := json.Marshal(userJSON)
  3456. var res ResultTwo
  3457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3464. infoStr := string(Iinfos)
  3465. idetinfoStr := string(Idetinfos)
  3466. if res.Infcode == 0 {
  3467. his := models.VMHisPatient{
  3468. Status: 1,
  3469. Ctime: time.Now().Unix(),
  3470. Mtime: time.Now().Unix(),
  3471. PsnNo: res.Output.Baseinfo.PsnNo,
  3472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3473. Certno: res.Output.Baseinfo.Certno,
  3474. PsnName: res.Output.Baseinfo.PsnName,
  3475. Gend: res.Output.Baseinfo.Gend,
  3476. Naty: res.Output.Baseinfo.Naty,
  3477. Brdy: res.Output.Baseinfo.Brdy,
  3478. Age: res.Output.Baseinfo.Age,
  3479. Iinfo: infoStr,
  3480. Idetinfo: idetinfoStr,
  3481. UserOrgId: adminInfo.CurrentOrgId,
  3482. IsReturn: 1,
  3483. IdCardType: id_card_type,
  3484. }
  3485. c.ServeSuccessJSON(map[string]interface{}{
  3486. "info": his,
  3487. })
  3488. } else {
  3489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3490. return
  3491. }
  3492. }
  3493. }
  3494. //func GetBasBaseInfo() (jsonStr string, err error) {
  3495. //
  3496. // handle := syscall.NewLazyDLL("SSCard.dll")
  3497. // add := handle.NewProc("ReadCardBas")
  3498. // str := make([]byte, 1024)
  3499. // str1 := make([]byte, 1024)
  3500. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3501. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3502. //
  3503. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3504. //
  3505. // fmt.Println("> Add(4,5)的结果为:", ret)
  3506. // handle.Release()
  3507. //
  3508. // return "", nil
  3509. //
  3510. //}
  3511. //func GetQRBaseInfo() (jsonStr string, err error) {
  3512. // handle := syscall.LoadDLL("SSCard.dll")
  3513. // ReadCardBas := handle.FindProc("GetQRBase")
  3514. //
  3515. // str := make([]byte, 256)
  3516. // str1 := make([]byte, 256)
  3517. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3518. //
  3519. // fmt.Println(string(str))
  3520. // fmt.Println(r)
  3521. // return string(str), nil
  3522. //}
  3523. //func CardInit() int {
  3524. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3525. // add := DllTestDef.MustFindProc("Init")
  3526. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3527. // if err != nil {
  3528. // fmt.Println("SSCard的运算结果为:", ret)
  3529. // }
  3530. // result := int(ret)
  3531. // return result
  3532. //}
  3533. //func CardInit() int {
  3534. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3535. // if err != nil {
  3536. // fmt.Println("SSCard的运算结果为:", ret)
  3537. // }
  3538. // fmt.Println(err)
  3539. // result := int(ret)
  3540. // return result
  3541. //}
  3542. func IntPtr(n int) uintptr {
  3543. return uintptr(n)
  3544. }
  3545. func StrPtr(s string) uintptr {
  3546. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3547. }
  3548. type Result2001 struct {
  3549. Cainfo interface{} `json:"cainfo"`
  3550. ErrMsg string `json:"err_msg"`
  3551. InfRefmsgid string `json:"inf_refmsgid"`
  3552. Infcode int64 `json:"infcode"`
  3553. Output struct {
  3554. Trtinfo struct {
  3555. PsnNo string `json:"psn_no"`
  3556. TrtChkType string `json:"trt_chk_type"`
  3557. FundPayType string `json:"fund_pay_type"`
  3558. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3559. Begndate string `json:"begndate"`
  3560. Enddate string `json:"enddate"`
  3561. TrtChkRslt string `json:"trt_chk_rslt"`
  3562. } `json:"trtinfo"`
  3563. } `json:"output"`
  3564. RefmsgTime string `json:"refmsg_time"`
  3565. RespondTime string `json:"respond_time"`
  3566. Signtype interface{} `json:"signtype"`
  3567. WarnMsg interface{} `json:"warn_msg"`
  3568. }
  3569. type Result2001Org10265 struct {
  3570. Cainfo interface{} `json:"cainfo"`
  3571. ErrMsg string `json:"err_msg"`
  3572. InfRefmsgid string `json:"inf_refmsgid"`
  3573. Infcode string `json:"infcode"`
  3574. Output struct {
  3575. Trtinfo struct {
  3576. PsnNo string `json:"psn_no"`
  3577. TrtChkType string `json:"trt_chk_type"`
  3578. FundPayType string `json:"fund_pay_type"`
  3579. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3580. Begndate string `json:"begndate"`
  3581. Enddate string `json:"enddate"`
  3582. TrtChkRslt string `json:"trt_chk_rslt"`
  3583. } `json:"trtinfo"`
  3584. } `json:"output"`
  3585. RefmsgTime string `json:"refmsg_time"`
  3586. RespondTime string `json:"respond_time"`
  3587. Signtype interface{} `json:"signtype"`
  3588. WarnMsg interface{} `json:"warn_msg"`
  3589. }
  3590. type ResultTwo struct {
  3591. ErrMsg string `json:"err_msg"`
  3592. InfRefmsgid string `json:"inf_refmsgid"`
  3593. Infcode int64 `json:"infcode"`
  3594. Output struct {
  3595. Baseinfo struct {
  3596. Age float64 `json:"age"`
  3597. Brdy string `json:"brdy"`
  3598. Certno string `json:"certno"`
  3599. Gend string `json:"gend"`
  3600. Naty string `json:"naty"`
  3601. PsnCertType string `json:"psn_cert_type"`
  3602. PsnName string `json:"psn_name"`
  3603. PsnNo string `json:"psn_no"`
  3604. } `json:"baseinfo"`
  3605. Idetinfo []interface{} `json:"idetinfo"`
  3606. Iinfo []struct {
  3607. Balc float64 `json:"balc"`
  3608. CvlservFlag string `json:"cvlserv_flag"`
  3609. EmpName string `json:"emp_name"`
  3610. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3611. Insutype string `json:"insutype"`
  3612. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3613. PausInsuDate string `json:"paus_insu_date"`
  3614. PsnInsuDate string `json:"psn_insu_date"`
  3615. PsnInsuStas string `json:"psn_insu_stas"`
  3616. PsnType string `json:"psn_type"`
  3617. } `json:"insuinfo"`
  3618. } `json:"output"`
  3619. RefmsgTime string `json:"refmsg_time"`
  3620. RespondTime string `json:"respond_time"`
  3621. Signtype interface{} `json:"signtype"`
  3622. WarnInfo interface{} `json:"warn_info"`
  3623. }
  3624. type ResultTwo10265 struct {
  3625. ErrMsg string `json:"err_msg"`
  3626. InfRefmsgid string `json:"inf_refmsgid"`
  3627. Infcode string `json:"infcode"`
  3628. Output struct {
  3629. Baseinfo struct {
  3630. Age float64 `json:"age"`
  3631. Brdy string `json:"brdy"`
  3632. Certno string `json:"certno"`
  3633. Gend string `json:"gend"`
  3634. Naty string `json:"naty"`
  3635. PsnCertType string `json:"psn_cert_type"`
  3636. PsnName string `json:"psn_name"`
  3637. PsnNo string `json:"psn_no"`
  3638. } `json:"baseinfo"`
  3639. Idetinfo []interface{} `json:"idetinfo"`
  3640. Iinfo []struct {
  3641. Balc float64 `json:"balc"`
  3642. CvlservFlag string `json:"cvlserv_flag"`
  3643. EmpName string `json:"emp_name"`
  3644. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3645. Insutype string `json:"insutype"`
  3646. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3647. PausInsuDate string `json:"paus_insu_date"`
  3648. PsnInsuDate string `json:"psn_insu_date"`
  3649. PsnInsuStas string `json:"psn_insu_stas"`
  3650. PsnType string `json:"psn_type"`
  3651. } `json:"insuinfo"`
  3652. } `json:"output"`
  3653. RefmsgTime string `json:"refmsg_time"`
  3654. RespondTime string `json:"respond_time"`
  3655. Signtype interface{} `json:"signtype"`
  3656. WarnInfo interface{} `json:"warn_info"`
  3657. }
  3658. type ResultThree struct {
  3659. Cainfo interface{} `json:"cainfo"`
  3660. ErrMsg string `json:"err_msg"`
  3661. InfRefmsgid string `json:"inf_refmsgid"`
  3662. Infcode int64 `json:"infcode"`
  3663. Output struct {
  3664. Data struct {
  3665. IptOtpNo string `json:"ipt_otp_no"`
  3666. MdtrtID string `json:"mdtrt_id"`
  3667. PsnNo string `json:"psn_no"`
  3668. } `json:"data"`
  3669. } `json:"output"`
  3670. RefmsgTime string `json:"refmsg_time"`
  3671. RespondTime string `json:"respond_time"`
  3672. Signtype interface{} `json:"signtype"`
  3673. WarnMsg interface{} `json:"warn_msg"`
  3674. }
  3675. type ResultThree10265 struct {
  3676. Cainfo interface{} `json:"cainfo"`
  3677. ErrMsg string `json:"err_msg"`
  3678. InfRefmsgid string `json:"inf_refmsgid"`
  3679. Infcode string `json:"infcode"`
  3680. Output struct {
  3681. Data struct {
  3682. IptOtpNo string `json:"ipt_otp_no"`
  3683. MdtrtID string `json:"mdtrt_id"`
  3684. PsnNo string `json:"psn_no"`
  3685. } `json:"data"`
  3686. } `json:"output"`
  3687. RefmsgTime string `json:"refmsg_time"`
  3688. RespondTime string `json:"respond_time"`
  3689. Signtype interface{} `json:"signtype"`
  3690. WarnMsg interface{} `json:"warn_msg"`
  3691. }
  3692. type ResultFour struct {
  3693. Cainfo string `json:"cainfo"`
  3694. ErrMsg string `json:"err_msg"`
  3695. InfRefmsgid string `json:"inf_refmsgid"`
  3696. Infcode int64 `json:"infcode"`
  3697. Output struct {
  3698. Result []struct {
  3699. BasMednFlag string `json:"bas_medn_flag"`
  3700. ChldMedcFlag string `json:"chld_medc_flag"`
  3701. ChrgitmLv string `json:"chrgitm_lv"`
  3702. Cnt float64 `json:"cnt"`
  3703. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3704. DrtReimFlag string `json:"drt_reim_flag"`
  3705. FeedetlSn string `json:"feedetl_sn"`
  3706. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3707. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3708. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3709. ListSpItemFlag string `json:"list_sp_item_flag"`
  3710. LmtUsedFlag string `json:"lmt_used_flag"`
  3711. MedChrgitmType string `json:"med_chrgitm_type"`
  3712. Memo string `json:"memo"`
  3713. OverlmtAmt float64 `json:"overlmt_amt"`
  3714. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3715. Pric float64 `json:"pric"`
  3716. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3717. SelfpayProp float64 `json:"selfpay_prop"`
  3718. } `json:"result"`
  3719. } `json:"output"`
  3720. RefmsgTime string `json:"refmsg_time"`
  3721. RespondTime string `json:"respond_time"`
  3722. Signtype string `json:"signtype"`
  3723. WarnMsg string `json:"warn_msg"`
  3724. }
  3725. type ResultFour10265 struct {
  3726. Cainfo string `json:"cainfo"`
  3727. ErrMsg string `json:"err_msg"`
  3728. InfRefmsgid string `json:"inf_refmsgid"`
  3729. Infcode string `json:"infcode"`
  3730. Output struct {
  3731. Result []struct {
  3732. BasMednFlag string `json:"bas_medn_flag"`
  3733. ChldMedcFlag string `json:"chld_medc_flag"`
  3734. ChrgitmLv string `json:"chrgitm_lv"`
  3735. Cnt float64 `json:"cnt"`
  3736. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3737. DrtReimFlag string `json:"drt_reim_flag"`
  3738. FeedetlSn string `json:"feedetl_sn"`
  3739. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3740. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3741. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3742. ListSpItemFlag string `json:"list_sp_item_flag"`
  3743. LmtUsedFlag string `json:"lmt_used_flag"`
  3744. MedChrgitmType string `json:"med_chrgitm_type"`
  3745. Memo string `json:"memo"`
  3746. OverlmtAmt float64 `json:"overlmt_amt"`
  3747. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3748. Pric float64 `json:"pric"`
  3749. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3750. SelfpayProp float64 `json:"selfpay_prop"`
  3751. } `json:"result"`
  3752. } `json:"output"`
  3753. RefmsgTime string `json:"refmsg_time"`
  3754. RespondTime string `json:"respond_time"`
  3755. Signtype string `json:"signtype"`
  3756. WarnMsg string `json:"warn_msg"`
  3757. }
  3758. type ResultFive struct {
  3759. Balc float64 `json:"balc"`
  3760. CvlservFlag string `json:"cvlserv_flag"`
  3761. EmpName string `json:"emp_name"`
  3762. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3763. Insutype string `json:"insutype"`
  3764. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3765. PausInsuDate string `json:"paus_insu_date"`
  3766. PsnInsuDate string `json:"psn_insu_date"`
  3767. PsnInsuStas string `json:"psn_insu_stas"`
  3768. PsnType string `json:"psn_type"`
  3769. }
  3770. type ResultSix struct {
  3771. Cainfo interface{} `json:"cainfo"`
  3772. ErrMsg string `json:"err_msg"`
  3773. InfRefmsgid string `json:"inf_refmsgid"`
  3774. Infcode int64 `json:"infcode"`
  3775. Output struct {
  3776. } `json:"output"`
  3777. RefmsgTime string `json:"refmsg_time"`
  3778. RespondTime string `json:"respond_time"`
  3779. Signtype interface{} `json:"signtype"`
  3780. WarnMsg interface{} `json:"warn_msg"`
  3781. }
  3782. type ResultSix10265 struct {
  3783. Cainfo interface{} `json:"cainfo"`
  3784. ErrMsg string `json:"err_msg"`
  3785. InfRefmsgid string `json:"inf_refmsgid"`
  3786. Infcode string `json:"infcode"`
  3787. Output struct {
  3788. } `json:"output"`
  3789. RefmsgTime string `json:"refmsg_time"`
  3790. RespondTime string `json:"respond_time"`
  3791. Signtype interface{} `json:"signtype"`
  3792. WarnMsg interface{} `json:"warn_msg"`
  3793. }
  3794. type ResultSeven struct {
  3795. Cainfo string `json:"cainfo"`
  3796. ErrMsg string `json:"err_msg"`
  3797. InfRefmsgid string `json:"inf_refmsgid"`
  3798. Infcode int64 `json:"infcode"`
  3799. Output struct {
  3800. Setldetail []interface{} `json:"setldetail"`
  3801. Setlinfo struct {
  3802. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3803. AcctPay float64 `json:"acct_pay"`
  3804. ActPayDedc float64 `json:"act_pay_dedc"`
  3805. Age float64 `json:"age"`
  3806. Balc float64 `json:"balc"`
  3807. Brdy string `json:"brdy"`
  3808. Certno string `json:"certno"`
  3809. ClrOptins string `json:"clr_optins"`
  3810. ClrType string `json:"clr_type"`
  3811. ClrWay string `json:"clr_way"`
  3812. CvlservFlag string `json:"cvlserv_flag"`
  3813. CvlservPay float64 `json:"cvlserv_pay"`
  3814. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3815. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3816. Gend string `json:"gend"`
  3817. HifesPay float64 `json:"hifes_pay"`
  3818. HifmiPay float64 `json:"hifmi_pay"`
  3819. HifpPay float64 `json:"hifp_pay"`
  3820. HospPartAmt float64 `json:"hosp_part_amt"`
  3821. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3822. Insutype string `json:"insutype"`
  3823. MafPay float64 `json:"maf_pay"`
  3824. MdtrtCertType string `json:"mdtrt_cert_type"`
  3825. HifobPay float64 `json:"hifob_pay"`
  3826. MdtrtID string `json:"mdtrt_id"`
  3827. MedType string `json:"med_type"`
  3828. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3829. MedinsSetlID string `json:"medins_setl_id"`
  3830. Naty string `json:"naty"`
  3831. OthPay float64 `json:"oth_pay"`
  3832. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3833. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3834. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3835. PsnCashPay float64 `json:"psn_cash_pay"`
  3836. PsnCertType string `json:"psn_cert_type"`
  3837. PsnName string `json:"psn_name"`
  3838. PsnNo string `json:"psn_no"`
  3839. PsnPartAmt float64 `json:"psn_part_amt"`
  3840. PsnType string `json:"psn_type"`
  3841. SetlID string `json:"setl_id"`
  3842. SetlTime string `json:"setl_time"`
  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 ResultSeven10265 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. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3859. AcctPay float64 `json:"acct_pay"`
  3860. ActPayDedc float64 `json:"act_pay_dedc"`
  3861. Age float64 `json:"age"`
  3862. Balc float64 `json:"balc"`
  3863. Brdy string `json:"brdy"`
  3864. Certno string `json:"certno"`
  3865. ClrOptins string `json:"clr_optins"`
  3866. ClrType string `json:"clr_type"`
  3867. ClrWay string `json:"clr_way"`
  3868. CvlservFlag string `json:"cvlserv_flag"`
  3869. CvlservPay float64 `json:"cvlserv_pay"`
  3870. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3871. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3872. Gend string `json:"gend"`
  3873. HifesPay float64 `json:"hifes_pay"`
  3874. HifmiPay float64 `json:"hifmi_pay"`
  3875. HifpPay float64 `json:"hifp_pay"`
  3876. HospPartAmt float64 `json:"hosp_part_amt"`
  3877. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3878. Insutype string `json:"insutype"`
  3879. MafPay float64 `json:"maf_pay"`
  3880. MdtrtCertType string `json:"mdtrt_cert_type"`
  3881. HifobPay float64 `json:"hifob_pay"`
  3882. MdtrtID string `json:"mdtrt_id"`
  3883. MedType string `json:"med_type"`
  3884. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3885. MedinsSetlID string `json:"medins_setl_id"`
  3886. Naty string `json:"naty"`
  3887. OthPay float64 `json:"oth_pay"`
  3888. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3889. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3890. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3891. PsnCashPay float64 `json:"psn_cash_pay"`
  3892. PsnCertType string `json:"psn_cert_type"`
  3893. PsnName string `json:"psn_name"`
  3894. PsnNo string `json:"psn_no"`
  3895. PsnPartAmt float64 `json:"psn_part_amt"`
  3896. PsnType string `json:"psn_type"`
  3897. SetlID string `json:"setl_id"`
  3898. SetlTime string `json:"setl_time"`
  3899. } `json:"setlinfo"`
  3900. } `json:"output"`
  3901. RefmsgTime string `json:"refmsg_time"`
  3902. RespondTime string `json:"respond_time"`
  3903. Signtype interface{} `json:"signtype"`
  3904. WarnMsg interface{} `json:"warn_msg"`
  3905. }
  3906. type ResultEight struct {
  3907. Cainfo string `json:"cainfo"`
  3908. ErrMsg string `json:"err_msg"`
  3909. InfRefmsgid string `json:"inf_refmsgid"`
  3910. Infcode int64 `json:"infcode"`
  3911. Output struct {
  3912. Stmtinfo struct {
  3913. SetlOptins string `json:"setl_optins"`
  3914. StmtRslt string `json:"stmt_rslt"`
  3915. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3916. } `json:"stmtinfo"`
  3917. } `json:"output"`
  3918. RefmsgTime string `json:"refmsg_time"`
  3919. RespondTime string `json:"respond_time"`
  3920. Signtype interface{} `json:"signtype"`
  3921. WarnMsg interface{} `json:"warn_msg"`
  3922. }
  3923. type ResultEightFor10188 struct {
  3924. Cainfo string `json:"cainfo"`
  3925. ErrMsg string `json:"err_msg"`
  3926. InfRefmsgid string `json:"inf_refmsgid"`
  3927. Infcode string `json:"infcode"`
  3928. Output struct {
  3929. Stmtinfo struct {
  3930. SetlOptins string `json:"setl_optins"`
  3931. StmtRslt string `json:"stmt_rslt"`
  3932. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3933. } `json:"stmtinfo"`
  3934. } `json:"output"`
  3935. RefmsgTime string `json:"refmsg_time"`
  3936. RespondTime string `json:"respond_time"`
  3937. Signtype interface{} `json:"signtype"`
  3938. WarnMsg interface{} `json:"warn_msg"`
  3939. }
  3940. type ResultNine struct {
  3941. Cainfo string `json:"cainfo"`
  3942. ErrMsg string `json:"err_msg"`
  3943. InfRefmsgid string `json:"inf_refmsgid"`
  3944. Infcode int64 `json:"infcode"`
  3945. Output struct {
  3946. FileQuryNo string `json:"file_qury_no"`
  3947. } `json:"output"`
  3948. RefmsgTime string `json:"refmsg_time"`
  3949. RespondTime string `json:"respond_time"`
  3950. Signtype interface{} `json:"signtype"`
  3951. WarnMsg interface{} `json:"warn_msg"`
  3952. }
  3953. type ResultTen struct {
  3954. Cainfo string `json:"cainfo"`
  3955. ErrMsg string `json:"err_msg"`
  3956. InfRefmsgid string `json:"inf_refmsgid"`
  3957. Infcode int64 `json:"infcode"`
  3958. Output struct {
  3959. DldEndtime string `json:"dld_endtime"`
  3960. FileQuryNo string `json:"file_qury_no"`
  3961. Filename string `json:"filename"`
  3962. } `json:"output"`
  3963. RefmsgTime string `json:"refmsg_time"`
  3964. RespondTime string `json:"respond_time"`
  3965. Signtype interface{} `json:"signtype"`
  3966. WarnMsg interface{} `json:"warn_msg"`
  3967. }
  3968. //type Autogenerated struct {
  3969. // Output struct {
  3970. // Setlinfo struct {
  3971. // SetlTime string `json:"setl_time"`
  3972. // CvlservPay float64 `json:"cvlserv_pay"`
  3973. // Year string `json:"year"`
  3974. // MedType string `json:"med_type"`
  3975. // PsnPay float64 `json:"psn_pay"`
  3976. // OpterID string `json:"opter_id"`
  3977. // Begndate string `json:"begndate"`
  3978. // FlxempeFlag string `json:"flxempe_flag"`
  3979. // HifmiPay float64 `json:"hifmi_pay"`
  3980. // PsnNo string `json:"psn_no"`
  3981. // ActPayDedc float64 `json:"act_pay_dedc"`
  3982. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3983. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3984. // ClrWay string `json:"clr_way"`
  3985. // OthPay float64 `json:"oth_pay"`
  3986. // Gend string `json:"gend"`
  3987. // MdtrtID string `json:"mdtrt_id"`
  3988. // AcctPay float64 `json:"acct_pay"`
  3989. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3990. // Insutype string `json:"insutype"`
  3991. // Invono interface{} `json:"invono"`
  3992. // Enddate string `json:"enddate"`
  3993. // CashPayamt float64 `json:"cash_payamt"`
  3994. // PsnType string `json:"psn_type"`
  3995. // FixmedinsName string `json:"fixmedins_name"`
  3996. // HifpPay float64 `json:"hifp_pay"`
  3997. // NewFlag interface{} `json:"new_flag"`
  3998. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3999. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4000. // PayLoc string `json:"pay_loc"`
  4001. // ClrType string `json:"clr_type"`
  4002. // RefdSetlFlag string `json:"refd_setl_flag"`
  4003. // CvlservFlag string `json:"cvlserv_flag"`
  4004. // EmpName string `json:"emp_name"`
  4005. // Brdy string `json:"brdy"`
  4006. // Naty string `json:"naty"`
  4007. // Certno string `json:"certno"`
  4008. // DiseCode string `json:"dise_code"`
  4009. // FixmedinsCode string `json:"fixmedins_code"`
  4010. // DedcHospLv string `json:"dedc_hosp_lv"`
  4011. // OpterName string `json:"opter_name"`
  4012. // Balc float64 `json:"balc"`
  4013. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4014. // PsnCertType string `json:"psn_cert_type"`
  4015. // HifobPay float64 `json:"hifob_pay"`
  4016. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4017. // HifesPay float64 `json:"hifes_pay"`
  4018. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4019. // OptTime string `json:"opt_time"`
  4020. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4021. // SetlID string `json:"setl_id"`
  4022. // MafPay float64 `json:"maf_pay"`
  4023. // PsnName string `json:"psn_name"`
  4024. // InsuOptins interface{} `json:"insu_optins"`
  4025. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4026. // ClrOptins string `json:"clr_optins"`
  4027. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4028. // DiseName string `json:"dise_name"`
  4029. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4030. // Age float64 `json:"age"`
  4031. // DtrtCertType string `json:"dtrt_cert_type"`
  4032. // HospLv string `json:"hosp_lv"`
  4033. // } `json:"setlinfo"`
  4034. // Setldetail []struct {
  4035. // FundPayType string `json:"fund_pay_type"`
  4036. // FundPayamt float64 `json:"fund_payamt"`
  4037. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4038. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4039. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4040. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4041. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4042. // } `json:"setldetail"`
  4043. // } `json:"output"`
  4044. // Infcode int `json:"infcode"`
  4045. // WarnMsg interface{} `json:"warn_msg"`
  4046. // Cainfo interface{} `json:"cainfo"`
  4047. // ErrMsg interface{} `json:"err_msg"`
  4048. // RefmsgTime string `json:"refmsg_time"`
  4049. // Signtype interface{} `json:"signtype"`
  4050. // RespondTime string `json:"respond_time"`
  4051. // InfRefmsgid string `json:"inf_refmsgid"`
  4052. //}
  4053. type ResultEleven struct {
  4054. Cainfo string `json:"cainfo"`
  4055. ErrMsg string `json:"err_msg"`
  4056. InfRefmsgid string `json:"inf_refmsgid"`
  4057. Infcode int64 `json:"infcode"`
  4058. Output struct {
  4059. Setlinfo struct {
  4060. SetlTime string `json:"setl_time"`
  4061. CvlservPay float64 `json:"cvlserv_pay"`
  4062. Year string `json:"year"`
  4063. MedType string `json:"med_type"`
  4064. PsnPay float64 `json:"psn_pay"`
  4065. OpterID string `json:"opter_id"`
  4066. Begndate string `json:"begndate"`
  4067. FlxempeFlag string `json:"flxempe_flag"`
  4068. HifmiPay float64 `json:"hifmi_pay"`
  4069. PsnNo string `json:"psn_no"`
  4070. ActPayDedc float64 `json:"act_pay_dedc"`
  4071. MedinsSetlID interface{} `json:"medins_setl_id"`
  4072. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4073. ClrWay string `json:"clr_way"`
  4074. OthPay float64 `json:"oth_pay"`
  4075. Gend string `json:"gend"`
  4076. MdtrtID string `json:"mdtrt_id"`
  4077. AcctPay float64 `json:"acct_pay"`
  4078. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4079. Insutype string `json:"insutype"`
  4080. Invono interface{} `json:"invono"`
  4081. Enddate string `json:"enddate"`
  4082. CashPayamt float64 `json:"cash_payamt"`
  4083. PsnType string `json:"psn_type"`
  4084. FixmedinsName string `json:"fixmedins_name"`
  4085. HifpPay float64 `json:"hifp_pay"`
  4086. NewFlag interface{} `json:"new_flag"`
  4087. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4088. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4089. PayLoc string `json:"pay_loc"`
  4090. ClrType string `json:"clr_type"`
  4091. RefdSetlFlag string `json:"refd_setl_flag"`
  4092. CvlservFlag string `json:"cvlserv_flag"`
  4093. EmpName string `json:"emp_name"`
  4094. Brdy string `json:"brdy"`
  4095. Naty string `json:"naty"`
  4096. Certno string `json:"certno"`
  4097. DiseCode string `json:"dise_code"`
  4098. FixmedinsCode string `json:"fixmedins_code"`
  4099. DedcHospLv string `json:"dedc_hosp_lv"`
  4100. OpterName string `json:"opter_name"`
  4101. Balc float64 `json:"balc"`
  4102. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4103. PsnCertType string `json:"psn_cert_type"`
  4104. HifobPay float64 `json:"hifob_pay"`
  4105. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4106. HifesPay float64 `json:"hifes_pay"`
  4107. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4108. OptTime string `json:"opt_time"`
  4109. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4110. SetlID string `json:"setl_id"`
  4111. MafPay float64 `json:"maf_pay"`
  4112. PsnName string `json:"psn_name"`
  4113. InsuOptins interface{} `json:"insu_optins"`
  4114. PrefFundPay interface{} `json:"pref_fund_pay"`
  4115. ClrOptins string `json:"clr_optins"`
  4116. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4117. DiseName string `json:"dise_name"`
  4118. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4119. Age float64 `json:"age"`
  4120. DtrtCertType string `json:"dtrt_cert_type"`
  4121. HospLv string `json:"hosp_lv"`
  4122. } `json:"setlinfo"`
  4123. } `json:"output"`
  4124. RefmsgTime string `json:"refmsg_time"`
  4125. RespondTime string `json:"respond_time"`
  4126. Signtype interface{} `json:"signtype"`
  4127. WarnMsg interface{} `json:"warn_msg"`
  4128. }
  4129. type ResultEleven10265 struct {
  4130. Cainfo string `json:"cainfo"`
  4131. ErrMsg string `json:"err_msg"`
  4132. InfRefmsgid string `json:"inf_refmsgid"`
  4133. Infcode string `json:"infcode"`
  4134. Output struct {
  4135. Setlinfo struct {
  4136. SetlTime string `json:"setl_time"`
  4137. CvlservPay float64 `json:"cvlserv_pay"`
  4138. Year string `json:"year"`
  4139. MedType string `json:"med_type"`
  4140. PsnPay float64 `json:"psn_pay"`
  4141. OpterID string `json:"opter_id"`
  4142. Begndate string `json:"begndate"`
  4143. FlxempeFlag string `json:"flxempe_flag"`
  4144. HifmiPay float64 `json:"hifmi_pay"`
  4145. PsnNo string `json:"psn_no"`
  4146. ActPayDedc float64 `json:"act_pay_dedc"`
  4147. MedinsSetlID interface{} `json:"medins_setl_id"`
  4148. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4149. ClrWay string `json:"clr_way"`
  4150. OthPay float64 `json:"oth_pay"`
  4151. Gend string `json:"gend"`
  4152. MdtrtID string `json:"mdtrt_id"`
  4153. AcctPay float64 `json:"acct_pay"`
  4154. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4155. Insutype string `json:"insutype"`
  4156. Invono interface{} `json:"invono"`
  4157. Enddate string `json:"enddate"`
  4158. CashPayamt float64 `json:"cash_payamt"`
  4159. PsnType string `json:"psn_type"`
  4160. FixmedinsName string `json:"fixmedins_name"`
  4161. HifpPay float64 `json:"hifp_pay"`
  4162. NewFlag interface{} `json:"new_flag"`
  4163. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4164. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4165. PayLoc string `json:"pay_loc"`
  4166. ClrType string `json:"clr_type"`
  4167. RefdSetlFlag string `json:"refd_setl_flag"`
  4168. CvlservFlag string `json:"cvlserv_flag"`
  4169. EmpName string `json:"emp_name"`
  4170. Brdy string `json:"brdy"`
  4171. Naty string `json:"naty"`
  4172. Certno string `json:"certno"`
  4173. DiseCode string `json:"dise_code"`
  4174. FixmedinsCode string `json:"fixmedins_code"`
  4175. DedcHospLv string `json:"dedc_hosp_lv"`
  4176. OpterName string `json:"opter_name"`
  4177. Balc float64 `json:"balc"`
  4178. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4179. PsnCertType string `json:"psn_cert_type"`
  4180. HifobPay float64 `json:"hifob_pay"`
  4181. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4182. HifesPay float64 `json:"hifes_pay"`
  4183. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4184. OptTime string `json:"opt_time"`
  4185. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4186. SetlID string `json:"setl_id"`
  4187. MafPay float64 `json:"maf_pay"`
  4188. PsnName string `json:"psn_name"`
  4189. InsuOptins interface{} `json:"insu_optins"`
  4190. PrefFundPay interface{} `json:"pref_fund_pay"`
  4191. ClrOptins string `json:"clr_optins"`
  4192. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4193. DiseName string `json:"dise_name"`
  4194. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4195. Age float64 `json:"age"`
  4196. DtrtCertType string `json:"dtrt_cert_type"`
  4197. HospLv string `json:"hosp_lv"`
  4198. } `json:"setlinfo"`
  4199. } `json:"output"`
  4200. RefmsgTime string `json:"refmsg_time"`
  4201. RespondTime string `json:"respond_time"`
  4202. Signtype interface{} `json:"signtype"`
  4203. WarnMsg interface{} `json:"warn_msg"`
  4204. }
  4205. type ResultTwelve struct {
  4206. Cainfo string `json:"cainfo"`
  4207. ErrMsg string `json:"err_msg"`
  4208. InfRefmsgid string `json:"inf_refmsgid"`
  4209. Infcode int64 `json:"infcode"`
  4210. Output struct {
  4211. MdtrtId string `json:"mdtrt_id"`
  4212. ChrgBchno string `json:"chrg_bchno"`
  4213. PsnNo string `json:"psn_no"`
  4214. } `json:"output"`
  4215. RefmsgTime string `json:"refmsg_time"`
  4216. RespondTime string `json:"respond_time"`
  4217. Signtype interface{} `json:"signtype"`
  4218. WarnMsg interface{} `json:"warn_msg"`
  4219. }
  4220. type ResultThirteen struct {
  4221. ErrMsg string `json:"err_msg"`
  4222. InfRefmsgid string `json:"inf_refmsgid"`
  4223. Infcode int64 `json:"infcode"`
  4224. Output struct {
  4225. Result struct {
  4226. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4227. } `json:"result"`
  4228. } `json:"output"`
  4229. RefmsgTime string `json:"refmsg_time"`
  4230. RespondTime string `json:"respond_time"`
  4231. Signtype interface{} `json:"signtype"`
  4232. WarnInfo interface{} `json:"warn_info"`
  4233. }
  4234. type ResultThirteen10265 struct {
  4235. ErrMsg string `json:"err_msg"`
  4236. InfRefmsgid string `json:"inf_refmsgid"`
  4237. Infcode string `json:"infcode"`
  4238. Output struct {
  4239. Result struct {
  4240. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4241. } `json:"result"`
  4242. } `json:"output"`
  4243. RefmsgTime string `json:"refmsg_time"`
  4244. RespondTime string `json:"respond_time"`
  4245. Signtype interface{} `json:"signtype"`
  4246. WarnInfo interface{} `json:"warn_info"`
  4247. }
  4248. type ResultFourteen struct {
  4249. ErrMsg string `json:"err_msg"`
  4250. InfRefmsgid string `json:"inf_refmsgid"`
  4251. Infcode int64 `json:"infcode"`
  4252. Output struct {
  4253. } `json:"output"`
  4254. RefmsgTime string `json:"refmsg_time"`
  4255. RespondTime string `json:"respond_time"`
  4256. Signtype interface{} `json:"signtype"`
  4257. WarnInfo interface{} `json:"warn_info"`
  4258. }
  4259. type ResultFourteen10265 struct {
  4260. ErrMsg string `json:"err_msg"`
  4261. InfRefmsgid string `json:"inf_refmsgid"`
  4262. Infcode string `json:"infcode"`
  4263. Output struct {
  4264. } `json:"output"`
  4265. RefmsgTime string `json:"refmsg_time"`
  4266. RespondTime string `json:"respond_time"`
  4267. Signtype interface{} `json:"signtype"`
  4268. WarnInfo interface{} `json:"warn_info"`
  4269. }
  4270. type ResultSixteen struct {
  4271. Cainfo string `json:"cainfo"`
  4272. ErrMsg string `json:"err_msg"`
  4273. InfRefmsgid string `json:"inf_refmsgid"`
  4274. Infcode int64 `json:"infcode"`
  4275. Output struct {
  4276. Setldetail []interface{} `json:"setldetail"`
  4277. Setlinfo struct {
  4278. MdtrtID string `json:"mdtrt_id"`
  4279. SetlID string `json:"setl_id"`
  4280. ClrOptins string `json:"clr_optins"`
  4281. SetlTime string `json:"setl_time"`
  4282. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4283. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4284. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4285. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4286. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4287. ActPayDedc float64 `json:"act_pay_dedc"`
  4288. HifpPay float64 `json:"hifp_pay"`
  4289. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4290. Lfpay float64 `json:"selfpay"`
  4291. CvlservPay float64 `json:"cvlserv_pay"`
  4292. HifesPay float64 `json:"hifes_pay"`
  4293. HifmiPay float64 `json:"hifmi_pay"`
  4294. HifobPay float64 `json:"hifob_pay"`
  4295. MafPay float64 `json:"maf_pay"`
  4296. OthPay float64 `json:"oth_pay"`
  4297. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4298. PsnPartAmt float64 `json:"psn_part_amt"`
  4299. AcctPay float64 `json:"acct_pay"`
  4300. Balc float64 `json:"balc"`
  4301. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4302. HospPartAmt float64 `json:"hosp_part_amt"`
  4303. MedinsSetlID string `json:"medins_setl_id"`
  4304. PdnCashPay string `json:"pdn_cash_pay"`
  4305. } `json:"setlinfo"`
  4306. } `json:"output"`
  4307. RefmsgTime string `json:"refmsg_time"`
  4308. RespondTime string `json:"respond_time"`
  4309. Signtype interface{} `json:"signtype"`
  4310. WarnMsg interface{} `json:"warn_msg"`
  4311. }
  4312. type ResultSixteen10265 struct {
  4313. Cainfo string `json:"cainfo"`
  4314. ErrMsg string `json:"err_msg"`
  4315. InfRefmsgid string `json:"inf_refmsgid"`
  4316. Infcode string `json:"infcode"`
  4317. Output struct {
  4318. Setldetail []interface{} `json:"setldetail"`
  4319. Setlinfo struct {
  4320. MdtrtID string `json:"mdtrt_id"`
  4321. SetlID string `json:"setl_id"`
  4322. ClrOptins string `json:"clr_optins"`
  4323. SetlTime string `json:"setl_time"`
  4324. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4325. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4326. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4327. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4328. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4329. ActPayDedc float64 `json:"act_pay_dedc"`
  4330. HifpPay float64 `json:"hifp_pay"`
  4331. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4332. Lfpay float64 `json:"selfpay"`
  4333. CvlservPay float64 `json:"cvlserv_pay"`
  4334. HifesPay float64 `json:"hifes_pay"`
  4335. HifmiPay float64 `json:"hifmi_pay"`
  4336. HifobPay float64 `json:"hifob_pay"`
  4337. MafPay float64 `json:"maf_pay"`
  4338. OthPay float64 `json:"oth_pay"`
  4339. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4340. PsnPartAmt float64 `json:"psn_part_amt"`
  4341. AcctPay float64 `json:"acct_pay"`
  4342. Balc float64 `json:"balc"`
  4343. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4344. HospPartAmt float64 `json:"hosp_part_amt"`
  4345. MedinsSetlID string `json:"medins_setl_id"`
  4346. PdnCashPay string `json:"pdn_cash_pay"`
  4347. } `json:"setlinfo"`
  4348. } `json:"output"`
  4349. RefmsgTime string `json:"refmsg_time"`
  4350. RespondTime string `json:"respond_time"`
  4351. Signtype interface{} `json:"signtype"`
  4352. WarnMsg interface{} `json:"warn_msg"`
  4353. }
  4354. type ResultSeventeen struct {
  4355. ErrMsg string `json:"err_msg"`
  4356. InfRefmsgid string `json:"inf_refmsgid"`
  4357. Infcode int64 `json:"infcode"`
  4358. Output struct {
  4359. SetlListId string `json:"setl_list_id"`
  4360. } `json:"output"`
  4361. RefmsgTime string `json:"refmsg_time"`
  4362. RespondTime string `json:"respond_time"`
  4363. Signtype string `json:"signtype"`
  4364. WarnInfo string `json:"warn_info"`
  4365. }
  4366. type ResultSeventeenOther struct {
  4367. ErrMsg string `json:"err_msg"`
  4368. InfRefmsgid string `json:"inf_refmsgid"`
  4369. Infcode string `json:"infcode"`
  4370. Output struct {
  4371. SetlListId string `json:"setl_list_id"`
  4372. } `json:"output"`
  4373. RefmsgTime string `json:"refmsg_time"`
  4374. RespondTime string `json:"respond_time"`
  4375. Signtype string `json:"signtype"`
  4376. WarnInfo string `json:"warn_info"`
  4377. }
  4378. type Result90991 struct {
  4379. ErrMsg string `json:"err_msg"`
  4380. InfRefmsgid string `json:"inf_refmsgid"`
  4381. Infcode int64 `json:"infcode"`
  4382. Output struct {
  4383. Result struct {
  4384. PsnNo string `json:"psn_no"`
  4385. CardStat string `json:"card_stat"`
  4386. Certno string `json:"certno"`
  4387. PsnName string `json:"psn_name"`
  4388. CheckStat string `json:"check_stat"`
  4389. SscnoCheckStat string `json:"sscno_check_stat"`
  4390. } `json:"result"`
  4391. } `json:"output"`
  4392. RefmsgTime string `json:"refmsg_time"`
  4393. RespondTime string `json:"respond_time"`
  4394. Signtype interface{} `json:"signtype"`
  4395. WarnInfo interface{} `json:"warn_info"`
  4396. }
  4397. type Result90100 struct {
  4398. ErrMsg string `json:"err_msg"`
  4399. InfRefmsgid string `json:"inf_refmsgid"`
  4400. Infcode int64 `json:"infcode"`
  4401. Output struct {
  4402. PoolareaNo string `json:"poolarea_no"`
  4403. PoolareaNoName string `json:"poolarea_no_name"`
  4404. Insutype string `json:"insutype"`
  4405. InsutypeName string `json:"insutype_name"`
  4406. ClctType string `json:"clct_type"`
  4407. ClctTypeName string `json:"clct_type_name"`
  4408. ClctFlag string `json:"clct_flag"`
  4409. ClctFlagName string `json:"clct_flag_name"`
  4410. AccrymBegn string `json:"accrym_begn"`
  4411. AccrymEnd string `json:"accrym_end"`
  4412. ClctTime string `json:"clct_time"`
  4413. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4414. } `json:"output"`
  4415. RefmsgTime string `json:"refmsg_time"`
  4416. RespondTime string `json:"respond_time"`
  4417. Signtype interface{} `json:"signtype"`
  4418. WarnInfo interface{} `json:"warn_info"`
  4419. }
  4420. type Custom struct {
  4421. DetItemFeeSumamt string
  4422. Cut string
  4423. FeedetlSn string
  4424. Price string
  4425. MedListCodg string
  4426. Type int64
  4427. AdviceId int64
  4428. ProjectId int64
  4429. ItemId int64
  4430. }
  4431. type Result5301 struct {
  4432. ErrMsg string `json:"err_msg"`
  4433. InfRefmsgid string `json:"inf_refmsgid"`
  4434. Infcode int64 `json:"infcode"`
  4435. Output struct {
  4436. Result []struct {
  4437. OpspDiseCode string `json:"opsp_dise_code"`
  4438. OpspDiseName string `json:"opsp_dise_name"`
  4439. Begndate string `json:"begndate"`
  4440. Enddate string `json:"enddate"`
  4441. } `json:"feedetail"`
  4442. } `json:"output"`
  4443. RefmsgTime string `json:"refmsg_time"`
  4444. RespondTime string `json:"respond_time"`
  4445. Signtype interface{} `json:"signtype"`
  4446. WarnInfo interface{} `json:"warn_info"`
  4447. }
  4448. type Result5301For10265 struct {
  4449. ErrMsg string `json:"err_msg"`
  4450. InfRefmsgid string `json:"inf_refmsgid"`
  4451. Infcode string `json:"infcode"`
  4452. Output struct {
  4453. Result []struct {
  4454. OpspDiseCode string `json:"opsp_dise_code"`
  4455. OpspDiseName string `json:"opsp_dise_name"`
  4456. Begndate string `json:"begndate"`
  4457. Enddate string `json:"enddate"`
  4458. } `json:"feedetail"`
  4459. } `json:"output"`
  4460. RefmsgTime string `json:"refmsg_time"`
  4461. RespondTime string `json:"respond_time"`
  4462. Signtype interface{} `json:"signtype"`
  4463. WarnInfo interface{} `json:"warn_info"`
  4464. }
  4465. //获取个人信息----挂号-----上传就诊信息
  4466. func (c *HisApiController) GetRegisterInfo() {
  4467. id, _ := c.GetInt64("id")
  4468. record_time := c.GetString("record_time")
  4469. settlementValue, _ := c.GetInt64("settlement_value")
  4470. medical_insurance_card := c.GetString("medical_insurance_card")
  4471. name := c.GetString("name")
  4472. id_card_type, _ := c.GetInt64("id_card_type")
  4473. certificates, _ := c.GetInt64("certificates")
  4474. medical_care, _ := c.GetInt64("medical_care")
  4475. birthday := c.GetString("birthday")
  4476. id_card := c.GetString("id_card")
  4477. register_type, _ := c.GetInt64("register")
  4478. doctor, _ := c.GetInt64("doctor")
  4479. department, _ := c.GetInt64("department")
  4480. gender, _ := c.GetInt64("sex")
  4481. registration_fee, _ := c.GetFloat("registration_fee")
  4482. medical_expenses, _ := c.GetFloat("medical_expenses")
  4483. social_type, _ := c.GetInt64("social_type")
  4484. med_type := c.GetString("social_type")
  4485. admin_user_id, _ := c.GetInt64("admin_user_id")
  4486. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4487. timeLayout := "2006-01-02"
  4488. loc, _ := time.LoadLocation("Local")
  4489. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4490. birthUnix := birthdays.Unix()
  4491. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4492. if err != nil {
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4494. return
  4495. }
  4496. recordDateTime := theTime.Unix()
  4497. adminInfo := c.GetAdminUserInfo()
  4498. var patient service.Patients
  4499. if id == 0 {
  4500. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4501. } else {
  4502. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4503. }
  4504. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4505. if patientPrescription.ID == 0 {
  4506. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4507. }
  4508. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4509. if patient.ID == 0 {
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4511. return
  4512. }
  4513. if len(patient.IdCardNo) == 0 {
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4515. return
  4516. }
  4517. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4518. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4519. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4520. //就诊结算未完成,不能进行二次挂号
  4521. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4522. if len(his) >= 1 {
  4523. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4524. if len(his) >= 1 && order.ID == 0 {
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4526. return
  4527. }
  4528. }
  4529. //var register_log string
  4530. if config.IsOpen == 1 {
  4531. var res ResultTwo
  4532. var res10265 ResultTwo10265
  4533. var PsnNo string
  4534. var PsnCertType string
  4535. var Certno string
  4536. var PsnName string
  4537. var Gend string
  4538. var Naty string
  4539. var Brdy string
  4540. var Age float64
  4541. var infoStr string
  4542. var idetinfoStr string
  4543. var infocode int64
  4544. var verify_number string
  4545. fmt.Println(verify_number)
  4546. if miConfig.MdtrtareaAdmvs == "421300" {
  4547. psn_info, _ := service.GetPsnByPatientId(id)
  4548. PsnNo = psn_info.PsnNo
  4549. PsnCertType = psn_info.PsnCertType
  4550. Certno = psn_info.Certno
  4551. PsnName = psn_info.PsnName
  4552. Gend = psn_info.Gend
  4553. Naty = psn_info.Naty
  4554. Brdy = psn_info.Brdy
  4555. Age = psn_info.Age
  4556. infoStr = psn_info.Insuinfo
  4557. idetinfoStr = psn_info.Idetinfo
  4558. infocode = 0
  4559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4560. psn_info, _ := service.GetPsnByPatientId(id)
  4561. PsnNo = psn_info.PsnNo
  4562. PsnCertType = psn_info.PsnCertType
  4563. Certno = psn_info.Certno
  4564. PsnName = psn_info.PsnName
  4565. Gend = psn_info.Gend
  4566. Naty = psn_info.Naty
  4567. Brdy = psn_info.Brdy
  4568. Age = psn_info.Age
  4569. infoStr = psn_info.Insuinfo
  4570. idetinfoStr = psn_info.Idetinfo
  4571. infocode = 0
  4572. verify_number = psn_info.VerifyNumber
  4573. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4574. psn_info, _ := service.GetPsnByPatientId(id)
  4575. PsnNo = psn_info.PsnNo
  4576. PsnCertType = psn_info.PsnCertType
  4577. Certno = psn_info.Certno
  4578. PsnName = psn_info.PsnName
  4579. Gend = psn_info.Gend
  4580. Naty = psn_info.Naty
  4581. Brdy = psn_info.Brdy
  4582. Age = psn_info.Age
  4583. infoStr = psn_info.Insuinfo
  4584. idetinfoStr = psn_info.Idetinfo
  4585. infocode = 0
  4586. verify_number = psn_info.VerifyNumber
  4587. } else {
  4588. var result string
  4589. var requestLog string
  4590. if miConfig.UserOrgId == 10138 {
  4591. 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)
  4592. } else {
  4593. 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)
  4594. }
  4595. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4596. if miConfig.Code == "H15049901371" {
  4597. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4598. utils.ErrorLog("解析失败:%v", err)
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. res.ErrMsg = res10265.ErrMsg
  4603. res.Output = res10265.Output
  4604. res.InfRefmsgid = res10265.InfRefmsgid
  4605. } else {
  4606. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. }
  4612. PsnNo = res.Output.Baseinfo.PsnNo
  4613. PsnCertType = res.Output.Baseinfo.PsnCertType
  4614. Certno = res.Output.Baseinfo.Certno
  4615. PsnName = res.Output.Baseinfo.PsnName
  4616. Gend = res.Output.Baseinfo.Gend
  4617. Naty = res.Output.Baseinfo.Naty
  4618. Brdy = res.Output.Baseinfo.Brdy
  4619. Age = res.Output.Baseinfo.Age
  4620. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4621. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4622. infoStr = string(Iinfos)
  4623. idetinfoStr = string(Idetinfos)
  4624. if miConfig.Code == "H15049901371" {
  4625. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4626. } else {
  4627. infocode = res.Infcode
  4628. }
  4629. }
  4630. if infocode == 0 {
  4631. his := models.VMHisPatient{
  4632. Name: name,
  4633. Gender: gender,
  4634. Birthday: birthUnix,
  4635. MedicalTreatmentType: medical_care,
  4636. IdType: certificates,
  4637. IdCardNo: id_card,
  4638. BalanceAccountsType: settlementValue,
  4639. SocialType: social_type,
  4640. MedicalInsuranceNumber: medical_insurance_card,
  4641. RegisterType: register_type,
  4642. RegisterCost: registration_fee,
  4643. TreatmentCost: medical_expenses,
  4644. Status: 1,
  4645. Ctime: time.Now().Unix(),
  4646. Mtime: time.Now().Unix(),
  4647. PsnNo: PsnNo,
  4648. PsnCertType: PsnCertType,
  4649. Certno: Certno,
  4650. PsnName: PsnName,
  4651. Gend: Gend,
  4652. Naty: Naty,
  4653. Brdy: Brdy,
  4654. Age: Age,
  4655. Iinfo: infoStr,
  4656. Idetinfo: idetinfoStr,
  4657. PatientId: patient.ID,
  4658. RecordDate: theTime.Unix(),
  4659. UserOrgId: adminInfo.CurrentOrgId,
  4660. AdminUserId: admin_user_id,
  4661. IsReturn: 1,
  4662. IdCardType: id_card_type,
  4663. Doctor: doctor,
  4664. Departments: department,
  4665. }
  4666. timestamp := time.Now().Unix()
  4667. tempTime := time.Unix(timestamp, 0)
  4668. timeFormat := tempTime.Format("20060102150405")
  4669. chrgBchno := rand.Intn(100000) + 10000
  4670. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4671. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4672. department, _ := service.GetDepartMentDetail(department)
  4673. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4674. IdCardNo := ""
  4675. if id_card_type == 1 {
  4676. // IdCardNo = medical_insurance_card
  4677. IdCardNo = patient.IdCardNo
  4678. } else {
  4679. IdCardNo = patient.IdCardNo
  4680. }
  4681. var rf []*ResultFive
  4682. json.Unmarshal([]byte(his.Iinfo), &rf)
  4683. var insutypes []*ResultFive
  4684. var insutype string
  4685. var insuplc_admdvs_temp string
  4686. var is390 int = 0
  4687. var is310 int = 0
  4688. for _, item := range rf {
  4689. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4690. insutypes = append(insutypes, item)
  4691. }
  4692. }
  4693. if len(insutypes) == 1 {
  4694. insutype = insutypes[0].Insutype
  4695. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4696. } else {
  4697. for _, i := range insutypes {
  4698. if i.Insutype == "390" {
  4699. is390 = 1
  4700. }
  4701. if i.Insutype == "310" {
  4702. is310 = 1
  4703. }
  4704. }
  4705. }
  4706. if is390 == 1 {
  4707. insutype = "390"
  4708. }
  4709. if is310 == 1 {
  4710. insutype = "310"
  4711. }
  4712. if len(insutypes) == 0 {
  4713. insutype = "310"
  4714. }
  4715. if len(insutypes) == 2 {
  4716. insutype = med_type
  4717. }
  4718. if len(med_type) > 0 {
  4719. insutype = med_type
  4720. }
  4721. //for _, item := range rf {
  4722. // if item.Insutype == insutype {
  4723. // insuplc_admdvs = item.InsuplcAdmdvs
  4724. // }
  4725. //}
  4726. var infocode int64
  4727. var resThree ResultThree
  4728. var resThree10265 ResultThree10265
  4729. if len(insuplc_admdvs) == 0 {
  4730. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4731. } else {
  4732. insuplc_admdvs_temp = insuplc_admdvs
  4733. }
  4734. if miConfig.MdtrtareaAdmvs == "421300" {
  4735. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4736. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4737. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4738. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4739. resp, requestErr := http.Get(api)
  4740. if requestErr != nil {
  4741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4742. return
  4743. }
  4744. body, ioErr := ioutil.ReadAll(resp.Body)
  4745. if ioErr != nil {
  4746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. var respJSON map[string]interface{}
  4751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. return
  4755. }
  4756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4757. result, _ := json.Marshal(respJSON)
  4758. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4759. utils.ErrorLog("解析失败:%v", err)
  4760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. return
  4762. }
  4763. infocode = resThree.Infcode
  4764. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4765. psn_info, _ := service.GetPsnByPatientId(id)
  4766. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4767. var cert_no string
  4768. if id_card_type == 3 {
  4769. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4770. cert_no = IdCardNo
  4771. } else if id_card_type == 4 {
  4772. cert_no = IdCardNo
  4773. psn_info.VerifyNumber = psn_info.VerifyNumber
  4774. } else {
  4775. bas := strings.Split(psn_info.CardInfo, "|")
  4776. cert_no = bas[2]
  4777. }
  4778. var api string
  4779. if miConfig.MdtrtareaAdmvs == "320921" {
  4780. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4781. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4782. "&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
  4783. } else {
  4784. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4785. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4786. "&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
  4787. }
  4788. resp, requestErr := http.Get(api)
  4789. if requestErr != nil {
  4790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4791. return
  4792. }
  4793. body, ioErr := ioutil.ReadAll(resp.Body)
  4794. if ioErr != nil {
  4795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. var respJSON map[string]interface{}
  4800. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4803. return
  4804. }
  4805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4806. result, _ := json.Marshal(respJSON)
  4807. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4808. utils.ErrorLog("解析失败:%v", err)
  4809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4810. return
  4811. }
  4812. resThree.ErrMsg = resThree10265.ErrMsg
  4813. resThree.Output = resThree10265.Output
  4814. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4815. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4816. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4817. psn_info, _ := service.GetPsnByPatientId(id)
  4818. var cert_no string
  4819. if id_card_type == 1 {
  4820. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4821. }
  4822. fmt.Println(cert_no)
  4823. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  4824. saveLog(result, requestLog, "2201", "挂号")
  4825. if miConfig.Code == "H15049901371" {
  4826. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4827. utils.ErrorLog("解析失败:%v", err)
  4828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4829. return
  4830. }
  4831. resThree.ErrMsg = resThree10265.ErrMsg
  4832. resThree.Output = resThree10265.Output
  4833. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4834. } else {
  4835. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4836. utils.ErrorLog("解析失败:%v", err)
  4837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4838. return
  4839. }
  4840. }
  4841. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4842. } else {
  4843. 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)
  4844. saveLog(result, requestLog, "2201A", "挂号")
  4845. if miConfig.Code == "H15049901371" {
  4846. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4847. utils.ErrorLog("解析失败:%v", err)
  4848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4849. return
  4850. }
  4851. resThree.ErrMsg = resThree10265.ErrMsg
  4852. resThree.Output = resThree10265.Output
  4853. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4854. } else {
  4855. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4856. utils.ErrorLog("解析失败:%v", err)
  4857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4858. return
  4859. }
  4860. }
  4861. if miConfig.Code == "H15049901371" {
  4862. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4863. } else {
  4864. infocode = resThree.Infcode
  4865. }
  4866. }
  4867. if infocode != 0 {
  4868. adminUser := c.GetAdminUserInfo()
  4869. errlog := &models.HisOrderError{
  4870. UserOrgId: adminUser.CurrentOrgId,
  4871. Ctime: time.Now().Unix(),
  4872. Mtime: time.Now().Unix(),
  4873. ErrMsg: resThree.ErrMsg,
  4874. Status: 1,
  4875. PatientId: id,
  4876. RecordTime: recordDateTime,
  4877. Stage: 2,
  4878. }
  4879. service.CreateErrMsgLog(errlog)
  4880. c.ServeSuccessJSON(map[string]interface{}{
  4881. "failed_code": -10,
  4882. "msg": resThree.ErrMsg,
  4883. })
  4884. return
  4885. }
  4886. his.Number = resThree.Output.Data.MdtrtID
  4887. his.PsnNo = resThree.Output.Data.PsnNo
  4888. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4889. his.IdCardNo = patient.IdCardNo
  4890. his.PhoneNumber = patient.Phone
  4891. his.UserOrgId = adminInfo.CurrentOrgId
  4892. his.Insutype = insutype
  4893. his.Ctime = time.Now().Unix()
  4894. his.Mtime = time.Now().Unix()
  4895. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4896. his.Status = 1
  4897. service.UpdateHisPatientStatus(&his)
  4898. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4899. c.ServeSuccessJSON(map[string]interface{}{
  4900. "his_info": his,
  4901. })
  4902. } else {
  4903. adminUser := c.GetAdminUserInfo()
  4904. errlog := &models.HisOrderError{
  4905. UserOrgId: adminUser.CurrentOrgId,
  4906. Ctime: time.Now().Unix(),
  4907. Mtime: time.Now().Unix(),
  4908. ErrMsg: res.ErrMsg,
  4909. Status: 1,
  4910. PatientId: id,
  4911. RecordTime: recordDateTime,
  4912. Stage: 1,
  4913. }
  4914. service.CreateErrMsgLog(errlog)
  4915. c.ServeSuccessJSON(map[string]interface{}{
  4916. "failed_code": -10,
  4917. "msg": res.ErrMsg,
  4918. })
  4919. return
  4920. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4921. }
  4922. }
  4923. }
  4924. //上传明细----预结算----确认订单
  4925. func (c *HisApiController) GetUploadInfo() {
  4926. id, _ := c.GetInt64("id")
  4927. record_time := c.GetString("record_time")
  4928. his_patient_id, _ := c.GetInt64("his_patient_id")
  4929. order_id, _ := c.GetInt64("order_id")
  4930. pay_way, _ := c.GetInt64("pay_way")
  4931. pay_price, _ := c.GetFloat("pay_price")
  4932. pay_card_no := c.GetString("pay_card_no")
  4933. token := c.GetString("token")
  4934. discount_price, _ := c.GetFloat("discount_price")
  4935. preferential_price, _ := c.GetFloat("preferential_price")
  4936. reality_price, _ := c.GetFloat("reality_price")
  4937. found_price, _ := c.GetFloat("found_price")
  4938. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4939. private_price, _ := c.GetFloat("private_price")
  4940. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4941. admin_user_id, _ := c.GetInt64("admin_user_id")
  4942. fapiao_code := c.GetString("fapiao_code")
  4943. fapiao_number := c.GetString("fapiao_number")
  4944. diagnosis_id := c.GetString("diagnosis")
  4945. sick_type, _ := c.GetInt64("sick_type")
  4946. reg_type, _ := c.GetInt64("p_type")
  4947. begin_time := c.GetString("begin_time")
  4948. id_str := c.GetString("ids")
  4949. ids_arr := strings.Split(id_str, ",")
  4950. timeLayout := "2006-01-02"
  4951. loc, _ := time.LoadLocation("Local")
  4952. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4953. if err != nil {
  4954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4955. return
  4956. }
  4957. recordDateTime := theTime.Unix()
  4958. adminUser := c.GetAdminUserInfo()
  4959. var tempOrder models.HisOrder
  4960. tempOrder, _ = service.GetHisOrderByID(order_id)
  4961. var prescriptions []*models.HisPrescription
  4962. var start_time int64
  4963. var end_time int64
  4964. //押金模块
  4965. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4966. tmp_decimal := c.GetString("tmp_decimal")
  4967. var decimal float64 //本次使用的押金
  4968. var errmsg error
  4969. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4970. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4971. return
  4972. }
  4973. if len(tmp_decimal) > 0 {
  4974. if tmp_decimal[0] == 45 {
  4975. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4976. return
  4977. }
  4978. }
  4979. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4980. fmt.Println(errs)
  4981. decimal = tt
  4982. //if adminUser.CurrentOrgId == 10106{
  4983. // if len(fapiao_code) == 0{
  4984. // fapiao_code = "144072080589"
  4985. // }
  4986. // if len(fapiao_number) == 0{
  4987. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4988. // if order.ID == 0{
  4989. // fapiao_number = "00001520"
  4990. // }else{
  4991. // //fapiao_code = "00001520"
  4992. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4993. // var zero string
  4994. // if fpNumber >= 1000{
  4995. // zero = "0000" + strconv.Itoa(fpNumber)
  4996. // }else if fpNumber >= 10000{
  4997. // zero = "000" + strconv.Itoa(fpNumber)
  4998. // } else if fpNumber >= 100000{
  4999. // zero = "00" + strconv.Itoa(fpNumber)
  5000. // } else if fpNumber >= 1000000{
  5001. // zero = "0" + strconv.Itoa(fpNumber)
  5002. // }else {
  5003. // zero = strconv.Itoa(fpNumber)
  5004. // }
  5005. // fapiao_number = zero
  5006. // }
  5007. // }
  5008. //}
  5009. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5010. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5011. var patientPrescription models.HisPrescriptionInfo
  5012. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5013. if patientPrescription.ID == 0 {
  5014. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5015. }
  5016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5017. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5018. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5019. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5020. var config []*models.HisXtDiagnoseConfig
  5021. for _, item := range diagnosis_ids {
  5022. id, _ := strconv.ParseInt(item, 10, 64)
  5023. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5024. config = append(config, &diagnosisConfig)
  5025. }
  5026. sickConfig, _ := service.FindSickById(sick_type)
  5027. //if tempOrder.ID == 0 {
  5028. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5029. //}
  5030. if tempOrder.ID == 0 {
  5031. var result string
  5032. var requestLog string
  5033. var res2 ResultSix
  5034. var ressix10265 ResultSix10265
  5035. if miConfig.MdtrtareaAdmvs == "421300" {
  5036. data := make(map[string]interface{})
  5037. client := &http.Client{}
  5038. data["psn_no"] = his.PsnNo
  5039. data["mdtrt_id"] = his.Number
  5040. data["opter"] = roles.UserName
  5041. data["org_name"] = miConfig.OrgName
  5042. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5043. data["doctor_id"] = doctor_info.DoctorNumber
  5044. data["doctor_name"] = doctor_info.UserName
  5045. data["department"] = department.Name
  5046. data["fixmedins_code"] = miConfig.Code
  5047. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5048. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5049. data["secret_key"] = miConfig.SecretKey
  5050. data["sick_code"] = sickConfig.CountryCode
  5051. data["sick_name"] = sickConfig.ClassName
  5052. data["dept"] = strconv.FormatInt(department.ID, 10)
  5053. data["config"] = config
  5054. data["begin_time"] = begin_time
  5055. bytesData, _ := json.Marshal(data)
  5056. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5057. resp, _ := client.Do(req)
  5058. defer resp.Body.Close()
  5059. body, ioErr := ioutil.ReadAll(resp.Body)
  5060. if ioErr != nil {
  5061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5063. return
  5064. }
  5065. var respJSON map[string]interface{}
  5066. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5069. return
  5070. }
  5071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5072. userJSONBytes, _ := json.Marshal(respJSON)
  5073. fmt.Println("log")
  5074. fmt.Println(string(userJSONBytes))
  5075. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5076. utils.ErrorLog("解析失败:%v", err)
  5077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5078. return
  5079. }
  5080. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5081. //江苏地区国家医保医疗类别
  5082. //职工透析:医疗类别选特殊情况门诊9933
  5083. //居民血透门慢: 医疗类别选门诊慢病1402
  5084. //var med_type string
  5085. //if his.Insutype == "310" {
  5086. // if reg_type == 14 {
  5087. // med_type = "9933"
  5088. // } else if reg_type == 11 {
  5089. // med_type = "11"
  5090. //
  5091. // }
  5092. //} else if his.Insutype == "390" {
  5093. // if reg_type == 14 {
  5094. // med_type = "1402"
  5095. // } else if reg_type == 11 {
  5096. // med_type = "11"
  5097. // }
  5098. //}
  5099. data := make(map[string]interface{})
  5100. client := &http.Client{}
  5101. data["psn_no"] = his.PsnNo
  5102. data["mdtrt_id"] = his.Number
  5103. data["doctor"] = roles.UserName
  5104. data["department"] = department.Name
  5105. data["org_name"] = miConfig.OrgName
  5106. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5107. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5108. data["fixmedins_code"] = miConfig.Code
  5109. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5110. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5111. data["secret_key"] = miConfig.SecretKey
  5112. data["sick_code"] = sickConfig.CountryCode
  5113. data["sick_name"] = sickConfig.ClassName
  5114. data["url"] = miConfig.Url
  5115. data["ak"] = miConfig.AccessKey
  5116. data["begin_time"] = begin_time
  5117. data["cainfo"] = miConfig.Cainfo
  5118. data["dept"] = strconv.FormatInt(department.ID, 10)
  5119. data["config"] = config
  5120. bytesData, _ := json.Marshal(data)
  5121. var req *http.Request
  5122. if miConfig.MdtrtareaAdmvs == "320921" {
  5123. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5124. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5125. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5126. } else {
  5127. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5128. }
  5129. resp, _ := client.Do(req)
  5130. defer resp.Body.Close()
  5131. body, ioErr := ioutil.ReadAll(resp.Body)
  5132. if ioErr != nil {
  5133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. var respJSON map[string]interface{}
  5138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5141. return
  5142. }
  5143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5144. userJSONBytes, _ := json.Marshal(respJSON)
  5145. fmt.Println("log")
  5146. fmt.Println(string(userJSONBytes))
  5147. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5148. utils.ErrorLog("解析失败:%v", err)
  5149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5150. return
  5151. }
  5152. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5153. res2.Output = ressix10265.Output
  5154. res2.ErrMsg = ressix10265.ErrMsg
  5155. res2.Cainfo = ressix10265.Cainfo
  5156. res2.WarnMsg = ressix10265.WarnMsg
  5157. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5158. res2.Infcode = infocode
  5159. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5160. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5161. saveLog(result, requestLog, "2203", "上传就诊信息")
  5162. var respJSON2 map[string]interface{}
  5163. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. return
  5167. }
  5168. userJSONBytes2, _ := json.Marshal(respJSON2)
  5169. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5170. utils.ErrorLog("解析失败:%v", err)
  5171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5172. return
  5173. }
  5174. } else {
  5175. if miConfig.MdtrtareaAdmvs == "440781" { //
  5176. 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)
  5177. } else {
  5178. if miConfig.Code == "H15049901371" {
  5179. //赤峰地区国家医保医疗类别
  5180. //职工透析:医疗类别选特殊情况门诊990502
  5181. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5182. var med_type string
  5183. if his.Insutype == "390" {
  5184. if reg_type == 14 {
  5185. med_type = "9933"
  5186. } else if reg_type == 11 {
  5187. med_type = "11"
  5188. }
  5189. } else if his.Insutype == "310" {
  5190. if reg_type == 14 {
  5191. med_type = "990502"
  5192. } else if reg_type == 11 {
  5193. med_type = "11"
  5194. }
  5195. }
  5196. 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)
  5197. } else {
  5198. 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)
  5199. }
  5200. }
  5201. saveLog(result, requestLog, "2203", "上传就诊信息")
  5202. var respJSON2 map[string]interface{}
  5203. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5206. return
  5207. }
  5208. userJSONBytes2, _ := json.Marshal(respJSON2)
  5209. if miConfig.Code == "H15049901371" {
  5210. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5211. utils.ErrorLog("解析失败:%v", err)
  5212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. return
  5214. }
  5215. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5216. res2.Output = ressix10265.Output
  5217. res2.ErrMsg = ressix10265.ErrMsg
  5218. res2.Cainfo = ressix10265.Cainfo
  5219. res2.WarnMsg = ressix10265.WarnMsg
  5220. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5221. res2.Infcode = infocode
  5222. } else {
  5223. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5224. utils.ErrorLog("解析失败:%v", err)
  5225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5226. return
  5227. }
  5228. }
  5229. }
  5230. if res2.Infcode != 0 {
  5231. adminUser := c.GetAdminUserInfo()
  5232. errlog := &models.HisOrderError{
  5233. UserOrgId: adminUser.CurrentOrgId,
  5234. Ctime: time.Now().Unix(),
  5235. Mtime: time.Now().Unix(),
  5236. ErrMsg: res2.ErrMsg,
  5237. Status: 1,
  5238. PatientId: id,
  5239. RecordTime: recordDateTime,
  5240. Stage: 3,
  5241. }
  5242. service.CreateErrMsgLog(errlog)
  5243. c.ServeSuccessJSON(map[string]interface{}{
  5244. "failed_code": -10,
  5245. "msg": res2.ErrMsg,
  5246. })
  5247. return
  5248. } else {
  5249. his.Diagnosis = diagnosis_id
  5250. his.SickType = sickConfig.ID
  5251. //var p_type int64
  5252. //if reg_type == 1111 || reg_type == 1112 {
  5253. // p_type = 11
  5254. //
  5255. //}
  5256. his.PType = fmt.Sprintf("%d", reg_type)
  5257. service.UpdateHisPatientThree(&his)
  5258. data := make(map[string]interface{})
  5259. if settle_accounts_type == 1 { //日结
  5260. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5261. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5262. } else {
  5263. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5264. }
  5265. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5266. data["pre"] = prescriptions
  5267. } else { //月结
  5268. start_time_str := c.GetString("start_time")
  5269. end_time_str := c.GetString("end_time")
  5270. timeLayout := "2006-01-02"
  5271. loc, _ := time.LoadLocation("Local")
  5272. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5273. if err != nil {
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5275. return
  5276. }
  5277. recordStartTime := theStartTime.Unix()
  5278. start_time = recordStartTime
  5279. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5280. if err != nil {
  5281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5282. return
  5283. }
  5284. recordEndTime := theEndTime.Unix()
  5285. end_time = recordEndTime
  5286. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5287. data["pre"] = prescriptions
  5288. }
  5289. timestamp := time.Now().Unix()
  5290. tempTime := time.Unix(timestamp, 0)
  5291. timeFormat := tempTime.Format("20060102150405")
  5292. chrgBchno := rand.Intn(100000) + 10000
  5293. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5294. strconv.FormatInt(his.PatientId, 10)
  5295. client := &http.Client{}
  5296. data["psn_no"] = his.PsnNo
  5297. data["mdtrt_id"] = his.Number
  5298. data["chrg_bchno"] = chrg_bchno
  5299. data["org_name"] = miConfig.OrgName
  5300. data["doctor"] = doctor_info.UserName
  5301. data["doctor_id"] = doctor_info.DoctorNumber
  5302. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5303. data["fixmedins_code"] = miConfig.Code
  5304. data["opter"] = roles.UserName
  5305. data["dept_code"] = department.Number
  5306. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5307. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5308. data["secret_key"] = miConfig.SecretKey
  5309. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5310. data["url"] = miConfig.Url
  5311. data["ak"] = miConfig.AccessKey
  5312. data["new_doctor_name"] = patientPrescription.Doctor
  5313. data["diag_code"] = sickConfig.CountryCode
  5314. data["cainfo"] = miConfig.Cainfo
  5315. var ids []int64
  5316. for _, item := range prescriptions {
  5317. ids = append(ids, item.ID)
  5318. }
  5319. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5320. if config.IsOpen == 1 { //对接了医保,走医保流程
  5321. var res ResultFour
  5322. var resFour10265 ResultFour10265
  5323. if miConfig.MdtrtareaAdmvs == "421300" {
  5324. bytesData, _ := json.Marshal(data)
  5325. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5326. resp, _ := client.Do(req)
  5327. defer resp.Body.Close()
  5328. body, ioErr := ioutil.ReadAll(resp.Body)
  5329. if ioErr != nil {
  5330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5332. return
  5333. }
  5334. var respJSON map[string]interface{}
  5335. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5338. return
  5339. }
  5340. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5341. userJSONBytes, _ := json.Marshal(respJSON)
  5342. fmt.Println("log")
  5343. fmt.Println(string(userJSONBytes))
  5344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5345. utils.ErrorLog("解析失败:%v", err)
  5346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5347. return
  5348. }
  5349. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5350. bytesData, _ := json.Marshal(data)
  5351. var req *http.Request
  5352. if miConfig.MdtrtareaAdmvs == "320921" {
  5353. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5354. } else {
  5355. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5356. }
  5357. resp, _ := client.Do(req)
  5358. defer resp.Body.Close()
  5359. body, ioErr := ioutil.ReadAll(resp.Body)
  5360. if ioErr != nil {
  5361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5363. return
  5364. }
  5365. var respJSON map[string]interface{}
  5366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. return
  5370. }
  5371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5372. userJSONBytes, _ := json.Marshal(respJSON)
  5373. fmt.Println("log")
  5374. fmt.Println(string(userJSONBytes))
  5375. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5376. utils.ErrorLog("解析失败:%v", err)
  5377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5378. return
  5379. }
  5380. res.InfRefmsgid = resFour10265.InfRefmsgid
  5381. res.Output = resFour10265.Output
  5382. res.ErrMsg = resFour10265.ErrMsg
  5383. res.Cainfo = resFour10265.Cainfo
  5384. res.WarnMsg = resFour10265.WarnMsg
  5385. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5386. res.Infcode = infocode
  5387. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5388. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5389. var dat map[string]interface{}
  5390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5391. fmt.Println(dat)
  5392. } else {
  5393. fmt.Println(err)
  5394. }
  5395. saveLog(result, request_log, "2204", "上传费用明细")
  5396. userJSONBytes, _ := json.Marshal(dat)
  5397. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5398. utils.ErrorLog("解析失败:%v", err)
  5399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5400. return
  5401. }
  5402. res.InfRefmsgid = resFour10265.InfRefmsgid
  5403. res.Output = resFour10265.Output
  5404. res.ErrMsg = resFour10265.ErrMsg
  5405. res.Cainfo = resFour10265.Cainfo
  5406. res.WarnMsg = resFour10265.WarnMsg
  5407. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5408. res.Infcode = infocode
  5409. } else {
  5410. if miConfig.Code == "H15049901371" {
  5411. 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)
  5412. var dat map[string]interface{}
  5413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5414. fmt.Println(dat)
  5415. } else {
  5416. fmt.Println(err)
  5417. }
  5418. saveLog(result, request_log, "2204", "上传费用明细")
  5419. userJSONBytes, _ := json.Marshal(dat)
  5420. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5421. utils.ErrorLog("解析失败:%v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. res.InfRefmsgid = resFour10265.InfRefmsgid
  5426. res.Output = resFour10265.Output
  5427. res.ErrMsg = resFour10265.ErrMsg
  5428. res.Cainfo = resFour10265.Cainfo
  5429. res.WarnMsg = resFour10265.WarnMsg
  5430. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5431. res.Infcode = infocode
  5432. } else {
  5433. 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)
  5434. var dat map[string]interface{}
  5435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5436. fmt.Println(dat)
  5437. } else {
  5438. fmt.Println(err)
  5439. }
  5440. saveLog(result, request_log, "2204", "上传费用明细")
  5441. userJSONBytes, _ := json.Marshal(dat)
  5442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5443. utils.ErrorLog("解析失败:%v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. }
  5448. }
  5449. if res.Infcode == 0 {
  5450. order := &models.HisOrder{
  5451. UserOrgId: adminUser.CurrentOrgId,
  5452. HisPatientId: his.ID,
  5453. PatientId: his.PatientId,
  5454. SettleAccountsDate: recordDateTime,
  5455. MdtrtId: his.Number,
  5456. PsnNo: his.PsnNo,
  5457. MedType: strconv.FormatInt(reg_type, 10),
  5458. Ctime: time.Now().Unix(),
  5459. Mtime: time.Now().Unix(),
  5460. Status: 1,
  5461. Number: chrg_bchno,
  5462. Infcode: res.Infcode,
  5463. WarnMsg: res.WarnMsg,
  5464. Cainfo: res.Cainfo,
  5465. ErrMsg: res.ErrMsg,
  5466. RespondTime: res.RefmsgTime,
  5467. InfRefmsgid: res.InfRefmsgid,
  5468. OrderStatus: 1,
  5469. PayWay: pay_way,
  5470. PayPrice: pay_price,
  5471. PayCardNo: pay_card_no,
  5472. DiscountPrice: discount_price,
  5473. PreferentialPrice: preferential_price,
  5474. RealityPrice: reality_price,
  5475. FoundPrice: found_price,
  5476. MedicalInsurancePrice: medical_insurance_price,
  5477. PrivatePrice: private_price,
  5478. IsMedicineInsurance: 1,
  5479. SettleType: settle_accounts_type,
  5480. SettleStartTime: start_time,
  5481. SettleEndTime: end_time,
  5482. Creator: roles.AdminUserId,
  5483. Modify: roles.AdminUserId,
  5484. FaPiaoNumber: fapiao_number,
  5485. FaPiaoCode: fapiao_code,
  5486. PType: 2,
  5487. Diagnosis: diagnosis_id,
  5488. }
  5489. err = service.CreateOrder(order)
  5490. if err != nil {
  5491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5492. return
  5493. }
  5494. for _, item := range res.Output.Result {
  5495. temp := strings.Split(item.FeedetlSn, "-")
  5496. var advice_id int64 = 0
  5497. var project_id int64 = 0
  5498. var types int64 = 0
  5499. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5500. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5501. if temp[1] == "1" {
  5502. advice_id = id
  5503. project_id = 0
  5504. } else if temp[1] == "2" {
  5505. advice_id = 0
  5506. project_id = id
  5507. }
  5508. info := &models.HisOrderInfo{
  5509. OrderNumber: order.Number,
  5510. FeedetlSn: item.FeedetlSn,
  5511. UploadDate: time.Now().Unix(),
  5512. AdviceId: advice_id,
  5513. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5514. Cnt: item.Cnt,
  5515. Pric: float64(item.Pric),
  5516. PatientId: his.PatientId,
  5517. PricUplmtAmt: item.PricUplmtAmt,
  5518. SelfpayProp: item.SelfpayProp,
  5519. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5520. OverlmtAmt: item.OverlmtAmt,
  5521. PreselfpayAmt: item.PreselfpayAmt,
  5522. BasMednFlag: item.BasMednFlag,
  5523. MedChrgitmType: item.MedChrgitmType,
  5524. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5525. Status: 1,
  5526. Memo: item.Memo,
  5527. Mtime: time.Now().Unix(),
  5528. InscpScpAmt: item.InscpScpAmt,
  5529. DrtReimFlag: item.DrtReimFlag,
  5530. Ctime: time.Now().Unix(),
  5531. ListSpItemFlag: item.ListSpItemFlag,
  5532. ChldMedcFlag: item.ChldMedcFlag,
  5533. LmtUsedFlag: item.LmtUsedFlag,
  5534. ChrgitmLv: item.ChrgitmLv,
  5535. UserOrgId: adminUser.CurrentOrgId,
  5536. HisPatientId: his.ID,
  5537. OrderId: order.ID,
  5538. ProjectId: project_id,
  5539. Type: types,
  5540. }
  5541. service.CreateOrderInfo(info)
  5542. }
  5543. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5544. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5545. var total float64
  5546. for _, item := range prescriptions {
  5547. if item.Type == 1 { //药品
  5548. for _, subItem := range item.HisDoctorAdviceInfo {
  5549. total = total + (subItem.Price * subItem.PrescribingNumber)
  5550. }
  5551. }
  5552. if item.Type == 2 { //项目
  5553. for _, subItem := range item.HisPrescriptionProject {
  5554. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5555. total = total + (subItem.Price * cnt)
  5556. }
  5557. }
  5558. }
  5559. for _, item := range prescriptions {
  5560. for _, subItem := range item.HisAdditionalCharge {
  5561. total = total + (subItem.Price * float64(subItem.Count))
  5562. }
  5563. }
  5564. var allTotal string
  5565. if adminUser.CurrentOrgId == 9919 {
  5566. allTotal = fmt.Sprintf("%.4f", total)
  5567. } else {
  5568. allTotal = fmt.Sprintf("%.4f", total)
  5569. }
  5570. if res.Infcode == 0 {
  5571. var rf []*ResultFive
  5572. json.Unmarshal([]byte(his.Iinfo), &rf)
  5573. chrg_bchno := chrg_bchno
  5574. cert_no := his.Certno
  5575. var insutypes []string
  5576. var insutype string
  5577. var is390 int = 0
  5578. var is310 int = 0
  5579. for _, item := range rf {
  5580. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5581. insutypes = append(insutypes, item.Insutype)
  5582. }
  5583. }
  5584. if len(insutypes) == 1 {
  5585. insutype = insutypes[0]
  5586. } else {
  5587. for _, i := range insutypes {
  5588. if i == "390" {
  5589. is390 = 1
  5590. }
  5591. if i == "310" {
  5592. is310 = 1
  5593. }
  5594. }
  5595. }
  5596. if is390 == 1 {
  5597. insutype = "390"
  5598. }
  5599. if is310 == 1 {
  5600. insutype = "310"
  5601. }
  5602. if len(insutypes) == 0 {
  5603. insutype = "310"
  5604. }
  5605. if len(insutypes) == 2 {
  5606. insutype = strconv.FormatInt(his.SocialType, 10)
  5607. }
  5608. insutype = strconv.FormatInt(his.SocialType, 10)
  5609. //insutype = "390"
  5610. if his.IdCardType == 1 {
  5611. // cert_no = his.MedicalInsuranceNumber
  5612. cert_no = his.Certno
  5613. } else {
  5614. cert_no = his.Certno
  5615. }
  5616. var res ResultSeven
  5617. var resSeven10265 ResultSeven10265
  5618. var src_resquest string
  5619. var result2 string
  5620. var acct_used_flag string
  5621. fmt.Println("pay_way")
  5622. fmt.Println(pay_way)
  5623. fmt.Println("pay_way")
  5624. if pay_way == 4 {
  5625. acct_used_flag = "1"
  5626. } else {
  5627. acct_used_flag = "0"
  5628. }
  5629. if miConfig.MdtrtareaAdmvs == "421300" {
  5630. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5631. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5632. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5634. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5635. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5636. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5637. resp, requestErr := http.Get(api)
  5638. if requestErr != nil {
  5639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5640. return
  5641. }
  5642. body, ioErr := ioutil.ReadAll(resp.Body)
  5643. if ioErr != nil {
  5644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5646. return
  5647. }
  5648. var respJSON map[string]interface{}
  5649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5652. return
  5653. }
  5654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5655. result, _ := json.Marshal(respJSON)
  5656. if miConfig.Code == "H15049901371" {
  5657. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5658. utils.ErrorLog("解析失败:%v", err)
  5659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5660. return
  5661. }
  5662. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5663. res.Output = resSeven10265.Output
  5664. res.ErrMsg = resSeven10265.ErrMsg
  5665. res.Cainfo = resSeven10265.Cainfo
  5666. res.WarnMsg = resSeven10265.WarnMsg
  5667. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5668. res.Infcode = infocode
  5669. } else {
  5670. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5671. utils.ErrorLog("解析失败:%v", err)
  5672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5673. return
  5674. }
  5675. }
  5676. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5677. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5678. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5679. bas := strings.Split(psn_info.CardInfo, "|")
  5680. if his.IdCardType == 1 {
  5681. cert_no = bas[2]
  5682. } else if his.IdCardType == 3 {
  5683. cert_no = his.Certno
  5684. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5685. } else if his.IdCardType == 4 {
  5686. cert_no = his.Certno
  5687. psn_info.VerifyNumber = token
  5688. }
  5689. var api string
  5690. if miConfig.MdtrtareaAdmvs == "320921" {
  5691. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5692. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5693. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5694. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5695. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5696. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5697. "&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
  5698. } else {
  5699. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5700. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5701. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5702. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5703. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5704. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5705. "&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
  5706. }
  5707. resp, requestErr := http.Get(api)
  5708. if requestErr != nil {
  5709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5710. return
  5711. }
  5712. body, ioErr := ioutil.ReadAll(resp.Body)
  5713. if ioErr != nil {
  5714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5716. return
  5717. }
  5718. var respJSON map[string]interface{}
  5719. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5722. return
  5723. }
  5724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5725. result, _ := json.Marshal(respJSON)
  5726. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5727. utils.ErrorLog("解析失败:%v", err)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. return
  5730. }
  5731. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5732. res.Output = resSeven10265.Output
  5733. res.ErrMsg = resSeven10265.ErrMsg
  5734. res.Cainfo = resSeven10265.Cainfo
  5735. res.WarnMsg = resSeven10265.WarnMsg
  5736. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5737. res.Infcode = infocode
  5738. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5739. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5740. var cert_no string
  5741. if his.IdCardType == 1 {
  5742. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5743. }
  5744. fmt.Println(cert_no)
  5745. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5746. //result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
  5747. var dat map[string]interface{}
  5748. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5749. fmt.Println(dat)
  5750. } else {
  5751. fmt.Println(err)
  5752. }
  5753. saveLog(result2, src_resquest, "2207", "结算")
  5754. userJSONBytes, _ := json.Marshal(dat)
  5755. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5756. utils.ErrorLog("解析失败:%v", err)
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5758. return
  5759. }
  5760. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5761. res.Output = resSeven10265.Output
  5762. res.ErrMsg = resSeven10265.ErrMsg
  5763. res.Cainfo = resSeven10265.Cainfo
  5764. res.WarnMsg = resSeven10265.WarnMsg
  5765. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5766. res.Infcode = infocode
  5767. } else {
  5768. if miConfig.Code == "H15049901371" {
  5769. //赤峰地区国家医保医疗类别
  5770. //职工透析:医疗类别选特殊情况门诊990502
  5771. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5772. var med_type string
  5773. if his.Insutype == "390" {
  5774. if reg_type == 14 {
  5775. med_type = "9933"
  5776. } else if reg_type == 11 {
  5777. med_type = "11"
  5778. }
  5779. } else if his.Insutype == "310" {
  5780. if reg_type == 14 {
  5781. med_type = "990502"
  5782. } else if reg_type == 11 {
  5783. med_type = "11"
  5784. }
  5785. }
  5786. 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)
  5787. } else {
  5788. 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)
  5789. }
  5790. //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)
  5791. var dat map[string]interface{}
  5792. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5793. fmt.Println(dat)
  5794. } else {
  5795. fmt.Println(err)
  5796. }
  5797. saveLog(result2, src_resquest, "2207", "结算")
  5798. userJSONBytes, _ := json.Marshal(dat)
  5799. if miConfig.Code == "H15049901371" {
  5800. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5801. utils.ErrorLog("解析失败:%v", err)
  5802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5803. return
  5804. }
  5805. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5806. res.Output = resSeven10265.Output
  5807. res.ErrMsg = resSeven10265.ErrMsg
  5808. res.Cainfo = resSeven10265.Cainfo
  5809. res.WarnMsg = resSeven10265.WarnMsg
  5810. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5811. res.Infcode = infocode
  5812. } else {
  5813. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5814. utils.ErrorLog("解析失败:%v", err)
  5815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5816. return
  5817. }
  5818. }
  5819. }
  5820. if res.Infcode != 0 {
  5821. errlog := &models.HisOrderError{
  5822. UserOrgId: adminUser.CurrentOrgId,
  5823. Ctime: time.Now().Unix(),
  5824. Mtime: time.Now().Unix(),
  5825. Number: chrg_bchno,
  5826. ErrMsg: res.ErrMsg,
  5827. Status: 1,
  5828. PatientId: id,
  5829. RecordTime: recordDateTime,
  5830. Stage: 6,
  5831. }
  5832. service.CreateErrMsgLog(errlog)
  5833. c.ServeSuccessJSON(map[string]interface{}{
  5834. "failed_code": -10,
  5835. "msg": res.ErrMsg,
  5836. })
  5837. return
  5838. } else {
  5839. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5840. order.OrderStatus = 2
  5841. order.Status = 1
  5842. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5843. order.SetlId = res.Output.Setlinfo.SetlID
  5844. order.PsnNo = res.Output.Setlinfo.PsnNo
  5845. order.PsnName = res.Output.Setlinfo.PsnName
  5846. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5847. order.Certno = res.Output.Setlinfo.Certno
  5848. order.Gend = res.Output.Setlinfo.Gend
  5849. order.Naty = res.Output.Setlinfo.Naty
  5850. order.Age = res.Output.Setlinfo.Age
  5851. order.Insutype = res.Output.Setlinfo.Insutype
  5852. order.PsnType = res.Output.Setlinfo.PsnType
  5853. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5854. order.SetlTime = res.Output.Setlinfo.SetlTime
  5855. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5856. if res.Output.Setlinfo.MedType == "140101" {
  5857. order.MedType = "14"
  5858. } else {
  5859. order.MedType = res.Output.Setlinfo.MedType
  5860. }
  5861. if reg_type == 1112 {
  5862. order.MedType = "1112"
  5863. }
  5864. if reg_type == 1111 {
  5865. order.MedType = "1111"
  5866. }
  5867. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5868. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5869. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5870. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5871. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5872. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5873. order.HifpPay = res.Output.Setlinfo.HifpPay
  5874. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5875. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5876. order.HifesPay = res.Output.Setlinfo.HifesPay
  5877. order.HifobPay = res.Output.Setlinfo.HifobPay
  5878. order.MafPay = res.Output.Setlinfo.MafPay
  5879. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5880. order.OthPay = res.Output.Setlinfo.OthPay
  5881. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5882. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5883. order.AcctPay = res.Output.Setlinfo.AcctPay
  5884. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5885. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5886. order.Balc = res.Output.Setlinfo.Balc
  5887. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5888. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5889. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5890. order.ClrType = res.Output.Setlinfo.ClrType
  5891. order.ClrWay = res.Output.Setlinfo.ClrWay
  5892. order.Creator = order.Creator
  5893. order.Modify = roles.AdminUserId
  5894. order.RequestLog = src_resquest
  5895. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5896. detailStr := string(setlDetail)
  5897. order.SetlDetail = detailStr
  5898. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5899. err = service.UpDateOrder(order)
  5900. if err == nil {
  5901. //判断是否使用了押金
  5902. if dec_way == "true" {
  5903. tmpstring := strconv.FormatInt(order.ID, 10)
  5904. order.Decimal = decimal
  5905. service.UpDateOrder(order)
  5906. //扣押金
  5907. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5908. if errmsg != nil {
  5909. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5910. return
  5911. }
  5912. }
  5913. c.ServeSuccessJSON(map[string]interface{}{
  5914. "msg": "结算成功",
  5915. })
  5916. } else {
  5917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5918. return
  5919. }
  5920. }
  5921. } else {
  5922. adminUser := c.GetAdminUserInfo()
  5923. errlog := &models.HisOrderError{
  5924. UserOrgId: adminUser.CurrentOrgId,
  5925. Ctime: time.Now().Unix(),
  5926. Mtime: time.Now().Unix(),
  5927. ErrMsg: res.ErrMsg,
  5928. Status: 1,
  5929. PatientId: id,
  5930. RecordTime: recordDateTime,
  5931. Stage: 4,
  5932. }
  5933. service.CreateErrMsgLog(errlog)
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5935. return
  5936. }
  5937. } else {
  5938. adminUser := c.GetAdminUserInfo()
  5939. errlog := &models.HisOrderError{
  5940. UserOrgId: adminUser.CurrentOrgId,
  5941. Ctime: time.Now().Unix(),
  5942. Mtime: time.Now().Unix(),
  5943. ErrMsg: res.ErrMsg,
  5944. Status: 1,
  5945. PatientId: id,
  5946. RecordTime: recordDateTime,
  5947. Stage: 4,
  5948. }
  5949. service.CreateErrMsgLog(errlog)
  5950. c.ServeSuccessJSON(map[string]interface{}{
  5951. "failed_code": -10,
  5952. "msg": res.ErrMsg,
  5953. })
  5954. return
  5955. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5956. //return
  5957. }
  5958. }
  5959. }
  5960. } else if tempOrder.ID > 0 {
  5961. if tempOrder.IsPre == 1 {
  5962. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5963. var rf []*ResultFive
  5964. json.Unmarshal([]byte(his.Iinfo), &rf)
  5965. chrg_bchno := tempOrder.Number
  5966. cert_no := his.Certno
  5967. var insutypes []string
  5968. var insutype string
  5969. var is390 int = 0
  5970. var is310 int = 0
  5971. for _, item := range rf {
  5972. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5973. insutypes = append(insutypes, item.Insutype)
  5974. }
  5975. }
  5976. if len(insutypes) == 1 {
  5977. insutype = insutypes[0]
  5978. } else {
  5979. for _, i := range insutypes {
  5980. if i == "390" {
  5981. is390 = 1
  5982. }
  5983. if i == "310" {
  5984. is310 = 1
  5985. }
  5986. }
  5987. }
  5988. if is390 == 1 {
  5989. insutype = "390"
  5990. }
  5991. if is310 == 1 {
  5992. insutype = "310"
  5993. }
  5994. if len(insutypes) == 0 {
  5995. insutype = "310"
  5996. }
  5997. if len(insutypes) == 2 {
  5998. insutype = strconv.FormatInt(his.SocialType, 64)
  5999. }
  6000. //insutype = "390"
  6001. if his.IdCardType == 1 {
  6002. // cert_no = his.MedicalInsuranceNumber
  6003. cert_no = his.Certno
  6004. } else {
  6005. cert_no = his.Certno
  6006. }
  6007. var res ResultSeven
  6008. var resSeven10265 ResultSeven10265
  6009. var src_resquest string
  6010. var result2 string
  6011. var acct_used_flag string
  6012. fmt.Println("pay_way")
  6013. fmt.Println(pay_way)
  6014. fmt.Println("pay_way")
  6015. if pay_way == 4 {
  6016. acct_used_flag = "1"
  6017. } else {
  6018. acct_used_flag = "0"
  6019. }
  6020. if miConfig.MdtrtareaAdmvs == "421300" {
  6021. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6022. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6023. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6024. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6025. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6026. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6027. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6028. resp, requestErr := http.Get(api)
  6029. if requestErr != nil {
  6030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6031. return
  6032. }
  6033. body, ioErr := ioutil.ReadAll(resp.Body)
  6034. if ioErr != nil {
  6035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6037. return
  6038. }
  6039. var respJSON map[string]interface{}
  6040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6043. return
  6044. }
  6045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6046. result, _ := json.Marshal(respJSON)
  6047. fmt.Println("log")
  6048. fmt.Println(string(result))
  6049. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6050. utils.ErrorLog("解析失败:%v", err)
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6055. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6056. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6057. //psn_info, _ := service.GetPsnByPatientId(id)
  6058. bas := strings.Split(psn_info.CardInfo, "|")
  6059. if his.IdCardType == 1 {
  6060. cert_no = bas[2]
  6061. } else {
  6062. cert_no = bas[1]
  6063. }
  6064. //江苏地区国家医保医疗类别
  6065. //职工透析:医疗类别选特殊情况门诊9933
  6066. //居民血透门慢: 医疗类别选门诊慢病1402
  6067. //var med_type string
  6068. //if his.Insutype == "310" {
  6069. // if reg_type == 14 {
  6070. // med_type = "9933"
  6071. // } else if reg_type == 11 {
  6072. // med_type = "11"
  6073. //
  6074. // }
  6075. //} else if his.Insutype == "390" {
  6076. // if reg_type == 14 {
  6077. // med_type = "1402"
  6078. // } else if reg_type == 11 {
  6079. // med_type = "11"
  6080. // }
  6081. //}
  6082. var api string
  6083. if miConfig.MdtrtareaAdmvs == "320921" {
  6084. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6085. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6086. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6088. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6089. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6090. "&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
  6091. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6092. } else {
  6093. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6094. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6095. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6096. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6097. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6098. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6099. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6100. "&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
  6101. }
  6102. resp, requestErr := http.Get(api)
  6103. if requestErr != nil {
  6104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6105. return
  6106. }
  6107. body, ioErr := ioutil.ReadAll(resp.Body)
  6108. if ioErr != nil {
  6109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6111. return
  6112. }
  6113. var respJSON map[string]interface{}
  6114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6117. return
  6118. }
  6119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6120. result, _ := json.Marshal(respJSON)
  6121. fmt.Println("log")
  6122. fmt.Println(string(result))
  6123. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6124. utils.ErrorLog("解析失败:%v", err)
  6125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6126. return
  6127. }
  6128. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6129. res.Output = resSeven10265.Output
  6130. res.ErrMsg = resSeven10265.ErrMsg
  6131. res.Cainfo = resSeven10265.Cainfo
  6132. res.WarnMsg = resSeven10265.WarnMsg
  6133. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6134. res.Infcode = infocode
  6135. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6136. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6137. var cert_no string
  6138. if his.IdCardType == 1 {
  6139. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6140. }
  6141. fmt.Println(cert_no)
  6142. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6143. var dat map[string]interface{}
  6144. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6145. fmt.Println(dat)
  6146. } else {
  6147. fmt.Println(err)
  6148. }
  6149. saveLog(result2, src_resquest, "2207", "结算")
  6150. userJSONBytes, _ := json.Marshal(dat)
  6151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6152. utils.ErrorLog("解析失败:%v", err)
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return
  6155. }
  6156. } else {
  6157. var src_resquest string
  6158. if miConfig.Code == "H15049901371" {
  6159. //赤峰地区国家医保医疗类别
  6160. //职工透析:医疗类别选特殊情况门诊990502
  6161. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6162. var med_type string
  6163. if his.Insutype == "390" {
  6164. if reg_type == 14 {
  6165. med_type = "9933"
  6166. } else if reg_type == 11 {
  6167. med_type = "11"
  6168. }
  6169. } else if his.Insutype == "310" {
  6170. if reg_type == 14 {
  6171. med_type = "990502"
  6172. } else if reg_type == 11 {
  6173. med_type = "11"
  6174. }
  6175. }
  6176. 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)
  6177. } else {
  6178. 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)
  6179. }
  6180. var dat map[string]interface{}
  6181. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6182. fmt.Println(dat)
  6183. } else {
  6184. fmt.Println(err)
  6185. }
  6186. saveLog(result2, src_resquest, "2207", "结算")
  6187. userJSONBytes, _ := json.Marshal(dat)
  6188. if miConfig.Code == "H15049901371" {
  6189. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6190. utils.ErrorLog("解析失败:%v", err)
  6191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6192. return
  6193. }
  6194. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6195. res.Output = resSeven10265.Output
  6196. res.ErrMsg = resSeven10265.ErrMsg
  6197. res.Cainfo = resSeven10265.Cainfo
  6198. res.WarnMsg = resSeven10265.WarnMsg
  6199. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6200. res.Infcode = infocode
  6201. } else {
  6202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6203. utils.ErrorLog("解析失败:%v", err)
  6204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6205. return
  6206. }
  6207. }
  6208. }
  6209. if res.Infcode != 0 {
  6210. errlog := &models.HisOrderError{
  6211. UserOrgId: adminUser.CurrentOrgId,
  6212. Ctime: time.Now().Unix(),
  6213. Mtime: time.Now().Unix(),
  6214. Number: chrg_bchno,
  6215. ErrMsg: res.ErrMsg,
  6216. Status: 1,
  6217. PatientId: id,
  6218. RecordTime: recordDateTime,
  6219. Stage: 6,
  6220. }
  6221. service.CreateErrMsgLog(errlog)
  6222. c.ServeSuccessJSON(map[string]interface{}{
  6223. "failed_code": -10,
  6224. "msg": res.ErrMsg,
  6225. })
  6226. return
  6227. } else {
  6228. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6229. order.OrderStatus = 2
  6230. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6231. order.SetlId = res.Output.Setlinfo.SetlID
  6232. order.PsnNo = res.Output.Setlinfo.PsnNo
  6233. order.PsnName = res.Output.Setlinfo.PsnName
  6234. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6235. order.Certno = res.Output.Setlinfo.Certno
  6236. order.Gend = res.Output.Setlinfo.Gend
  6237. order.Naty = res.Output.Setlinfo.Naty
  6238. order.Age = res.Output.Setlinfo.Age
  6239. order.Insutype = res.Output.Setlinfo.Insutype
  6240. order.PsnType = res.Output.Setlinfo.PsnType
  6241. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6242. order.SetlTime = res.Output.Setlinfo.SetlTime
  6243. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6244. //order.MedType = res.Output.Setlinfo.MedType
  6245. if reg_type == 1112 {
  6246. order.MedType = "1112"
  6247. }
  6248. if reg_type == 1111 {
  6249. order.MedType = "1111"
  6250. }
  6251. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6252. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6253. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6254. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6255. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6256. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6257. order.HifpPay = res.Output.Setlinfo.HifpPay
  6258. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6259. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6260. order.HifesPay = res.Output.Setlinfo.HifesPay
  6261. order.HifobPay = res.Output.Setlinfo.HifobPay
  6262. order.MafPay = res.Output.Setlinfo.MafPay
  6263. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6264. order.OthPay = res.Output.Setlinfo.OthPay
  6265. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6266. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6267. order.AcctPay = res.Output.Setlinfo.AcctPay
  6268. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6269. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6270. order.Balc = res.Output.Setlinfo.Balc
  6271. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6272. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6273. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6274. order.ClrWay = res.Output.Setlinfo.ClrWay
  6275. order.Creator = order.Creator
  6276. order.Modify = roles.AdminUserId
  6277. order.RequestLog = src_resquest
  6278. order.Diagnosis = diagnosis_id
  6279. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6280. detailStr := string(setlDetail)
  6281. order.SetlDetail = detailStr
  6282. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6283. err = service.UpDateOrder(order)
  6284. if err == nil {
  6285. //判断是否使用了押金
  6286. if dec_way == "true" {
  6287. tmpstring := strconv.FormatInt(order.ID, 10)
  6288. //扣押金
  6289. order.Decimal = decimal
  6290. service.UpDateOrder(order)
  6291. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6292. if errmsg != nil {
  6293. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6294. return
  6295. }
  6296. }
  6297. c.ServeSuccessJSON(map[string]interface{}{
  6298. "msg": "结算成功",
  6299. })
  6300. } else {
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6302. return
  6303. }
  6304. }
  6305. }
  6306. }
  6307. }
  6308. //func (c *HisApiController) GetPreUploadInfo() {
  6309. // id, _ := c.GetInt64("id")
  6310. // record_time := c.GetString("record_time")
  6311. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6312. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6313. //
  6314. // timeLayout := "2006-01-02"
  6315. // loc, _ := time.LoadLocation("Local")
  6316. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6317. // if err != nil {
  6318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6319. // return
  6320. // }
  6321. // recordDateTime := theTime.Unix()
  6322. // adminUser := c.GetAdminUserInfo()
  6323. //
  6324. // var prescriptions []*models.HisPrescription
  6325. //
  6326. // var start_time int64
  6327. // var end_time int64
  6328. //
  6329. // data := make(map[string]interface{})
  6330. // if settle_accounts_type == 1 { //日结
  6331. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6332. // data["pre"] = prescriptions
  6333. //
  6334. // } else { //月结
  6335. // start_time_str := c.GetString("start_time")
  6336. // end_time_str := c.GetString("end_time")
  6337. // timeLayout := "2006-01-02"
  6338. // loc, _ := time.LoadLocation("Local")
  6339. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6340. // if err != nil {
  6341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6342. // return
  6343. // }
  6344. // recordStartTime := theStartTime.Unix()
  6345. // start_time = recordStartTime
  6346. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6347. // if err != nil {
  6348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6349. // return
  6350. // }
  6351. // recordEndTime := theEndTime.Unix()
  6352. // end_time = recordEndTime
  6353. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6354. // data["pre"] = prescriptions
  6355. //
  6356. // }
  6357. //
  6358. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6359. //
  6360. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6361. // timestamp := time.Now().Unix()
  6362. // tempTime := time.Unix(timestamp, 0)
  6363. // timeFormat := tempTime.Format("20060102150405")
  6364. // chrgBchno := rand.Intn(100000) + 10000
  6365. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6366. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6367. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6368. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6369. // strconv.FormatInt(his.PatientId, 10)
  6370. // client := &http.Client{}
  6371. // data["psn_no"] = his.PsnNo
  6372. // data["mdtrt_id"] = his.Number
  6373. // data["chrg_bchno"] = chrg_bchno
  6374. // data["org_name"] = miConfig.OrgName
  6375. // data["doctor"] = roles.UserName
  6376. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6377. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6378. // data["fixmedins_code"] = miConfig.Code
  6379. // data["dept_code"] = department.Number
  6380. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6381. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6382. // data["secret_key"] = miConfig.SecretKey
  6383. // var ids []int64
  6384. //
  6385. // for _, item := range prescriptions {
  6386. // ids = append(ids, item.ID)
  6387. // }
  6388. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6389. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6390. // bytesData, _ := json.Marshal(data)
  6391. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6392. // resp, _ := client.Do(req)
  6393. // defer resp.Body.Close()
  6394. // body, ioErr := ioutil.ReadAll(resp.Body)
  6395. // if ioErr != nil {
  6396. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6398. // return
  6399. // }
  6400. // var respJSON map[string]interface{}
  6401. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6402. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6404. // return
  6405. // }
  6406. //
  6407. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6408. // userJSONBytes, _ := json.Marshal(respJSON)
  6409. // var res ResultFour
  6410. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6411. // utils.ErrorLog("解析失败:%v", err)
  6412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. // return
  6414. // }
  6415. //
  6416. // if res.Infcode == 0 {
  6417. // order := &models.HisOrder{
  6418. // UserOrgId: adminUser.CurrentOrgId,
  6419. // HisPatientId: his.ID,
  6420. // PatientId: his.PatientId,
  6421. // SettleAccountsDate: recordDateTime,
  6422. // Ctime: time.Now().Unix(),
  6423. // Mtime: time.Now().Unix(),
  6424. // Status: 1,
  6425. // Number: chrg_bchno,
  6426. // Infcode: res.Infcode,
  6427. // WarnMsg: res.WarnMsg,
  6428. // Cainfo: res.Cainfo,
  6429. // ErrMsg: res.ErrMsg,
  6430. // RespondTime: res.RefmsgTime,
  6431. // InfRefmsgid: res.InfRefmsgid,
  6432. // OrderStatus: 1,
  6433. // IsMedicineInsurance: 1,
  6434. // SettleType: settle_accounts_type,
  6435. // SettleStartTime: start_time,
  6436. // SettleEndTime: end_time,
  6437. // Creator: roles.ID,
  6438. // Modify: roles.ID,
  6439. // PType: 2,
  6440. // }
  6441. // err = service.CreateOrder(order)
  6442. // if err != nil {
  6443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6444. // return
  6445. // }
  6446. //
  6447. // for _, item := range res.Output.Result {
  6448. // temp := strings.Split(item.FeedetlSn, "-")
  6449. // var advice_id int64 = 0
  6450. // var project_id int64 = 0
  6451. // var types int64 = 0
  6452. //
  6453. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6454. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6455. //
  6456. // if temp[1] == "1" {
  6457. // advice_id = id
  6458. // project_id = 0
  6459. // } else if temp[1] == "2" {
  6460. // advice_id = 0
  6461. // project_id = id
  6462. // }
  6463. //
  6464. // info := &models.HisOrderInfo{
  6465. // OrderNumber: order.Number,
  6466. // FeedetlSn: item.FeedetlSn,
  6467. // UploadDate: time.Now().Unix(),
  6468. // AdviceId: advice_id,
  6469. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6470. // Cnt: item.Cnt,
  6471. // Pric: float64(item.Pric),
  6472. // PatientId: his.PatientId,
  6473. // PricUplmtAmt: item.PricUplmtAmt,
  6474. // SelfpayProp: item.SelfpayProp,
  6475. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6476. // OverlmtAmt: item.OverlmtAmt,
  6477. // PreselfpayAmt: item.PreselfpayAmt,
  6478. // BasMednFlag: item.BasMednFlag,
  6479. // MedChrgitmType: item.MedChrgitmType,
  6480. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6481. // Status: 1,
  6482. // Memo: item.Memo,
  6483. // Mtime: time.Now().Unix(),
  6484. // InscpScpAmt: item.InscpScpAmt,
  6485. // DrtReimFlag: item.DrtReimFlag,
  6486. // Ctime: time.Now().Unix(),
  6487. // ListSpItemFlag: item.ListSpItemFlag,
  6488. // ChldMedcFlag: item.ChldMedcFlag,
  6489. // LmtUsedFlag: item.LmtUsedFlag,
  6490. // ChrgitmLv: item.ChrgitmLv,
  6491. // UserOrgId: adminUser.CurrentOrgId,
  6492. // HisPatientId: his.ID,
  6493. // OrderId: order.ID,
  6494. // ProjectId: project_id,
  6495. // Type: types,
  6496. // }
  6497. // service.CreateOrderInfo(info)
  6498. //
  6499. // }
  6500. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6501. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6502. //
  6503. // var total float64
  6504. // for _, item := range prescriptions {
  6505. // if item.Type == 1 { //药品
  6506. // for _, subItem := range item.HisDoctorAdviceInfo {
  6507. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6508. // }
  6509. // }
  6510. // if item.Type == 2 { //项目
  6511. // for _, subItem := range item.HisPrescriptionProject {
  6512. // total = total + (subItem.Price * float64(subItem.Count))
  6513. // }
  6514. // }
  6515. // }
  6516. //
  6517. // for _, item := range prescriptions {
  6518. // for _, subItem := range item.HisAdditionalCharge {
  6519. // total = total + (subItem.Price * float64(subItem.Count))
  6520. // }
  6521. // }
  6522. //
  6523. // allTotal := fmt.Sprintf("%.2f", total)
  6524. // if res.Infcode == 0 {
  6525. // var rf []*ResultFive
  6526. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6527. // psn_no := his.PsnNo
  6528. // mdtrt_id := his.Number
  6529. // chrg_bchno := chrg_bchno
  6530. // cert_no := his.Certno
  6531. // insutype := rf[0].Insutype
  6532. //
  6533. // if his.IdCardType == 1 {
  6534. // cert_no = his.MedicalInsuranceNumber
  6535. //
  6536. // } else {
  6537. //
  6538. // cert_no = his.Certno
  6539. //
  6540. // }
  6541. //
  6542. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6543. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6544. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6545. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6546. // resp, requestErr := http.Get(api)
  6547. // if requestErr != nil {
  6548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6549. // return
  6550. // }
  6551. // defer resp.Body.Close()
  6552. // body, ioErr := ioutil.ReadAll(resp.Body)
  6553. // if ioErr != nil {
  6554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. // return
  6557. // }
  6558. // var respJSON map[string]interface{}
  6559. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6560. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6562. // return
  6563. // }
  6564. // fmt.Println(respJSON)
  6565. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6566. // userJSONBytes, _ := json.Marshal(respJSON)
  6567. // var res ResultSeven
  6568. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6569. // utils.ErrorLog("解析失败:%v", err)
  6570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. // return
  6572. // }
  6573. // if res.Infcode != 0 {
  6574. // errlog := &models.HisOrderError{
  6575. // UserOrgId: adminUser.CurrentOrgId,
  6576. // Ctime: time.Now().Unix(),
  6577. // Mtime: time.Now().Unix(),
  6578. // Number: chrg_bchno,
  6579. // ErrMsg: res.ErrMsg,
  6580. // Status: 1,
  6581. // PatientId: id,
  6582. // RecordTime: recordDateTime,
  6583. // Stage: 7,
  6584. // }
  6585. // service.CreateErrMsgLog(errlog)
  6586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6587. // return
  6588. // } else {
  6589. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6590. // order.OrderStatus = 1
  6591. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6592. // order.SetlId = res.Output.Setlinfo.SetlID
  6593. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6594. // order.PsnName = res.Output.Setlinfo.PsnName
  6595. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6596. // order.Certno = res.Output.Setlinfo.Certno
  6597. // order.Gend = res.Output.Setlinfo.Gend
  6598. // order.Naty = res.Output.Setlinfo.Naty
  6599. // order.Age = res.Output.Setlinfo.Age
  6600. // order.Insutype = res.Output.Setlinfo.Insutype
  6601. // order.PsnType = res.Output.Setlinfo.PsnType
  6602. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6603. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6604. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6605. // order.MedType = res.Output.Setlinfo.MedType
  6606. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6607. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6608. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6609. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6610. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6611. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6612. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6613. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6614. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6615. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6616. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6617. // order.MafPay = res.Output.Setlinfo.MafPay
  6618. // order.OthPay = res.Output.Setlinfo.OthPay
  6619. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6620. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6621. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6622. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6623. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6624. // order.Balc = res.Output.Setlinfo.Balc
  6625. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6626. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6627. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6628. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6629. // order.Creator = order.Creator
  6630. // order.Modify = roles.ID
  6631. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6632. // detailStr := string(setlDetail)
  6633. // order.SetlDetail = detailStr
  6634. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6635. // err = service.UpDateOrder(order)
  6636. // if err == nil {
  6637. // c.ServeSuccessJSON(map[string]interface{}{
  6638. // "msg": "预结算成功",
  6639. // })
  6640. // } else {
  6641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6642. // return
  6643. // }
  6644. // }
  6645. // } else {
  6646. // adminUser := c.GetAdminUserInfo()
  6647. // errlog := &models.HisOrderError{
  6648. // UserOrgId: adminUser.CurrentOrgId,
  6649. // Ctime: time.Now().Unix(),
  6650. // Mtime: time.Now().Unix(),
  6651. // ErrMsg: res.ErrMsg,
  6652. // Status: 1,
  6653. // PatientId: id,
  6654. // RecordTime: recordDateTime,
  6655. // Stage: 4,
  6656. // }
  6657. // service.CreateErrMsgLog(errlog)
  6658. //
  6659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6660. // return
  6661. // }
  6662. // } else {
  6663. // adminUser := c.GetAdminUserInfo()
  6664. // errlog := &models.HisOrderError{
  6665. // UserOrgId: adminUser.CurrentOrgId,
  6666. // Ctime: time.Now().Unix(),
  6667. // Mtime: time.Now().Unix(),
  6668. // ErrMsg: res.ErrMsg,
  6669. // Status: 1,
  6670. // PatientId: id,
  6671. // RecordTime: recordDateTime,
  6672. // Stage: 4,
  6673. // }
  6674. // service.CreateErrMsgLog(errlog)
  6675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6676. // return
  6677. // }
  6678. //
  6679. // } else {
  6680. // var total float64
  6681. // for _, item := range prescriptions {
  6682. // if item.Type == 1 { //药品
  6683. // for _, subItem := range item.HisDoctorAdviceInfo {
  6684. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6685. // }
  6686. // }
  6687. // if item.Type == 2 { //项目
  6688. // for _, subItem := range item.HisPrescriptionProject {
  6689. // total = total + (subItem.Price * float64(subItem.Count))
  6690. // }
  6691. // }
  6692. //
  6693. // for _, subItem := range item.HisAdditionalCharge {
  6694. // total = total + (subItem.Price * float64(subItem.Count))
  6695. // }
  6696. // }
  6697. //
  6698. // allTotal := fmt.Sprintf("%.2f", total)
  6699. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6700. // order := &models.HisOrder{
  6701. // UserOrgId: adminUser.CurrentOrgId,
  6702. // HisPatientId: his.ID,
  6703. // PatientId: id,
  6704. // SettleAccountsDate: recordDateTime,
  6705. // Ctime: time.Now().Unix(),
  6706. // Mtime: time.Now().Unix(),
  6707. // Status: 1,
  6708. // OrderStatus: 2,
  6709. // Number: chrg_bchno,
  6710. // MedfeeSumamt: totals,
  6711. // }
  6712. // err = service.CreateOrder(order)
  6713. // if err != nil {
  6714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6715. // return
  6716. // }
  6717. //
  6718. // var customs []*Custom
  6719. // for _, item := range prescriptions {
  6720. //
  6721. // if item.Type == 1 { //药品
  6722. // for _, subItem := range item.HisDoctorAdviceInfo {
  6723. // cus := &Custom{
  6724. // AdviceId: subItem.ID,
  6725. // ProjectId: 0,
  6726. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6727. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6728. // FeedetlSn: subItem.FeedetlSn,
  6729. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6730. // MedListCodg: subItem.MedListCodg,
  6731. // Type: 1,
  6732. // }
  6733. // customs = append(customs, cus)
  6734. // }
  6735. // }
  6736. //
  6737. // if item.Type == 2 { //项目
  6738. // for _, subItem := range item.HisPrescriptionProject {
  6739. //
  6740. // cus := &Custom{
  6741. // AdviceId: 0,
  6742. // ProjectId: subItem.ID,
  6743. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6744. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6745. // FeedetlSn: subItem.FeedetlSn,
  6746. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6747. // MedListCodg: subItem.MedListCodg,
  6748. // Type: 2,
  6749. // }
  6750. //
  6751. // customs = append(customs, cus)
  6752. // }
  6753. // }
  6754. //
  6755. // for _, item := range item.HisAdditionalCharge {
  6756. // cus := &Custom{
  6757. // ItemId: item.ID,
  6758. // AdviceId: 0,
  6759. // ProjectId: 0,
  6760. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6761. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6762. // FeedetlSn: item.FeedetlSn,
  6763. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6764. // MedListCodg: item.XtHisAddtionConfig.Code,
  6765. // Type: 3,
  6766. // }
  6767. //
  6768. // customs = append(customs, cus)
  6769. // }
  6770. //
  6771. // }
  6772. //
  6773. // for _, item := range customs {
  6774. // var advice_id int64 = 0
  6775. // var project_id int64 = 0
  6776. // var item_id int64 = 0
  6777. //
  6778. // var types int64 = 0
  6779. //
  6780. // if item.Type == 1 {
  6781. // advice_id = item.AdviceId
  6782. // project_id = 0
  6783. // item_id = 0
  6784. // } else if item.Type == 2 {
  6785. // advice_id = 0
  6786. // item_id = 0
  6787. //
  6788. // project_id = item.ProjectId
  6789. // } else if item.Type == 3 {
  6790. // advice_id = 0
  6791. // item_id = item.ItemId
  6792. // project_id = 0
  6793. // }
  6794. //
  6795. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6796. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6797. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6798. //
  6799. // info := &models.HisOrderInfo{
  6800. // OrderNumber: order.Number,
  6801. // UploadDate: time.Now().Unix(),
  6802. // AdviceId: advice_id,
  6803. // DetItemFeeSumamt: detItemFeeSumamt,
  6804. // Cnt: cut,
  6805. // Pric: pric,
  6806. // PatientId: id,
  6807. // Status: 1,
  6808. // Mtime: time.Now().Unix(),
  6809. // Ctime: time.Now().Unix(),
  6810. // UserOrgId: adminUser.CurrentOrgId,
  6811. // HisPatientId: his.ID,
  6812. // OrderId: order.ID,
  6813. // ProjectId: project_id,
  6814. // Type: types,
  6815. // ItemId: item_id,
  6816. // }
  6817. // service.CreateOrderInfo(info)
  6818. // }
  6819. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6820. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6821. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6822. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6823. // if err == nil {
  6824. // c.ServeSuccessJSON(map[string]interface{}{
  6825. // "msg": "结算成功",
  6826. // })
  6827. // } else {
  6828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6829. // return
  6830. // }
  6831. // }
  6832. //}
  6833. //上传明细-预结算-
  6834. func (c *HisApiController) GetPreUploadInfo() {
  6835. id, _ := c.GetInt64("id")
  6836. record_time := c.GetString("record_time")
  6837. his_patient_id, _ := c.GetInt64("his_patient_id")
  6838. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6839. admin_user_id, _ := c.GetInt64("admin_user_id")
  6840. diagnosis_id := c.GetString("diagnosis")
  6841. sick_type, _ := c.GetInt64("sick_type")
  6842. reg_type, _ := c.GetInt64("p_type")
  6843. begin_time := c.GetString("begin_time")
  6844. id_str := c.GetString("ids")
  6845. ids_arr := strings.Split(id_str, ",")
  6846. timeLayout := "2006-01-02"
  6847. loc, _ := time.LoadLocation("Local")
  6848. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6849. if err != nil {
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6851. return
  6852. }
  6853. recordDateTime := theTime.Unix()
  6854. adminUser := c.GetAdminUserInfo()
  6855. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6856. var config []*models.HisXtDiagnoseConfig
  6857. for _, item := range diagnosis_ids {
  6858. id, _ := strconv.ParseInt(item, 10, 64)
  6859. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6860. config = append(config, &diagnosisConfig)
  6861. }
  6862. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6863. sickConfig, _ := service.FindSickById(sick_type)
  6864. var prescriptions []*models.HisPrescription
  6865. var start_time int64
  6866. var end_time int64
  6867. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6868. fmt.Println(his_patient_id)
  6869. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6870. timestamp := time.Now().Unix()
  6871. tempTime := time.Unix(timestamp, 0)
  6872. timeFormat := tempTime.Format("20060102150405")
  6873. chrgBchno := rand.Intn(100000) + 10000
  6874. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6876. var patientPrescription models.HisPrescriptionInfo
  6877. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6878. if patientPrescription.ID == 0 {
  6879. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6880. }
  6881. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6882. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6883. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6884. strconv.FormatInt(his.PatientId, 10)
  6885. var res2 ResultSix
  6886. var resSix10265 ResultSix10265
  6887. var time_stamp string
  6888. if miConfig.MdtrtareaAdmvs == "421300" {
  6889. data := make(map[string]interface{})
  6890. client := &http.Client{}
  6891. data["psn_no"] = his.PsnNo
  6892. data["mdtrt_id"] = his.Number
  6893. data["department"] = department.Name
  6894. data["org_name"] = miConfig.OrgName
  6895. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6896. data["doctor_id"] = doctor_info.DoctorNumber
  6897. data["doctor_name"] = roles.UserName
  6898. data["fixmedins_code"] = miConfig.Code
  6899. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6900. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6901. data["secret_key"] = miConfig.SecretKey
  6902. data["sick_code"] = sickConfig.CountryCode
  6903. data["sick_name"] = sickConfig.ClassName
  6904. data["begin_time"] = begin_time
  6905. data["dept"] = strconv.FormatInt(department.ID, 10)
  6906. data["config"] = config
  6907. data["opter"] = roles.UserName
  6908. fmt.Println(data)
  6909. bytesData, _ := json.Marshal(data)
  6910. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6911. resp, _ := client.Do(req)
  6912. defer resp.Body.Close()
  6913. body, ioErr := ioutil.ReadAll(resp.Body)
  6914. if ioErr != nil {
  6915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. return
  6918. }
  6919. var respJSON map[string]interface{}
  6920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6923. return
  6924. }
  6925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6926. userJSONBytes, _ := json.Marshal(respJSON)
  6927. fmt.Println("log")
  6928. fmt.Println(string(userJSONBytes))
  6929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6930. utils.ErrorLog("解析失败:%v", err)
  6931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6932. return
  6933. }
  6934. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6935. data := make(map[string]interface{})
  6936. client := &http.Client{}
  6937. data["psn_no"] = his.PsnNo
  6938. data["mdtrt_id"] = his.Number
  6939. data["doctor"] = roles.UserName
  6940. data["department"] = department.Name
  6941. data["org_name"] = miConfig.OrgName
  6942. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6943. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6944. data["fixmedins_code"] = miConfig.Code
  6945. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6947. data["secret_key"] = miConfig.SecretKey
  6948. data["sick_code"] = sickConfig.CountryCode
  6949. data["sick_name"] = sickConfig.ClassName
  6950. data["begin_time"] = begin_time
  6951. data["dept"] = strconv.FormatInt(department.ID, 10)
  6952. data["config"] = config
  6953. data["url"] = miConfig.Url
  6954. data["ak"] = miConfig.AccessKey
  6955. data["cainfo"] = miConfig.Cainfo
  6956. bytesData, _ := json.Marshal(data)
  6957. var req *http.Request
  6958. if miConfig.MdtrtareaAdmvs == "320921" {
  6959. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6960. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6961. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6962. } else {
  6963. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6964. }
  6965. resp, _ := client.Do(req)
  6966. defer resp.Body.Close()
  6967. body, ioErr := ioutil.ReadAll(resp.Body)
  6968. if ioErr != nil {
  6969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. return
  6972. }
  6973. var respJSON map[string]interface{}
  6974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6980. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6981. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6983. userJSONBytes, _ := json.Marshal(respJSON)
  6984. fmt.Println("log")
  6985. fmt.Println(string(userJSONBytes))
  6986. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6987. utils.ErrorLog("解析失败:%v", err)
  6988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. return
  6990. }
  6991. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6992. res2.Output = resSix10265.Output
  6993. res2.ErrMsg = resSix10265.ErrMsg
  6994. res2.Cainfo = resSix10265.Cainfo
  6995. res2.WarnMsg = resSix10265.WarnMsg
  6996. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6997. res2.Infcode = infocode
  6998. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6999. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7000. saveLog(result, requestLog, "2203", "上传就诊信息")
  7001. var respJSON2 map[string]interface{}
  7002. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. userJSONBytes2, _ := json.Marshal(respJSON2)
  7008. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7009. utils.ErrorLog("解析失败:%v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. } else {
  7014. var result string
  7015. var requestLog string
  7016. if miConfig.MdtrtareaAdmvs == "440781" { //
  7017. 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)
  7018. } else {
  7019. if miConfig.Code == "H15049901371" {
  7020. //赤峰地区国家医保医疗类别
  7021. //职工透析:医疗类别选特殊情况门诊990502
  7022. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7023. var med_type string
  7024. if his.Insutype == "390" {
  7025. if reg_type == 14 {
  7026. med_type = "9933"
  7027. } else if reg_type == 11 {
  7028. med_type = "11"
  7029. }
  7030. } else if his.Insutype == "310" {
  7031. if reg_type == 14 {
  7032. med_type = "990502"
  7033. } else if reg_type == 11 {
  7034. med_type = "11"
  7035. }
  7036. }
  7037. 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)
  7038. } else {
  7039. 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)
  7040. }
  7041. saveLog(result, requestLog, "2203", "上传就诊信息")
  7042. var respJSON2 map[string]interface{}
  7043. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. userJSONBytes2, _ := json.Marshal(respJSON2)
  7049. if miConfig.Code == "H15049901371" {
  7050. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7051. utils.ErrorLog("解析失败:%v", err)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. return
  7054. }
  7055. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7056. res2.Output = resSix10265.Output
  7057. res2.ErrMsg = resSix10265.ErrMsg
  7058. res2.Cainfo = resSix10265.Cainfo
  7059. res2.WarnMsg = resSix10265.WarnMsg
  7060. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7061. res2.Infcode = infocode
  7062. } else {
  7063. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7064. utils.ErrorLog("解析失败:%v", err)
  7065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7066. return
  7067. }
  7068. }
  7069. }
  7070. }
  7071. if res2.Infcode != 0 {
  7072. adminUser := c.GetAdminUserInfo()
  7073. errlog := &models.HisOrderError{
  7074. UserOrgId: adminUser.CurrentOrgId,
  7075. Ctime: time.Now().Unix(),
  7076. Mtime: time.Now().Unix(),
  7077. ErrMsg: res2.ErrMsg,
  7078. Status: 1,
  7079. PatientId: id,
  7080. RecordTime: recordDateTime,
  7081. Stage: 3,
  7082. }
  7083. service.CreateErrMsgLog(errlog)
  7084. c.ServeSuccessJSON(map[string]interface{}{
  7085. "failed_code": -10,
  7086. "msg": res2.ErrMsg,
  7087. })
  7088. return
  7089. } else {
  7090. his.Diagnosis = diagnosis_id
  7091. his.SickType = sickConfig.ID
  7092. his.PType = fmt.Sprintf("%d", reg_type)
  7093. service.UpdateHisPatientThree(&his)
  7094. data := make(map[string]interface{})
  7095. if settle_accounts_type == 1 { //日结
  7096. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7097. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7098. } else {
  7099. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7100. }
  7101. data["pre"] = prescriptions
  7102. } else { //月结
  7103. start_time_str := c.GetString("start_time")
  7104. end_time_str := c.GetString("end_time")
  7105. timeLayout := "2006-01-02"
  7106. loc, _ := time.LoadLocation("Local")
  7107. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7108. if err != nil {
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7110. return
  7111. }
  7112. recordStartTime := theStartTime.Unix()
  7113. start_time = recordStartTime
  7114. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7115. if err != nil {
  7116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7117. return
  7118. }
  7119. recordEndTime := theEndTime.Unix()
  7120. end_time = recordEndTime
  7121. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7122. data["pre"] = prescriptions
  7123. }
  7124. client := &http.Client{}
  7125. data["psn_no"] = his.PsnNo
  7126. data["mdtrt_id"] = his.Number
  7127. data["chrg_bchno"] = chrg_bchno
  7128. data["org_name"] = miConfig.OrgName
  7129. data["doctor"] = roles.UserName
  7130. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7131. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7132. data["fixmedins_code"] = miConfig.Code
  7133. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7134. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7135. data["dept_code"] = "15"
  7136. } else {
  7137. data["dept_code"] = department.Number
  7138. }
  7139. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7140. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7141. data["secret_key"] = miConfig.SecretKey
  7142. data["url"] = miConfig.Url
  7143. data["ak"] = miConfig.AccessKey
  7144. data["new_doctor_name"] = patientPrescription.Doctor
  7145. data["diag_code"] = sickConfig.CountryCode
  7146. data["time_stamp"] = time_stamp
  7147. data["cainfo"] = miConfig.Cainfo
  7148. var ids []int64
  7149. for _, item := range prescriptions {
  7150. ids = append(ids, item.ID)
  7151. }
  7152. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7153. if config.IsOpen == 1 { //对接了医保,走医保流程
  7154. var res ResultFour
  7155. var resFour10265 ResultFour10265
  7156. if miConfig.MdtrtareaAdmvs == "421300" {
  7157. bytesData, _ := json.Marshal(data)
  7158. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7159. resp, _ := client.Do(req)
  7160. defer resp.Body.Close()
  7161. body, ioErr := ioutil.ReadAll(resp.Body)
  7162. if ioErr != nil {
  7163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. return
  7166. }
  7167. var respJSON map[string]interface{}
  7168. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. return
  7172. }
  7173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7174. userJSONBytes, _ := json.Marshal(respJSON)
  7175. fmt.Println("log")
  7176. fmt.Println(string(userJSONBytes))
  7177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7178. utils.ErrorLog("解析失败:%v", err)
  7179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7180. return
  7181. }
  7182. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7183. bytesData, _ := json.Marshal(data)
  7184. var req *http.Request
  7185. if miConfig.MdtrtareaAdmvs == "320921" {
  7186. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7187. } else {
  7188. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7189. }
  7190. resp, _ := client.Do(req)
  7191. defer resp.Body.Close()
  7192. body, ioErr := ioutil.ReadAll(resp.Body)
  7193. if ioErr != nil {
  7194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. return
  7197. }
  7198. var respJSON map[string]interface{}
  7199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. return
  7203. }
  7204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7205. userJSONBytes, _ := json.Marshal(respJSON)
  7206. fmt.Println("log")
  7207. fmt.Println(string(userJSONBytes))
  7208. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7209. utils.ErrorLog("解析失败:%v", err)
  7210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7211. return
  7212. }
  7213. res.InfRefmsgid = resFour10265.InfRefmsgid
  7214. res.Output = resFour10265.Output
  7215. res.ErrMsg = resFour10265.ErrMsg
  7216. res.Cainfo = resFour10265.Cainfo
  7217. res.WarnMsg = resFour10265.WarnMsg
  7218. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7219. res.Infcode = infocode
  7220. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7221. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7222. var dat map[string]interface{}
  7223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7224. fmt.Println(dat)
  7225. } else {
  7226. fmt.Println(err)
  7227. }
  7228. saveLog(result, request_log, "2204", "上传费用明细")
  7229. userJSONBytes, _ := json.Marshal(dat)
  7230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7231. utils.ErrorLog("解析失败:%v", err)
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. } else {
  7236. if miConfig.Code == "H15049901371" {
  7237. 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)
  7238. var dat map[string]interface{}
  7239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7240. fmt.Println(dat)
  7241. } else {
  7242. fmt.Println(err)
  7243. }
  7244. saveLog(result, request_log, "2204", "上传费用明细")
  7245. userJSONBytes, _ := json.Marshal(dat)
  7246. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7247. utils.ErrorLog("解析失败:%v", err)
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. res.InfRefmsgid = resFour10265.InfRefmsgid
  7252. res.Output = resFour10265.Output
  7253. res.ErrMsg = resFour10265.ErrMsg
  7254. res.Cainfo = resFour10265.Cainfo
  7255. res.WarnMsg = resFour10265.WarnMsg
  7256. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7257. res.Infcode = infocode
  7258. } else {
  7259. 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)
  7260. var dat map[string]interface{}
  7261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7262. fmt.Println(dat)
  7263. } else {
  7264. fmt.Println(err)
  7265. }
  7266. saveLog(result, request_log, "2204", "上传费用明细")
  7267. userJSONBytes, _ := json.Marshal(dat)
  7268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7269. utils.ErrorLog("解析失败:%v", err)
  7270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7271. return
  7272. }
  7273. }
  7274. }
  7275. if res.Infcode == 0 {
  7276. order := &models.HisOrder{
  7277. UserOrgId: adminUser.CurrentOrgId,
  7278. HisPatientId: his.ID,
  7279. PatientId: his.PatientId,
  7280. SettleAccountsDate: recordDateTime,
  7281. Ctime: time.Now().Unix(),
  7282. Mtime: time.Now().Unix(),
  7283. MdtrtId: his.Number,
  7284. PsnNo: his.PsnNo,
  7285. MedType: strconv.FormatInt(reg_type, 10),
  7286. Status: 1,
  7287. Number: chrg_bchno,
  7288. Infcode: res.Infcode,
  7289. WarnMsg: res.WarnMsg,
  7290. Cainfo: res.Cainfo,
  7291. ErrMsg: res.ErrMsg,
  7292. RespondTime: res.RefmsgTime,
  7293. InfRefmsgid: res.InfRefmsgid,
  7294. OrderStatus: 1,
  7295. IsMedicineInsurance: 1,
  7296. SettleType: settle_accounts_type,
  7297. SettleStartTime: start_time,
  7298. SettleEndTime: end_time,
  7299. Creator: roles.AdminUserId,
  7300. Modify: roles.AdminUserId,
  7301. PType: 2,
  7302. Diagnosis: diagnosis_id,
  7303. }
  7304. err = service.CreateOrder(order)
  7305. if err != nil {
  7306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7307. return
  7308. }
  7309. for _, item := range res.Output.Result {
  7310. temp := strings.Split(item.FeedetlSn, "-")
  7311. var advice_id int64 = 0
  7312. var project_id int64 = 0
  7313. var types int64 = 0
  7314. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7315. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7316. if temp[1] == "1" {
  7317. advice_id = id
  7318. project_id = 0
  7319. } else if temp[1] == "2" {
  7320. advice_id = 0
  7321. project_id = id
  7322. }
  7323. info := &models.HisOrderInfo{
  7324. OrderNumber: order.Number,
  7325. FeedetlSn: item.FeedetlSn,
  7326. UploadDate: time.Now().Unix(),
  7327. AdviceId: advice_id,
  7328. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7329. Cnt: item.Cnt,
  7330. Pric: float64(item.Pric),
  7331. PatientId: his.PatientId,
  7332. PricUplmtAmt: item.PricUplmtAmt,
  7333. SelfpayProp: item.SelfpayProp,
  7334. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7335. OverlmtAmt: item.OverlmtAmt,
  7336. PreselfpayAmt: item.PreselfpayAmt,
  7337. BasMednFlag: item.BasMednFlag,
  7338. MedChrgitmType: item.MedChrgitmType,
  7339. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7340. Status: 1,
  7341. Memo: item.Memo,
  7342. Mtime: time.Now().Unix(),
  7343. InscpScpAmt: item.InscpScpAmt,
  7344. DrtReimFlag: item.DrtReimFlag,
  7345. Ctime: time.Now().Unix(),
  7346. ListSpItemFlag: item.ListSpItemFlag,
  7347. ChldMedcFlag: item.ChldMedcFlag,
  7348. LmtUsedFlag: item.LmtUsedFlag,
  7349. ChrgitmLv: item.ChrgitmLv,
  7350. UserOrgId: adminUser.CurrentOrgId,
  7351. HisPatientId: his.ID,
  7352. OrderId: order.ID,
  7353. ProjectId: project_id,
  7354. Type: types,
  7355. }
  7356. service.CreateOrderInfo(info)
  7357. }
  7358. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7359. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7360. var total float64
  7361. for _, item := range prescriptions {
  7362. if item.Type == 1 { //药品
  7363. for _, subItem := range item.HisDoctorAdviceInfo {
  7364. total = total + (subItem.Price * subItem.PrescribingNumber)
  7365. }
  7366. }
  7367. if item.Type == 2 { //项目
  7368. for _, subItem := range item.HisPrescriptionProject {
  7369. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7370. total = total + (subItem.Price * cnt)
  7371. }
  7372. }
  7373. }
  7374. for _, item := range prescriptions {
  7375. for _, subItem := range item.HisAdditionalCharge {
  7376. total = total + (subItem.Price * float64(subItem.Count))
  7377. }
  7378. }
  7379. allTotal := fmt.Sprintf("%.4f", total)
  7380. if res.Infcode == 0 {
  7381. var rf []*ResultFive
  7382. json.Unmarshal([]byte(his.Iinfo), &rf)
  7383. chrg_bchno := chrg_bchno
  7384. cert_no := his.Certno
  7385. var insutypes []string
  7386. var insutype string
  7387. var is390 int = 0
  7388. var is310 int = 0
  7389. for _, item := range rf {
  7390. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7391. insutypes = append(insutypes, item.Insutype)
  7392. }
  7393. }
  7394. if len(insutypes) == 1 {
  7395. insutype = insutypes[0]
  7396. } else {
  7397. for _, i := range insutypes {
  7398. if i == "390" {
  7399. is390 = 1
  7400. }
  7401. if i == "310" {
  7402. is310 = 1
  7403. }
  7404. }
  7405. }
  7406. if is390 == 1 {
  7407. insutype = "390"
  7408. }
  7409. if is310 == 1 {
  7410. insutype = "310"
  7411. }
  7412. if len(insutypes) == 0 {
  7413. insutype = "310"
  7414. }
  7415. if len(insutypes) == 2 {
  7416. insutype = strconv.FormatInt(his.SocialType, 64)
  7417. }
  7418. //insutype = "390"
  7419. if his.IdCardType == 1 {
  7420. cert_no = his.MedicalInsuranceNumber
  7421. } else {
  7422. cert_no = his.Certno
  7423. }
  7424. var res ResultSeven
  7425. var resSeven10265 ResultSeven10265
  7426. if miConfig.MdtrtareaAdmvs == "421300" {
  7427. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7428. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7429. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7431. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7432. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7433. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7434. resp, requestErr := http.Get(api)
  7435. if requestErr != nil {
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7437. return
  7438. }
  7439. body, ioErr := ioutil.ReadAll(resp.Body)
  7440. if ioErr != nil {
  7441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7443. return
  7444. }
  7445. var respJSON map[string]interface{}
  7446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7452. result, _ := json.Marshal(respJSON)
  7453. fmt.Println("log")
  7454. fmt.Println(string(result))
  7455. if err := json.Unmarshal([]byte(result), &res); 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. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7462. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7463. bas := strings.Split(psn_info.CardInfo, "|")
  7464. if his.IdCardType == 1 {
  7465. cert_no = bas[2]
  7466. } else {
  7467. cert_no = bas[1]
  7468. }
  7469. //江苏地区国家医保医疗类别
  7470. //职工透析:医疗类别选特殊情况门诊9933
  7471. //居民血透门慢: 医疗类别选门诊慢病1402
  7472. //var med_type string
  7473. //if his.Insutype == "310" {
  7474. // if reg_type == 14 {
  7475. // med_type = "9933"
  7476. // } else if reg_type == 11 {
  7477. // med_type = "11"
  7478. //
  7479. // }
  7480. //} else if his.Insutype == "390" {
  7481. // if reg_type == 14 {
  7482. // med_type = "1402"
  7483. // } else if reg_type == 11 {
  7484. // med_type = "11"
  7485. // }
  7486. //}
  7487. var api string
  7488. if miConfig.MdtrtareaAdmvs == "320921" {
  7489. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7490. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7491. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7492. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7493. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7494. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7495. "&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
  7496. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7497. } else {
  7498. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7499. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7500. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7501. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7503. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7504. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7505. "&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
  7506. }
  7507. resp, requestErr := http.Get(api)
  7508. if requestErr != nil {
  7509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7510. return
  7511. }
  7512. body, ioErr := ioutil.ReadAll(resp.Body)
  7513. if ioErr != nil {
  7514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7516. return
  7517. }
  7518. var respJSON map[string]interface{}
  7519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7522. return
  7523. }
  7524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7525. result, _ := json.Marshal(respJSON)
  7526. fmt.Println("log")
  7527. fmt.Println(string(result))
  7528. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7529. utils.ErrorLog("解析失败:%v", err)
  7530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7531. return
  7532. }
  7533. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7534. res.Output = resSeven10265.Output
  7535. res.ErrMsg = resSeven10265.ErrMsg
  7536. res.Cainfo = resSeven10265.Cainfo
  7537. res.WarnMsg = resSeven10265.WarnMsg
  7538. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7539. res.Infcode = infocode
  7540. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7541. result, request_log, _ := service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7542. var dat map[string]interface{}
  7543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7544. fmt.Println(dat)
  7545. } else {
  7546. fmt.Println(err)
  7547. }
  7548. saveLog(result, request_log, "2206", "预结算")
  7549. userJSONBytes, _ := json.Marshal(dat)
  7550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7551. utils.ErrorLog("解析失败:%v", err)
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. } else {
  7556. var result string
  7557. var request_log string
  7558. if miConfig.Code == "H15049901371" {
  7559. //赤峰地区国家医保医疗类别
  7560. //职工透析:医疗类别选特殊情况门诊990502
  7561. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7562. var med_type string
  7563. if his.Insutype == "390" {
  7564. if reg_type == 14 {
  7565. med_type = "9933"
  7566. } else if reg_type == 11 {
  7567. med_type = "11"
  7568. }
  7569. } else if his.Insutype == "310" {
  7570. if reg_type == 14 {
  7571. med_type = "990502"
  7572. } else if reg_type == 11 {
  7573. med_type = "11"
  7574. }
  7575. }
  7576. 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)
  7577. } else {
  7578. 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)
  7579. }
  7580. var dat map[string]interface{}
  7581. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7582. fmt.Println(dat)
  7583. } else {
  7584. fmt.Println(err)
  7585. }
  7586. saveLog(result, request_log, "2206", "预结算")
  7587. //userJSONBytes, _ := json.Marshal(dat)
  7588. //
  7589. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7590. // utils.ErrorLog("解析失败:%v", err)
  7591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7592. // return
  7593. //}
  7594. userJSONBytes, _ := json.Marshal(dat)
  7595. if miConfig.Code == "H15049901371" {
  7596. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7597. utils.ErrorLog("解析失败:%v", err)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. return
  7600. }
  7601. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7602. res.Output = resSeven10265.Output
  7603. res.ErrMsg = resSeven10265.ErrMsg
  7604. res.Cainfo = resSeven10265.Cainfo
  7605. res.WarnMsg = resSeven10265.WarnMsg
  7606. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7607. res.Infcode = infocode
  7608. } else {
  7609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7610. utils.ErrorLog("解析失败:%v", err)
  7611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7612. return
  7613. }
  7614. }
  7615. }
  7616. if res.Infcode != 0 {
  7617. errlog := &models.HisOrderError{
  7618. UserOrgId: adminUser.CurrentOrgId,
  7619. Ctime: time.Now().Unix(),
  7620. Mtime: time.Now().Unix(),
  7621. Number: chrg_bchno,
  7622. ErrMsg: res.ErrMsg,
  7623. Status: 1,
  7624. PatientId: id,
  7625. RecordTime: recordDateTime,
  7626. Stage: 20,
  7627. }
  7628. service.CreateErrMsgLog(errlog)
  7629. c.ServeSuccessJSON(map[string]interface{}{
  7630. "failed_code": -10,
  7631. "msg": res.ErrMsg,
  7632. })
  7633. return
  7634. } else {
  7635. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7636. order.OrderStatus = 1
  7637. order.IsPre = 1
  7638. order.Status = 1
  7639. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7640. order.SetlId = res.Output.Setlinfo.SetlID
  7641. order.PsnNo = res.Output.Setlinfo.PsnNo
  7642. order.PsnName = res.Output.Setlinfo.PsnName
  7643. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7644. order.Certno = res.Output.Setlinfo.Certno
  7645. order.Gend = res.Output.Setlinfo.Gend
  7646. order.Naty = res.Output.Setlinfo.Naty
  7647. order.Age = res.Output.Setlinfo.Age
  7648. order.Insutype = res.Output.Setlinfo.Insutype
  7649. order.PsnType = res.Output.Setlinfo.PsnType
  7650. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7651. order.SetlTime = res.Output.Setlinfo.SetlTime
  7652. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7653. if res.Output.Setlinfo.MedType == "140101" {
  7654. order.MedType = "14"
  7655. } else {
  7656. order.MedType = res.Output.Setlinfo.MedType
  7657. }
  7658. if reg_type == 1112 {
  7659. order.MedType = "1112"
  7660. }
  7661. if reg_type == 1111 {
  7662. order.MedType = "1111"
  7663. }
  7664. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7665. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7666. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7667. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7668. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7669. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7670. order.HifpPay = res.Output.Setlinfo.HifpPay
  7671. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7672. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7673. order.HifesPay = res.Output.Setlinfo.HifesPay
  7674. order.HifobPay = res.Output.Setlinfo.HifobPay
  7675. order.MafPay = res.Output.Setlinfo.MafPay
  7676. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7677. order.OthPay = res.Output.Setlinfo.OthPay
  7678. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7679. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7680. order.AcctPay = res.Output.Setlinfo.AcctPay
  7681. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7682. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7683. order.Balc = res.Output.Setlinfo.Balc
  7684. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7685. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7686. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7687. order.ClrWay = res.Output.Setlinfo.ClrWay
  7688. order.Creator = order.Creator
  7689. order.Modify = roles.AdminUserId
  7690. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7691. detailStr := string(setlDetail)
  7692. order.SetlDetail = detailStr
  7693. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7694. err = service.UpDateOrder(order)
  7695. if err == nil {
  7696. c.ServeSuccessJSON(map[string]interface{}{
  7697. "msg": "预结算成功",
  7698. })
  7699. } else {
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7701. return
  7702. }
  7703. }
  7704. } else {
  7705. adminUser := c.GetAdminUserInfo()
  7706. errlog := &models.HisOrderError{
  7707. UserOrgId: adminUser.CurrentOrgId,
  7708. Ctime: time.Now().Unix(),
  7709. Mtime: time.Now().Unix(),
  7710. ErrMsg: res.ErrMsg,
  7711. Status: 1,
  7712. PatientId: id,
  7713. RecordTime: recordDateTime,
  7714. Stage: 4,
  7715. }
  7716. service.CreateErrMsgLog(errlog)
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7718. return
  7719. }
  7720. } else {
  7721. adminUser := c.GetAdminUserInfo()
  7722. errlog := &models.HisOrderError{
  7723. UserOrgId: adminUser.CurrentOrgId,
  7724. Ctime: time.Now().Unix(),
  7725. Mtime: time.Now().Unix(),
  7726. ErrMsg: res.ErrMsg,
  7727. Status: 1,
  7728. PatientId: id,
  7729. RecordTime: recordDateTime,
  7730. Stage: 4,
  7731. }
  7732. service.CreateErrMsgLog(errlog)
  7733. c.ServeSuccessJSON(map[string]interface{}{
  7734. "failed_code": -10,
  7735. "msg": res.ErrMsg,
  7736. })
  7737. return
  7738. }
  7739. }
  7740. }
  7741. }
  7742. //退款
  7743. func (c *HisApiController) Refund() {
  7744. order_id, _ := c.GetInt64("order_id")
  7745. admin_user_id, _ := c.GetInt64("admin_user_id")
  7746. adminUser := c.GetAdminUserInfo()
  7747. var order models.HisOrder
  7748. order, _ = service.GetHisOrderByID(order_id)
  7749. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7750. if order.ID == 0 {
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7752. return
  7753. }
  7754. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7755. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7756. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7757. if config.IsOpen == 1 { //对接了医保,走医保流程
  7758. var res ResultSixteen
  7759. var resSixteen10265 ResultSixteen10265
  7760. var src_resquest string
  7761. var result string
  7762. if miConfig.MdtrtareaAdmvs == "421300" {
  7763. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7764. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7766. resp3, requestErr3 := http.Get(api3)
  7767. if requestErr3 != nil {
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7769. return
  7770. }
  7771. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7772. if ioErr3 != nil {
  7773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7775. return
  7776. }
  7777. var respJSON3 map[string]interface{}
  7778. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7781. return
  7782. }
  7783. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7784. userJSONBytes3, _ := json.Marshal(respJSON3)
  7785. fmt.Println("log")
  7786. fmt.Println(string(userJSONBytes3))
  7787. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7788. utils.ErrorLog("解析失败:%v", err)
  7789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7790. return
  7791. }
  7792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7793. var api3 string
  7794. if miConfig.MdtrtareaAdmvs == "320921" {
  7795. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7796. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7797. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7798. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7799. } else {
  7800. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7801. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7802. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7803. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7804. }
  7805. resp3, requestErr3 := http.Get(api3)
  7806. if requestErr3 != nil {
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. return
  7809. }
  7810. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7811. if ioErr3 != nil {
  7812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. return
  7815. }
  7816. var respJSON3 map[string]interface{}
  7817. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7820. return
  7821. }
  7822. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7823. userJSONBytes3, _ := json.Marshal(respJSON3)
  7824. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7825. utils.ErrorLog("解析失败:%v", err)
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7827. return
  7828. }
  7829. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7830. res.Output = resSixteen10265.Output
  7831. res.ErrMsg = resSixteen10265.ErrMsg
  7832. res.Cainfo = resSixteen10265.Cainfo
  7833. res.WarnMsg = resSixteen10265.WarnMsg
  7834. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7835. res.Infcode = infocode
  7836. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7837. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7838. var dat map[string]interface{}
  7839. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7840. fmt.Println(dat)
  7841. } else {
  7842. fmt.Println(err)
  7843. }
  7844. saveLog(result, src_resquest, "2208", "退费")
  7845. userJSONBytes, _ := json.Marshal(dat)
  7846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7847. utils.ErrorLog("解析失败:%v", err)
  7848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7849. return
  7850. }
  7851. } else {
  7852. if miConfig.Code == "H15049901371" {
  7853. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7854. var dat map[string]interface{}
  7855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7856. fmt.Println(dat)
  7857. } else {
  7858. fmt.Println(err)
  7859. }
  7860. saveLog(result, src_resquest, "2208", "退费")
  7861. userJSONBytes, _ := json.Marshal(dat)
  7862. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7863. utils.ErrorLog("解析失败:%v", err)
  7864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7865. return
  7866. }
  7867. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7868. res.Output = resSixteen10265.Output
  7869. res.ErrMsg = resSixteen10265.ErrMsg
  7870. res.Cainfo = resSixteen10265.Cainfo
  7871. res.WarnMsg = resSixteen10265.WarnMsg
  7872. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7873. res.Infcode = infocode
  7874. } else {
  7875. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7876. var dat map[string]interface{}
  7877. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7878. fmt.Println(dat)
  7879. } else {
  7880. fmt.Println(err)
  7881. }
  7882. saveLog(result, src_resquest, "2208", "退费")
  7883. userJSONBytes, _ := json.Marshal(dat)
  7884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7885. utils.ErrorLog("解析失败:%v", err)
  7886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7887. return
  7888. }
  7889. }
  7890. }
  7891. if res.Infcode == 0 {
  7892. var res2 ResultSix
  7893. var resSix10265 ResultSix10265
  7894. if miConfig.MdtrtareaAdmvs == "421300" {
  7895. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7896. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7898. resp3, requestErr3 := http.Get(api3)
  7899. if requestErr3 != nil {
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7904. if ioErr3 != nil {
  7905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. var respJSON3 map[string]interface{}
  7910. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7916. userJSONBytes3, _ := json.Marshal(respJSON3)
  7917. fmt.Println("log")
  7918. fmt.Println(string(userJSONBytes3))
  7919. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7920. utils.ErrorLog("解析失败:%v", err)
  7921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7922. return
  7923. }
  7924. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7925. var api3 string
  7926. if miConfig.MdtrtareaAdmvs == "320921" {
  7927. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7928. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7929. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7930. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7931. } else {
  7932. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7933. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7934. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7935. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7936. }
  7937. resp3, requestErr3 := http.Get(api3)
  7938. if requestErr3 != nil {
  7939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7940. return
  7941. }
  7942. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7943. if ioErr3 != nil {
  7944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. return
  7947. }
  7948. var respJSON3 map[string]interface{}
  7949. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. return
  7953. }
  7954. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7955. userJSONBytes3, _ := json.Marshal(respJSON3)
  7956. fmt.Println("log")
  7957. fmt.Println(string(userJSONBytes3))
  7958. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7959. utils.ErrorLog("解析失败:%v", err)
  7960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. return
  7962. }
  7963. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7964. res2.Output = resSix10265.Output
  7965. res2.ErrMsg = resSix10265.ErrMsg
  7966. res2.Cainfo = resSix10265.Cainfo
  7967. res2.WarnMsg = resSix10265.WarnMsg
  7968. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7969. res2.Infcode = infocode
  7970. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7971. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7972. var dat map[string]interface{}
  7973. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7974. fmt.Println(dat)
  7975. } else {
  7976. fmt.Println(err)
  7977. }
  7978. saveLog(result2, src_request, "2205", "撤销明细")
  7979. userJSONBytes, _ := json.Marshal(dat)
  7980. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7981. utils.ErrorLog("解析失败:%v", err)
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7983. return
  7984. }
  7985. } else {
  7986. if miConfig.Code == "H15049901371" {
  7987. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7988. var dat map[string]interface{}
  7989. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7990. fmt.Println(dat)
  7991. } else {
  7992. fmt.Println(err)
  7993. }
  7994. saveLog(result2, src_request, "2205", "撤销明细")
  7995. userJSONBytes, _ := json.Marshal(dat)
  7996. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7997. utils.ErrorLog("解析失败:%v", err)
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7999. return
  8000. }
  8001. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8002. res2.Output = resSix10265.Output
  8003. res2.ErrMsg = resSix10265.ErrMsg
  8004. res2.Cainfo = resSix10265.Cainfo
  8005. res2.WarnMsg = resSix10265.WarnMsg
  8006. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8007. res2.Infcode = infocode
  8008. } else {
  8009. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8010. var dat map[string]interface{}
  8011. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8012. fmt.Println(dat)
  8013. } else {
  8014. fmt.Println(err)
  8015. }
  8016. saveLog(result2, src_request, "2205", "撤销明细")
  8017. userJSONBytes, _ := json.Marshal(dat)
  8018. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8019. utils.ErrorLog("解析失败:%v", err)
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8021. return
  8022. }
  8023. }
  8024. }
  8025. if res2.Infcode == 0 {
  8026. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8027. if err == nil {
  8028. //当押金不为零时产生退费记录
  8029. if order.Decimal != 0 {
  8030. tmp := strconv.FormatInt(order.ID, 10)
  8031. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8032. if err != nil {
  8033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8034. return
  8035. }
  8036. }
  8037. c.ServeSuccessJSON(map[string]interface{}{
  8038. "msg": "退费成功",
  8039. })
  8040. } else {
  8041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8042. return
  8043. }
  8044. } else {
  8045. c.ServeSuccessJSON(map[string]interface{}{
  8046. "code": -10,
  8047. "msg": res2.ErrMsg,
  8048. })
  8049. }
  8050. } else {
  8051. c.ServeSuccessJSON(map[string]interface{}{
  8052. "code": -10,
  8053. "msg": res.ErrMsg,
  8054. })
  8055. }
  8056. }
  8057. }
  8058. func (c *HisApiController) RefundNumber() {
  8059. record_time := c.GetString("record_time")
  8060. //patient_id, _ := c.GetInt64("patient_id")
  8061. admin_user_id, _ := c.GetInt64("admin_user_id")
  8062. his_patient_id, _ := c.GetInt64("id")
  8063. timeLayout := "2006-01-02"
  8064. loc, _ := time.LoadLocation("Local")
  8065. adminUser := c.GetAdminUserInfo()
  8066. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8067. fmt.Println(err)
  8068. if err != nil {
  8069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8070. return
  8071. }
  8072. recordDateTime := theTime.Unix()
  8073. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8074. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8075. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8076. //order, _ := service.GetHisOrderByID(order_id)
  8077. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8078. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8079. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8080. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8081. if count > 0 {
  8082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8083. return
  8084. }
  8085. if config.IsOpen == 1 { //对接了医保,走医保流程
  8086. var res2 ResultSix
  8087. var resSix10265 ResultSix10265
  8088. if miConfig.MdtrtareaAdmvs == "421300" {
  8089. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8090. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8092. resp3, requestErr3 := http.Get(api3)
  8093. if requestErr3 != nil {
  8094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8095. return
  8096. }
  8097. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8098. if ioErr3 != nil {
  8099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8101. return
  8102. }
  8103. var respJSON3 map[string]interface{}
  8104. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8107. return
  8108. }
  8109. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8110. userJSONBytes3, _ := json.Marshal(respJSON3)
  8111. fmt.Println("log")
  8112. fmt.Println(string(userJSONBytes3))
  8113. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8114. utils.ErrorLog("解析失败:%v", err)
  8115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. return
  8117. }
  8118. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8119. var api3 string
  8120. if miConfig.MdtrtareaAdmvs == "320921" {
  8121. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8122. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8124. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8125. } else {
  8126. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8127. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8128. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8129. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8130. }
  8131. resp3, requestErr3 := http.Get(api3)
  8132. if requestErr3 != nil {
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8137. if ioErr3 != nil {
  8138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. var respJSON3 map[string]interface{}
  8143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8149. userJSONBytes3, _ := json.Marshal(respJSON3)
  8150. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8151. utils.ErrorLog("解析失败:%v", err)
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8153. return
  8154. }
  8155. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8156. res2.Output = resSix10265.Output
  8157. res2.ErrMsg = resSix10265.ErrMsg
  8158. res2.Cainfo = resSix10265.Cainfo
  8159. res2.WarnMsg = resSix10265.WarnMsg
  8160. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8161. res2.Infcode = infocode
  8162. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8163. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8164. var dat map[string]interface{}
  8165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8166. fmt.Println(dat)
  8167. } else {
  8168. fmt.Println(err)
  8169. }
  8170. saveLog(result, request, "2202", "退号")
  8171. userJSONBytes, _ := json.Marshal(dat)
  8172. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8173. utils.ErrorLog("解析失败:%v", err)
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. } else {
  8178. var api3 string
  8179. if miConfig.Code == "H15049901371" {
  8180. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8181. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8182. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8183. } else {
  8184. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8185. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8186. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8187. }
  8188. resp3, requestErr3 := http.Get(api3)
  8189. if requestErr3 != nil {
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8191. return
  8192. }
  8193. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8194. if ioErr3 != nil {
  8195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. var respJSON3 map[string]interface{}
  8200. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. return
  8204. }
  8205. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8206. userJSONBytes3, _ := json.Marshal(respJSON3)
  8207. if miConfig.Code == "H15049901371" {
  8208. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8209. utils.ErrorLog("解析失败:%v", err)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8214. res2.Output = resSix10265.Output
  8215. res2.ErrMsg = resSix10265.ErrMsg
  8216. res2.Cainfo = resSix10265.Cainfo
  8217. res2.WarnMsg = resSix10265.WarnMsg
  8218. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8219. res2.Infcode = infocode
  8220. } else {
  8221. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8222. utils.ErrorLog("解析失败:%v", err)
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. return
  8225. }
  8226. }
  8227. }
  8228. if res2.Infcode == 0 {
  8229. if err == nil {
  8230. c.ServeSuccessJSON(map[string]interface{}{
  8231. "msg": "退号成功",
  8232. })
  8233. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8234. } else {
  8235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8236. return
  8237. }
  8238. } else {
  8239. c.ServeSuccessJSON(map[string]interface{}{
  8240. "code": -10,
  8241. "msg": res2.ErrMsg,
  8242. })
  8243. }
  8244. } else {
  8245. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8246. //if err == nil {
  8247. // c.ServeSuccessJSON(map[string]interface{}{
  8248. // "msg": "退费成功",
  8249. // })
  8250. //} else {
  8251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8252. // return
  8253. //}
  8254. }
  8255. }
  8256. func (c *HisApiController) RefundDetail() {
  8257. order_id, _ := c.GetInt64("order_id")
  8258. admin_user_id, _ := c.GetInt64("admin_user_id")
  8259. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8260. number := c.GetString("number")
  8261. record_time := c.GetString("record_time")
  8262. patient_id, _ := c.GetInt64("patient_id")
  8263. //med_type, _ := c.GetInt64("med_type")
  8264. timeLayout := "2006-01-02"
  8265. loc, _ := time.LoadLocation("Local")
  8266. adminUser := c.GetAdminUserInfo()
  8267. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8268. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8269. fmt.Println(err)
  8270. if err != nil {
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8272. return
  8273. }
  8274. recordDateTime := theTime.Unix()
  8275. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8276. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8277. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8278. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8279. var order models.HisOrder
  8280. order, _ = service.GetHisOrderByID(order_id)
  8281. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8282. if config.IsOpen == 1 { //对接了医保,走医保流程
  8283. var res2 ResultSix
  8284. if miConfig.MdtrtareaAdmvs == "421300" {
  8285. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8286. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8288. resp3, requestErr3 := http.Get(api3)
  8289. if requestErr3 != nil {
  8290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8291. return
  8292. }
  8293. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8294. if ioErr3 != nil {
  8295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. var respJSON3 map[string]interface{}
  8300. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8306. userJSONBytes3, _ := json.Marshal(respJSON3)
  8307. fmt.Println("log")
  8308. fmt.Println(string(userJSONBytes3))
  8309. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8310. utils.ErrorLog("解析失败:%v", err)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8315. if err == nil {
  8316. c.ServeSuccessJSON(map[string]interface{}{
  8317. "msg": "撤销明细成功",
  8318. })
  8319. return
  8320. } else {
  8321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8322. return
  8323. }
  8324. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8325. var resSix10265 ResultSix10265
  8326. var api3 string
  8327. if miConfig.MdtrtareaAdmvs == "320921" {
  8328. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8329. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8331. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8332. } else {
  8333. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8334. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8335. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8337. }
  8338. resp3, requestErr3 := http.Get(api3)
  8339. if requestErr3 != nil {
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8344. if ioErr3 != nil {
  8345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. return
  8348. }
  8349. var respJSON3 map[string]interface{}
  8350. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. return
  8354. }
  8355. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8356. userJSONBytes3, _ := json.Marshal(respJSON3)
  8357. fmt.Println("log")
  8358. fmt.Println(string(userJSONBytes3))
  8359. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8360. utils.ErrorLog("解析失败:%v", err)
  8361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8362. return
  8363. }
  8364. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8365. res2.Output = resSix10265.Output
  8366. res2.ErrMsg = resSix10265.ErrMsg
  8367. res2.Cainfo = resSix10265.Cainfo
  8368. res2.WarnMsg = resSix10265.WarnMsg
  8369. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8370. res2.Infcode = infocode
  8371. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8372. if err == nil {
  8373. c.ServeSuccessJSON(map[string]interface{}{
  8374. "msg": "撤销明细成功",
  8375. })
  8376. return
  8377. } else {
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8382. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8383. var dat map[string]interface{}
  8384. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8385. fmt.Println(dat)
  8386. } else {
  8387. fmt.Println(err)
  8388. }
  8389. saveLog(result2, src_request, "2205", "撤销明细")
  8390. userJSONBytes, _ := json.Marshal(dat)
  8391. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8392. utils.ErrorLog("解析失败:%v", err)
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8394. return
  8395. }
  8396. if res2.Infcode == 0 {
  8397. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8398. if err == nil {
  8399. c.ServeSuccessJSON(map[string]interface{}{
  8400. "msg": "撤销明细成功",
  8401. })
  8402. return
  8403. } else {
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. } else {
  8408. c.ServeSuccessJSON(map[string]interface{}{
  8409. "code": -10,
  8410. "msg": res2.ErrMsg,
  8411. })
  8412. }
  8413. } else {
  8414. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8415. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8416. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8417. resp2, requestErr2 := http.Get(api2)
  8418. if requestErr2 != nil {
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8420. return
  8421. }
  8422. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8423. if ioErr2 != nil {
  8424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. var respJSON2 map[string]interface{}
  8429. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8435. if err == nil {
  8436. c.ServeSuccessJSON(map[string]interface{}{
  8437. "msg": "撤销明细成功",
  8438. })
  8439. return
  8440. } else {
  8441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8442. return
  8443. }
  8444. }
  8445. } else {
  8446. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8447. if err == nil {
  8448. c.ServeSuccessJSON(map[string]interface{}{
  8449. "msg": "退费成功",
  8450. })
  8451. } else {
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. }
  8456. }
  8457. //对账
  8458. func (c *HisApiController) GetCheckAccount() {
  8459. start_time := c.GetString("start_time")
  8460. end_time := c.GetString("end_time")
  8461. insutype := c.GetString("insutype")
  8462. clr_type := c.GetString("clr_type")
  8463. clr_org := c.GetString("clr_optins")
  8464. admin_user_id, _ := c.GetInt64("admin_user_id")
  8465. adminUser := c.GetAdminUserInfo()
  8466. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8467. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8468. if len(clr_org) == 0 {
  8469. clr_org = miConfig.MdtrtareaAdmvs
  8470. }
  8471. timeLayout := "2006-01-02"
  8472. loc, _ := time.LoadLocation("Local")
  8473. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8474. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8475. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8476. fixmedins_setl_cnt := int64(len(orders))
  8477. var medfee_sumamt float64
  8478. var acct_pay float64
  8479. var fund_pay_sumamt float64
  8480. for _, item := range orders {
  8481. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8482. acct_pay = acct_pay + item.AcctPay
  8483. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8484. }
  8485. var user_name string
  8486. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8487. if role.ID == 0 {
  8488. user_name = "xxx"
  8489. } else {
  8490. user_name = role.UserName
  8491. }
  8492. var res ResultEight
  8493. var res10188 ResultEightFor10188
  8494. if config.IsOpen == 1 {
  8495. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8496. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8497. "insutype=" + insutype +
  8498. "&clr_type=" + clr_type +
  8499. "&setl_optins=" + clr_org +
  8500. "&stmt_begndate=" + start_time +
  8501. "&stm_enddate=" + end_time +
  8502. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8503. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8504. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8505. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8506. "&fixmedins_code=" + miConfig.Code +
  8507. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8508. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8509. "&secret_key=" + miConfig.SecretKey +
  8510. "&org_name=" + miConfig.OrgName +
  8511. "&doctor=" + user_name +
  8512. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8513. fmt.Println(api)
  8514. resp, requestErr := http.Get(api)
  8515. if requestErr != nil {
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. body, ioErr := ioutil.ReadAll(resp.Body)
  8520. fmt.Println(body)
  8521. if ioErr != nil {
  8522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8524. return
  8525. }
  8526. var respJSON map[string]interface{}
  8527. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8530. return
  8531. }
  8532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8533. userJSONBytes, _ := json.Marshal(respJSON)
  8534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8535. utils.ErrorLog("解析失败:%v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. res.InfRefmsgid = res10188.InfRefmsgid
  8540. res.Output = res10188.Output
  8541. res.ErrMsg = res10188.ErrMsg
  8542. res.Cainfo = res10188.Cainfo
  8543. res.WarnMsg = res10188.WarnMsg
  8544. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8545. res.Infcode = infocode
  8546. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8547. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8548. "insutype=" + insutype +
  8549. "&clr_type=" + clr_type +
  8550. "&setl_optins=" + clr_org +
  8551. "&stmt_begndate=" + start_time +
  8552. "&stm_enddate=" + end_time +
  8553. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8554. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8555. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8556. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8557. "&fixmedins_code=" + miConfig.Code +
  8558. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8559. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8560. "&secret_key=" + miConfig.SecretKey +
  8561. "&org_name=" + miConfig.OrgName +
  8562. "&doctor=" + user_name
  8563. resp, requestErr := http.Get(api)
  8564. if requestErr != nil {
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. body, ioErr := ioutil.ReadAll(resp.Body)
  8569. if ioErr != nil {
  8570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8572. return
  8573. }
  8574. var respJSON map[string]interface{}
  8575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8578. return
  8579. }
  8580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8581. result, _ := json.Marshal(respJSON)
  8582. fmt.Println("log")
  8583. fmt.Println(string(result))
  8584. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8585. utils.ErrorLog("解析失败:%v", err)
  8586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8587. return
  8588. }
  8589. res.InfRefmsgid = res10188.InfRefmsgid
  8590. res.Output = res10188.Output
  8591. res.ErrMsg = res10188.ErrMsg
  8592. res.Cainfo = res10188.Cainfo
  8593. res.WarnMsg = res10188.WarnMsg
  8594. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8595. res.Infcode = infocode
  8596. } else {
  8597. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8598. "insutype=" + insutype +
  8599. "&clr_type=" + clr_type +
  8600. "&setl_optins=" + clr_org +
  8601. "&stmt_begndate=" + start_time +
  8602. "&stm_enddate=" + end_time +
  8603. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8604. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8605. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8606. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8607. "&fixmedins_code=" + miConfig.Code +
  8608. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8609. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8610. "&secret_key=" + miConfig.SecretKey +
  8611. "&org_name=" + miConfig.OrgName +
  8612. "&doctor=" + user_name
  8613. fmt.Println(api)
  8614. resp, requestErr := http.Get(api)
  8615. if requestErr != nil {
  8616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8617. return
  8618. }
  8619. body, ioErr := ioutil.ReadAll(resp.Body)
  8620. fmt.Println(body)
  8621. if ioErr != nil {
  8622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8624. return
  8625. }
  8626. var respJSON map[string]interface{}
  8627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8630. return
  8631. }
  8632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8633. userJSONBytes, _ := json.Marshal(respJSON)
  8634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8635. utils.ErrorLog("解析失败:%v", err)
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. return
  8638. }
  8639. }
  8640. if res.Infcode == 0 {
  8641. if res.Output.Stmtinfo.StmtRslt == "0" {
  8642. micc := &models.MedicalInsuranceCostCompare{
  8643. StartTime: startime.Unix(),
  8644. EndTime: endtime.Unix(),
  8645. Insutype: insutype,
  8646. CheckType: 1,
  8647. Num: fixmedins_setl_cnt,
  8648. Mtime: time.Now().Unix(),
  8649. Status: 1,
  8650. UserOrgId: adminUser.CurrentOrgId,
  8651. CostTotal: medfee_sumamt,
  8652. FuncTotal: fund_pay_sumamt,
  8653. PsnPay: acct_pay,
  8654. Creator: admin_user_id,
  8655. Ctime: time.Now().Unix(),
  8656. ClrType: clr_type,
  8657. }
  8658. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8659. if err == nil {
  8660. c.ServeSuccessJSON(map[string]interface{}{
  8661. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8662. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8663. })
  8664. } else {
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. }
  8667. } else {
  8668. c.ServeSuccessJSON(map[string]interface{}{
  8669. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8670. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8671. })
  8672. }
  8673. } else {
  8674. c.ServeSuccessJSON(map[string]interface{}{
  8675. "code": -10,
  8676. "msg": res.ErrMsg,
  8677. })
  8678. }
  8679. }
  8680. }
  8681. func (c *HisApiController) Check310() {
  8682. adminUser := c.GetAdminUserInfo()
  8683. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8684. var user_name string
  8685. user_name = "高慧裕"
  8686. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8687. "insutype=" + "310" +
  8688. "&clr_type=" + "" +
  8689. "&setl_optins=" + "441202" +
  8690. "&stmt_begndate=" + "2022-03-01" +
  8691. "&stm_enddate=" + "2022-03-31" +
  8692. "&medfee_sumamt=" + "194930.12" +
  8693. "&fund_pay_sumamt=" + "188741.46" +
  8694. "&acct_pay=" + "0" +
  8695. "&fixmedins_setl_cnt=" + "452" +
  8696. "&fixmedins_code=" + miConfig.Code +
  8697. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8698. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8699. "&secret_key=" + miConfig.SecretKey +
  8700. "&org_name=" + miConfig.OrgName +
  8701. "&doctor=" + user_name
  8702. fmt.Println(api)
  8703. resp, requestErr := http.Get(api)
  8704. if requestErr != nil {
  8705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8706. return
  8707. }
  8708. body, ioErr := ioutil.ReadAll(resp.Body)
  8709. fmt.Println(body)
  8710. if ioErr != nil {
  8711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8713. return
  8714. }
  8715. var respJSON map[string]interface{}
  8716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8719. return
  8720. }
  8721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8722. userJSONBytes, _ := json.Marshal(respJSON)
  8723. var res ResultEight
  8724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8725. utils.ErrorLog("解析失败:%v", err)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. }
  8730. func (c *HisApiController) Check390() {
  8731. adminUser := c.GetAdminUserInfo()
  8732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8733. var user_name string
  8734. user_name = "高慧裕"
  8735. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8736. "insutype=" + "390" +
  8737. "&clr_type=" + "" +
  8738. "&setl_optins=" + "441202" +
  8739. "&stmt_begndate=" + "2022-03-01" +
  8740. "&stm_enddate=" + "2022-03-31" +
  8741. "&medfee_sumamt=" + "1068448.89" +
  8742. "&fund_pay_sumamt=" + "1014677.62" +
  8743. "&acct_pay=" + "0" +
  8744. "&fixmedins_setl_cnt=" + "1950" +
  8745. "&fixmedins_code=" + miConfig.Code +
  8746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8747. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8748. "&secret_key=" + miConfig.SecretKey +
  8749. "&org_name=" + miConfig.OrgName +
  8750. "&doctor=" + user_name
  8751. fmt.Println(api)
  8752. resp, requestErr := http.Get(api)
  8753. if requestErr != nil {
  8754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. return
  8756. }
  8757. body, ioErr := ioutil.ReadAll(resp.Body)
  8758. fmt.Println(body)
  8759. if ioErr != nil {
  8760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8762. return
  8763. }
  8764. var respJSON map[string]interface{}
  8765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8771. userJSONBytes, _ := json.Marshal(respJSON)
  8772. var res ResultEight
  8773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8774. utils.ErrorLog("解析失败:%v", err)
  8775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8776. return
  8777. }
  8778. }
  8779. //对账明细
  8780. func (c *HisApiController) GetCheckDetailAccount() {
  8781. start_time := c.GetString("start_time")
  8782. end_time := c.GetString("end_time")
  8783. admin_user_id, _ := c.GetInt64("admin_user_id")
  8784. adminUser := c.GetAdminUserInfo()
  8785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8786. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8787. timeLayout := "2006-01-02"
  8788. loc, _ := time.LoadLocation("Local")
  8789. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8790. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8791. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8792. rand.Seed(time.Now().UnixNano())
  8793. num := rand.Intn(30000)
  8794. Mkdir(miConfig.OrgName)
  8795. file := strconv.FormatInt(int64(num), 10)
  8796. file_name := file + ".txt"
  8797. zip_name := file + ".zip"
  8798. zip_path := miConfig.OrgName + "/" + zip_name
  8799. file_path := miConfig.OrgName + "/" + file_name
  8800. decimal.DivisionPrecision = 2
  8801. var medfee_sumamt float64
  8802. var psn_cash_pay float64
  8803. var fund_pay_sumamt float64
  8804. fixmedins_setl_cnt := int64(len(orders))
  8805. for _, item := range orders {
  8806. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8807. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8808. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8809. }
  8810. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8811. defer f.Close()
  8812. if err != nil {
  8813. fmt.Println(err.Error())
  8814. } else {
  8815. for _, item := range orders {
  8816. var refd_setl_flag string
  8817. if item.OrderStatus == 2 {
  8818. refd_setl_flag = "0"
  8819. var str string
  8820. str = item.SetlId + " " +
  8821. item.MdtrtId + " " +
  8822. item.PsnNo + " " +
  8823. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8824. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8825. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8826. _, err = f.Write([]byte(str))
  8827. }
  8828. if item.OrderStatus == 3 {
  8829. var str string
  8830. str = item.SetlId + " " +
  8831. item.MdtrtId + " " +
  8832. item.PsnNo + " " +
  8833. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8834. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8835. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8836. _, err = f.Write([]byte(str))
  8837. var str2 string
  8838. str2 = item.SetlId + " " +
  8839. item.MdtrtId + " " +
  8840. item.PsnNo + " " +
  8841. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8842. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8843. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8844. _, err = f.Write([]byte(str2))
  8845. }
  8846. }
  8847. }
  8848. Zip(file_path, zip_path)
  8849. fmt.Println(ReadFile(zip_path))
  8850. fmt.Println(string(ReadFile(zip_path)))
  8851. if config.IsOpen == 1 {
  8852. var user_name string
  8853. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8854. if role.ID == 0 {
  8855. user_name = "管理员"
  8856. } else {
  8857. user_name = role.UserName
  8858. }
  8859. baseParams := models.BaseParams{
  8860. SecretKey: miConfig.SecretKey,
  8861. FixmedinsCode: miConfig.Code,
  8862. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8863. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8864. OrgName: miConfig.OrgName,
  8865. Doctor: user_name,
  8866. }
  8867. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8868. var dat map[string]interface{}
  8869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8870. fmt.Println(dat)
  8871. } else {
  8872. fmt.Println(err)
  8873. }
  8874. userJSONBytes, _ := json.Marshal(dat)
  8875. var res ResultNine
  8876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8877. utils.ErrorLog("解析失败:%v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. if res.Infcode == 0 {
  8882. fileNo := res.Output.FileQuryNo
  8883. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8884. "file_qury_no=" + fileNo +
  8885. "&setl_optins=" + "定点医保中心" +
  8886. "&stmt_begndate=" + start_time +
  8887. "&stm_enddate=" + end_time +
  8888. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8889. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8890. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8891. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8892. "&fixmedins_code=" + miConfig.Code +
  8893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8894. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8895. "&secret_key=" + miConfig.SecretKey +
  8896. "&org_name=" + miConfig.OrgName +
  8897. "&doctor=" + user_name
  8898. resp, requestErr := http.Get(api)
  8899. if requestErr != nil {
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. body, ioErr := ioutil.ReadAll(resp.Body)
  8904. if ioErr != nil {
  8905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. var respJSON map[string]interface{}
  8910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8916. userJSONBytes, _ := json.Marshal(respJSON)
  8917. var res ResultTen
  8918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8919. utils.ErrorLog("解析失败:%v", err)
  8920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8921. return
  8922. }
  8923. if res.Infcode == 0 {
  8924. service.Gdyb9102(baseParams, zip_name, fileNo)
  8925. micc := &models.MedicalInsuranceCostCompare{
  8926. StartTime: startime.Unix(),
  8927. EndTime: endtime.Unix(),
  8928. Insutype: "0",
  8929. CheckType: 2,
  8930. Num: fixmedins_setl_cnt,
  8931. Mtime: time.Now().Unix(),
  8932. Status: 1,
  8933. UserOrgId: adminUser.CurrentOrgId,
  8934. CostTotal: medfee_sumamt,
  8935. FuncTotal: fund_pay_sumamt,
  8936. PsnPay: psn_cash_pay,
  8937. Creator: admin_user_id,
  8938. Ctime: time.Now().Unix(),
  8939. }
  8940. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8941. c.ServeSuccessJSON(map[string]interface{}{
  8942. "msg": "明细对账成功",
  8943. })
  8944. }
  8945. } else {
  8946. }
  8947. }
  8948. }
  8949. type CustomOrderInfo struct {
  8950. Name string
  8951. Spec string
  8952. Unit string
  8953. Count float64
  8954. Price float64
  8955. Total float64
  8956. }
  8957. func (c *HisApiController) GetSettleAccounts() {
  8958. //id, _ := c.GetInt64("id")
  8959. //record_time := c.GetString("record_time")
  8960. order_id, _ := c.GetInt64("order_id")
  8961. admin_user_id, _ := c.GetInt64("admin_user_id")
  8962. //timeLayout := "2006-01-02"
  8963. //loc, _ := time.LoadLocation("Local")
  8964. //
  8965. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8966. //if err != nil {
  8967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8968. // return
  8969. //}
  8970. //recordDateTime := theTime.Unix()
  8971. adminUser := c.GetAdminUserInfo()
  8972. order, _ := service.GetHisOrderByID(order_id)
  8973. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8974. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8975. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8976. orderInfos = append(orderInfos, orderInfos_two...)
  8977. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8978. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8979. var diagnosis_ids []string
  8980. if his.ID > 0 {
  8981. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8982. } else {
  8983. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8984. }
  8985. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8986. var dia_config []*models.HisXtDiagnoseConfig
  8987. var name string
  8988. for _, item := range diagnosis_ids {
  8989. id, _ := strconv.ParseInt(item, 10, 64)
  8990. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8991. dia_config = append(dia_config, &diagnosisConfig)
  8992. if len(name) == 0 {
  8993. name = diagnosisConfig.ClassName
  8994. } else {
  8995. name = name + "," + diagnosisConfig.ClassName
  8996. }
  8997. }
  8998. var bedCostTotal float64 = 0 //床位总费
  8999. var bedCostSelfTotal float64 = 0 //床位自费
  9000. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9001. var operationCostTotal float64 = 0 //手术费
  9002. var operationCostSelfTotal float64 = 0 //手术费
  9003. var operationCostPartSelfTotal float64 = 0 //手术费
  9004. var otherCostTotal float64 = 0 //其他费用
  9005. var otherCostSelfTotal float64 = 0 //其他费用
  9006. var otherCostPartSelfTotal float64 = 0 //其他费用
  9007. var materialCostTotal float64 = 0 //材料费
  9008. var materialCostSelfTotal float64 = 0 //材料费
  9009. var materialCostPartSelfTotal float64 = 0 //材料费
  9010. var westernMedicineCostTotal float64 = 0 //西药费
  9011. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9012. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9013. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9014. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9015. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9016. var checkCostTotal float64 = 0 //检查费
  9017. var checkCostSelfTotal float64 = 0 //检查费
  9018. var checkCostPartSelfTotal float64 = 0 //检查费
  9019. var laboratoryCostTotal float64 = 0 //化验费
  9020. var laboratoryCostSelfTotal float64 = 0 //化验费
  9021. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9022. var treatCostTotal float64 = 0 //治疗费用
  9023. var treatCostSelfTotal float64 = 0 //治疗费用
  9024. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9025. decimal.DivisionPrecision = 2
  9026. for _, item := range orderInfos {
  9027. if item.MedChrgitmType == "01" { //床位费
  9028. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9029. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9030. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9031. }
  9032. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9033. if item.MedChrgitmType == "03" { //检查费
  9034. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9035. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9036. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9037. }
  9038. } else {
  9039. if item.MedChrgitmType == "03" { //检查费
  9040. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9041. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9042. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9043. }
  9044. }
  9045. if item.MedChrgitmType == "04" { //化验费
  9046. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9047. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9048. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9049. }
  9050. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9051. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9052. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9053. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9054. }
  9055. if item.MedChrgitmType == "06" { //手术费
  9056. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9057. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9058. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9059. }
  9060. if item.MedChrgitmType == "08" { //材料费
  9061. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9062. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9063. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9064. }
  9065. if item.MedChrgitmType == "09" { //西药费
  9066. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9067. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9068. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9069. }
  9070. if item.MedChrgitmType == "11" { //中成费
  9071. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9072. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9073. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9074. }
  9075. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9076. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9077. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9078. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9079. }
  9080. }
  9081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9082. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9083. var user_name string
  9084. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9085. if role.ID == 0 {
  9086. user_name = "管理员"
  9087. } else {
  9088. user_name = role.UserName
  9089. }
  9090. baseParams := models.BaseParams{
  9091. SecretKey: miConfig.SecretKey,
  9092. FixmedinsCode: miConfig.Code,
  9093. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9094. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9095. OrgName: miConfig.OrgName,
  9096. Doctor: user_name,
  9097. }
  9098. businessParams := models.BusinessParams{
  9099. PsnNo: order.PsnNo,
  9100. MdtrtId: order.MdtrtId,
  9101. SetlId: order.SetlId,
  9102. }
  9103. var res ResultEleven
  9104. var resEleven10265 ResultEleven10265
  9105. if config.IsOpen == 1 {
  9106. if miConfig.MdtrtareaAdmvs == "421300" {
  9107. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9108. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9110. resp, requestErr := http.Get(api)
  9111. if requestErr != nil {
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. body, ioErr := ioutil.ReadAll(resp.Body)
  9116. if ioErr != nil {
  9117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9119. return
  9120. }
  9121. var respJSON map[string]interface{}
  9122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9125. return
  9126. }
  9127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9128. result, _ := json.Marshal(respJSON)
  9129. fmt.Println("log")
  9130. fmt.Println(string(result))
  9131. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9132. utils.ErrorLog("解析失败:%v", err)
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9137. var api string
  9138. if miConfig.MdtrtareaAdmvs == "320921" {
  9139. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9140. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9141. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9142. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9143. } else {
  9144. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9145. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9146. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9147. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9148. }
  9149. resp, requestErr := http.Get(api)
  9150. if requestErr != nil {
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. body, ioErr := ioutil.ReadAll(resp.Body)
  9155. if ioErr != nil {
  9156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. var respJSON map[string]interface{}
  9161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9164. return
  9165. }
  9166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9167. result, _ := json.Marshal(respJSON)
  9168. fmt.Println("log")
  9169. fmt.Println(string(result))
  9170. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9171. utils.ErrorLog("解析失败:%v", err)
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9173. return
  9174. }
  9175. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9176. res.Output = resEleven10265.Output
  9177. res.ErrMsg = resEleven10265.ErrMsg
  9178. res.Cainfo = resEleven10265.Cainfo
  9179. res.WarnMsg = resEleven10265.WarnMsg
  9180. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9181. res.Infcode = infocode
  9182. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9183. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9184. saveLog(result, requestLog, "5203", "结算单")
  9185. var dat map[string]interface{}
  9186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9187. fmt.Println(dat)
  9188. } else {
  9189. fmt.Println(err)
  9190. }
  9191. userJSONBytes, _ := json.Marshal(dat)
  9192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9193. utils.ErrorLog("解析失败:%v", err)
  9194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9195. return
  9196. }
  9197. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9198. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9199. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9200. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9201. resp, requestErr := http.Get(api)
  9202. if requestErr != nil {
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. body, ioErr := ioutil.ReadAll(resp.Body)
  9207. if ioErr != nil {
  9208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9210. return
  9211. }
  9212. var respJSON map[string]interface{}
  9213. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9216. return
  9217. }
  9218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9219. result, _ := json.Marshal(respJSON)
  9220. fmt.Println("log")
  9221. fmt.Println(string(result))
  9222. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9223. utils.ErrorLog("解析失败:%v", err)
  9224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9225. return
  9226. }
  9227. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9228. res.Output = resEleven10265.Output
  9229. res.ErrMsg = resEleven10265.ErrMsg
  9230. res.Cainfo = resEleven10265.Cainfo
  9231. res.WarnMsg = resEleven10265.WarnMsg
  9232. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9233. res.Infcode = infocode
  9234. } else {
  9235. result := service.Gdyb5203(baseParams, businessParams)
  9236. //service.Gdyb5204(baseParams, businessParams)
  9237. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9238. var dat map[string]interface{}
  9239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9240. fmt.Println(dat)
  9241. } else {
  9242. fmt.Println(err)
  9243. }
  9244. userJSONBytes, _ := json.Marshal(dat)
  9245. if miConfig.Code == "H15049901371" {
  9246. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9247. utils.ErrorLog("解析失败:%v", err)
  9248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9249. return
  9250. }
  9251. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9252. res.Output = resEleven10265.Output
  9253. res.ErrMsg = resEleven10265.ErrMsg
  9254. res.Cainfo = resEleven10265.Cainfo
  9255. res.WarnMsg = resEleven10265.WarnMsg
  9256. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9257. res.Infcode = infocode
  9258. } else {
  9259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9260. utils.ErrorLog("解析失败:%v", err)
  9261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9262. return
  9263. }
  9264. }
  9265. }
  9266. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9267. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9268. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9269. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9270. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9271. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9272. var doctor_name string
  9273. if roles.ID == 0 {
  9274. doctor_name = "管理员"
  9275. } else {
  9276. doctor_name = roles.UserName
  9277. }
  9278. yiliao_leibie := ""
  9279. switch order.MedType {
  9280. case "11":
  9281. yiliao_leibie = "普通门诊"
  9282. break
  9283. case "12":
  9284. yiliao_leibie = "门诊挂号"
  9285. break
  9286. case "13":
  9287. yiliao_leibie = "急诊"
  9288. break
  9289. case "14":
  9290. yiliao_leibie = "门诊特殊病"
  9291. break
  9292. case "15":
  9293. yiliao_leibie = "门诊统筹"
  9294. break
  9295. case "16":
  9296. yiliao_leibie = "门诊慢性病"
  9297. break
  9298. case "21":
  9299. yiliao_leibie = "普通住院"
  9300. break
  9301. }
  9302. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9303. if res.Infcode == 0 {
  9304. c.ServeSuccessJSON(map[string]interface{}{
  9305. "diagnosis": name,
  9306. "order_infos": orderInfos,
  9307. "number": order.MdtrtId,
  9308. "date": order.SettleAccountsDate,
  9309. "charge_admin": charge_admin,
  9310. "printor_admin": printor_admin,
  9311. "info": res.Output.Setlinfo,
  9312. "order": order,
  9313. "bedCostTotal": bedCostTotal,
  9314. "bedCostSelfTotal": bedCostSelfTotal,
  9315. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9316. "operationCostTotal": operationCostTotal,
  9317. "operationCostSelfTotal": operationCostSelfTotal,
  9318. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9319. "otherCostTotal": otherCostTotal,
  9320. "otherCostSelfTotal": otherCostSelfTotal,
  9321. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9322. "materialCostTotal": materialCostTotal,
  9323. "materialCostSelfTotal": materialCostSelfTotal,
  9324. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9325. "westernMedicineCostTotal": westernMedicineCostTotal,
  9326. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9327. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9328. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9329. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9330. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9331. "checkCostTotal": checkCostTotal,
  9332. "checkCostSelfTotal": checkCostSelfTotal,
  9333. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9334. "laboratoryCostTotal": laboratoryCostTotal,
  9335. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9336. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9337. "treatCostTotal": treatCostTotal,
  9338. "treatCostSelfTotal": treatCostSelfTotal,
  9339. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9340. "doctor_info": doctor_info,
  9341. "doctor_code": adminRole_two.DoctorCode,
  9342. "doctor_name": doctor_name,
  9343. "health_card_no": order.PsnNo,
  9344. "department": departments.Name,
  9345. "yiliao_leibie": yiliao_leibie,
  9346. "after_money": order.AccountPrice,
  9347. "patient": patient,
  9348. "org_name": miConfig.OrgName,
  9349. "org_code": miConfig.Code,
  9350. "order_number": order.Number,
  9351. "his_hospital": his_hospital,
  9352. "his": his,
  9353. "dia_config": dia_config,
  9354. //"check_order_info": cus_slice,
  9355. })
  9356. }
  9357. }
  9358. }
  9359. func (c *HisApiController) CheckTreatment() {
  9360. patient_id, _ := c.GetInt64("patient_id")
  9361. id_card_no := c.GetString("id_card_no")
  9362. insutype := c.GetString("insutype")
  9363. med_type := c.GetString("med_type")
  9364. admin_user_id, _ := c.GetInt64("admin_user_id")
  9365. adminUser := c.GetAdminUserInfo()
  9366. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9367. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9368. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9369. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9370. if miConfig.MdtrtareaAdmvs == "421300" {
  9371. var res ResultTwo
  9372. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9373. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9374. "&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)
  9375. resp, requestErr := http.Get(api)
  9376. if requestErr != nil {
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. body, ioErr := ioutil.ReadAll(resp.Body)
  9381. if ioErr != nil {
  9382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9384. return
  9385. }
  9386. var respJSON map[string]interface{}
  9387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9390. return
  9391. }
  9392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9393. result, _ := json.Marshal(respJSON)
  9394. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9395. utils.ErrorLog("解析失败:%v", err)
  9396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9397. return
  9398. }
  9399. if res.Infcode == 0 {
  9400. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9401. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9402. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9403. resp, requestErr := http.Get(api)
  9404. if requestErr != nil {
  9405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9406. return
  9407. }
  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. var res Result2001
  9421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9422. result2, _ := json.Marshal(respJSON)
  9423. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9424. utils.ErrorLog("解析失败:%v", err)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. if res.Infcode == 0 {
  9429. c.ServeSuccessJSON(map[string]interface{}{
  9430. "msg": res.Output.Trtinfo,
  9431. })
  9432. }
  9433. } else {
  9434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9435. return
  9436. }
  9437. } else {
  9438. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9439. var dat map[string]interface{}
  9440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9441. fmt.Println(dat)
  9442. } else {
  9443. fmt.Println(err)
  9444. }
  9445. userJSONBytes, _ := json.Marshal(dat)
  9446. var res ResultTwo
  9447. var res10265 ResultTwo10265
  9448. if miConfig.Code == "H15049901371" {
  9449. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9450. utils.ErrorLog("解析失败:%v", err)
  9451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9452. return
  9453. }
  9454. res.ErrMsg = res10265.ErrMsg
  9455. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9456. res.Infcode = infocode
  9457. res.Output = res10265.Output
  9458. res.InfRefmsgid = res10265.InfRefmsgid
  9459. } else {
  9460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9461. utils.ErrorLog("解析失败:%v", err)
  9462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9463. return
  9464. }
  9465. }
  9466. var user_name string
  9467. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9468. if role.ID == 0 {
  9469. user_name = "xxx"
  9470. } else {
  9471. user_name = role.UserName
  9472. }
  9473. baseParams := models.BaseParams{
  9474. SecretKey: miConfig.SecretKey,
  9475. FixmedinsCode: miConfig.Code,
  9476. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9477. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9478. OrgName: miConfig.OrgName,
  9479. Doctor: user_name,
  9480. }
  9481. if config.IsOpen == 1 {
  9482. if miConfig.Code == "H15049901371" {
  9483. if med_type == "14" {
  9484. if insutype == "390" {
  9485. med_type = "9933"
  9486. } else if insutype == "310" {
  9487. med_type = "990502"
  9488. }
  9489. } else if med_type == "11" {
  9490. med_type = "11"
  9491. }
  9492. }
  9493. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9494. var dat map[string]interface{}
  9495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9496. fmt.Println(dat)
  9497. } else {
  9498. fmt.Println(err)
  9499. }
  9500. var res Result2001
  9501. var res10265 Result2001Org10265
  9502. if miConfig.Code == "H15049901371" {
  9503. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9504. utils.ErrorLog("解析失败:%v", err)
  9505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9506. return
  9507. }
  9508. res.ErrMsg = res10265.ErrMsg
  9509. res.Output = res10265.Output
  9510. res.InfRefmsgid = res10265.InfRefmsgid
  9511. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9512. res.Infcode = infocode
  9513. } else {
  9514. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9515. utils.ErrorLog("解析失败:%v", err)
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9517. return
  9518. }
  9519. }
  9520. if res.Infcode == 0 {
  9521. c.ServeSuccessJSON(map[string]interface{}{
  9522. "msg": res.Output.Trtinfo,
  9523. })
  9524. }
  9525. }
  9526. }
  9527. }
  9528. //func (c *HisApiController) PutRecord() {
  9529. // id, _ := c.GetInt64("id")
  9530. // record_time := c.GetString("record_time")
  9531. // timeLayout := "2006-01-02"
  9532. // loc, _ := time.LoadLocation("Local")
  9533. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9534. // if err != nil {
  9535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9536. // return
  9537. // }
  9538. // recordDateTime := theTime.Unix()
  9539. //
  9540. // adminInfo := c.GetAdminUserInfo()
  9541. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9542. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9543. //
  9544. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9545. //
  9546. // fmt.Println(miConfig.SecretKey)
  9547. //
  9548. // if patient == nil {
  9549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9550. // return
  9551. // }
  9552. // if len(patient.IdCardNo) == 0 {
  9553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9554. // return
  9555. // }
  9556. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9557. // if config.IsOpen == 1 {
  9558. // 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
  9559. // resp, requestErr := http.Get(api)
  9560. // if requestErr != nil {
  9561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9562. // return
  9563. // }
  9564. // defer resp.Body.Close()
  9565. // body, ioErr := ioutil.ReadAll(resp.Body)
  9566. // if ioErr != nil {
  9567. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9569. // return
  9570. // }
  9571. // var respJSON map[string]interface{}
  9572. //
  9573. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9574. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9576. // return
  9577. // }
  9578. //
  9579. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9580. // userJSONBytes, _ := json.Marshal(userJSON)
  9581. // var res ResultTwo
  9582. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9583. // utils.ErrorLog("解析失败:%v", err)
  9584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. // return
  9586. // }
  9587. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9588. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9589. // infoStr := string(Iinfos)
  9590. // idetinfoStr := string(Idetinfos)
  9591. //
  9592. // if res.Infcode == 0 {
  9593. // his := models.VMHisPatient{
  9594. // Status: 1,
  9595. // Ctime: time.Now().Unix(),
  9596. // Mtime: time.Now().Unix(),
  9597. // PsnNo: res.Output.Baseinfo.PsnNo,
  9598. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9599. // Certno: res.Output.Baseinfo.Certno,
  9600. // PsnName: res.Output.Baseinfo.PsnName,
  9601. // Gend: res.Output.Baseinfo.Gend,
  9602. // Naty: res.Output.Baseinfo.Naty,
  9603. // Brdy: res.Output.Baseinfo.Brdy,
  9604. // Age: res.Output.Baseinfo.Age,
  9605. // Iinfo: infoStr,
  9606. // Idetinfo: idetinfoStr,
  9607. // PatientId: patient.ID,
  9608. // RecordDate: theTime.Unix(),
  9609. // UserOrgId: adminInfo.CurrentOrgId,
  9610. // AdminUserId: adminInfo.AdminUser.Id,
  9611. // IsReturn: 1,
  9612. // }
  9613. //
  9614. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9615. // //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")
  9616. // //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")
  9617. //
  9618. // //var dat map[string]interface{}
  9619. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9620. // // fmt.Println(dat)
  9621. // //} else {
  9622. // // fmt.Println(err)
  9623. // //}
  9624. //
  9625. // var dat2 map[string]interface{}
  9626. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9627. // fmt.Println(dat2)
  9628. // } else {
  9629. // fmt.Println(err)
  9630. // }
  9631. //
  9632. // } else {
  9633. // adminUser := c.GetAdminUserInfo()
  9634. // errlog := &models.HisOrderError{
  9635. // UserOrgId: adminUser.CurrentOrgId,
  9636. // Ctime: time.Now().Unix(),
  9637. // Mtime: time.Now().Unix(),
  9638. // ErrMsg: res.ErrMsg,
  9639. // Status: 1,
  9640. // PatientId: id,
  9641. // RecordTime: recordDateTime,
  9642. // Stage: 1,
  9643. // }
  9644. // service.CreateErrMsgLog(errlog)
  9645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9646. // return
  9647. // }
  9648. // }
  9649. //
  9650. //}
  9651. //func (c *HisApiController) GetUploadDiag() {
  9652. // id, _ := c.GetInt64("id")
  9653. // record_time := c.GetString("record_time")
  9654. //
  9655. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9656. // sick_type, _ := c.GetInt64("sick_type")
  9657. // reg_type, _ := c.GetInt64("reg_type")
  9658. //
  9659. // timeLayout := "2006-01-02"
  9660. // loc, _ := time.LoadLocation("Local")
  9661. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9662. // if err != nil {
  9663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9664. // return
  9665. // }
  9666. //
  9667. // var patientPrescription models.HisPrescriptionInfo
  9668. // recordDateTime := theTime.Unix()
  9669. // adminInfo := c.GetAdminUserInfo()
  9670. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9671. //
  9672. // if patientPrescription.ID == 0 {
  9673. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9674. // }
  9675. //
  9676. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9677. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9678. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9679. // sickConfig, _ := service.FindSickById(sick_type)
  9680. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9681. //
  9682. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9683. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9684. // "&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 +
  9685. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9686. // resp2, requestErr2 := http.Get(api2)
  9687. // if requestErr2 != nil {
  9688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9689. // return
  9690. // }
  9691. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9692. // if ioErr2 != nil {
  9693. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9695. // return
  9696. // }
  9697. // var respJSON2 map[string]interface{}
  9698. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9699. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9701. // return
  9702. // }
  9703. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9704. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9705. //
  9706. // var res2 ResultSix
  9707. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9708. // utils.ErrorLog("解析失败:%v", err)
  9709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9710. // return
  9711. // }
  9712. // if res2.Infcode != 0 {
  9713. // adminUser := c.GetAdminUserInfo()
  9714. // errlog := &models.HisOrderError{
  9715. // UserOrgId: adminUser.CurrentOrgId,
  9716. // Ctime: time.Now().Unix(),
  9717. // Mtime: time.Now().Unix(),
  9718. // ErrMsg: res2.ErrMsg,
  9719. // Status: 1,
  9720. // PatientId: id,
  9721. // RecordTime: recordDateTime,
  9722. // Stage: 3,
  9723. // }
  9724. // service.CreateErrMsgLog(errlog)
  9725. //
  9726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9727. // return
  9728. // }
  9729. //
  9730. // c.ServeSuccessJSON(map[string]interface{}{
  9731. // "msg": "上传成功",
  9732. // })
  9733. //
  9734. //}
  9735. type QueryResult struct {
  9736. ID int64
  9737. Name string
  9738. Code string
  9739. List_type_code string
  9740. }
  9741. func (c *HisApiController) GetCheckCode() {
  9742. ids_str := c.GetString("ids")
  9743. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9744. ids_arr := strings.Split(ids_str, ",")
  9745. var queryResult []QueryResult
  9746. ids := make([]int64, 0)
  9747. for _, item := range ids_arr {
  9748. id, _ := strconv.ParseInt(item, 10, 64)
  9749. ids = append(ids, id)
  9750. }
  9751. if record_type == 1 {
  9752. drugs, _ := service.GetBatchDrugList(ids)
  9753. for _, item := range drugs {
  9754. result := QueryResult{
  9755. ID: item.ID,
  9756. Name: item.DrugName,
  9757. Code: item.MedicalInsuranceNumber,
  9758. List_type_code: "101",
  9759. }
  9760. queryResult = append(queryResult, result)
  9761. }
  9762. } else if record_type == 2 {
  9763. goods, _ := service.GetBatchGoodInformationList(ids)
  9764. for _, item := range goods {
  9765. result := QueryResult{
  9766. ID: item.ID,
  9767. Name: item.GoodName,
  9768. Code: item.MedicalInsuranceNumber,
  9769. List_type_code: "301",
  9770. }
  9771. queryResult = append(queryResult, result)
  9772. }
  9773. } else if record_type == 3 {
  9774. projects, _ := service.GetBathchMyPorjecgList(ids)
  9775. for _, item := range projects {
  9776. result := QueryResult{
  9777. ID: item.ID,
  9778. Name: item.ProjectName,
  9779. Code: item.MedicalCode,
  9780. List_type_code: "201",
  9781. }
  9782. queryResult = append(queryResult, result)
  9783. }
  9784. }
  9785. admin_user_id, _ := c.GetInt64("admin_user_id")
  9786. adminUser := c.GetAdminUserInfo()
  9787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9789. var user_name string
  9790. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9791. if role.ID == 0 {
  9792. user_name = "xxx"
  9793. } else {
  9794. user_name = role.UserName
  9795. }
  9796. baseParams := &models.BaseParams{
  9797. SecretKey: miConfig.SecretKey,
  9798. FixmedinsCode: miConfig.Code,
  9799. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9800. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9801. OrgName: miConfig.OrgName,
  9802. Doctor: user_name,
  9803. }
  9804. if config.IsOpen == 1 {
  9805. for _, item := range queryResult {
  9806. var result string
  9807. if record_type == 1 {
  9808. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9809. } else if record_type == 2 {
  9810. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9811. } else if record_type == 3 {
  9812. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9813. }
  9814. var dat map[string]interface{}
  9815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9816. fmt.Println(dat)
  9817. } else {
  9818. fmt.Println(err)
  9819. }
  9820. userJSONBytes, _ := json.Marshal(dat)
  9821. var res ResultSix
  9822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9823. utils.ErrorLog("解析失败:%v", err)
  9824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9825. return
  9826. }
  9827. if res.Infcode == 0 {
  9828. if record_type == 1 {
  9829. service.UpdateBaseDrugById(item.ID)
  9830. } else if record_type == 2 {
  9831. service.UpdateGoodInformaitonByDetail(item.ID)
  9832. } else if record_type == 3 {
  9833. service.UpdateProjectById(item.ID)
  9834. }
  9835. c.ServeSuccessJSON(map[string]interface{}{
  9836. "failed_code": 0,
  9837. "msg": "目录对照成功",
  9838. })
  9839. } else {
  9840. c.ServeSuccessJSON(map[string]interface{}{
  9841. "failed_code": -10,
  9842. "msg": res.ErrMsg,
  9843. })
  9844. }
  9845. }
  9846. }
  9847. }
  9848. func (c *HisApiController) UnCheckCode() {
  9849. ids_str := c.GetString("ids")
  9850. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9851. admin_user_id, _ := c.GetInt64("admin_user_id")
  9852. ids_arr := strings.Split(ids_str, ",")
  9853. var queryResult []QueryResult
  9854. ids := make([]int64, 0)
  9855. for _, item := range ids_arr {
  9856. id, _ := strconv.ParseInt(item, 10, 64)
  9857. ids = append(ids, id)
  9858. }
  9859. if record_type == 1 {
  9860. drugs, _ := service.GetBatchDrugList(ids)
  9861. for _, item := range drugs {
  9862. result := QueryResult{
  9863. ID: item.ID,
  9864. Name: item.DrugName,
  9865. Code: item.MedicalInsuranceNumber,
  9866. List_type_code: "101",
  9867. }
  9868. queryResult = append(queryResult, result)
  9869. }
  9870. } else if record_type == 2 {
  9871. goods, _ := service.GetBatchGoodInformationList(ids)
  9872. for _, item := range goods {
  9873. result := QueryResult{
  9874. ID: item.ID,
  9875. Name: item.GoodName,
  9876. Code: item.MedicalInsuranceNumber,
  9877. List_type_code: "301",
  9878. }
  9879. queryResult = append(queryResult, result)
  9880. }
  9881. } else if record_type == 3 {
  9882. projects, _ := service.GetBathchMyPorjecgList(ids)
  9883. for _, item := range projects {
  9884. result := QueryResult{
  9885. ID: item.ID,
  9886. Name: item.ProjectName,
  9887. Code: item.MedicalCode,
  9888. List_type_code: "201",
  9889. }
  9890. queryResult = append(queryResult, result)
  9891. }
  9892. }
  9893. adminUser := c.GetAdminUserInfo()
  9894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9895. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9896. var user_name string
  9897. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9898. if role.ID == 0 {
  9899. user_name = "xxx"
  9900. } else {
  9901. user_name = role.UserName
  9902. }
  9903. baseParams := &models.BaseParams{
  9904. SecretKey: miConfig.SecretKey,
  9905. FixmedinsCode: miConfig.Code,
  9906. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9907. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9908. OrgName: miConfig.OrgName,
  9909. Doctor: user_name,
  9910. }
  9911. if config.IsOpen == 1 {
  9912. for _, item := range queryResult {
  9913. var result string
  9914. if record_type == 1 {
  9915. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9916. } else if record_type == 2 {
  9917. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9918. } else if record_type == 3 {
  9919. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9920. }
  9921. var dat2 map[string]interface{}
  9922. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9923. fmt.Println(dat2)
  9924. } else {
  9925. fmt.Println(err)
  9926. }
  9927. userJSONBytes, _ := json.Marshal(dat2)
  9928. var res ResultSix
  9929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9932. return
  9933. }
  9934. if res.Infcode == 0 {
  9935. if record_type == 1 {
  9936. service.UpdateDrugByIdDetail(item.ID)
  9937. } else if record_type == 2 {
  9938. service.UpdateGoodInfoById(item.ID)
  9939. } else if record_type == 3 {
  9940. service.UpdateMyProjectById(item.ID)
  9941. }
  9942. c.ServeSuccessJSON(map[string]interface{}{
  9943. "failed_code": 0,
  9944. "msg": "撤销目录对照成功",
  9945. })
  9946. } else {
  9947. c.ServeSuccessJSON(map[string]interface{}{
  9948. "failed_code": -10,
  9949. "msg": res.ErrMsg,
  9950. })
  9951. }
  9952. }
  9953. }
  9954. }
  9955. func (c *HisApiController) GetPatientInfo() {
  9956. id_card_no := c.GetString("id_card_no")
  9957. admin_user_id, _ := c.GetInt64("admin_user_id")
  9958. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9959. if patient.ID == 0 {
  9960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9961. return
  9962. }
  9963. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9964. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9965. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9966. if config.IsOpen == 1 {
  9967. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9968. var dat map[string]interface{}
  9969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9970. fmt.Println(dat)
  9971. } else {
  9972. fmt.Println(err)
  9973. }
  9974. userJSONBytes, _ := json.Marshal(dat)
  9975. var res ResultTwo
  9976. var res10265 ResultTwo10265
  9977. if miConfig.Code == "H15049901371" {
  9978. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9979. utils.ErrorLog("解析失败:%v", err)
  9980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9981. return
  9982. }
  9983. res.ErrMsg = res10265.ErrMsg
  9984. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9985. res.Infcode = infocode
  9986. res.Output = res10265.Output
  9987. res.InfRefmsgid = res10265.InfRefmsgid
  9988. } else {
  9989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9990. utils.ErrorLog("解析失败:%v", err)
  9991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9992. return
  9993. }
  9994. }
  9995. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9996. // utils.ErrorLog("解析失败:%v", err)
  9997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9998. // return
  9999. //}
  10000. if res.Infcode != 0 {
  10001. c.ServeSuccessJSON(map[string]interface{}{
  10002. "failed_code": -10,
  10003. "msg": res.ErrMsg,
  10004. })
  10005. } else {
  10006. c.ServeSuccessJSON(map[string]interface{}{
  10007. "failed_code": 0,
  10008. "info": res,
  10009. })
  10010. }
  10011. }
  10012. }
  10013. func (c *HisApiController) PsnPutOnRecord() {
  10014. record_type, _ := c.GetInt64("type")
  10015. patient_id, _ := c.GetInt64("patient_id")
  10016. admin_user_id, _ := c.GetInt64("admin_user_id")
  10017. start_time := c.GetString("start_time")
  10018. end_time := c.GetString("end_time")
  10019. adminUser := c.GetAdminUserInfo()
  10020. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10021. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10022. var patients []*models.Patients
  10023. if record_type == 1 { //全部备案
  10024. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10025. patients = append(patients, patient...)
  10026. } else { //单个备案
  10027. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10028. patients = append(patients, patient)
  10029. }
  10030. var user_name string
  10031. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10032. if role.ID == 0 {
  10033. user_name = "xxx"
  10034. } else {
  10035. user_name = role.UserName
  10036. }
  10037. if config.IsOpen == 1 {
  10038. for _, item := range patients {
  10039. 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
  10040. resp, requestErr := http.Get(api)
  10041. if requestErr != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10043. return
  10044. }
  10045. defer resp.Body.Close()
  10046. body, ioErr := ioutil.ReadAll(resp.Body)
  10047. if ioErr != nil {
  10048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10050. return
  10051. }
  10052. var respJSON map[string]interface{}
  10053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10056. return
  10057. }
  10058. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10059. userJSONBytes, _ := json.Marshal(userJSON)
  10060. var res ResultTwo
  10061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10062. utils.ErrorLog("解析失败:%v", err)
  10063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10064. return
  10065. }
  10066. if res.Infcode == 0 {
  10067. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10068. var dat map[string]interface{}
  10069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10070. fmt.Println(dat)
  10071. } else {
  10072. fmt.Println(err)
  10073. }
  10074. userJSONBytes, _ := json.Marshal(dat)
  10075. var res2 ResultThirteen
  10076. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10077. utils.ErrorLog("解析失败:%v", err)
  10078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10079. return
  10080. }
  10081. if res2.Infcode == 0 {
  10082. psnResult := &models.GdybPsnRecord{
  10083. UserOrgId: adminUser.CurrentOrgId,
  10084. PatientId: item.ID,
  10085. PsnNo: res.Output.Baseinfo.PsnNo,
  10086. Ctime: time.Now().Unix(),
  10087. Mtime: time.Now().Unix(),
  10088. Status: 1,
  10089. IsCancel: 1,
  10090. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10091. }
  10092. service.CreatePsnRecord(psnResult)
  10093. } else {
  10094. c.ServeSuccessJSON(map[string]interface{}{
  10095. "failed_code": -10,
  10096. "msg": res2.ErrMsg,
  10097. })
  10098. return
  10099. }
  10100. }
  10101. }
  10102. }
  10103. }
  10104. func (c *HisApiController) PsnUnPutOnRecord() {
  10105. id, _ := c.GetInt64("id")
  10106. //record_type, _ := c.GetInt64("type")
  10107. admin_user_id, _ := c.GetInt64("admin_user_id")
  10108. adminUser := c.GetAdminUserInfo()
  10109. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10110. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10111. var user_name string
  10112. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10113. if role.ID == 0 {
  10114. user_name = "xxx"
  10115. } else {
  10116. user_name = role.UserName
  10117. }
  10118. psn_record, _ := service.GetPsnRecordById(id)
  10119. if psn_record.ID == 0 {
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10121. return
  10122. }
  10123. if config.IsOpen == 1 {
  10124. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10125. var dat map[string]interface{}
  10126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10127. fmt.Println(dat)
  10128. } else {
  10129. fmt.Println(err)
  10130. }
  10131. userJSONBytes, _ := json.Marshal(dat)
  10132. var res ResultFourteen
  10133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10134. utils.ErrorLog("解析失败:%v", err)
  10135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10136. return
  10137. }
  10138. if res.Infcode == 0 {
  10139. psn_record.IsCancel = 2
  10140. service.CreatePsnRecord(&psn_record)
  10141. } else {
  10142. c.ServeSuccessJSON(map[string]interface{}{
  10143. "failed_code": -10,
  10144. "msg": res.ErrMsg,
  10145. })
  10146. return
  10147. }
  10148. }
  10149. }
  10150. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10151. patient_id, _ := c.GetInt64("patient_id")
  10152. insutype_two := c.GetString("insutype")
  10153. psn_no := c.GetString("psn_no")
  10154. doctor_id, _ := c.GetInt64("doctor_id")
  10155. sick_id, _ := c.GetInt64("sick_id")
  10156. department_id, _ := c.GetInt64("department_id")
  10157. start_time := c.GetString("start_time")
  10158. end_time := c.GetString("end_time")
  10159. check_time := c.GetString("check_time")
  10160. adminUser := c.GetAdminUserInfo()
  10161. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10163. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10164. sick, _ := service.FindSickById(sick_id)
  10165. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10166. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10167. var res ResultTwo
  10168. var res10265 ResultTwo10265
  10169. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10170. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10171. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10172. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10173. "&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
  10174. resp, requestErr := http.Get(api)
  10175. if requestErr != nil {
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10177. return
  10178. }
  10179. body, ioErr := ioutil.ReadAll(resp.Body)
  10180. if ioErr != nil {
  10181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10183. return
  10184. }
  10185. var respJSON map[string]interface{}
  10186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10189. return
  10190. }
  10191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10192. result, _ := json.Marshal(respJSON)
  10193. fmt.Println("log")
  10194. fmt.Println(string(result))
  10195. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10196. utils.ErrorLog("解析失败:%v", err)
  10197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10198. return
  10199. }
  10200. res.ErrMsg = res10265.ErrMsg
  10201. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10202. res.Infcode = infocode
  10203. res.Output = res10265.Output
  10204. res.InfRefmsgid = res10265.InfRefmsgid
  10205. } else {
  10206. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10207. if miConfig.Code == "H15049901371" {
  10208. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10209. utils.ErrorLog("解析失败:%v", err)
  10210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10211. return
  10212. }
  10213. res.ErrMsg = res10265.ErrMsg
  10214. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10215. res.Infcode = infocode
  10216. res.Output = res10265.Output
  10217. res.InfRefmsgid = res10265.InfRefmsgid
  10218. } else {
  10219. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10220. utils.ErrorLog("解析失败:%v", err)
  10221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10222. return
  10223. }
  10224. }
  10225. }
  10226. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10227. infoStr := string(Iinfos)
  10228. var rf []*ResultFive
  10229. json.Unmarshal([]byte(infoStr), &rf)
  10230. var insuplc_admdvs string
  10231. var insutype string
  10232. var is390 int = 0
  10233. var is310 int = 0
  10234. var insutypes []*ResultFive
  10235. for _, item := range rf {
  10236. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10237. insutypes = append(insutypes, item)
  10238. }
  10239. }
  10240. if len(insutypes) == 1 {
  10241. insutype = insutypes[0].Insutype
  10242. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10243. } else {
  10244. for _, i := range insutypes {
  10245. if i.Insutype == "390" {
  10246. is390 = 1
  10247. }
  10248. if i.Insutype == "310" {
  10249. is310 = 1
  10250. }
  10251. }
  10252. }
  10253. if is390 == 1 {
  10254. insutype = "390"
  10255. }
  10256. if is310 == 1 {
  10257. insutype = "310"
  10258. }
  10259. if len(insutypes) == 2 {
  10260. insutype = insutype_two
  10261. }
  10262. if len(insutypes) == 0 {
  10263. insutype = "310"
  10264. }
  10265. insutype = insutype_two
  10266. fmt.Println(insutype)
  10267. for _, item := range rf {
  10268. fmt.Println(item.Insutype)
  10269. fmt.Println(insutype)
  10270. if item.Insutype == insutype {
  10271. fmt.Println(item.Insutype)
  10272. fmt.Println(insutype)
  10273. insuplc_admdvs = item.InsuplcAdmdvs
  10274. }
  10275. }
  10276. fmt.Println(insuplc_admdvs)
  10277. var res2 ResultThirteen
  10278. var res10265_2 ResultThirteen10265
  10279. if config.IsOpen == 1 {
  10280. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10281. } else {
  10282. 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)
  10283. var dat map[string]interface{}
  10284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10285. fmt.Println(dat)
  10286. } else {
  10287. fmt.Println(err)
  10288. }
  10289. userJSONBytes, _ := json.Marshal(dat)
  10290. if miConfig.Code == "H15049901371" {
  10291. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10292. utils.ErrorLog("解析失败:%v", err)
  10293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10294. return
  10295. }
  10296. res2.ErrMsg = res10265_2.ErrMsg
  10297. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10298. res2.Infcode = infocode
  10299. res2.Output = res10265_2.Output
  10300. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10301. } else {
  10302. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10303. utils.ErrorLog("解析失败:%v", err)
  10304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10305. return
  10306. }
  10307. }
  10308. }
  10309. if res2.Infcode == 0 {
  10310. psnResult := &models.GdybPsnNcdsRecord{
  10311. UserOrgId: adminUser.CurrentOrgId,
  10312. PatientId: patient.ID,
  10313. PsnNo: psn_no,
  10314. DoctorId: doctor.AdminUserId,
  10315. DepartmentId: department_id,
  10316. SickType: sick_id,
  10317. Insutype: insutype,
  10318. Ctime: time.Now().Unix(),
  10319. Mtime: time.Now().Unix(),
  10320. Status: 1,
  10321. IsCancel: 1,
  10322. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10323. }
  10324. service.CreatePsnNCDSRecord(psnResult)
  10325. c.ServeSuccessJSON(map[string]interface{}{
  10326. "failed_code": 0,
  10327. "msg": "备案成功",
  10328. "result": psnResult,
  10329. })
  10330. } else {
  10331. c.ServeSuccessJSON(map[string]interface{}{
  10332. "failed_code": -10,
  10333. "msg": res2.ErrMsg,
  10334. })
  10335. return
  10336. }
  10337. }
  10338. }
  10339. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10340. id, _ := c.GetInt64("id")
  10341. admin_user_id, _ := c.GetInt64("admin_user_id")
  10342. adminUser := c.GetAdminUserInfo()
  10343. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10344. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10345. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10346. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10347. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10348. //var user_name string
  10349. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10350. //if role.ID == 0 {
  10351. // user_name = "xxx"
  10352. //} else {
  10353. // user_name = role.UserName
  10354. //}
  10355. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10356. if psn_record.ID == 0 {
  10357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10358. return
  10359. }
  10360. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10361. var res ResultTwo
  10362. var res10265 ResultTwo10265
  10363. if miConfig.Code == "H15049901371" {
  10364. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10365. utils.ErrorLog("解析失败:%v", err)
  10366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10367. return
  10368. }
  10369. res.ErrMsg = res10265.ErrMsg
  10370. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10371. res.Infcode = infocode
  10372. res.Output = res10265.Output
  10373. res.InfRefmsgid = res10265.InfRefmsgid
  10374. } else {
  10375. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10376. utils.ErrorLog("解析失败:%v", err)
  10377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10378. return
  10379. }
  10380. }
  10381. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10382. infoStr := string(Iinfos)
  10383. var rf []*ResultFive
  10384. json.Unmarshal([]byte(infoStr), &rf)
  10385. var insuplc_admdvs string
  10386. var insutype string
  10387. var is390 int = 0
  10388. var is310 int = 0
  10389. var insutypes []*ResultFive
  10390. for _, item := range rf {
  10391. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10392. insutypes = append(insutypes, item)
  10393. }
  10394. }
  10395. if len(insutypes) == 1 {
  10396. insutype = insutypes[0].Insutype
  10397. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10398. } else {
  10399. for _, i := range insutypes {
  10400. if i.Insutype == "390" {
  10401. is390 = 1
  10402. }
  10403. if i.Insutype == "310" {
  10404. is310 = 1
  10405. }
  10406. }
  10407. }
  10408. if is390 == 1 {
  10409. insutype = "390"
  10410. }
  10411. if is310 == 1 {
  10412. insutype = "310"
  10413. }
  10414. if len(insutypes) == 0 {
  10415. insutype = "310"
  10416. }
  10417. insutype = psn_record.Insutype
  10418. for _, item := range rf {
  10419. if item.Insutype == insutype {
  10420. insuplc_admdvs = item.InsuplcAdmdvs
  10421. }
  10422. }
  10423. if config.IsOpen == 1 {
  10424. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10425. var dat map[string]interface{}
  10426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10427. fmt.Println(dat)
  10428. } else {
  10429. fmt.Println(err)
  10430. }
  10431. userJSONBytes, _ := json.Marshal(dat)
  10432. var res ResultFourteen
  10433. var res10265 ResultFourteen10265
  10434. if miConfig.Code == "H15049901371" {
  10435. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10436. utils.ErrorLog("解析失败:%v", err)
  10437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10438. return
  10439. }
  10440. res.ErrMsg = res10265.ErrMsg
  10441. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10442. res.Infcode = infocode
  10443. res.Output = res10265.Output
  10444. res.InfRefmsgid = res10265.InfRefmsgid
  10445. } else {
  10446. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10447. utils.ErrorLog("解析失败:%v", err)
  10448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10449. return
  10450. }
  10451. }
  10452. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10453. // utils.ErrorLog("解析失败:%v", err)
  10454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10455. // return
  10456. //}
  10457. if res.Infcode == 0 {
  10458. psn_record.IsCancel = 2
  10459. service.CreatePsnNCDSRecord(&psn_record)
  10460. c.ServeSuccessJSON(map[string]interface{}{
  10461. "failed_code": 0,
  10462. "msg": "撤销备案成功",
  10463. })
  10464. } else {
  10465. c.ServeSuccessJSON(map[string]interface{}{
  10466. "failed_code": -10,
  10467. "msg": res.ErrMsg,
  10468. })
  10469. return
  10470. }
  10471. }
  10472. }
  10473. func (c *HisApiController) TestTest() {
  10474. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10475. fmt.Println(patient.Iinfo)
  10476. }
  10477. type CustomData struct {
  10478. MsgId string
  10479. PsnNo string
  10480. Info string
  10481. }
  10482. func (c *HisApiController) ReversalData() {
  10483. var customData []*CustomData
  10484. custom := &CustomData{
  10485. MsgId: "H44022900158202103301714472004",
  10486. PsnNo: "44020000001101329945",
  10487. Info: "2207",
  10488. }
  10489. customData = append(customData, custom)
  10490. custom1 := &CustomData{
  10491. MsgId: "H4402290015820210330172057803",
  10492. PsnNo: "44020000001101161813",
  10493. Info: "2207",
  10494. }
  10495. customData = append(customData, custom1)
  10496. custom2 := &CustomData{
  10497. MsgId: "H44022900158202103301705198813",
  10498. PsnNo: "44190000133097375417",
  10499. Info: "2207",
  10500. }
  10501. customData = append(customData, custom2)
  10502. custom3 := &CustomData{
  10503. MsgId: "H44022900158202103301715524756",
  10504. PsnNo: "44020000001100187221",
  10505. Info: "2207",
  10506. }
  10507. customData = append(customData, custom3)
  10508. custom4 := &CustomData{
  10509. MsgId: "H44022900158202103301730376224",
  10510. PsnNo: "44020000001101959155",
  10511. Info: "2207",
  10512. }
  10513. customData = append(customData, custom4)
  10514. custom5 := &CustomData{
  10515. MsgId: "H44022900158202103301748008725",
  10516. PsnNo: "44020000001104246641",
  10517. Info: "2207",
  10518. }
  10519. customData = append(customData, custom5)
  10520. custom6 := &CustomData{
  10521. MsgId: "H44022900158202103301718096755",
  10522. PsnNo: "44020000001102211860",
  10523. Info: "2207",
  10524. }
  10525. customData = append(customData, custom6)
  10526. custom7 := &CustomData{
  10527. MsgId: "H44022900158202103301736551640",
  10528. PsnNo: "44020000001102687718",
  10529. Info: "2207",
  10530. }
  10531. customData = append(customData, custom7)
  10532. custom8 := &CustomData{
  10533. MsgId: "H44022900158202103301743097676",
  10534. PsnNo: "44020000001102127785",
  10535. Info: "2207",
  10536. }
  10537. customData = append(customData, custom8)
  10538. custom9 := &CustomData{
  10539. MsgId: "H44022900158202103301712304203",
  10540. PsnNo: "44020000001101518097",
  10541. Info: "2207",
  10542. }
  10543. customData = append(customData, custom9)
  10544. custom10 := &CustomData{
  10545. MsgId: "H44022900158202103301738448785",
  10546. PsnNo: "44020000001100500813",
  10547. Info: "2207",
  10548. }
  10549. customData = append(customData, custom10)
  10550. custom11 := &CustomData{
  10551. MsgId: "H44022900158202103301732455843",
  10552. PsnNo: "44020000001102690557",
  10553. Info: "2207",
  10554. }
  10555. customData = append(customData, custom11)
  10556. custom12 := &CustomData{
  10557. MsgId: "H44022900158202103301745421708",
  10558. PsnNo: "44020000001102211928",
  10559. Info: "2207",
  10560. }
  10561. customData = append(customData, custom12)
  10562. custom1212 := &CustomData{
  10563. MsgId: "H440229001582021033017351627",
  10564. PsnNo: "44020000001102481733",
  10565. Info: "2207",
  10566. }
  10567. customData = append(customData, custom1212)
  10568. custom13 := &CustomData{
  10569. MsgId: "H44022900158202103301740327951",
  10570. PsnNo: "44020000001103174866",
  10571. Info: "2207",
  10572. }
  10573. customData = append(customData, custom13)
  10574. custom14 := &CustomData{
  10575. MsgId: "H4402290015820210330174922668",
  10576. PsnNo: "44020000001102927272",
  10577. Info: "2207",
  10578. }
  10579. customData = append(customData, custom14)
  10580. custom15 := &CustomData{
  10581. MsgId: "H44022900158202103301752362273",
  10582. PsnNo: "44020000001102942890",
  10583. Info: "2207",
  10584. }
  10585. customData = append(customData, custom15)
  10586. custom16 := &CustomData{
  10587. MsgId: "H44022900158202103301751082917",
  10588. PsnNo: "44020000001101662162",
  10589. Info: "2207",
  10590. }
  10591. customData = append(customData, custom16)
  10592. custom17 := &CustomData{
  10593. MsgId: "H44022900158202103301754147728",
  10594. PsnNo: "44020000000229014511",
  10595. Info: "2207",
  10596. }
  10597. customData = append(customData, custom17)
  10598. adminUser := c.GetAdminUserInfo()
  10599. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10600. for _, item := range customData {
  10601. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10602. fmt.Println(result)
  10603. }
  10604. }
  10605. //func (c *HisApiController) GetAllopatry() {
  10606. // year := c.GetString("year")
  10607. // month := c.GetString("month")
  10608. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10609. // adminUser := c.GetAdminUserInfo()
  10610. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10611. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10612. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10613. //
  10614. // var dat map[string]interface{}
  10615. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10616. // fmt.Println(dat)
  10617. // } else {
  10618. // fmt.Println(err)
  10619. // }
  10620. // userJSONBytes, _ := json.Marshal(dat)
  10621. // var res models.Result9001
  10622. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10623. // utils.ErrorLog("解析失败:%v", err)
  10624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10625. // return
  10626. // }
  10627. //
  10628. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10629. // var dat2 map[string]interface{}
  10630. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10631. // fmt.Println(dat)
  10632. // } else {
  10633. // fmt.Println(err)
  10634. // }
  10635. // userJSONBytes2, _ := json.Marshal(dat2)
  10636. // var res2 models.Result3260
  10637. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10638. // utils.ErrorLog("解析失败:%v", err)
  10639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10640. // return
  10641. // }
  10642. // if res2.Infcode == 0 {
  10643. // c.ServeSuccessJSON(map[string]interface{}{
  10644. // "list": res2.Output.Data,
  10645. // })
  10646. // return
  10647. // } else {
  10648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10649. // return
  10650. // }
  10651. //
  10652. //}
  10653. //func (c *HisApiController) ComfirmAllopatry() {
  10654. // year := c.GetString("year")
  10655. // month := c.GetString("month")
  10656. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10657. // adminUser := c.GetAdminUserInfo()
  10658. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10659. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10660. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10661. // var dat map[string]interface{}
  10662. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10663. // fmt.Println(dat)
  10664. // } else {
  10665. // fmt.Println(err)
  10666. // }
  10667. // userJSONBytes, _ := json.Marshal(dat)
  10668. // var res models.Result9001
  10669. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10670. // utils.ErrorLog("解析失败:%v", err)
  10671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10672. // return
  10673. // }
  10674. //
  10675. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10676. // var dat2 map[string]interface{}
  10677. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10678. // fmt.Println(dat)
  10679. // } else {
  10680. // fmt.Println(err)
  10681. // }
  10682. // userJSONBytes2, _ := json.Marshal(dat2)
  10683. // var res2 models.Result3260
  10684. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10685. // utils.ErrorLog("解析失败:%v", err)
  10686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10687. // return
  10688. // }
  10689. //
  10690. // if res2.Infcode == 0 {
  10691. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10692. // var dat map[string]interface{}
  10693. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10694. // fmt.Println(dat)
  10695. // } else {
  10696. // fmt.Println(err)
  10697. // }
  10698. // userJSONBytes, _ := json.Marshal(dat)
  10699. // var res3 models.Result3261
  10700. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10701. // utils.ErrorLog("解析失败:%v", err)
  10702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10703. // return
  10704. // }
  10705. //
  10706. // if res3.Infcode == 0 {
  10707. // record := &models.HisYidiClearRecord{
  10708. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10709. // Ctime: time.Now().Unix(),
  10710. // Mtime: time.Now().Unix(),
  10711. // Status: 1,
  10712. // MsgId: msgId,
  10713. // }
  10714. // service.SaveClearRecord(record)
  10715. // c.ServeSuccessJSON(map[string]interface{}{
  10716. // "msg": "提取成功",
  10717. // })
  10718. // }
  10719. // }
  10720. //}
  10721. func (c *HisApiController) RefundAllopatry() {
  10722. year := c.GetString("year")
  10723. month := c.GetString("month")
  10724. id, _ := c.GetInt64("id")
  10725. admin_user_id, _ := c.GetInt64("admin_user_id")
  10726. adminUser := c.GetAdminUserInfo()
  10727. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10728. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10729. record, _ := service.GetClearRecordById(id)
  10730. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10731. var dat map[string]interface{}
  10732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10733. fmt.Println(dat)
  10734. } else {
  10735. fmt.Println(err)
  10736. }
  10737. userJSONBytes, _ := json.Marshal(dat)
  10738. var empty ResultFourteen
  10739. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10740. utils.ErrorLog("解析失败:%v", err)
  10741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10742. return
  10743. }
  10744. if empty.Infcode == 0 {
  10745. c.ServeSuccessJSON(map[string]interface{}{
  10746. "msg": "撤销成功",
  10747. })
  10748. return
  10749. }
  10750. }
  10751. func (c *HisApiController) ReversalOtherData() {
  10752. var customData []*CustomData
  10753. custom := &CustomData{
  10754. MsgId: "H44022900158202103301714472004",
  10755. PsnNo: "44020000001101329945",
  10756. Info: "2208",
  10757. }
  10758. customData = append(customData, custom)
  10759. custom1 := &CustomData{
  10760. MsgId: "H4402290015820210330172057803",
  10761. PsnNo: "44020000001101161813",
  10762. Info: "2208",
  10763. }
  10764. customData = append(customData, custom1)
  10765. custom2 := &CustomData{
  10766. MsgId: "H44022900158202103301705198813",
  10767. PsnNo: "44190000133097375417",
  10768. Info: "2208",
  10769. }
  10770. customData = append(customData, custom2)
  10771. custom3 := &CustomData{
  10772. MsgId: "H44022900158202103301715524756",
  10773. PsnNo: "44020000001100187221",
  10774. Info: "2208",
  10775. }
  10776. customData = append(customData, custom3)
  10777. custom4 := &CustomData{
  10778. MsgId: "H44022900158202103301730376224",
  10779. PsnNo: "44020000001101959155",
  10780. Info: "2208",
  10781. }
  10782. customData = append(customData, custom4)
  10783. custom5 := &CustomData{
  10784. MsgId: "H44022900158202103301748008725",
  10785. PsnNo: "44020000001104246641",
  10786. Info: "2208",
  10787. }
  10788. customData = append(customData, custom5)
  10789. custom6 := &CustomData{
  10790. MsgId: "H44022900158202103301718096755",
  10791. PsnNo: "44020000001102211860",
  10792. Info: "2208",
  10793. }
  10794. customData = append(customData, custom6)
  10795. custom7 := &CustomData{
  10796. MsgId: "H44022900158202103301736551640",
  10797. PsnNo: "44020000001102687718",
  10798. Info: "2208",
  10799. }
  10800. customData = append(customData, custom7)
  10801. custom8 := &CustomData{
  10802. MsgId: "H44022900158202103301743097676",
  10803. PsnNo: "44020000001102127785",
  10804. Info: "2208",
  10805. }
  10806. customData = append(customData, custom8)
  10807. custom9 := &CustomData{
  10808. MsgId: "H44022900158202103301712304203",
  10809. PsnNo: "44020000001101518097",
  10810. Info: "2208",
  10811. }
  10812. customData = append(customData, custom9)
  10813. custom10 := &CustomData{
  10814. MsgId: "H44022900158202103301738448785",
  10815. PsnNo: "44020000001100500813",
  10816. Info: "2208",
  10817. }
  10818. customData = append(customData, custom10)
  10819. custom11 := &CustomData{
  10820. MsgId: "H44022900158202103301732455843",
  10821. PsnNo: "44020000001102690557",
  10822. Info: "2208",
  10823. }
  10824. customData = append(customData, custom11)
  10825. custom12 := &CustomData{
  10826. MsgId: "H44022900158202103301745421708",
  10827. PsnNo: "44020000001102211928",
  10828. Info: "2208",
  10829. }
  10830. customData = append(customData, custom12)
  10831. custom1212 := &CustomData{
  10832. MsgId: "H440229001582021033017351627",
  10833. PsnNo: "44020000001102481733",
  10834. Info: "2208",
  10835. }
  10836. customData = append(customData, custom1212)
  10837. custom13 := &CustomData{
  10838. MsgId: "H44022900158202103301740327951",
  10839. PsnNo: "44020000001103174866",
  10840. Info: "2208",
  10841. }
  10842. customData = append(customData, custom13)
  10843. custom14 := &CustomData{
  10844. MsgId: "H4402290015820210330174922668",
  10845. PsnNo: "44020000001102927272",
  10846. Info: "2208",
  10847. }
  10848. customData = append(customData, custom14)
  10849. custom15 := &CustomData{
  10850. MsgId: "H44022900158202103301752362273",
  10851. PsnNo: "44020000001102942890",
  10852. Info: "2208",
  10853. }
  10854. customData = append(customData, custom15)
  10855. custom16 := &CustomData{
  10856. MsgId: "H44022900158202103301751082917",
  10857. PsnNo: "44020000001101662162",
  10858. Info: "2208",
  10859. }
  10860. customData = append(customData, custom16)
  10861. custom17 := &CustomData{
  10862. MsgId: "H44022900158202103301754147728",
  10863. PsnNo: "44020000000229014511",
  10864. Info: "2208",
  10865. }
  10866. customData = append(customData, custom17)
  10867. adminUser := c.GetAdminUserInfo()
  10868. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10869. for _, item := range customData {
  10870. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10871. fmt.Println(result)
  10872. }
  10873. }
  10874. func PathExists(path string) (bool, error) {
  10875. _, err := os.Stat(path)
  10876. if err == nil {
  10877. return true, nil
  10878. }
  10879. if os.IsNotExist(err) {
  10880. return false, nil
  10881. }
  10882. return false, err
  10883. }
  10884. //创建文件夹
  10885. func Mkdir(dir string) {
  10886. // 创建文件夹
  10887. exist, err := PathExists(dir)
  10888. if err != nil {
  10889. fmt.Println(err.Error())
  10890. } else {
  10891. if exist {
  10892. fmt.Println(dir + "文件夹已存在!")
  10893. } else {
  10894. // 文件夹名称,权限
  10895. err := os.Mkdir(dir, os.ModePerm)
  10896. if err != nil {
  10897. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10898. } else {
  10899. fmt.Println(dir + "文件夹创建成功!")
  10900. }
  10901. }
  10902. }
  10903. }
  10904. //压缩文件
  10905. func Zip(srcFile string, destZip string) error {
  10906. zipfile, err := os.Create(destZip)
  10907. if err != nil {
  10908. return err
  10909. }
  10910. defer zipfile.Close()
  10911. archive := zip.NewWriter(zipfile)
  10912. defer archive.Close()
  10913. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10914. if err != nil {
  10915. return err
  10916. }
  10917. header, err := zip.FileInfoHeader(info)
  10918. if err != nil {
  10919. return err
  10920. }
  10921. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10922. // header.Name = path
  10923. if info.IsDir() {
  10924. header.Name += "/"
  10925. } else {
  10926. header.Method = zip.Deflate
  10927. }
  10928. writer, err := archive.CreateHeader(header)
  10929. if err != nil {
  10930. return err
  10931. }
  10932. if !info.IsDir() {
  10933. file, err := os.Open(path)
  10934. if err != nil {
  10935. return err
  10936. }
  10937. defer file.Close()
  10938. _, err = io.Copy(writer, file)
  10939. }
  10940. return err
  10941. })
  10942. return err
  10943. }
  10944. func ReadFile(filePath string) []byte {
  10945. f, err := os.Open(filePath)
  10946. if err != nil {
  10947. fmt.Println("read file fail", err)
  10948. return nil
  10949. }
  10950. defer f.Close()
  10951. fd, err := ioutil.ReadAll(f)
  10952. if err != nil {
  10953. fmt.Println("read to fd fail", err)
  10954. return nil
  10955. }
  10956. return fd
  10957. }
  10958. func saveLog(result string, request string, infno string, desc string) {
  10959. org_id, _ := beego.AppConfig.Int64("org_id")
  10960. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10961. dir := miConfig.OrgName + "日志"
  10962. utils.Mkdir(dir)
  10963. month := time.Unix(1557042972, 0).Format("1")
  10964. year := time.Now().Format("2006")
  10965. month = time.Now().Format("01")
  10966. day := time.Now().Format("02")
  10967. hour := time.Now().Format("15")
  10968. min := time.Now().Format("04")
  10969. sec := time.Now().Format("05")
  10970. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10971. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10972. file_name := file + ".txt"
  10973. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10974. exist, _ := utils.PathExists(file_path)
  10975. if exist { //存在
  10976. fmt.Println("存在")
  10977. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10978. if err != nil {
  10979. fmt.Println("read fail")
  10980. }
  10981. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10982. n, _ := f.Seek(0, 2)
  10983. _, err = f.WriteAt([]byte(content), n)
  10984. } else { //不存在
  10985. fmt.Println("文件不存在,创建文件")
  10986. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10987. defer f.Close()
  10988. if err != nil {
  10989. } else {
  10990. _, err = f.Write([]byte("记录日志"))
  10991. }
  10992. }
  10993. }
  10994. type Charset string
  10995. const (
  10996. UTF8 = Charset("UTF-8")
  10997. GB18030 = Charset("GB18030")
  10998. )
  10999. func ConvertToString(src string, srcCode string, tagCode string) string {
  11000. srcCoder := mahonia.NewDecoder(srcCode)
  11001. srcResult := srcCoder.ConvertString(src)
  11002. tagCoder := mahonia.NewDecoder(tagCode)
  11003. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11004. result := string(cdata)
  11005. return result
  11006. }
  11007. func (c *HisApiController) ReadEleCard() {
  11008. id_card_type, _ := c.GetInt64("id_card_type")
  11009. admin_user_id, _ := c.GetInt64("admin_user_id")
  11010. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11011. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11013. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11014. var api string
  11015. if miConfig.MdtrtareaAdmvs == "320921" {
  11016. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11017. "&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
  11018. fmt.Println(api)
  11019. } else {
  11020. 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 +
  11021. "&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)
  11022. }
  11023. resp, requestErr := http.Get(api)
  11024. if requestErr != nil {
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11026. return
  11027. }
  11028. body, ioErr := ioutil.ReadAll(resp.Body)
  11029. if ioErr != nil {
  11030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11032. return
  11033. }
  11034. var respJSON map[string]interface{}
  11035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11038. return
  11039. }
  11040. var status string
  11041. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11042. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11043. var token string
  11044. var res ResultTwo //1101结果
  11045. var res10265 ResultTwo10265 //1101结果
  11046. if status == "0" { //读卡成功
  11047. var card_info string //卡信息
  11048. var busi_card_info string
  11049. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11050. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11051. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11052. fmt.Println(card_info)
  11053. fmt.Println(busi_card_info)
  11054. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11055. result, _ := json.Marshal(respJSON)
  11056. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11057. utils.ErrorLog("解析失败:%v", err)
  11058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11059. return
  11060. }
  11061. res.ErrMsg = res10265.ErrMsg
  11062. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11063. res.Infcode = infocode
  11064. res.Output = res10265.Output
  11065. res.InfRefmsgid = res10265.InfRefmsgid
  11066. if res.Infcode == 0 {
  11067. c.ServeSuccessJSON(map[string]interface{}{
  11068. "number": token,
  11069. })
  11070. }
  11071. } else {
  11072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11073. return
  11074. }
  11075. } else { //读卡失败
  11076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11077. return
  11078. }
  11079. }
  11080. func DeleteExtraSpaceTwo(s string) string {
  11081. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11082. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11083. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11084. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11085. s2 := make([]byte, len(s1)) //定义字符数组切片
  11086. copy(s2, s1) //将字符串复制到切片
  11087. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11088. for len(spc_index) > 0 { //找到适配项
  11089. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11090. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11091. }
  11092. return string(s2)
  11093. }
  11094. func Remove0000(s string) string {
  11095. str := make([]rune, 0, len(s))
  11096. for _, v := range []rune(s) {
  11097. if v == 0 {
  11098. continue
  11099. }
  11100. str = append(str, v)
  11101. }
  11102. return string(str)
  11103. }
  11104. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11105. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11106. readCard := DllDef.MustFindProc("EcQuery")
  11107. pCardInfo := make([]byte, 8192)
  11108. pBusiCardInfo := make([]byte, 8192)
  11109. data := make(map[string]interface{})
  11110. //pData := make(map[string]interface{})
  11111. inputData := make(map[string]interface{})
  11112. inputData["orgId"] = code
  11113. inputData["businessType"] = "01101"
  11114. inputData["operatorId"] = operator_id
  11115. inputData["operatorName"] = operator_name
  11116. inputData["officeId"] = "001"
  11117. inputData["officeName"] = "血透室"
  11118. //
  11119. data["data"] = inputData
  11120. data["transType"] = "ec.query"
  11121. data["orgId"] = code
  11122. bytesData, _ := json.Marshal(data)
  11123. pCardInfo = bytesData
  11124. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11125. fmt.Println(ret2)
  11126. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11127. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11128. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11129. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11130. if ret2 != 0 {
  11131. return "", ""
  11132. }
  11133. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11134. }
  11135. func DeleteExtraSpace(s string) string {
  11136. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11137. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11138. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11139. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11140. s2 := make([]byte, len(s1)) //定义字符数组切片
  11141. copy(s2, s1) //将字符串复制到切片
  11142. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11143. for len(spc_index) > 0 { //找到适配项
  11144. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11145. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11146. }
  11147. return string(s2)
  11148. }