his_api_controller.go 453KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357
  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, _ := 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. var dat map[string]interface{}
  1274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1275. fmt.Println(dat)
  1276. } else {
  1277. fmt.Println(err)
  1278. }
  1279. userJSONBytes, _ := json.Marshal(dat)
  1280. var res ResultTwo
  1281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1282. utils.ErrorLog("解析失败:%v", err)
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1284. return
  1285. }
  1286. if res.Infcode == 0 {
  1287. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1288. if err == gorm.ErrRecordNotFound {
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1290. return
  1291. } else if err != nil {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1293. return
  1294. } else {
  1295. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1296. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1297. infoStr := string(Iinfos)
  1298. idetinfoStr := string(Idetinfos)
  1299. psn := &models.HisPsn{
  1300. PsnNo: res.Output.Baseinfo.PsnNo,
  1301. Age: res.Output.Baseinfo.Age,
  1302. PatientId: patient.ID,
  1303. Certno: res.Output.Baseinfo.Certno,
  1304. Brdy: res.Output.Baseinfo.Brdy,
  1305. Gend: res.Output.Baseinfo.Gend,
  1306. Naty: res.Output.Baseinfo.Naty,
  1307. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1308. PsnName: res.Output.Baseinfo.PsnName,
  1309. Idetinfo: idetinfoStr,
  1310. Insuinfo: infoStr,
  1311. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1312. CardInfo: basStr,
  1313. VerifyNumber: "",
  1314. }
  1315. service.CreateHisPsn(psn)
  1316. c.ServeSuccessJSON(map[string]interface{}{
  1317. "patient": patient,
  1318. "number": cardnum,
  1319. })
  1320. }
  1321. } else {
  1322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1323. return
  1324. }
  1325. } else {
  1326. if initFlag == 0 {
  1327. c.TestGetBasBaseInit()
  1328. }
  1329. basStr := c.GetBasBaseInfo()
  1330. if len(basStr) == 0 {
  1331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1332. return
  1333. }
  1334. fmt.Println(basStr)
  1335. bas := strings.Split(basStr, "|")
  1336. basNumber := bas[1]
  1337. fmt.Println(basNumber)
  1338. card_sn := bas[3]
  1339. fmt.Println(card_sn)
  1340. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1341. var dat map[string]interface{}
  1342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1343. fmt.Println(dat)
  1344. } else {
  1345. fmt.Println(err)
  1346. }
  1347. userJSONBytes, _ := json.Marshal(dat)
  1348. var res ResultTwo
  1349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1350. utils.ErrorLog("解析失败:%v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. if res.Infcode == 0 {
  1355. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1356. if err == gorm.ErrRecordNotFound {
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1358. return
  1359. } else if err != nil {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1361. return
  1362. } else {
  1363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1365. infoStr := string(Iinfos)
  1366. idetinfoStr := string(Idetinfos)
  1367. psn := &models.HisPsn{
  1368. PsnNo: res.Output.Baseinfo.PsnNo,
  1369. Age: res.Output.Baseinfo.Age,
  1370. PatientId: patient.ID,
  1371. Certno: res.Output.Baseinfo.Certno,
  1372. Brdy: res.Output.Baseinfo.Brdy,
  1373. Gend: res.Output.Baseinfo.Gend,
  1374. Naty: res.Output.Baseinfo.Naty,
  1375. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1376. PsnName: res.Output.Baseinfo.PsnName,
  1377. Idetinfo: idetinfoStr,
  1378. Insuinfo: infoStr,
  1379. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1380. CardInfo: basStr,
  1381. VerifyNumber: "",
  1382. }
  1383. service.CreateHisPsn(psn)
  1384. c.ServeSuccessJSON(map[string]interface{}{
  1385. "patient": patient,
  1386. "number": basNumber,
  1387. })
  1388. }
  1389. } else {
  1390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1391. return
  1392. }
  1393. break
  1394. }
  1395. case 2:
  1396. SFZStr := c.GetSFZBaseInfo()
  1397. id_card_str := strings.Split(SFZStr, "^")
  1398. id_card_number := id_card_str[0]
  1399. card_sn := ""
  1400. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1401. var dat map[string]interface{}
  1402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1403. fmt.Println(dat)
  1404. } else {
  1405. fmt.Println(err)
  1406. }
  1407. userJSONBytes, _ := json.Marshal(dat)
  1408. var res ResultTwo
  1409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1410. utils.ErrorLog("解析失败:%v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. return
  1413. }
  1414. if res.Infcode == 0 {
  1415. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1416. if err == gorm.ErrRecordNotFound {
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1418. return
  1419. } else if err != nil {
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1421. return
  1422. } else {
  1423. c.ServeSuccessJSON(map[string]interface{}{
  1424. "patient": patient,
  1425. "number": id_card_number,
  1426. })
  1427. }
  1428. } else {
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1430. return
  1431. }
  1432. break
  1433. case 3:
  1434. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1435. var api string
  1436. if miConfig.MdtrtareaAdmvs == "320921" {
  1437. 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 +
  1438. "&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
  1439. fmt.Println(api)
  1440. } else {
  1441. 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 +
  1442. "&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)
  1443. }
  1444. resp, requestErr := http.Get(api)
  1445. if requestErr != nil {
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. body, ioErr := ioutil.ReadAll(resp.Body)
  1450. if ioErr != nil {
  1451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return
  1454. }
  1455. var respJSON map[string]interface{}
  1456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1459. return
  1460. }
  1461. var status string
  1462. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1463. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1464. var token string
  1465. var res ResultTwo //1101结果
  1466. var res10265 ResultTwo10265 //1101结果
  1467. var card_info string //卡信息
  1468. var busi_card_info string
  1469. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1470. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1471. if status == "0" { //读卡成功
  1472. if card_type == "1" {
  1473. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1474. result, _ := json.Marshal(respJSON)
  1475. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1476. utils.ErrorLog("解析失败:%v", err)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. return
  1479. }
  1480. res.ErrMsg = res10265.ErrMsg
  1481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1482. res.Infcode = infocode
  1483. res.Output = res10265.Output
  1484. res.InfRefmsgid = res10265.InfRefmsgid
  1485. } else {
  1486. //var card_info string //卡信息
  1487. //var busi_card_info string
  1488. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1489. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1490. //fmt.Println(card_info)
  1491. //fmt.Println(busi_card_info)
  1492. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1493. result, _ := json.Marshal(respJSON)
  1494. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1495. utils.ErrorLog("解析失败:%v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. res.ErrMsg = res10265.ErrMsg
  1500. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1501. res.Infcode = infocode
  1502. res.Output = res10265.Output
  1503. res.InfRefmsgid = res10265.InfRefmsgid
  1504. }
  1505. if res.Infcode == 0 {
  1506. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1507. if err == gorm.ErrRecordNotFound {
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1509. return
  1510. } else if err != nil {
  1511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1512. return
  1513. } else {
  1514. if card_type == "1" {
  1515. bas := strings.Split(card_info, "|")
  1516. basNumber := bas[2]
  1517. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1518. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1519. infoStr := string(Iinfos)
  1520. idetinfoStr := string(Idetinfos)
  1521. psn := &models.HisPsn{
  1522. PsnNo: res.Output.Baseinfo.PsnNo,
  1523. Age: res.Output.Baseinfo.Age,
  1524. PatientId: patient.ID,
  1525. Certno: res.Output.Baseinfo.Certno,
  1526. Brdy: res.Output.Baseinfo.Brdy,
  1527. Gend: res.Output.Baseinfo.Gend,
  1528. Naty: res.Output.Baseinfo.Naty,
  1529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1530. PsnName: res.Output.Baseinfo.PsnName,
  1531. Idetinfo: idetinfoStr,
  1532. Insuinfo: infoStr,
  1533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1534. CardInfo: card_info,
  1535. VerifyNumber: busi_card_info,
  1536. }
  1537. service.CreateHisPsn(psn)
  1538. c.ServeSuccessJSON(map[string]interface{}{
  1539. "patient": patient,
  1540. "number": basNumber,
  1541. })
  1542. } else {
  1543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1545. infoStr := string(Iinfos)
  1546. idetinfoStr := string(Idetinfos)
  1547. psn := &models.HisPsn{
  1548. PsnNo: res.Output.Baseinfo.PsnNo,
  1549. Age: res.Output.Baseinfo.Age,
  1550. PatientId: patient.ID,
  1551. Certno: res.Output.Baseinfo.Certno,
  1552. Brdy: res.Output.Baseinfo.Brdy,
  1553. Gend: res.Output.Baseinfo.Gend,
  1554. Naty: res.Output.Baseinfo.Naty,
  1555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1556. PsnName: res.Output.Baseinfo.PsnName,
  1557. Idetinfo: idetinfoStr,
  1558. Insuinfo: infoStr,
  1559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1560. CardInfo: card_info,
  1561. VerifyNumber: token,
  1562. }
  1563. service.CreateHisPsn(psn)
  1564. var rf []*ResultFive
  1565. json.Unmarshal([]byte(infoStr), &rf)
  1566. var insutypes []*ResultFive
  1567. var insutype string
  1568. var is390 int = 0
  1569. var is310 int = 0
  1570. for _, item := range rf {
  1571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1572. insutypes = append(insutypes, item)
  1573. }
  1574. }
  1575. if len(insutypes) == 1 {
  1576. insutype = insutypes[0].Insutype
  1577. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1578. } else {
  1579. for _, i := range insutypes {
  1580. if i.Insutype == "390" {
  1581. is390 = 1
  1582. }
  1583. if i.Insutype == "310" {
  1584. is310 = 1
  1585. }
  1586. }
  1587. }
  1588. if is390 == 1 {
  1589. insutype = "390"
  1590. }
  1591. if is310 == 1 {
  1592. insutype = "310"
  1593. }
  1594. if len(insutypes) == 0 {
  1595. insutype = "310"
  1596. }
  1597. c.ServeSuccessJSON(map[string]interface{}{
  1598. "patient": patient,
  1599. "number": token,
  1600. "insutype": insutype,
  1601. })
  1602. }
  1603. }
  1604. } else {
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1606. return
  1607. }
  1608. } else { //读卡失败
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1610. return
  1611. }
  1612. }
  1613. break
  1614. case 4:
  1615. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1616. var api string
  1617. if miConfig.MdtrtareaAdmvs == "320921" {
  1618. 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 +
  1619. "&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
  1620. fmt.Println(api)
  1621. } else {
  1622. 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 +
  1623. "&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)
  1624. }
  1625. resp, requestErr := http.Get(api)
  1626. if requestErr != nil {
  1627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1628. return
  1629. }
  1630. body, ioErr := ioutil.ReadAll(resp.Body)
  1631. if ioErr != nil {
  1632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1634. return
  1635. }
  1636. var respJSON map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. var status string
  1643. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1644. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1645. var token string
  1646. var res ResultTwo //1101结果
  1647. var res10265 ResultTwo10265 //1101结果
  1648. if status == "0" { //读卡成功
  1649. var card_info string //卡信息
  1650. var busi_card_info string
  1651. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1652. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1653. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1654. fmt.Println(card_info)
  1655. fmt.Println(busi_card_info)
  1656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1657. result, _ := json.Marshal(respJSON)
  1658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1659. utils.ErrorLog("解析失败:%v", err)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. return
  1662. }
  1663. res.ErrMsg = res10265.ErrMsg
  1664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1665. res.Infcode = infocode
  1666. res.Output = res10265.Output
  1667. res.InfRefmsgid = res10265.InfRefmsgid
  1668. if res.Infcode == 0 {
  1669. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1670. if err == gorm.ErrRecordNotFound {
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1672. return
  1673. } else if err != nil {
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1675. return
  1676. } else {
  1677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1679. infoStr := string(Iinfos)
  1680. idetinfoStr := string(Idetinfos)
  1681. psn := &models.HisPsn{
  1682. PsnNo: res.Output.Baseinfo.PsnNo,
  1683. Age: res.Output.Baseinfo.Age,
  1684. PatientId: patient.ID,
  1685. Certno: res.Output.Baseinfo.Certno,
  1686. Brdy: res.Output.Baseinfo.Brdy,
  1687. Gend: res.Output.Baseinfo.Gend,
  1688. Naty: res.Output.Baseinfo.Naty,
  1689. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1690. PsnName: res.Output.Baseinfo.PsnName,
  1691. Idetinfo: idetinfoStr,
  1692. Insuinfo: infoStr,
  1693. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1694. CardInfo: card_info,
  1695. VerifyNumber: token,
  1696. }
  1697. service.CreateHisPsn(psn)
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "patient": patient,
  1700. "number": token,
  1701. })
  1702. }
  1703. } else {
  1704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1705. return
  1706. }
  1707. } else { //读卡失败
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1709. return
  1710. }
  1711. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1712. }
  1713. break
  1714. }
  1715. }
  1716. var initFlag int64 = 0
  1717. func (c *HisApiController) TestGetBasBaseInit() {
  1718. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1719. Iinit := DllDef.MustFindProc("Init")
  1720. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1721. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1722. if ret != 0 {
  1723. fmt.Println("SSCard的报错原因:", err)
  1724. fmt.Println("SSCard的运算结果为:", ret)
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1726. return
  1727. }
  1728. result := int(ret)
  1729. fmt.Println("SSCard的运算结果为1:", result)
  1730. initFlag = 1
  1731. return
  1732. }
  1733. func (c *HisApiController) GetSFZBaseInfo() string {
  1734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1735. readCard := DllDef.MustFindProc("ReadSFZ")
  1736. if readCard == nil {
  1737. fmt.Println("readcard is nil")
  1738. readCard = DllDef.MustFindProc("ReadSFZ")
  1739. }
  1740. str := make([]byte, 256)
  1741. str1 := make([]byte, 256)
  1742. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1743. fmt.Println(r)
  1744. return string(str)
  1745. }
  1746. func (c *HisApiController) GetBasBaseInfo() string {
  1747. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1748. readCard := DllDef.MustFindProc("ReadCardBas")
  1749. if readCard == nil {
  1750. fmt.Println("readcard is nil")
  1751. readCard = DllDef.MustFindProc("ReadCardBas")
  1752. }
  1753. str := make([]byte, 1024)
  1754. str1 := make([]byte, 1024)
  1755. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1756. fmt.Println(string(str1))
  1757. fmt.Println(string(str))
  1758. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1759. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1760. if ret2 != 0 {
  1761. return ""
  1762. }
  1763. return string(str)
  1764. }
  1765. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1766. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1767. readCard := DllDef.MustFindProc("read_cardinfo")
  1768. if readCard == nil {
  1769. fmt.Println("readcard is nil")
  1770. readCard = DllDef.MustFindProc("read_cardinfo")
  1771. }
  1772. str := make([]byte, 1024) //卡号
  1773. str1 := make([]byte, 1024) //卡识别码
  1774. str2 := make([]byte, 1024) //身份证号
  1775. str3 := make([]byte, 1024) //姓名
  1776. str4 := make([]byte, 1024) //错误信息
  1777. 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])))
  1778. fmt.Println(string(str1))
  1779. fmt.Println(string(str))
  1780. fmt.Println(string(str2))
  1781. fmt.Println(string(str3))
  1782. fmt.Println(string(str4))
  1783. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1784. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1785. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1786. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1787. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1788. if ret2 != 0 {
  1789. return "", "", "", "", ""
  1790. }
  1791. return string(str), string(str1), string(str2), string(str3), string(str4)
  1792. }
  1793. type CustomFundPay struct {
  1794. FundPayType string `json:"fund_pay_type"`
  1795. FundPayamt float64 `json:"fund_payamt"`
  1796. }
  1797. func (c *HisApiController) GetSettleList() {
  1798. order_id, _ := c.GetInt64("order_id")
  1799. admin_user_id, _ := c.GetInt64("admin_user_id")
  1800. order, _ := service.GetHisOrderByIDTwo(order_id)
  1801. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1802. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1803. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1804. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1805. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1807. if order.ID == 0 {
  1808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1809. return
  1810. }
  1811. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1812. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1813. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1814. fmt.Println(count)
  1815. var zero string
  1816. number := count + 1
  1817. if number >= 1000 {
  1818. zero = "0000" + strconv.FormatInt(number, 10)
  1819. } else if number >= 10000 {
  1820. zero = "000" + strconv.FormatInt(number, 10)
  1821. } else if number >= 100000 {
  1822. zero = "00" + strconv.FormatInt(number, 10)
  1823. } else if number >= 1000000 {
  1824. zero = "0" + strconv.FormatInt(number, 10)
  1825. } else {
  1826. zero = strconv.FormatInt(number, 10)
  1827. }
  1828. fmt.Println(zero)
  1829. struct4101 := service.Struct4101{
  1830. PsnNo: order.PsnNo,
  1831. MdtrtId: order.MdtrtId,
  1832. SetlId: order.SetlId,
  1833. PsnName: order.PsnName,
  1834. Gend: order.Gend,
  1835. Brdy: his.Brdy,
  1836. Age: his.Age,
  1837. Naty: order.Naty,
  1838. PatnCertType: "01",
  1839. Certno: order.Certno,
  1840. Prfs: "90",
  1841. ConerName: roles[0].UserName,
  1842. PatnRlts: "99",
  1843. ConerAddr: miConfig.OrgName,
  1844. ConerTel: admin.Mobile,
  1845. HiType: order.Insutype,
  1846. Insuplc: miConfig.InsuplcAdmdvs,
  1847. MaindiagFlag: "1",
  1848. BillCode: last_order.FaPiaoCode,
  1849. BillNo: zero,
  1850. BizSn: order.Number,
  1851. PsnSelfPay: order.PsnPartAmt,
  1852. PsnOwnPay: order.PsnPartAmt,
  1853. AcctPay: order.AcctPay,
  1854. PsnCashpay: order.PsnCashPay,
  1855. HiPaymtd: "1",
  1856. Hsorg: miConfig.InsuplcAdmdvs,
  1857. HsorgOpter: miConfig.InsuplcAdmdvs,
  1858. MedinsFillPsn: curRoles.UserName,
  1859. MedinsFillDept: depart.Name,
  1860. IptMedType: "2",
  1861. }
  1862. struct4101.SetlBegnDate = order.SetlTime
  1863. struct4101.SetlEndDate = order.SetlTime
  1864. time_arr := strings.Split(order.SetlTime, " ")
  1865. struct4101.AdmTime = time_arr[0]
  1866. struct4101.AdmEndTime = time_arr[0]
  1867. var rf []CustomFundPay
  1868. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1869. var tempFunPays []service.CustomStruct
  1870. for _, item := range rf {
  1871. var tempFunPay service.CustomStruct
  1872. tempFunPay.FundPayamt = item.FundPayamt
  1873. tempFunPay.FundPayType = item.FundPayType
  1874. tempFunPays = append(tempFunPays, tempFunPay)
  1875. }
  1876. struct4101.CustomStruct = tempFunPays
  1877. var tempDiaginfos []service.DiaginfoStructTwo
  1878. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1879. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1880. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1881. var config []*models.HisXtDiagnoseConfig
  1882. for _, item := range diagnosis_ids {
  1883. id, _ := strconv.ParseInt(item, 10, 64)
  1884. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1885. config = append(config, &diagnosisConfig)
  1886. }
  1887. for index, item := range config {
  1888. if index == 0 {
  1889. var tempDiaginfo service.DiaginfoStructTwo
  1890. tempDiaginfo.DiagCode = item.CountryCode
  1891. tempDiaginfo.DiagName = item.CountryContentName
  1892. tempDiaginfo.DiagType = "1"
  1893. tempDiaginfo.MaindiagFlag = "1"
  1894. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1895. } else {
  1896. var tempDiaginfo service.DiaginfoStructTwo
  1897. tempDiaginfo.DiagCode = item.CountryCode
  1898. tempDiaginfo.DiagName = item.CountryContentName
  1899. tempDiaginfo.DiagType = "2"
  1900. tempDiaginfo.MaindiagFlag = "0"
  1901. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1902. }
  1903. }
  1904. struct4101.Diseinfo = tempDiaginfos
  1905. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1906. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1907. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1908. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1909. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1910. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1911. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1912. var iteminfo service.IteminfoStruct
  1913. var bedCostTotal float64 = 0 //床位总费
  1914. var bedCostSelfTotal float64 = 0 //床位自费
  1915. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1916. var operationCostTotal float64 = 0 //手术费
  1917. var operationCostSelfTotal float64 = 0 //手术费
  1918. var operationCostPartSelfTotal float64 = 0 //手术费
  1919. var otherCostTotal float64 = 0 //其他费用
  1920. var otherCostSelfTotal float64 = 0 //其他费用
  1921. var otherCostPartSelfTotal float64 = 0 //其他费用
  1922. var materialCostTotal float64 = 0 //材料费
  1923. var materialCostSelfTotal float64 = 0 //材料费
  1924. var materialCostPartSelfTotal float64 = 0 //材料费
  1925. var westernMedicineCostTotal float64 = 0 //西药费
  1926. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1927. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1928. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1929. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1930. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1931. var checkCostTotal float64 = 0 //检查费
  1932. var checkCostSelfTotal float64 = 0 //检查费
  1933. var checkCostPartSelfTotal float64 = 0 //检查费
  1934. var laboratoryCostTotal float64 = 0 //化验费
  1935. var laboratoryCostSelfTotal float64 = 0 //化验费
  1936. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1937. var treatCostTotal float64 = 0 //治疗费用
  1938. var treatCostSelfTotal float64 = 0 //治疗费用
  1939. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1940. decimal.DivisionPrecision = 2
  1941. var bed_fulamt_ownpay_amt float64 = 0
  1942. var operation_fulamt_ownpay_amt float64 = 0
  1943. var other_fulamt_ownpay_amt float64 = 0
  1944. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1945. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1946. var check_fulamt_ownpay_amt float64 = 0
  1947. var material_fulamt_ownpay_amt float64 = 0
  1948. var laboratory_fulamt_ownpay_amt float64 = 0
  1949. var treat_fulamt_ownpay_amt float64 = 0
  1950. var bed_claa_sunmfee float64 = 0
  1951. var bed_clab_amt float64 = 0
  1952. var bed_other_amt float64 = 0
  1953. var operation_claa_sunmfee float64 = 0
  1954. var operation_clab_amt float64 = 0
  1955. var operation_other_amt float64 = 0
  1956. var other_claa_sunmfee float64 = 0
  1957. var other_clab_amt float64 = 0
  1958. var other_other_amt float64 = 0
  1959. var westernMedicine_claa_sunmfee float64 = 0
  1960. var westernMedicine_clab_amt float64 = 0
  1961. var westernMedicine_other_amt float64 = 0
  1962. var chineseTraditional_claa_sunmfee float64 = 0
  1963. var chineseTraditional_clab_amt float64 = 0
  1964. var chineseTraditional_other_amt float64 = 0
  1965. var check_claa_sunmfee float64 = 0
  1966. var check_clab_amt float64 = 0
  1967. var check_other_amt float64 = 0
  1968. var material_claa_sunmfee float64 = 0
  1969. var material_clab_amt float64 = 0
  1970. var material_other_amt float64 = 0
  1971. var laboratory_claa_sunmfee float64 = 0
  1972. var laboratory_clab_amt float64 = 0
  1973. var laboratory_other_amt float64 = 0
  1974. var treat_claa_sunmfee float64 = 0
  1975. var treat_clab_amt float64 = 0
  1976. var treat_other_amt float64 = 0
  1977. for _, item := range order.HisOrderInfo {
  1978. if item.MedChrgitmType == "01" { //床位费
  1979. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1980. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1981. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1982. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1983. if item.ChrgitmLv == "1" {
  1984. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1985. }
  1986. if item.ChrgitmLv == "2" {
  1987. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1988. }
  1989. if item.ChrgitmLv == "3" {
  1990. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1991. }
  1992. }
  1993. if item.MedChrgitmType == "03" { //检查费
  1994. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1995. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1996. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1997. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1998. if item.ChrgitmLv == "1" {
  1999. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2000. }
  2001. if item.ChrgitmLv == "2" {
  2002. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2003. }
  2004. if item.ChrgitmLv == "3" {
  2005. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2006. }
  2007. }
  2008. if item.MedChrgitmType == "04" { //化验费
  2009. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2010. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2011. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2012. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2013. if item.ChrgitmLv == "1" {
  2014. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2015. }
  2016. if item.ChrgitmLv == "2" {
  2017. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2018. }
  2019. if item.ChrgitmLv == "3" {
  2020. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2021. }
  2022. }
  2023. if item.MedChrgitmType == "05" { //治疗费
  2024. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2025. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2026. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2027. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2028. if item.ChrgitmLv == "1" {
  2029. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2030. }
  2031. if item.ChrgitmLv == "2" {
  2032. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2033. }
  2034. if item.ChrgitmLv == "3" {
  2035. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2036. }
  2037. }
  2038. if item.MedChrgitmType == "06" { //手术费
  2039. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2040. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2041. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2042. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2043. if item.ChrgitmLv == "1" {
  2044. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2045. }
  2046. if item.ChrgitmLv == "2" {
  2047. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2048. }
  2049. if item.ChrgitmLv == "3" {
  2050. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2051. }
  2052. }
  2053. if item.MedChrgitmType == "08" { //材料费
  2054. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2055. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2056. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2057. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2058. if item.ChrgitmLv == "1" {
  2059. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2060. }
  2061. if item.ChrgitmLv == "2" {
  2062. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "3" {
  2065. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2066. }
  2067. }
  2068. if item.MedChrgitmType == "09" { //西药费
  2069. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2070. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2071. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2072. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2073. if item.ChrgitmLv == "1" {
  2074. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2075. }
  2076. if item.ChrgitmLv == "2" {
  2077. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "3" {
  2080. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2081. }
  2082. }
  2083. if item.MedChrgitmType == "11" { //中成费
  2084. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2085. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2086. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2087. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2088. if item.ChrgitmLv == "1" {
  2089. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2090. }
  2091. if item.ChrgitmLv == "2" {
  2092. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "3" {
  2095. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2096. }
  2097. }
  2098. if item.MedChrgitmType == "14" { //其他费
  2099. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2100. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2101. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2102. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2103. if item.ChrgitmLv == "1" {
  2104. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "2" {
  2107. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "3" {
  2110. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2111. }
  2112. }
  2113. }
  2114. var iteminfoStructs []service.IteminfoStruct
  2115. if bedCostTotal != 0 {
  2116. iteminfo.MedChrgitm = "01"
  2117. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2118. iteminfo.Amt = bedCostTotal
  2119. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2120. iteminfo.ClabAmt = bed_clab_amt
  2121. iteminfo.OthAmt = bed_other_amt
  2122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2123. }
  2124. if checkCostTotal != 0 {
  2125. iteminfo.MedChrgitm = "03"
  2126. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2127. iteminfo.Amt = checkCostTotal
  2128. iteminfo.ClaaSumfee = check_claa_sunmfee
  2129. iteminfo.ClabAmt = check_clab_amt
  2130. iteminfo.OthAmt = check_other_amt
  2131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2132. }
  2133. if laboratoryCostTotal != 0 {
  2134. iteminfo.MedChrgitm = "04"
  2135. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2136. iteminfo.Amt = laboratoryCostTotal
  2137. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2138. iteminfo.ClabAmt = laboratory_clab_amt
  2139. iteminfo.OthAmt = laboratory_other_amt
  2140. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2142. }
  2143. if treatCostTotal != 0 {
  2144. iteminfo.MedChrgitm = "05"
  2145. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2146. iteminfo.Amt = treatCostTotal
  2147. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2148. iteminfo.ClabAmt = treat_clab_amt
  2149. iteminfo.OthAmt = treat_other_amt
  2150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2151. //(struct4101.IteminfoStruct, iteminfo)
  2152. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2153. }
  2154. if operationCostTotal != 0 {
  2155. iteminfo.MedChrgitm = "06"
  2156. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2157. iteminfo.Amt = operationCostTotal
  2158. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2159. iteminfo.ClabAmt = operation_clab_amt
  2160. iteminfo.OthAmt = operation_other_amt
  2161. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2163. }
  2164. if materialCostTotal != 0 {
  2165. iteminfo.MedChrgitm = "08"
  2166. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2167. iteminfo.Amt = materialCostTotal
  2168. iteminfo.ClaaSumfee = material_claa_sunmfee
  2169. iteminfo.ClabAmt = material_clab_amt
  2170. iteminfo.OthAmt = material_other_amt
  2171. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2172. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2173. }
  2174. if westernMedicineCostTotal != 0 {
  2175. iteminfo.MedChrgitm = "09"
  2176. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2177. iteminfo.Amt = westernMedicineCostTotal
  2178. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2179. iteminfo.ClabAmt = westernMedicine_clab_amt
  2180. iteminfo.OthAmt = westernMedicine_other_amt
  2181. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2183. }
  2184. if chineseTraditionalMedicineCostTotal != 0 {
  2185. iteminfo.MedChrgitm = "11"
  2186. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2187. iteminfo.Amt = westernMedicineCostTotal
  2188. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2189. iteminfo.ClabAmt = westernMedicine_clab_amt
  2190. iteminfo.OthAmt = westernMedicine_other_amt
  2191. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2193. }
  2194. if otherCostTotal != 0 {
  2195. iteminfo.MedChrgitm = "14"
  2196. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2197. iteminfo.Amt = otherCostTotal
  2198. iteminfo.ClaaSumfee = other_claa_sunmfee
  2199. iteminfo.ClabAmt = other_clab_amt
  2200. iteminfo.OthAmt = other_other_amt
  2201. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2203. }
  2204. struct4101.IteminfoStruct = iteminfoStructs
  2205. struct4101.Ntly = "中国"
  2206. struct4101.AdmCaty = "A03.06"
  2207. var res ResultSeventeen
  2208. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2209. var resOther ResultSeventeenOther
  2210. var pp models.PublicParams
  2211. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2212. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2213. pp.FixmedinsName = miConfig.OrgName
  2214. pp.FixmedinsCode = miConfig.Code
  2215. pp.RequestUrl = miConfig.Url
  2216. pp.Cainfo = miConfig.Cainfo
  2217. pp.SecretKey = miConfig.SecretKey
  2218. pp.AccessKey = miConfig.AccessKey
  2219. pp.OpterName = curRoles.UserName
  2220. client := &http.Client{}
  2221. var req *http.Request
  2222. data := make(map[string]interface{})
  2223. data["struct4101"] = struct4101
  2224. data["pp"] = pp
  2225. bytesData, _ := json.Marshal(data)
  2226. if miConfig.MdtrtareaAdmvs == "320921" {
  2227. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2228. } else {
  2229. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2230. }
  2231. resp, _ := client.Do(req)
  2232. defer resp.Body.Close()
  2233. body, ioErr := ioutil.ReadAll(resp.Body)
  2234. if ioErr != nil {
  2235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2237. return
  2238. }
  2239. var respJSON map[string]interface{}
  2240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. return
  2244. }
  2245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2246. userJSONBytes, _ := json.Marshal(respJSON)
  2247. fmt.Println("log")
  2248. fmt.Println(string(userJSONBytes))
  2249. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2250. utils.ErrorLog("解析失败:%v", err)
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. return
  2253. }
  2254. res.InfRefmsgid = resOther.InfRefmsgid
  2255. res.Output = resOther.Output
  2256. res.ErrMsg = resOther.ErrMsg
  2257. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2258. res.Infcode = infocode
  2259. } else {
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2261. var dat map[string]interface{}
  2262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2263. fmt.Println(dat)
  2264. } else {
  2265. fmt.Println(err)
  2266. }
  2267. userJSONBytes, _ := json.Marshal(dat)
  2268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2269. utils.ErrorLog("解析失败:%v", err)
  2270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2271. return
  2272. }
  2273. }
  2274. if res.Infcode != 0 {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "failed_code": -10,
  2277. "msg": res.ErrMsg,
  2278. })
  2279. return
  2280. } else {
  2281. order.FaPiaoNumber = zero
  2282. order.FaPiaoCode = last_order.FaPiaoCode
  2283. service.UpdateOrder(order)
  2284. hisFundSettleListResult := &models.HisFundSettleListResult{
  2285. Number: res.Output.SetlListId,
  2286. Status: 1,
  2287. Ctime: time.Now().Unix(),
  2288. Mtime: time.Now().Unix(),
  2289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2290. IsUpload: 1,
  2291. OrderId: order_id,
  2292. }
  2293. service.CreateUploadRecord(hisFundSettleListResult)
  2294. c.ServeSuccessJSON(map[string]interface{}{
  2295. "msg": "上传成功",
  2296. "result": hisFundSettleListResult,
  2297. })
  2298. return
  2299. }
  2300. }
  2301. func (c *HisApiController) GetSettleListHospital() {
  2302. order_id, _ := c.GetInt64("order_id")
  2303. admin_user_id, _ := c.GetInt64("admin_user_id")
  2304. order, _ := service.GetHisOrderByIDTwo(order_id)
  2305. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2306. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2307. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2309. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2311. if order.ID == 0 {
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2313. return
  2314. }
  2315. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2316. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2317. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2318. fmt.Println(count)
  2319. var zero string
  2320. number := count + 1
  2321. if number >= 1000 {
  2322. zero = "0000" + strconv.FormatInt(number, 10)
  2323. } else if number >= 10000 {
  2324. zero = "000" + strconv.FormatInt(number, 10)
  2325. } else if number >= 100000 {
  2326. zero = "00" + strconv.FormatInt(number, 10)
  2327. } else if number >= 1000000 {
  2328. zero = "0" + strconv.FormatInt(number, 10)
  2329. } else {
  2330. zero = strconv.FormatInt(number, 10)
  2331. }
  2332. fmt.Println(zero)
  2333. struct4101 := service.Struct4101{
  2334. PsnNo: order.PsnNo,
  2335. MdtrtId: order.MdtrtId,
  2336. SetlId: order.SetlId,
  2337. PsnName: order.PsnName,
  2338. Gend: order.Gend,
  2339. Brdy: his.Brdy,
  2340. Age: int64(order.Age),
  2341. Naty: order.Naty,
  2342. PatnCertType: "01",
  2343. Certno: order.Certno,
  2344. Prfs: "90",
  2345. ConerName: roles[0].UserName,
  2346. PatnRlts: "99",
  2347. ConerAddr: miConfig.OrgName,
  2348. ConerTel: admin.Mobile,
  2349. HiType: order.Insutype,
  2350. Insuplc: miConfig.InsuplcAdmdvs,
  2351. MaindiagFlag: "1",
  2352. BillCode: last_order.FaPiaoCode,
  2353. BillNo: zero,
  2354. BizSn: order.Number,
  2355. PsnSelfPay: order.PsnPartAmt,
  2356. PsnOwnPay: order.PsnPartAmt,
  2357. AcctPay: order.AcctPay,
  2358. PsnCashpay: order.PsnCashPay,
  2359. HiPaymtd: "1",
  2360. Hsorg: miConfig.InsuplcAdmdvs,
  2361. HsorgOpter: miConfig.InsuplcAdmdvs,
  2362. MedinsFillPsn: curRoles.UserName,
  2363. MedinsFillDept: depart.Name,
  2364. IptMedType: "2",
  2365. AdmTime: his.InHosptialTime,
  2366. AdmEndTime: his.OutHosptialTime,
  2367. }
  2368. struct4101.SetlBegnDate = order.SetlTime
  2369. struct4101.SetlEndDate = order.SetlTime
  2370. var rf []CustomFundPay
  2371. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2372. var tempFunPays []service.CustomStruct
  2373. for _, item := range rf {
  2374. var tempFunPay service.CustomStruct
  2375. tempFunPay.FundPayamt = item.FundPayamt
  2376. tempFunPay.FundPayType = item.FundPayType
  2377. tempFunPays = append(tempFunPays, tempFunPay)
  2378. }
  2379. struct4101.CustomStruct = tempFunPays
  2380. var tempDiaginfos []service.DiaginfoStructTwo
  2381. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2382. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2384. var config []*models.HisXtDiagnoseConfig
  2385. for _, item := range diagnosis_ids {
  2386. id, _ := strconv.ParseInt(item, 10, 64)
  2387. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2388. config = append(config, &diagnosisConfig)
  2389. }
  2390. for index, item := range config {
  2391. if index == 0 {
  2392. var tempDiaginfo service.DiaginfoStructTwo
  2393. tempDiaginfo.DiagCode = item.CountryCode
  2394. tempDiaginfo.DiagName = item.CountryContentName
  2395. tempDiaginfo.DiagType = "1"
  2396. tempDiaginfo.MaindiagFlag = "1"
  2397. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2398. } else {
  2399. var tempDiaginfo service.DiaginfoStructTwo
  2400. tempDiaginfo.DiagCode = item.CountryCode
  2401. tempDiaginfo.DiagName = item.CountryContentName
  2402. tempDiaginfo.DiagType = "2"
  2403. tempDiaginfo.MaindiagFlag = "0"
  2404. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2405. }
  2406. }
  2407. struct4101.Diseinfo = tempDiaginfos
  2408. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2409. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2410. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2411. tempOpspdiseinfo2.OprnOprtCode = ""
  2412. tempOpspdiseinfo2.OprnOprtName = ""
  2413. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2414. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2415. var iteminfo service.IteminfoStruct
  2416. var bedCostTotal float64 = 0 //床位总费
  2417. var bedCostSelfTotal float64 = 0 //床位自费
  2418. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2419. var operationCostTotal float64 = 0 //手术费
  2420. var operationCostSelfTotal float64 = 0 //手术费
  2421. var operationCostPartSelfTotal float64 = 0 //手术费
  2422. var otherCostTotal float64 = 0 //其他费用
  2423. var otherCostSelfTotal float64 = 0 //其他费用
  2424. var otherCostPartSelfTotal float64 = 0 //其他费用
  2425. var materialCostTotal float64 = 0 //材料费
  2426. var materialCostSelfTotal float64 = 0 //材料费
  2427. var materialCostPartSelfTotal float64 = 0 //材料费
  2428. var westernMedicineCostTotal float64 = 0 //西药费
  2429. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2430. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2431. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2432. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2433. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2434. var checkCostTotal float64 = 0 //检查费
  2435. var checkCostSelfTotal float64 = 0 //检查费
  2436. var checkCostPartSelfTotal float64 = 0 //检查费
  2437. var laboratoryCostTotal float64 = 0 //化验费
  2438. var laboratoryCostSelfTotal float64 = 0 //化验费
  2439. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2440. var treatCostTotal float64 = 0 //治疗费用
  2441. var treatCostSelfTotal float64 = 0 //治疗费用
  2442. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2443. decimal.DivisionPrecision = 2
  2444. var bed_fulamt_ownpay_amt float64 = 0
  2445. var operation_fulamt_ownpay_amt float64 = 0
  2446. var other_fulamt_ownpay_amt float64 = 0
  2447. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2448. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2449. var check_fulamt_ownpay_amt float64 = 0
  2450. var material_fulamt_ownpay_amt float64 = 0
  2451. var laboratory_fulamt_ownpay_amt float64 = 0
  2452. var treat_fulamt_ownpay_amt float64 = 0
  2453. var bed_claa_sunmfee float64 = 0
  2454. var bed_clab_amt float64 = 0
  2455. var bed_other_amt float64 = 0
  2456. var operation_claa_sunmfee float64 = 0
  2457. var operation_clab_amt float64 = 0
  2458. var operation_other_amt float64 = 0
  2459. var other_claa_sunmfee float64 = 0
  2460. var other_clab_amt float64 = 0
  2461. var other_other_amt float64 = 0
  2462. var westernMedicine_claa_sunmfee float64 = 0
  2463. var westernMedicine_clab_amt float64 = 0
  2464. var westernMedicine_other_amt float64 = 0
  2465. var chineseTraditional_claa_sunmfee float64 = 0
  2466. var chineseTraditional_clab_amt float64 = 0
  2467. var chineseTraditional_other_amt float64 = 0
  2468. var check_claa_sunmfee float64 = 0
  2469. var check_clab_amt float64 = 0
  2470. var check_other_amt float64 = 0
  2471. var material_claa_sunmfee float64 = 0
  2472. var material_clab_amt float64 = 0
  2473. var material_other_amt float64 = 0
  2474. var laboratory_claa_sunmfee float64 = 0
  2475. var laboratory_clab_amt float64 = 0
  2476. var laboratory_other_amt float64 = 0
  2477. var treat_claa_sunmfee float64 = 0
  2478. var treat_clab_amt float64 = 0
  2479. var treat_other_amt float64 = 0
  2480. for _, item := range order.HisOrderInfo {
  2481. if item.MedChrgitmType == "01" { //床位费
  2482. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2483. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2484. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2485. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2486. if item.ChrgitmLv == "1" {
  2487. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2488. }
  2489. if item.ChrgitmLv == "2" {
  2490. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2491. }
  2492. if item.ChrgitmLv == "3" {
  2493. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2494. }
  2495. }
  2496. if item.MedChrgitmType == "03" { //检查费
  2497. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2498. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2499. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2500. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2501. if item.ChrgitmLv == "1" {
  2502. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2503. }
  2504. if item.ChrgitmLv == "2" {
  2505. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2506. }
  2507. if item.ChrgitmLv == "3" {
  2508. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2509. }
  2510. }
  2511. if item.MedChrgitmType == "04" { //化验费
  2512. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2513. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2514. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2515. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2516. if item.ChrgitmLv == "1" {
  2517. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2518. }
  2519. if item.ChrgitmLv == "2" {
  2520. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2521. }
  2522. if item.ChrgitmLv == "3" {
  2523. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2524. }
  2525. }
  2526. if item.MedChrgitmType == "05" { //治疗费
  2527. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2528. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2529. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2530. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2531. if item.ChrgitmLv == "1" {
  2532. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2533. }
  2534. if item.ChrgitmLv == "2" {
  2535. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2536. }
  2537. if item.ChrgitmLv == "3" {
  2538. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2539. }
  2540. }
  2541. if item.MedChrgitmType == "06" { //手术费
  2542. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2543. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2544. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2545. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2546. if item.ChrgitmLv == "1" {
  2547. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2548. }
  2549. if item.ChrgitmLv == "2" {
  2550. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2551. }
  2552. if item.ChrgitmLv == "3" {
  2553. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2554. }
  2555. }
  2556. if item.MedChrgitmType == "08" { //材料费
  2557. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2558. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2559. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2560. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2561. if item.ChrgitmLv == "1" {
  2562. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2563. }
  2564. if item.ChrgitmLv == "2" {
  2565. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2566. }
  2567. if item.ChrgitmLv == "3" {
  2568. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2569. }
  2570. }
  2571. if item.MedChrgitmType == "09" { //西药费
  2572. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2573. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2574. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2575. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2576. if item.ChrgitmLv == "1" {
  2577. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2578. }
  2579. if item.ChrgitmLv == "2" {
  2580. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2581. }
  2582. if item.ChrgitmLv == "3" {
  2583. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2584. }
  2585. }
  2586. if item.MedChrgitmType == "11" { //中成费
  2587. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2588. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2589. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2590. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2591. if item.ChrgitmLv == "1" {
  2592. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2593. }
  2594. if item.ChrgitmLv == "2" {
  2595. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2596. }
  2597. if item.ChrgitmLv == "3" {
  2598. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2599. }
  2600. }
  2601. if item.MedChrgitmType == "14" { //其他费
  2602. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2603. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2604. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2605. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2606. if item.ChrgitmLv == "1" {
  2607. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2608. }
  2609. if item.ChrgitmLv == "2" {
  2610. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2611. }
  2612. if item.ChrgitmLv == "3" {
  2613. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2614. }
  2615. }
  2616. }
  2617. var iteminfoStructs []service.IteminfoStruct
  2618. if bedCostTotal != 0 {
  2619. iteminfo.MedChrgitm = "01"
  2620. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2621. iteminfo.Amt = bedCostTotal
  2622. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2623. iteminfo.ClabAmt = bed_clab_amt
  2624. iteminfo.OthAmt = bed_other_amt
  2625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2626. }
  2627. if checkCostTotal != 0 {
  2628. iteminfo.MedChrgitm = "03"
  2629. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2630. iteminfo.Amt = checkCostTotal
  2631. iteminfo.ClaaSumfee = check_claa_sunmfee
  2632. iteminfo.ClabAmt = check_clab_amt
  2633. iteminfo.OthAmt = check_other_amt
  2634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2635. }
  2636. if laboratoryCostTotal != 0 {
  2637. iteminfo.MedChrgitm = "04"
  2638. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2639. iteminfo.Amt = laboratoryCostTotal
  2640. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2641. iteminfo.ClabAmt = laboratory_clab_amt
  2642. iteminfo.OthAmt = laboratory_other_amt
  2643. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2645. }
  2646. if treatCostTotal != 0 {
  2647. iteminfo.MedChrgitm = "05"
  2648. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2649. iteminfo.Amt = treatCostTotal
  2650. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2651. iteminfo.ClabAmt = treat_clab_amt
  2652. iteminfo.OthAmt = treat_other_amt
  2653. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2654. //(struct4101.IteminfoStruct, iteminfo)
  2655. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2656. }
  2657. if operationCostTotal != 0 {
  2658. iteminfo.MedChrgitm = "06"
  2659. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2660. iteminfo.Amt = operationCostTotal
  2661. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2662. iteminfo.ClabAmt = operation_clab_amt
  2663. iteminfo.OthAmt = operation_other_amt
  2664. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2665. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2666. }
  2667. if materialCostTotal != 0 {
  2668. iteminfo.MedChrgitm = "08"
  2669. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2670. iteminfo.Amt = materialCostTotal
  2671. iteminfo.ClaaSumfee = material_claa_sunmfee
  2672. iteminfo.ClabAmt = material_clab_amt
  2673. iteminfo.OthAmt = material_other_amt
  2674. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2675. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2676. }
  2677. if westernMedicineCostTotal != 0 {
  2678. iteminfo.MedChrgitm = "09"
  2679. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2680. iteminfo.Amt = westernMedicineCostTotal
  2681. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2682. iteminfo.ClabAmt = westernMedicine_clab_amt
  2683. iteminfo.OthAmt = westernMedicine_other_amt
  2684. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2685. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2686. }
  2687. if chineseTraditionalMedicineCostTotal != 0 {
  2688. iteminfo.MedChrgitm = "11"
  2689. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2690. iteminfo.Amt = westernMedicineCostTotal
  2691. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2692. iteminfo.ClabAmt = westernMedicine_clab_amt
  2693. iteminfo.OthAmt = westernMedicine_other_amt
  2694. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2695. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2696. }
  2697. if otherCostTotal != 0 {
  2698. iteminfo.MedChrgitm = "14"
  2699. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2700. iteminfo.Amt = otherCostTotal
  2701. iteminfo.ClaaSumfee = other_claa_sunmfee
  2702. iteminfo.ClabAmt = other_clab_amt
  2703. iteminfo.OthAmt = other_other_amt
  2704. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2705. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2706. }
  2707. struct4101.IteminfoStruct = iteminfoStructs
  2708. struct4101.Ntly = "中国"
  2709. struct4101.AdmCaty = "A03.06"
  2710. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2711. fmt.Println(result)
  2712. var dat map[string]interface{}
  2713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2714. fmt.Println(dat)
  2715. } else {
  2716. fmt.Println(err)
  2717. }
  2718. userJSONBytes, _ := json.Marshal(dat)
  2719. var res ResultSeventeen
  2720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2721. utils.ErrorLog("解析失败:%v", err)
  2722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2723. return
  2724. }
  2725. if res.Infcode != 0 {
  2726. c.ServeSuccessJSON(map[string]interface{}{
  2727. "failed_code": -10,
  2728. "msg": res.ErrMsg,
  2729. })
  2730. return
  2731. } else {
  2732. order.FaPiaoNumber = zero
  2733. order.FaPiaoCode = last_order.FaPiaoCode
  2734. service.UpdateOrder(order)
  2735. hisFundSettleListResult := &models.HisFundSettleListResult{
  2736. Number: res.Output.SetlListId,
  2737. Status: 1,
  2738. Ctime: time.Now().Unix(),
  2739. Mtime: time.Now().Unix(),
  2740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2741. IsUpload: 1,
  2742. OrderId: order_id,
  2743. }
  2744. service.CreateUploadRecord(hisFundSettleListResult)
  2745. c.ServeSuccessJSON(map[string]interface{}{
  2746. "msg": "上传成功",
  2747. "result": hisFundSettleListResult,
  2748. })
  2749. return
  2750. }
  2751. }
  2752. func (c *HisApiController) GetBatchSettleList() {
  2753. orders, _ := service.GetAllHisOrder(10106)
  2754. for _, item := range orders {
  2755. order_id := item.ID
  2756. order, _ := service.GetHisOrderByIDTwo(order_id)
  2757. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2758. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2759. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2760. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2761. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2762. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2763. if order.ID == 0 {
  2764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2765. return
  2766. }
  2767. if his.BalanceAccountsType == 2 {
  2768. continue
  2769. }
  2770. struct4101 := service.Struct4101{
  2771. PsnNo: order.PsnNo,
  2772. MdtrtId: order.MdtrtId,
  2773. SetlId: order.SetlId,
  2774. PsnName: order.PsnName,
  2775. Gend: order.Gend,
  2776. Brdy: his.Brdy,
  2777. Age: his.Age,
  2778. Naty: order.Naty,
  2779. PatnCertType: "01",
  2780. Certno: order.Certno,
  2781. Prfs: "90",
  2782. ConerName: roles[0].UserName,
  2783. PatnRlts: "99",
  2784. ConerAddr: miConfig.OrgName,
  2785. ConerTel: admin.Mobile,
  2786. HiType: order.Insutype,
  2787. Insuplc: his.InsuplcAdmdvs,
  2788. MaindiagFlag: "1",
  2789. BillCode: order.FaPiaoCode,
  2790. BillNo: order.FaPiaoNumber,
  2791. BizSn: order.Number,
  2792. PsnSelfPay: order.PsnPartAmt,
  2793. PsnOwnPay: order.PsnPartAmt,
  2794. AcctPay: order.AcctPay,
  2795. PsnCashpay: order.PsnCashPay,
  2796. HiPaymtd: "1",
  2797. Hsorg: his.InsuplcAdmdvs,
  2798. HsorgOpter: his.InsuplcAdmdvs,
  2799. MedinsFillPsn: curRoles.UserName,
  2800. MedinsFillDept: depart.Name,
  2801. IptMedType: "2",
  2802. }
  2803. struct4101.SetlBegnDate = order.SetlTime
  2804. struct4101.SetlEndDate = order.SetlTime
  2805. //if order.SettleType == 1 {
  2806. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2807. // dateStr := t.Format("2006-01-02")
  2808. // struct4101.SetlBegnDate = dateStr
  2809. // struct4101.SetlEndDate = dateStr
  2810. //} else {
  2811. // t := time.Unix(int64(order.SettleStartTime), 0)
  2812. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2813. // dateStartStr := t.Format("2006-01-02")
  2814. // dateEndStr := t2.Format("2006-01-02")
  2815. // struct4101.SetlBegnDate = dateStartStr
  2816. // struct4101.SetlEndDate = dateEndStr
  2817. //}
  2818. var rf []CustomFundPay
  2819. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2820. var tempFunPays []service.CustomStruct
  2821. var tempFunPay610100 service.CustomStruct
  2822. for _, item := range rf {
  2823. if item.FundPayType == "610100" {
  2824. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2825. tempFunPay610100.FundPayType = item.FundPayType
  2826. } else {
  2827. var tempFunPay service.CustomStruct
  2828. tempFunPay.FundPayamt = item.FundPayamt
  2829. tempFunPay.FundPayType = item.FundPayType
  2830. tempFunPays = append(tempFunPays, tempFunPay)
  2831. }
  2832. }
  2833. tempFunPays = append(tempFunPays, tempFunPay610100)
  2834. struct4101.CustomStruct = tempFunPays
  2835. var tempDiaginfos []service.DiaginfoStructTwo
  2836. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2837. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2838. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2839. var config []*models.HisXtDiagnoseConfig
  2840. for _, item := range diagnosis_ids {
  2841. id, _ := strconv.ParseInt(item, 10, 64)
  2842. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2843. config = append(config, &diagnosisConfig)
  2844. }
  2845. for index, item := range config {
  2846. if index == 0 {
  2847. var tempDiaginfo service.DiaginfoStructTwo
  2848. tempDiaginfo.DiagCode = item.CountryCode
  2849. tempDiaginfo.DiagName = item.CountryContentName
  2850. tempDiaginfo.DiagType = "1"
  2851. tempDiaginfo.MaindiagFlag = "1"
  2852. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2853. } else {
  2854. var tempDiaginfo service.DiaginfoStructTwo
  2855. tempDiaginfo.DiagCode = item.CountryCode
  2856. tempDiaginfo.DiagName = item.CountryContentName
  2857. tempDiaginfo.DiagType = "2"
  2858. tempDiaginfo.MaindiagFlag = "0"
  2859. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2860. }
  2861. }
  2862. struct4101.Diseinfo = tempDiaginfos
  2863. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2864. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2865. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2866. tempOpspdiseinfo2.OprnOprtCode = ""
  2867. tempOpspdiseinfo2.OprnOprtName = ""
  2868. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2869. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2870. var iteminfo service.IteminfoStruct
  2871. var bedCostTotal float64 = 0 //床位总费
  2872. var bedCostSelfTotal float64 = 0 //床位自费
  2873. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2874. var examineCostTotal float64 = 0 //诊查总费
  2875. var examineCostSelfTotal float64 = 0 //诊查自费
  2876. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2877. var nursingCostTotal float64 = 0 //护理总费
  2878. var nursingCostSelfTotal float64 = 0 //护理自费
  2879. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2880. var chineseMedicineCostTotal float64 = 0 //中成药
  2881. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2882. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2883. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2884. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2885. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2886. var registerCostTotal float64 = 0 //一般诊疗费
  2887. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2888. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2889. var operationCostTotal float64 = 0 //手术费
  2890. var operationCostSelfTotal float64 = 0 //手术费
  2891. var operationCostPartSelfTotal float64 = 0 //手术费
  2892. var otherCostTotal float64 = 0 //其他费用
  2893. var otherCostSelfTotal float64 = 0 //其他费用
  2894. var otherCostPartSelfTotal float64 = 0 //其他费用
  2895. var materialCostTotal float64 = 0 //材料费
  2896. var materialCostSelfTotal float64 = 0 //材料费
  2897. var materialCostPartSelfTotal float64 = 0 //材料费
  2898. var westernMedicineCostTotal float64 = 0 //西药费
  2899. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2900. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2901. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2902. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2903. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2904. var checkCostTotal float64 = 0 //检查费
  2905. var checkCostSelfTotal float64 = 0 //检查费
  2906. var checkCostPartSelfTotal float64 = 0 //检查费
  2907. var laboratoryCostTotal float64 = 0 //化验费
  2908. var laboratoryCostSelfTotal float64 = 0 //化验费
  2909. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2910. var treatCostTotal float64 = 0 //治疗费用
  2911. var treatCostSelfTotal float64 = 0 //治疗费用
  2912. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2913. decimal.DivisionPrecision = 2
  2914. var bed_fulamt_ownpay_amt float64 = 0
  2915. var examine_fulamt_ownpay_amt float64 = 0
  2916. var nursing_fulamt_ownpay_amt float64 = 0
  2917. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2918. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2919. var register_fulamt_ownpay_amt float64 = 0
  2920. var operation_fulamt_ownpay_amt float64 = 0
  2921. var other_fulamt_ownpay_amt float64 = 0
  2922. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2923. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2924. var check_fulamt_ownpay_amt float64 = 0
  2925. var material_fulamt_ownpay_amt float64 = 0
  2926. var laboratory_fulamt_ownpay_amt float64 = 0
  2927. var treat_fulamt_ownpay_amt float64 = 0
  2928. var bed_claa_sunmfee float64 = 0
  2929. var bed_clab_amt float64 = 0
  2930. var bed_other_amt float64 = 0
  2931. var examine_claa_sunmfee float64 = 0
  2932. var examine_clab_amt float64 = 0
  2933. var examine_other_amt float64 = 0
  2934. var nursing_claa_sunmfee float64 = 0
  2935. var nursing_clab_amt float64 = 0
  2936. var nursing_other_amt float64 = 0
  2937. var chinese_medicine_claa_sunmfee float64 = 0
  2938. var chinese_medicine_clab_amt float64 = 0
  2939. var chinese_medicine_other_amt float64 = 0
  2940. var commonly_treatment_claa_sunmfee float64 = 0
  2941. var commonly_treatment_clab_amt float64 = 0
  2942. var commonly_treatment_other_amt float64 = 0
  2943. var operation_claa_sunmfee float64 = 0
  2944. var operation_clab_amt float64 = 0
  2945. var operation_other_amt float64 = 0
  2946. var other_claa_sunmfee float64 = 0
  2947. var other_clab_amt float64 = 0
  2948. var other_other_amt float64 = 0
  2949. var westernMedicine_claa_sunmfee float64 = 0
  2950. var westernMedicine_clab_amt float64 = 0
  2951. var westernMedicine_other_amt float64 = 0
  2952. var chineseTraditional_claa_sunmfee float64 = 0
  2953. var chineseTraditional_clab_amt float64 = 0
  2954. var chineseTraditional_other_amt float64 = 0
  2955. var check_claa_sunmfee float64 = 0
  2956. var check_clab_amt float64 = 0
  2957. var check_other_amt float64 = 0
  2958. var material_claa_sunmfee float64 = 0
  2959. var material_clab_amt float64 = 0
  2960. var material_other_amt float64 = 0
  2961. var laboratory_claa_sunmfee float64 = 0
  2962. var laboratory_clab_amt float64 = 0
  2963. var laboratory_other_amt float64 = 0
  2964. var treat_claa_sunmfee float64 = 0
  2965. var treat_clab_amt float64 = 0
  2966. var treat_other_amt float64 = 0
  2967. var register_claa_sunmfee float64 = 0
  2968. var register_clab_amt float64 = 0
  2969. var register_other_amt float64 = 0
  2970. for _, item := range order.HisOrderInfo {
  2971. if item.MedChrgitmType == "01" { //床位费
  2972. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2973. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2974. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2975. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2976. if item.ChrgitmLv == "1" {
  2977. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2978. }
  2979. if item.ChrgitmLv == "2" {
  2980. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2981. }
  2982. if item.ChrgitmLv == "3" {
  2983. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2984. }
  2985. }
  2986. if item.MedChrgitmType == "02" { //诊查
  2987. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2988. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2989. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2990. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2991. if item.ChrgitmLv == "1" {
  2992. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2993. }
  2994. if item.ChrgitmLv == "2" {
  2995. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2996. }
  2997. if item.ChrgitmLv == "3" {
  2998. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2999. }
  3000. }
  3001. if item.MedChrgitmType == "03" { //检查费
  3002. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3003. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3004. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3005. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3006. if item.ChrgitmLv == "1" {
  3007. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3008. }
  3009. if item.ChrgitmLv == "2" {
  3010. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3011. }
  3012. if item.ChrgitmLv == "3" {
  3013. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3014. }
  3015. }
  3016. if item.MedChrgitmType == "04" { //化验费
  3017. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3018. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3019. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3020. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3021. if item.ChrgitmLv == "1" {
  3022. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3023. }
  3024. if item.ChrgitmLv == "2" {
  3025. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3026. }
  3027. if item.ChrgitmLv == "3" {
  3028. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3029. }
  3030. }
  3031. if item.MedChrgitmType == "05" { //治疗费
  3032. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3033. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3034. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3035. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3036. if item.ChrgitmLv == "1" {
  3037. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3038. }
  3039. if item.ChrgitmLv == "2" {
  3040. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3041. }
  3042. if item.ChrgitmLv == "3" {
  3043. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3044. }
  3045. }
  3046. if item.MedChrgitmType == "06" { //手术费
  3047. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3048. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3049. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3050. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3051. if item.ChrgitmLv == "1" {
  3052. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3053. }
  3054. if item.ChrgitmLv == "2" {
  3055. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3056. }
  3057. if item.ChrgitmLv == "3" {
  3058. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3059. }
  3060. }
  3061. if item.MedChrgitmType == "07" { //手术费
  3062. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3063. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3064. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3065. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3066. if item.ChrgitmLv == "1" {
  3067. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3068. }
  3069. if item.ChrgitmLv == "2" {
  3070. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3071. }
  3072. if item.ChrgitmLv == "3" {
  3073. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3074. }
  3075. }
  3076. if item.MedChrgitmType == "08" { //材料费
  3077. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3078. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3079. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3080. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3081. if item.ChrgitmLv == "1" {
  3082. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3083. }
  3084. if item.ChrgitmLv == "2" {
  3085. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3086. }
  3087. if item.ChrgitmLv == "3" {
  3088. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3089. }
  3090. }
  3091. if item.MedChrgitmType == "09" { //西药费
  3092. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3093. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3094. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3095. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3096. if item.ChrgitmLv == "1" {
  3097. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3098. }
  3099. if item.ChrgitmLv == "2" {
  3100. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3101. }
  3102. if item.ChrgitmLv == "3" {
  3103. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3104. }
  3105. }
  3106. if item.MedChrgitmType == "10" { //中药饮片
  3107. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3108. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3109. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3110. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3111. if item.ChrgitmLv == "1" {
  3112. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3113. }
  3114. if item.ChrgitmLv == "2" {
  3115. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3116. }
  3117. if item.ChrgitmLv == "3" {
  3118. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3119. }
  3120. }
  3121. if item.MedChrgitmType == "11" { //中成费
  3122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3126. if item.ChrgitmLv == "1" {
  3127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3128. }
  3129. if item.ChrgitmLv == "2" {
  3130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3131. }
  3132. if item.ChrgitmLv == "3" {
  3133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3134. }
  3135. }
  3136. if item.MedChrgitmType == "12" { //中成费
  3137. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3139. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3140. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3141. if item.ChrgitmLv == "1" {
  3142. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3143. }
  3144. if item.ChrgitmLv == "2" {
  3145. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "3" {
  3148. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. }
  3150. }
  3151. if item.MedChrgitmType == "13" { //中成费
  3152. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3154. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3155. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3156. if item.ChrgitmLv == "1" {
  3157. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3158. }
  3159. if item.ChrgitmLv == "2" {
  3160. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "3" {
  3163. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. }
  3165. }
  3166. if item.MedChrgitmType == "14" { //其他费
  3167. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3169. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3170. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3171. if item.ChrgitmLv == "1" {
  3172. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3173. }
  3174. if item.ChrgitmLv == "2" {
  3175. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "3" {
  3178. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3179. }
  3180. }
  3181. }
  3182. var iteminfoStructs []service.IteminfoStruct
  3183. if bedCostTotal != 0 {
  3184. iteminfo.MedChrgitm = "01"
  3185. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3186. iteminfo.Amt = bedCostTotal
  3187. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3188. iteminfo.ClabAmt = bed_clab_amt
  3189. iteminfo.OthAmt = bed_other_amt
  3190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3191. }
  3192. if examineCostTotal != 0 {
  3193. iteminfo.MedChrgitm = "02"
  3194. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3195. iteminfo.Amt = examineCostTotal
  3196. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3197. iteminfo.ClabAmt = examine_clab_amt
  3198. iteminfo.OthAmt = examine_other_amt
  3199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3201. }
  3202. if checkCostTotal != 0 {
  3203. iteminfo.MedChrgitm = "03"
  3204. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3205. iteminfo.Amt = checkCostTotal
  3206. iteminfo.ClaaSumfee = check_claa_sunmfee
  3207. iteminfo.ClabAmt = check_clab_amt
  3208. iteminfo.OthAmt = check_other_amt
  3209. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3210. }
  3211. if laboratoryCostTotal != 0 {
  3212. iteminfo.MedChrgitm = "04"
  3213. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3214. iteminfo.Amt = laboratoryCostTotal
  3215. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3216. iteminfo.ClabAmt = laboratory_clab_amt
  3217. iteminfo.OthAmt = laboratory_other_amt
  3218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3220. }
  3221. if treatCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "05"
  3223. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3224. iteminfo.Amt = treatCostTotal
  3225. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3226. iteminfo.ClabAmt = treat_clab_amt
  3227. iteminfo.OthAmt = treat_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. //(struct4101.IteminfoStruct, iteminfo)
  3230. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3231. }
  3232. if operationCostTotal != 0 {
  3233. iteminfo.MedChrgitm = "06"
  3234. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3235. iteminfo.Amt = operationCostTotal
  3236. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3237. iteminfo.ClabAmt = operation_clab_amt
  3238. iteminfo.OthAmt = operation_other_amt
  3239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3241. }
  3242. if nursingCostTotal != 0 {
  3243. iteminfo.MedChrgitm = "07"
  3244. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3245. iteminfo.Amt = nursingCostTotal
  3246. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3247. iteminfo.ClabAmt = nursing_clab_amt
  3248. iteminfo.OthAmt = nursing_other_amt
  3249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3250. }
  3251. if materialCostTotal != 0 {
  3252. iteminfo.MedChrgitm = "08"
  3253. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3254. iteminfo.Amt = materialCostTotal
  3255. iteminfo.ClaaSumfee = material_claa_sunmfee
  3256. iteminfo.ClabAmt = material_clab_amt
  3257. iteminfo.OthAmt = material_other_amt
  3258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3260. }
  3261. if westernMedicineCostTotal != 0 {
  3262. iteminfo.MedChrgitm = "09"
  3263. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3264. iteminfo.Amt = westernMedicineCostTotal
  3265. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3266. iteminfo.ClabAmt = westernMedicine_clab_amt
  3267. iteminfo.OthAmt = westernMedicine_other_amt
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3270. }
  3271. if chineseMedicineCostTotal != 0 {
  3272. iteminfo.MedChrgitm = "10"
  3273. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3274. iteminfo.Amt = chineseMedicineCostTotal
  3275. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3276. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3277. iteminfo.OthAmt = chinese_medicine_other_amt
  3278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3279. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3280. }
  3281. if chineseTraditionalMedicineCostTotal != 0 {
  3282. iteminfo.MedChrgitm = "11"
  3283. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3284. iteminfo.Amt = westernMedicineCostTotal
  3285. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3286. iteminfo.ClabAmt = westernMedicine_clab_amt
  3287. iteminfo.OthAmt = westernMedicine_other_amt
  3288. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3290. }
  3291. if commonlyTreatmentCostTotal != 0 {
  3292. iteminfo.MedChrgitm = "12"
  3293. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3294. iteminfo.Amt = commonlyTreatmentCostTotal
  3295. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3296. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3297. iteminfo.OthAmt = commonly_treatment_other_amt
  3298. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3300. }
  3301. if registerCostTotal != 0 {
  3302. iteminfo.MedChrgitm = "13"
  3303. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3304. iteminfo.Amt = registerCostTotal
  3305. iteminfo.ClaaSumfee = register_claa_sunmfee
  3306. iteminfo.ClabAmt = register_clab_amt
  3307. iteminfo.OthAmt = register_other_amt
  3308. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3309. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3310. }
  3311. if otherCostTotal != 0 {
  3312. iteminfo.MedChrgitm = "14"
  3313. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3314. iteminfo.Amt = otherCostTotal
  3315. iteminfo.ClaaSumfee = other_claa_sunmfee
  3316. iteminfo.ClabAmt = other_clab_amt
  3317. iteminfo.OthAmt = other_other_amt
  3318. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3319. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3320. }
  3321. struct4101.IteminfoStruct = iteminfoStructs
  3322. struct4101.Ntly = "中国"
  3323. struct4101.AdmCaty = "A03.06"
  3324. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3325. fmt.Println(result)
  3326. var dat map[string]interface{}
  3327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3328. fmt.Println(dat)
  3329. } else {
  3330. fmt.Println(err)
  3331. }
  3332. userJSONBytes, _ := json.Marshal(dat)
  3333. var res ResultSeventeen
  3334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3335. utils.ErrorLog("解析失败:%v", err)
  3336. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3337. adminUser := c.GetAdminUserInfo()
  3338. errlog := &models.HisOrderError{
  3339. UserOrgId: adminUser.CurrentOrgId,
  3340. Ctime: time.Now().Unix(),
  3341. Mtime: time.Now().Unix(),
  3342. ErrMsg: res.ErrMsg + "解析失败",
  3343. Status: 1,
  3344. PatientId: order_id,
  3345. Stage: 10106,
  3346. }
  3347. service.CreateErrMsgLog(errlog)
  3348. continue
  3349. }
  3350. if res.Infcode != 0 {
  3351. adminUser := c.GetAdminUserInfo()
  3352. errlog := &models.HisOrderError{
  3353. UserOrgId: adminUser.CurrentOrgId,
  3354. Ctime: time.Now().Unix(),
  3355. Mtime: time.Now().Unix(),
  3356. ErrMsg: res.ErrMsg,
  3357. Status: 1,
  3358. PatientId: order_id,
  3359. Stage: 10106,
  3360. }
  3361. service.CreateErrMsgLog(errlog)
  3362. continue
  3363. } else {
  3364. hisFundSettleListResult := &models.HisFundSettleListResult{
  3365. Number: res.Output.SetlListId,
  3366. Status: 1,
  3367. Ctime: time.Now().Unix(),
  3368. Mtime: time.Now().Unix(),
  3369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3370. IsUpload: 1,
  3371. OrderId: order_id,
  3372. }
  3373. service.CreateUploadRecord(hisFundSettleListResult)
  3374. continue
  3375. }
  3376. }
  3377. }
  3378. func (c *HisApiController) GetOrgInfo() {
  3379. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3380. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3381. }
  3382. func (c *HisApiController) GetHisPatientInfo() {
  3383. medical_insurance_card := c.GetString("medical_insurance_card")
  3384. id_card_type, _ := c.GetInt64("id_card_type")
  3385. id_card := c.GetString("id_card")
  3386. adminInfo := c.GetAdminUserInfo()
  3387. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3388. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3389. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3390. IdCardNo := ""
  3391. if id_card_type == 1 {
  3392. IdCardNo = medical_insurance_card
  3393. } else if id_card_type == 2 {
  3394. IdCardNo = id_card
  3395. }
  3396. if config.IsOpen == 1 {
  3397. 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
  3398. resp, requestErr := http.Get(api)
  3399. if requestErr != nil {
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. defer resp.Body.Close()
  3404. body, ioErr := ioutil.ReadAll(resp.Body)
  3405. if ioErr != nil {
  3406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. var respJSON map[string]interface{}
  3411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3414. return
  3415. }
  3416. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3417. userJSONBytes, _ := json.Marshal(userJSON)
  3418. var res ResultTwo
  3419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3426. infoStr := string(Iinfos)
  3427. idetinfoStr := string(Idetinfos)
  3428. if res.Infcode == 0 {
  3429. his := models.VMHisPatient{
  3430. Status: 1,
  3431. Ctime: time.Now().Unix(),
  3432. Mtime: time.Now().Unix(),
  3433. PsnNo: res.Output.Baseinfo.PsnNo,
  3434. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3435. Certno: res.Output.Baseinfo.Certno,
  3436. PsnName: res.Output.Baseinfo.PsnName,
  3437. Gend: res.Output.Baseinfo.Gend,
  3438. Naty: res.Output.Baseinfo.Naty,
  3439. Brdy: res.Output.Baseinfo.Brdy,
  3440. Age: res.Output.Baseinfo.Age,
  3441. Iinfo: infoStr,
  3442. Idetinfo: idetinfoStr,
  3443. UserOrgId: adminInfo.CurrentOrgId,
  3444. IsReturn: 1,
  3445. IdCardType: id_card_type,
  3446. }
  3447. c.ServeSuccessJSON(map[string]interface{}{
  3448. "info": his,
  3449. })
  3450. } else {
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3452. return
  3453. }
  3454. }
  3455. }
  3456. //func GetBasBaseInfo() (jsonStr string, err error) {
  3457. //
  3458. // handle := syscall.NewLazyDLL("SSCard.dll")
  3459. // add := handle.NewProc("ReadCardBas")
  3460. // str := make([]byte, 1024)
  3461. // str1 := make([]byte, 1024)
  3462. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3463. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3464. //
  3465. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3466. //
  3467. // fmt.Println("> Add(4,5)的结果为:", ret)
  3468. // handle.Release()
  3469. //
  3470. // return "", nil
  3471. //
  3472. //}
  3473. //func GetQRBaseInfo() (jsonStr string, err error) {
  3474. // handle := syscall.LoadDLL("SSCard.dll")
  3475. // ReadCardBas := handle.FindProc("GetQRBase")
  3476. //
  3477. // str := make([]byte, 256)
  3478. // str1 := make([]byte, 256)
  3479. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3480. //
  3481. // fmt.Println(string(str))
  3482. // fmt.Println(r)
  3483. // return string(str), nil
  3484. //}
  3485. //func CardInit() int {
  3486. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3487. // add := DllTestDef.MustFindProc("Init")
  3488. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3489. // if err != nil {
  3490. // fmt.Println("SSCard的运算结果为:", ret)
  3491. // }
  3492. // result := int(ret)
  3493. // return result
  3494. //}
  3495. //func CardInit() int {
  3496. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3497. // if err != nil {
  3498. // fmt.Println("SSCard的运算结果为:", ret)
  3499. // }
  3500. // fmt.Println(err)
  3501. // result := int(ret)
  3502. // return result
  3503. //}
  3504. func IntPtr(n int) uintptr {
  3505. return uintptr(n)
  3506. }
  3507. func StrPtr(s string) uintptr {
  3508. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3509. }
  3510. type Result2001 struct {
  3511. Cainfo interface{} `json:"cainfo"`
  3512. ErrMsg string `json:"err_msg"`
  3513. InfRefmsgid string `json:"inf_refmsgid"`
  3514. Infcode int64 `json:"infcode"`
  3515. Output struct {
  3516. Trtinfo struct {
  3517. PsnNo string `json:"psn_no"`
  3518. TrtChkType string `json:"trt_chk_type"`
  3519. FundPayType string `json:"fund_pay_type"`
  3520. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3521. Begndate string `json:"begndate"`
  3522. Enddate string `json:"enddate"`
  3523. TrtChkRslt string `json:"trt_chk_rslt"`
  3524. } `json:"trtinfo"`
  3525. } `json:"output"`
  3526. RefmsgTime string `json:"refmsg_time"`
  3527. RespondTime string `json:"respond_time"`
  3528. Signtype interface{} `json:"signtype"`
  3529. WarnMsg interface{} `json:"warn_msg"`
  3530. }
  3531. type Result2001Org10265 struct {
  3532. Cainfo interface{} `json:"cainfo"`
  3533. ErrMsg string `json:"err_msg"`
  3534. InfRefmsgid string `json:"inf_refmsgid"`
  3535. Infcode string `json:"infcode"`
  3536. Output struct {
  3537. Trtinfo struct {
  3538. PsnNo string `json:"psn_no"`
  3539. TrtChkType string `json:"trt_chk_type"`
  3540. FundPayType string `json:"fund_pay_type"`
  3541. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3542. Begndate string `json:"begndate"`
  3543. Enddate string `json:"enddate"`
  3544. TrtChkRslt string `json:"trt_chk_rslt"`
  3545. } `json:"trtinfo"`
  3546. } `json:"output"`
  3547. RefmsgTime string `json:"refmsg_time"`
  3548. RespondTime string `json:"respond_time"`
  3549. Signtype interface{} `json:"signtype"`
  3550. WarnMsg interface{} `json:"warn_msg"`
  3551. }
  3552. type ResultTwo struct {
  3553. ErrMsg string `json:"err_msg"`
  3554. InfRefmsgid string `json:"inf_refmsgid"`
  3555. Infcode int64 `json:"infcode"`
  3556. Output struct {
  3557. Baseinfo struct {
  3558. Age float64 `json:"age"`
  3559. Brdy string `json:"brdy"`
  3560. Certno string `json:"certno"`
  3561. Gend string `json:"gend"`
  3562. Naty string `json:"naty"`
  3563. PsnCertType string `json:"psn_cert_type"`
  3564. PsnName string `json:"psn_name"`
  3565. PsnNo string `json:"psn_no"`
  3566. } `json:"baseinfo"`
  3567. Idetinfo []interface{} `json:"idetinfo"`
  3568. Iinfo []struct {
  3569. Balc float64 `json:"balc"`
  3570. CvlservFlag string `json:"cvlserv_flag"`
  3571. EmpName string `json:"emp_name"`
  3572. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3573. Insutype string `json:"insutype"`
  3574. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3575. PausInsuDate string `json:"paus_insu_date"`
  3576. PsnInsuDate string `json:"psn_insu_date"`
  3577. PsnInsuStas string `json:"psn_insu_stas"`
  3578. PsnType string `json:"psn_type"`
  3579. } `json:"insuinfo"`
  3580. } `json:"output"`
  3581. RefmsgTime string `json:"refmsg_time"`
  3582. RespondTime string `json:"respond_time"`
  3583. Signtype interface{} `json:"signtype"`
  3584. WarnInfo interface{} `json:"warn_info"`
  3585. }
  3586. type ResultTwo10265 struct {
  3587. ErrMsg string `json:"err_msg"`
  3588. InfRefmsgid string `json:"inf_refmsgid"`
  3589. Infcode string `json:"infcode"`
  3590. Output struct {
  3591. Baseinfo struct {
  3592. Age float64 `json:"age"`
  3593. Brdy string `json:"brdy"`
  3594. Certno string `json:"certno"`
  3595. Gend string `json:"gend"`
  3596. Naty string `json:"naty"`
  3597. PsnCertType string `json:"psn_cert_type"`
  3598. PsnName string `json:"psn_name"`
  3599. PsnNo string `json:"psn_no"`
  3600. } `json:"baseinfo"`
  3601. Idetinfo []interface{} `json:"idetinfo"`
  3602. Iinfo []struct {
  3603. Balc float64 `json:"balc"`
  3604. CvlservFlag string `json:"cvlserv_flag"`
  3605. EmpName string `json:"emp_name"`
  3606. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3607. Insutype string `json:"insutype"`
  3608. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3609. PausInsuDate string `json:"paus_insu_date"`
  3610. PsnInsuDate string `json:"psn_insu_date"`
  3611. PsnInsuStas string `json:"psn_insu_stas"`
  3612. PsnType string `json:"psn_type"`
  3613. } `json:"insuinfo"`
  3614. } `json:"output"`
  3615. RefmsgTime string `json:"refmsg_time"`
  3616. RespondTime string `json:"respond_time"`
  3617. Signtype interface{} `json:"signtype"`
  3618. WarnInfo interface{} `json:"warn_info"`
  3619. }
  3620. type ResultThree struct {
  3621. Cainfo interface{} `json:"cainfo"`
  3622. ErrMsg string `json:"err_msg"`
  3623. InfRefmsgid string `json:"inf_refmsgid"`
  3624. Infcode int64 `json:"infcode"`
  3625. Output struct {
  3626. Data struct {
  3627. IptOtpNo string `json:"ipt_otp_no"`
  3628. MdtrtID string `json:"mdtrt_id"`
  3629. PsnNo string `json:"psn_no"`
  3630. } `json:"data"`
  3631. } `json:"output"`
  3632. RefmsgTime string `json:"refmsg_time"`
  3633. RespondTime string `json:"respond_time"`
  3634. Signtype interface{} `json:"signtype"`
  3635. WarnMsg interface{} `json:"warn_msg"`
  3636. }
  3637. type ResultThree10265 struct {
  3638. Cainfo interface{} `json:"cainfo"`
  3639. ErrMsg string `json:"err_msg"`
  3640. InfRefmsgid string `json:"inf_refmsgid"`
  3641. Infcode string `json:"infcode"`
  3642. Output struct {
  3643. Data struct {
  3644. IptOtpNo string `json:"ipt_otp_no"`
  3645. MdtrtID string `json:"mdtrt_id"`
  3646. PsnNo string `json:"psn_no"`
  3647. } `json:"data"`
  3648. } `json:"output"`
  3649. RefmsgTime string `json:"refmsg_time"`
  3650. RespondTime string `json:"respond_time"`
  3651. Signtype interface{} `json:"signtype"`
  3652. WarnMsg interface{} `json:"warn_msg"`
  3653. }
  3654. type ResultFour struct {
  3655. Cainfo string `json:"cainfo"`
  3656. ErrMsg string `json:"err_msg"`
  3657. InfRefmsgid string `json:"inf_refmsgid"`
  3658. Infcode int64 `json:"infcode"`
  3659. Output struct {
  3660. Result []struct {
  3661. BasMednFlag string `json:"bas_medn_flag"`
  3662. ChldMedcFlag string `json:"chld_medc_flag"`
  3663. ChrgitmLv string `json:"chrgitm_lv"`
  3664. Cnt float64 `json:"cnt"`
  3665. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3666. DrtReimFlag string `json:"drt_reim_flag"`
  3667. FeedetlSn string `json:"feedetl_sn"`
  3668. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3669. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3670. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3671. ListSpItemFlag string `json:"list_sp_item_flag"`
  3672. LmtUsedFlag string `json:"lmt_used_flag"`
  3673. MedChrgitmType string `json:"med_chrgitm_type"`
  3674. Memo string `json:"memo"`
  3675. OverlmtAmt float64 `json:"overlmt_amt"`
  3676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3677. Pric float64 `json:"pric"`
  3678. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3679. SelfpayProp float64 `json:"selfpay_prop"`
  3680. } `json:"result"`
  3681. } `json:"output"`
  3682. RefmsgTime string `json:"refmsg_time"`
  3683. RespondTime string `json:"respond_time"`
  3684. Signtype string `json:"signtype"`
  3685. WarnMsg string `json:"warn_msg"`
  3686. }
  3687. type ResultFour10265 struct {
  3688. Cainfo string `json:"cainfo"`
  3689. ErrMsg string `json:"err_msg"`
  3690. InfRefmsgid string `json:"inf_refmsgid"`
  3691. Infcode string `json:"infcode"`
  3692. Output struct {
  3693. Result []struct {
  3694. BasMednFlag string `json:"bas_medn_flag"`
  3695. ChldMedcFlag string `json:"chld_medc_flag"`
  3696. ChrgitmLv string `json:"chrgitm_lv"`
  3697. Cnt float64 `json:"cnt"`
  3698. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3699. DrtReimFlag string `json:"drt_reim_flag"`
  3700. FeedetlSn string `json:"feedetl_sn"`
  3701. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3702. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3703. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3704. ListSpItemFlag string `json:"list_sp_item_flag"`
  3705. LmtUsedFlag string `json:"lmt_used_flag"`
  3706. MedChrgitmType string `json:"med_chrgitm_type"`
  3707. Memo string `json:"memo"`
  3708. OverlmtAmt float64 `json:"overlmt_amt"`
  3709. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3710. Pric float64 `json:"pric"`
  3711. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3712. SelfpayProp float64 `json:"selfpay_prop"`
  3713. } `json:"result"`
  3714. } `json:"output"`
  3715. RefmsgTime string `json:"refmsg_time"`
  3716. RespondTime string `json:"respond_time"`
  3717. Signtype string `json:"signtype"`
  3718. WarnMsg string `json:"warn_msg"`
  3719. }
  3720. type ResultFive struct {
  3721. Balc float64 `json:"balc"`
  3722. CvlservFlag string `json:"cvlserv_flag"`
  3723. EmpName string `json:"emp_name"`
  3724. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3725. Insutype string `json:"insutype"`
  3726. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3727. PausInsuDate string `json:"paus_insu_date"`
  3728. PsnInsuDate string `json:"psn_insu_date"`
  3729. PsnInsuStas string `json:"psn_insu_stas"`
  3730. PsnType string `json:"psn_type"`
  3731. }
  3732. type ResultSix struct {
  3733. Cainfo interface{} `json:"cainfo"`
  3734. ErrMsg string `json:"err_msg"`
  3735. InfRefmsgid string `json:"inf_refmsgid"`
  3736. Infcode int64 `json:"infcode"`
  3737. Output struct {
  3738. } `json:"output"`
  3739. RefmsgTime string `json:"refmsg_time"`
  3740. RespondTime string `json:"respond_time"`
  3741. Signtype interface{} `json:"signtype"`
  3742. WarnMsg interface{} `json:"warn_msg"`
  3743. }
  3744. type ResultSix10265 struct {
  3745. Cainfo interface{} `json:"cainfo"`
  3746. ErrMsg string `json:"err_msg"`
  3747. InfRefmsgid string `json:"inf_refmsgid"`
  3748. Infcode string `json:"infcode"`
  3749. Output struct {
  3750. } `json:"output"`
  3751. RefmsgTime string `json:"refmsg_time"`
  3752. RespondTime string `json:"respond_time"`
  3753. Signtype interface{} `json:"signtype"`
  3754. WarnMsg interface{} `json:"warn_msg"`
  3755. }
  3756. type ResultSeven struct {
  3757. Cainfo string `json:"cainfo"`
  3758. ErrMsg string `json:"err_msg"`
  3759. InfRefmsgid string `json:"inf_refmsgid"`
  3760. Infcode int64 `json:"infcode"`
  3761. Output struct {
  3762. Setldetail []interface{} `json:"setldetail"`
  3763. Setlinfo struct {
  3764. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3765. AcctPay float64 `json:"acct_pay"`
  3766. ActPayDedc float64 `json:"act_pay_dedc"`
  3767. Age float64 `json:"age"`
  3768. Balc float64 `json:"balc"`
  3769. Brdy string `json:"brdy"`
  3770. Certno string `json:"certno"`
  3771. ClrOptins string `json:"clr_optins"`
  3772. ClrType string `json:"clr_type"`
  3773. ClrWay string `json:"clr_way"`
  3774. CvlservFlag string `json:"cvlserv_flag"`
  3775. CvlservPay float64 `json:"cvlserv_pay"`
  3776. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3777. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3778. Gend string `json:"gend"`
  3779. HifesPay float64 `json:"hifes_pay"`
  3780. HifmiPay float64 `json:"hifmi_pay"`
  3781. HifpPay float64 `json:"hifp_pay"`
  3782. HospPartAmt float64 `json:"hosp_part_amt"`
  3783. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3784. Insutype string `json:"insutype"`
  3785. MafPay float64 `json:"maf_pay"`
  3786. MdtrtCertType string `json:"mdtrt_cert_type"`
  3787. HifobPay float64 `json:"hifob_pay"`
  3788. MdtrtID string `json:"mdtrt_id"`
  3789. MedType string `json:"med_type"`
  3790. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3791. MedinsSetlID string `json:"medins_setl_id"`
  3792. Naty string `json:"naty"`
  3793. OthPay float64 `json:"oth_pay"`
  3794. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3795. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3796. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3797. PsnCashPay float64 `json:"psn_cash_pay"`
  3798. PsnCertType string `json:"psn_cert_type"`
  3799. PsnName string `json:"psn_name"`
  3800. PsnNo string `json:"psn_no"`
  3801. PsnPartAmt float64 `json:"psn_part_amt"`
  3802. PsnType string `json:"psn_type"`
  3803. SetlID string `json:"setl_id"`
  3804. SetlTime string `json:"setl_time"`
  3805. } `json:"setlinfo"`
  3806. } `json:"output"`
  3807. RefmsgTime string `json:"refmsg_time"`
  3808. RespondTime string `json:"respond_time"`
  3809. Signtype interface{} `json:"signtype"`
  3810. WarnMsg interface{} `json:"warn_msg"`
  3811. }
  3812. type ResultSeven10265 struct {
  3813. Cainfo string `json:"cainfo"`
  3814. ErrMsg string `json:"err_msg"`
  3815. InfRefmsgid string `json:"inf_refmsgid"`
  3816. Infcode string `json:"infcode"`
  3817. Output struct {
  3818. Setldetail []interface{} `json:"setldetail"`
  3819. Setlinfo struct {
  3820. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3821. AcctPay float64 `json:"acct_pay"`
  3822. ActPayDedc float64 `json:"act_pay_dedc"`
  3823. Age float64 `json:"age"`
  3824. Balc float64 `json:"balc"`
  3825. Brdy string `json:"brdy"`
  3826. Certno string `json:"certno"`
  3827. ClrOptins string `json:"clr_optins"`
  3828. ClrType string `json:"clr_type"`
  3829. ClrWay string `json:"clr_way"`
  3830. CvlservFlag string `json:"cvlserv_flag"`
  3831. CvlservPay float64 `json:"cvlserv_pay"`
  3832. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3833. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3834. Gend string `json:"gend"`
  3835. HifesPay float64 `json:"hifes_pay"`
  3836. HifmiPay float64 `json:"hifmi_pay"`
  3837. HifpPay float64 `json:"hifp_pay"`
  3838. HospPartAmt float64 `json:"hosp_part_amt"`
  3839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3840. Insutype string `json:"insutype"`
  3841. MafPay float64 `json:"maf_pay"`
  3842. MdtrtCertType string `json:"mdtrt_cert_type"`
  3843. HifobPay float64 `json:"hifob_pay"`
  3844. MdtrtID string `json:"mdtrt_id"`
  3845. MedType string `json:"med_type"`
  3846. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3847. MedinsSetlID string `json:"medins_setl_id"`
  3848. Naty string `json:"naty"`
  3849. OthPay float64 `json:"oth_pay"`
  3850. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3851. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3852. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3853. PsnCashPay float64 `json:"psn_cash_pay"`
  3854. PsnCertType string `json:"psn_cert_type"`
  3855. PsnName string `json:"psn_name"`
  3856. PsnNo string `json:"psn_no"`
  3857. PsnPartAmt float64 `json:"psn_part_amt"`
  3858. PsnType string `json:"psn_type"`
  3859. SetlID string `json:"setl_id"`
  3860. SetlTime string `json:"setl_time"`
  3861. } `json:"setlinfo"`
  3862. } `json:"output"`
  3863. RefmsgTime string `json:"refmsg_time"`
  3864. RespondTime string `json:"respond_time"`
  3865. Signtype interface{} `json:"signtype"`
  3866. WarnMsg interface{} `json:"warn_msg"`
  3867. }
  3868. type ResultEight struct {
  3869. Cainfo string `json:"cainfo"`
  3870. ErrMsg string `json:"err_msg"`
  3871. InfRefmsgid string `json:"inf_refmsgid"`
  3872. Infcode int64 `json:"infcode"`
  3873. Output struct {
  3874. Stmtinfo struct {
  3875. SetlOptins string `json:"setl_optins"`
  3876. StmtRslt string `json:"stmt_rslt"`
  3877. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3878. } `json:"stmtinfo"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype interface{} `json:"signtype"`
  3883. WarnMsg interface{} `json:"warn_msg"`
  3884. }
  3885. type ResultEightFor10188 struct {
  3886. Cainfo string `json:"cainfo"`
  3887. ErrMsg string `json:"err_msg"`
  3888. InfRefmsgid string `json:"inf_refmsgid"`
  3889. Infcode string `json:"infcode"`
  3890. Output struct {
  3891. Stmtinfo struct {
  3892. SetlOptins string `json:"setl_optins"`
  3893. StmtRslt string `json:"stmt_rslt"`
  3894. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3895. } `json:"stmtinfo"`
  3896. } `json:"output"`
  3897. RefmsgTime string `json:"refmsg_time"`
  3898. RespondTime string `json:"respond_time"`
  3899. Signtype interface{} `json:"signtype"`
  3900. WarnMsg interface{} `json:"warn_msg"`
  3901. }
  3902. type ResultNine struct {
  3903. Cainfo string `json:"cainfo"`
  3904. ErrMsg string `json:"err_msg"`
  3905. InfRefmsgid string `json:"inf_refmsgid"`
  3906. Infcode int64 `json:"infcode"`
  3907. Output struct {
  3908. FileQuryNo string `json:"file_qury_no"`
  3909. } `json:"output"`
  3910. RefmsgTime string `json:"refmsg_time"`
  3911. RespondTime string `json:"respond_time"`
  3912. Signtype interface{} `json:"signtype"`
  3913. WarnMsg interface{} `json:"warn_msg"`
  3914. }
  3915. type ResultTen struct {
  3916. Cainfo string `json:"cainfo"`
  3917. ErrMsg string `json:"err_msg"`
  3918. InfRefmsgid string `json:"inf_refmsgid"`
  3919. Infcode int64 `json:"infcode"`
  3920. Output struct {
  3921. DldEndtime string `json:"dld_endtime"`
  3922. FileQuryNo string `json:"file_qury_no"`
  3923. Filename string `json:"filename"`
  3924. } `json:"output"`
  3925. RefmsgTime string `json:"refmsg_time"`
  3926. RespondTime string `json:"respond_time"`
  3927. Signtype interface{} `json:"signtype"`
  3928. WarnMsg interface{} `json:"warn_msg"`
  3929. }
  3930. //type Autogenerated struct {
  3931. // Output struct {
  3932. // Setlinfo struct {
  3933. // SetlTime string `json:"setl_time"`
  3934. // CvlservPay float64 `json:"cvlserv_pay"`
  3935. // Year string `json:"year"`
  3936. // MedType string `json:"med_type"`
  3937. // PsnPay float64 `json:"psn_pay"`
  3938. // OpterID string `json:"opter_id"`
  3939. // Begndate string `json:"begndate"`
  3940. // FlxempeFlag string `json:"flxempe_flag"`
  3941. // HifmiPay float64 `json:"hifmi_pay"`
  3942. // PsnNo string `json:"psn_no"`
  3943. // ActPayDedc float64 `json:"act_pay_dedc"`
  3944. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3945. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3946. // ClrWay string `json:"clr_way"`
  3947. // OthPay float64 `json:"oth_pay"`
  3948. // Gend string `json:"gend"`
  3949. // MdtrtID string `json:"mdtrt_id"`
  3950. // AcctPay float64 `json:"acct_pay"`
  3951. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3952. // Insutype string `json:"insutype"`
  3953. // Invono interface{} `json:"invono"`
  3954. // Enddate string `json:"enddate"`
  3955. // CashPayamt float64 `json:"cash_payamt"`
  3956. // PsnType string `json:"psn_type"`
  3957. // FixmedinsName string `json:"fixmedins_name"`
  3958. // HifpPay float64 `json:"hifp_pay"`
  3959. // NewFlag interface{} `json:"new_flag"`
  3960. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3961. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. // PayLoc string `json:"pay_loc"`
  3963. // ClrType string `json:"clr_type"`
  3964. // RefdSetlFlag string `json:"refd_setl_flag"`
  3965. // CvlservFlag string `json:"cvlserv_flag"`
  3966. // EmpName string `json:"emp_name"`
  3967. // Brdy string `json:"brdy"`
  3968. // Naty string `json:"naty"`
  3969. // Certno string `json:"certno"`
  3970. // DiseCode string `json:"dise_code"`
  3971. // FixmedinsCode string `json:"fixmedins_code"`
  3972. // DedcHospLv string `json:"dedc_hosp_lv"`
  3973. // OpterName string `json:"opter_name"`
  3974. // Balc float64 `json:"balc"`
  3975. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3976. // PsnCertType string `json:"psn_cert_type"`
  3977. // HifobPay float64 `json:"hifob_pay"`
  3978. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3979. // HifesPay float64 `json:"hifes_pay"`
  3980. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3981. // OptTime string `json:"opt_time"`
  3982. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3983. // SetlID string `json:"setl_id"`
  3984. // MafPay float64 `json:"maf_pay"`
  3985. // PsnName string `json:"psn_name"`
  3986. // InsuOptins interface{} `json:"insu_optins"`
  3987. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3988. // ClrOptins string `json:"clr_optins"`
  3989. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3990. // DiseName string `json:"dise_name"`
  3991. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3992. // Age float64 `json:"age"`
  3993. // DtrtCertType string `json:"dtrt_cert_type"`
  3994. // HospLv string `json:"hosp_lv"`
  3995. // } `json:"setlinfo"`
  3996. // Setldetail []struct {
  3997. // FundPayType string `json:"fund_pay_type"`
  3998. // FundPayamt float64 `json:"fund_payamt"`
  3999. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4000. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4001. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4002. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4003. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4004. // } `json:"setldetail"`
  4005. // } `json:"output"`
  4006. // Infcode int `json:"infcode"`
  4007. // WarnMsg interface{} `json:"warn_msg"`
  4008. // Cainfo interface{} `json:"cainfo"`
  4009. // ErrMsg interface{} `json:"err_msg"`
  4010. // RefmsgTime string `json:"refmsg_time"`
  4011. // Signtype interface{} `json:"signtype"`
  4012. // RespondTime string `json:"respond_time"`
  4013. // InfRefmsgid string `json:"inf_refmsgid"`
  4014. //}
  4015. type ResultEleven struct {
  4016. Cainfo string `json:"cainfo"`
  4017. ErrMsg string `json:"err_msg"`
  4018. InfRefmsgid string `json:"inf_refmsgid"`
  4019. Infcode int64 `json:"infcode"`
  4020. Output struct {
  4021. Setlinfo struct {
  4022. SetlTime string `json:"setl_time"`
  4023. CvlservPay float64 `json:"cvlserv_pay"`
  4024. Year string `json:"year"`
  4025. MedType string `json:"med_type"`
  4026. PsnPay float64 `json:"psn_pay"`
  4027. OpterID string `json:"opter_id"`
  4028. Begndate string `json:"begndate"`
  4029. FlxempeFlag string `json:"flxempe_flag"`
  4030. HifmiPay float64 `json:"hifmi_pay"`
  4031. PsnNo string `json:"psn_no"`
  4032. ActPayDedc float64 `json:"act_pay_dedc"`
  4033. MedinsSetlID interface{} `json:"medins_setl_id"`
  4034. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4035. ClrWay string `json:"clr_way"`
  4036. OthPay float64 `json:"oth_pay"`
  4037. Gend string `json:"gend"`
  4038. MdtrtID string `json:"mdtrt_id"`
  4039. AcctPay float64 `json:"acct_pay"`
  4040. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4041. Insutype string `json:"insutype"`
  4042. Invono interface{} `json:"invono"`
  4043. Enddate string `json:"enddate"`
  4044. CashPayamt float64 `json:"cash_payamt"`
  4045. PsnType string `json:"psn_type"`
  4046. FixmedinsName string `json:"fixmedins_name"`
  4047. HifpPay float64 `json:"hifp_pay"`
  4048. NewFlag interface{} `json:"new_flag"`
  4049. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4051. PayLoc string `json:"pay_loc"`
  4052. ClrType string `json:"clr_type"`
  4053. RefdSetlFlag string `json:"refd_setl_flag"`
  4054. CvlservFlag string `json:"cvlserv_flag"`
  4055. EmpName string `json:"emp_name"`
  4056. Brdy string `json:"brdy"`
  4057. Naty string `json:"naty"`
  4058. Certno string `json:"certno"`
  4059. DiseCode string `json:"dise_code"`
  4060. FixmedinsCode string `json:"fixmedins_code"`
  4061. DedcHospLv string `json:"dedc_hosp_lv"`
  4062. OpterName string `json:"opter_name"`
  4063. Balc float64 `json:"balc"`
  4064. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4065. PsnCertType string `json:"psn_cert_type"`
  4066. HifobPay float64 `json:"hifob_pay"`
  4067. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4068. HifesPay float64 `json:"hifes_pay"`
  4069. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4070. OptTime string `json:"opt_time"`
  4071. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4072. SetlID string `json:"setl_id"`
  4073. MafPay float64 `json:"maf_pay"`
  4074. PsnName string `json:"psn_name"`
  4075. InsuOptins interface{} `json:"insu_optins"`
  4076. PrefFundPay interface{} `json:"pref_fund_pay"`
  4077. ClrOptins string `json:"clr_optins"`
  4078. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4079. DiseName string `json:"dise_name"`
  4080. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4081. Age float64 `json:"age"`
  4082. DtrtCertType string `json:"dtrt_cert_type"`
  4083. HospLv string `json:"hosp_lv"`
  4084. } `json:"setlinfo"`
  4085. } `json:"output"`
  4086. RefmsgTime string `json:"refmsg_time"`
  4087. RespondTime string `json:"respond_time"`
  4088. Signtype interface{} `json:"signtype"`
  4089. WarnMsg interface{} `json:"warn_msg"`
  4090. }
  4091. type ResultEleven10265 struct {
  4092. Cainfo string `json:"cainfo"`
  4093. ErrMsg string `json:"err_msg"`
  4094. InfRefmsgid string `json:"inf_refmsgid"`
  4095. Infcode string `json:"infcode"`
  4096. Output struct {
  4097. Setlinfo struct {
  4098. SetlTime string `json:"setl_time"`
  4099. CvlservPay float64 `json:"cvlserv_pay"`
  4100. Year string `json:"year"`
  4101. MedType string `json:"med_type"`
  4102. PsnPay float64 `json:"psn_pay"`
  4103. OpterID string `json:"opter_id"`
  4104. Begndate string `json:"begndate"`
  4105. FlxempeFlag string `json:"flxempe_flag"`
  4106. HifmiPay float64 `json:"hifmi_pay"`
  4107. PsnNo string `json:"psn_no"`
  4108. ActPayDedc float64 `json:"act_pay_dedc"`
  4109. MedinsSetlID interface{} `json:"medins_setl_id"`
  4110. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4111. ClrWay string `json:"clr_way"`
  4112. OthPay float64 `json:"oth_pay"`
  4113. Gend string `json:"gend"`
  4114. MdtrtID string `json:"mdtrt_id"`
  4115. AcctPay float64 `json:"acct_pay"`
  4116. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4117. Insutype string `json:"insutype"`
  4118. Invono interface{} `json:"invono"`
  4119. Enddate string `json:"enddate"`
  4120. CashPayamt float64 `json:"cash_payamt"`
  4121. PsnType string `json:"psn_type"`
  4122. FixmedinsName string `json:"fixmedins_name"`
  4123. HifpPay float64 `json:"hifp_pay"`
  4124. NewFlag interface{} `json:"new_flag"`
  4125. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4126. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4127. PayLoc string `json:"pay_loc"`
  4128. ClrType string `json:"clr_type"`
  4129. RefdSetlFlag string `json:"refd_setl_flag"`
  4130. CvlservFlag string `json:"cvlserv_flag"`
  4131. EmpName string `json:"emp_name"`
  4132. Brdy string `json:"brdy"`
  4133. Naty string `json:"naty"`
  4134. Certno string `json:"certno"`
  4135. DiseCode string `json:"dise_code"`
  4136. FixmedinsCode string `json:"fixmedins_code"`
  4137. DedcHospLv string `json:"dedc_hosp_lv"`
  4138. OpterName string `json:"opter_name"`
  4139. Balc float64 `json:"balc"`
  4140. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4141. PsnCertType string `json:"psn_cert_type"`
  4142. HifobPay float64 `json:"hifob_pay"`
  4143. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4144. HifesPay float64 `json:"hifes_pay"`
  4145. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4146. OptTime string `json:"opt_time"`
  4147. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4148. SetlID string `json:"setl_id"`
  4149. MafPay float64 `json:"maf_pay"`
  4150. PsnName string `json:"psn_name"`
  4151. InsuOptins interface{} `json:"insu_optins"`
  4152. PrefFundPay interface{} `json:"pref_fund_pay"`
  4153. ClrOptins string `json:"clr_optins"`
  4154. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4155. DiseName string `json:"dise_name"`
  4156. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4157. Age float64 `json:"age"`
  4158. DtrtCertType string `json:"dtrt_cert_type"`
  4159. HospLv string `json:"hosp_lv"`
  4160. } `json:"setlinfo"`
  4161. } `json:"output"`
  4162. RefmsgTime string `json:"refmsg_time"`
  4163. RespondTime string `json:"respond_time"`
  4164. Signtype interface{} `json:"signtype"`
  4165. WarnMsg interface{} `json:"warn_msg"`
  4166. }
  4167. type ResultTwelve struct {
  4168. Cainfo string `json:"cainfo"`
  4169. ErrMsg string `json:"err_msg"`
  4170. InfRefmsgid string `json:"inf_refmsgid"`
  4171. Infcode int64 `json:"infcode"`
  4172. Output struct {
  4173. MdtrtId string `json:"mdtrt_id"`
  4174. ChrgBchno string `json:"chrg_bchno"`
  4175. PsnNo string `json:"psn_no"`
  4176. } `json:"output"`
  4177. RefmsgTime string `json:"refmsg_time"`
  4178. RespondTime string `json:"respond_time"`
  4179. Signtype interface{} `json:"signtype"`
  4180. WarnMsg interface{} `json:"warn_msg"`
  4181. }
  4182. type ResultThirteen struct {
  4183. ErrMsg string `json:"err_msg"`
  4184. InfRefmsgid string `json:"inf_refmsgid"`
  4185. Infcode int64 `json:"infcode"`
  4186. Output struct {
  4187. Result struct {
  4188. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4189. } `json:"result"`
  4190. } `json:"output"`
  4191. RefmsgTime string `json:"refmsg_time"`
  4192. RespondTime string `json:"respond_time"`
  4193. Signtype interface{} `json:"signtype"`
  4194. WarnInfo interface{} `json:"warn_info"`
  4195. }
  4196. type ResultThirteen10265 struct {
  4197. ErrMsg string `json:"err_msg"`
  4198. InfRefmsgid string `json:"inf_refmsgid"`
  4199. Infcode string `json:"infcode"`
  4200. Output struct {
  4201. Result struct {
  4202. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4203. } `json:"result"`
  4204. } `json:"output"`
  4205. RefmsgTime string `json:"refmsg_time"`
  4206. RespondTime string `json:"respond_time"`
  4207. Signtype interface{} `json:"signtype"`
  4208. WarnInfo interface{} `json:"warn_info"`
  4209. }
  4210. type ResultFourteen struct {
  4211. ErrMsg string `json:"err_msg"`
  4212. InfRefmsgid string `json:"inf_refmsgid"`
  4213. Infcode int64 `json:"infcode"`
  4214. Output struct {
  4215. } `json:"output"`
  4216. RefmsgTime string `json:"refmsg_time"`
  4217. RespondTime string `json:"respond_time"`
  4218. Signtype interface{} `json:"signtype"`
  4219. WarnInfo interface{} `json:"warn_info"`
  4220. }
  4221. type ResultFourteen10265 struct {
  4222. ErrMsg string `json:"err_msg"`
  4223. InfRefmsgid string `json:"inf_refmsgid"`
  4224. Infcode string `json:"infcode"`
  4225. Output struct {
  4226. } `json:"output"`
  4227. RefmsgTime string `json:"refmsg_time"`
  4228. RespondTime string `json:"respond_time"`
  4229. Signtype interface{} `json:"signtype"`
  4230. WarnInfo interface{} `json:"warn_info"`
  4231. }
  4232. type ResultSixteen struct {
  4233. Cainfo string `json:"cainfo"`
  4234. ErrMsg string `json:"err_msg"`
  4235. InfRefmsgid string `json:"inf_refmsgid"`
  4236. Infcode int64 `json:"infcode"`
  4237. Output struct {
  4238. Setldetail []interface{} `json:"setldetail"`
  4239. Setlinfo struct {
  4240. MdtrtID string `json:"mdtrt_id"`
  4241. SetlID string `json:"setl_id"`
  4242. ClrOptins string `json:"clr_optins"`
  4243. SetlTime string `json:"setl_time"`
  4244. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4245. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4246. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4247. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4249. ActPayDedc float64 `json:"act_pay_dedc"`
  4250. HifpPay float64 `json:"hifp_pay"`
  4251. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4252. Lfpay float64 `json:"selfpay"`
  4253. CvlservPay float64 `json:"cvlserv_pay"`
  4254. HifesPay float64 `json:"hifes_pay"`
  4255. HifmiPay float64 `json:"hifmi_pay"`
  4256. HifobPay float64 `json:"hifob_pay"`
  4257. MafPay float64 `json:"maf_pay"`
  4258. OthPay float64 `json:"oth_pay"`
  4259. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4260. PsnPartAmt float64 `json:"psn_part_amt"`
  4261. AcctPay float64 `json:"acct_pay"`
  4262. Balc float64 `json:"balc"`
  4263. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4264. HospPartAmt float64 `json:"hosp_part_amt"`
  4265. MedinsSetlID string `json:"medins_setl_id"`
  4266. PdnCashPay string `json:"pdn_cash_pay"`
  4267. } `json:"setlinfo"`
  4268. } `json:"output"`
  4269. RefmsgTime string `json:"refmsg_time"`
  4270. RespondTime string `json:"respond_time"`
  4271. Signtype interface{} `json:"signtype"`
  4272. WarnMsg interface{} `json:"warn_msg"`
  4273. }
  4274. type ResultSixteen10265 struct {
  4275. Cainfo string `json:"cainfo"`
  4276. ErrMsg string `json:"err_msg"`
  4277. InfRefmsgid string `json:"inf_refmsgid"`
  4278. Infcode string `json:"infcode"`
  4279. Output struct {
  4280. Setldetail []interface{} `json:"setldetail"`
  4281. Setlinfo struct {
  4282. MdtrtID string `json:"mdtrt_id"`
  4283. SetlID string `json:"setl_id"`
  4284. ClrOptins string `json:"clr_optins"`
  4285. SetlTime string `json:"setl_time"`
  4286. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4287. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4288. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4289. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4290. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4291. ActPayDedc float64 `json:"act_pay_dedc"`
  4292. HifpPay float64 `json:"hifp_pay"`
  4293. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4294. Lfpay float64 `json:"selfpay"`
  4295. CvlservPay float64 `json:"cvlserv_pay"`
  4296. HifesPay float64 `json:"hifes_pay"`
  4297. HifmiPay float64 `json:"hifmi_pay"`
  4298. HifobPay float64 `json:"hifob_pay"`
  4299. MafPay float64 `json:"maf_pay"`
  4300. OthPay float64 `json:"oth_pay"`
  4301. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4302. PsnPartAmt float64 `json:"psn_part_amt"`
  4303. AcctPay float64 `json:"acct_pay"`
  4304. Balc float64 `json:"balc"`
  4305. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4306. HospPartAmt float64 `json:"hosp_part_amt"`
  4307. MedinsSetlID string `json:"medins_setl_id"`
  4308. PdnCashPay string `json:"pdn_cash_pay"`
  4309. } `json:"setlinfo"`
  4310. } `json:"output"`
  4311. RefmsgTime string `json:"refmsg_time"`
  4312. RespondTime string `json:"respond_time"`
  4313. Signtype interface{} `json:"signtype"`
  4314. WarnMsg interface{} `json:"warn_msg"`
  4315. }
  4316. type ResultSeventeen struct {
  4317. ErrMsg string `json:"err_msg"`
  4318. InfRefmsgid string `json:"inf_refmsgid"`
  4319. Infcode int64 `json:"infcode"`
  4320. Output struct {
  4321. SetlListId string `json:"setl_list_id"`
  4322. } `json:"output"`
  4323. RefmsgTime string `json:"refmsg_time"`
  4324. RespondTime string `json:"respond_time"`
  4325. Signtype string `json:"signtype"`
  4326. WarnInfo string `json:"warn_info"`
  4327. }
  4328. type ResultSeventeenOther struct {
  4329. ErrMsg string `json:"err_msg"`
  4330. InfRefmsgid string `json:"inf_refmsgid"`
  4331. Infcode string `json:"infcode"`
  4332. Output struct {
  4333. SetlListId string `json:"setl_list_id"`
  4334. } `json:"output"`
  4335. RefmsgTime string `json:"refmsg_time"`
  4336. RespondTime string `json:"respond_time"`
  4337. Signtype string `json:"signtype"`
  4338. WarnInfo string `json:"warn_info"`
  4339. }
  4340. type Result90991 struct {
  4341. ErrMsg string `json:"err_msg"`
  4342. InfRefmsgid string `json:"inf_refmsgid"`
  4343. Infcode int64 `json:"infcode"`
  4344. Output struct {
  4345. Result struct {
  4346. PsnNo string `json:"psn_no"`
  4347. CardStat string `json:"card_stat"`
  4348. Certno string `json:"certno"`
  4349. PsnName string `json:"psn_name"`
  4350. CheckStat string `json:"check_stat"`
  4351. SscnoCheckStat string `json:"sscno_check_stat"`
  4352. } `json:"result"`
  4353. } `json:"output"`
  4354. RefmsgTime string `json:"refmsg_time"`
  4355. RespondTime string `json:"respond_time"`
  4356. Signtype interface{} `json:"signtype"`
  4357. WarnInfo interface{} `json:"warn_info"`
  4358. }
  4359. type Result90100 struct {
  4360. ErrMsg string `json:"err_msg"`
  4361. InfRefmsgid string `json:"inf_refmsgid"`
  4362. Infcode int64 `json:"infcode"`
  4363. Output struct {
  4364. PoolareaNo string `json:"poolarea_no"`
  4365. PoolareaNoName string `json:"poolarea_no_name"`
  4366. Insutype string `json:"insutype"`
  4367. InsutypeName string `json:"insutype_name"`
  4368. ClctType string `json:"clct_type"`
  4369. ClctTypeName string `json:"clct_type_name"`
  4370. ClctFlag string `json:"clct_flag"`
  4371. ClctFlagName string `json:"clct_flag_name"`
  4372. AccrymBegn string `json:"accrym_begn"`
  4373. AccrymEnd string `json:"accrym_end"`
  4374. ClctTime string `json:"clct_time"`
  4375. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4376. } `json:"output"`
  4377. RefmsgTime string `json:"refmsg_time"`
  4378. RespondTime string `json:"respond_time"`
  4379. Signtype interface{} `json:"signtype"`
  4380. WarnInfo interface{} `json:"warn_info"`
  4381. }
  4382. type Custom struct {
  4383. DetItemFeeSumamt string
  4384. Cut string
  4385. FeedetlSn string
  4386. Price string
  4387. MedListCodg string
  4388. Type int64
  4389. AdviceId int64
  4390. ProjectId int64
  4391. ItemId int64
  4392. }
  4393. type Result5301 struct {
  4394. ErrMsg string `json:"err_msg"`
  4395. InfRefmsgid string `json:"inf_refmsgid"`
  4396. Infcode int64 `json:"infcode"`
  4397. Output struct {
  4398. Result []struct {
  4399. OpspDiseCode string `json:"opsp_dise_code"`
  4400. OpspDiseName string `json:"opsp_dise_name"`
  4401. Begndate string `json:"begndate"`
  4402. Enddate string `json:"enddate"`
  4403. } `json:"feedetail"`
  4404. } `json:"output"`
  4405. RefmsgTime string `json:"refmsg_time"`
  4406. RespondTime string `json:"respond_time"`
  4407. Signtype interface{} `json:"signtype"`
  4408. WarnInfo interface{} `json:"warn_info"`
  4409. }
  4410. type Result5301For10265 struct {
  4411. ErrMsg string `json:"err_msg"`
  4412. InfRefmsgid string `json:"inf_refmsgid"`
  4413. Infcode string `json:"infcode"`
  4414. Output struct {
  4415. Result []struct {
  4416. OpspDiseCode string `json:"opsp_dise_code"`
  4417. OpspDiseName string `json:"opsp_dise_name"`
  4418. Begndate string `json:"begndate"`
  4419. Enddate string `json:"enddate"`
  4420. } `json:"feedetail"`
  4421. } `json:"output"`
  4422. RefmsgTime string `json:"refmsg_time"`
  4423. RespondTime string `json:"respond_time"`
  4424. Signtype interface{} `json:"signtype"`
  4425. WarnInfo interface{} `json:"warn_info"`
  4426. }
  4427. //获取个人信息----挂号-----上传就诊信息
  4428. func (c *HisApiController) GetRegisterInfo() {
  4429. id, _ := c.GetInt64("id")
  4430. record_time := c.GetString("record_time")
  4431. settlementValue, _ := c.GetInt64("settlement_value")
  4432. medical_insurance_card := c.GetString("medical_insurance_card")
  4433. name := c.GetString("name")
  4434. id_card_type, _ := c.GetInt64("id_card_type")
  4435. certificates, _ := c.GetInt64("certificates")
  4436. medical_care, _ := c.GetInt64("medical_care")
  4437. birthday := c.GetString("birthday")
  4438. id_card := c.GetString("id_card")
  4439. register_type, _ := c.GetInt64("register")
  4440. doctor, _ := c.GetInt64("doctor")
  4441. department, _ := c.GetInt64("department")
  4442. gender, _ := c.GetInt64("sex")
  4443. registration_fee, _ := c.GetFloat("registration_fee")
  4444. medical_expenses, _ := c.GetFloat("medical_expenses")
  4445. social_type, _ := c.GetInt64("social_type")
  4446. med_type := c.GetString("social_type")
  4447. admin_user_id, _ := c.GetInt64("admin_user_id")
  4448. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4449. timeLayout := "2006-01-02"
  4450. loc, _ := time.LoadLocation("Local")
  4451. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4452. birthUnix := birthdays.Unix()
  4453. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4454. if err != nil {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4456. return
  4457. }
  4458. recordDateTime := theTime.Unix()
  4459. adminInfo := c.GetAdminUserInfo()
  4460. var patient service.Patients
  4461. if id == 0 {
  4462. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4463. } else {
  4464. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4465. }
  4466. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4467. if patientPrescription.ID == 0 {
  4468. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4469. }
  4470. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4471. if patient.ID == 0 {
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4473. return
  4474. }
  4475. if len(patient.IdCardNo) == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4477. return
  4478. }
  4479. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4480. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4481. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4482. //就诊结算未完成,不能进行二次挂号
  4483. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4484. if len(his) >= 1 {
  4485. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4486. if len(his) >= 1 && order.ID == 0 {
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4488. return
  4489. }
  4490. }
  4491. //var register_log string
  4492. if config.IsOpen == 1 {
  4493. var res ResultTwo
  4494. var res10265 ResultTwo10265
  4495. var PsnNo string
  4496. var PsnCertType string
  4497. var Certno string
  4498. var PsnName string
  4499. var Gend string
  4500. var Naty string
  4501. var Brdy string
  4502. var Age float64
  4503. var infoStr string
  4504. var idetinfoStr string
  4505. var infocode int64
  4506. var verify_number string
  4507. fmt.Println(verify_number)
  4508. if miConfig.MdtrtareaAdmvs == "421300" {
  4509. psn_info, _ := service.GetPsnByPatientId(id)
  4510. PsnNo = psn_info.PsnNo
  4511. PsnCertType = psn_info.PsnCertType
  4512. Certno = psn_info.Certno
  4513. PsnName = psn_info.PsnName
  4514. Gend = psn_info.Gend
  4515. Naty = psn_info.Naty
  4516. Brdy = psn_info.Brdy
  4517. Age = psn_info.Age
  4518. infoStr = psn_info.Insuinfo
  4519. idetinfoStr = psn_info.Idetinfo
  4520. infocode = 0
  4521. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4522. psn_info, _ := service.GetPsnByPatientId(id)
  4523. PsnNo = psn_info.PsnNo
  4524. PsnCertType = psn_info.PsnCertType
  4525. Certno = psn_info.Certno
  4526. PsnName = psn_info.PsnName
  4527. Gend = psn_info.Gend
  4528. Naty = psn_info.Naty
  4529. Brdy = psn_info.Brdy
  4530. Age = psn_info.Age
  4531. infoStr = psn_info.Insuinfo
  4532. idetinfoStr = psn_info.Idetinfo
  4533. infocode = 0
  4534. verify_number = psn_info.VerifyNumber
  4535. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4536. psn_info, _ := service.GetPsnByPatientId(id)
  4537. PsnNo = psn_info.PsnNo
  4538. PsnCertType = psn_info.PsnCertType
  4539. Certno = psn_info.Certno
  4540. PsnName = psn_info.PsnName
  4541. Gend = psn_info.Gend
  4542. Naty = psn_info.Naty
  4543. Brdy = psn_info.Brdy
  4544. Age = psn_info.Age
  4545. infoStr = psn_info.Insuinfo
  4546. idetinfoStr = psn_info.Idetinfo
  4547. infocode = 0
  4548. verify_number = psn_info.VerifyNumber
  4549. } else {
  4550. var result string
  4551. var requestLog string
  4552. if miConfig.UserOrgId == 10138 {
  4553. 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)
  4554. } else {
  4555. 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)
  4556. }
  4557. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4558. if miConfig.Code == "H15049901371" {
  4559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4560. utils.ErrorLog("解析失败:%v", err)
  4561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4562. return
  4563. }
  4564. res.ErrMsg = res10265.ErrMsg
  4565. res.Output = res10265.Output
  4566. res.InfRefmsgid = res10265.InfRefmsgid
  4567. } else {
  4568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. }
  4574. PsnNo = res.Output.Baseinfo.PsnNo
  4575. PsnCertType = res.Output.Baseinfo.PsnCertType
  4576. Certno = res.Output.Baseinfo.Certno
  4577. PsnName = res.Output.Baseinfo.PsnName
  4578. Gend = res.Output.Baseinfo.Gend
  4579. Naty = res.Output.Baseinfo.Naty
  4580. Brdy = res.Output.Baseinfo.Brdy
  4581. Age = res.Output.Baseinfo.Age
  4582. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4583. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4584. infoStr = string(Iinfos)
  4585. idetinfoStr = string(Idetinfos)
  4586. if miConfig.Code == "H15049901371" {
  4587. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4588. } else {
  4589. infocode = res.Infcode
  4590. }
  4591. }
  4592. if infocode == 0 {
  4593. his := models.VMHisPatient{
  4594. Name: name,
  4595. Gender: gender,
  4596. Birthday: birthUnix,
  4597. MedicalTreatmentType: medical_care,
  4598. IdType: certificates,
  4599. IdCardNo: id_card,
  4600. BalanceAccountsType: settlementValue,
  4601. SocialType: social_type,
  4602. MedicalInsuranceNumber: medical_insurance_card,
  4603. RegisterType: register_type,
  4604. RegisterCost: registration_fee,
  4605. TreatmentCost: medical_expenses,
  4606. Status: 1,
  4607. Ctime: time.Now().Unix(),
  4608. Mtime: time.Now().Unix(),
  4609. PsnNo: PsnNo,
  4610. PsnCertType: PsnCertType,
  4611. Certno: Certno,
  4612. PsnName: PsnName,
  4613. Gend: Gend,
  4614. Naty: Naty,
  4615. Brdy: Brdy,
  4616. Age: Age,
  4617. Iinfo: infoStr,
  4618. Idetinfo: idetinfoStr,
  4619. PatientId: patient.ID,
  4620. RecordDate: theTime.Unix(),
  4621. UserOrgId: adminInfo.CurrentOrgId,
  4622. AdminUserId: admin_user_id,
  4623. IsReturn: 1,
  4624. IdCardType: id_card_type,
  4625. Doctor: doctor,
  4626. Departments: department,
  4627. }
  4628. timestamp := time.Now().Unix()
  4629. tempTime := time.Unix(timestamp, 0)
  4630. timeFormat := tempTime.Format("20060102150405")
  4631. chrgBchno := rand.Intn(100000) + 10000
  4632. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4633. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4634. department, _ := service.GetDepartMentDetail(department)
  4635. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4636. IdCardNo := ""
  4637. if id_card_type == 1 {
  4638. // IdCardNo = medical_insurance_card
  4639. IdCardNo = patient.IdCardNo
  4640. } else {
  4641. IdCardNo = patient.IdCardNo
  4642. }
  4643. var rf []*ResultFive
  4644. json.Unmarshal([]byte(his.Iinfo), &rf)
  4645. var insutypes []*ResultFive
  4646. var insutype string
  4647. var insuplc_admdvs_temp string
  4648. var is390 int = 0
  4649. var is310 int = 0
  4650. for _, item := range rf {
  4651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4652. insutypes = append(insutypes, item)
  4653. }
  4654. }
  4655. if len(insutypes) == 1 {
  4656. insutype = insutypes[0].Insutype
  4657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4658. } else {
  4659. for _, i := range insutypes {
  4660. if i.Insutype == "390" {
  4661. is390 = 1
  4662. }
  4663. if i.Insutype == "310" {
  4664. is310 = 1
  4665. }
  4666. }
  4667. }
  4668. if is390 == 1 {
  4669. insutype = "390"
  4670. }
  4671. if is310 == 1 {
  4672. insutype = "310"
  4673. }
  4674. if len(insutypes) == 0 {
  4675. insutype = "310"
  4676. }
  4677. if len(insutypes) == 2 {
  4678. insutype = med_type
  4679. }
  4680. if len(med_type) > 0 {
  4681. insutype = med_type
  4682. }
  4683. //for _, item := range rf {
  4684. // if item.Insutype == insutype {
  4685. // insuplc_admdvs = item.InsuplcAdmdvs
  4686. // }
  4687. //}
  4688. var infocode int64
  4689. var resThree ResultThree
  4690. var resThree10265 ResultThree10265
  4691. if len(insuplc_admdvs) == 0 {
  4692. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4693. } else {
  4694. insuplc_admdvs_temp = insuplc_admdvs
  4695. }
  4696. if miConfig.MdtrtareaAdmvs == "421300" {
  4697. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4698. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4699. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4700. "&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
  4701. resp, requestErr := http.Get(api)
  4702. if requestErr != nil {
  4703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. body, ioErr := ioutil.ReadAll(resp.Body)
  4707. if ioErr != nil {
  4708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. var respJSON map[string]interface{}
  4713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4719. result, _ := json.Marshal(respJSON)
  4720. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4721. utils.ErrorLog("解析失败:%v", err)
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. infocode = resThree.Infcode
  4726. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4727. psn_info, _ := service.GetPsnByPatientId(id)
  4728. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4729. var cert_no string
  4730. if id_card_type == 3 {
  4731. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4732. cert_no = IdCardNo
  4733. } else if id_card_type == 4 {
  4734. cert_no = IdCardNo
  4735. psn_info.VerifyNumber = psn_info.VerifyNumber
  4736. } else {
  4737. bas := strings.Split(psn_info.CardInfo, "|")
  4738. cert_no = bas[2]
  4739. }
  4740. var api string
  4741. if miConfig.MdtrtareaAdmvs == "320921" {
  4742. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4743. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4744. "&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
  4745. } else {
  4746. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4747. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4748. "&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
  4749. }
  4750. resp, requestErr := http.Get(api)
  4751. if requestErr != nil {
  4752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4753. return
  4754. }
  4755. body, ioErr := ioutil.ReadAll(resp.Body)
  4756. if ioErr != nil {
  4757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. var respJSON map[string]interface{}
  4762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4768. result, _ := json.Marshal(respJSON)
  4769. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4770. utils.ErrorLog("解析失败:%v", err)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. resThree.ErrMsg = resThree10265.ErrMsg
  4775. resThree.Output = resThree10265.Output
  4776. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4777. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4778. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4779. result, requestLog := service.FJyb2201(res.Output.Baseinfo.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)
  4780. saveLog(result, requestLog, "2201", "挂号")
  4781. if miConfig.Code == "H15049901371" {
  4782. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4783. utils.ErrorLog("解析失败:%v", err)
  4784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4785. return
  4786. }
  4787. resThree.ErrMsg = resThree10265.ErrMsg
  4788. resThree.Output = resThree10265.Output
  4789. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4790. } else {
  4791. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4792. utils.ErrorLog("解析失败:%v", err)
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4794. return
  4795. }
  4796. }
  4797. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4798. } else {
  4799. 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)
  4800. saveLog(result, requestLog, "2201A", "挂号")
  4801. if miConfig.Code == "H15049901371" {
  4802. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4803. utils.ErrorLog("解析失败:%v", err)
  4804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. return
  4806. }
  4807. resThree.ErrMsg = resThree10265.ErrMsg
  4808. resThree.Output = resThree10265.Output
  4809. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4810. } else {
  4811. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4812. utils.ErrorLog("解析失败:%v", err)
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. return
  4815. }
  4816. }
  4817. if miConfig.Code == "H15049901371" {
  4818. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4819. } else {
  4820. infocode = resThree.Infcode
  4821. }
  4822. }
  4823. if infocode != 0 {
  4824. adminUser := c.GetAdminUserInfo()
  4825. errlog := &models.HisOrderError{
  4826. UserOrgId: adminUser.CurrentOrgId,
  4827. Ctime: time.Now().Unix(),
  4828. Mtime: time.Now().Unix(),
  4829. ErrMsg: resThree.ErrMsg,
  4830. Status: 1,
  4831. PatientId: id,
  4832. RecordTime: recordDateTime,
  4833. Stage: 2,
  4834. }
  4835. service.CreateErrMsgLog(errlog)
  4836. c.ServeSuccessJSON(map[string]interface{}{
  4837. "failed_code": -10,
  4838. "msg": resThree.ErrMsg,
  4839. })
  4840. return
  4841. }
  4842. his.Number = resThree.Output.Data.MdtrtID
  4843. his.PsnNo = resThree.Output.Data.PsnNo
  4844. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4845. his.IdCardNo = patient.IdCardNo
  4846. his.PhoneNumber = patient.Phone
  4847. his.UserOrgId = adminInfo.CurrentOrgId
  4848. his.Insutype = insutype
  4849. his.Ctime = time.Now().Unix()
  4850. his.Mtime = time.Now().Unix()
  4851. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4852. his.Status = 1
  4853. service.UpdateHisPatientStatus(&his)
  4854. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4855. c.ServeSuccessJSON(map[string]interface{}{
  4856. "his_info": his,
  4857. })
  4858. } else {
  4859. adminUser := c.GetAdminUserInfo()
  4860. errlog := &models.HisOrderError{
  4861. UserOrgId: adminUser.CurrentOrgId,
  4862. Ctime: time.Now().Unix(),
  4863. Mtime: time.Now().Unix(),
  4864. ErrMsg: res.ErrMsg,
  4865. Status: 1,
  4866. PatientId: id,
  4867. RecordTime: recordDateTime,
  4868. Stage: 1,
  4869. }
  4870. service.CreateErrMsgLog(errlog)
  4871. c.ServeSuccessJSON(map[string]interface{}{
  4872. "failed_code": -10,
  4873. "msg": res.ErrMsg,
  4874. })
  4875. return
  4876. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4877. }
  4878. }
  4879. }
  4880. //上传明细----预结算----确认订单
  4881. func (c *HisApiController) GetUploadInfo() {
  4882. id, _ := c.GetInt64("id")
  4883. record_time := c.GetString("record_time")
  4884. his_patient_id, _ := c.GetInt64("his_patient_id")
  4885. order_id, _ := c.GetInt64("order_id")
  4886. pay_way, _ := c.GetInt64("pay_way")
  4887. pay_price, _ := c.GetFloat("pay_price")
  4888. pay_card_no := c.GetString("pay_card_no")
  4889. token := c.GetString("token")
  4890. discount_price, _ := c.GetFloat("discount_price")
  4891. preferential_price, _ := c.GetFloat("preferential_price")
  4892. reality_price, _ := c.GetFloat("reality_price")
  4893. found_price, _ := c.GetFloat("found_price")
  4894. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4895. private_price, _ := c.GetFloat("private_price")
  4896. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4897. admin_user_id, _ := c.GetInt64("admin_user_id")
  4898. fapiao_code := c.GetString("fapiao_code")
  4899. fapiao_number := c.GetString("fapiao_number")
  4900. diagnosis_id := c.GetString("diagnosis")
  4901. sick_type, _ := c.GetInt64("sick_type")
  4902. reg_type, _ := c.GetInt64("p_type")
  4903. begin_time := c.GetString("begin_time")
  4904. id_str := c.GetString("ids")
  4905. ids_arr := strings.Split(id_str, ",")
  4906. timeLayout := "2006-01-02"
  4907. loc, _ := time.LoadLocation("Local")
  4908. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4909. if err != nil {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4911. return
  4912. }
  4913. recordDateTime := theTime.Unix()
  4914. adminUser := c.GetAdminUserInfo()
  4915. var tempOrder models.HisOrder
  4916. tempOrder, _ = service.GetHisOrderByID(order_id)
  4917. var prescriptions []*models.HisPrescription
  4918. var start_time int64
  4919. var end_time int64
  4920. //押金模块
  4921. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4922. tmp_decimal := c.GetString("tmp_decimal")
  4923. var decimal float64 //本次使用的押金
  4924. var errmsg error
  4925. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4926. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4927. return
  4928. }
  4929. if len(tmp_decimal) > 0 {
  4930. if tmp_decimal[0] == 45 {
  4931. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4932. return
  4933. }
  4934. }
  4935. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4936. fmt.Println(errs)
  4937. decimal = tt
  4938. //if adminUser.CurrentOrgId == 10106{
  4939. // if len(fapiao_code) == 0{
  4940. // fapiao_code = "144072080589"
  4941. // }
  4942. // if len(fapiao_number) == 0{
  4943. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4944. // if order.ID == 0{
  4945. // fapiao_number = "00001520"
  4946. // }else{
  4947. // //fapiao_code = "00001520"
  4948. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4949. // var zero string
  4950. // if fpNumber >= 1000{
  4951. // zero = "0000" + strconv.Itoa(fpNumber)
  4952. // }else if fpNumber >= 10000{
  4953. // zero = "000" + strconv.Itoa(fpNumber)
  4954. // } else if fpNumber >= 100000{
  4955. // zero = "00" + strconv.Itoa(fpNumber)
  4956. // } else if fpNumber >= 1000000{
  4957. // zero = "0" + strconv.Itoa(fpNumber)
  4958. // }else {
  4959. // zero = strconv.Itoa(fpNumber)
  4960. // }
  4961. // fapiao_number = zero
  4962. // }
  4963. // }
  4964. //}
  4965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4966. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4967. var patientPrescription models.HisPrescriptionInfo
  4968. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4969. if patientPrescription.ID == 0 {
  4970. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4971. }
  4972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4973. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4974. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4975. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4976. var config []*models.HisXtDiagnoseConfig
  4977. for _, item := range diagnosis_ids {
  4978. id, _ := strconv.ParseInt(item, 10, 64)
  4979. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4980. config = append(config, &diagnosisConfig)
  4981. }
  4982. sickConfig, _ := service.FindSickById(sick_type)
  4983. //if tempOrder.ID == 0 {
  4984. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4985. //}
  4986. if tempOrder.ID == 0 {
  4987. var result string
  4988. var requestLog string
  4989. var res2 ResultSix
  4990. var ressix10265 ResultSix10265
  4991. if miConfig.MdtrtareaAdmvs == "421300" {
  4992. data := make(map[string]interface{})
  4993. client := &http.Client{}
  4994. data["psn_no"] = his.PsnNo
  4995. data["mdtrt_id"] = his.Number
  4996. data["opter"] = roles.UserName
  4997. data["org_name"] = miConfig.OrgName
  4998. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4999. data["doctor_id"] = doctor_info.DoctorNumber
  5000. data["doctor_name"] = doctor_info.UserName
  5001. data["department"] = department.Name
  5002. data["fixmedins_code"] = miConfig.Code
  5003. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5004. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5005. data["secret_key"] = miConfig.SecretKey
  5006. data["sick_code"] = sickConfig.CountryCode
  5007. data["sick_name"] = sickConfig.ClassName
  5008. data["dept"] = strconv.FormatInt(department.ID, 10)
  5009. data["config"] = config
  5010. data["begin_time"] = begin_time
  5011. bytesData, _ := json.Marshal(data)
  5012. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5013. resp, _ := client.Do(req)
  5014. defer resp.Body.Close()
  5015. body, ioErr := ioutil.ReadAll(resp.Body)
  5016. if ioErr != nil {
  5017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5019. return
  5020. }
  5021. var respJSON map[string]interface{}
  5022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return
  5026. }
  5027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5028. userJSONBytes, _ := json.Marshal(respJSON)
  5029. fmt.Println("log")
  5030. fmt.Println(string(userJSONBytes))
  5031. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5032. utils.ErrorLog("解析失败:%v", err)
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. return
  5035. }
  5036. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5037. //江苏地区国家医保医疗类别
  5038. //职工透析:医疗类别选特殊情况门诊9933
  5039. //居民血透门慢: 医疗类别选门诊慢病1402
  5040. //var med_type string
  5041. //if his.Insutype == "310" {
  5042. // if reg_type == 14 {
  5043. // med_type = "9933"
  5044. // } else if reg_type == 11 {
  5045. // med_type = "11"
  5046. //
  5047. // }
  5048. //} else if his.Insutype == "390" {
  5049. // if reg_type == 14 {
  5050. // med_type = "1402"
  5051. // } else if reg_type == 11 {
  5052. // med_type = "11"
  5053. // }
  5054. //}
  5055. data := make(map[string]interface{})
  5056. client := &http.Client{}
  5057. data["psn_no"] = his.PsnNo
  5058. data["mdtrt_id"] = his.Number
  5059. data["doctor"] = roles.UserName
  5060. data["department"] = department.Name
  5061. data["org_name"] = miConfig.OrgName
  5062. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5063. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5064. data["fixmedins_code"] = miConfig.Code
  5065. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5066. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5067. data["secret_key"] = miConfig.SecretKey
  5068. data["sick_code"] = sickConfig.CountryCode
  5069. data["sick_name"] = sickConfig.ClassName
  5070. data["url"] = miConfig.Url
  5071. data["ak"] = miConfig.AccessKey
  5072. data["begin_time"] = begin_time
  5073. data["cainfo"] = miConfig.Cainfo
  5074. data["dept"] = strconv.FormatInt(department.ID, 10)
  5075. data["config"] = config
  5076. bytesData, _ := json.Marshal(data)
  5077. var req *http.Request
  5078. if miConfig.MdtrtareaAdmvs == "320921" {
  5079. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5080. //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 +
  5081. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5082. } else {
  5083. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5084. }
  5085. resp, _ := client.Do(req)
  5086. defer resp.Body.Close()
  5087. body, ioErr := ioutil.ReadAll(resp.Body)
  5088. if ioErr != nil {
  5089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5091. return
  5092. }
  5093. var respJSON map[string]interface{}
  5094. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5097. return
  5098. }
  5099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5100. userJSONBytes, _ := json.Marshal(respJSON)
  5101. fmt.Println("log")
  5102. fmt.Println(string(userJSONBytes))
  5103. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5104. utils.ErrorLog("解析失败:%v", err)
  5105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5106. return
  5107. }
  5108. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5109. res2.Output = ressix10265.Output
  5110. res2.ErrMsg = ressix10265.ErrMsg
  5111. res2.Cainfo = ressix10265.Cainfo
  5112. res2.WarnMsg = ressix10265.WarnMsg
  5113. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5114. res2.Infcode = infocode
  5115. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5116. 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)
  5117. saveLog(result, requestLog, "2203", "上传就诊信息")
  5118. var respJSON2 map[string]interface{}
  5119. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5122. return
  5123. }
  5124. userJSONBytes2, _ := json.Marshal(respJSON2)
  5125. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5126. utils.ErrorLog("解析失败:%v", err)
  5127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5128. return
  5129. }
  5130. } else {
  5131. if miConfig.MdtrtareaAdmvs == "440781" { //
  5132. 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)
  5133. } else {
  5134. if miConfig.Code == "H15049901371" {
  5135. //赤峰地区国家医保医疗类别
  5136. //职工透析:医疗类别选特殊情况门诊990502
  5137. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5138. var med_type string
  5139. if his.Insutype == "390" {
  5140. if reg_type == 14 {
  5141. med_type = "9933"
  5142. } else if reg_type == 11 {
  5143. med_type = "11"
  5144. }
  5145. } else if his.Insutype == "310" {
  5146. if reg_type == 14 {
  5147. med_type = "990502"
  5148. } else if reg_type == 11 {
  5149. med_type = "11"
  5150. }
  5151. }
  5152. 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)
  5153. } else {
  5154. 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)
  5155. }
  5156. }
  5157. saveLog(result, requestLog, "2203", "上传就诊信息")
  5158. var respJSON2 map[string]interface{}
  5159. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. return
  5163. }
  5164. userJSONBytes2, _ := json.Marshal(respJSON2)
  5165. if miConfig.Code == "H15049901371" {
  5166. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5167. utils.ErrorLog("解析失败:%v", err)
  5168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5169. return
  5170. }
  5171. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5172. res2.Output = ressix10265.Output
  5173. res2.ErrMsg = ressix10265.ErrMsg
  5174. res2.Cainfo = ressix10265.Cainfo
  5175. res2.WarnMsg = ressix10265.WarnMsg
  5176. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5177. res2.Infcode = infocode
  5178. } else {
  5179. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5180. utils.ErrorLog("解析失败:%v", err)
  5181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5182. return
  5183. }
  5184. }
  5185. }
  5186. if res2.Infcode != 0 {
  5187. adminUser := c.GetAdminUserInfo()
  5188. errlog := &models.HisOrderError{
  5189. UserOrgId: adminUser.CurrentOrgId,
  5190. Ctime: time.Now().Unix(),
  5191. Mtime: time.Now().Unix(),
  5192. ErrMsg: res2.ErrMsg,
  5193. Status: 1,
  5194. PatientId: id,
  5195. RecordTime: recordDateTime,
  5196. Stage: 3,
  5197. }
  5198. service.CreateErrMsgLog(errlog)
  5199. c.ServeSuccessJSON(map[string]interface{}{
  5200. "failed_code": -10,
  5201. "msg": res2.ErrMsg,
  5202. })
  5203. return
  5204. } else {
  5205. his.Diagnosis = diagnosis_id
  5206. his.SickType = sickConfig.ID
  5207. //var p_type int64
  5208. //if reg_type == 1111 || reg_type == 1112 {
  5209. // p_type = 11
  5210. //
  5211. //}
  5212. his.PType = fmt.Sprintf("%d", reg_type)
  5213. service.UpdateHisPatientThree(&his)
  5214. data := make(map[string]interface{})
  5215. if settle_accounts_type == 1 { //日结
  5216. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5217. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5218. } else {
  5219. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5220. }
  5221. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5222. data["pre"] = prescriptions
  5223. } else { //月结
  5224. start_time_str := c.GetString("start_time")
  5225. end_time_str := c.GetString("end_time")
  5226. timeLayout := "2006-01-02"
  5227. loc, _ := time.LoadLocation("Local")
  5228. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5229. if err != nil {
  5230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5231. return
  5232. }
  5233. recordStartTime := theStartTime.Unix()
  5234. start_time = recordStartTime
  5235. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5236. if err != nil {
  5237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5238. return
  5239. }
  5240. recordEndTime := theEndTime.Unix()
  5241. end_time = recordEndTime
  5242. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5243. data["pre"] = prescriptions
  5244. }
  5245. timestamp := time.Now().Unix()
  5246. tempTime := time.Unix(timestamp, 0)
  5247. timeFormat := tempTime.Format("20060102150405")
  5248. chrgBchno := rand.Intn(100000) + 10000
  5249. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5250. strconv.FormatInt(his.PatientId, 10)
  5251. client := &http.Client{}
  5252. data["psn_no"] = his.PsnNo
  5253. data["mdtrt_id"] = his.Number
  5254. data["chrg_bchno"] = chrg_bchno
  5255. data["org_name"] = miConfig.OrgName
  5256. data["doctor"] = doctor_info.UserName
  5257. data["doctor_id"] = doctor_info.DoctorNumber
  5258. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5259. data["fixmedins_code"] = miConfig.Code
  5260. data["opter"] = roles.UserName
  5261. data["dept_code"] = department.Number
  5262. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5263. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5264. data["secret_key"] = miConfig.SecretKey
  5265. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5266. data["url"] = miConfig.Url
  5267. data["ak"] = miConfig.AccessKey
  5268. data["new_doctor_name"] = patientPrescription.Doctor
  5269. data["diag_code"] = sickConfig.CountryCode
  5270. data["cainfo"] = miConfig.Cainfo
  5271. var ids []int64
  5272. for _, item := range prescriptions {
  5273. ids = append(ids, item.ID)
  5274. }
  5275. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5276. if config.IsOpen == 1 { //对接了医保,走医保流程
  5277. var res ResultFour
  5278. var resFour10265 ResultFour10265
  5279. if miConfig.MdtrtareaAdmvs == "421300" {
  5280. bytesData, _ := json.Marshal(data)
  5281. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5282. resp, _ := client.Do(req)
  5283. defer resp.Body.Close()
  5284. body, ioErr := ioutil.ReadAll(resp.Body)
  5285. if ioErr != nil {
  5286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5288. return
  5289. }
  5290. var respJSON map[string]interface{}
  5291. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5294. return
  5295. }
  5296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5297. userJSONBytes, _ := json.Marshal(respJSON)
  5298. fmt.Println("log")
  5299. fmt.Println(string(userJSONBytes))
  5300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5301. utils.ErrorLog("解析失败:%v", err)
  5302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5303. return
  5304. }
  5305. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5306. bytesData, _ := json.Marshal(data)
  5307. var req *http.Request
  5308. if miConfig.MdtrtareaAdmvs == "320921" {
  5309. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5310. } else {
  5311. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5312. }
  5313. resp, _ := client.Do(req)
  5314. defer resp.Body.Close()
  5315. body, ioErr := ioutil.ReadAll(resp.Body)
  5316. if ioErr != nil {
  5317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. return
  5320. }
  5321. var respJSON map[string]interface{}
  5322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5325. return
  5326. }
  5327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5328. userJSONBytes, _ := json.Marshal(respJSON)
  5329. fmt.Println("log")
  5330. fmt.Println(string(userJSONBytes))
  5331. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5332. utils.ErrorLog("解析失败:%v", err)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. res.InfRefmsgid = resFour10265.InfRefmsgid
  5337. res.Output = resFour10265.Output
  5338. res.ErrMsg = resFour10265.ErrMsg
  5339. res.Cainfo = resFour10265.Cainfo
  5340. res.WarnMsg = resFour10265.WarnMsg
  5341. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5342. res.Infcode = infocode
  5343. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5344. 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)
  5345. var dat map[string]interface{}
  5346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5347. fmt.Println(dat)
  5348. } else {
  5349. fmt.Println(err)
  5350. }
  5351. saveLog(result, request_log, "2204", "上传费用明细")
  5352. userJSONBytes, _ := json.Marshal(dat)
  5353. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5354. utils.ErrorLog("解析失败:%v", err)
  5355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5356. return
  5357. }
  5358. res.InfRefmsgid = resFour10265.InfRefmsgid
  5359. res.Output = resFour10265.Output
  5360. res.ErrMsg = resFour10265.ErrMsg
  5361. res.Cainfo = resFour10265.Cainfo
  5362. res.WarnMsg = resFour10265.WarnMsg
  5363. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5364. res.Infcode = infocode
  5365. } else {
  5366. if miConfig.Code == "H15049901371" {
  5367. 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)
  5368. var dat map[string]interface{}
  5369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5370. fmt.Println(dat)
  5371. } else {
  5372. fmt.Println(err)
  5373. }
  5374. saveLog(result, request_log, "2204", "上传费用明细")
  5375. userJSONBytes, _ := json.Marshal(dat)
  5376. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5377. utils.ErrorLog("解析失败:%v", err)
  5378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5379. return
  5380. }
  5381. res.InfRefmsgid = resFour10265.InfRefmsgid
  5382. res.Output = resFour10265.Output
  5383. res.ErrMsg = resFour10265.ErrMsg
  5384. res.Cainfo = resFour10265.Cainfo
  5385. res.WarnMsg = resFour10265.WarnMsg
  5386. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5387. res.Infcode = infocode
  5388. } else {
  5389. 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)
  5390. var dat map[string]interface{}
  5391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5392. fmt.Println(dat)
  5393. } else {
  5394. fmt.Println(err)
  5395. }
  5396. saveLog(result, request_log, "2204", "上传费用明细")
  5397. userJSONBytes, _ := json.Marshal(dat)
  5398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5399. utils.ErrorLog("解析失败:%v", err)
  5400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5401. return
  5402. }
  5403. }
  5404. }
  5405. if res.Infcode == 0 {
  5406. order := &models.HisOrder{
  5407. UserOrgId: adminUser.CurrentOrgId,
  5408. HisPatientId: his.ID,
  5409. PatientId: his.PatientId,
  5410. SettleAccountsDate: recordDateTime,
  5411. MdtrtId: his.Number,
  5412. PsnNo: his.PsnNo,
  5413. MedType: strconv.FormatInt(reg_type, 10),
  5414. Ctime: time.Now().Unix(),
  5415. Mtime: time.Now().Unix(),
  5416. Status: 1,
  5417. Number: chrg_bchno,
  5418. Infcode: res.Infcode,
  5419. WarnMsg: res.WarnMsg,
  5420. Cainfo: res.Cainfo,
  5421. ErrMsg: res.ErrMsg,
  5422. RespondTime: res.RefmsgTime,
  5423. InfRefmsgid: res.InfRefmsgid,
  5424. OrderStatus: 1,
  5425. PayWay: pay_way,
  5426. PayPrice: pay_price,
  5427. PayCardNo: pay_card_no,
  5428. DiscountPrice: discount_price,
  5429. PreferentialPrice: preferential_price,
  5430. RealityPrice: reality_price,
  5431. FoundPrice: found_price,
  5432. MedicalInsurancePrice: medical_insurance_price,
  5433. PrivatePrice: private_price,
  5434. IsMedicineInsurance: 1,
  5435. SettleType: settle_accounts_type,
  5436. SettleStartTime: start_time,
  5437. SettleEndTime: end_time,
  5438. Creator: roles.AdminUserId,
  5439. Modify: roles.AdminUserId,
  5440. FaPiaoNumber: fapiao_number,
  5441. FaPiaoCode: fapiao_code,
  5442. PType: 2,
  5443. Diagnosis: diagnosis_id,
  5444. }
  5445. err = service.CreateOrder(order)
  5446. if err != nil {
  5447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5448. return
  5449. }
  5450. for _, item := range res.Output.Result {
  5451. temp := strings.Split(item.FeedetlSn, "-")
  5452. var advice_id int64 = 0
  5453. var project_id int64 = 0
  5454. var types int64 = 0
  5455. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5456. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5457. if temp[1] == "1" {
  5458. advice_id = id
  5459. project_id = 0
  5460. } else if temp[1] == "2" {
  5461. advice_id = 0
  5462. project_id = id
  5463. }
  5464. info := &models.HisOrderInfo{
  5465. OrderNumber: order.Number,
  5466. FeedetlSn: item.FeedetlSn,
  5467. UploadDate: time.Now().Unix(),
  5468. AdviceId: advice_id,
  5469. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5470. Cnt: item.Cnt,
  5471. Pric: float64(item.Pric),
  5472. PatientId: his.PatientId,
  5473. PricUplmtAmt: item.PricUplmtAmt,
  5474. SelfpayProp: item.SelfpayProp,
  5475. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5476. OverlmtAmt: item.OverlmtAmt,
  5477. PreselfpayAmt: item.PreselfpayAmt,
  5478. BasMednFlag: item.BasMednFlag,
  5479. MedChrgitmType: item.MedChrgitmType,
  5480. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5481. Status: 1,
  5482. Memo: item.Memo,
  5483. Mtime: time.Now().Unix(),
  5484. InscpScpAmt: item.InscpScpAmt,
  5485. DrtReimFlag: item.DrtReimFlag,
  5486. Ctime: time.Now().Unix(),
  5487. ListSpItemFlag: item.ListSpItemFlag,
  5488. ChldMedcFlag: item.ChldMedcFlag,
  5489. LmtUsedFlag: item.LmtUsedFlag,
  5490. ChrgitmLv: item.ChrgitmLv,
  5491. UserOrgId: adminUser.CurrentOrgId,
  5492. HisPatientId: his.ID,
  5493. OrderId: order.ID,
  5494. ProjectId: project_id,
  5495. Type: types,
  5496. }
  5497. service.CreateOrderInfo(info)
  5498. }
  5499. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5500. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5501. var total float64
  5502. for _, item := range prescriptions {
  5503. if item.Type == 1 { //药品
  5504. for _, subItem := range item.HisDoctorAdviceInfo {
  5505. total = total + (subItem.Price * subItem.PrescribingNumber)
  5506. }
  5507. }
  5508. if item.Type == 2 { //项目
  5509. for _, subItem := range item.HisPrescriptionProject {
  5510. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5511. total = total + (subItem.Price * cnt)
  5512. }
  5513. }
  5514. }
  5515. for _, item := range prescriptions {
  5516. for _, subItem := range item.HisAdditionalCharge {
  5517. total = total + (subItem.Price * float64(subItem.Count))
  5518. }
  5519. }
  5520. var allTotal string
  5521. if adminUser.CurrentOrgId == 9919 {
  5522. allTotal = fmt.Sprintf("%.4f", total)
  5523. } else {
  5524. allTotal = fmt.Sprintf("%.4f", total)
  5525. }
  5526. if res.Infcode == 0 {
  5527. var rf []*ResultFive
  5528. json.Unmarshal([]byte(his.Iinfo), &rf)
  5529. chrg_bchno := chrg_bchno
  5530. cert_no := his.Certno
  5531. var insutypes []string
  5532. var insutype string
  5533. var is390 int = 0
  5534. var is310 int = 0
  5535. for _, item := range rf {
  5536. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5537. insutypes = append(insutypes, item.Insutype)
  5538. }
  5539. }
  5540. if len(insutypes) == 1 {
  5541. insutype = insutypes[0]
  5542. } else {
  5543. for _, i := range insutypes {
  5544. if i == "390" {
  5545. is390 = 1
  5546. }
  5547. if i == "310" {
  5548. is310 = 1
  5549. }
  5550. }
  5551. }
  5552. if is390 == 1 {
  5553. insutype = "390"
  5554. }
  5555. if is310 == 1 {
  5556. insutype = "310"
  5557. }
  5558. if len(insutypes) == 0 {
  5559. insutype = "310"
  5560. }
  5561. if len(insutypes) == 2 {
  5562. insutype = strconv.FormatInt(his.SocialType, 10)
  5563. }
  5564. insutype = strconv.FormatInt(his.SocialType, 10)
  5565. //insutype = "390"
  5566. if his.IdCardType == 1 {
  5567. // cert_no = his.MedicalInsuranceNumber
  5568. cert_no = his.Certno
  5569. } else {
  5570. cert_no = his.Certno
  5571. }
  5572. var res ResultSeven
  5573. var resSeven10265 ResultSeven10265
  5574. var src_resquest string
  5575. var result2 string
  5576. var acct_used_flag string
  5577. fmt.Println("pay_way")
  5578. fmt.Println(pay_way)
  5579. fmt.Println("pay_way")
  5580. if pay_way == 4 {
  5581. acct_used_flag = "1"
  5582. } else {
  5583. acct_used_flag = "0"
  5584. }
  5585. if miConfig.MdtrtareaAdmvs == "421300" {
  5586. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5587. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5588. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5589. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5590. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5591. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5592. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5593. resp, requestErr := http.Get(api)
  5594. if requestErr != nil {
  5595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5596. return
  5597. }
  5598. body, ioErr := ioutil.ReadAll(resp.Body)
  5599. if ioErr != nil {
  5600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. var respJSON map[string]interface{}
  5605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5608. return
  5609. }
  5610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5611. result, _ := json.Marshal(respJSON)
  5612. if miConfig.Code == "H15049901371" {
  5613. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5614. utils.ErrorLog("解析失败:%v", err)
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. return
  5617. }
  5618. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5619. res.Output = resSeven10265.Output
  5620. res.ErrMsg = resSeven10265.ErrMsg
  5621. res.Cainfo = resSeven10265.Cainfo
  5622. res.WarnMsg = resSeven10265.WarnMsg
  5623. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5624. res.Infcode = infocode
  5625. } else {
  5626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5627. utils.ErrorLog("解析失败:%v", err)
  5628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5629. return
  5630. }
  5631. }
  5632. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5633. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5634. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5635. bas := strings.Split(psn_info.CardInfo, "|")
  5636. if his.IdCardType == 1 {
  5637. cert_no = bas[2]
  5638. } else if his.IdCardType == 3 {
  5639. cert_no = his.Certno
  5640. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5641. } else if his.IdCardType == 4 {
  5642. cert_no = his.Certno
  5643. psn_info.VerifyNumber = token
  5644. }
  5645. var api string
  5646. if miConfig.MdtrtareaAdmvs == "320921" {
  5647. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5648. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5649. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5651. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5652. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5653. "&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
  5654. } else {
  5655. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5656. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5657. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5658. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5659. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5660. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5661. "&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
  5662. }
  5663. resp, requestErr := http.Get(api)
  5664. if requestErr != nil {
  5665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5666. return
  5667. }
  5668. body, ioErr := ioutil.ReadAll(resp.Body)
  5669. if ioErr != nil {
  5670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5672. return
  5673. }
  5674. var respJSON map[string]interface{}
  5675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5678. return
  5679. }
  5680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5681. result, _ := json.Marshal(respJSON)
  5682. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5683. utils.ErrorLog("解析失败:%v", err)
  5684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5685. return
  5686. }
  5687. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5688. res.Output = resSeven10265.Output
  5689. res.ErrMsg = resSeven10265.ErrMsg
  5690. res.Cainfo = resSeven10265.Cainfo
  5691. res.WarnMsg = resSeven10265.WarnMsg
  5692. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5693. res.Infcode = infocode
  5694. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5695. 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)
  5696. //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)
  5697. var dat map[string]interface{}
  5698. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5699. fmt.Println(dat)
  5700. } else {
  5701. fmt.Println(err)
  5702. }
  5703. saveLog(result2, src_resquest, "2207", "结算")
  5704. userJSONBytes, _ := json.Marshal(dat)
  5705. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5706. utils.ErrorLog("解析失败:%v", err)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5708. return
  5709. }
  5710. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5711. res.Output = resSeven10265.Output
  5712. res.ErrMsg = resSeven10265.ErrMsg
  5713. res.Cainfo = resSeven10265.Cainfo
  5714. res.WarnMsg = resSeven10265.WarnMsg
  5715. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5716. res.Infcode = infocode
  5717. } else {
  5718. if miConfig.Code == "H15049901371" {
  5719. //赤峰地区国家医保医疗类别
  5720. //职工透析:医疗类别选特殊情况门诊990502
  5721. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5722. var med_type string
  5723. if his.Insutype == "390" {
  5724. if reg_type == 14 {
  5725. med_type = "9933"
  5726. } else if reg_type == 11 {
  5727. med_type = "11"
  5728. }
  5729. } else if his.Insutype == "310" {
  5730. if reg_type == 14 {
  5731. med_type = "990502"
  5732. } else if reg_type == 11 {
  5733. med_type = "11"
  5734. }
  5735. }
  5736. 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)
  5737. } else {
  5738. 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)
  5739. }
  5740. //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)
  5741. var dat map[string]interface{}
  5742. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5743. fmt.Println(dat)
  5744. } else {
  5745. fmt.Println(err)
  5746. }
  5747. saveLog(result2, src_resquest, "2207", "结算")
  5748. userJSONBytes, _ := json.Marshal(dat)
  5749. if miConfig.Code == "H15049901371" {
  5750. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5751. utils.ErrorLog("解析失败:%v", err)
  5752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5753. return
  5754. }
  5755. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5756. res.Output = resSeven10265.Output
  5757. res.ErrMsg = resSeven10265.ErrMsg
  5758. res.Cainfo = resSeven10265.Cainfo
  5759. res.WarnMsg = resSeven10265.WarnMsg
  5760. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5761. res.Infcode = infocode
  5762. } else {
  5763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5764. utils.ErrorLog("解析失败:%v", err)
  5765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5766. return
  5767. }
  5768. }
  5769. }
  5770. if res.Infcode != 0 {
  5771. errlog := &models.HisOrderError{
  5772. UserOrgId: adminUser.CurrentOrgId,
  5773. Ctime: time.Now().Unix(),
  5774. Mtime: time.Now().Unix(),
  5775. Number: chrg_bchno,
  5776. ErrMsg: res.ErrMsg,
  5777. Status: 1,
  5778. PatientId: id,
  5779. RecordTime: recordDateTime,
  5780. Stage: 6,
  5781. }
  5782. service.CreateErrMsgLog(errlog)
  5783. c.ServeSuccessJSON(map[string]interface{}{
  5784. "failed_code": -10,
  5785. "msg": res.ErrMsg,
  5786. })
  5787. return
  5788. } else {
  5789. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5790. order.OrderStatus = 2
  5791. order.Status = 1
  5792. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5793. order.SetlId = res.Output.Setlinfo.SetlID
  5794. order.PsnNo = res.Output.Setlinfo.PsnNo
  5795. order.PsnName = res.Output.Setlinfo.PsnName
  5796. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5797. order.Certno = res.Output.Setlinfo.Certno
  5798. order.Gend = res.Output.Setlinfo.Gend
  5799. order.Naty = res.Output.Setlinfo.Naty
  5800. order.Age = res.Output.Setlinfo.Age
  5801. order.Insutype = res.Output.Setlinfo.Insutype
  5802. order.PsnType = res.Output.Setlinfo.PsnType
  5803. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5804. order.SetlTime = res.Output.Setlinfo.SetlTime
  5805. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5806. if res.Output.Setlinfo.MedType == "140101" {
  5807. order.MedType = "14"
  5808. } else {
  5809. order.MedType = res.Output.Setlinfo.MedType
  5810. }
  5811. if reg_type == 1112 {
  5812. order.MedType = "1112"
  5813. }
  5814. if reg_type == 1111 {
  5815. order.MedType = "1111"
  5816. }
  5817. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5818. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5819. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5820. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5821. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5822. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5823. order.HifpPay = res.Output.Setlinfo.HifpPay
  5824. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5825. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5826. order.HifesPay = res.Output.Setlinfo.HifesPay
  5827. order.HifobPay = res.Output.Setlinfo.HifobPay
  5828. order.MafPay = res.Output.Setlinfo.MafPay
  5829. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5830. order.OthPay = res.Output.Setlinfo.OthPay
  5831. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5832. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5833. order.AcctPay = res.Output.Setlinfo.AcctPay
  5834. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5835. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5836. order.Balc = res.Output.Setlinfo.Balc
  5837. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5838. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5839. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5840. order.ClrType = res.Output.Setlinfo.ClrType
  5841. order.ClrWay = res.Output.Setlinfo.ClrWay
  5842. order.Creator = order.Creator
  5843. order.Modify = roles.AdminUserId
  5844. order.RequestLog = src_resquest
  5845. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5846. detailStr := string(setlDetail)
  5847. order.SetlDetail = detailStr
  5848. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5849. err = service.UpDateOrder(order)
  5850. if err == nil {
  5851. //判断是否使用了押金
  5852. if dec_way == "true" {
  5853. tmpstring := strconv.FormatInt(order.ID, 10)
  5854. order.Decimal = decimal
  5855. service.UpDateOrder(order)
  5856. //扣押金
  5857. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5858. if errmsg != nil {
  5859. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5860. return
  5861. }
  5862. }
  5863. c.ServeSuccessJSON(map[string]interface{}{
  5864. "msg": "结算成功",
  5865. })
  5866. } else {
  5867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5868. return
  5869. }
  5870. }
  5871. } else {
  5872. adminUser := c.GetAdminUserInfo()
  5873. errlog := &models.HisOrderError{
  5874. UserOrgId: adminUser.CurrentOrgId,
  5875. Ctime: time.Now().Unix(),
  5876. Mtime: time.Now().Unix(),
  5877. ErrMsg: res.ErrMsg,
  5878. Status: 1,
  5879. PatientId: id,
  5880. RecordTime: recordDateTime,
  5881. Stage: 4,
  5882. }
  5883. service.CreateErrMsgLog(errlog)
  5884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5885. return
  5886. }
  5887. } else {
  5888. adminUser := c.GetAdminUserInfo()
  5889. errlog := &models.HisOrderError{
  5890. UserOrgId: adminUser.CurrentOrgId,
  5891. Ctime: time.Now().Unix(),
  5892. Mtime: time.Now().Unix(),
  5893. ErrMsg: res.ErrMsg,
  5894. Status: 1,
  5895. PatientId: id,
  5896. RecordTime: recordDateTime,
  5897. Stage: 4,
  5898. }
  5899. service.CreateErrMsgLog(errlog)
  5900. c.ServeSuccessJSON(map[string]interface{}{
  5901. "failed_code": -10,
  5902. "msg": res.ErrMsg,
  5903. })
  5904. return
  5905. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5906. //return
  5907. }
  5908. }
  5909. }
  5910. } else if tempOrder.ID > 0 {
  5911. if tempOrder.IsPre == 1 {
  5912. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5913. var rf []*ResultFive
  5914. json.Unmarshal([]byte(his.Iinfo), &rf)
  5915. chrg_bchno := tempOrder.Number
  5916. cert_no := his.Certno
  5917. var insutypes []string
  5918. var insutype string
  5919. var is390 int = 0
  5920. var is310 int = 0
  5921. for _, item := range rf {
  5922. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5923. insutypes = append(insutypes, item.Insutype)
  5924. }
  5925. }
  5926. if len(insutypes) == 1 {
  5927. insutype = insutypes[0]
  5928. } else {
  5929. for _, i := range insutypes {
  5930. if i == "390" {
  5931. is390 = 1
  5932. }
  5933. if i == "310" {
  5934. is310 = 1
  5935. }
  5936. }
  5937. }
  5938. if is390 == 1 {
  5939. insutype = "390"
  5940. }
  5941. if is310 == 1 {
  5942. insutype = "310"
  5943. }
  5944. if len(insutypes) == 0 {
  5945. insutype = "310"
  5946. }
  5947. if len(insutypes) == 2 {
  5948. insutype = strconv.FormatInt(his.SocialType, 64)
  5949. }
  5950. //insutype = "390"
  5951. if his.IdCardType == 1 {
  5952. // cert_no = his.MedicalInsuranceNumber
  5953. cert_no = his.Certno
  5954. } else {
  5955. cert_no = his.Certno
  5956. }
  5957. var res ResultSeven
  5958. var resSeven10265 ResultSeven10265
  5959. var src_resquest string
  5960. var result2 string
  5961. var acct_used_flag string
  5962. fmt.Println("pay_way")
  5963. fmt.Println(pay_way)
  5964. fmt.Println("pay_way")
  5965. if pay_way == 4 {
  5966. acct_used_flag = "1"
  5967. } else {
  5968. acct_used_flag = "0"
  5969. }
  5970. if miConfig.MdtrtareaAdmvs == "421300" {
  5971. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5972. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5973. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5975. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5976. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5977. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5978. resp, requestErr := http.Get(api)
  5979. if requestErr != nil {
  5980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5981. return
  5982. }
  5983. body, ioErr := ioutil.ReadAll(resp.Body)
  5984. if ioErr != nil {
  5985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5987. return
  5988. }
  5989. var respJSON map[string]interface{}
  5990. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5996. result, _ := json.Marshal(respJSON)
  5997. fmt.Println("log")
  5998. fmt.Println(string(result))
  5999. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6000. utils.ErrorLog("解析失败:%v", err)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6005. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6006. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6007. //psn_info, _ := service.GetPsnByPatientId(id)
  6008. bas := strings.Split(psn_info.CardInfo, "|")
  6009. if his.IdCardType == 1 {
  6010. cert_no = bas[2]
  6011. } else {
  6012. cert_no = bas[1]
  6013. }
  6014. //江苏地区国家医保医疗类别
  6015. //职工透析:医疗类别选特殊情况门诊9933
  6016. //居民血透门慢: 医疗类别选门诊慢病1402
  6017. //var med_type string
  6018. //if his.Insutype == "310" {
  6019. // if reg_type == 14 {
  6020. // med_type = "9933"
  6021. // } else if reg_type == 11 {
  6022. // med_type = "11"
  6023. //
  6024. // }
  6025. //} else if his.Insutype == "390" {
  6026. // if reg_type == 14 {
  6027. // med_type = "1402"
  6028. // } else if reg_type == 11 {
  6029. // med_type = "11"
  6030. // }
  6031. //}
  6032. var api string
  6033. if miConfig.MdtrtareaAdmvs == "320921" {
  6034. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6040. "&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
  6041. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6042. } else {
  6043. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6044. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6045. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6046. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6048. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6049. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6050. "&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
  6051. }
  6052. resp, requestErr := http.Get(api)
  6053. if requestErr != nil {
  6054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6055. return
  6056. }
  6057. body, ioErr := ioutil.ReadAll(resp.Body)
  6058. if ioErr != nil {
  6059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6061. return
  6062. }
  6063. var respJSON map[string]interface{}
  6064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6067. return
  6068. }
  6069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6070. result, _ := json.Marshal(respJSON)
  6071. fmt.Println("log")
  6072. fmt.Println(string(result))
  6073. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6074. utils.ErrorLog("解析失败:%v", err)
  6075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6076. return
  6077. }
  6078. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6079. res.Output = resSeven10265.Output
  6080. res.ErrMsg = resSeven10265.ErrMsg
  6081. res.Cainfo = resSeven10265.Cainfo
  6082. res.WarnMsg = resSeven10265.WarnMsg
  6083. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6084. res.Infcode = infocode
  6085. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6086. 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)
  6087. var dat map[string]interface{}
  6088. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6089. fmt.Println(dat)
  6090. } else {
  6091. fmt.Println(err)
  6092. }
  6093. saveLog(result2, src_resquest, "2207", "结算")
  6094. userJSONBytes, _ := json.Marshal(dat)
  6095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6096. utils.ErrorLog("解析失败:%v", err)
  6097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6098. return
  6099. }
  6100. } else {
  6101. var src_resquest string
  6102. if miConfig.Code == "H15049901371" {
  6103. //赤峰地区国家医保医疗类别
  6104. //职工透析:医疗类别选特殊情况门诊990502
  6105. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6106. var med_type string
  6107. if his.Insutype == "390" {
  6108. if reg_type == 14 {
  6109. med_type = "9933"
  6110. } else if reg_type == 11 {
  6111. med_type = "11"
  6112. }
  6113. } else if his.Insutype == "310" {
  6114. if reg_type == 14 {
  6115. med_type = "990502"
  6116. } else if reg_type == 11 {
  6117. med_type = "11"
  6118. }
  6119. }
  6120. 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)
  6121. } else {
  6122. 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)
  6123. }
  6124. var dat map[string]interface{}
  6125. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6126. fmt.Println(dat)
  6127. } else {
  6128. fmt.Println(err)
  6129. }
  6130. saveLog(result2, src_resquest, "2207", "结算")
  6131. userJSONBytes, _ := json.Marshal(dat)
  6132. if miConfig.Code == "H15049901371" {
  6133. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6134. utils.ErrorLog("解析失败:%v", err)
  6135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6136. return
  6137. }
  6138. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6139. res.Output = resSeven10265.Output
  6140. res.ErrMsg = resSeven10265.ErrMsg
  6141. res.Cainfo = resSeven10265.Cainfo
  6142. res.WarnMsg = resSeven10265.WarnMsg
  6143. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6144. res.Infcode = infocode
  6145. } else {
  6146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6147. utils.ErrorLog("解析失败:%v", err)
  6148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6149. return
  6150. }
  6151. }
  6152. }
  6153. if res.Infcode != 0 {
  6154. errlog := &models.HisOrderError{
  6155. UserOrgId: adminUser.CurrentOrgId,
  6156. Ctime: time.Now().Unix(),
  6157. Mtime: time.Now().Unix(),
  6158. Number: chrg_bchno,
  6159. ErrMsg: res.ErrMsg,
  6160. Status: 1,
  6161. PatientId: id,
  6162. RecordTime: recordDateTime,
  6163. Stage: 6,
  6164. }
  6165. service.CreateErrMsgLog(errlog)
  6166. c.ServeSuccessJSON(map[string]interface{}{
  6167. "failed_code": -10,
  6168. "msg": res.ErrMsg,
  6169. })
  6170. return
  6171. } else {
  6172. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6173. order.OrderStatus = 2
  6174. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6175. order.SetlId = res.Output.Setlinfo.SetlID
  6176. order.PsnNo = res.Output.Setlinfo.PsnNo
  6177. order.PsnName = res.Output.Setlinfo.PsnName
  6178. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6179. order.Certno = res.Output.Setlinfo.Certno
  6180. order.Gend = res.Output.Setlinfo.Gend
  6181. order.Naty = res.Output.Setlinfo.Naty
  6182. order.Age = res.Output.Setlinfo.Age
  6183. order.Insutype = res.Output.Setlinfo.Insutype
  6184. order.PsnType = res.Output.Setlinfo.PsnType
  6185. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6186. order.SetlTime = res.Output.Setlinfo.SetlTime
  6187. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6188. //order.MedType = res.Output.Setlinfo.MedType
  6189. if reg_type == 1112 {
  6190. order.MedType = "1112"
  6191. }
  6192. if reg_type == 1111 {
  6193. order.MedType = "1111"
  6194. }
  6195. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6196. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6197. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6198. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6199. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6200. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6201. order.HifpPay = res.Output.Setlinfo.HifpPay
  6202. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6203. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6204. order.HifesPay = res.Output.Setlinfo.HifesPay
  6205. order.HifobPay = res.Output.Setlinfo.HifobPay
  6206. order.MafPay = res.Output.Setlinfo.MafPay
  6207. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6208. order.OthPay = res.Output.Setlinfo.OthPay
  6209. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6210. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6211. order.AcctPay = res.Output.Setlinfo.AcctPay
  6212. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6213. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6214. order.Balc = res.Output.Setlinfo.Balc
  6215. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6216. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6217. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6218. order.ClrWay = res.Output.Setlinfo.ClrWay
  6219. order.Creator = order.Creator
  6220. order.Modify = roles.AdminUserId
  6221. order.RequestLog = src_resquest
  6222. order.Diagnosis = diagnosis_id
  6223. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6224. detailStr := string(setlDetail)
  6225. order.SetlDetail = detailStr
  6226. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6227. err = service.UpDateOrder(order)
  6228. if err == nil {
  6229. //判断是否使用了押金
  6230. if dec_way == "true" {
  6231. tmpstring := strconv.FormatInt(order.ID, 10)
  6232. //扣押金
  6233. order.Decimal = decimal
  6234. service.UpDateOrder(order)
  6235. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6236. if errmsg != nil {
  6237. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6238. return
  6239. }
  6240. }
  6241. c.ServeSuccessJSON(map[string]interface{}{
  6242. "msg": "结算成功",
  6243. })
  6244. } else {
  6245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6246. return
  6247. }
  6248. }
  6249. }
  6250. }
  6251. }
  6252. //func (c *HisApiController) GetPreUploadInfo() {
  6253. // id, _ := c.GetInt64("id")
  6254. // record_time := c.GetString("record_time")
  6255. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6256. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6257. //
  6258. // timeLayout := "2006-01-02"
  6259. // loc, _ := time.LoadLocation("Local")
  6260. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6261. // if err != nil {
  6262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6263. // return
  6264. // }
  6265. // recordDateTime := theTime.Unix()
  6266. // adminUser := c.GetAdminUserInfo()
  6267. //
  6268. // var prescriptions []*models.HisPrescription
  6269. //
  6270. // var start_time int64
  6271. // var end_time int64
  6272. //
  6273. // data := make(map[string]interface{})
  6274. // if settle_accounts_type == 1 { //日结
  6275. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6276. // data["pre"] = prescriptions
  6277. //
  6278. // } else { //月结
  6279. // start_time_str := c.GetString("start_time")
  6280. // end_time_str := c.GetString("end_time")
  6281. // timeLayout := "2006-01-02"
  6282. // loc, _ := time.LoadLocation("Local")
  6283. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6284. // if err != nil {
  6285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6286. // return
  6287. // }
  6288. // recordStartTime := theStartTime.Unix()
  6289. // start_time = recordStartTime
  6290. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6291. // if err != nil {
  6292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6293. // return
  6294. // }
  6295. // recordEndTime := theEndTime.Unix()
  6296. // end_time = recordEndTime
  6297. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6298. // data["pre"] = prescriptions
  6299. //
  6300. // }
  6301. //
  6302. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6303. //
  6304. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6305. // timestamp := time.Now().Unix()
  6306. // tempTime := time.Unix(timestamp, 0)
  6307. // timeFormat := tempTime.Format("20060102150405")
  6308. // chrgBchno := rand.Intn(100000) + 10000
  6309. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6310. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6311. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6312. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6313. // strconv.FormatInt(his.PatientId, 10)
  6314. // client := &http.Client{}
  6315. // data["psn_no"] = his.PsnNo
  6316. // data["mdtrt_id"] = his.Number
  6317. // data["chrg_bchno"] = chrg_bchno
  6318. // data["org_name"] = miConfig.OrgName
  6319. // data["doctor"] = roles.UserName
  6320. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6321. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6322. // data["fixmedins_code"] = miConfig.Code
  6323. // data["dept_code"] = department.Number
  6324. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6325. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6326. // data["secret_key"] = miConfig.SecretKey
  6327. // var ids []int64
  6328. //
  6329. // for _, item := range prescriptions {
  6330. // ids = append(ids, item.ID)
  6331. // }
  6332. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6333. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6334. // bytesData, _ := json.Marshal(data)
  6335. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6336. // resp, _ := client.Do(req)
  6337. // defer resp.Body.Close()
  6338. // body, ioErr := ioutil.ReadAll(resp.Body)
  6339. // if ioErr != nil {
  6340. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6342. // return
  6343. // }
  6344. // var respJSON map[string]interface{}
  6345. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6346. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6348. // return
  6349. // }
  6350. //
  6351. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6352. // userJSONBytes, _ := json.Marshal(respJSON)
  6353. // var res ResultFour
  6354. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6355. // utils.ErrorLog("解析失败:%v", err)
  6356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6357. // return
  6358. // }
  6359. //
  6360. // if res.Infcode == 0 {
  6361. // order := &models.HisOrder{
  6362. // UserOrgId: adminUser.CurrentOrgId,
  6363. // HisPatientId: his.ID,
  6364. // PatientId: his.PatientId,
  6365. // SettleAccountsDate: recordDateTime,
  6366. // Ctime: time.Now().Unix(),
  6367. // Mtime: time.Now().Unix(),
  6368. // Status: 1,
  6369. // Number: chrg_bchno,
  6370. // Infcode: res.Infcode,
  6371. // WarnMsg: res.WarnMsg,
  6372. // Cainfo: res.Cainfo,
  6373. // ErrMsg: res.ErrMsg,
  6374. // RespondTime: res.RefmsgTime,
  6375. // InfRefmsgid: res.InfRefmsgid,
  6376. // OrderStatus: 1,
  6377. // IsMedicineInsurance: 1,
  6378. // SettleType: settle_accounts_type,
  6379. // SettleStartTime: start_time,
  6380. // SettleEndTime: end_time,
  6381. // Creator: roles.ID,
  6382. // Modify: roles.ID,
  6383. // PType: 2,
  6384. // }
  6385. // err = service.CreateOrder(order)
  6386. // if err != nil {
  6387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6388. // return
  6389. // }
  6390. //
  6391. // for _, item := range res.Output.Result {
  6392. // temp := strings.Split(item.FeedetlSn, "-")
  6393. // var advice_id int64 = 0
  6394. // var project_id int64 = 0
  6395. // var types int64 = 0
  6396. //
  6397. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6398. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6399. //
  6400. // if temp[1] == "1" {
  6401. // advice_id = id
  6402. // project_id = 0
  6403. // } else if temp[1] == "2" {
  6404. // advice_id = 0
  6405. // project_id = id
  6406. // }
  6407. //
  6408. // info := &models.HisOrderInfo{
  6409. // OrderNumber: order.Number,
  6410. // FeedetlSn: item.FeedetlSn,
  6411. // UploadDate: time.Now().Unix(),
  6412. // AdviceId: advice_id,
  6413. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6414. // Cnt: item.Cnt,
  6415. // Pric: float64(item.Pric),
  6416. // PatientId: his.PatientId,
  6417. // PricUplmtAmt: item.PricUplmtAmt,
  6418. // SelfpayProp: item.SelfpayProp,
  6419. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6420. // OverlmtAmt: item.OverlmtAmt,
  6421. // PreselfpayAmt: item.PreselfpayAmt,
  6422. // BasMednFlag: item.BasMednFlag,
  6423. // MedChrgitmType: item.MedChrgitmType,
  6424. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6425. // Status: 1,
  6426. // Memo: item.Memo,
  6427. // Mtime: time.Now().Unix(),
  6428. // InscpScpAmt: item.InscpScpAmt,
  6429. // DrtReimFlag: item.DrtReimFlag,
  6430. // Ctime: time.Now().Unix(),
  6431. // ListSpItemFlag: item.ListSpItemFlag,
  6432. // ChldMedcFlag: item.ChldMedcFlag,
  6433. // LmtUsedFlag: item.LmtUsedFlag,
  6434. // ChrgitmLv: item.ChrgitmLv,
  6435. // UserOrgId: adminUser.CurrentOrgId,
  6436. // HisPatientId: his.ID,
  6437. // OrderId: order.ID,
  6438. // ProjectId: project_id,
  6439. // Type: types,
  6440. // }
  6441. // service.CreateOrderInfo(info)
  6442. //
  6443. // }
  6444. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6445. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6446. //
  6447. // var total float64
  6448. // for _, item := range prescriptions {
  6449. // if item.Type == 1 { //药品
  6450. // for _, subItem := range item.HisDoctorAdviceInfo {
  6451. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6452. // }
  6453. // }
  6454. // if item.Type == 2 { //项目
  6455. // for _, subItem := range item.HisPrescriptionProject {
  6456. // total = total + (subItem.Price * float64(subItem.Count))
  6457. // }
  6458. // }
  6459. // }
  6460. //
  6461. // for _, item := range prescriptions {
  6462. // for _, subItem := range item.HisAdditionalCharge {
  6463. // total = total + (subItem.Price * float64(subItem.Count))
  6464. // }
  6465. // }
  6466. //
  6467. // allTotal := fmt.Sprintf("%.2f", total)
  6468. // if res.Infcode == 0 {
  6469. // var rf []*ResultFive
  6470. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6471. // psn_no := his.PsnNo
  6472. // mdtrt_id := his.Number
  6473. // chrg_bchno := chrg_bchno
  6474. // cert_no := his.Certno
  6475. // insutype := rf[0].Insutype
  6476. //
  6477. // if his.IdCardType == 1 {
  6478. // cert_no = his.MedicalInsuranceNumber
  6479. //
  6480. // } else {
  6481. //
  6482. // cert_no = his.Certno
  6483. //
  6484. // }
  6485. //
  6486. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6487. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6488. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6489. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6490. // resp, requestErr := http.Get(api)
  6491. // if requestErr != nil {
  6492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6493. // return
  6494. // }
  6495. // defer resp.Body.Close()
  6496. // body, ioErr := ioutil.ReadAll(resp.Body)
  6497. // if ioErr != nil {
  6498. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6500. // return
  6501. // }
  6502. // var respJSON map[string]interface{}
  6503. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6504. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6506. // return
  6507. // }
  6508. // fmt.Println(respJSON)
  6509. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6510. // userJSONBytes, _ := json.Marshal(respJSON)
  6511. // var res ResultSeven
  6512. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6513. // utils.ErrorLog("解析失败:%v", err)
  6514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6515. // return
  6516. // }
  6517. // if res.Infcode != 0 {
  6518. // errlog := &models.HisOrderError{
  6519. // UserOrgId: adminUser.CurrentOrgId,
  6520. // Ctime: time.Now().Unix(),
  6521. // Mtime: time.Now().Unix(),
  6522. // Number: chrg_bchno,
  6523. // ErrMsg: res.ErrMsg,
  6524. // Status: 1,
  6525. // PatientId: id,
  6526. // RecordTime: recordDateTime,
  6527. // Stage: 7,
  6528. // }
  6529. // service.CreateErrMsgLog(errlog)
  6530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6531. // return
  6532. // } else {
  6533. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6534. // order.OrderStatus = 1
  6535. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6536. // order.SetlId = res.Output.Setlinfo.SetlID
  6537. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6538. // order.PsnName = res.Output.Setlinfo.PsnName
  6539. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6540. // order.Certno = res.Output.Setlinfo.Certno
  6541. // order.Gend = res.Output.Setlinfo.Gend
  6542. // order.Naty = res.Output.Setlinfo.Naty
  6543. // order.Age = res.Output.Setlinfo.Age
  6544. // order.Insutype = res.Output.Setlinfo.Insutype
  6545. // order.PsnType = res.Output.Setlinfo.PsnType
  6546. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6547. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6548. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6549. // order.MedType = res.Output.Setlinfo.MedType
  6550. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6551. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6552. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6553. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6554. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6555. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6556. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6557. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6558. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6559. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6560. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6561. // order.MafPay = res.Output.Setlinfo.MafPay
  6562. // order.OthPay = res.Output.Setlinfo.OthPay
  6563. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6564. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6565. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6566. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6567. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6568. // order.Balc = res.Output.Setlinfo.Balc
  6569. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6570. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6571. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6572. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6573. // order.Creator = order.Creator
  6574. // order.Modify = roles.ID
  6575. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6576. // detailStr := string(setlDetail)
  6577. // order.SetlDetail = detailStr
  6578. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6579. // err = service.UpDateOrder(order)
  6580. // if err == nil {
  6581. // c.ServeSuccessJSON(map[string]interface{}{
  6582. // "msg": "预结算成功",
  6583. // })
  6584. // } else {
  6585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6586. // return
  6587. // }
  6588. // }
  6589. // } else {
  6590. // adminUser := c.GetAdminUserInfo()
  6591. // errlog := &models.HisOrderError{
  6592. // UserOrgId: adminUser.CurrentOrgId,
  6593. // Ctime: time.Now().Unix(),
  6594. // Mtime: time.Now().Unix(),
  6595. // ErrMsg: res.ErrMsg,
  6596. // Status: 1,
  6597. // PatientId: id,
  6598. // RecordTime: recordDateTime,
  6599. // Stage: 4,
  6600. // }
  6601. // service.CreateErrMsgLog(errlog)
  6602. //
  6603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6604. // return
  6605. // }
  6606. // } else {
  6607. // adminUser := c.GetAdminUserInfo()
  6608. // errlog := &models.HisOrderError{
  6609. // UserOrgId: adminUser.CurrentOrgId,
  6610. // Ctime: time.Now().Unix(),
  6611. // Mtime: time.Now().Unix(),
  6612. // ErrMsg: res.ErrMsg,
  6613. // Status: 1,
  6614. // PatientId: id,
  6615. // RecordTime: recordDateTime,
  6616. // Stage: 4,
  6617. // }
  6618. // service.CreateErrMsgLog(errlog)
  6619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6620. // return
  6621. // }
  6622. //
  6623. // } else {
  6624. // var total float64
  6625. // for _, item := range prescriptions {
  6626. // if item.Type == 1 { //药品
  6627. // for _, subItem := range item.HisDoctorAdviceInfo {
  6628. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6629. // }
  6630. // }
  6631. // if item.Type == 2 { //项目
  6632. // for _, subItem := range item.HisPrescriptionProject {
  6633. // total = total + (subItem.Price * float64(subItem.Count))
  6634. // }
  6635. // }
  6636. //
  6637. // for _, subItem := range item.HisAdditionalCharge {
  6638. // total = total + (subItem.Price * float64(subItem.Count))
  6639. // }
  6640. // }
  6641. //
  6642. // allTotal := fmt.Sprintf("%.2f", total)
  6643. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6644. // order := &models.HisOrder{
  6645. // UserOrgId: adminUser.CurrentOrgId,
  6646. // HisPatientId: his.ID,
  6647. // PatientId: id,
  6648. // SettleAccountsDate: recordDateTime,
  6649. // Ctime: time.Now().Unix(),
  6650. // Mtime: time.Now().Unix(),
  6651. // Status: 1,
  6652. // OrderStatus: 2,
  6653. // Number: chrg_bchno,
  6654. // MedfeeSumamt: totals,
  6655. // }
  6656. // err = service.CreateOrder(order)
  6657. // if err != nil {
  6658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6659. // return
  6660. // }
  6661. //
  6662. // var customs []*Custom
  6663. // for _, item := range prescriptions {
  6664. //
  6665. // if item.Type == 1 { //药品
  6666. // for _, subItem := range item.HisDoctorAdviceInfo {
  6667. // cus := &Custom{
  6668. // AdviceId: subItem.ID,
  6669. // ProjectId: 0,
  6670. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6671. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6672. // FeedetlSn: subItem.FeedetlSn,
  6673. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6674. // MedListCodg: subItem.MedListCodg,
  6675. // Type: 1,
  6676. // }
  6677. // customs = append(customs, cus)
  6678. // }
  6679. // }
  6680. //
  6681. // if item.Type == 2 { //项目
  6682. // for _, subItem := range item.HisPrescriptionProject {
  6683. //
  6684. // cus := &Custom{
  6685. // AdviceId: 0,
  6686. // ProjectId: subItem.ID,
  6687. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6688. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6689. // FeedetlSn: subItem.FeedetlSn,
  6690. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6691. // MedListCodg: subItem.MedListCodg,
  6692. // Type: 2,
  6693. // }
  6694. //
  6695. // customs = append(customs, cus)
  6696. // }
  6697. // }
  6698. //
  6699. // for _, item := range item.HisAdditionalCharge {
  6700. // cus := &Custom{
  6701. // ItemId: item.ID,
  6702. // AdviceId: 0,
  6703. // ProjectId: 0,
  6704. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6705. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6706. // FeedetlSn: item.FeedetlSn,
  6707. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6708. // MedListCodg: item.XtHisAddtionConfig.Code,
  6709. // Type: 3,
  6710. // }
  6711. //
  6712. // customs = append(customs, cus)
  6713. // }
  6714. //
  6715. // }
  6716. //
  6717. // for _, item := range customs {
  6718. // var advice_id int64 = 0
  6719. // var project_id int64 = 0
  6720. // var item_id int64 = 0
  6721. //
  6722. // var types int64 = 0
  6723. //
  6724. // if item.Type == 1 {
  6725. // advice_id = item.AdviceId
  6726. // project_id = 0
  6727. // item_id = 0
  6728. // } else if item.Type == 2 {
  6729. // advice_id = 0
  6730. // item_id = 0
  6731. //
  6732. // project_id = item.ProjectId
  6733. // } else if item.Type == 3 {
  6734. // advice_id = 0
  6735. // item_id = item.ItemId
  6736. // project_id = 0
  6737. // }
  6738. //
  6739. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6740. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6741. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6742. //
  6743. // info := &models.HisOrderInfo{
  6744. // OrderNumber: order.Number,
  6745. // UploadDate: time.Now().Unix(),
  6746. // AdviceId: advice_id,
  6747. // DetItemFeeSumamt: detItemFeeSumamt,
  6748. // Cnt: cut,
  6749. // Pric: pric,
  6750. // PatientId: id,
  6751. // Status: 1,
  6752. // Mtime: time.Now().Unix(),
  6753. // Ctime: time.Now().Unix(),
  6754. // UserOrgId: adminUser.CurrentOrgId,
  6755. // HisPatientId: his.ID,
  6756. // OrderId: order.ID,
  6757. // ProjectId: project_id,
  6758. // Type: types,
  6759. // ItemId: item_id,
  6760. // }
  6761. // service.CreateOrderInfo(info)
  6762. // }
  6763. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6764. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6765. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6766. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6767. // if err == nil {
  6768. // c.ServeSuccessJSON(map[string]interface{}{
  6769. // "msg": "结算成功",
  6770. // })
  6771. // } else {
  6772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6773. // return
  6774. // }
  6775. // }
  6776. //}
  6777. //上传明细-预结算-
  6778. func (c *HisApiController) GetPreUploadInfo() {
  6779. id, _ := c.GetInt64("id")
  6780. record_time := c.GetString("record_time")
  6781. his_patient_id, _ := c.GetInt64("his_patient_id")
  6782. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6783. admin_user_id, _ := c.GetInt64("admin_user_id")
  6784. diagnosis_id := c.GetString("diagnosis")
  6785. sick_type, _ := c.GetInt64("sick_type")
  6786. reg_type, _ := c.GetInt64("p_type")
  6787. begin_time := c.GetString("begin_time")
  6788. id_str := c.GetString("ids")
  6789. ids_arr := strings.Split(id_str, ",")
  6790. timeLayout := "2006-01-02"
  6791. loc, _ := time.LoadLocation("Local")
  6792. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6793. if err != nil {
  6794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6795. return
  6796. }
  6797. recordDateTime := theTime.Unix()
  6798. adminUser := c.GetAdminUserInfo()
  6799. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6800. var config []*models.HisXtDiagnoseConfig
  6801. for _, item := range diagnosis_ids {
  6802. id, _ := strconv.ParseInt(item, 10, 64)
  6803. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6804. config = append(config, &diagnosisConfig)
  6805. }
  6806. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6807. sickConfig, _ := service.FindSickById(sick_type)
  6808. var prescriptions []*models.HisPrescription
  6809. var start_time int64
  6810. var end_time int64
  6811. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6812. fmt.Println(his_patient_id)
  6813. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6814. timestamp := time.Now().Unix()
  6815. tempTime := time.Unix(timestamp, 0)
  6816. timeFormat := tempTime.Format("20060102150405")
  6817. chrgBchno := rand.Intn(100000) + 10000
  6818. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6819. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6820. var patientPrescription models.HisPrescriptionInfo
  6821. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6822. if patientPrescription.ID == 0 {
  6823. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6824. }
  6825. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6826. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6827. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6828. strconv.FormatInt(his.PatientId, 10)
  6829. var res2 ResultSix
  6830. var resSix10265 ResultSix10265
  6831. var time_stamp string
  6832. if miConfig.MdtrtareaAdmvs == "421300" {
  6833. data := make(map[string]interface{})
  6834. client := &http.Client{}
  6835. data["psn_no"] = his.PsnNo
  6836. data["mdtrt_id"] = his.Number
  6837. data["department"] = department.Name
  6838. data["org_name"] = miConfig.OrgName
  6839. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6840. data["doctor_id"] = doctor_info.DoctorNumber
  6841. data["doctor_name"] = roles.UserName
  6842. data["fixmedins_code"] = miConfig.Code
  6843. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6844. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6845. data["secret_key"] = miConfig.SecretKey
  6846. data["sick_code"] = sickConfig.CountryCode
  6847. data["sick_name"] = sickConfig.ClassName
  6848. data["begin_time"] = begin_time
  6849. data["dept"] = strconv.FormatInt(department.ID, 10)
  6850. data["config"] = config
  6851. data["opter"] = roles.UserName
  6852. fmt.Println(data)
  6853. bytesData, _ := json.Marshal(data)
  6854. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6855. resp, _ := client.Do(req)
  6856. defer resp.Body.Close()
  6857. body, ioErr := ioutil.ReadAll(resp.Body)
  6858. if ioErr != nil {
  6859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6861. return
  6862. }
  6863. var respJSON map[string]interface{}
  6864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6867. return
  6868. }
  6869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6870. userJSONBytes, _ := json.Marshal(respJSON)
  6871. fmt.Println("log")
  6872. fmt.Println(string(userJSONBytes))
  6873. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6874. utils.ErrorLog("解析失败:%v", err)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6879. data := make(map[string]interface{})
  6880. client := &http.Client{}
  6881. data["psn_no"] = his.PsnNo
  6882. data["mdtrt_id"] = his.Number
  6883. data["doctor"] = roles.UserName
  6884. data["department"] = department.Name
  6885. data["org_name"] = miConfig.OrgName
  6886. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6887. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6888. data["fixmedins_code"] = miConfig.Code
  6889. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6890. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6891. data["secret_key"] = miConfig.SecretKey
  6892. data["sick_code"] = sickConfig.CountryCode
  6893. data["sick_name"] = sickConfig.ClassName
  6894. data["begin_time"] = begin_time
  6895. data["dept"] = strconv.FormatInt(department.ID, 10)
  6896. data["config"] = config
  6897. data["url"] = miConfig.Url
  6898. data["ak"] = miConfig.AccessKey
  6899. data["cainfo"] = miConfig.Cainfo
  6900. bytesData, _ := json.Marshal(data)
  6901. var req *http.Request
  6902. if miConfig.MdtrtareaAdmvs == "320921" {
  6903. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6904. //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 +
  6905. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6906. } else {
  6907. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6908. }
  6909. resp, _ := client.Do(req)
  6910. defer resp.Body.Close()
  6911. body, ioErr := ioutil.ReadAll(resp.Body)
  6912. if ioErr != nil {
  6913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6915. return
  6916. }
  6917. var respJSON map[string]interface{}
  6918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6921. return
  6922. }
  6923. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6924. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6925. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6927. userJSONBytes, _ := json.Marshal(respJSON)
  6928. fmt.Println("log")
  6929. fmt.Println(string(userJSONBytes))
  6930. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6931. utils.ErrorLog("解析失败:%v", err)
  6932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6933. return
  6934. }
  6935. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6936. res2.Output = resSix10265.Output
  6937. res2.ErrMsg = resSix10265.ErrMsg
  6938. res2.Cainfo = resSix10265.Cainfo
  6939. res2.WarnMsg = resSix10265.WarnMsg
  6940. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6941. res2.Infcode = infocode
  6942. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6943. 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)
  6944. saveLog(result, requestLog, "2203", "上传就诊信息")
  6945. var respJSON2 map[string]interface{}
  6946. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. userJSONBytes2, _ := json.Marshal(respJSON2)
  6952. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6953. utils.ErrorLog("解析失败:%v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. } else {
  6958. var result string
  6959. var requestLog string
  6960. if miConfig.MdtrtareaAdmvs == "440781" { //
  6961. 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)
  6962. } else {
  6963. if miConfig.Code == "H15049901371" {
  6964. //赤峰地区国家医保医疗类别
  6965. //职工透析:医疗类别选特殊情况门诊990502
  6966. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6967. var med_type string
  6968. if his.Insutype == "390" {
  6969. if reg_type == 14 {
  6970. med_type = "9933"
  6971. } else if reg_type == 11 {
  6972. med_type = "11"
  6973. }
  6974. } else if his.Insutype == "310" {
  6975. if reg_type == 14 {
  6976. med_type = "990502"
  6977. } else if reg_type == 11 {
  6978. med_type = "11"
  6979. }
  6980. }
  6981. 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)
  6982. } else {
  6983. 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)
  6984. }
  6985. saveLog(result, requestLog, "2203", "上传就诊信息")
  6986. var respJSON2 map[string]interface{}
  6987. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. return
  6991. }
  6992. userJSONBytes2, _ := json.Marshal(respJSON2)
  6993. if miConfig.Code == "H15049901371" {
  6994. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6995. utils.ErrorLog("解析失败:%v", err)
  6996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6997. return
  6998. }
  6999. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7000. res2.Output = resSix10265.Output
  7001. res2.ErrMsg = resSix10265.ErrMsg
  7002. res2.Cainfo = resSix10265.Cainfo
  7003. res2.WarnMsg = resSix10265.WarnMsg
  7004. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7005. res2.Infcode = infocode
  7006. } else {
  7007. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7008. utils.ErrorLog("解析失败:%v", err)
  7009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7010. return
  7011. }
  7012. }
  7013. }
  7014. }
  7015. if res2.Infcode != 0 {
  7016. adminUser := c.GetAdminUserInfo()
  7017. errlog := &models.HisOrderError{
  7018. UserOrgId: adminUser.CurrentOrgId,
  7019. Ctime: time.Now().Unix(),
  7020. Mtime: time.Now().Unix(),
  7021. ErrMsg: res2.ErrMsg,
  7022. Status: 1,
  7023. PatientId: id,
  7024. RecordTime: recordDateTime,
  7025. Stage: 3,
  7026. }
  7027. service.CreateErrMsgLog(errlog)
  7028. c.ServeSuccessJSON(map[string]interface{}{
  7029. "failed_code": -10,
  7030. "msg": res2.ErrMsg,
  7031. })
  7032. return
  7033. } else {
  7034. his.Diagnosis = diagnosis_id
  7035. his.SickType = sickConfig.ID
  7036. his.PType = fmt.Sprintf("%d", reg_type)
  7037. service.UpdateHisPatientThree(&his)
  7038. data := make(map[string]interface{})
  7039. if settle_accounts_type == 1 { //日结
  7040. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7041. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7042. } else {
  7043. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7044. }
  7045. data["pre"] = prescriptions
  7046. } else { //月结
  7047. start_time_str := c.GetString("start_time")
  7048. end_time_str := c.GetString("end_time")
  7049. timeLayout := "2006-01-02"
  7050. loc, _ := time.LoadLocation("Local")
  7051. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7052. if err != nil {
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7054. return
  7055. }
  7056. recordStartTime := theStartTime.Unix()
  7057. start_time = recordStartTime
  7058. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7059. if err != nil {
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7061. return
  7062. }
  7063. recordEndTime := theEndTime.Unix()
  7064. end_time = recordEndTime
  7065. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7066. data["pre"] = prescriptions
  7067. }
  7068. client := &http.Client{}
  7069. data["psn_no"] = his.PsnNo
  7070. data["mdtrt_id"] = his.Number
  7071. data["chrg_bchno"] = chrg_bchno
  7072. data["org_name"] = miConfig.OrgName
  7073. data["doctor"] = roles.UserName
  7074. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7075. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7076. data["fixmedins_code"] = miConfig.Code
  7077. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7078. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7079. data["dept_code"] = "15"
  7080. } else {
  7081. data["dept_code"] = department.Number
  7082. }
  7083. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7084. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7085. data["secret_key"] = miConfig.SecretKey
  7086. data["url"] = miConfig.Url
  7087. data["ak"] = miConfig.AccessKey
  7088. data["new_doctor_name"] = patientPrescription.Doctor
  7089. data["diag_code"] = sickConfig.CountryCode
  7090. data["time_stamp"] = time_stamp
  7091. data["cainfo"] = miConfig.Cainfo
  7092. var ids []int64
  7093. for _, item := range prescriptions {
  7094. ids = append(ids, item.ID)
  7095. }
  7096. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7097. if config.IsOpen == 1 { //对接了医保,走医保流程
  7098. var res ResultFour
  7099. var resFour10265 ResultFour10265
  7100. if miConfig.MdtrtareaAdmvs == "421300" {
  7101. bytesData, _ := json.Marshal(data)
  7102. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7103. resp, _ := client.Do(req)
  7104. defer resp.Body.Close()
  7105. body, ioErr := ioutil.ReadAll(resp.Body)
  7106. if ioErr != nil {
  7107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. return
  7110. }
  7111. var respJSON map[string]interface{}
  7112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7115. return
  7116. }
  7117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7118. userJSONBytes, _ := json.Marshal(respJSON)
  7119. fmt.Println("log")
  7120. fmt.Println(string(userJSONBytes))
  7121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7122. utils.ErrorLog("解析失败:%v", err)
  7123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7124. return
  7125. }
  7126. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7127. bytesData, _ := json.Marshal(data)
  7128. var req *http.Request
  7129. if miConfig.MdtrtareaAdmvs == "320921" {
  7130. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7131. } else {
  7132. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7133. }
  7134. resp, _ := client.Do(req)
  7135. defer resp.Body.Close()
  7136. body, ioErr := ioutil.ReadAll(resp.Body)
  7137. if ioErr != nil {
  7138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. return
  7141. }
  7142. var respJSON map[string]interface{}
  7143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7146. return
  7147. }
  7148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7149. userJSONBytes, _ := json.Marshal(respJSON)
  7150. fmt.Println("log")
  7151. fmt.Println(string(userJSONBytes))
  7152. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7153. utils.ErrorLog("解析失败:%v", err)
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. return
  7156. }
  7157. res.InfRefmsgid = resFour10265.InfRefmsgid
  7158. res.Output = resFour10265.Output
  7159. res.ErrMsg = resFour10265.ErrMsg
  7160. res.Cainfo = resFour10265.Cainfo
  7161. res.WarnMsg = resFour10265.WarnMsg
  7162. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7163. res.Infcode = infocode
  7164. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7165. 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)
  7166. var dat map[string]interface{}
  7167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7168. fmt.Println(dat)
  7169. } else {
  7170. fmt.Println(err)
  7171. }
  7172. saveLog(result, request_log, "2204", "上传费用明细")
  7173. userJSONBytes, _ := json.Marshal(dat)
  7174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7175. utils.ErrorLog("解析失败:%v", err)
  7176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. return
  7178. }
  7179. } else {
  7180. if miConfig.Code == "H15049901371" {
  7181. 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)
  7182. var dat map[string]interface{}
  7183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7184. fmt.Println(dat)
  7185. } else {
  7186. fmt.Println(err)
  7187. }
  7188. saveLog(result, request_log, "2204", "上传费用明细")
  7189. userJSONBytes, _ := json.Marshal(dat)
  7190. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7191. utils.ErrorLog("解析失败:%v", err)
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. res.InfRefmsgid = resFour10265.InfRefmsgid
  7196. res.Output = resFour10265.Output
  7197. res.ErrMsg = resFour10265.ErrMsg
  7198. res.Cainfo = resFour10265.Cainfo
  7199. res.WarnMsg = resFour10265.WarnMsg
  7200. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7201. res.Infcode = infocode
  7202. } else {
  7203. 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)
  7204. var dat map[string]interface{}
  7205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7206. fmt.Println(dat)
  7207. } else {
  7208. fmt.Println(err)
  7209. }
  7210. saveLog(result, request_log, "2204", "上传费用明细")
  7211. userJSONBytes, _ := json.Marshal(dat)
  7212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7213. utils.ErrorLog("解析失败:%v", err)
  7214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7215. return
  7216. }
  7217. }
  7218. }
  7219. if res.Infcode == 0 {
  7220. order := &models.HisOrder{
  7221. UserOrgId: adminUser.CurrentOrgId,
  7222. HisPatientId: his.ID,
  7223. PatientId: his.PatientId,
  7224. SettleAccountsDate: recordDateTime,
  7225. Ctime: time.Now().Unix(),
  7226. Mtime: time.Now().Unix(),
  7227. MdtrtId: his.Number,
  7228. PsnNo: his.PsnNo,
  7229. MedType: strconv.FormatInt(reg_type, 10),
  7230. Status: 1,
  7231. Number: chrg_bchno,
  7232. Infcode: res.Infcode,
  7233. WarnMsg: res.WarnMsg,
  7234. Cainfo: res.Cainfo,
  7235. ErrMsg: res.ErrMsg,
  7236. RespondTime: res.RefmsgTime,
  7237. InfRefmsgid: res.InfRefmsgid,
  7238. OrderStatus: 1,
  7239. IsMedicineInsurance: 1,
  7240. SettleType: settle_accounts_type,
  7241. SettleStartTime: start_time,
  7242. SettleEndTime: end_time,
  7243. Creator: roles.AdminUserId,
  7244. Modify: roles.AdminUserId,
  7245. PType: 2,
  7246. Diagnosis: diagnosis_id,
  7247. }
  7248. err = service.CreateOrder(order)
  7249. if err != nil {
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7251. return
  7252. }
  7253. for _, item := range res.Output.Result {
  7254. temp := strings.Split(item.FeedetlSn, "-")
  7255. var advice_id int64 = 0
  7256. var project_id int64 = 0
  7257. var types int64 = 0
  7258. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7259. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7260. if temp[1] == "1" {
  7261. advice_id = id
  7262. project_id = 0
  7263. } else if temp[1] == "2" {
  7264. advice_id = 0
  7265. project_id = id
  7266. }
  7267. info := &models.HisOrderInfo{
  7268. OrderNumber: order.Number,
  7269. FeedetlSn: item.FeedetlSn,
  7270. UploadDate: time.Now().Unix(),
  7271. AdviceId: advice_id,
  7272. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7273. Cnt: item.Cnt,
  7274. Pric: float64(item.Pric),
  7275. PatientId: his.PatientId,
  7276. PricUplmtAmt: item.PricUplmtAmt,
  7277. SelfpayProp: item.SelfpayProp,
  7278. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7279. OverlmtAmt: item.OverlmtAmt,
  7280. PreselfpayAmt: item.PreselfpayAmt,
  7281. BasMednFlag: item.BasMednFlag,
  7282. MedChrgitmType: item.MedChrgitmType,
  7283. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7284. Status: 1,
  7285. Memo: item.Memo,
  7286. Mtime: time.Now().Unix(),
  7287. InscpScpAmt: item.InscpScpAmt,
  7288. DrtReimFlag: item.DrtReimFlag,
  7289. Ctime: time.Now().Unix(),
  7290. ListSpItemFlag: item.ListSpItemFlag,
  7291. ChldMedcFlag: item.ChldMedcFlag,
  7292. LmtUsedFlag: item.LmtUsedFlag,
  7293. ChrgitmLv: item.ChrgitmLv,
  7294. UserOrgId: adminUser.CurrentOrgId,
  7295. HisPatientId: his.ID,
  7296. OrderId: order.ID,
  7297. ProjectId: project_id,
  7298. Type: types,
  7299. }
  7300. service.CreateOrderInfo(info)
  7301. }
  7302. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7303. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7304. var total float64
  7305. for _, item := range prescriptions {
  7306. if item.Type == 1 { //药品
  7307. for _, subItem := range item.HisDoctorAdviceInfo {
  7308. total = total + (subItem.Price * subItem.PrescribingNumber)
  7309. }
  7310. }
  7311. if item.Type == 2 { //项目
  7312. for _, subItem := range item.HisPrescriptionProject {
  7313. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7314. total = total + (subItem.Price * cnt)
  7315. }
  7316. }
  7317. }
  7318. for _, item := range prescriptions {
  7319. for _, subItem := range item.HisAdditionalCharge {
  7320. total = total + (subItem.Price * float64(subItem.Count))
  7321. }
  7322. }
  7323. allTotal := fmt.Sprintf("%.4f", total)
  7324. if res.Infcode == 0 {
  7325. var rf []*ResultFive
  7326. json.Unmarshal([]byte(his.Iinfo), &rf)
  7327. chrg_bchno := chrg_bchno
  7328. cert_no := his.Certno
  7329. var insutypes []string
  7330. var insutype string
  7331. var is390 int = 0
  7332. var is310 int = 0
  7333. for _, item := range rf {
  7334. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7335. insutypes = append(insutypes, item.Insutype)
  7336. }
  7337. }
  7338. if len(insutypes) == 1 {
  7339. insutype = insutypes[0]
  7340. } else {
  7341. for _, i := range insutypes {
  7342. if i == "390" {
  7343. is390 = 1
  7344. }
  7345. if i == "310" {
  7346. is310 = 1
  7347. }
  7348. }
  7349. }
  7350. if is390 == 1 {
  7351. insutype = "390"
  7352. }
  7353. if is310 == 1 {
  7354. insutype = "310"
  7355. }
  7356. if len(insutypes) == 0 {
  7357. insutype = "310"
  7358. }
  7359. if len(insutypes) == 2 {
  7360. insutype = strconv.FormatInt(his.SocialType, 64)
  7361. }
  7362. //insutype = "390"
  7363. if his.IdCardType == 1 {
  7364. cert_no = his.MedicalInsuranceNumber
  7365. } else {
  7366. cert_no = his.Certno
  7367. }
  7368. var res ResultSeven
  7369. var resSeven10265 ResultSeven10265
  7370. if miConfig.MdtrtareaAdmvs == "421300" {
  7371. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7372. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7373. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7374. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7375. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7376. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7377. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7378. resp, requestErr := http.Get(api)
  7379. if requestErr != nil {
  7380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7381. return
  7382. }
  7383. body, ioErr := ioutil.ReadAll(resp.Body)
  7384. if ioErr != nil {
  7385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7387. return
  7388. }
  7389. var respJSON map[string]interface{}
  7390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. return
  7394. }
  7395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7396. result, _ := json.Marshal(respJSON)
  7397. fmt.Println("log")
  7398. fmt.Println(string(result))
  7399. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7400. utils.ErrorLog("解析失败:%v", err)
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7405. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7406. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7407. bas := strings.Split(psn_info.CardInfo, "|")
  7408. if his.IdCardType == 1 {
  7409. cert_no = bas[2]
  7410. } else {
  7411. cert_no = bas[1]
  7412. }
  7413. //江苏地区国家医保医疗类别
  7414. //职工透析:医疗类别选特殊情况门诊9933
  7415. //居民血透门慢: 医疗类别选门诊慢病1402
  7416. //var med_type string
  7417. //if his.Insutype == "310" {
  7418. // if reg_type == 14 {
  7419. // med_type = "9933"
  7420. // } else if reg_type == 11 {
  7421. // med_type = "11"
  7422. //
  7423. // }
  7424. //} else if his.Insutype == "390" {
  7425. // if reg_type == 14 {
  7426. // med_type = "1402"
  7427. // } else if reg_type == 11 {
  7428. // med_type = "11"
  7429. // }
  7430. //}
  7431. var api string
  7432. if miConfig.MdtrtareaAdmvs == "320921" {
  7433. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7434. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7435. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7436. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7437. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7438. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7439. "&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
  7440. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7441. } else {
  7442. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7443. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7444. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7445. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7446. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7447. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7448. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7449. "&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
  7450. }
  7451. resp, requestErr := http.Get(api)
  7452. if requestErr != nil {
  7453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7454. return
  7455. }
  7456. body, ioErr := ioutil.ReadAll(resp.Body)
  7457. if ioErr != nil {
  7458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. return
  7461. }
  7462. var respJSON map[string]interface{}
  7463. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7466. return
  7467. }
  7468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7469. result, _ := json.Marshal(respJSON)
  7470. fmt.Println("log")
  7471. fmt.Println(string(result))
  7472. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7473. utils.ErrorLog("解析失败:%v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7478. res.Output = resSeven10265.Output
  7479. res.ErrMsg = resSeven10265.ErrMsg
  7480. res.Cainfo = resSeven10265.Cainfo
  7481. res.WarnMsg = resSeven10265.WarnMsg
  7482. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7483. res.Infcode = infocode
  7484. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7485. 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)
  7486. var dat map[string]interface{}
  7487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7488. fmt.Println(dat)
  7489. } else {
  7490. fmt.Println(err)
  7491. }
  7492. saveLog(result, request_log, "2206", "预结算")
  7493. userJSONBytes, _ := json.Marshal(dat)
  7494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7495. utils.ErrorLog("解析失败:%v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. } else {
  7500. var result string
  7501. var request_log string
  7502. if miConfig.Code == "H15049901371" {
  7503. //赤峰地区国家医保医疗类别
  7504. //职工透析:医疗类别选特殊情况门诊990502
  7505. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7506. var med_type string
  7507. if his.Insutype == "390" {
  7508. if reg_type == 14 {
  7509. med_type = "9933"
  7510. } else if reg_type == 11 {
  7511. med_type = "11"
  7512. }
  7513. } else if his.Insutype == "310" {
  7514. if reg_type == 14 {
  7515. med_type = "990502"
  7516. } else if reg_type == 11 {
  7517. med_type = "11"
  7518. }
  7519. }
  7520. 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)
  7521. } else {
  7522. 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)
  7523. }
  7524. var dat map[string]interface{}
  7525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7526. fmt.Println(dat)
  7527. } else {
  7528. fmt.Println(err)
  7529. }
  7530. saveLog(result, request_log, "2206", "预结算")
  7531. //userJSONBytes, _ := json.Marshal(dat)
  7532. //
  7533. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7534. // utils.ErrorLog("解析失败:%v", err)
  7535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. // return
  7537. //}
  7538. userJSONBytes, _ := json.Marshal(dat)
  7539. if miConfig.Code == "H15049901371" {
  7540. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7541. utils.ErrorLog("解析失败:%v", err)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7546. res.Output = resSeven10265.Output
  7547. res.ErrMsg = resSeven10265.ErrMsg
  7548. res.Cainfo = resSeven10265.Cainfo
  7549. res.WarnMsg = resSeven10265.WarnMsg
  7550. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7551. res.Infcode = infocode
  7552. } else {
  7553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7554. utils.ErrorLog("解析失败:%v", err)
  7555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7556. return
  7557. }
  7558. }
  7559. }
  7560. if res.Infcode != 0 {
  7561. errlog := &models.HisOrderError{
  7562. UserOrgId: adminUser.CurrentOrgId,
  7563. Ctime: time.Now().Unix(),
  7564. Mtime: time.Now().Unix(),
  7565. Number: chrg_bchno,
  7566. ErrMsg: res.ErrMsg,
  7567. Status: 1,
  7568. PatientId: id,
  7569. RecordTime: recordDateTime,
  7570. Stage: 20,
  7571. }
  7572. service.CreateErrMsgLog(errlog)
  7573. c.ServeSuccessJSON(map[string]interface{}{
  7574. "failed_code": -10,
  7575. "msg": res.ErrMsg,
  7576. })
  7577. return
  7578. } else {
  7579. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7580. order.OrderStatus = 1
  7581. order.IsPre = 1
  7582. order.Status = 1
  7583. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7584. order.SetlId = res.Output.Setlinfo.SetlID
  7585. order.PsnNo = res.Output.Setlinfo.PsnNo
  7586. order.PsnName = res.Output.Setlinfo.PsnName
  7587. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7588. order.Certno = res.Output.Setlinfo.Certno
  7589. order.Gend = res.Output.Setlinfo.Gend
  7590. order.Naty = res.Output.Setlinfo.Naty
  7591. order.Age = res.Output.Setlinfo.Age
  7592. order.Insutype = res.Output.Setlinfo.Insutype
  7593. order.PsnType = res.Output.Setlinfo.PsnType
  7594. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7595. order.SetlTime = res.Output.Setlinfo.SetlTime
  7596. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7597. if res.Output.Setlinfo.MedType == "140101" {
  7598. order.MedType = "14"
  7599. } else {
  7600. order.MedType = res.Output.Setlinfo.MedType
  7601. }
  7602. if reg_type == 1112 {
  7603. order.MedType = "1112"
  7604. }
  7605. if reg_type == 1111 {
  7606. order.MedType = "1111"
  7607. }
  7608. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7609. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7610. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7611. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7612. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7613. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7614. order.HifpPay = res.Output.Setlinfo.HifpPay
  7615. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7616. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7617. order.HifesPay = res.Output.Setlinfo.HifesPay
  7618. order.HifobPay = res.Output.Setlinfo.HifobPay
  7619. order.MafPay = res.Output.Setlinfo.MafPay
  7620. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7621. order.OthPay = res.Output.Setlinfo.OthPay
  7622. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7623. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7624. order.AcctPay = res.Output.Setlinfo.AcctPay
  7625. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7626. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7627. order.Balc = res.Output.Setlinfo.Balc
  7628. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7629. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7630. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7631. order.ClrWay = res.Output.Setlinfo.ClrWay
  7632. order.Creator = order.Creator
  7633. order.Modify = roles.AdminUserId
  7634. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7635. detailStr := string(setlDetail)
  7636. order.SetlDetail = detailStr
  7637. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7638. err = service.UpDateOrder(order)
  7639. if err == nil {
  7640. c.ServeSuccessJSON(map[string]interface{}{
  7641. "msg": "预结算成功",
  7642. })
  7643. } else {
  7644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7645. return
  7646. }
  7647. }
  7648. } else {
  7649. adminUser := c.GetAdminUserInfo()
  7650. errlog := &models.HisOrderError{
  7651. UserOrgId: adminUser.CurrentOrgId,
  7652. Ctime: time.Now().Unix(),
  7653. Mtime: time.Now().Unix(),
  7654. ErrMsg: res.ErrMsg,
  7655. Status: 1,
  7656. PatientId: id,
  7657. RecordTime: recordDateTime,
  7658. Stage: 4,
  7659. }
  7660. service.CreateErrMsgLog(errlog)
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7662. return
  7663. }
  7664. } else {
  7665. adminUser := c.GetAdminUserInfo()
  7666. errlog := &models.HisOrderError{
  7667. UserOrgId: adminUser.CurrentOrgId,
  7668. Ctime: time.Now().Unix(),
  7669. Mtime: time.Now().Unix(),
  7670. ErrMsg: res.ErrMsg,
  7671. Status: 1,
  7672. PatientId: id,
  7673. RecordTime: recordDateTime,
  7674. Stage: 4,
  7675. }
  7676. service.CreateErrMsgLog(errlog)
  7677. c.ServeSuccessJSON(map[string]interface{}{
  7678. "failed_code": -10,
  7679. "msg": res.ErrMsg,
  7680. })
  7681. return
  7682. }
  7683. }
  7684. }
  7685. }
  7686. //退款
  7687. func (c *HisApiController) Refund() {
  7688. order_id, _ := c.GetInt64("order_id")
  7689. admin_user_id, _ := c.GetInt64("admin_user_id")
  7690. adminUser := c.GetAdminUserInfo()
  7691. var order models.HisOrder
  7692. order, _ = service.GetHisOrderByID(order_id)
  7693. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7694. if order.ID == 0 {
  7695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7696. return
  7697. }
  7698. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7699. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7700. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7701. if config.IsOpen == 1 { //对接了医保,走医保流程
  7702. var res ResultSixteen
  7703. var resSixteen10265 ResultSixteen10265
  7704. var src_resquest string
  7705. var result string
  7706. if miConfig.MdtrtareaAdmvs == "421300" {
  7707. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7708. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7709. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7710. resp3, requestErr3 := http.Get(api3)
  7711. if requestErr3 != nil {
  7712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7713. return
  7714. }
  7715. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7716. if ioErr3 != nil {
  7717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. var respJSON3 map[string]interface{}
  7722. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7725. return
  7726. }
  7727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7728. userJSONBytes3, _ := json.Marshal(respJSON3)
  7729. fmt.Println("log")
  7730. fmt.Println(string(userJSONBytes3))
  7731. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7732. utils.ErrorLog("解析失败:%v", err)
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7737. var api3 string
  7738. if miConfig.MdtrtareaAdmvs == "320921" {
  7739. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7740. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7741. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7742. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7743. } else {
  7744. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7745. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7746. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7748. }
  7749. resp3, requestErr3 := http.Get(api3)
  7750. if requestErr3 != nil {
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7755. if ioErr3 != nil {
  7756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. var respJSON3 map[string]interface{}
  7761. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. return
  7765. }
  7766. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7767. userJSONBytes3, _ := json.Marshal(respJSON3)
  7768. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7769. utils.ErrorLog("解析失败:%v", err)
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. return
  7772. }
  7773. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7774. res.Output = resSixteen10265.Output
  7775. res.ErrMsg = resSixteen10265.ErrMsg
  7776. res.Cainfo = resSixteen10265.Cainfo
  7777. res.WarnMsg = resSixteen10265.WarnMsg
  7778. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7779. res.Infcode = infocode
  7780. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7781. 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)
  7782. var dat map[string]interface{}
  7783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7784. fmt.Println(dat)
  7785. } else {
  7786. fmt.Println(err)
  7787. }
  7788. saveLog(result, src_resquest, "2208", "退费")
  7789. userJSONBytes, _ := json.Marshal(dat)
  7790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7791. utils.ErrorLog("解析失败:%v", err)
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. } else {
  7796. if miConfig.Code == "H15049901371" {
  7797. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7798. var dat map[string]interface{}
  7799. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7800. fmt.Println(dat)
  7801. } else {
  7802. fmt.Println(err)
  7803. }
  7804. saveLog(result, src_resquest, "2208", "退费")
  7805. userJSONBytes, _ := json.Marshal(dat)
  7806. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7807. utils.ErrorLog("解析失败:%v", err)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7812. res.Output = resSixteen10265.Output
  7813. res.ErrMsg = resSixteen10265.ErrMsg
  7814. res.Cainfo = resSixteen10265.Cainfo
  7815. res.WarnMsg = resSixteen10265.WarnMsg
  7816. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7817. res.Infcode = infocode
  7818. } else {
  7819. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7820. var dat map[string]interface{}
  7821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7822. fmt.Println(dat)
  7823. } else {
  7824. fmt.Println(err)
  7825. }
  7826. saveLog(result, src_resquest, "2208", "退费")
  7827. userJSONBytes, _ := json.Marshal(dat)
  7828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7829. utils.ErrorLog("解析失败:%v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. }
  7834. }
  7835. if res.Infcode == 0 {
  7836. var res2 ResultSix
  7837. var resSix10265 ResultSix10265
  7838. if miConfig.MdtrtareaAdmvs == "421300" {
  7839. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7840. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7841. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7842. resp3, requestErr3 := http.Get(api3)
  7843. if requestErr3 != nil {
  7844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7845. return
  7846. }
  7847. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7848. if ioErr3 != nil {
  7849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. var respJSON3 map[string]interface{}
  7854. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7857. return
  7858. }
  7859. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7860. userJSONBytes3, _ := json.Marshal(respJSON3)
  7861. fmt.Println("log")
  7862. fmt.Println(string(userJSONBytes3))
  7863. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7864. utils.ErrorLog("解析失败:%v", err)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7869. var api3 string
  7870. if miConfig.MdtrtareaAdmvs == "320921" {
  7871. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7872. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7873. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7874. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7875. } else {
  7876. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7877. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7878. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7879. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7880. }
  7881. resp3, requestErr3 := http.Get(api3)
  7882. if requestErr3 != nil {
  7883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7884. return
  7885. }
  7886. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7887. if ioErr3 != nil {
  7888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. return
  7891. }
  7892. var respJSON3 map[string]interface{}
  7893. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7899. userJSONBytes3, _ := json.Marshal(respJSON3)
  7900. fmt.Println("log")
  7901. fmt.Println(string(userJSONBytes3))
  7902. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7903. utils.ErrorLog("解析失败:%v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7908. res2.Output = resSix10265.Output
  7909. res2.ErrMsg = resSix10265.ErrMsg
  7910. res2.Cainfo = resSix10265.Cainfo
  7911. res2.WarnMsg = resSix10265.WarnMsg
  7912. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7913. res2.Infcode = infocode
  7914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7915. 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)
  7916. var dat map[string]interface{}
  7917. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7918. fmt.Println(dat)
  7919. } else {
  7920. fmt.Println(err)
  7921. }
  7922. saveLog(result2, src_request, "2205", "撤销明细")
  7923. userJSONBytes, _ := json.Marshal(dat)
  7924. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7925. utils.ErrorLog("解析失败:%v", err)
  7926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7927. return
  7928. }
  7929. } else {
  7930. if miConfig.Code == "H15049901371" {
  7931. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7932. var dat map[string]interface{}
  7933. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7934. fmt.Println(dat)
  7935. } else {
  7936. fmt.Println(err)
  7937. }
  7938. saveLog(result2, src_request, "2205", "撤销明细")
  7939. userJSONBytes, _ := json.Marshal(dat)
  7940. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7941. utils.ErrorLog("解析失败:%v", err)
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. return
  7944. }
  7945. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7946. res2.Output = resSix10265.Output
  7947. res2.ErrMsg = resSix10265.ErrMsg
  7948. res2.Cainfo = resSix10265.Cainfo
  7949. res2.WarnMsg = resSix10265.WarnMsg
  7950. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7951. res2.Infcode = infocode
  7952. } else {
  7953. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7954. var dat map[string]interface{}
  7955. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7956. fmt.Println(dat)
  7957. } else {
  7958. fmt.Println(err)
  7959. }
  7960. saveLog(result2, src_request, "2205", "撤销明细")
  7961. userJSONBytes, _ := json.Marshal(dat)
  7962. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7963. utils.ErrorLog("解析失败:%v", err)
  7964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. return
  7966. }
  7967. }
  7968. }
  7969. if res2.Infcode == 0 {
  7970. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7971. if err == nil {
  7972. //当押金不为零时产生退费记录
  7973. if order.Decimal != 0 {
  7974. tmp := strconv.FormatInt(order.ID, 10)
  7975. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7976. if err != nil {
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. }
  7981. c.ServeSuccessJSON(map[string]interface{}{
  7982. "msg": "退费成功",
  7983. })
  7984. } else {
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7986. return
  7987. }
  7988. } else {
  7989. c.ServeSuccessJSON(map[string]interface{}{
  7990. "code": -10,
  7991. "msg": res2.ErrMsg,
  7992. })
  7993. }
  7994. } else {
  7995. c.ServeSuccessJSON(map[string]interface{}{
  7996. "code": -10,
  7997. "msg": res.ErrMsg,
  7998. })
  7999. }
  8000. }
  8001. }
  8002. func (c *HisApiController) RefundNumber() {
  8003. record_time := c.GetString("record_time")
  8004. //patient_id, _ := c.GetInt64("patient_id")
  8005. admin_user_id, _ := c.GetInt64("admin_user_id")
  8006. his_patient_id, _ := c.GetInt64("id")
  8007. timeLayout := "2006-01-02"
  8008. loc, _ := time.LoadLocation("Local")
  8009. adminUser := c.GetAdminUserInfo()
  8010. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8011. fmt.Println(err)
  8012. if err != nil {
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8014. return
  8015. }
  8016. recordDateTime := theTime.Unix()
  8017. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8018. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8019. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8020. //order, _ := service.GetHisOrderByID(order_id)
  8021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8022. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8023. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8024. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8025. if count > 0 {
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8027. return
  8028. }
  8029. if config.IsOpen == 1 { //对接了医保,走医保流程
  8030. var res2 ResultSix
  8031. var resSix10265 ResultSix10265
  8032. if miConfig.MdtrtareaAdmvs == "421300" {
  8033. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8034. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8036. resp3, requestErr3 := http.Get(api3)
  8037. if requestErr3 != nil {
  8038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8039. return
  8040. }
  8041. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8042. if ioErr3 != nil {
  8043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8045. return
  8046. }
  8047. var respJSON3 map[string]interface{}
  8048. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8054. userJSONBytes3, _ := json.Marshal(respJSON3)
  8055. fmt.Println("log")
  8056. fmt.Println(string(userJSONBytes3))
  8057. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8058. utils.ErrorLog("解析失败:%v", err)
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8060. return
  8061. }
  8062. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8063. var api3 string
  8064. if miConfig.MdtrtareaAdmvs == "320921" {
  8065. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8066. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8068. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8069. } else {
  8070. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8071. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8072. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8074. }
  8075. resp3, requestErr3 := http.Get(api3)
  8076. if requestErr3 != nil {
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8081. if ioErr3 != nil {
  8082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8084. return
  8085. }
  8086. var respJSON3 map[string]interface{}
  8087. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. return
  8091. }
  8092. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8093. userJSONBytes3, _ := json.Marshal(respJSON3)
  8094. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8095. utils.ErrorLog("解析失败:%v", err)
  8096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8097. return
  8098. }
  8099. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8100. res2.Output = resSix10265.Output
  8101. res2.ErrMsg = resSix10265.ErrMsg
  8102. res2.Cainfo = resSix10265.Cainfo
  8103. res2.WarnMsg = resSix10265.WarnMsg
  8104. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8105. res2.Infcode = infocode
  8106. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8107. 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)
  8108. var dat map[string]interface{}
  8109. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8110. fmt.Println(dat)
  8111. } else {
  8112. fmt.Println(err)
  8113. }
  8114. saveLog(result, request, "2202", "退号")
  8115. userJSONBytes, _ := json.Marshal(dat)
  8116. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8117. utils.ErrorLog("解析失败:%v", err)
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. } else {
  8122. var api3 string
  8123. if miConfig.Code == "H15049901371" {
  8124. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8125. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8127. } else {
  8128. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8129. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8130. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8131. }
  8132. resp3, requestErr3 := http.Get(api3)
  8133. if requestErr3 != nil {
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8138. if ioErr3 != nil {
  8139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. var respJSON3 map[string]interface{}
  8144. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8147. return
  8148. }
  8149. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8150. userJSONBytes3, _ := json.Marshal(respJSON3)
  8151. if miConfig.Code == "H15049901371" {
  8152. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8153. utils.ErrorLog("解析失败:%v", err)
  8154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8155. return
  8156. }
  8157. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8158. res2.Output = resSix10265.Output
  8159. res2.ErrMsg = resSix10265.ErrMsg
  8160. res2.Cainfo = resSix10265.Cainfo
  8161. res2.WarnMsg = resSix10265.WarnMsg
  8162. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8163. res2.Infcode = infocode
  8164. } else {
  8165. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8166. utils.ErrorLog("解析失败:%v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. }
  8171. }
  8172. if res2.Infcode == 0 {
  8173. if err == nil {
  8174. c.ServeSuccessJSON(map[string]interface{}{
  8175. "msg": "退号成功",
  8176. })
  8177. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8178. } else {
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8180. return
  8181. }
  8182. } else {
  8183. c.ServeSuccessJSON(map[string]interface{}{
  8184. "code": -10,
  8185. "msg": res2.ErrMsg,
  8186. })
  8187. }
  8188. } else {
  8189. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8190. //if err == nil {
  8191. // c.ServeSuccessJSON(map[string]interface{}{
  8192. // "msg": "退费成功",
  8193. // })
  8194. //} else {
  8195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8196. // return
  8197. //}
  8198. }
  8199. }
  8200. func (c *HisApiController) RefundDetail() {
  8201. order_id, _ := c.GetInt64("order_id")
  8202. admin_user_id, _ := c.GetInt64("admin_user_id")
  8203. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8204. number := c.GetString("number")
  8205. record_time := c.GetString("record_time")
  8206. patient_id, _ := c.GetInt64("patient_id")
  8207. //med_type, _ := c.GetInt64("med_type")
  8208. timeLayout := "2006-01-02"
  8209. loc, _ := time.LoadLocation("Local")
  8210. adminUser := c.GetAdminUserInfo()
  8211. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8212. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8213. fmt.Println(err)
  8214. if err != nil {
  8215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8216. return
  8217. }
  8218. recordDateTime := theTime.Unix()
  8219. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8220. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8221. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8222. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8223. var order models.HisOrder
  8224. order, _ = service.GetHisOrderByID(order_id)
  8225. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8226. if config.IsOpen == 1 { //对接了医保,走医保流程
  8227. var res2 ResultSix
  8228. if miConfig.MdtrtareaAdmvs == "421300" {
  8229. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8230. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8231. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8232. resp3, requestErr3 := http.Get(api3)
  8233. if requestErr3 != nil {
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8235. return
  8236. }
  8237. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8238. if ioErr3 != nil {
  8239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8241. return
  8242. }
  8243. var respJSON3 map[string]interface{}
  8244. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8247. return
  8248. }
  8249. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8250. userJSONBytes3, _ := json.Marshal(respJSON3)
  8251. fmt.Println("log")
  8252. fmt.Println(string(userJSONBytes3))
  8253. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8254. utils.ErrorLog("解析失败:%v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8259. if err == nil {
  8260. c.ServeSuccessJSON(map[string]interface{}{
  8261. "msg": "撤销明细成功",
  8262. })
  8263. return
  8264. } else {
  8265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8266. return
  8267. }
  8268. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8269. var resSix10265 ResultSix10265
  8270. var api3 string
  8271. if miConfig.MdtrtareaAdmvs == "320921" {
  8272. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8273. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8274. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8275. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8276. } else {
  8277. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8278. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8279. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8280. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8281. }
  8282. resp3, requestErr3 := http.Get(api3)
  8283. if requestErr3 != nil {
  8284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8285. return
  8286. }
  8287. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8288. if ioErr3 != nil {
  8289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8291. return
  8292. }
  8293. var respJSON3 map[string]interface{}
  8294. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8300. userJSONBytes3, _ := json.Marshal(respJSON3)
  8301. fmt.Println("log")
  8302. fmt.Println(string(userJSONBytes3))
  8303. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8304. utils.ErrorLog("解析失败:%v", err)
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8309. res2.Output = resSix10265.Output
  8310. res2.ErrMsg = resSix10265.ErrMsg
  8311. res2.Cainfo = resSix10265.Cainfo
  8312. res2.WarnMsg = resSix10265.WarnMsg
  8313. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8314. res2.Infcode = infocode
  8315. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8316. if err == nil {
  8317. c.ServeSuccessJSON(map[string]interface{}{
  8318. "msg": "撤销明细成功",
  8319. })
  8320. return
  8321. } else {
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. return
  8324. }
  8325. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8326. 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)
  8327. var dat map[string]interface{}
  8328. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8329. fmt.Println(dat)
  8330. } else {
  8331. fmt.Println(err)
  8332. }
  8333. saveLog(result2, src_request, "2205", "撤销明细")
  8334. userJSONBytes, _ := json.Marshal(dat)
  8335. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8336. utils.ErrorLog("解析失败:%v", err)
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. if res2.Infcode == 0 {
  8341. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8342. if err == nil {
  8343. c.ServeSuccessJSON(map[string]interface{}{
  8344. "msg": "撤销明细成功",
  8345. })
  8346. return
  8347. } else {
  8348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8349. return
  8350. }
  8351. } else {
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "code": -10,
  8354. "msg": res2.ErrMsg,
  8355. })
  8356. }
  8357. } else {
  8358. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8359. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8361. resp2, requestErr2 := http.Get(api2)
  8362. if requestErr2 != nil {
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8364. return
  8365. }
  8366. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8367. if ioErr2 != nil {
  8368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8370. return
  8371. }
  8372. var respJSON2 map[string]interface{}
  8373. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8379. if err == nil {
  8380. c.ServeSuccessJSON(map[string]interface{}{
  8381. "msg": "撤销明细成功",
  8382. })
  8383. return
  8384. } else {
  8385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8386. return
  8387. }
  8388. }
  8389. } else {
  8390. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8391. if err == nil {
  8392. c.ServeSuccessJSON(map[string]interface{}{
  8393. "msg": "退费成功",
  8394. })
  8395. } else {
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. }
  8400. }
  8401. //对账
  8402. func (c *HisApiController) GetCheckAccount() {
  8403. start_time := c.GetString("start_time")
  8404. end_time := c.GetString("end_time")
  8405. insutype := c.GetString("insutype")
  8406. clr_type := c.GetString("clr_type")
  8407. clr_org := c.GetString("clr_optins")
  8408. admin_user_id, _ := c.GetInt64("admin_user_id")
  8409. adminUser := c.GetAdminUserInfo()
  8410. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8411. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8412. if len(clr_org) == 0 {
  8413. clr_org = miConfig.MdtrtareaAdmvs
  8414. }
  8415. timeLayout := "2006-01-02"
  8416. loc, _ := time.LoadLocation("Local")
  8417. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8418. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8419. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8420. fixmedins_setl_cnt := int64(len(orders))
  8421. var medfee_sumamt float64
  8422. var acct_pay float64
  8423. var fund_pay_sumamt float64
  8424. for _, item := range orders {
  8425. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8426. acct_pay = acct_pay + item.AcctPay
  8427. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8428. }
  8429. var user_name string
  8430. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8431. if role.ID == 0 {
  8432. user_name = "xxx"
  8433. } else {
  8434. user_name = role.UserName
  8435. }
  8436. var res ResultEight
  8437. var res10188 ResultEightFor10188
  8438. if config.IsOpen == 1 {
  8439. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8440. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8441. "insutype=" + insutype +
  8442. "&clr_type=" + clr_type +
  8443. "&setl_optins=" + clr_org +
  8444. "&stmt_begndate=" + start_time +
  8445. "&stm_enddate=" + end_time +
  8446. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8447. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8448. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8449. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8450. "&fixmedins_code=" + miConfig.Code +
  8451. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8452. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8453. "&secret_key=" + miConfig.SecretKey +
  8454. "&org_name=" + miConfig.OrgName +
  8455. "&doctor=" + user_name +
  8456. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8457. fmt.Println(api)
  8458. resp, requestErr := http.Get(api)
  8459. if requestErr != nil {
  8460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8461. return
  8462. }
  8463. body, ioErr := ioutil.ReadAll(resp.Body)
  8464. fmt.Println(body)
  8465. if ioErr != nil {
  8466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8468. return
  8469. }
  8470. var respJSON map[string]interface{}
  8471. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8474. return
  8475. }
  8476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8477. userJSONBytes, _ := json.Marshal(respJSON)
  8478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8479. utils.ErrorLog("解析失败:%v", err)
  8480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8481. return
  8482. }
  8483. res.InfRefmsgid = res10188.InfRefmsgid
  8484. res.Output = res10188.Output
  8485. res.ErrMsg = res10188.ErrMsg
  8486. res.Cainfo = res10188.Cainfo
  8487. res.WarnMsg = res10188.WarnMsg
  8488. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8489. res.Infcode = infocode
  8490. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8491. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8492. "insutype=" + insutype +
  8493. "&clr_type=" + clr_type +
  8494. "&setl_optins=" + clr_org +
  8495. "&stmt_begndate=" + start_time +
  8496. "&stm_enddate=" + end_time +
  8497. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8498. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8499. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8500. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8501. "&fixmedins_code=" + miConfig.Code +
  8502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8503. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8504. "&secret_key=" + miConfig.SecretKey +
  8505. "&org_name=" + miConfig.OrgName +
  8506. "&doctor=" + user_name
  8507. resp, requestErr := http.Get(api)
  8508. if requestErr != nil {
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8510. return
  8511. }
  8512. body, ioErr := ioutil.ReadAll(resp.Body)
  8513. if ioErr != nil {
  8514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. var respJSON map[string]interface{}
  8519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. return
  8523. }
  8524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8525. result, _ := json.Marshal(respJSON)
  8526. fmt.Println("log")
  8527. fmt.Println(string(result))
  8528. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8529. utils.ErrorLog("解析失败:%v", err)
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8531. return
  8532. }
  8533. res.InfRefmsgid = res10188.InfRefmsgid
  8534. res.Output = res10188.Output
  8535. res.ErrMsg = res10188.ErrMsg
  8536. res.Cainfo = res10188.Cainfo
  8537. res.WarnMsg = res10188.WarnMsg
  8538. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8539. res.Infcode = infocode
  8540. } else {
  8541. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8542. "insutype=" + insutype +
  8543. "&clr_type=" + clr_type +
  8544. "&setl_optins=" + clr_org +
  8545. "&stmt_begndate=" + start_time +
  8546. "&stm_enddate=" + end_time +
  8547. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8548. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8549. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8550. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8551. "&fixmedins_code=" + miConfig.Code +
  8552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8553. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8554. "&secret_key=" + miConfig.SecretKey +
  8555. "&org_name=" + miConfig.OrgName +
  8556. "&doctor=" + user_name
  8557. fmt.Println(api)
  8558. resp, requestErr := http.Get(api)
  8559. if requestErr != nil {
  8560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8561. return
  8562. }
  8563. body, ioErr := ioutil.ReadAll(resp.Body)
  8564. fmt.Println(body)
  8565. if ioErr != nil {
  8566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. var respJSON map[string]interface{}
  8571. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8574. return
  8575. }
  8576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8577. userJSONBytes, _ := json.Marshal(respJSON)
  8578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8579. utils.ErrorLog("解析失败:%v", err)
  8580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8581. return
  8582. }
  8583. }
  8584. if res.Infcode == 0 {
  8585. if res.Output.Stmtinfo.StmtRslt == "0" {
  8586. micc := &models.MedicalInsuranceCostCompare{
  8587. StartTime: startime.Unix(),
  8588. EndTime: endtime.Unix(),
  8589. Insutype: insutype,
  8590. CheckType: 1,
  8591. Num: fixmedins_setl_cnt,
  8592. Mtime: time.Now().Unix(),
  8593. Status: 1,
  8594. UserOrgId: adminUser.CurrentOrgId,
  8595. CostTotal: medfee_sumamt,
  8596. FuncTotal: fund_pay_sumamt,
  8597. PsnPay: acct_pay,
  8598. Creator: admin_user_id,
  8599. Ctime: time.Now().Unix(),
  8600. ClrType: clr_type,
  8601. }
  8602. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8603. if err == nil {
  8604. c.ServeSuccessJSON(map[string]interface{}{
  8605. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8606. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8607. })
  8608. } else {
  8609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8610. }
  8611. } else {
  8612. c.ServeSuccessJSON(map[string]interface{}{
  8613. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8614. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8615. })
  8616. }
  8617. } else {
  8618. c.ServeSuccessJSON(map[string]interface{}{
  8619. "code": -10,
  8620. "msg": res.ErrMsg,
  8621. })
  8622. }
  8623. }
  8624. }
  8625. func (c *HisApiController) Check310() {
  8626. adminUser := c.GetAdminUserInfo()
  8627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8628. var user_name string
  8629. user_name = "高慧裕"
  8630. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8631. "insutype=" + "310" +
  8632. "&clr_type=" + "" +
  8633. "&setl_optins=" + "441202" +
  8634. "&stmt_begndate=" + "2022-03-01" +
  8635. "&stm_enddate=" + "2022-03-31" +
  8636. "&medfee_sumamt=" + "194930.12" +
  8637. "&fund_pay_sumamt=" + "188741.46" +
  8638. "&acct_pay=" + "0" +
  8639. "&fixmedins_setl_cnt=" + "452" +
  8640. "&fixmedins_code=" + miConfig.Code +
  8641. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8642. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8643. "&secret_key=" + miConfig.SecretKey +
  8644. "&org_name=" + miConfig.OrgName +
  8645. "&doctor=" + user_name
  8646. fmt.Println(api)
  8647. resp, requestErr := http.Get(api)
  8648. if requestErr != nil {
  8649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8650. return
  8651. }
  8652. body, ioErr := ioutil.ReadAll(resp.Body)
  8653. fmt.Println(body)
  8654. if ioErr != nil {
  8655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8657. return
  8658. }
  8659. var respJSON map[string]interface{}
  8660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8666. userJSONBytes, _ := json.Marshal(respJSON)
  8667. var res ResultEight
  8668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8669. utils.ErrorLog("解析失败:%v", err)
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. }
  8674. func (c *HisApiController) Check390() {
  8675. adminUser := c.GetAdminUserInfo()
  8676. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8677. var user_name string
  8678. user_name = "高慧裕"
  8679. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8680. "insutype=" + "390" +
  8681. "&clr_type=" + "" +
  8682. "&setl_optins=" + "441202" +
  8683. "&stmt_begndate=" + "2022-03-01" +
  8684. "&stm_enddate=" + "2022-03-31" +
  8685. "&medfee_sumamt=" + "1068448.89" +
  8686. "&fund_pay_sumamt=" + "1014677.62" +
  8687. "&acct_pay=" + "0" +
  8688. "&fixmedins_setl_cnt=" + "1950" +
  8689. "&fixmedins_code=" + miConfig.Code +
  8690. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8691. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8692. "&secret_key=" + miConfig.SecretKey +
  8693. "&org_name=" + miConfig.OrgName +
  8694. "&doctor=" + user_name
  8695. fmt.Println(api)
  8696. resp, requestErr := http.Get(api)
  8697. if requestErr != nil {
  8698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8699. return
  8700. }
  8701. body, ioErr := ioutil.ReadAll(resp.Body)
  8702. fmt.Println(body)
  8703. if ioErr != nil {
  8704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8706. return
  8707. }
  8708. var respJSON map[string]interface{}
  8709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8712. return
  8713. }
  8714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8715. userJSONBytes, _ := json.Marshal(respJSON)
  8716. var res ResultEight
  8717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8718. utils.ErrorLog("解析失败:%v", err)
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. }
  8723. //对账明细
  8724. func (c *HisApiController) GetCheckDetailAccount() {
  8725. start_time := c.GetString("start_time")
  8726. end_time := c.GetString("end_time")
  8727. admin_user_id, _ := c.GetInt64("admin_user_id")
  8728. adminUser := c.GetAdminUserInfo()
  8729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8730. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8731. timeLayout := "2006-01-02"
  8732. loc, _ := time.LoadLocation("Local")
  8733. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8734. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8735. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8736. rand.Seed(time.Now().UnixNano())
  8737. num := rand.Intn(30000)
  8738. Mkdir(miConfig.OrgName)
  8739. file := strconv.FormatInt(int64(num), 10)
  8740. file_name := file + ".txt"
  8741. zip_name := file + ".zip"
  8742. zip_path := miConfig.OrgName + "/" + zip_name
  8743. file_path := miConfig.OrgName + "/" + file_name
  8744. decimal.DivisionPrecision = 2
  8745. var medfee_sumamt float64
  8746. var psn_cash_pay float64
  8747. var fund_pay_sumamt float64
  8748. fixmedins_setl_cnt := int64(len(orders))
  8749. for _, item := range orders {
  8750. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8751. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8752. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8753. }
  8754. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8755. defer f.Close()
  8756. if err != nil {
  8757. fmt.Println(err.Error())
  8758. } else {
  8759. for _, item := range orders {
  8760. var refd_setl_flag string
  8761. if item.OrderStatus == 2 {
  8762. refd_setl_flag = "0"
  8763. var str string
  8764. str = item.SetlId + " " +
  8765. item.MdtrtId + " " +
  8766. item.PsnNo + " " +
  8767. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8768. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8769. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8770. _, err = f.Write([]byte(str))
  8771. }
  8772. if item.OrderStatus == 3 {
  8773. var str string
  8774. str = item.SetlId + " " +
  8775. item.MdtrtId + " " +
  8776. item.PsnNo + " " +
  8777. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8778. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8779. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8780. _, err = f.Write([]byte(str))
  8781. var str2 string
  8782. str2 = item.SetlId + " " +
  8783. item.MdtrtId + " " +
  8784. item.PsnNo + " " +
  8785. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8786. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8787. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8788. _, err = f.Write([]byte(str2))
  8789. }
  8790. }
  8791. }
  8792. Zip(file_path, zip_path)
  8793. fmt.Println(ReadFile(zip_path))
  8794. fmt.Println(string(ReadFile(zip_path)))
  8795. if config.IsOpen == 1 {
  8796. var user_name string
  8797. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8798. if role.ID == 0 {
  8799. user_name = "管理员"
  8800. } else {
  8801. user_name = role.UserName
  8802. }
  8803. baseParams := models.BaseParams{
  8804. SecretKey: miConfig.SecretKey,
  8805. FixmedinsCode: miConfig.Code,
  8806. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8807. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8808. OrgName: miConfig.OrgName,
  8809. Doctor: user_name,
  8810. }
  8811. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8812. var dat map[string]interface{}
  8813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8814. fmt.Println(dat)
  8815. } else {
  8816. fmt.Println(err)
  8817. }
  8818. userJSONBytes, _ := json.Marshal(dat)
  8819. var res ResultNine
  8820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8821. utils.ErrorLog("解析失败:%v", err)
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8823. return
  8824. }
  8825. if res.Infcode == 0 {
  8826. fileNo := res.Output.FileQuryNo
  8827. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8828. "file_qury_no=" + fileNo +
  8829. "&setl_optins=" + "定点医保中心" +
  8830. "&stmt_begndate=" + start_time +
  8831. "&stm_enddate=" + end_time +
  8832. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8833. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8834. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8835. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8836. "&fixmedins_code=" + miConfig.Code +
  8837. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8838. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8839. "&secret_key=" + miConfig.SecretKey +
  8840. "&org_name=" + miConfig.OrgName +
  8841. "&doctor=" + user_name
  8842. resp, requestErr := http.Get(api)
  8843. if requestErr != nil {
  8844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8845. return
  8846. }
  8847. body, ioErr := ioutil.ReadAll(resp.Body)
  8848. if ioErr != nil {
  8849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8851. return
  8852. }
  8853. var respJSON map[string]interface{}
  8854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8857. return
  8858. }
  8859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8860. userJSONBytes, _ := json.Marshal(respJSON)
  8861. var res ResultTen
  8862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8863. utils.ErrorLog("解析失败:%v", err)
  8864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8865. return
  8866. }
  8867. if res.Infcode == 0 {
  8868. service.Gdyb9102(baseParams, zip_name, fileNo)
  8869. micc := &models.MedicalInsuranceCostCompare{
  8870. StartTime: startime.Unix(),
  8871. EndTime: endtime.Unix(),
  8872. Insutype: "0",
  8873. CheckType: 2,
  8874. Num: fixmedins_setl_cnt,
  8875. Mtime: time.Now().Unix(),
  8876. Status: 1,
  8877. UserOrgId: adminUser.CurrentOrgId,
  8878. CostTotal: medfee_sumamt,
  8879. FuncTotal: fund_pay_sumamt,
  8880. PsnPay: psn_cash_pay,
  8881. Creator: admin_user_id,
  8882. Ctime: time.Now().Unix(),
  8883. }
  8884. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8885. c.ServeSuccessJSON(map[string]interface{}{
  8886. "msg": "明细对账成功",
  8887. })
  8888. }
  8889. } else {
  8890. }
  8891. }
  8892. }
  8893. type CustomOrderInfo struct {
  8894. Name string
  8895. Spec string
  8896. Unit string
  8897. Count float64
  8898. Price float64
  8899. Total float64
  8900. }
  8901. func (c *HisApiController) GetSettleAccounts() {
  8902. //id, _ := c.GetInt64("id")
  8903. //record_time := c.GetString("record_time")
  8904. order_id, _ := c.GetInt64("order_id")
  8905. admin_user_id, _ := c.GetInt64("admin_user_id")
  8906. //timeLayout := "2006-01-02"
  8907. //loc, _ := time.LoadLocation("Local")
  8908. //
  8909. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8910. //if err != nil {
  8911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8912. // return
  8913. //}
  8914. //recordDateTime := theTime.Unix()
  8915. adminUser := c.GetAdminUserInfo()
  8916. order, _ := service.GetHisOrderByID(order_id)
  8917. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8918. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8919. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8920. orderInfos = append(orderInfos, orderInfos_two...)
  8921. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8922. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8923. var diagnosis_ids []string
  8924. if his.ID > 0 {
  8925. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8926. } else {
  8927. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8928. }
  8929. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8930. var dia_config []*models.HisXtDiagnoseConfig
  8931. var name string
  8932. for _, item := range diagnosis_ids {
  8933. id, _ := strconv.ParseInt(item, 10, 64)
  8934. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8935. dia_config = append(dia_config, &diagnosisConfig)
  8936. if len(name) == 0 {
  8937. name = diagnosisConfig.ClassName
  8938. } else {
  8939. name = name + "," + diagnosisConfig.ClassName
  8940. }
  8941. }
  8942. var bedCostTotal float64 = 0 //床位总费
  8943. var bedCostSelfTotal float64 = 0 //床位自费
  8944. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8945. var operationCostTotal float64 = 0 //手术费
  8946. var operationCostSelfTotal float64 = 0 //手术费
  8947. var operationCostPartSelfTotal float64 = 0 //手术费
  8948. var otherCostTotal float64 = 0 //其他费用
  8949. var otherCostSelfTotal float64 = 0 //其他费用
  8950. var otherCostPartSelfTotal float64 = 0 //其他费用
  8951. var materialCostTotal float64 = 0 //材料费
  8952. var materialCostSelfTotal float64 = 0 //材料费
  8953. var materialCostPartSelfTotal float64 = 0 //材料费
  8954. var westernMedicineCostTotal float64 = 0 //西药费
  8955. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8956. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8957. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8958. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8959. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8960. var checkCostTotal float64 = 0 //检查费
  8961. var checkCostSelfTotal float64 = 0 //检查费
  8962. var checkCostPartSelfTotal float64 = 0 //检查费
  8963. var laboratoryCostTotal float64 = 0 //化验费
  8964. var laboratoryCostSelfTotal float64 = 0 //化验费
  8965. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8966. var treatCostTotal float64 = 0 //治疗费用
  8967. var treatCostSelfTotal float64 = 0 //治疗费用
  8968. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8969. decimal.DivisionPrecision = 2
  8970. for _, item := range orderInfos {
  8971. if item.MedChrgitmType == "01" { //床位费
  8972. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8973. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8974. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8975. }
  8976. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8977. if item.MedChrgitmType == "03" { //检查费
  8978. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8979. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8980. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8981. }
  8982. } else {
  8983. if item.MedChrgitmType == "03" { //检查费
  8984. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8985. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8986. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8987. }
  8988. }
  8989. if item.MedChrgitmType == "04" { //化验费
  8990. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8991. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8992. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8993. }
  8994. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8995. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8996. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8997. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8998. }
  8999. if item.MedChrgitmType == "06" { //手术费
  9000. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9001. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9002. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9003. }
  9004. if item.MedChrgitmType == "08" { //材料费
  9005. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9006. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9007. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9008. }
  9009. if item.MedChrgitmType == "09" { //西药费
  9010. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9011. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9012. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9013. }
  9014. if item.MedChrgitmType == "11" { //中成费
  9015. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9016. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9017. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9018. }
  9019. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9020. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9021. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9022. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9023. }
  9024. }
  9025. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9026. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9027. var user_name string
  9028. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9029. if role.ID == 0 {
  9030. user_name = "管理员"
  9031. } else {
  9032. user_name = role.UserName
  9033. }
  9034. baseParams := models.BaseParams{
  9035. SecretKey: miConfig.SecretKey,
  9036. FixmedinsCode: miConfig.Code,
  9037. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9038. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9039. OrgName: miConfig.OrgName,
  9040. Doctor: user_name,
  9041. }
  9042. businessParams := models.BusinessParams{
  9043. PsnNo: order.PsnNo,
  9044. MdtrtId: order.MdtrtId,
  9045. SetlId: order.SetlId,
  9046. }
  9047. var res ResultEleven
  9048. var resEleven10265 ResultEleven10265
  9049. if config.IsOpen == 1 {
  9050. if miConfig.MdtrtareaAdmvs == "421300" {
  9051. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9052. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9054. resp, requestErr := http.Get(api)
  9055. if requestErr != nil {
  9056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9057. return
  9058. }
  9059. body, ioErr := ioutil.ReadAll(resp.Body)
  9060. if ioErr != nil {
  9061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9063. return
  9064. }
  9065. var respJSON map[string]interface{}
  9066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9069. return
  9070. }
  9071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9072. result, _ := json.Marshal(respJSON)
  9073. fmt.Println("log")
  9074. fmt.Println(string(result))
  9075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9076. utils.ErrorLog("解析失败:%v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9081. var api string
  9082. if miConfig.MdtrtareaAdmvs == "320921" {
  9083. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9084. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9085. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9086. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9087. } else {
  9088. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9089. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9090. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9091. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9092. }
  9093. resp, requestErr := http.Get(api)
  9094. if requestErr != nil {
  9095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9096. return
  9097. }
  9098. body, ioErr := ioutil.ReadAll(resp.Body)
  9099. if ioErr != nil {
  9100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9102. return
  9103. }
  9104. var respJSON map[string]interface{}
  9105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9108. return
  9109. }
  9110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9111. result, _ := json.Marshal(respJSON)
  9112. fmt.Println("log")
  9113. fmt.Println(string(result))
  9114. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9115. utils.ErrorLog("解析失败:%v", err)
  9116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9117. return
  9118. }
  9119. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9120. res.Output = resEleven10265.Output
  9121. res.ErrMsg = resEleven10265.ErrMsg
  9122. res.Cainfo = resEleven10265.Cainfo
  9123. res.WarnMsg = resEleven10265.WarnMsg
  9124. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9125. res.Infcode = infocode
  9126. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9127. result := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9128. var dat map[string]interface{}
  9129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9130. fmt.Println(dat)
  9131. } else {
  9132. fmt.Println(err)
  9133. }
  9134. userJSONBytes, _ := json.Marshal(dat)
  9135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9136. utils.ErrorLog("解析失败:%v", err)
  9137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9138. return
  9139. }
  9140. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9141. fmt.Println("~~~~~~~")
  9142. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9143. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9144. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9145. resp, requestErr := http.Get(api)
  9146. if requestErr != nil {
  9147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9148. return
  9149. }
  9150. body, ioErr := ioutil.ReadAll(resp.Body)
  9151. if ioErr != nil {
  9152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. return
  9155. }
  9156. var respJSON map[string]interface{}
  9157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9163. result, _ := json.Marshal(respJSON)
  9164. fmt.Println("log")
  9165. fmt.Println(string(result))
  9166. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9167. utils.ErrorLog("解析失败:%v", err)
  9168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9169. return
  9170. }
  9171. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9172. res.Output = resEleven10265.Output
  9173. res.ErrMsg = resEleven10265.ErrMsg
  9174. res.Cainfo = resEleven10265.Cainfo
  9175. res.WarnMsg = resEleven10265.WarnMsg
  9176. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9177. res.Infcode = infocode
  9178. } else {
  9179. result := service.Gdyb5203(baseParams, businessParams)
  9180. //service.Gdyb5204(baseParams, businessParams)
  9181. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9182. var dat map[string]interface{}
  9183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9184. fmt.Println(dat)
  9185. } else {
  9186. fmt.Println(err)
  9187. }
  9188. userJSONBytes, _ := json.Marshal(dat)
  9189. if miConfig.Code == "H15049901371" {
  9190. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9191. utils.ErrorLog("解析失败:%v", err)
  9192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9193. return
  9194. }
  9195. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9196. res.Output = resEleven10265.Output
  9197. res.ErrMsg = resEleven10265.ErrMsg
  9198. res.Cainfo = resEleven10265.Cainfo
  9199. res.WarnMsg = resEleven10265.WarnMsg
  9200. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9201. res.Infcode = infocode
  9202. } else {
  9203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9204. utils.ErrorLog("解析失败:%v", err)
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. }
  9209. }
  9210. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9211. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9212. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9213. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9214. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9215. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9216. var doctor_name string
  9217. if roles.ID == 0 {
  9218. doctor_name = "管理员"
  9219. } else {
  9220. doctor_name = roles.UserName
  9221. }
  9222. yiliao_leibie := ""
  9223. switch order.MedType {
  9224. case "11":
  9225. yiliao_leibie = "普通门诊"
  9226. break
  9227. case "12":
  9228. yiliao_leibie = "门诊挂号"
  9229. break
  9230. case "13":
  9231. yiliao_leibie = "急诊"
  9232. break
  9233. case "14":
  9234. yiliao_leibie = "门诊特殊病"
  9235. break
  9236. case "15":
  9237. yiliao_leibie = "门诊统筹"
  9238. break
  9239. case "16":
  9240. yiliao_leibie = "门诊慢性病"
  9241. break
  9242. case "21":
  9243. yiliao_leibie = "普通住院"
  9244. break
  9245. }
  9246. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9247. if res.Infcode == 0 {
  9248. c.ServeSuccessJSON(map[string]interface{}{
  9249. "diagnosis": name,
  9250. "order_infos": orderInfos,
  9251. "number": order.MdtrtId,
  9252. "date": order.SettleAccountsDate,
  9253. "charge_admin": charge_admin,
  9254. "printor_admin": printor_admin,
  9255. "info": res.Output.Setlinfo,
  9256. "order": order,
  9257. "bedCostTotal": bedCostTotal,
  9258. "bedCostSelfTotal": bedCostSelfTotal,
  9259. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9260. "operationCostTotal": operationCostTotal,
  9261. "operationCostSelfTotal": operationCostSelfTotal,
  9262. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9263. "otherCostTotal": otherCostTotal,
  9264. "otherCostSelfTotal": otherCostSelfTotal,
  9265. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9266. "materialCostTotal": materialCostTotal,
  9267. "materialCostSelfTotal": materialCostSelfTotal,
  9268. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9269. "westernMedicineCostTotal": westernMedicineCostTotal,
  9270. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9271. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9272. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9273. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9274. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9275. "checkCostTotal": checkCostTotal,
  9276. "checkCostSelfTotal": checkCostSelfTotal,
  9277. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9278. "laboratoryCostTotal": laboratoryCostTotal,
  9279. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9280. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9281. "treatCostTotal": treatCostTotal,
  9282. "treatCostSelfTotal": treatCostSelfTotal,
  9283. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9284. "doctor_info": doctor_info,
  9285. "doctor_code": adminRole_two.DoctorCode,
  9286. "doctor_name": doctor_name,
  9287. "health_card_no": order.PsnNo,
  9288. "department": departments.Name,
  9289. "yiliao_leibie": yiliao_leibie,
  9290. "after_money": order.AccountPrice,
  9291. "patient": patient,
  9292. "org_name": miConfig.OrgName,
  9293. "org_code": miConfig.Code,
  9294. "order_number": order.Number,
  9295. "his_hospital": his_hospital,
  9296. "his": his,
  9297. "dia_config": dia_config,
  9298. //"check_order_info": cus_slice,
  9299. })
  9300. }
  9301. }
  9302. }
  9303. func (c *HisApiController) CheckTreatment() {
  9304. patient_id, _ := c.GetInt64("patient_id")
  9305. id_card_no := c.GetString("id_card_no")
  9306. insutype := c.GetString("insutype")
  9307. med_type := c.GetString("med_type")
  9308. admin_user_id, _ := c.GetInt64("admin_user_id")
  9309. adminUser := c.GetAdminUserInfo()
  9310. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9312. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9313. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9314. if miConfig.MdtrtareaAdmvs == "421300" {
  9315. var res ResultTwo
  9316. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9317. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9318. "&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)
  9319. resp, requestErr := http.Get(api)
  9320. if requestErr != nil {
  9321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9322. return
  9323. }
  9324. body, ioErr := ioutil.ReadAll(resp.Body)
  9325. if ioErr != nil {
  9326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9328. return
  9329. }
  9330. var respJSON map[string]interface{}
  9331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9334. return
  9335. }
  9336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9337. result, _ := json.Marshal(respJSON)
  9338. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9339. utils.ErrorLog("解析失败:%v", err)
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. if res.Infcode == 0 {
  9344. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9345. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9347. resp, requestErr := http.Get(api)
  9348. if requestErr != nil {
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. body, ioErr := ioutil.ReadAll(resp.Body)
  9353. if ioErr != nil {
  9354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. var respJSON map[string]interface{}
  9359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. var res Result2001
  9365. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9366. result2, _ := json.Marshal(respJSON)
  9367. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9368. utils.ErrorLog("解析失败:%v", err)
  9369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9370. return
  9371. }
  9372. if res.Infcode == 0 {
  9373. c.ServeSuccessJSON(map[string]interface{}{
  9374. "msg": res.Output.Trtinfo,
  9375. })
  9376. }
  9377. } else {
  9378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9379. return
  9380. }
  9381. } else {
  9382. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9383. var dat map[string]interface{}
  9384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9385. fmt.Println(dat)
  9386. } else {
  9387. fmt.Println(err)
  9388. }
  9389. userJSONBytes, _ := json.Marshal(dat)
  9390. var res ResultTwo
  9391. var res10265 ResultTwo10265
  9392. if miConfig.Code == "H15049901371" {
  9393. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9394. utils.ErrorLog("解析失败:%v", err)
  9395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9396. return
  9397. }
  9398. res.ErrMsg = res10265.ErrMsg
  9399. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9400. res.Infcode = infocode
  9401. res.Output = res10265.Output
  9402. res.InfRefmsgid = res10265.InfRefmsgid
  9403. } else {
  9404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9405. utils.ErrorLog("解析失败:%v", err)
  9406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9407. return
  9408. }
  9409. }
  9410. var user_name string
  9411. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9412. if role.ID == 0 {
  9413. user_name = "xxx"
  9414. } else {
  9415. user_name = role.UserName
  9416. }
  9417. baseParams := models.BaseParams{
  9418. SecretKey: miConfig.SecretKey,
  9419. FixmedinsCode: miConfig.Code,
  9420. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9421. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9422. OrgName: miConfig.OrgName,
  9423. Doctor: user_name,
  9424. }
  9425. if config.IsOpen == 1 {
  9426. if miConfig.Code == "H15049901371" {
  9427. if med_type == "14" {
  9428. if insutype == "390" {
  9429. med_type = "9933"
  9430. } else if insutype == "310" {
  9431. med_type = "990502"
  9432. }
  9433. } else if med_type == "11" {
  9434. med_type = "11"
  9435. }
  9436. }
  9437. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9438. var dat map[string]interface{}
  9439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9440. fmt.Println(dat)
  9441. } else {
  9442. fmt.Println(err)
  9443. }
  9444. var res Result2001
  9445. var res10265 Result2001Org10265
  9446. if miConfig.Code == "H15049901371" {
  9447. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9448. utils.ErrorLog("解析失败:%v", err)
  9449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9450. return
  9451. }
  9452. res.ErrMsg = res10265.ErrMsg
  9453. res.Output = res10265.Output
  9454. res.InfRefmsgid = res10265.InfRefmsgid
  9455. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9456. res.Infcode = infocode
  9457. } else {
  9458. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9459. utils.ErrorLog("解析失败:%v", err)
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9461. return
  9462. }
  9463. }
  9464. if res.Infcode == 0 {
  9465. c.ServeSuccessJSON(map[string]interface{}{
  9466. "msg": res.Output.Trtinfo,
  9467. })
  9468. }
  9469. }
  9470. }
  9471. }
  9472. //func (c *HisApiController) PutRecord() {
  9473. // id, _ := c.GetInt64("id")
  9474. // record_time := c.GetString("record_time")
  9475. // timeLayout := "2006-01-02"
  9476. // loc, _ := time.LoadLocation("Local")
  9477. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9478. // if err != nil {
  9479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9480. // return
  9481. // }
  9482. // recordDateTime := theTime.Unix()
  9483. //
  9484. // adminInfo := c.GetAdminUserInfo()
  9485. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9486. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9487. //
  9488. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9489. //
  9490. // fmt.Println(miConfig.SecretKey)
  9491. //
  9492. // if patient == nil {
  9493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9494. // return
  9495. // }
  9496. // if len(patient.IdCardNo) == 0 {
  9497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9498. // return
  9499. // }
  9500. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9501. // if config.IsOpen == 1 {
  9502. // 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
  9503. // resp, requestErr := http.Get(api)
  9504. // if requestErr != nil {
  9505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9506. // return
  9507. // }
  9508. // defer resp.Body.Close()
  9509. // body, ioErr := ioutil.ReadAll(resp.Body)
  9510. // if ioErr != nil {
  9511. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. // return
  9514. // }
  9515. // var respJSON map[string]interface{}
  9516. //
  9517. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9518. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9520. // return
  9521. // }
  9522. //
  9523. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9524. // userJSONBytes, _ := json.Marshal(userJSON)
  9525. // var res ResultTwo
  9526. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9527. // utils.ErrorLog("解析失败:%v", err)
  9528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. // return
  9530. // }
  9531. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9532. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9533. // infoStr := string(Iinfos)
  9534. // idetinfoStr := string(Idetinfos)
  9535. //
  9536. // if res.Infcode == 0 {
  9537. // his := models.VMHisPatient{
  9538. // Status: 1,
  9539. // Ctime: time.Now().Unix(),
  9540. // Mtime: time.Now().Unix(),
  9541. // PsnNo: res.Output.Baseinfo.PsnNo,
  9542. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9543. // Certno: res.Output.Baseinfo.Certno,
  9544. // PsnName: res.Output.Baseinfo.PsnName,
  9545. // Gend: res.Output.Baseinfo.Gend,
  9546. // Naty: res.Output.Baseinfo.Naty,
  9547. // Brdy: res.Output.Baseinfo.Brdy,
  9548. // Age: res.Output.Baseinfo.Age,
  9549. // Iinfo: infoStr,
  9550. // Idetinfo: idetinfoStr,
  9551. // PatientId: patient.ID,
  9552. // RecordDate: theTime.Unix(),
  9553. // UserOrgId: adminInfo.CurrentOrgId,
  9554. // AdminUserId: adminInfo.AdminUser.Id,
  9555. // IsReturn: 1,
  9556. // }
  9557. //
  9558. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9559. // //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")
  9560. // //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")
  9561. //
  9562. // //var dat map[string]interface{}
  9563. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9564. // // fmt.Println(dat)
  9565. // //} else {
  9566. // // fmt.Println(err)
  9567. // //}
  9568. //
  9569. // var dat2 map[string]interface{}
  9570. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9571. // fmt.Println(dat2)
  9572. // } else {
  9573. // fmt.Println(err)
  9574. // }
  9575. //
  9576. // } else {
  9577. // adminUser := c.GetAdminUserInfo()
  9578. // errlog := &models.HisOrderError{
  9579. // UserOrgId: adminUser.CurrentOrgId,
  9580. // Ctime: time.Now().Unix(),
  9581. // Mtime: time.Now().Unix(),
  9582. // ErrMsg: res.ErrMsg,
  9583. // Status: 1,
  9584. // PatientId: id,
  9585. // RecordTime: recordDateTime,
  9586. // Stage: 1,
  9587. // }
  9588. // service.CreateErrMsgLog(errlog)
  9589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9590. // return
  9591. // }
  9592. // }
  9593. //
  9594. //}
  9595. //func (c *HisApiController) GetUploadDiag() {
  9596. // id, _ := c.GetInt64("id")
  9597. // record_time := c.GetString("record_time")
  9598. //
  9599. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9600. // sick_type, _ := c.GetInt64("sick_type")
  9601. // reg_type, _ := c.GetInt64("reg_type")
  9602. //
  9603. // timeLayout := "2006-01-02"
  9604. // loc, _ := time.LoadLocation("Local")
  9605. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9606. // if err != nil {
  9607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9608. // return
  9609. // }
  9610. //
  9611. // var patientPrescription models.HisPrescriptionInfo
  9612. // recordDateTime := theTime.Unix()
  9613. // adminInfo := c.GetAdminUserInfo()
  9614. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9615. //
  9616. // if patientPrescription.ID == 0 {
  9617. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9618. // }
  9619. //
  9620. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9621. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9622. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9623. // sickConfig, _ := service.FindSickById(sick_type)
  9624. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9625. //
  9626. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9627. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9628. // "&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 +
  9629. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9630. // resp2, requestErr2 := http.Get(api2)
  9631. // if requestErr2 != nil {
  9632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9633. // return
  9634. // }
  9635. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9636. // if ioErr2 != nil {
  9637. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9639. // return
  9640. // }
  9641. // var respJSON2 map[string]interface{}
  9642. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9643. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9645. // return
  9646. // }
  9647. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9648. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9649. //
  9650. // var res2 ResultSix
  9651. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9652. // utils.ErrorLog("解析失败:%v", err)
  9653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. // return
  9655. // }
  9656. // if res2.Infcode != 0 {
  9657. // adminUser := c.GetAdminUserInfo()
  9658. // errlog := &models.HisOrderError{
  9659. // UserOrgId: adminUser.CurrentOrgId,
  9660. // Ctime: time.Now().Unix(),
  9661. // Mtime: time.Now().Unix(),
  9662. // ErrMsg: res2.ErrMsg,
  9663. // Status: 1,
  9664. // PatientId: id,
  9665. // RecordTime: recordDateTime,
  9666. // Stage: 3,
  9667. // }
  9668. // service.CreateErrMsgLog(errlog)
  9669. //
  9670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9671. // return
  9672. // }
  9673. //
  9674. // c.ServeSuccessJSON(map[string]interface{}{
  9675. // "msg": "上传成功",
  9676. // })
  9677. //
  9678. //}
  9679. type QueryResult struct {
  9680. ID int64
  9681. Name string
  9682. Code string
  9683. List_type_code string
  9684. }
  9685. func (c *HisApiController) GetCheckCode() {
  9686. ids_str := c.GetString("ids")
  9687. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9688. ids_arr := strings.Split(ids_str, ",")
  9689. var queryResult []QueryResult
  9690. ids := make([]int64, 0)
  9691. for _, item := range ids_arr {
  9692. id, _ := strconv.ParseInt(item, 10, 64)
  9693. ids = append(ids, id)
  9694. }
  9695. if record_type == 1 {
  9696. drugs, _ := service.GetBatchDrugList(ids)
  9697. for _, item := range drugs {
  9698. result := QueryResult{
  9699. ID: item.ID,
  9700. Name: item.DrugName,
  9701. Code: item.MedicalInsuranceNumber,
  9702. List_type_code: "101",
  9703. }
  9704. queryResult = append(queryResult, result)
  9705. }
  9706. } else if record_type == 2 {
  9707. goods, _ := service.GetBatchGoodInformationList(ids)
  9708. for _, item := range goods {
  9709. result := QueryResult{
  9710. ID: item.ID,
  9711. Name: item.GoodName,
  9712. Code: item.MedicalInsuranceNumber,
  9713. List_type_code: "301",
  9714. }
  9715. queryResult = append(queryResult, result)
  9716. }
  9717. } else if record_type == 3 {
  9718. projects, _ := service.GetBathchMyPorjecgList(ids)
  9719. for _, item := range projects {
  9720. result := QueryResult{
  9721. ID: item.ID,
  9722. Name: item.ProjectName,
  9723. Code: item.MedicalCode,
  9724. List_type_code: "201",
  9725. }
  9726. queryResult = append(queryResult, result)
  9727. }
  9728. }
  9729. admin_user_id, _ := c.GetInt64("admin_user_id")
  9730. adminUser := c.GetAdminUserInfo()
  9731. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9732. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9733. var user_name string
  9734. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9735. if role.ID == 0 {
  9736. user_name = "xxx"
  9737. } else {
  9738. user_name = role.UserName
  9739. }
  9740. baseParams := &models.BaseParams{
  9741. SecretKey: miConfig.SecretKey,
  9742. FixmedinsCode: miConfig.Code,
  9743. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9744. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9745. OrgName: miConfig.OrgName,
  9746. Doctor: user_name,
  9747. }
  9748. if config.IsOpen == 1 {
  9749. for _, item := range queryResult {
  9750. var result string
  9751. if record_type == 1 {
  9752. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9753. } else if record_type == 2 {
  9754. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9755. } else if record_type == 3 {
  9756. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9757. }
  9758. var dat map[string]interface{}
  9759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9760. fmt.Println(dat)
  9761. } else {
  9762. fmt.Println(err)
  9763. }
  9764. userJSONBytes, _ := json.Marshal(dat)
  9765. var res ResultSix
  9766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9767. utils.ErrorLog("解析失败:%v", err)
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9769. return
  9770. }
  9771. if res.Infcode == 0 {
  9772. if record_type == 1 {
  9773. service.UpdateBaseDrugById(item.ID)
  9774. } else if record_type == 2 {
  9775. service.UpdateGoodInformaitonByDetail(item.ID)
  9776. } else if record_type == 3 {
  9777. service.UpdateProjectById(item.ID)
  9778. }
  9779. c.ServeSuccessJSON(map[string]interface{}{
  9780. "failed_code": 0,
  9781. "msg": "目录对照成功",
  9782. })
  9783. } else {
  9784. c.ServeSuccessJSON(map[string]interface{}{
  9785. "failed_code": -10,
  9786. "msg": res.ErrMsg,
  9787. })
  9788. }
  9789. }
  9790. }
  9791. }
  9792. func (c *HisApiController) UnCheckCode() {
  9793. ids_str := c.GetString("ids")
  9794. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9795. admin_user_id, _ := c.GetInt64("admin_user_id")
  9796. ids_arr := strings.Split(ids_str, ",")
  9797. var queryResult []QueryResult
  9798. ids := make([]int64, 0)
  9799. for _, item := range ids_arr {
  9800. id, _ := strconv.ParseInt(item, 10, 64)
  9801. ids = append(ids, id)
  9802. }
  9803. if record_type == 1 {
  9804. drugs, _ := service.GetBatchDrugList(ids)
  9805. for _, item := range drugs {
  9806. result := QueryResult{
  9807. ID: item.ID,
  9808. Name: item.DrugName,
  9809. Code: item.MedicalInsuranceNumber,
  9810. List_type_code: "101",
  9811. }
  9812. queryResult = append(queryResult, result)
  9813. }
  9814. } else if record_type == 2 {
  9815. goods, _ := service.GetBatchGoodInformationList(ids)
  9816. for _, item := range goods {
  9817. result := QueryResult{
  9818. ID: item.ID,
  9819. Name: item.GoodName,
  9820. Code: item.MedicalInsuranceNumber,
  9821. List_type_code: "301",
  9822. }
  9823. queryResult = append(queryResult, result)
  9824. }
  9825. } else if record_type == 3 {
  9826. projects, _ := service.GetBathchMyPorjecgList(ids)
  9827. for _, item := range projects {
  9828. result := QueryResult{
  9829. ID: item.ID,
  9830. Name: item.ProjectName,
  9831. Code: item.MedicalCode,
  9832. List_type_code: "201",
  9833. }
  9834. queryResult = append(queryResult, result)
  9835. }
  9836. }
  9837. adminUser := c.GetAdminUserInfo()
  9838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9839. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9840. var user_name string
  9841. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9842. if role.ID == 0 {
  9843. user_name = "xxx"
  9844. } else {
  9845. user_name = role.UserName
  9846. }
  9847. baseParams := &models.BaseParams{
  9848. SecretKey: miConfig.SecretKey,
  9849. FixmedinsCode: miConfig.Code,
  9850. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9851. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9852. OrgName: miConfig.OrgName,
  9853. Doctor: user_name,
  9854. }
  9855. if config.IsOpen == 1 {
  9856. for _, item := range queryResult {
  9857. var result string
  9858. if record_type == 1 {
  9859. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9860. } else if record_type == 2 {
  9861. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9862. } else if record_type == 3 {
  9863. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9864. }
  9865. var dat2 map[string]interface{}
  9866. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9867. fmt.Println(dat2)
  9868. } else {
  9869. fmt.Println(err)
  9870. }
  9871. userJSONBytes, _ := json.Marshal(dat2)
  9872. var res ResultSix
  9873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9874. utils.ErrorLog("解析失败:%v", err)
  9875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9876. return
  9877. }
  9878. if res.Infcode == 0 {
  9879. if record_type == 1 {
  9880. service.UpdateDrugByIdDetail(item.ID)
  9881. } else if record_type == 2 {
  9882. service.UpdateGoodInfoById(item.ID)
  9883. } else if record_type == 3 {
  9884. service.UpdateMyProjectById(item.ID)
  9885. }
  9886. c.ServeSuccessJSON(map[string]interface{}{
  9887. "failed_code": 0,
  9888. "msg": "撤销目录对照成功",
  9889. })
  9890. } else {
  9891. c.ServeSuccessJSON(map[string]interface{}{
  9892. "failed_code": -10,
  9893. "msg": res.ErrMsg,
  9894. })
  9895. }
  9896. }
  9897. }
  9898. }
  9899. func (c *HisApiController) GetPatientInfo() {
  9900. id_card_no := c.GetString("id_card_no")
  9901. admin_user_id, _ := c.GetInt64("admin_user_id")
  9902. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9903. if patient.ID == 0 {
  9904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9905. return
  9906. }
  9907. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9908. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9909. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9910. if config.IsOpen == 1 {
  9911. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9912. var dat map[string]interface{}
  9913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9914. fmt.Println(dat)
  9915. } else {
  9916. fmt.Println(err)
  9917. }
  9918. userJSONBytes, _ := json.Marshal(dat)
  9919. var res ResultTwo
  9920. var res10265 ResultTwo10265
  9921. if miConfig.Code == "H15049901371" {
  9922. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9923. utils.ErrorLog("解析失败:%v", err)
  9924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9925. return
  9926. }
  9927. res.ErrMsg = res10265.ErrMsg
  9928. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9929. res.Infcode = infocode
  9930. res.Output = res10265.Output
  9931. res.InfRefmsgid = res10265.InfRefmsgid
  9932. } else {
  9933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9934. utils.ErrorLog("解析失败:%v", err)
  9935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9936. return
  9937. }
  9938. }
  9939. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9940. // utils.ErrorLog("解析失败:%v", err)
  9941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. // return
  9943. //}
  9944. if res.Infcode != 0 {
  9945. c.ServeSuccessJSON(map[string]interface{}{
  9946. "failed_code": -10,
  9947. "msg": res.ErrMsg,
  9948. })
  9949. } else {
  9950. c.ServeSuccessJSON(map[string]interface{}{
  9951. "failed_code": 0,
  9952. "info": res,
  9953. })
  9954. }
  9955. }
  9956. }
  9957. func (c *HisApiController) PsnPutOnRecord() {
  9958. record_type, _ := c.GetInt64("type")
  9959. patient_id, _ := c.GetInt64("patient_id")
  9960. admin_user_id, _ := c.GetInt64("admin_user_id")
  9961. start_time := c.GetString("start_time")
  9962. end_time := c.GetString("end_time")
  9963. adminUser := c.GetAdminUserInfo()
  9964. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9965. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9966. var patients []*models.Patients
  9967. if record_type == 1 { //全部备案
  9968. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9969. patients = append(patients, patient...)
  9970. } else { //单个备案
  9971. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9972. patients = append(patients, patient)
  9973. }
  9974. var user_name string
  9975. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9976. if role.ID == 0 {
  9977. user_name = "xxx"
  9978. } else {
  9979. user_name = role.UserName
  9980. }
  9981. if config.IsOpen == 1 {
  9982. for _, item := range patients {
  9983. 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
  9984. resp, requestErr := http.Get(api)
  9985. if requestErr != nil {
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9987. return
  9988. }
  9989. defer resp.Body.Close()
  9990. body, ioErr := ioutil.ReadAll(resp.Body)
  9991. if ioErr != nil {
  9992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9994. return
  9995. }
  9996. var respJSON map[string]interface{}
  9997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. return
  10001. }
  10002. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10003. userJSONBytes, _ := json.Marshal(userJSON)
  10004. var res ResultTwo
  10005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10006. utils.ErrorLog("解析失败:%v", err)
  10007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10008. return
  10009. }
  10010. if res.Infcode == 0 {
  10011. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10012. var dat map[string]interface{}
  10013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10014. fmt.Println(dat)
  10015. } else {
  10016. fmt.Println(err)
  10017. }
  10018. userJSONBytes, _ := json.Marshal(dat)
  10019. var res2 ResultThirteen
  10020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10021. utils.ErrorLog("解析失败:%v", err)
  10022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10023. return
  10024. }
  10025. if res2.Infcode == 0 {
  10026. psnResult := &models.GdybPsnRecord{
  10027. UserOrgId: adminUser.CurrentOrgId,
  10028. PatientId: item.ID,
  10029. PsnNo: res.Output.Baseinfo.PsnNo,
  10030. Ctime: time.Now().Unix(),
  10031. Mtime: time.Now().Unix(),
  10032. Status: 1,
  10033. IsCancel: 1,
  10034. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10035. }
  10036. service.CreatePsnRecord(psnResult)
  10037. } else {
  10038. c.ServeSuccessJSON(map[string]interface{}{
  10039. "failed_code": -10,
  10040. "msg": res2.ErrMsg,
  10041. })
  10042. return
  10043. }
  10044. }
  10045. }
  10046. }
  10047. }
  10048. func (c *HisApiController) PsnUnPutOnRecord() {
  10049. id, _ := c.GetInt64("id")
  10050. //record_type, _ := c.GetInt64("type")
  10051. admin_user_id, _ := c.GetInt64("admin_user_id")
  10052. adminUser := c.GetAdminUserInfo()
  10053. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10054. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10055. var user_name string
  10056. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10057. if role.ID == 0 {
  10058. user_name = "xxx"
  10059. } else {
  10060. user_name = role.UserName
  10061. }
  10062. psn_record, _ := service.GetPsnRecordById(id)
  10063. if psn_record.ID == 0 {
  10064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10065. return
  10066. }
  10067. if config.IsOpen == 1 {
  10068. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10069. var dat map[string]interface{}
  10070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10071. fmt.Println(dat)
  10072. } else {
  10073. fmt.Println(err)
  10074. }
  10075. userJSONBytes, _ := json.Marshal(dat)
  10076. var res ResultFourteen
  10077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10078. utils.ErrorLog("解析失败:%v", err)
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10080. return
  10081. }
  10082. if res.Infcode == 0 {
  10083. psn_record.IsCancel = 2
  10084. service.CreatePsnRecord(&psn_record)
  10085. } else {
  10086. c.ServeSuccessJSON(map[string]interface{}{
  10087. "failed_code": -10,
  10088. "msg": res.ErrMsg,
  10089. })
  10090. return
  10091. }
  10092. }
  10093. }
  10094. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10095. patient_id, _ := c.GetInt64("patient_id")
  10096. insutype_two := c.GetString("insutype")
  10097. psn_no := c.GetString("psn_no")
  10098. doctor_id, _ := c.GetInt64("doctor_id")
  10099. sick_id, _ := c.GetInt64("sick_id")
  10100. department_id, _ := c.GetInt64("department_id")
  10101. start_time := c.GetString("start_time")
  10102. end_time := c.GetString("end_time")
  10103. check_time := c.GetString("check_time")
  10104. adminUser := c.GetAdminUserInfo()
  10105. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10106. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10107. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10108. sick, _ := service.FindSickById(sick_id)
  10109. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10110. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10111. var res ResultTwo
  10112. var res10265 ResultTwo10265
  10113. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10114. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10115. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10116. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10117. "&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
  10118. resp, requestErr := http.Get(api)
  10119. if requestErr != nil {
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. body, ioErr := ioutil.ReadAll(resp.Body)
  10124. if ioErr != nil {
  10125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. return
  10128. }
  10129. var respJSON map[string]interface{}
  10130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10133. return
  10134. }
  10135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10136. result, _ := json.Marshal(respJSON)
  10137. fmt.Println("log")
  10138. fmt.Println(string(result))
  10139. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10140. utils.ErrorLog("解析失败:%v", err)
  10141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10142. return
  10143. }
  10144. res.ErrMsg = res10265.ErrMsg
  10145. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10146. res.Infcode = infocode
  10147. res.Output = res10265.Output
  10148. res.InfRefmsgid = res10265.InfRefmsgid
  10149. } else {
  10150. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10151. if miConfig.Code == "H15049901371" {
  10152. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10153. utils.ErrorLog("解析失败:%v", err)
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10155. return
  10156. }
  10157. res.ErrMsg = res10265.ErrMsg
  10158. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10159. res.Infcode = infocode
  10160. res.Output = res10265.Output
  10161. res.InfRefmsgid = res10265.InfRefmsgid
  10162. } else {
  10163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10164. utils.ErrorLog("解析失败:%v", err)
  10165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10166. return
  10167. }
  10168. }
  10169. }
  10170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10171. infoStr := string(Iinfos)
  10172. var rf []*ResultFive
  10173. json.Unmarshal([]byte(infoStr), &rf)
  10174. var insuplc_admdvs string
  10175. var insutype string
  10176. var is390 int = 0
  10177. var is310 int = 0
  10178. var insutypes []*ResultFive
  10179. for _, item := range rf {
  10180. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10181. insutypes = append(insutypes, item)
  10182. }
  10183. }
  10184. if len(insutypes) == 1 {
  10185. insutype = insutypes[0].Insutype
  10186. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10187. } else {
  10188. for _, i := range insutypes {
  10189. if i.Insutype == "390" {
  10190. is390 = 1
  10191. }
  10192. if i.Insutype == "310" {
  10193. is310 = 1
  10194. }
  10195. }
  10196. }
  10197. if is390 == 1 {
  10198. insutype = "390"
  10199. }
  10200. if is310 == 1 {
  10201. insutype = "310"
  10202. }
  10203. if len(insutypes) == 2 {
  10204. insutype = insutype_two
  10205. }
  10206. if len(insutypes) == 0 {
  10207. insutype = "310"
  10208. }
  10209. insutype = insutype_two
  10210. fmt.Println(insutype)
  10211. for _, item := range rf {
  10212. fmt.Println(item.Insutype)
  10213. fmt.Println(insutype)
  10214. if item.Insutype == insutype {
  10215. fmt.Println(item.Insutype)
  10216. fmt.Println(insutype)
  10217. insuplc_admdvs = item.InsuplcAdmdvs
  10218. }
  10219. }
  10220. fmt.Println(insuplc_admdvs)
  10221. var res2 ResultThirteen
  10222. var res10265_2 ResultThirteen10265
  10223. if config.IsOpen == 1 {
  10224. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10225. } else {
  10226. 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)
  10227. var dat map[string]interface{}
  10228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10229. fmt.Println(dat)
  10230. } else {
  10231. fmt.Println(err)
  10232. }
  10233. userJSONBytes, _ := json.Marshal(dat)
  10234. if miConfig.Code == "H15049901371" {
  10235. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10236. utils.ErrorLog("解析失败:%v", err)
  10237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10238. return
  10239. }
  10240. res2.ErrMsg = res10265_2.ErrMsg
  10241. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10242. res2.Infcode = infocode
  10243. res2.Output = res10265_2.Output
  10244. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10245. } else {
  10246. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10247. utils.ErrorLog("解析失败:%v", err)
  10248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10249. return
  10250. }
  10251. }
  10252. }
  10253. if res2.Infcode == 0 {
  10254. psnResult := &models.GdybPsnNcdsRecord{
  10255. UserOrgId: adminUser.CurrentOrgId,
  10256. PatientId: patient.ID,
  10257. PsnNo: psn_no,
  10258. DoctorId: doctor.AdminUserId,
  10259. DepartmentId: department_id,
  10260. SickType: sick_id,
  10261. Insutype: insutype,
  10262. Ctime: time.Now().Unix(),
  10263. Mtime: time.Now().Unix(),
  10264. Status: 1,
  10265. IsCancel: 1,
  10266. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10267. }
  10268. service.CreatePsnNCDSRecord(psnResult)
  10269. c.ServeSuccessJSON(map[string]interface{}{
  10270. "failed_code": 0,
  10271. "msg": "备案成功",
  10272. "result": psnResult,
  10273. })
  10274. } else {
  10275. c.ServeSuccessJSON(map[string]interface{}{
  10276. "failed_code": -10,
  10277. "msg": res2.ErrMsg,
  10278. })
  10279. return
  10280. }
  10281. }
  10282. }
  10283. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10284. id, _ := c.GetInt64("id")
  10285. admin_user_id, _ := c.GetInt64("admin_user_id")
  10286. adminUser := c.GetAdminUserInfo()
  10287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10288. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10289. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10290. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10291. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10292. //var user_name string
  10293. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10294. //if role.ID == 0 {
  10295. // user_name = "xxx"
  10296. //} else {
  10297. // user_name = role.UserName
  10298. //}
  10299. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10300. if psn_record.ID == 0 {
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10302. return
  10303. }
  10304. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10305. var res ResultTwo
  10306. var res10265 ResultTwo10265
  10307. if miConfig.Code == "H15049901371" {
  10308. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10309. utils.ErrorLog("解析失败:%v", err)
  10310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10311. return
  10312. }
  10313. res.ErrMsg = res10265.ErrMsg
  10314. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10315. res.Infcode = infocode
  10316. res.Output = res10265.Output
  10317. res.InfRefmsgid = res10265.InfRefmsgid
  10318. } else {
  10319. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10320. utils.ErrorLog("解析失败:%v", err)
  10321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10322. return
  10323. }
  10324. }
  10325. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10326. infoStr := string(Iinfos)
  10327. var rf []*ResultFive
  10328. json.Unmarshal([]byte(infoStr), &rf)
  10329. var insuplc_admdvs string
  10330. var insutype string
  10331. var is390 int = 0
  10332. var is310 int = 0
  10333. var insutypes []*ResultFive
  10334. for _, item := range rf {
  10335. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10336. insutypes = append(insutypes, item)
  10337. }
  10338. }
  10339. if len(insutypes) == 1 {
  10340. insutype = insutypes[0].Insutype
  10341. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10342. } else {
  10343. for _, i := range insutypes {
  10344. if i.Insutype == "390" {
  10345. is390 = 1
  10346. }
  10347. if i.Insutype == "310" {
  10348. is310 = 1
  10349. }
  10350. }
  10351. }
  10352. if is390 == 1 {
  10353. insutype = "390"
  10354. }
  10355. if is310 == 1 {
  10356. insutype = "310"
  10357. }
  10358. if len(insutypes) == 0 {
  10359. insutype = "310"
  10360. }
  10361. insutype = psn_record.Insutype
  10362. for _, item := range rf {
  10363. if item.Insutype == insutype {
  10364. insuplc_admdvs = item.InsuplcAdmdvs
  10365. }
  10366. }
  10367. if config.IsOpen == 1 {
  10368. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10369. var dat map[string]interface{}
  10370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10371. fmt.Println(dat)
  10372. } else {
  10373. fmt.Println(err)
  10374. }
  10375. userJSONBytes, _ := json.Marshal(dat)
  10376. var res ResultFourteen
  10377. var res10265 ResultFourteen10265
  10378. if miConfig.Code == "H15049901371" {
  10379. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10380. utils.ErrorLog("解析失败:%v", err)
  10381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10382. return
  10383. }
  10384. res.ErrMsg = res10265.ErrMsg
  10385. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10386. res.Infcode = infocode
  10387. res.Output = res10265.Output
  10388. res.InfRefmsgid = res10265.InfRefmsgid
  10389. } else {
  10390. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10391. utils.ErrorLog("解析失败:%v", err)
  10392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10393. return
  10394. }
  10395. }
  10396. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10397. // utils.ErrorLog("解析失败:%v", err)
  10398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10399. // return
  10400. //}
  10401. if res.Infcode == 0 {
  10402. psn_record.IsCancel = 2
  10403. service.CreatePsnNCDSRecord(&psn_record)
  10404. c.ServeSuccessJSON(map[string]interface{}{
  10405. "failed_code": 0,
  10406. "msg": "撤销备案成功",
  10407. })
  10408. } else {
  10409. c.ServeSuccessJSON(map[string]interface{}{
  10410. "failed_code": -10,
  10411. "msg": res.ErrMsg,
  10412. })
  10413. return
  10414. }
  10415. }
  10416. }
  10417. func (c *HisApiController) TestTest() {
  10418. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10419. fmt.Println(patient.Iinfo)
  10420. }
  10421. type CustomData struct {
  10422. MsgId string
  10423. PsnNo string
  10424. Info string
  10425. }
  10426. func (c *HisApiController) ReversalData() {
  10427. var customData []*CustomData
  10428. custom := &CustomData{
  10429. MsgId: "H44022900158202103301714472004",
  10430. PsnNo: "44020000001101329945",
  10431. Info: "2207",
  10432. }
  10433. customData = append(customData, custom)
  10434. custom1 := &CustomData{
  10435. MsgId: "H4402290015820210330172057803",
  10436. PsnNo: "44020000001101161813",
  10437. Info: "2207",
  10438. }
  10439. customData = append(customData, custom1)
  10440. custom2 := &CustomData{
  10441. MsgId: "H44022900158202103301705198813",
  10442. PsnNo: "44190000133097375417",
  10443. Info: "2207",
  10444. }
  10445. customData = append(customData, custom2)
  10446. custom3 := &CustomData{
  10447. MsgId: "H44022900158202103301715524756",
  10448. PsnNo: "44020000001100187221",
  10449. Info: "2207",
  10450. }
  10451. customData = append(customData, custom3)
  10452. custom4 := &CustomData{
  10453. MsgId: "H44022900158202103301730376224",
  10454. PsnNo: "44020000001101959155",
  10455. Info: "2207",
  10456. }
  10457. customData = append(customData, custom4)
  10458. custom5 := &CustomData{
  10459. MsgId: "H44022900158202103301748008725",
  10460. PsnNo: "44020000001104246641",
  10461. Info: "2207",
  10462. }
  10463. customData = append(customData, custom5)
  10464. custom6 := &CustomData{
  10465. MsgId: "H44022900158202103301718096755",
  10466. PsnNo: "44020000001102211860",
  10467. Info: "2207",
  10468. }
  10469. customData = append(customData, custom6)
  10470. custom7 := &CustomData{
  10471. MsgId: "H44022900158202103301736551640",
  10472. PsnNo: "44020000001102687718",
  10473. Info: "2207",
  10474. }
  10475. customData = append(customData, custom7)
  10476. custom8 := &CustomData{
  10477. MsgId: "H44022900158202103301743097676",
  10478. PsnNo: "44020000001102127785",
  10479. Info: "2207",
  10480. }
  10481. customData = append(customData, custom8)
  10482. custom9 := &CustomData{
  10483. MsgId: "H44022900158202103301712304203",
  10484. PsnNo: "44020000001101518097",
  10485. Info: "2207",
  10486. }
  10487. customData = append(customData, custom9)
  10488. custom10 := &CustomData{
  10489. MsgId: "H44022900158202103301738448785",
  10490. PsnNo: "44020000001100500813",
  10491. Info: "2207",
  10492. }
  10493. customData = append(customData, custom10)
  10494. custom11 := &CustomData{
  10495. MsgId: "H44022900158202103301732455843",
  10496. PsnNo: "44020000001102690557",
  10497. Info: "2207",
  10498. }
  10499. customData = append(customData, custom11)
  10500. custom12 := &CustomData{
  10501. MsgId: "H44022900158202103301745421708",
  10502. PsnNo: "44020000001102211928",
  10503. Info: "2207",
  10504. }
  10505. customData = append(customData, custom12)
  10506. custom1212 := &CustomData{
  10507. MsgId: "H440229001582021033017351627",
  10508. PsnNo: "44020000001102481733",
  10509. Info: "2207",
  10510. }
  10511. customData = append(customData, custom1212)
  10512. custom13 := &CustomData{
  10513. MsgId: "H44022900158202103301740327951",
  10514. PsnNo: "44020000001103174866",
  10515. Info: "2207",
  10516. }
  10517. customData = append(customData, custom13)
  10518. custom14 := &CustomData{
  10519. MsgId: "H4402290015820210330174922668",
  10520. PsnNo: "44020000001102927272",
  10521. Info: "2207",
  10522. }
  10523. customData = append(customData, custom14)
  10524. custom15 := &CustomData{
  10525. MsgId: "H44022900158202103301752362273",
  10526. PsnNo: "44020000001102942890",
  10527. Info: "2207",
  10528. }
  10529. customData = append(customData, custom15)
  10530. custom16 := &CustomData{
  10531. MsgId: "H44022900158202103301751082917",
  10532. PsnNo: "44020000001101662162",
  10533. Info: "2207",
  10534. }
  10535. customData = append(customData, custom16)
  10536. custom17 := &CustomData{
  10537. MsgId: "H44022900158202103301754147728",
  10538. PsnNo: "44020000000229014511",
  10539. Info: "2207",
  10540. }
  10541. customData = append(customData, custom17)
  10542. adminUser := c.GetAdminUserInfo()
  10543. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10544. for _, item := range customData {
  10545. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10546. fmt.Println(result)
  10547. }
  10548. }
  10549. //func (c *HisApiController) GetAllopatry() {
  10550. // year := c.GetString("year")
  10551. // month := c.GetString("month")
  10552. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10553. // adminUser := c.GetAdminUserInfo()
  10554. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10555. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10556. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10557. //
  10558. // var dat map[string]interface{}
  10559. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10560. // fmt.Println(dat)
  10561. // } else {
  10562. // fmt.Println(err)
  10563. // }
  10564. // userJSONBytes, _ := json.Marshal(dat)
  10565. // var res models.Result9001
  10566. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10567. // utils.ErrorLog("解析失败:%v", err)
  10568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10569. // return
  10570. // }
  10571. //
  10572. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10573. // var dat2 map[string]interface{}
  10574. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10575. // fmt.Println(dat)
  10576. // } else {
  10577. // fmt.Println(err)
  10578. // }
  10579. // userJSONBytes2, _ := json.Marshal(dat2)
  10580. // var res2 models.Result3260
  10581. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10582. // utils.ErrorLog("解析失败:%v", err)
  10583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10584. // return
  10585. // }
  10586. // if res2.Infcode == 0 {
  10587. // c.ServeSuccessJSON(map[string]interface{}{
  10588. // "list": res2.Output.Data,
  10589. // })
  10590. // return
  10591. // } else {
  10592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. // return
  10594. // }
  10595. //
  10596. //}
  10597. //func (c *HisApiController) ComfirmAllopatry() {
  10598. // year := c.GetString("year")
  10599. // month := c.GetString("month")
  10600. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10601. // adminUser := c.GetAdminUserInfo()
  10602. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10603. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10604. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10605. // var dat map[string]interface{}
  10606. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10607. // fmt.Println(dat)
  10608. // } else {
  10609. // fmt.Println(err)
  10610. // }
  10611. // userJSONBytes, _ := json.Marshal(dat)
  10612. // var res models.Result9001
  10613. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10614. // utils.ErrorLog("解析失败:%v", err)
  10615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10616. // return
  10617. // }
  10618. //
  10619. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10620. // var dat2 map[string]interface{}
  10621. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10622. // fmt.Println(dat)
  10623. // } else {
  10624. // fmt.Println(err)
  10625. // }
  10626. // userJSONBytes2, _ := json.Marshal(dat2)
  10627. // var res2 models.Result3260
  10628. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10629. // utils.ErrorLog("解析失败:%v", err)
  10630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10631. // return
  10632. // }
  10633. //
  10634. // if res2.Infcode == 0 {
  10635. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10636. // var dat map[string]interface{}
  10637. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10638. // fmt.Println(dat)
  10639. // } else {
  10640. // fmt.Println(err)
  10641. // }
  10642. // userJSONBytes, _ := json.Marshal(dat)
  10643. // var res3 models.Result3261
  10644. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10645. // utils.ErrorLog("解析失败:%v", err)
  10646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10647. // return
  10648. // }
  10649. //
  10650. // if res3.Infcode == 0 {
  10651. // record := &models.HisYidiClearRecord{
  10652. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10653. // Ctime: time.Now().Unix(),
  10654. // Mtime: time.Now().Unix(),
  10655. // Status: 1,
  10656. // MsgId: msgId,
  10657. // }
  10658. // service.SaveClearRecord(record)
  10659. // c.ServeSuccessJSON(map[string]interface{}{
  10660. // "msg": "提取成功",
  10661. // })
  10662. // }
  10663. // }
  10664. //}
  10665. func (c *HisApiController) RefundAllopatry() {
  10666. year := c.GetString("year")
  10667. month := c.GetString("month")
  10668. id, _ := c.GetInt64("id")
  10669. admin_user_id, _ := c.GetInt64("admin_user_id")
  10670. adminUser := c.GetAdminUserInfo()
  10671. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10672. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10673. record, _ := service.GetClearRecordById(id)
  10674. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10675. var dat map[string]interface{}
  10676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10677. fmt.Println(dat)
  10678. } else {
  10679. fmt.Println(err)
  10680. }
  10681. userJSONBytes, _ := json.Marshal(dat)
  10682. var empty ResultFourteen
  10683. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10684. utils.ErrorLog("解析失败:%v", err)
  10685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10686. return
  10687. }
  10688. if empty.Infcode == 0 {
  10689. c.ServeSuccessJSON(map[string]interface{}{
  10690. "msg": "撤销成功",
  10691. })
  10692. return
  10693. }
  10694. }
  10695. func (c *HisApiController) ReversalOtherData() {
  10696. var customData []*CustomData
  10697. custom := &CustomData{
  10698. MsgId: "H44022900158202103301714472004",
  10699. PsnNo: "44020000001101329945",
  10700. Info: "2208",
  10701. }
  10702. customData = append(customData, custom)
  10703. custom1 := &CustomData{
  10704. MsgId: "H4402290015820210330172057803",
  10705. PsnNo: "44020000001101161813",
  10706. Info: "2208",
  10707. }
  10708. customData = append(customData, custom1)
  10709. custom2 := &CustomData{
  10710. MsgId: "H44022900158202103301705198813",
  10711. PsnNo: "44190000133097375417",
  10712. Info: "2208",
  10713. }
  10714. customData = append(customData, custom2)
  10715. custom3 := &CustomData{
  10716. MsgId: "H44022900158202103301715524756",
  10717. PsnNo: "44020000001100187221",
  10718. Info: "2208",
  10719. }
  10720. customData = append(customData, custom3)
  10721. custom4 := &CustomData{
  10722. MsgId: "H44022900158202103301730376224",
  10723. PsnNo: "44020000001101959155",
  10724. Info: "2208",
  10725. }
  10726. customData = append(customData, custom4)
  10727. custom5 := &CustomData{
  10728. MsgId: "H44022900158202103301748008725",
  10729. PsnNo: "44020000001104246641",
  10730. Info: "2208",
  10731. }
  10732. customData = append(customData, custom5)
  10733. custom6 := &CustomData{
  10734. MsgId: "H44022900158202103301718096755",
  10735. PsnNo: "44020000001102211860",
  10736. Info: "2208",
  10737. }
  10738. customData = append(customData, custom6)
  10739. custom7 := &CustomData{
  10740. MsgId: "H44022900158202103301736551640",
  10741. PsnNo: "44020000001102687718",
  10742. Info: "2208",
  10743. }
  10744. customData = append(customData, custom7)
  10745. custom8 := &CustomData{
  10746. MsgId: "H44022900158202103301743097676",
  10747. PsnNo: "44020000001102127785",
  10748. Info: "2208",
  10749. }
  10750. customData = append(customData, custom8)
  10751. custom9 := &CustomData{
  10752. MsgId: "H44022900158202103301712304203",
  10753. PsnNo: "44020000001101518097",
  10754. Info: "2208",
  10755. }
  10756. customData = append(customData, custom9)
  10757. custom10 := &CustomData{
  10758. MsgId: "H44022900158202103301738448785",
  10759. PsnNo: "44020000001100500813",
  10760. Info: "2208",
  10761. }
  10762. customData = append(customData, custom10)
  10763. custom11 := &CustomData{
  10764. MsgId: "H44022900158202103301732455843",
  10765. PsnNo: "44020000001102690557",
  10766. Info: "2208",
  10767. }
  10768. customData = append(customData, custom11)
  10769. custom12 := &CustomData{
  10770. MsgId: "H44022900158202103301745421708",
  10771. PsnNo: "44020000001102211928",
  10772. Info: "2208",
  10773. }
  10774. customData = append(customData, custom12)
  10775. custom1212 := &CustomData{
  10776. MsgId: "H440229001582021033017351627",
  10777. PsnNo: "44020000001102481733",
  10778. Info: "2208",
  10779. }
  10780. customData = append(customData, custom1212)
  10781. custom13 := &CustomData{
  10782. MsgId: "H44022900158202103301740327951",
  10783. PsnNo: "44020000001103174866",
  10784. Info: "2208",
  10785. }
  10786. customData = append(customData, custom13)
  10787. custom14 := &CustomData{
  10788. MsgId: "H4402290015820210330174922668",
  10789. PsnNo: "44020000001102927272",
  10790. Info: "2208",
  10791. }
  10792. customData = append(customData, custom14)
  10793. custom15 := &CustomData{
  10794. MsgId: "H44022900158202103301752362273",
  10795. PsnNo: "44020000001102942890",
  10796. Info: "2208",
  10797. }
  10798. customData = append(customData, custom15)
  10799. custom16 := &CustomData{
  10800. MsgId: "H44022900158202103301751082917",
  10801. PsnNo: "44020000001101662162",
  10802. Info: "2208",
  10803. }
  10804. customData = append(customData, custom16)
  10805. custom17 := &CustomData{
  10806. MsgId: "H44022900158202103301754147728",
  10807. PsnNo: "44020000000229014511",
  10808. Info: "2208",
  10809. }
  10810. customData = append(customData, custom17)
  10811. adminUser := c.GetAdminUserInfo()
  10812. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10813. for _, item := range customData {
  10814. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10815. fmt.Println(result)
  10816. }
  10817. }
  10818. func PathExists(path string) (bool, error) {
  10819. _, err := os.Stat(path)
  10820. if err == nil {
  10821. return true, nil
  10822. }
  10823. if os.IsNotExist(err) {
  10824. return false, nil
  10825. }
  10826. return false, err
  10827. }
  10828. //创建文件夹
  10829. func Mkdir(dir string) {
  10830. // 创建文件夹
  10831. exist, err := PathExists(dir)
  10832. if err != nil {
  10833. fmt.Println(err.Error())
  10834. } else {
  10835. if exist {
  10836. fmt.Println(dir + "文件夹已存在!")
  10837. } else {
  10838. // 文件夹名称,权限
  10839. err := os.Mkdir(dir, os.ModePerm)
  10840. if err != nil {
  10841. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10842. } else {
  10843. fmt.Println(dir + "文件夹创建成功!")
  10844. }
  10845. }
  10846. }
  10847. }
  10848. //压缩文件
  10849. func Zip(srcFile string, destZip string) error {
  10850. zipfile, err := os.Create(destZip)
  10851. if err != nil {
  10852. return err
  10853. }
  10854. defer zipfile.Close()
  10855. archive := zip.NewWriter(zipfile)
  10856. defer archive.Close()
  10857. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10858. if err != nil {
  10859. return err
  10860. }
  10861. header, err := zip.FileInfoHeader(info)
  10862. if err != nil {
  10863. return err
  10864. }
  10865. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10866. // header.Name = path
  10867. if info.IsDir() {
  10868. header.Name += "/"
  10869. } else {
  10870. header.Method = zip.Deflate
  10871. }
  10872. writer, err := archive.CreateHeader(header)
  10873. if err != nil {
  10874. return err
  10875. }
  10876. if !info.IsDir() {
  10877. file, err := os.Open(path)
  10878. if err != nil {
  10879. return err
  10880. }
  10881. defer file.Close()
  10882. _, err = io.Copy(writer, file)
  10883. }
  10884. return err
  10885. })
  10886. return err
  10887. }
  10888. func ReadFile(filePath string) []byte {
  10889. f, err := os.Open(filePath)
  10890. if err != nil {
  10891. fmt.Println("read file fail", err)
  10892. return nil
  10893. }
  10894. defer f.Close()
  10895. fd, err := ioutil.ReadAll(f)
  10896. if err != nil {
  10897. fmt.Println("read to fd fail", err)
  10898. return nil
  10899. }
  10900. return fd
  10901. }
  10902. func saveLog(result string, request string, infno string, desc string) {
  10903. org_id, _ := beego.AppConfig.Int64("org_id")
  10904. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10905. dir := miConfig.OrgName + "日志"
  10906. utils.Mkdir(dir)
  10907. month := time.Unix(1557042972, 0).Format("1")
  10908. year := time.Now().Format("2006")
  10909. month = time.Now().Format("01")
  10910. day := time.Now().Format("02")
  10911. hour := time.Now().Format("15")
  10912. min := time.Now().Format("04")
  10913. sec := time.Now().Format("05")
  10914. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10915. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10916. file_name := file + ".txt"
  10917. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10918. exist, _ := utils.PathExists(file_path)
  10919. if exist { //存在
  10920. fmt.Println("存在")
  10921. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10922. if err != nil {
  10923. fmt.Println("read fail")
  10924. }
  10925. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10926. n, _ := f.Seek(0, 2)
  10927. _, err = f.WriteAt([]byte(content), n)
  10928. } else { //不存在
  10929. fmt.Println("文件不存在,创建文件")
  10930. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10931. defer f.Close()
  10932. if err != nil {
  10933. } else {
  10934. _, err = f.Write([]byte("记录日志"))
  10935. }
  10936. }
  10937. }
  10938. type Charset string
  10939. const (
  10940. UTF8 = Charset("UTF-8")
  10941. GB18030 = Charset("GB18030")
  10942. )
  10943. func ConvertToString(src string, srcCode string, tagCode string) string {
  10944. srcCoder := mahonia.NewDecoder(srcCode)
  10945. srcResult := srcCoder.ConvertString(src)
  10946. tagCoder := mahonia.NewDecoder(tagCode)
  10947. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10948. result := string(cdata)
  10949. return result
  10950. }
  10951. func (c *HisApiController) ReadEleCard() {
  10952. id_card_type, _ := c.GetInt64("id_card_type")
  10953. admin_user_id, _ := c.GetInt64("admin_user_id")
  10954. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10955. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10956. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10957. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10958. var api string
  10959. if miConfig.MdtrtareaAdmvs == "320921" {
  10960. 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 +
  10961. "&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
  10962. fmt.Println(api)
  10963. } else {
  10964. 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 +
  10965. "&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)
  10966. }
  10967. resp, requestErr := http.Get(api)
  10968. if requestErr != nil {
  10969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10970. return
  10971. }
  10972. body, ioErr := ioutil.ReadAll(resp.Body)
  10973. if ioErr != nil {
  10974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10976. return
  10977. }
  10978. var respJSON map[string]interface{}
  10979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10982. return
  10983. }
  10984. var status string
  10985. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10986. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10987. var token string
  10988. var res ResultTwo //1101结果
  10989. var res10265 ResultTwo10265 //1101结果
  10990. if status == "0" { //读卡成功
  10991. var card_info string //卡信息
  10992. var busi_card_info string
  10993. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10994. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10995. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10996. fmt.Println(card_info)
  10997. fmt.Println(busi_card_info)
  10998. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10999. result, _ := json.Marshal(respJSON)
  11000. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11001. utils.ErrorLog("解析失败:%v", err)
  11002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11003. return
  11004. }
  11005. res.ErrMsg = res10265.ErrMsg
  11006. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11007. res.Infcode = infocode
  11008. res.Output = res10265.Output
  11009. res.InfRefmsgid = res10265.InfRefmsgid
  11010. if res.Infcode == 0 {
  11011. c.ServeSuccessJSON(map[string]interface{}{
  11012. "number": token,
  11013. })
  11014. }
  11015. } else {
  11016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11017. return
  11018. }
  11019. } else { //读卡失败
  11020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11021. return
  11022. }
  11023. }
  11024. func DeleteExtraSpaceTwo(s string) string {
  11025. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11026. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11027. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11028. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11029. s2 := make([]byte, len(s1)) //定义字符数组切片
  11030. copy(s2, s1) //将字符串复制到切片
  11031. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11032. for len(spc_index) > 0 { //找到适配项
  11033. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11034. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11035. }
  11036. return string(s2)
  11037. }
  11038. func Remove0000(s string) string {
  11039. str := make([]rune, 0, len(s))
  11040. for _, v := range []rune(s) {
  11041. if v == 0 {
  11042. continue
  11043. }
  11044. str = append(str, v)
  11045. }
  11046. return string(str)
  11047. }
  11048. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11049. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11050. readCard := DllDef.MustFindProc("EcQuery")
  11051. pCardInfo := make([]byte, 8192)
  11052. pBusiCardInfo := make([]byte, 8192)
  11053. data := make(map[string]interface{})
  11054. //pData := make(map[string]interface{})
  11055. inputData := make(map[string]interface{})
  11056. inputData["orgId"] = code
  11057. inputData["businessType"] = "01101"
  11058. inputData["operatorId"] = operator_id
  11059. inputData["operatorName"] = operator_name
  11060. inputData["officeId"] = "001"
  11061. inputData["officeName"] = "血透室"
  11062. //
  11063. data["data"] = inputData
  11064. data["transType"] = "ec.query"
  11065. data["orgId"] = code
  11066. bytesData, _ := json.Marshal(data)
  11067. pCardInfo = bytesData
  11068. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11069. fmt.Println(ret2)
  11070. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11071. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11072. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11073. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11074. if ret2 != 0 {
  11075. return "", ""
  11076. }
  11077. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11078. }