his_api_controller.go 334KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  66. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  67. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  68. }
  69. func (c *HisApiController) GetPsnNcdsInfo() {
  70. admin_user_id, _ := c.GetInt64("admin_user_id")
  71. id, _ := c.GetInt64("id")
  72. adminUser := c.GetAdminUserInfo()
  73. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  74. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  75. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  76. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  77. psn_record, _ := service.GetPsnNCDSRecordById(id)
  78. if psn_record.ID == 0 {
  79. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  80. return
  81. }
  82. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  83. var dat map[string]interface{}
  84. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  85. fmt.Println(dat)
  86. } else {
  87. fmt.Println(err)
  88. }
  89. userJSONBytes, _ := json.Marshal(dat)
  90. var res Result5301
  91. var res10265 Result5301For10265
  92. if miConfig.Code == "H15049901371" {
  93. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  94. utils.ErrorLog("解析失败:%v", err)
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  96. return
  97. }
  98. res.InfRefmsgid = res10265.InfRefmsgid
  99. res.Output = res10265.Output
  100. res.ErrMsg = res10265.ErrMsg
  101. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  102. res.Infcode = infocode
  103. } else {
  104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  105. utils.ErrorLog("解析失败:%v", err)
  106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  107. return
  108. }
  109. }
  110. if res.Infcode == 0 {
  111. c.ServeSuccessJSON(map[string]interface{}{
  112. "result": res.Output.Result,
  113. })
  114. }
  115. }
  116. func (c *HisApiController) CheckInsutype() {
  117. his_patient_id, _ := c.GetInt64("his_patient_id")
  118. admin_user_id, _ := c.GetInt64("admin_user_id")
  119. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  122. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  123. var dat map[string]interface{}
  124. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  125. fmt.Println(dat)
  126. } else {
  127. fmt.Println(err)
  128. }
  129. userJSONBytes, _ := json.Marshal(dat)
  130. var res Result90100
  131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  132. utils.ErrorLog("解析失败:%v", err)
  133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  134. return
  135. }
  136. if res.Infcode != 0 {
  137. c.ServeSuccessJSON(map[string]interface{}{
  138. "failed_code": -10,
  139. "msg": res.ErrMsg,
  140. })
  141. return
  142. } else {
  143. fmt.Println(res)
  144. }
  145. }
  146. func (c *HisApiController) CheckCardPWD() {
  147. card_pwd := c.GetString("card_pwd")
  148. his_patient_id, _ := c.GetInt64("his_patient_id")
  149. admin_user_id, _ := c.GetInt64("admin_user_id")
  150. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  152. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  153. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  154. var dat map[string]interface{}
  155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  156. fmt.Println(dat)
  157. } else {
  158. fmt.Println(err)
  159. }
  160. userJSONBytes, _ := json.Marshal(dat)
  161. var res Result90991
  162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  163. utils.ErrorLog("解析失败:%v", err)
  164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  165. return
  166. }
  167. if res.Infcode != 0 {
  168. c.ServeSuccessJSON(map[string]interface{}{
  169. "failed_code": -10,
  170. "msg": res.ErrMsg,
  171. })
  172. return
  173. } else {
  174. if res.Output.Result.CheckStat == "0" {
  175. var msg string
  176. switch res.Output.Result.CardStat {
  177. case "00":
  178. msg = "未激活"
  179. break
  180. case "10":
  181. msg = "激活"
  182. break
  183. case "20":
  184. msg = "窗口挂失"
  185. break
  186. case "21":
  187. msg = "电话挂失"
  188. break
  189. case "22":
  190. msg = "单位网上申报挂失"
  191. break
  192. case "23":
  193. msg = "保健办挂失"
  194. break
  195. case "24":
  196. msg = "个人网上挂失"
  197. break
  198. case "25":
  199. msg = "网上服务大厅挂失"
  200. break
  201. case "30":
  202. msg = "注销"
  203. break
  204. case "40":
  205. msg = "回收"
  206. break
  207. case "99":
  208. msg = "制卡中(无效卡)"
  209. break
  210. }
  211. c.ServeSuccessJSON(map[string]interface{}{
  212. "failed_code": -10,
  213. "msg": msg,
  214. })
  215. return
  216. } else {
  217. c.ServeSuccessJSON(map[string]interface{}{
  218. "msg": "校验成功",
  219. })
  220. return
  221. }
  222. }
  223. }
  224. func (c *HisApiController) ReadCard() {
  225. id_card_type, _ := c.GetInt64("id_card_type")
  226. admin_user_id, _ := c.GetInt64("admin_user_id")
  227. certificates, _ := c.GetInt64("certificates")
  228. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  229. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  231. switch id_card_type {
  232. case 1:
  233. if miConfig.MdtrtareaAdmvs == "421300" {
  234. var res ResultTwo
  235. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  236. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  237. "&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)
  238. resp, requestErr := http.Get(api)
  239. if requestErr != nil {
  240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  241. return
  242. }
  243. body, ioErr := ioutil.ReadAll(resp.Body)
  244. if ioErr != nil {
  245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  247. return
  248. }
  249. var respJSON map[string]interface{}
  250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  253. return
  254. }
  255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  256. result, _ := json.Marshal(respJSON)
  257. fmt.Println("log")
  258. fmt.Println(string(result))
  259. if err := json.Unmarshal([]byte(result), &res); err != nil {
  260. utils.ErrorLog("解析失败:%v", err)
  261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  262. return
  263. }
  264. if res.Infcode == 0 {
  265. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  266. if err == gorm.ErrRecordNotFound {
  267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  268. return
  269. } else if err != nil {
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  271. return
  272. } else {
  273. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  274. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  275. infoStr := string(Iinfos)
  276. idetinfoStr := string(Idetinfos)
  277. psn := &models.HisPsn{
  278. PsnNo: res.Output.Baseinfo.PsnNo,
  279. Age: res.Output.Baseinfo.Age,
  280. PatientId: patient.ID,
  281. Certno: res.Output.Baseinfo.Certno,
  282. Brdy: res.Output.Baseinfo.Brdy,
  283. Gend: res.Output.Baseinfo.Gend,
  284. Naty: res.Output.Baseinfo.Naty,
  285. PsnCertType: res.Output.Baseinfo.PsnCertType,
  286. PsnName: res.Output.Baseinfo.PsnName,
  287. Idetinfo: idetinfoStr,
  288. Insuinfo: infoStr,
  289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  290. }
  291. service.CreateHisPsn(psn)
  292. c.ServeSuccessJSON(map[string]interface{}{
  293. "patient": patient,
  294. "number": res.Output.Baseinfo.Certno,
  295. })
  296. }
  297. } else {
  298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  299. return
  300. }
  301. } else if miConfig.MdtrtareaAdmvs == "320921" {
  302. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  303. Iinit := DllDef.MustFindProc("Init")
  304. fmt.Println(Iinit)
  305. var res ResultTwo
  306. api := "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.ChannelNumber
  307. resp, requestErr := http.Get(api)
  308. if requestErr != nil {
  309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  310. return
  311. }
  312. body, ioErr := ioutil.ReadAll(resp.Body)
  313. if ioErr != nil {
  314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  316. return
  317. }
  318. var respJSON map[string]interface{}
  319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  325. result, _ := json.Marshal(respJSON)
  326. fmt.Println("log")
  327. fmt.Println(string(result))
  328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  329. utils.ErrorLog("解析失败:%v", err)
  330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  331. return
  332. }
  333. if res.Infcode == 0 {
  334. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  335. if err == gorm.ErrRecordNotFound {
  336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  337. return
  338. } else if err != nil {
  339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  340. return
  341. } else {
  342. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  343. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  344. infoStr := string(Iinfos)
  345. idetinfoStr := string(Idetinfos)
  346. psn := &models.HisPsn{
  347. PsnNo: res.Output.Baseinfo.PsnNo,
  348. Age: res.Output.Baseinfo.Age,
  349. PatientId: patient.ID,
  350. Certno: res.Output.Baseinfo.Certno,
  351. Brdy: res.Output.Baseinfo.Brdy,
  352. Gend: res.Output.Baseinfo.Gend,
  353. Naty: res.Output.Baseinfo.Naty,
  354. PsnCertType: res.Output.Baseinfo.PsnCertType,
  355. PsnName: res.Output.Baseinfo.PsnName,
  356. Idetinfo: idetinfoStr,
  357. Insuinfo: infoStr,
  358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  359. }
  360. service.CreateHisPsn(psn)
  361. c.ServeSuccessJSON(map[string]interface{}{
  362. "patient": patient,
  363. "number": res.Output.Baseinfo.Certno,
  364. })
  365. }
  366. } else {
  367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  368. return
  369. }
  370. } else {
  371. if initFlag == 0 {
  372. c.TestGetBasBaseInit()
  373. }
  374. basStr := c.GetBasBaseInfo()
  375. if len(basStr) == 0 {
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  377. return
  378. }
  379. fmt.Println(basStr)
  380. bas := strings.Split(basStr, "|")
  381. basNumber := bas[1]
  382. fmt.Println(basNumber)
  383. card_sn := bas[3]
  384. fmt.Println(card_sn)
  385. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  386. var dat map[string]interface{}
  387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  388. fmt.Println(dat)
  389. } else {
  390. fmt.Println(err)
  391. }
  392. userJSONBytes, _ := json.Marshal(dat)
  393. var res ResultTwo
  394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  395. utils.ErrorLog("解析失败:%v", err)
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. if res.Infcode == 0 {
  400. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  401. if err == gorm.ErrRecordNotFound {
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  403. return
  404. } else if err != nil {
  405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  406. return
  407. } else {
  408. c.ServeSuccessJSON(map[string]interface{}{
  409. "patient": patient,
  410. "number": basNumber,
  411. })
  412. }
  413. } else {
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  415. return
  416. }
  417. break
  418. }
  419. case 2:
  420. SFZStr := c.GetSFZBaseInfo()
  421. id_card_str := strings.Split(SFZStr, "^")
  422. id_card_number := id_card_str[0]
  423. card_sn := ""
  424. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  425. var dat map[string]interface{}
  426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  427. fmt.Println(dat)
  428. } else {
  429. fmt.Println(err)
  430. }
  431. userJSONBytes, _ := json.Marshal(dat)
  432. var res ResultTwo
  433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  434. utils.ErrorLog("解析失败:%v", err)
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  436. return
  437. }
  438. if res.Infcode == 0 {
  439. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  440. if err == gorm.ErrRecordNotFound {
  441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  442. return
  443. } else if err != nil {
  444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  445. return
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "patient": patient,
  449. "number": id_card_number,
  450. })
  451. }
  452. } else {
  453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  454. return
  455. }
  456. break
  457. case 3:
  458. break
  459. }
  460. }
  461. var initFlag int64 = 0
  462. func (c *HisApiController) TestGetBasBaseInit() {
  463. DllDef := syscall.MustLoadDLL("SSCard.dll")
  464. Iinit := DllDef.MustFindProc("Init")
  465. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  466. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  467. if ret != 0 {
  468. fmt.Println("SSCard的报错原因:", err)
  469. fmt.Println("SSCard的运算结果为:", ret)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  471. return
  472. }
  473. result := int(ret)
  474. fmt.Println("SSCard的运算结果为1:", result)
  475. initFlag = 1
  476. return
  477. }
  478. func (c *HisApiController) GetSFZBaseInfo() string {
  479. DllDef := syscall.MustLoadDLL("SSCard.dll")
  480. readCard := DllDef.MustFindProc("ReadSFZ")
  481. if readCard == nil {
  482. fmt.Println("readcard is nil")
  483. readCard = DllDef.MustFindProc("ReadSFZ")
  484. }
  485. str := make([]byte, 256)
  486. str1 := make([]byte, 256)
  487. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  488. fmt.Println(r)
  489. return string(str)
  490. }
  491. func (c *HisApiController) GetBasBaseInfo() string {
  492. DllDef := syscall.MustLoadDLL("SSCard.dll")
  493. readCard := DllDef.MustFindProc("ReadCardBas")
  494. if readCard == nil {
  495. fmt.Println("readcard is nil")
  496. readCard = DllDef.MustFindProc("ReadCardBas")
  497. }
  498. str := make([]byte, 1024)
  499. str1 := make([]byte, 1024)
  500. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  501. fmt.Println(string(str1))
  502. fmt.Println(string(str))
  503. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  504. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  505. if ret2 != 0 {
  506. return ""
  507. }
  508. return string(str)
  509. }
  510. type CustomFundPay struct {
  511. FundPayType string `json:"fund_pay_type"`
  512. FundPayamt float64 `json:"fund_payamt"`
  513. }
  514. func (c *HisApiController) GetSettleList() {
  515. order_id, _ := c.GetInt64("order_id")
  516. admin_user_id, _ := c.GetInt64("admin_user_id")
  517. order, _ := service.GetHisOrderByIDTwo(order_id)
  518. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  519. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  520. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  521. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  522. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  523. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  524. if order.ID == 0 {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  526. return
  527. }
  528. struct4101 := service.Struct4101{
  529. PsnNo: order.PsnNo,
  530. MdtrtId: order.MdtrtId,
  531. SetlId: order.SetlId,
  532. PsnName: order.PsnName,
  533. Gend: order.Gend,
  534. Brdy: his.Brdy,
  535. Age: his.Age,
  536. Naty: order.Naty,
  537. PatnCertType: "01",
  538. Certno: order.Certno,
  539. Prfs: "90",
  540. ConerName: roles[0].UserName,
  541. PatnRlts: "99",
  542. ConerAddr: miConfig.OrgName,
  543. ConerTel: admin.Mobile,
  544. HiType: order.Insutype,
  545. Insuplc: miConfig.InsuplcAdmdvs,
  546. MaindiagFlag: "1",
  547. BillCode: order.FaPiaoCode,
  548. BillNo: order.FaPiaoNumber,
  549. BizSn: order.Number,
  550. PsnSelfPay: order.PsnPartAmt,
  551. PsnOwnPay: order.PsnPartAmt,
  552. AcctPay: order.AcctPay,
  553. PsnCashpay: order.PsnCashPay,
  554. HiPaymtd: "1",
  555. Hsorg: miConfig.InsuplcAdmdvs,
  556. HsorgOpter: miConfig.InsuplcAdmdvs,
  557. MedinsFillPsn: curRoles.UserName,
  558. MedinsFillDept: depart.Name,
  559. IptMedType: "2",
  560. }
  561. struct4101.SetlBegnDate = order.SetlTime
  562. struct4101.SetlEndDate = order.SetlTime
  563. //if order.SettleType == 1 {
  564. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  565. // dateStr := t.Format("2006-01-02")
  566. // struct4101.SetlBegnDate = dateStr
  567. // struct4101.SetlEndDate = dateStr
  568. //} else {
  569. // t := time.Unix(int64(order.SettleStartTime), 0)
  570. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  571. // dateStartStr := t.Format("2006-01-02")
  572. // dateEndStr := t2.Format("2006-01-02")
  573. // struct4101.SetlBegnDate = dateStartStr
  574. // struct4101.SetlEndDate = dateEndStr
  575. //}
  576. var rf []CustomFundPay
  577. json.Unmarshal([]byte(order.SetlDetail), &rf)
  578. var tempFunPays []service.CustomStruct
  579. for _, item := range rf {
  580. var tempFunPay service.CustomStruct
  581. tempFunPay.FundPayamt = item.FundPayamt
  582. tempFunPay.FundPayType = item.FundPayType
  583. tempFunPays = append(tempFunPays, tempFunPay)
  584. }
  585. struct4101.CustomStruct = tempFunPays
  586. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  587. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  588. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  589. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  590. var config []*models.HisXtDiagnoseConfig
  591. for _, item := range diagnosis_ids {
  592. id, _ := strconv.ParseInt(item, 10, 64)
  593. diagnosisConfig, _ := service.FindDiagnoseById(id)
  594. config = append(config, &diagnosisConfig)
  595. }
  596. for _, item := range config {
  597. var tempOpspdiseinfo service.OpspdiseinfoStruct
  598. tempOpspdiseinfo.DiagCode = item.CountryCode
  599. tempOpspdiseinfo.DiagName = item.CountryContentName
  600. tempOpspdiseinfo.MaindiagFlag = "1"
  601. tempOpspdiseinfo.OprnOprtCode = ""
  602. tempOpspdiseinfo.OprnOprtName = ""
  603. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  604. }
  605. sickConfigTwo, _ := service.FindSickById(his.SickType)
  606. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  607. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  608. tempOpspdiseinfo2.MaindiagFlag = "2"
  609. tempOpspdiseinfo2.OprnOprtCode = ""
  610. tempOpspdiseinfo2.OprnOprtName = ""
  611. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  612. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  613. var iteminfo service.IteminfoStruct
  614. var bedCostTotal float64 = 0 //床位总费
  615. var bedCostSelfTotal float64 = 0 //床位自费
  616. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  617. var operationCostTotal float64 = 0 //手术费
  618. var operationCostSelfTotal float64 = 0 //手术费
  619. var operationCostPartSelfTotal float64 = 0 //手术费
  620. var otherCostTotal float64 = 0 //其他费用
  621. var otherCostSelfTotal float64 = 0 //其他费用
  622. var otherCostPartSelfTotal float64 = 0 //其他费用
  623. var materialCostTotal float64 = 0 //材料费
  624. var materialCostSelfTotal float64 = 0 //材料费
  625. var materialCostPartSelfTotal float64 = 0 //材料费
  626. var westernMedicineCostTotal float64 = 0 //西药费
  627. var westernMedicineCostSelfTotal float64 = 0 //西药费
  628. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  629. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  630. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  631. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  632. var checkCostTotal float64 = 0 //检查费
  633. var checkCostSelfTotal float64 = 0 //检查费
  634. var checkCostPartSelfTotal float64 = 0 //检查费
  635. var laboratoryCostTotal float64 = 0 //化验费
  636. var laboratoryCostSelfTotal float64 = 0 //化验费
  637. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  638. var treatCostTotal float64 = 0 //治疗费用
  639. var treatCostSelfTotal float64 = 0 //治疗费用
  640. var treatCostPartSelfTotal float64 = 0 //治疗费用
  641. decimal.DivisionPrecision = 2
  642. var bed_fulamt_ownpay_amt float64 = 0
  643. var operation_fulamt_ownpay_amt float64 = 0
  644. var other_fulamt_ownpay_amt float64 = 0
  645. var westernMedicine_fulamt_ownpay_amt float64 = 0
  646. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  647. var check_fulamt_ownpay_amt float64 = 0
  648. var material_fulamt_ownpay_amt float64 = 0
  649. var laboratory_fulamt_ownpay_amt float64 = 0
  650. var treat_fulamt_ownpay_amt float64 = 0
  651. var bed_claa_sunmfee float64 = 0
  652. var bed_clab_amt float64 = 0
  653. var bed_other_amt float64 = 0
  654. var operation_claa_sunmfee float64 = 0
  655. var operation_clab_amt float64 = 0
  656. var operation_other_amt float64 = 0
  657. var other_claa_sunmfee float64 = 0
  658. var other_clab_amt float64 = 0
  659. var other_other_amt float64 = 0
  660. var westernMedicine_claa_sunmfee float64 = 0
  661. var westernMedicine_clab_amt float64 = 0
  662. var westernMedicine_other_amt float64 = 0
  663. var chineseTraditional_claa_sunmfee float64 = 0
  664. var chineseTraditional_clab_amt float64 = 0
  665. var chineseTraditional_other_amt float64 = 0
  666. var check_claa_sunmfee float64 = 0
  667. var check_clab_amt float64 = 0
  668. var check_other_amt float64 = 0
  669. var material_claa_sunmfee float64 = 0
  670. var material_clab_amt float64 = 0
  671. var material_other_amt float64 = 0
  672. var laboratory_claa_sunmfee float64 = 0
  673. var laboratory_clab_amt float64 = 0
  674. var laboratory_other_amt float64 = 0
  675. var treat_claa_sunmfee float64 = 0
  676. var treat_clab_amt float64 = 0
  677. var treat_other_amt float64 = 0
  678. for _, item := range order.HisOrderInfo {
  679. if item.MedChrgitmType == "01" { //床位费
  680. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  681. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  682. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  683. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  684. if item.ChrgitmLv == "1" {
  685. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  686. }
  687. if item.ChrgitmLv == "2" {
  688. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  689. }
  690. if item.ChrgitmLv == "3" {
  691. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  692. }
  693. }
  694. if item.MedChrgitmType == "03" { //检查费
  695. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  696. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  697. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  698. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  699. if item.ChrgitmLv == "1" {
  700. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  701. }
  702. if item.ChrgitmLv == "2" {
  703. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  704. }
  705. if item.ChrgitmLv == "3" {
  706. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  707. }
  708. }
  709. if item.MedChrgitmType == "04" { //化验费
  710. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  711. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  712. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  713. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  714. if item.ChrgitmLv == "1" {
  715. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  716. }
  717. if item.ChrgitmLv == "2" {
  718. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  719. }
  720. if item.ChrgitmLv == "3" {
  721. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  722. }
  723. }
  724. if item.MedChrgitmType == "05" { //治疗费
  725. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  726. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  727. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  728. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  729. if item.ChrgitmLv == "1" {
  730. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  731. }
  732. if item.ChrgitmLv == "2" {
  733. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  734. }
  735. if item.ChrgitmLv == "3" {
  736. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  737. }
  738. }
  739. if item.MedChrgitmType == "06" { //手术费
  740. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  741. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  742. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  743. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  744. if item.ChrgitmLv == "1" {
  745. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  746. }
  747. if item.ChrgitmLv == "2" {
  748. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  749. }
  750. if item.ChrgitmLv == "3" {
  751. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  752. }
  753. }
  754. if item.MedChrgitmType == "08" { //材料费
  755. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  756. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  757. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  758. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  759. if item.ChrgitmLv == "1" {
  760. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  761. }
  762. if item.ChrgitmLv == "2" {
  763. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  764. }
  765. if item.ChrgitmLv == "3" {
  766. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  767. }
  768. }
  769. if item.MedChrgitmType == "09" { //西药费
  770. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  771. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  772. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  773. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  774. if item.ChrgitmLv == "1" {
  775. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  776. }
  777. if item.ChrgitmLv == "2" {
  778. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  779. }
  780. if item.ChrgitmLv == "3" {
  781. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  782. }
  783. }
  784. if item.MedChrgitmType == "11" { //中成费
  785. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  786. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  787. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  788. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  789. if item.ChrgitmLv == "1" {
  790. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  791. }
  792. if item.ChrgitmLv == "2" {
  793. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  794. }
  795. if item.ChrgitmLv == "3" {
  796. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  797. }
  798. }
  799. if item.MedChrgitmType == "14" { //其他费
  800. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  801. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  802. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  803. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  804. if item.ChrgitmLv == "1" {
  805. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  806. }
  807. if item.ChrgitmLv == "2" {
  808. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  809. }
  810. if item.ChrgitmLv == "3" {
  811. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  812. }
  813. }
  814. }
  815. var iteminfoStructs []service.IteminfoStruct
  816. if bedCostTotal != 0 {
  817. iteminfo.MedChrgitm = "01"
  818. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  819. iteminfo.Amt = bedCostTotal
  820. iteminfo.ClaaSumfee = bed_claa_sunmfee
  821. iteminfo.ClabAmt = bed_clab_amt
  822. iteminfo.OthAmt = bed_other_amt
  823. iteminfoStructs = append(iteminfoStructs, iteminfo)
  824. }
  825. if checkCostTotal != 0 {
  826. iteminfo.MedChrgitm = "03"
  827. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  828. iteminfo.Amt = checkCostTotal
  829. iteminfo.ClaaSumfee = check_claa_sunmfee
  830. iteminfo.ClabAmt = check_clab_amt
  831. iteminfo.OthAmt = check_other_amt
  832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  833. }
  834. if laboratoryCostTotal != 0 {
  835. iteminfo.MedChrgitm = "04"
  836. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  837. iteminfo.Amt = laboratoryCostTotal
  838. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  839. iteminfo.ClabAmt = laboratory_clab_amt
  840. iteminfo.OthAmt = laboratory_other_amt
  841. iteminfoStructs = append(iteminfoStructs, iteminfo)
  842. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  843. }
  844. if treatCostTotal != 0 {
  845. iteminfo.MedChrgitm = "05"
  846. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  847. iteminfo.Amt = treatCostTotal
  848. iteminfo.ClaaSumfee = treat_claa_sunmfee
  849. iteminfo.ClabAmt = treat_clab_amt
  850. iteminfo.OthAmt = treat_other_amt
  851. iteminfoStructs = append(iteminfoStructs, iteminfo)
  852. //(struct4101.IteminfoStruct, iteminfo)
  853. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  854. }
  855. if operationCostTotal != 0 {
  856. iteminfo.MedChrgitm = "06"
  857. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  858. iteminfo.Amt = operationCostTotal
  859. iteminfo.ClaaSumfee = operation_claa_sunmfee
  860. iteminfo.ClabAmt = operation_clab_amt
  861. iteminfo.OthAmt = operation_other_amt
  862. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  863. iteminfoStructs = append(iteminfoStructs, iteminfo)
  864. }
  865. if materialCostTotal != 0 {
  866. iteminfo.MedChrgitm = "08"
  867. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  868. iteminfo.Amt = materialCostTotal
  869. iteminfo.ClaaSumfee = material_claa_sunmfee
  870. iteminfo.ClabAmt = material_clab_amt
  871. iteminfo.OthAmt = material_other_amt
  872. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  873. iteminfoStructs = append(iteminfoStructs, iteminfo)
  874. }
  875. if westernMedicineCostTotal != 0 {
  876. iteminfo.MedChrgitm = "09"
  877. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  878. iteminfo.Amt = westernMedicineCostTotal
  879. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  880. iteminfo.ClabAmt = westernMedicine_clab_amt
  881. iteminfo.OthAmt = westernMedicine_other_amt
  882. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  883. iteminfoStructs = append(iteminfoStructs, iteminfo)
  884. }
  885. if chineseTraditionalMedicineCostTotal != 0 {
  886. iteminfo.MedChrgitm = "11"
  887. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  888. iteminfo.Amt = westernMedicineCostTotal
  889. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  890. iteminfo.ClabAmt = westernMedicine_clab_amt
  891. iteminfo.OthAmt = westernMedicine_other_amt
  892. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  893. iteminfoStructs = append(iteminfoStructs, iteminfo)
  894. }
  895. if otherCostTotal != 0 {
  896. iteminfo.MedChrgitm = "14"
  897. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  898. iteminfo.Amt = otherCostTotal
  899. iteminfo.ClaaSumfee = other_claa_sunmfee
  900. iteminfo.ClabAmt = other_clab_amt
  901. iteminfo.OthAmt = other_other_amt
  902. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  903. iteminfoStructs = append(iteminfoStructs, iteminfo)
  904. }
  905. struct4101.IteminfoStruct = iteminfoStructs
  906. struct4101.Ntly = "中国"
  907. struct4101.AdmCaty = "A03.06"
  908. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  909. fmt.Println(result)
  910. var dat map[string]interface{}
  911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  912. fmt.Println(dat)
  913. } else {
  914. fmt.Println(err)
  915. }
  916. userJSONBytes, _ := json.Marshal(dat)
  917. var res ResultSeventeen
  918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  919. utils.ErrorLog("解析失败:%v", err)
  920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  921. return
  922. }
  923. if res.Infcode != 0 {
  924. c.ServeSuccessJSON(map[string]interface{}{
  925. "failed_code": -10,
  926. "msg": res.ErrMsg,
  927. })
  928. return
  929. } else {
  930. hisFundSettleListResult := &models.HisFundSettleListResult{
  931. Number: res.Output.SetlListId,
  932. Status: 1,
  933. Ctime: time.Now().Unix(),
  934. Mtime: time.Now().Unix(),
  935. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  936. IsUpload: 1,
  937. OrderId: order_id,
  938. }
  939. service.CreateUploadRecord(hisFundSettleListResult)
  940. c.ServeSuccessJSON(map[string]interface{}{
  941. "msg": "上传成功",
  942. "result": hisFundSettleListResult,
  943. })
  944. return
  945. }
  946. }
  947. func (c *HisApiController) GetBatchSettleList() {
  948. org_id, _ := beego.AppConfig.Int64("org_id")
  949. //stage, _ := c.GetInt64("stage")
  950. orders, _ := service.GetAllHisOrder(org_id)
  951. for _, item := range orders {
  952. order_id := item.ID
  953. order, _ := service.GetHisOrderByIDTwo(order_id)
  954. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  955. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  956. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  957. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2500)
  958. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  959. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  960. if order.ID == 0 {
  961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  962. return
  963. }
  964. if his.BalanceAccountsType == 2 {
  965. continue
  966. }
  967. struct4101 := service.Struct4101{
  968. PsnNo: order.PsnNo,
  969. MdtrtId: order.MdtrtId,
  970. SetlId: order.SetlId,
  971. PsnName: order.PsnName,
  972. Gend: order.Gend,
  973. Brdy: his.Brdy,
  974. Age: his.Age,
  975. Naty: order.Naty,
  976. PatnCertType: "01",
  977. Certno: order.Certno,
  978. Prfs: "90",
  979. ConerName: roles[0].UserName,
  980. PatnRlts: "99",
  981. ConerAddr: miConfig.OrgName,
  982. ConerTel: admin.Mobile,
  983. HiType: order.Insutype,
  984. Insuplc: miConfig.InsuplcAdmdvs,
  985. MaindiagFlag: "1",
  986. BillCode: order.FaPiaoCode,
  987. BillNo: order.FaPiaoNumber,
  988. BizSn: order.Number,
  989. PsnSelfPay: order.PsnPartAmt,
  990. PsnOwnPay: order.PsnPartAmt,
  991. AcctPay: order.AcctPay,
  992. PsnCashpay: order.PsnCashPay,
  993. HiPaymtd: "1",
  994. Hsorg: miConfig.InsuplcAdmdvs,
  995. HsorgOpter: miConfig.InsuplcAdmdvs,
  996. MedinsFillPsn: curRoles.UserName,
  997. MedinsFillDept: depart.Name,
  998. IptMedType: "2",
  999. }
  1000. struct4101.SetlBegnDate = order.SetlTime
  1001. struct4101.SetlEndDate = order.SetlTime
  1002. //if order.SettleType == 1 {
  1003. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1004. // dateStr := t.Format("2006-01-02")
  1005. // struct4101.SetlBegnDate = dateStr
  1006. // struct4101.SetlEndDate = dateStr
  1007. //} else {
  1008. // t := time.Unix(int64(order.SettleStartTime), 0)
  1009. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1010. // dateStartStr := t.Format("2006-01-02")
  1011. // dateEndStr := t2.Format("2006-01-02")
  1012. // struct4101.SetlBegnDate = dateStartStr
  1013. // struct4101.SetlEndDate = dateEndStr
  1014. //}
  1015. var rf []CustomFundPay
  1016. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1017. var tempFunPays []service.CustomStruct
  1018. var tempFunPay610100 service.CustomStruct
  1019. for _, item := range rf {
  1020. if item.FundPayType == "610100" {
  1021. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1022. tempFunPay610100.FundPayType = item.FundPayType
  1023. } else {
  1024. var tempFunPay service.CustomStruct
  1025. tempFunPay.FundPayamt = item.FundPayamt
  1026. tempFunPay.FundPayType = item.FundPayType
  1027. tempFunPays = append(tempFunPays, tempFunPay)
  1028. }
  1029. }
  1030. tempFunPays = append(tempFunPays, tempFunPay610100)
  1031. struct4101.CustomStruct = tempFunPays
  1032. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1033. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1034. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1035. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1036. var config []*models.HisXtDiagnoseConfig
  1037. for _, item := range diagnosis_ids {
  1038. id, _ := strconv.ParseInt(item, 10, 64)
  1039. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1040. config = append(config, &diagnosisConfig)
  1041. }
  1042. for _, item := range config {
  1043. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1044. tempOpspdiseinfo.DiagCode = item.CountryCode
  1045. tempOpspdiseinfo.DiagName = item.CountryContentName
  1046. tempOpspdiseinfo.MaindiagFlag = "1"
  1047. tempOpspdiseinfo.OprnOprtCode = ""
  1048. tempOpspdiseinfo.OprnOprtName = ""
  1049. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1050. }
  1051. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1052. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1053. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1054. tempOpspdiseinfo2.MaindiagFlag = "2"
  1055. tempOpspdiseinfo2.OprnOprtCode = ""
  1056. tempOpspdiseinfo2.OprnOprtName = ""
  1057. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1058. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1059. var iteminfo service.IteminfoStruct
  1060. var bedCostTotal float64 = 0 //床位总费
  1061. var bedCostSelfTotal float64 = 0 //床位自费
  1062. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1063. var examineCostTotal float64 = 0 //诊查总费
  1064. var examineCostSelfTotal float64 = 0 //诊查自费
  1065. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1066. var nursingCostTotal float64 = 0 //护理总费
  1067. var nursingCostSelfTotal float64 = 0 //护理自费
  1068. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1069. var chineseMedicineCostTotal float64 = 0 //中成药
  1070. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1071. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1072. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1073. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1074. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1075. var registerCostTotal float64 = 0 //一般诊疗费
  1076. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1077. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1078. var operationCostTotal float64 = 0 //手术费
  1079. var operationCostSelfTotal float64 = 0 //手术费
  1080. var operationCostPartSelfTotal float64 = 0 //手术费
  1081. var otherCostTotal float64 = 0 //其他费用
  1082. var otherCostSelfTotal float64 = 0 //其他费用
  1083. var otherCostPartSelfTotal float64 = 0 //其他费用
  1084. var materialCostTotal float64 = 0 //材料费
  1085. var materialCostSelfTotal float64 = 0 //材料费
  1086. var materialCostPartSelfTotal float64 = 0 //材料费
  1087. var westernMedicineCostTotal float64 = 0 //西药费
  1088. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1089. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1090. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1091. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1092. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1093. var checkCostTotal float64 = 0 //检查费
  1094. var checkCostSelfTotal float64 = 0 //检查费
  1095. var checkCostPartSelfTotal float64 = 0 //检查费
  1096. var laboratoryCostTotal float64 = 0 //化验费
  1097. var laboratoryCostSelfTotal float64 = 0 //化验费
  1098. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1099. var treatCostTotal float64 = 0 //治疗费用
  1100. var treatCostSelfTotal float64 = 0 //治疗费用
  1101. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1102. decimal.DivisionPrecision = 2
  1103. var bed_fulamt_ownpay_amt float64 = 0
  1104. var examine_fulamt_ownpay_amt float64 = 0
  1105. var nursing_fulamt_ownpay_amt float64 = 0
  1106. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1107. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1108. var register_fulamt_ownpay_amt float64 = 0
  1109. var operation_fulamt_ownpay_amt float64 = 0
  1110. var other_fulamt_ownpay_amt float64 = 0
  1111. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1112. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1113. var check_fulamt_ownpay_amt float64 = 0
  1114. var material_fulamt_ownpay_amt float64 = 0
  1115. var laboratory_fulamt_ownpay_amt float64 = 0
  1116. var treat_fulamt_ownpay_amt float64 = 0
  1117. var bed_claa_sunmfee float64 = 0
  1118. var bed_clab_amt float64 = 0
  1119. var bed_other_amt float64 = 0
  1120. var examine_claa_sunmfee float64 = 0
  1121. var examine_clab_amt float64 = 0
  1122. var examine_other_amt float64 = 0
  1123. var nursing_claa_sunmfee float64 = 0
  1124. var nursing_clab_amt float64 = 0
  1125. var nursing_other_amt float64 = 0
  1126. var chinese_medicine_claa_sunmfee float64 = 0
  1127. var chinese_medicine_clab_amt float64 = 0
  1128. var chinese_medicine_other_amt float64 = 0
  1129. var commonly_treatment_claa_sunmfee float64 = 0
  1130. var commonly_treatment_clab_amt float64 = 0
  1131. var commonly_treatment_other_amt float64 = 0
  1132. var operation_claa_sunmfee float64 = 0
  1133. var operation_clab_amt float64 = 0
  1134. var operation_other_amt float64 = 0
  1135. var other_claa_sunmfee float64 = 0
  1136. var other_clab_amt float64 = 0
  1137. var other_other_amt float64 = 0
  1138. var westernMedicine_claa_sunmfee float64 = 0
  1139. var westernMedicine_clab_amt float64 = 0
  1140. var westernMedicine_other_amt float64 = 0
  1141. var chineseTraditional_claa_sunmfee float64 = 0
  1142. var chineseTraditional_clab_amt float64 = 0
  1143. var chineseTraditional_other_amt float64 = 0
  1144. var check_claa_sunmfee float64 = 0
  1145. var check_clab_amt float64 = 0
  1146. var check_other_amt float64 = 0
  1147. var material_claa_sunmfee float64 = 0
  1148. var material_clab_amt float64 = 0
  1149. var material_other_amt float64 = 0
  1150. var laboratory_claa_sunmfee float64 = 0
  1151. var laboratory_clab_amt float64 = 0
  1152. var laboratory_other_amt float64 = 0
  1153. var treat_claa_sunmfee float64 = 0
  1154. var treat_clab_amt float64 = 0
  1155. var treat_other_amt float64 = 0
  1156. var register_claa_sunmfee float64 = 0
  1157. var register_clab_amt float64 = 0
  1158. var register_other_amt float64 = 0
  1159. for _, item := range order.HisOrderInfo {
  1160. if item.MedChrgitmType == "01" { //床位费
  1161. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1162. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1163. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1164. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1165. if item.ChrgitmLv == "1" {
  1166. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1167. }
  1168. if item.ChrgitmLv == "2" {
  1169. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1170. }
  1171. if item.ChrgitmLv == "3" {
  1172. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1173. }
  1174. }
  1175. if item.MedChrgitmType == "02" { //诊查
  1176. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1177. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1178. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1179. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1180. if item.ChrgitmLv == "1" {
  1181. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1182. }
  1183. if item.ChrgitmLv == "2" {
  1184. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1185. }
  1186. if item.ChrgitmLv == "3" {
  1187. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1188. }
  1189. }
  1190. if item.MedChrgitmType == "03" { //检查费
  1191. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1192. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1193. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1194. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1195. if item.ChrgitmLv == "1" {
  1196. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1197. }
  1198. if item.ChrgitmLv == "2" {
  1199. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1200. }
  1201. if item.ChrgitmLv == "3" {
  1202. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1203. }
  1204. }
  1205. if item.MedChrgitmType == "04" { //化验费
  1206. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1207. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1208. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1209. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1210. if item.ChrgitmLv == "1" {
  1211. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1212. }
  1213. if item.ChrgitmLv == "2" {
  1214. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1215. }
  1216. if item.ChrgitmLv == "3" {
  1217. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1218. }
  1219. }
  1220. if item.MedChrgitmType == "05" { //治疗费
  1221. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1222. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1223. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1224. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1225. if item.ChrgitmLv == "1" {
  1226. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1227. }
  1228. if item.ChrgitmLv == "2" {
  1229. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1230. }
  1231. if item.ChrgitmLv == "3" {
  1232. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. }
  1234. }
  1235. if item.MedChrgitmType == "06" { //手术费
  1236. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1238. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1239. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1240. if item.ChrgitmLv == "1" {
  1241. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1242. }
  1243. if item.ChrgitmLv == "2" {
  1244. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1245. }
  1246. if item.ChrgitmLv == "3" {
  1247. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. }
  1249. }
  1250. if item.MedChrgitmType == "07" { //手术费
  1251. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1253. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1254. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1255. if item.ChrgitmLv == "1" {
  1256. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1257. }
  1258. if item.ChrgitmLv == "2" {
  1259. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1260. }
  1261. if item.ChrgitmLv == "3" {
  1262. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. }
  1264. }
  1265. if item.MedChrgitmType == "08" { //材料费
  1266. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1268. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1269. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1270. if item.ChrgitmLv == "1" {
  1271. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1272. }
  1273. if item.ChrgitmLv == "2" {
  1274. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1275. }
  1276. if item.ChrgitmLv == "3" {
  1277. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. }
  1279. }
  1280. if item.MedChrgitmType == "09" { //西药费
  1281. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1283. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1284. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1285. if item.ChrgitmLv == "1" {
  1286. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1287. }
  1288. if item.ChrgitmLv == "2" {
  1289. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1290. }
  1291. if item.ChrgitmLv == "3" {
  1292. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. }
  1294. }
  1295. if item.MedChrgitmType == "10" { //中药饮片
  1296. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1298. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1299. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1300. if item.ChrgitmLv == "1" {
  1301. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1302. }
  1303. if item.ChrgitmLv == "2" {
  1304. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1305. }
  1306. if item.ChrgitmLv == "3" {
  1307. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. }
  1309. }
  1310. if item.MedChrgitmType == "11" { //中成费
  1311. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1313. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1314. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1315. if item.ChrgitmLv == "1" {
  1316. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1317. }
  1318. if item.ChrgitmLv == "2" {
  1319. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1320. }
  1321. if item.ChrgitmLv == "3" {
  1322. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1323. }
  1324. }
  1325. if item.MedChrgitmType == "12" { //中成费
  1326. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1327. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1328. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1329. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1330. if item.ChrgitmLv == "1" {
  1331. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1332. }
  1333. if item.ChrgitmLv == "2" {
  1334. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1335. }
  1336. if item.ChrgitmLv == "3" {
  1337. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1338. }
  1339. }
  1340. if item.MedChrgitmType == "13" { //中成费
  1341. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1342. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1343. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1344. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1345. if item.ChrgitmLv == "1" {
  1346. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1347. }
  1348. if item.ChrgitmLv == "2" {
  1349. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1350. }
  1351. if item.ChrgitmLv == "3" {
  1352. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1353. }
  1354. }
  1355. if item.MedChrgitmType == "14" { //其他费
  1356. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1357. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1358. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1359. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1360. if item.ChrgitmLv == "1" {
  1361. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1362. }
  1363. if item.ChrgitmLv == "2" {
  1364. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1365. }
  1366. if item.ChrgitmLv == "3" {
  1367. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1368. }
  1369. }
  1370. }
  1371. var iteminfoStructs []service.IteminfoStruct
  1372. if bedCostTotal != 0 {
  1373. iteminfo.MedChrgitm = "01"
  1374. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1375. iteminfo.Amt = bedCostTotal
  1376. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1377. iteminfo.ClabAmt = bed_clab_amt
  1378. iteminfo.OthAmt = bed_other_amt
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. }
  1381. if examineCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "02"
  1383. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1384. iteminfo.Amt = examineCostTotal
  1385. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1386. iteminfo.ClabAmt = examine_clab_amt
  1387. iteminfo.OthAmt = examine_other_amt
  1388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1390. }
  1391. if checkCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "03"
  1393. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1394. iteminfo.Amt = checkCostTotal
  1395. iteminfo.ClaaSumfee = check_claa_sunmfee
  1396. iteminfo.ClabAmt = check_clab_amt
  1397. iteminfo.OthAmt = check_other_amt
  1398. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1399. }
  1400. if laboratoryCostTotal != 0 {
  1401. iteminfo.MedChrgitm = "04"
  1402. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1403. iteminfo.Amt = laboratoryCostTotal
  1404. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1405. iteminfo.ClabAmt = laboratory_clab_amt
  1406. iteminfo.OthAmt = laboratory_other_amt
  1407. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. }
  1410. if treatCostTotal != 0 {
  1411. iteminfo.MedChrgitm = "05"
  1412. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1413. iteminfo.Amt = treatCostTotal
  1414. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1415. iteminfo.ClabAmt = treat_clab_amt
  1416. iteminfo.OthAmt = treat_other_amt
  1417. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1418. //(struct4101.IteminfoStruct, iteminfo)
  1419. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1420. }
  1421. if operationCostTotal != 0 {
  1422. iteminfo.MedChrgitm = "06"
  1423. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1424. iteminfo.Amt = operationCostTotal
  1425. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1426. iteminfo.ClabAmt = operation_clab_amt
  1427. iteminfo.OthAmt = operation_other_amt
  1428. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1430. }
  1431. if nursingCostTotal != 0 {
  1432. iteminfo.MedChrgitm = "07"
  1433. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1434. iteminfo.Amt = nursingCostTotal
  1435. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1436. iteminfo.ClabAmt = nursing_clab_amt
  1437. iteminfo.OthAmt = nursing_other_amt
  1438. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1439. }
  1440. if materialCostTotal != 0 {
  1441. iteminfo.MedChrgitm = "08"
  1442. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1443. iteminfo.Amt = materialCostTotal
  1444. iteminfo.ClaaSumfee = material_claa_sunmfee
  1445. iteminfo.ClabAmt = material_clab_amt
  1446. iteminfo.OthAmt = material_other_amt
  1447. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1448. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1449. }
  1450. if westernMedicineCostTotal != 0 {
  1451. iteminfo.MedChrgitm = "09"
  1452. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1453. iteminfo.Amt = westernMedicineCostTotal
  1454. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1455. iteminfo.ClabAmt = westernMedicine_clab_amt
  1456. iteminfo.OthAmt = westernMedicine_other_amt
  1457. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1458. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1459. }
  1460. if chineseMedicineCostTotal != 0 {
  1461. iteminfo.MedChrgitm = "10"
  1462. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1463. iteminfo.Amt = chineseMedicineCostTotal
  1464. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1465. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1466. iteminfo.OthAmt = chinese_medicine_other_amt
  1467. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1468. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1469. }
  1470. if chineseTraditionalMedicineCostTotal != 0 {
  1471. iteminfo.MedChrgitm = "11"
  1472. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1473. iteminfo.Amt = westernMedicineCostTotal
  1474. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1475. iteminfo.ClabAmt = westernMedicine_clab_amt
  1476. iteminfo.OthAmt = westernMedicine_other_amt
  1477. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1478. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1479. }
  1480. if commonlyTreatmentCostTotal != 0 {
  1481. iteminfo.MedChrgitm = "12"
  1482. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1483. iteminfo.Amt = commonlyTreatmentCostTotal
  1484. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1485. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1486. iteminfo.OthAmt = commonly_treatment_other_amt
  1487. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1488. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1489. }
  1490. if registerCostTotal != 0 {
  1491. iteminfo.MedChrgitm = "13"
  1492. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  1493. iteminfo.Amt = registerCostTotal
  1494. iteminfo.ClaaSumfee = register_claa_sunmfee
  1495. iteminfo.ClabAmt = register_clab_amt
  1496. iteminfo.OthAmt = register_other_amt
  1497. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1498. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1499. }
  1500. if otherCostTotal != 0 {
  1501. iteminfo.MedChrgitm = "14"
  1502. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1503. iteminfo.Amt = otherCostTotal
  1504. iteminfo.ClaaSumfee = other_claa_sunmfee
  1505. iteminfo.ClabAmt = other_clab_amt
  1506. iteminfo.OthAmt = other_other_amt
  1507. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1508. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1509. }
  1510. struct4101.IteminfoStruct = iteminfoStructs
  1511. struct4101.Ntly = "中国"
  1512. struct4101.AdmCaty = "A03.06"
  1513. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  1514. fmt.Println(result)
  1515. var dat map[string]interface{}
  1516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1517. fmt.Println(dat)
  1518. } else {
  1519. fmt.Println(err)
  1520. }
  1521. userJSONBytes, _ := json.Marshal(dat)
  1522. var res ResultSeventeen
  1523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1524. utils.ErrorLog("解析失败:%v", err)
  1525. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1526. adminUser := c.GetAdminUserInfo()
  1527. errlog := &models.HisOrderError{
  1528. UserOrgId: adminUser.CurrentOrgId,
  1529. Ctime: time.Now().Unix(),
  1530. Mtime: time.Now().Unix(),
  1531. ErrMsg: res.ErrMsg + "解析失败",
  1532. Status: 1,
  1533. PatientId: order_id,
  1534. Stage: 120,
  1535. }
  1536. service.CreateErrMsgLog(errlog)
  1537. continue
  1538. }
  1539. if res.Infcode != 0 {
  1540. adminUser := c.GetAdminUserInfo()
  1541. errlog := &models.HisOrderError{
  1542. UserOrgId: adminUser.CurrentOrgId,
  1543. Ctime: time.Now().Unix(),
  1544. Mtime: time.Now().Unix(),
  1545. ErrMsg: res.ErrMsg,
  1546. Status: 1,
  1547. PatientId: order_id,
  1548. Stage: 200,
  1549. }
  1550. service.CreateErrMsgLog(errlog)
  1551. continue
  1552. } else {
  1553. hisFundSettleListResult := &models.HisFundSettleListResult{
  1554. Number: res.Output.SetlListId,
  1555. Status: 1,
  1556. Ctime: time.Now().Unix(),
  1557. Mtime: time.Now().Unix(),
  1558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1559. IsUpload: 1,
  1560. OrderId: order_id,
  1561. }
  1562. service.CreateUploadRecord(hisFundSettleListResult)
  1563. continue
  1564. }
  1565. }
  1566. }
  1567. func (c *HisApiController) GetOrgInfo() {
  1568. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  1569. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1570. }
  1571. func (c *HisApiController) GetHisPatientInfo() {
  1572. medical_insurance_card := c.GetString("medical_insurance_card")
  1573. id_card_type, _ := c.GetInt64("id_card_type")
  1574. id_card := c.GetString("id_card")
  1575. adminInfo := c.GetAdminUserInfo()
  1576. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1577. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1578. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  1579. IdCardNo := ""
  1580. if id_card_type == 1 {
  1581. IdCardNo = medical_insurance_card
  1582. } else if id_card_type == 2 {
  1583. IdCardNo = id_card
  1584. }
  1585. if config.IsOpen == 1 {
  1586. 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
  1587. resp, requestErr := http.Get(api)
  1588. if requestErr != nil {
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. return
  1591. }
  1592. defer resp.Body.Close()
  1593. body, ioErr := ioutil.ReadAll(resp.Body)
  1594. if ioErr != nil {
  1595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1597. return
  1598. }
  1599. var respJSON map[string]interface{}
  1600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1603. return
  1604. }
  1605. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1606. userJSONBytes, _ := json.Marshal(userJSON)
  1607. var res ResultTwo
  1608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1609. utils.ErrorLog("解析失败:%v", err)
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1611. return
  1612. }
  1613. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1614. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1615. infoStr := string(Iinfos)
  1616. idetinfoStr := string(Idetinfos)
  1617. if res.Infcode == 0 {
  1618. his := models.VMHisPatient{
  1619. Status: 1,
  1620. Ctime: time.Now().Unix(),
  1621. Mtime: time.Now().Unix(),
  1622. PsnNo: res.Output.Baseinfo.PsnNo,
  1623. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1624. Certno: res.Output.Baseinfo.Certno,
  1625. PsnName: res.Output.Baseinfo.PsnName,
  1626. Gend: res.Output.Baseinfo.Gend,
  1627. Naty: res.Output.Baseinfo.Naty,
  1628. Brdy: res.Output.Baseinfo.Brdy,
  1629. Age: res.Output.Baseinfo.Age,
  1630. Iinfo: infoStr,
  1631. Idetinfo: idetinfoStr,
  1632. UserOrgId: adminInfo.CurrentOrgId,
  1633. IsReturn: 1,
  1634. IdCardType: id_card_type,
  1635. }
  1636. c.ServeSuccessJSON(map[string]interface{}{
  1637. "info": his,
  1638. })
  1639. } else {
  1640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1641. return
  1642. }
  1643. }
  1644. }
  1645. //func GetBasBaseInfo() (jsonStr string, err error) {
  1646. //
  1647. // handle := syscall.NewLazyDLL("SSCard.dll")
  1648. // add := handle.NewProc("ReadCardBas")
  1649. // str := make([]byte, 1024)
  1650. // str1 := make([]byte, 1024)
  1651. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1652. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  1653. //
  1654. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  1655. //
  1656. // fmt.Println("> Add(4,5)的结果为:", ret)
  1657. // handle.Release()
  1658. //
  1659. // return "", nil
  1660. //
  1661. //}
  1662. //func GetQRBaseInfo() (jsonStr string, err error) {
  1663. // handle := syscall.LoadDLL("SSCard.dll")
  1664. // ReadCardBas := handle.FindProc("GetQRBase")
  1665. //
  1666. // str := make([]byte, 256)
  1667. // str1 := make([]byte, 256)
  1668. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1669. //
  1670. // fmt.Println(string(str))
  1671. // fmt.Println(r)
  1672. // return string(str), nil
  1673. //}
  1674. //func CardInit() int {
  1675. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  1676. // add := DllTestDef.MustFindProc("Init")
  1677. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1678. // if err != nil {
  1679. // fmt.Println("SSCard的运算结果为:", ret)
  1680. // }
  1681. // result := int(ret)
  1682. // return result
  1683. //}
  1684. //func CardInit() int {
  1685. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1686. // if err != nil {
  1687. // fmt.Println("SSCard的运算结果为:", ret)
  1688. // }
  1689. // fmt.Println(err)
  1690. // result := int(ret)
  1691. // return result
  1692. //}
  1693. func IntPtr(n int) uintptr {
  1694. return uintptr(n)
  1695. }
  1696. func StrPtr(s string) uintptr {
  1697. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1698. }
  1699. type Result2001 struct {
  1700. Cainfo interface{} `json:"cainfo"`
  1701. ErrMsg string `json:"err_msg"`
  1702. InfRefmsgid string `json:"inf_refmsgid"`
  1703. Infcode int64 `json:"infcode"`
  1704. Output struct {
  1705. Trtinfo struct {
  1706. PsnNo string `json:"psn_no"`
  1707. TrtChkType string `json:"trt_chk_type"`
  1708. FundPayType string `json:"fund_pay_type"`
  1709. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  1710. Begndate string `json:"begndate"`
  1711. Enddate string `json:"enddate"`
  1712. TrtChkRslt string `json:"trt_chk_rslt"`
  1713. } `json:"trtinfo"`
  1714. } `json:"output"`
  1715. RefmsgTime string `json:"refmsg_time"`
  1716. RespondTime string `json:"respond_time"`
  1717. Signtype interface{} `json:"signtype"`
  1718. WarnMsg interface{} `json:"warn_msg"`
  1719. }
  1720. type Result2001Org10265 struct {
  1721. Cainfo interface{} `json:"cainfo"`
  1722. ErrMsg string `json:"err_msg"`
  1723. InfRefmsgid string `json:"inf_refmsgid"`
  1724. Infcode string `json:"infcode"`
  1725. Output struct {
  1726. Trtinfo struct {
  1727. PsnNo string `json:"psn_no"`
  1728. TrtChkType string `json:"trt_chk_type"`
  1729. FundPayType string `json:"fund_pay_type"`
  1730. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  1731. Begndate string `json:"begndate"`
  1732. Enddate string `json:"enddate"`
  1733. TrtChkRslt string `json:"trt_chk_rslt"`
  1734. } `json:"trtinfo"`
  1735. } `json:"output"`
  1736. RefmsgTime string `json:"refmsg_time"`
  1737. RespondTime string `json:"respond_time"`
  1738. Signtype interface{} `json:"signtype"`
  1739. WarnMsg interface{} `json:"warn_msg"`
  1740. }
  1741. type ResultTwo struct {
  1742. ErrMsg string `json:"err_msg"`
  1743. InfRefmsgid string `json:"inf_refmsgid"`
  1744. Infcode int64 `json:"infcode"`
  1745. Output struct {
  1746. Baseinfo struct {
  1747. Age float64 `json:"age"`
  1748. Brdy string `json:"brdy"`
  1749. Certno string `json:"certno"`
  1750. Gend string `json:"gend"`
  1751. Naty string `json:"naty"`
  1752. PsnCertType string `json:"psn_cert_type"`
  1753. PsnName string `json:"psn_name"`
  1754. PsnNo string `json:"psn_no"`
  1755. } `json:"baseinfo"`
  1756. Idetinfo []interface{} `json:"idetinfo"`
  1757. Iinfo []struct {
  1758. Balc float64 `json:"balc"`
  1759. CvlservFlag string `json:"cvlserv_flag"`
  1760. EmpName string `json:"emp_name"`
  1761. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1762. Insutype string `json:"insutype"`
  1763. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1764. PausInsuDate string `json:"paus_insu_date"`
  1765. PsnInsuDate string `json:"psn_insu_date"`
  1766. PsnInsuStas string `json:"psn_insu_stas"`
  1767. PsnType string `json:"psn_type"`
  1768. } `json:"insuinfo"`
  1769. } `json:"output"`
  1770. RefmsgTime string `json:"refmsg_time"`
  1771. RespondTime string `json:"respond_time"`
  1772. Signtype interface{} `json:"signtype"`
  1773. WarnInfo interface{} `json:"warn_info"`
  1774. }
  1775. type ResultTwo10265 struct {
  1776. ErrMsg string `json:"err_msg"`
  1777. InfRefmsgid string `json:"inf_refmsgid"`
  1778. Infcode string `json:"infcode"`
  1779. Output struct {
  1780. Baseinfo struct {
  1781. Age float64 `json:"age"`
  1782. Brdy string `json:"brdy"`
  1783. Certno string `json:"certno"`
  1784. Gend string `json:"gend"`
  1785. Naty string `json:"naty"`
  1786. PsnCertType string `json:"psn_cert_type"`
  1787. PsnName string `json:"psn_name"`
  1788. PsnNo string `json:"psn_no"`
  1789. } `json:"baseinfo"`
  1790. Idetinfo []interface{} `json:"idetinfo"`
  1791. Iinfo []struct {
  1792. Balc float64 `json:"balc"`
  1793. CvlservFlag string `json:"cvlserv_flag"`
  1794. EmpName string `json:"emp_name"`
  1795. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1796. Insutype string `json:"insutype"`
  1797. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1798. PausInsuDate string `json:"paus_insu_date"`
  1799. PsnInsuDate string `json:"psn_insu_date"`
  1800. PsnInsuStas string `json:"psn_insu_stas"`
  1801. PsnType string `json:"psn_type"`
  1802. } `json:"insuinfo"`
  1803. } `json:"output"`
  1804. RefmsgTime string `json:"refmsg_time"`
  1805. RespondTime string `json:"respond_time"`
  1806. Signtype interface{} `json:"signtype"`
  1807. WarnInfo interface{} `json:"warn_info"`
  1808. }
  1809. type ResultThree struct {
  1810. Cainfo interface{} `json:"cainfo"`
  1811. ErrMsg string `json:"err_msg"`
  1812. InfRefmsgid string `json:"inf_refmsgid"`
  1813. Infcode int64 `json:"infcode"`
  1814. Output struct {
  1815. Data struct {
  1816. IptOtpNo string `json:"ipt_otp_no"`
  1817. MdtrtID string `json:"mdtrt_id"`
  1818. PsnNo string `json:"psn_no"`
  1819. } `json:"data"`
  1820. } `json:"output"`
  1821. RefmsgTime string `json:"refmsg_time"`
  1822. RespondTime string `json:"respond_time"`
  1823. Signtype interface{} `json:"signtype"`
  1824. WarnMsg interface{} `json:"warn_msg"`
  1825. }
  1826. type ResultThree10265 struct {
  1827. Cainfo interface{} `json:"cainfo"`
  1828. ErrMsg string `json:"err_msg"`
  1829. InfRefmsgid string `json:"inf_refmsgid"`
  1830. Infcode string `json:"infcode"`
  1831. Output struct {
  1832. Data struct {
  1833. IptOtpNo string `json:"ipt_otp_no"`
  1834. MdtrtID string `json:"mdtrt_id"`
  1835. PsnNo string `json:"psn_no"`
  1836. } `json:"data"`
  1837. } `json:"output"`
  1838. RefmsgTime string `json:"refmsg_time"`
  1839. RespondTime string `json:"respond_time"`
  1840. Signtype interface{} `json:"signtype"`
  1841. WarnMsg interface{} `json:"warn_msg"`
  1842. }
  1843. type ResultFour struct {
  1844. Cainfo string `json:"cainfo"`
  1845. ErrMsg string `json:"err_msg"`
  1846. InfRefmsgid string `json:"inf_refmsgid"`
  1847. Infcode int64 `json:"infcode"`
  1848. Output struct {
  1849. Result []struct {
  1850. BasMednFlag string `json:"bas_medn_flag"`
  1851. ChldMedcFlag string `json:"chld_medc_flag"`
  1852. ChrgitmLv string `json:"chrgitm_lv"`
  1853. Cnt float64 `json:"cnt"`
  1854. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1855. DrtReimFlag string `json:"drt_reim_flag"`
  1856. FeedetlSn string `json:"feedetl_sn"`
  1857. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1858. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1859. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1860. ListSpItemFlag string `json:"list_sp_item_flag"`
  1861. LmtUsedFlag string `json:"lmt_used_flag"`
  1862. MedChrgitmType string `json:"med_chrgitm_type"`
  1863. Memo string `json:"memo"`
  1864. OverlmtAmt float64 `json:"overlmt_amt"`
  1865. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1866. Pric float64 `json:"pric"`
  1867. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1868. SelfpayProp float64 `json:"selfpay_prop"`
  1869. } `json:"result"`
  1870. } `json:"output"`
  1871. RefmsgTime string `json:"refmsg_time"`
  1872. RespondTime string `json:"respond_time"`
  1873. Signtype string `json:"signtype"`
  1874. WarnMsg string `json:"warn_msg"`
  1875. }
  1876. type ResultFour10265 struct {
  1877. Cainfo string `json:"cainfo"`
  1878. ErrMsg string `json:"err_msg"`
  1879. InfRefmsgid string `json:"inf_refmsgid"`
  1880. Infcode string `json:"infcode"`
  1881. Output struct {
  1882. Result []struct {
  1883. BasMednFlag string `json:"bas_medn_flag"`
  1884. ChldMedcFlag string `json:"chld_medc_flag"`
  1885. ChrgitmLv string `json:"chrgitm_lv"`
  1886. Cnt float64 `json:"cnt"`
  1887. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1888. DrtReimFlag string `json:"drt_reim_flag"`
  1889. FeedetlSn string `json:"feedetl_sn"`
  1890. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1891. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1892. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1893. ListSpItemFlag string `json:"list_sp_item_flag"`
  1894. LmtUsedFlag string `json:"lmt_used_flag"`
  1895. MedChrgitmType string `json:"med_chrgitm_type"`
  1896. Memo string `json:"memo"`
  1897. OverlmtAmt float64 `json:"overlmt_amt"`
  1898. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1899. Pric float64 `json:"pric"`
  1900. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1901. SelfpayProp float64 `json:"selfpay_prop"`
  1902. } `json:"result"`
  1903. } `json:"output"`
  1904. RefmsgTime string `json:"refmsg_time"`
  1905. RespondTime string `json:"respond_time"`
  1906. Signtype string `json:"signtype"`
  1907. WarnMsg string `json:"warn_msg"`
  1908. }
  1909. type ResultFive struct {
  1910. Balc float64 `json:"balc"`
  1911. CvlservFlag string `json:"cvlserv_flag"`
  1912. EmpName string `json:"emp_name"`
  1913. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1914. Insutype string `json:"insutype"`
  1915. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1916. PausInsuDate string `json:"paus_insu_date"`
  1917. PsnInsuDate string `json:"psn_insu_date"`
  1918. PsnInsuStas string `json:"psn_insu_stas"`
  1919. PsnType string `json:"psn_type"`
  1920. }
  1921. type ResultSix struct {
  1922. Cainfo interface{} `json:"cainfo"`
  1923. ErrMsg string `json:"err_msg"`
  1924. InfRefmsgid string `json:"inf_refmsgid"`
  1925. Infcode int64 `json:"infcode"`
  1926. Output struct {
  1927. } `json:"output"`
  1928. RefmsgTime string `json:"refmsg_time"`
  1929. RespondTime string `json:"respond_time"`
  1930. Signtype interface{} `json:"signtype"`
  1931. WarnMsg interface{} `json:"warn_msg"`
  1932. }
  1933. type ResultSix10265 struct {
  1934. Cainfo interface{} `json:"cainfo"`
  1935. ErrMsg string `json:"err_msg"`
  1936. InfRefmsgid string `json:"inf_refmsgid"`
  1937. Infcode string `json:"infcode"`
  1938. Output struct {
  1939. } `json:"output"`
  1940. RefmsgTime string `json:"refmsg_time"`
  1941. RespondTime string `json:"respond_time"`
  1942. Signtype interface{} `json:"signtype"`
  1943. WarnMsg interface{} `json:"warn_msg"`
  1944. }
  1945. type ResultSeven struct {
  1946. Cainfo string `json:"cainfo"`
  1947. ErrMsg string `json:"err_msg"`
  1948. InfRefmsgid string `json:"inf_refmsgid"`
  1949. Infcode int64 `json:"infcode"`
  1950. Output struct {
  1951. Setldetail []interface{} `json:"setldetail"`
  1952. Setlinfo struct {
  1953. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1954. AcctPay float64 `json:"acct_pay"`
  1955. ActPayDedc float64 `json:"act_pay_dedc"`
  1956. Age float64 `json:"age"`
  1957. Balc float64 `json:"balc"`
  1958. Brdy string `json:"brdy"`
  1959. Certno string `json:"certno"`
  1960. ClrOptins string `json:"clr_optins"`
  1961. ClrType string `json:"clr_type"`
  1962. ClrWay string `json:"clr_way"`
  1963. CvlservFlag string `json:"cvlserv_flag"`
  1964. CvlservPay float64 `json:"cvlserv_pay"`
  1965. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1966. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1967. Gend string `json:"gend"`
  1968. HifesPay float64 `json:"hifes_pay"`
  1969. HifmiPay float64 `json:"hifmi_pay"`
  1970. HifpPay float64 `json:"hifp_pay"`
  1971. HospPartAmt float64 `json:"hosp_part_amt"`
  1972. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1973. Insutype string `json:"insutype"`
  1974. MafPay float64 `json:"maf_pay"`
  1975. MdtrtCertType string `json:"mdtrt_cert_type"`
  1976. HifobPay float64 `json:"hifob_pay"`
  1977. MdtrtID string `json:"mdtrt_id"`
  1978. MedType string `json:"med_type"`
  1979. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1980. MedinsSetlID string `json:"medins_setl_id"`
  1981. Naty string `json:"naty"`
  1982. OthPay float64 `json:"oth_pay"`
  1983. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1984. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1985. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1986. PsnCashPay float64 `json:"psn_cash_pay"`
  1987. PsnCertType string `json:"psn_cert_type"`
  1988. PsnName string `json:"psn_name"`
  1989. PsnNo string `json:"psn_no"`
  1990. PsnPartAmt float64 `json:"psn_part_amt"`
  1991. PsnType string `json:"psn_type"`
  1992. SetlID string `json:"setl_id"`
  1993. SetlTime string `json:"setl_time"`
  1994. } `json:"setlinfo"`
  1995. } `json:"output"`
  1996. RefmsgTime string `json:"refmsg_time"`
  1997. RespondTime string `json:"respond_time"`
  1998. Signtype interface{} `json:"signtype"`
  1999. WarnMsg interface{} `json:"warn_msg"`
  2000. }
  2001. type ResultSeven10265 struct {
  2002. Cainfo string `json:"cainfo"`
  2003. ErrMsg string `json:"err_msg"`
  2004. InfRefmsgid string `json:"inf_refmsgid"`
  2005. Infcode string `json:"infcode"`
  2006. Output struct {
  2007. Setldetail []interface{} `json:"setldetail"`
  2008. Setlinfo struct {
  2009. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2010. AcctPay float64 `json:"acct_pay"`
  2011. ActPayDedc float64 `json:"act_pay_dedc"`
  2012. Age float64 `json:"age"`
  2013. Balc float64 `json:"balc"`
  2014. Brdy string `json:"brdy"`
  2015. Certno string `json:"certno"`
  2016. ClrOptins string `json:"clr_optins"`
  2017. ClrType string `json:"clr_type"`
  2018. ClrWay string `json:"clr_way"`
  2019. CvlservFlag string `json:"cvlserv_flag"`
  2020. CvlservPay float64 `json:"cvlserv_pay"`
  2021. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2022. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2023. Gend string `json:"gend"`
  2024. HifesPay float64 `json:"hifes_pay"`
  2025. HifmiPay float64 `json:"hifmi_pay"`
  2026. HifpPay float64 `json:"hifp_pay"`
  2027. HospPartAmt float64 `json:"hosp_part_amt"`
  2028. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2029. Insutype string `json:"insutype"`
  2030. MafPay float64 `json:"maf_pay"`
  2031. MdtrtCertType string `json:"mdtrt_cert_type"`
  2032. HifobPay float64 `json:"hifob_pay"`
  2033. MdtrtID string `json:"mdtrt_id"`
  2034. MedType string `json:"med_type"`
  2035. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2036. MedinsSetlID string `json:"medins_setl_id"`
  2037. Naty string `json:"naty"`
  2038. OthPay float64 `json:"oth_pay"`
  2039. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2040. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2041. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2042. PsnCashPay float64 `json:"psn_cash_pay"`
  2043. PsnCertType string `json:"psn_cert_type"`
  2044. PsnName string `json:"psn_name"`
  2045. PsnNo string `json:"psn_no"`
  2046. PsnPartAmt float64 `json:"psn_part_amt"`
  2047. PsnType string `json:"psn_type"`
  2048. SetlID string `json:"setl_id"`
  2049. SetlTime string `json:"setl_time"`
  2050. } `json:"setlinfo"`
  2051. } `json:"output"`
  2052. RefmsgTime string `json:"refmsg_time"`
  2053. RespondTime string `json:"respond_time"`
  2054. Signtype interface{} `json:"signtype"`
  2055. WarnMsg interface{} `json:"warn_msg"`
  2056. }
  2057. type ResultEight struct {
  2058. Cainfo string `json:"cainfo"`
  2059. ErrMsg string `json:"err_msg"`
  2060. InfRefmsgid string `json:"inf_refmsgid"`
  2061. Infcode int64 `json:"infcode"`
  2062. Output struct {
  2063. Stmtinfo struct {
  2064. SetlOptins string `json:"setl_optins"`
  2065. StmtRslt string `json:"stmt_rslt"`
  2066. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2067. } `json:"stmtinfo"`
  2068. } `json:"output"`
  2069. RefmsgTime string `json:"refmsg_time"`
  2070. RespondTime string `json:"respond_time"`
  2071. Signtype interface{} `json:"signtype"`
  2072. WarnMsg interface{} `json:"warn_msg"`
  2073. }
  2074. type ResultNine struct {
  2075. Cainfo string `json:"cainfo"`
  2076. ErrMsg string `json:"err_msg"`
  2077. InfRefmsgid string `json:"inf_refmsgid"`
  2078. Infcode int64 `json:"infcode"`
  2079. Output struct {
  2080. FileQuryNo string `json:"file_qury_no"`
  2081. } `json:"output"`
  2082. RefmsgTime string `json:"refmsg_time"`
  2083. RespondTime string `json:"respond_time"`
  2084. Signtype interface{} `json:"signtype"`
  2085. WarnMsg interface{} `json:"warn_msg"`
  2086. }
  2087. type ResultTen struct {
  2088. Cainfo string `json:"cainfo"`
  2089. ErrMsg string `json:"err_msg"`
  2090. InfRefmsgid string `json:"inf_refmsgid"`
  2091. Infcode int64 `json:"infcode"`
  2092. Output struct {
  2093. DldEndtime string `json:"dld_endtime"`
  2094. FileQuryNo string `json:"file_qury_no"`
  2095. Filename string `json:"filename"`
  2096. } `json:"output"`
  2097. RefmsgTime string `json:"refmsg_time"`
  2098. RespondTime string `json:"respond_time"`
  2099. Signtype interface{} `json:"signtype"`
  2100. WarnMsg interface{} `json:"warn_msg"`
  2101. }
  2102. //type Autogenerated struct {
  2103. // Output struct {
  2104. // Setlinfo struct {
  2105. // SetlTime string `json:"setl_time"`
  2106. // CvlservPay float64 `json:"cvlserv_pay"`
  2107. // Year string `json:"year"`
  2108. // MedType string `json:"med_type"`
  2109. // PsnPay float64 `json:"psn_pay"`
  2110. // OpterID string `json:"opter_id"`
  2111. // Begndate string `json:"begndate"`
  2112. // FlxempeFlag string `json:"flxempe_flag"`
  2113. // HifmiPay float64 `json:"hifmi_pay"`
  2114. // PsnNo string `json:"psn_no"`
  2115. // ActPayDedc float64 `json:"act_pay_dedc"`
  2116. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2117. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2118. // ClrWay string `json:"clr_way"`
  2119. // OthPay float64 `json:"oth_pay"`
  2120. // Gend string `json:"gend"`
  2121. // MdtrtID string `json:"mdtrt_id"`
  2122. // AcctPay float64 `json:"acct_pay"`
  2123. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2124. // Insutype string `json:"insutype"`
  2125. // Invono interface{} `json:"invono"`
  2126. // Enddate string `json:"enddate"`
  2127. // CashPayamt float64 `json:"cash_payamt"`
  2128. // PsnType string `json:"psn_type"`
  2129. // FixmedinsName string `json:"fixmedins_name"`
  2130. // HifpPay float64 `json:"hifp_pay"`
  2131. // NewFlag interface{} `json:"new_flag"`
  2132. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2133. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2134. // PayLoc string `json:"pay_loc"`
  2135. // ClrType string `json:"clr_type"`
  2136. // RefdSetlFlag string `json:"refd_setl_flag"`
  2137. // CvlservFlag string `json:"cvlserv_flag"`
  2138. // EmpName string `json:"emp_name"`
  2139. // Brdy string `json:"brdy"`
  2140. // Naty string `json:"naty"`
  2141. // Certno string `json:"certno"`
  2142. // DiseCode string `json:"dise_code"`
  2143. // FixmedinsCode string `json:"fixmedins_code"`
  2144. // DedcHospLv string `json:"dedc_hosp_lv"`
  2145. // OpterName string `json:"opter_name"`
  2146. // Balc float64 `json:"balc"`
  2147. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2148. // PsnCertType string `json:"psn_cert_type"`
  2149. // HifobPay float64 `json:"hifob_pay"`
  2150. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2151. // HifesPay float64 `json:"hifes_pay"`
  2152. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2153. // OptTime string `json:"opt_time"`
  2154. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2155. // SetlID string `json:"setl_id"`
  2156. // MafPay float64 `json:"maf_pay"`
  2157. // PsnName string `json:"psn_name"`
  2158. // InsuOptins interface{} `json:"insu_optins"`
  2159. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2160. // ClrOptins string `json:"clr_optins"`
  2161. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2162. // DiseName string `json:"dise_name"`
  2163. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2164. // Age float64 `json:"age"`
  2165. // DtrtCertType string `json:"dtrt_cert_type"`
  2166. // HospLv string `json:"hosp_lv"`
  2167. // } `json:"setlinfo"`
  2168. // Setldetail []struct {
  2169. // FundPayType string `json:"fund_pay_type"`
  2170. // FundPayamt float64 `json:"fund_payamt"`
  2171. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2172. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2173. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2174. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2175. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2176. // } `json:"setldetail"`
  2177. // } `json:"output"`
  2178. // Infcode int `json:"infcode"`
  2179. // WarnMsg interface{} `json:"warn_msg"`
  2180. // Cainfo interface{} `json:"cainfo"`
  2181. // ErrMsg interface{} `json:"err_msg"`
  2182. // RefmsgTime string `json:"refmsg_time"`
  2183. // Signtype interface{} `json:"signtype"`
  2184. // RespondTime string `json:"respond_time"`
  2185. // InfRefmsgid string `json:"inf_refmsgid"`
  2186. //}
  2187. type ResultEleven struct {
  2188. Cainfo string `json:"cainfo"`
  2189. ErrMsg string `json:"err_msg"`
  2190. InfRefmsgid string `json:"inf_refmsgid"`
  2191. Infcode int64 `json:"infcode"`
  2192. Output struct {
  2193. Setlinfo struct {
  2194. SetlTime string `json:"setl_time"`
  2195. CvlservPay float64 `json:"cvlserv_pay"`
  2196. Year string `json:"year"`
  2197. MedType string `json:"med_type"`
  2198. PsnPay float64 `json:"psn_pay"`
  2199. OpterID string `json:"opter_id"`
  2200. Begndate string `json:"begndate"`
  2201. FlxempeFlag string `json:"flxempe_flag"`
  2202. HifmiPay float64 `json:"hifmi_pay"`
  2203. PsnNo string `json:"psn_no"`
  2204. ActPayDedc float64 `json:"act_pay_dedc"`
  2205. MedinsSetlID interface{} `json:"medins_setl_id"`
  2206. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2207. ClrWay string `json:"clr_way"`
  2208. OthPay float64 `json:"oth_pay"`
  2209. Gend string `json:"gend"`
  2210. MdtrtID string `json:"mdtrt_id"`
  2211. AcctPay float64 `json:"acct_pay"`
  2212. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2213. Insutype string `json:"insutype"`
  2214. Invono interface{} `json:"invono"`
  2215. Enddate string `json:"enddate"`
  2216. CashPayamt float64 `json:"cash_payamt"`
  2217. PsnType string `json:"psn_type"`
  2218. FixmedinsName string `json:"fixmedins_name"`
  2219. HifpPay float64 `json:"hifp_pay"`
  2220. NewFlag interface{} `json:"new_flag"`
  2221. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2222. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2223. PayLoc string `json:"pay_loc"`
  2224. ClrType string `json:"clr_type"`
  2225. RefdSetlFlag string `json:"refd_setl_flag"`
  2226. CvlservFlag string `json:"cvlserv_flag"`
  2227. EmpName string `json:"emp_name"`
  2228. Brdy string `json:"brdy"`
  2229. Naty string `json:"naty"`
  2230. Certno string `json:"certno"`
  2231. DiseCode string `json:"dise_code"`
  2232. FixmedinsCode string `json:"fixmedins_code"`
  2233. DedcHospLv string `json:"dedc_hosp_lv"`
  2234. OpterName string `json:"opter_name"`
  2235. Balc float64 `json:"balc"`
  2236. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2237. PsnCertType string `json:"psn_cert_type"`
  2238. HifobPay float64 `json:"hifob_pay"`
  2239. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2240. HifesPay float64 `json:"hifes_pay"`
  2241. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2242. OptTime string `json:"opt_time"`
  2243. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2244. SetlID string `json:"setl_id"`
  2245. MafPay float64 `json:"maf_pay"`
  2246. PsnName string `json:"psn_name"`
  2247. InsuOptins interface{} `json:"insu_optins"`
  2248. PrefFundPay interface{} `json:"pref_fund_pay"`
  2249. ClrOptins string `json:"clr_optins"`
  2250. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2251. DiseName string `json:"dise_name"`
  2252. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2253. Age float64 `json:"age"`
  2254. DtrtCertType string `json:"dtrt_cert_type"`
  2255. HospLv string `json:"hosp_lv"`
  2256. } `json:"setlinfo"`
  2257. } `json:"output"`
  2258. RefmsgTime string `json:"refmsg_time"`
  2259. RespondTime string `json:"respond_time"`
  2260. Signtype interface{} `json:"signtype"`
  2261. WarnMsg interface{} `json:"warn_msg"`
  2262. }
  2263. type ResultEleven10265 struct {
  2264. Cainfo string `json:"cainfo"`
  2265. ErrMsg string `json:"err_msg"`
  2266. InfRefmsgid string `json:"inf_refmsgid"`
  2267. Infcode string `json:"infcode"`
  2268. Output struct {
  2269. Setlinfo struct {
  2270. SetlTime string `json:"setl_time"`
  2271. CvlservPay float64 `json:"cvlserv_pay"`
  2272. Year string `json:"year"`
  2273. MedType string `json:"med_type"`
  2274. PsnPay float64 `json:"psn_pay"`
  2275. OpterID string `json:"opter_id"`
  2276. Begndate string `json:"begndate"`
  2277. FlxempeFlag string `json:"flxempe_flag"`
  2278. HifmiPay float64 `json:"hifmi_pay"`
  2279. PsnNo string `json:"psn_no"`
  2280. ActPayDedc float64 `json:"act_pay_dedc"`
  2281. MedinsSetlID interface{} `json:"medins_setl_id"`
  2282. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2283. ClrWay string `json:"clr_way"`
  2284. OthPay float64 `json:"oth_pay"`
  2285. Gend string `json:"gend"`
  2286. MdtrtID string `json:"mdtrt_id"`
  2287. AcctPay float64 `json:"acct_pay"`
  2288. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2289. Insutype string `json:"insutype"`
  2290. Invono interface{} `json:"invono"`
  2291. Enddate string `json:"enddate"`
  2292. CashPayamt float64 `json:"cash_payamt"`
  2293. PsnType string `json:"psn_type"`
  2294. FixmedinsName string `json:"fixmedins_name"`
  2295. HifpPay float64 `json:"hifp_pay"`
  2296. NewFlag interface{} `json:"new_flag"`
  2297. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2298. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2299. PayLoc string `json:"pay_loc"`
  2300. ClrType string `json:"clr_type"`
  2301. RefdSetlFlag string `json:"refd_setl_flag"`
  2302. CvlservFlag string `json:"cvlserv_flag"`
  2303. EmpName string `json:"emp_name"`
  2304. Brdy string `json:"brdy"`
  2305. Naty string `json:"naty"`
  2306. Certno string `json:"certno"`
  2307. DiseCode string `json:"dise_code"`
  2308. FixmedinsCode string `json:"fixmedins_code"`
  2309. DedcHospLv string `json:"dedc_hosp_lv"`
  2310. OpterName string `json:"opter_name"`
  2311. Balc float64 `json:"balc"`
  2312. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2313. PsnCertType string `json:"psn_cert_type"`
  2314. HifobPay float64 `json:"hifob_pay"`
  2315. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2316. HifesPay float64 `json:"hifes_pay"`
  2317. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2318. OptTime string `json:"opt_time"`
  2319. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2320. SetlID string `json:"setl_id"`
  2321. MafPay float64 `json:"maf_pay"`
  2322. PsnName string `json:"psn_name"`
  2323. InsuOptins interface{} `json:"insu_optins"`
  2324. PrefFundPay interface{} `json:"pref_fund_pay"`
  2325. ClrOptins string `json:"clr_optins"`
  2326. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2327. DiseName string `json:"dise_name"`
  2328. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2329. Age float64 `json:"age"`
  2330. DtrtCertType string `json:"dtrt_cert_type"`
  2331. HospLv string `json:"hosp_lv"`
  2332. } `json:"setlinfo"`
  2333. } `json:"output"`
  2334. RefmsgTime string `json:"refmsg_time"`
  2335. RespondTime string `json:"respond_time"`
  2336. Signtype interface{} `json:"signtype"`
  2337. WarnMsg interface{} `json:"warn_msg"`
  2338. }
  2339. type ResultTwelve struct {
  2340. Cainfo string `json:"cainfo"`
  2341. ErrMsg string `json:"err_msg"`
  2342. InfRefmsgid string `json:"inf_refmsgid"`
  2343. Infcode int64 `json:"infcode"`
  2344. Output struct {
  2345. MdtrtId string `json:"mdtrt_id"`
  2346. ChrgBchno string `json:"chrg_bchno"`
  2347. PsnNo string `json:"psn_no"`
  2348. } `json:"output"`
  2349. RefmsgTime string `json:"refmsg_time"`
  2350. RespondTime string `json:"respond_time"`
  2351. Signtype interface{} `json:"signtype"`
  2352. WarnMsg interface{} `json:"warn_msg"`
  2353. }
  2354. type ResultThirteen struct {
  2355. ErrMsg string `json:"err_msg"`
  2356. InfRefmsgid string `json:"inf_refmsgid"`
  2357. Infcode int64 `json:"infcode"`
  2358. Output struct {
  2359. Result struct {
  2360. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2361. } `json:"result"`
  2362. } `json:"output"`
  2363. RefmsgTime string `json:"refmsg_time"`
  2364. RespondTime string `json:"respond_time"`
  2365. Signtype interface{} `json:"signtype"`
  2366. WarnInfo interface{} `json:"warn_info"`
  2367. }
  2368. type ResultThirteen10265 struct {
  2369. ErrMsg string `json:"err_msg"`
  2370. InfRefmsgid string `json:"inf_refmsgid"`
  2371. Infcode string `json:"infcode"`
  2372. Output struct {
  2373. Result struct {
  2374. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2375. } `json:"result"`
  2376. } `json:"output"`
  2377. RefmsgTime string `json:"refmsg_time"`
  2378. RespondTime string `json:"respond_time"`
  2379. Signtype interface{} `json:"signtype"`
  2380. WarnInfo interface{} `json:"warn_info"`
  2381. }
  2382. type ResultFourteen struct {
  2383. ErrMsg string `json:"err_msg"`
  2384. InfRefmsgid string `json:"inf_refmsgid"`
  2385. Infcode int64 `json:"infcode"`
  2386. Output struct {
  2387. } `json:"output"`
  2388. RefmsgTime string `json:"refmsg_time"`
  2389. RespondTime string `json:"respond_time"`
  2390. Signtype interface{} `json:"signtype"`
  2391. WarnInfo interface{} `json:"warn_info"`
  2392. }
  2393. type ResultFourteen10265 struct {
  2394. ErrMsg string `json:"err_msg"`
  2395. InfRefmsgid string `json:"inf_refmsgid"`
  2396. Infcode string `json:"infcode"`
  2397. Output struct {
  2398. } `json:"output"`
  2399. RefmsgTime string `json:"refmsg_time"`
  2400. RespondTime string `json:"respond_time"`
  2401. Signtype interface{} `json:"signtype"`
  2402. WarnInfo interface{} `json:"warn_info"`
  2403. }
  2404. type ResultSixteen struct {
  2405. Cainfo string `json:"cainfo"`
  2406. ErrMsg string `json:"err_msg"`
  2407. InfRefmsgid string `json:"inf_refmsgid"`
  2408. Infcode int64 `json:"infcode"`
  2409. Output struct {
  2410. Setldetail []interface{} `json:"setldetail"`
  2411. Setlinfo struct {
  2412. MdtrtID string `json:"mdtrt_id"`
  2413. SetlID string `json:"setl_id"`
  2414. ClrOptins string `json:"clr_optins"`
  2415. SetlTime string `json:"setl_time"`
  2416. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2417. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2418. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2419. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2420. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2421. ActPayDedc float64 `json:"act_pay_dedc"`
  2422. HifpPay float64 `json:"hifp_pay"`
  2423. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2424. Lfpay float64 `json:"selfpay"`
  2425. CvlservPay float64 `json:"cvlserv_pay"`
  2426. HifesPay float64 `json:"hifes_pay"`
  2427. HifmiPay float64 `json:"hifmi_pay"`
  2428. HifobPay float64 `json:"hifob_pay"`
  2429. MafPay float64 `json:"maf_pay"`
  2430. OthPay float64 `json:"oth_pay"`
  2431. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2432. PsnPartAmt float64 `json:"psn_part_amt"`
  2433. AcctPay float64 `json:"acct_pay"`
  2434. Balc float64 `json:"balc"`
  2435. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2436. HospPartAmt float64 `json:"hosp_part_amt"`
  2437. MedinsSetlID string `json:"medins_setl_id"`
  2438. PdnCashPay string `json:"pdn_cash_pay"`
  2439. } `json:"setlinfo"`
  2440. } `json:"output"`
  2441. RefmsgTime string `json:"refmsg_time"`
  2442. RespondTime string `json:"respond_time"`
  2443. Signtype interface{} `json:"signtype"`
  2444. WarnMsg interface{} `json:"warn_msg"`
  2445. }
  2446. type ResultSixteen10265 struct {
  2447. Cainfo string `json:"cainfo"`
  2448. ErrMsg string `json:"err_msg"`
  2449. InfRefmsgid string `json:"inf_refmsgid"`
  2450. Infcode string `json:"infcode"`
  2451. Output struct {
  2452. Setldetail []interface{} `json:"setldetail"`
  2453. Setlinfo struct {
  2454. MdtrtID string `json:"mdtrt_id"`
  2455. SetlID string `json:"setl_id"`
  2456. ClrOptins string `json:"clr_optins"`
  2457. SetlTime string `json:"setl_time"`
  2458. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2459. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2460. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2461. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2462. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2463. ActPayDedc float64 `json:"act_pay_dedc"`
  2464. HifpPay float64 `json:"hifp_pay"`
  2465. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2466. Lfpay float64 `json:"selfpay"`
  2467. CvlservPay float64 `json:"cvlserv_pay"`
  2468. HifesPay float64 `json:"hifes_pay"`
  2469. HifmiPay float64 `json:"hifmi_pay"`
  2470. HifobPay float64 `json:"hifob_pay"`
  2471. MafPay float64 `json:"maf_pay"`
  2472. OthPay float64 `json:"oth_pay"`
  2473. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2474. PsnPartAmt float64 `json:"psn_part_amt"`
  2475. AcctPay float64 `json:"acct_pay"`
  2476. Balc float64 `json:"balc"`
  2477. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2478. HospPartAmt float64 `json:"hosp_part_amt"`
  2479. MedinsSetlID string `json:"medins_setl_id"`
  2480. PdnCashPay string `json:"pdn_cash_pay"`
  2481. } `json:"setlinfo"`
  2482. } `json:"output"`
  2483. RefmsgTime string `json:"refmsg_time"`
  2484. RespondTime string `json:"respond_time"`
  2485. Signtype interface{} `json:"signtype"`
  2486. WarnMsg interface{} `json:"warn_msg"`
  2487. }
  2488. type ResultSeventeen struct {
  2489. ErrMsg string `json:"err_msg"`
  2490. InfRefmsgid string `json:"inf_refmsgid"`
  2491. Infcode int64 `json:"infcode"`
  2492. Output struct {
  2493. SetlListId string `json:"setl_list_id"`
  2494. } `json:"output"`
  2495. RefmsgTime string `json:"refmsg_time"`
  2496. RespondTime string `json:"respond_time"`
  2497. Signtype string `json:"signtype"`
  2498. WarnInfo string `json:"warn_info"`
  2499. }
  2500. type Result90991 struct {
  2501. ErrMsg string `json:"err_msg"`
  2502. InfRefmsgid string `json:"inf_refmsgid"`
  2503. Infcode int64 `json:"infcode"`
  2504. Output struct {
  2505. Result struct {
  2506. PsnNo string `json:"psn_no"`
  2507. CardStat string `json:"card_stat"`
  2508. Certno string `json:"certno"`
  2509. PsnName string `json:"psn_name"`
  2510. CheckStat string `json:"check_stat"`
  2511. } `json:"result"`
  2512. } `json:"output"`
  2513. RefmsgTime string `json:"refmsg_time"`
  2514. RespondTime string `json:"respond_time"`
  2515. Signtype interface{} `json:"signtype"`
  2516. WarnInfo interface{} `json:"warn_info"`
  2517. }
  2518. type Result90100 struct {
  2519. ErrMsg string `json:"err_msg"`
  2520. InfRefmsgid string `json:"inf_refmsgid"`
  2521. Infcode int64 `json:"infcode"`
  2522. Output struct {
  2523. PoolareaNo string `json:"poolarea_no"`
  2524. PoolareaNoName string `json:"poolarea_no_name"`
  2525. Insutype string `json:"insutype"`
  2526. InsutypeName string `json:"insutype_name"`
  2527. ClctType string `json:"clct_type"`
  2528. ClctTypeName string `json:"clct_type_name"`
  2529. ClctFlag string `json:"clct_flag"`
  2530. ClctFlagName string `json:"clct_flag_name"`
  2531. AccrymBegn string `json:"accrym_begn"`
  2532. AccrymEnd string `json:"accrym_end"`
  2533. ClctTime string `json:"clct_time"`
  2534. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2535. } `json:"output"`
  2536. RefmsgTime string `json:"refmsg_time"`
  2537. RespondTime string `json:"respond_time"`
  2538. Signtype interface{} `json:"signtype"`
  2539. WarnInfo interface{} `json:"warn_info"`
  2540. }
  2541. type Custom struct {
  2542. DetItemFeeSumamt string
  2543. Cut string
  2544. FeedetlSn string
  2545. Price string
  2546. MedListCodg string
  2547. Type int64
  2548. AdviceId int64
  2549. ProjectId int64
  2550. ItemId int64
  2551. }
  2552. type Result5301 struct {
  2553. ErrMsg string `json:"err_msg"`
  2554. InfRefmsgid string `json:"inf_refmsgid"`
  2555. Infcode int64 `json:"infcode"`
  2556. Output struct {
  2557. Result struct {
  2558. OpspDiseCode string `json:"opsp_dise_code"`
  2559. OpspDiseName string `json:"opsp_dise_name"`
  2560. Begndate string `json:"begndate"`
  2561. Enddate string `json:"enddate"`
  2562. } `json:"feedetail"`
  2563. } `json:"output"`
  2564. RefmsgTime string `json:"refmsg_time"`
  2565. RespondTime string `json:"respond_time"`
  2566. Signtype interface{} `json:"signtype"`
  2567. WarnInfo interface{} `json:"warn_info"`
  2568. }
  2569. type Result5301For10265 struct {
  2570. ErrMsg string `json:"err_msg"`
  2571. InfRefmsgid string `json:"inf_refmsgid"`
  2572. Infcode string `json:"infcode"`
  2573. Output struct {
  2574. Result struct {
  2575. OpspDiseCode string `json:"opsp_dise_code"`
  2576. OpspDiseName string `json:"opsp_dise_name"`
  2577. Begndate string `json:"begndate"`
  2578. Enddate string `json:"enddate"`
  2579. } `json:"feedetail"`
  2580. } `json:"output"`
  2581. RefmsgTime string `json:"refmsg_time"`
  2582. RespondTime string `json:"respond_time"`
  2583. Signtype interface{} `json:"signtype"`
  2584. WarnInfo interface{} `json:"warn_info"`
  2585. }
  2586. //获取个人信息----挂号-----上传就诊信息
  2587. func (c *HisApiController) GetRegisterInfo() {
  2588. id, _ := c.GetInt64("id")
  2589. record_time := c.GetString("record_time")
  2590. settlementValue, _ := c.GetInt64("settlement_value")
  2591. medical_insurance_card := c.GetString("medical_insurance_card")
  2592. name := c.GetString("name")
  2593. id_card_type, _ := c.GetInt64("id_card_type")
  2594. certificates, _ := c.GetInt64("certificates")
  2595. medical_care, _ := c.GetInt64("medical_care")
  2596. birthday := c.GetString("birthday")
  2597. //age, _ := c.GetInt64("age")
  2598. id_card := c.GetString("id_card")
  2599. register_type, _ := c.GetInt64("register")
  2600. doctor, _ := c.GetInt64("doctor")
  2601. department, _ := c.GetInt64("department")
  2602. gender, _ := c.GetInt64("sex")
  2603. //phone := c.GetString("phone")
  2604. registration_fee, _ := c.GetFloat("registration_fee")
  2605. medical_expenses, _ := c.GetFloat("medical_expenses")
  2606. social_type, _ := c.GetInt64("social_type")
  2607. med_type := c.GetString("social_type")
  2608. admin_user_id, _ := c.GetInt64("admin_user_id")
  2609. timeLayout := "2006-01-02"
  2610. loc, _ := time.LoadLocation("Local")
  2611. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2612. birthUnix := birthdays.Unix()
  2613. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2614. if err != nil {
  2615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2616. return
  2617. }
  2618. recordDateTime := theTime.Unix()
  2619. adminInfo := c.GetAdminUserInfo()
  2620. var patient service.Patients
  2621. if id == 0 {
  2622. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2623. } else {
  2624. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2625. }
  2626. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2627. if patientPrescription.ID == 0 {
  2628. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2629. }
  2630. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2631. if patient.ID == 0 {
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2633. return
  2634. }
  2635. if len(patient.IdCardNo) == 0 {
  2636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2637. return
  2638. }
  2639. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2640. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2641. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2642. //就诊结算未完成,不能进行二次挂号
  2643. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2644. if len(his) >= 1 {
  2645. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2646. if len(his) >= 1 && order.ID == 0 {
  2647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2648. return
  2649. }
  2650. }
  2651. //var register_log string
  2652. if config.IsOpen == 1 {
  2653. var res ResultTwo
  2654. var res10265 ResultTwo10265
  2655. var PsnNo string
  2656. var PsnCertType string
  2657. var Certno string
  2658. var PsnName string
  2659. var Gend string
  2660. var Naty string
  2661. var Brdy string
  2662. var Age float64
  2663. var infoStr string
  2664. var idetinfoStr string
  2665. var infocode int64
  2666. if miConfig.MdtrtareaAdmvs == "421300" {
  2667. psn_info, _ := service.GetPsnByPatientId(id)
  2668. PsnNo = psn_info.PsnNo
  2669. PsnCertType = psn_info.PsnCertType
  2670. Certno = psn_info.Certno
  2671. PsnName = psn_info.PsnName
  2672. Gend = psn_info.Gend
  2673. Naty = psn_info.Naty
  2674. Brdy = psn_info.Brdy
  2675. Age = psn_info.Age
  2676. infoStr = psn_info.Insuinfo
  2677. idetinfoStr = psn_info.Idetinfo
  2678. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2679. var res ResultTwo
  2680. api := "http://192.168.3.111:9532/" + "jsyb/1101?cert_no=" + "" +
  2681. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2682. "&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) + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  2683. fmt.Println(api)
  2684. resp, requestErr := http.Get(api)
  2685. if requestErr != nil {
  2686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2687. return
  2688. }
  2689. body, ioErr := ioutil.ReadAll(resp.Body)
  2690. if ioErr != nil {
  2691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2693. return
  2694. }
  2695. var respJSON map[string]interface{}
  2696. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2699. return
  2700. }
  2701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2702. result, _ := json.Marshal(respJSON)
  2703. fmt.Println("log")
  2704. fmt.Println(string(result))
  2705. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2706. utils.ErrorLog("解析失败:%v", err)
  2707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2708. return
  2709. }
  2710. PsnNo = res.Output.Baseinfo.PsnNo
  2711. PsnCertType = res.Output.Baseinfo.PsnCertType
  2712. Certno = res.Output.Baseinfo.Certno
  2713. PsnName = res.Output.Baseinfo.PsnName
  2714. Gend = res.Output.Baseinfo.Gend
  2715. Naty = res.Output.Baseinfo.Naty
  2716. Brdy = res.Output.Baseinfo.Brdy
  2717. Age = res.Output.Baseinfo.Age
  2718. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2719. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2720. infoStr = string(Iinfos)
  2721. idetinfoStr = string(Idetinfos)
  2722. infocode = res.Infcode
  2723. } else {
  2724. 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)
  2725. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2726. if miConfig.Code == "H15049901371" {
  2727. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2728. utils.ErrorLog("解析失败:%v", err)
  2729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2730. return
  2731. }
  2732. res.ErrMsg = res10265.ErrMsg
  2733. res.Output = res10265.Output
  2734. res.InfRefmsgid = res10265.InfRefmsgid
  2735. } else {
  2736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2737. utils.ErrorLog("解析失败:%v", err)
  2738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2739. return
  2740. }
  2741. }
  2742. PsnNo = res.Output.Baseinfo.PsnNo
  2743. PsnCertType = res.Output.Baseinfo.PsnCertType
  2744. Certno = res.Output.Baseinfo.Certno
  2745. PsnName = res.Output.Baseinfo.PsnName
  2746. Gend = res.Output.Baseinfo.Gend
  2747. Naty = res.Output.Baseinfo.Naty
  2748. Brdy = res.Output.Baseinfo.Brdy
  2749. Age = res.Output.Baseinfo.Age
  2750. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2751. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2752. infoStr = string(Iinfos)
  2753. idetinfoStr = string(Idetinfos)
  2754. if miConfig.Code == "H15049901371" {
  2755. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2756. } else {
  2757. infocode = res.Infcode
  2758. }
  2759. }
  2760. if infocode == 0 {
  2761. his := models.VMHisPatient{
  2762. Name: name,
  2763. Gender: gender,
  2764. Birthday: birthUnix,
  2765. MedicalTreatmentType: medical_care,
  2766. IdType: certificates,
  2767. IdCardNo: id_card,
  2768. BalanceAccountsType: settlementValue,
  2769. SocialType: social_type,
  2770. MedicalInsuranceNumber: medical_insurance_card,
  2771. RegisterType: register_type,
  2772. RegisterCost: registration_fee,
  2773. TreatmentCost: medical_expenses,
  2774. Status: 1,
  2775. Ctime: time.Now().Unix(),
  2776. Mtime: time.Now().Unix(),
  2777. PsnNo: PsnNo,
  2778. PsnCertType: PsnCertType,
  2779. Certno: Certno,
  2780. PsnName: PsnName,
  2781. Gend: Gend,
  2782. Naty: Naty,
  2783. Brdy: Brdy,
  2784. Age: Age,
  2785. Iinfo: infoStr,
  2786. Idetinfo: idetinfoStr,
  2787. PatientId: patient.ID,
  2788. RecordDate: theTime.Unix(),
  2789. UserOrgId: adminInfo.CurrentOrgId,
  2790. AdminUserId: admin_user_id,
  2791. IsReturn: 1,
  2792. IdCardType: id_card_type,
  2793. Doctor: doctor,
  2794. Departments: department,
  2795. }
  2796. timestamp := time.Now().Unix()
  2797. tempTime := time.Unix(timestamp, 0)
  2798. timeFormat := tempTime.Format("20060102150405")
  2799. chrgBchno := rand.Intn(100000) + 10000
  2800. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2801. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2802. department, _ := service.GetDepartMentDetail(department)
  2803. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2804. IdCardNo := ""
  2805. if id_card_type == 1 {
  2806. // IdCardNo = medical_insurance_card
  2807. IdCardNo = patient.IdCardNo
  2808. } else {
  2809. IdCardNo = patient.IdCardNo
  2810. }
  2811. var rf []*ResultFive
  2812. json.Unmarshal([]byte(his.Iinfo), &rf)
  2813. var insutypes []*ResultFive
  2814. var insutype string
  2815. var insuplc_admdvs string
  2816. var is390 int = 0
  2817. var is310 int = 0
  2818. for _, item := range rf {
  2819. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2820. insutypes = append(insutypes, item)
  2821. }
  2822. }
  2823. if len(insutypes) == 1 {
  2824. insutype = insutypes[0].Insutype
  2825. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2826. } else {
  2827. for _, i := range insutypes {
  2828. if i.Insutype == "390" {
  2829. is390 = 1
  2830. }
  2831. if i.Insutype == "310" {
  2832. is310 = 1
  2833. }
  2834. }
  2835. }
  2836. if is390 == 1 {
  2837. insutype = "390"
  2838. }
  2839. if is310 == 1 {
  2840. insutype = "310"
  2841. }
  2842. if len(insutypes) == 0 {
  2843. insutype = "310"
  2844. }
  2845. if len(insutypes) == 2 {
  2846. insutype = med_type
  2847. }
  2848. if len(med_type) > 0 {
  2849. insutype = med_type
  2850. }
  2851. for _, item := range rf {
  2852. if item.Insutype == insutype {
  2853. insuplc_admdvs = item.InsuplcAdmdvs
  2854. }
  2855. }
  2856. var infocode int64
  2857. var resThree ResultThree
  2858. var resThree10265 ResultThree10265
  2859. if miConfig.MdtrtareaAdmvs == "421300" {
  2860. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2861. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2862. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&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
  2863. resp, requestErr := http.Get(api)
  2864. if requestErr != nil {
  2865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2866. return
  2867. }
  2868. body, ioErr := ioutil.ReadAll(resp.Body)
  2869. if ioErr != nil {
  2870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2872. return
  2873. }
  2874. var respJSON map[string]interface{}
  2875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2878. return
  2879. }
  2880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2881. result, _ := json.Marshal(respJSON)
  2882. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2883. utils.ErrorLog("解析失败:%v", err)
  2884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2885. return
  2886. }
  2887. infocode = resThree.Infcode
  2888. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2889. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2890. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2891. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&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.ChannelNumber
  2892. resp, requestErr := http.Get(api)
  2893. if requestErr != nil {
  2894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2895. return
  2896. }
  2897. body, ioErr := ioutil.ReadAll(resp.Body)
  2898. if ioErr != nil {
  2899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2901. return
  2902. }
  2903. var respJSON map[string]interface{}
  2904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. result, _ := json.Marshal(respJSON)
  2911. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. return
  2915. }
  2916. infocode = resThree.Infcode
  2917. } else {
  2918. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  2919. saveLog(result, requestLog, "2201", "挂号")
  2920. if miConfig.Code == "H15049901371" {
  2921. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2922. utils.ErrorLog("解析失败:%v", err)
  2923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2924. return
  2925. }
  2926. resThree.ErrMsg = resThree10265.ErrMsg
  2927. resThree.Output = resThree10265.Output
  2928. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2929. } else {
  2930. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2931. utils.ErrorLog("解析失败:%v", err)
  2932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2933. return
  2934. }
  2935. }
  2936. if miConfig.Code == "H15049901371" {
  2937. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2938. } else {
  2939. infocode = resThree.Infcode
  2940. }
  2941. }
  2942. if infocode != 0 {
  2943. adminUser := c.GetAdminUserInfo()
  2944. errlog := &models.HisOrderError{
  2945. UserOrgId: adminUser.CurrentOrgId,
  2946. Ctime: time.Now().Unix(),
  2947. Mtime: time.Now().Unix(),
  2948. ErrMsg: resThree.ErrMsg,
  2949. Status: 1,
  2950. PatientId: id,
  2951. RecordTime: recordDateTime,
  2952. Stage: 2,
  2953. }
  2954. service.CreateErrMsgLog(errlog)
  2955. c.ServeSuccessJSON(map[string]interface{}{
  2956. "failed_code": -10,
  2957. "msg": resThree.ErrMsg,
  2958. })
  2959. return
  2960. }
  2961. his.Number = resThree.Output.Data.MdtrtID
  2962. his.PsnNo = resThree.Output.Data.PsnNo
  2963. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2964. his.IdCardNo = patient.IdCardNo
  2965. his.PhoneNumber = patient.Phone
  2966. his.UserOrgId = adminInfo.CurrentOrgId
  2967. his.Insutype = insutype
  2968. his.Ctime = time.Now().Unix()
  2969. his.Mtime = time.Now().Unix()
  2970. his.InsuplcAdmdvs = insuplc_admdvs
  2971. his.Status = 1
  2972. service.UpdateHisPatientStatus(&his)
  2973. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2974. c.ServeSuccessJSON(map[string]interface{}{
  2975. "his_info": his,
  2976. })
  2977. } else {
  2978. adminUser := c.GetAdminUserInfo()
  2979. errlog := &models.HisOrderError{
  2980. UserOrgId: adminUser.CurrentOrgId,
  2981. Ctime: time.Now().Unix(),
  2982. Mtime: time.Now().Unix(),
  2983. ErrMsg: res.ErrMsg,
  2984. Status: 1,
  2985. PatientId: id,
  2986. RecordTime: recordDateTime,
  2987. Stage: 1,
  2988. }
  2989. service.CreateErrMsgLog(errlog)
  2990. c.ServeSuccessJSON(map[string]interface{}{
  2991. "failed_code": -10,
  2992. "msg": res.ErrMsg,
  2993. })
  2994. return
  2995. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2996. }
  2997. }
  2998. }
  2999. //上传明细----预结算----确认订单
  3000. func (c *HisApiController) GetUploadInfo() {
  3001. id, _ := c.GetInt64("id")
  3002. record_time := c.GetString("record_time")
  3003. his_patient_id, _ := c.GetInt64("his_patient_id")
  3004. order_id, _ := c.GetInt64("order_id")
  3005. pay_way, _ := c.GetInt64("pay_way")
  3006. pay_price, _ := c.GetFloat("pay_price")
  3007. pay_card_no := c.GetString("pay_card_no")
  3008. discount_price, _ := c.GetFloat("discount_price")
  3009. preferential_price, _ := c.GetFloat("preferential_price")
  3010. reality_price, _ := c.GetFloat("reality_price")
  3011. found_price, _ := c.GetFloat("found_price")
  3012. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3013. private_price, _ := c.GetFloat("private_price")
  3014. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3015. admin_user_id, _ := c.GetInt64("admin_user_id")
  3016. fapiao_code := c.GetString("fapiao_code")
  3017. fapiao_number := c.GetString("fapiao_number")
  3018. diagnosis_id := c.GetString("diagnosis")
  3019. sick_type, _ := c.GetInt64("sick_type")
  3020. reg_type, _ := c.GetInt64("p_type")
  3021. begin_time := c.GetString("begin_time")
  3022. id_str := c.GetString("ids")
  3023. ids_arr := strings.Split(id_str, ",")
  3024. timeLayout := "2006-01-02"
  3025. loc, _ := time.LoadLocation("Local")
  3026. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3027. if err != nil {
  3028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3029. return
  3030. }
  3031. recordDateTime := theTime.Unix()
  3032. adminUser := c.GetAdminUserInfo()
  3033. var tempOrder models.HisOrder
  3034. tempOrder, _ = service.GetHisOrderByID(order_id)
  3035. var prescriptions []*models.HisPrescription
  3036. var start_time int64
  3037. var end_time int64
  3038. //if adminUser.CurrentOrgId == 10106{
  3039. // if len(fapiao_code) == 0{
  3040. // fapiao_code = "144072080589"
  3041. // }
  3042. // if len(fapiao_number) == 0{
  3043. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3044. // if order.ID == 0{
  3045. // fapiao_number = "00001520"
  3046. // }else{
  3047. // //fapiao_code = "00001520"
  3048. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3049. // var zero string
  3050. // if fpNumber >= 1000{
  3051. // zero = "0000" + strconv.Itoa(fpNumber)
  3052. // }else if fpNumber >= 10000{
  3053. // zero = "000" + strconv.Itoa(fpNumber)
  3054. // } else if fpNumber >= 100000{
  3055. // zero = "00" + strconv.Itoa(fpNumber)
  3056. // } else if fpNumber >= 1000000{
  3057. // zero = "0" + strconv.Itoa(fpNumber)
  3058. // }else {
  3059. // zero = strconv.Itoa(fpNumber)
  3060. // }
  3061. // fapiao_number = zero
  3062. // }
  3063. // }
  3064. //}
  3065. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3066. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3067. var patientPrescription models.HisPrescriptionInfo
  3068. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3069. if patientPrescription.ID == 0 {
  3070. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3071. }
  3072. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3073. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3074. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3075. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3076. var config []*models.HisXtDiagnoseConfig
  3077. for _, item := range diagnosis_ids {
  3078. id, _ := strconv.ParseInt(item, 10, 64)
  3079. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3080. config = append(config, &diagnosisConfig)
  3081. }
  3082. sickConfig, _ := service.FindSickById(sick_type)
  3083. if tempOrder.ID == 0 {
  3084. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3085. }
  3086. if tempOrder.ID == 0 {
  3087. var result string
  3088. var requestLog string
  3089. var res2 ResultSix
  3090. var ressix10265 ResultSix10265
  3091. if miConfig.InsuplcAdmdvs == "421300" {
  3092. data := make(map[string]interface{})
  3093. client := &http.Client{}
  3094. data["psn_no"] = his.PsnNo
  3095. data["mdtrt_id"] = his.Number
  3096. data["doctor"] = roles.UserName
  3097. data["department"] = department.Name
  3098. data["org_name"] = miConfig.OrgName
  3099. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3100. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3101. data["fixmedins_code"] = miConfig.Code
  3102. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3103. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3104. data["secret_key"] = miConfig.SecretKey
  3105. data["sick_code"] = sickConfig.CountryCode
  3106. data["sick_name"] = sickConfig.ClassName
  3107. data["dept"] = strconv.FormatInt(department.ID, 10)
  3108. data["config"] = config
  3109. data["begin_time"] = begin_time
  3110. bytesData, _ := json.Marshal(data)
  3111. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3112. resp, _ := client.Do(req)
  3113. defer resp.Body.Close()
  3114. body, ioErr := ioutil.ReadAll(resp.Body)
  3115. if ioErr != nil {
  3116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3118. return
  3119. }
  3120. var respJSON map[string]interface{}
  3121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3124. return
  3125. }
  3126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3127. userJSONBytes, _ := json.Marshal(respJSON)
  3128. fmt.Println("log")
  3129. fmt.Println(string(userJSONBytes))
  3130. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3131. utils.ErrorLog("解析失败:%v", err)
  3132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3133. return
  3134. }
  3135. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3136. data := make(map[string]interface{})
  3137. client := &http.Client{}
  3138. data["psn_no"] = his.PsnNo
  3139. data["mdtrt_id"] = his.Number
  3140. data["doctor"] = roles.UserName
  3141. data["department"] = department.Name
  3142. data["org_name"] = miConfig.OrgName
  3143. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3144. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3145. data["fixmedins_code"] = miConfig.Code
  3146. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3147. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3148. data["secret_key"] = miConfig.SecretKey
  3149. data["sick_code"] = sickConfig.CountryCode
  3150. data["sick_name"] = sickConfig.ClassName
  3151. data["url"] = miConfig.Url
  3152. data["ak"] = miConfig.ChannelNumber
  3153. data["begin_time"] = begin_time
  3154. data["dept"] = strconv.FormatInt(department.ID, 10)
  3155. data["config"] = config
  3156. bytesData, _ := json.Marshal(data)
  3157. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3158. resp, _ := client.Do(req)
  3159. defer resp.Body.Close()
  3160. body, ioErr := ioutil.ReadAll(resp.Body)
  3161. if ioErr != nil {
  3162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. return
  3165. }
  3166. var respJSON map[string]interface{}
  3167. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3170. return
  3171. }
  3172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3173. userJSONBytes, _ := json.Marshal(respJSON)
  3174. fmt.Println("log")
  3175. fmt.Println(string(userJSONBytes))
  3176. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3177. utils.ErrorLog("解析失败:%v", err)
  3178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3179. return
  3180. }
  3181. } else {
  3182. if miConfig.MdtrtareaAdmvs == "440781" { //
  3183. 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)
  3184. } else {
  3185. if miConfig.Code == "H15049901371" {
  3186. //赤峰地区国家医保医疗类别
  3187. //职工透析:医疗类别选特殊情况门诊990502
  3188. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3189. var med_type string
  3190. if his.Insutype == "390" {
  3191. if reg_type == 14 {
  3192. med_type = "9933"
  3193. } else if reg_type == 11 {
  3194. med_type = "11"
  3195. }
  3196. } else if his.Insutype == "310" {
  3197. if reg_type == 14 {
  3198. med_type = "990502"
  3199. } else if reg_type == 11 {
  3200. med_type = "11"
  3201. }
  3202. }
  3203. 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)
  3204. } else {
  3205. 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)
  3206. }
  3207. }
  3208. saveLog(result, requestLog, "2203", "上传就诊信息")
  3209. var respJSON2 map[string]interface{}
  3210. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3213. return
  3214. }
  3215. userJSONBytes2, _ := json.Marshal(respJSON2)
  3216. if miConfig.Code == "H15049901371" {
  3217. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3218. utils.ErrorLog("解析失败:%v", err)
  3219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3220. return
  3221. }
  3222. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3223. res2.Output = ressix10265.Output
  3224. res2.ErrMsg = ressix10265.ErrMsg
  3225. res2.Cainfo = ressix10265.Cainfo
  3226. res2.WarnMsg = ressix10265.WarnMsg
  3227. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3228. res2.Infcode = infocode
  3229. } else {
  3230. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3231. utils.ErrorLog("解析失败:%v", err)
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3233. return
  3234. }
  3235. }
  3236. }
  3237. if res2.Infcode != 0 {
  3238. adminUser := c.GetAdminUserInfo()
  3239. errlog := &models.HisOrderError{
  3240. UserOrgId: adminUser.CurrentOrgId,
  3241. Ctime: time.Now().Unix(),
  3242. Mtime: time.Now().Unix(),
  3243. ErrMsg: res2.ErrMsg,
  3244. Status: 1,
  3245. PatientId: id,
  3246. RecordTime: recordDateTime,
  3247. Stage: 3,
  3248. }
  3249. service.CreateErrMsgLog(errlog)
  3250. c.ServeSuccessJSON(map[string]interface{}{
  3251. "failed_code": -10,
  3252. "msg": res2.ErrMsg,
  3253. })
  3254. return
  3255. } else {
  3256. his.Diagnosis = diagnosis_id
  3257. his.SickType = sickConfig.ID
  3258. var p_type int64
  3259. if reg_type == 1111 || reg_type == 1112 {
  3260. p_type = 11
  3261. }
  3262. his.PType = fmt.Sprintf("%d", p_type)
  3263. service.UpdateHisPatientThree(&his)
  3264. data := make(map[string]interface{})
  3265. if settle_accounts_type == 1 { //日结
  3266. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3267. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3268. } else {
  3269. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3270. }
  3271. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3272. data["pre"] = prescriptions
  3273. } else { //月结
  3274. start_time_str := c.GetString("start_time")
  3275. end_time_str := c.GetString("end_time")
  3276. timeLayout := "2006-01-02"
  3277. loc, _ := time.LoadLocation("Local")
  3278. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3279. if err != nil {
  3280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3281. return
  3282. }
  3283. recordStartTime := theStartTime.Unix()
  3284. start_time = recordStartTime
  3285. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3286. if err != nil {
  3287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3288. return
  3289. }
  3290. recordEndTime := theEndTime.Unix()
  3291. end_time = recordEndTime
  3292. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3293. data["pre"] = prescriptions
  3294. }
  3295. timestamp := time.Now().Unix()
  3296. tempTime := time.Unix(timestamp, 0)
  3297. timeFormat := tempTime.Format("20060102150405")
  3298. chrgBchno := rand.Intn(100000) + 10000
  3299. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3300. strconv.FormatInt(his.PatientId, 10)
  3301. client := &http.Client{}
  3302. data["psn_no"] = his.PsnNo
  3303. data["mdtrt_id"] = his.Number
  3304. data["chrg_bchno"] = chrg_bchno
  3305. data["org_name"] = miConfig.OrgName
  3306. data["doctor"] = roles.UserName
  3307. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3308. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3309. data["fixmedins_code"] = miConfig.Code
  3310. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3311. data["dept_code"] = "15"
  3312. } else {
  3313. data["dept_code"] = department.Number
  3314. }
  3315. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3316. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3317. data["secret_key"] = miConfig.SecretKey
  3318. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3319. data["url"] = miConfig.Url
  3320. data["ak"] = miConfig.ChannelNumber
  3321. data["new_doctor_name"] = patientPrescription.Doctor
  3322. var ids []int64
  3323. for _, item := range prescriptions {
  3324. ids = append(ids, item.ID)
  3325. }
  3326. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3327. if config.IsOpen == 1 { //对接了医保,走医保流程
  3328. var res ResultFour
  3329. var resFour10265 ResultFour10265
  3330. if miConfig.MdtrtareaAdmvs == "421300" {
  3331. bytesData, _ := json.Marshal(data)
  3332. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3333. resp, _ := client.Do(req)
  3334. defer resp.Body.Close()
  3335. body, ioErr := ioutil.ReadAll(resp.Body)
  3336. if ioErr != nil {
  3337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3339. return
  3340. }
  3341. var respJSON map[string]interface{}
  3342. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3345. return
  3346. }
  3347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3348. userJSONBytes, _ := json.Marshal(respJSON)
  3349. fmt.Println("log")
  3350. fmt.Println(string(userJSONBytes))
  3351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3352. utils.ErrorLog("解析失败:%v", err)
  3353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3354. return
  3355. }
  3356. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3357. bytesData, _ := json.Marshal(data)
  3358. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3359. resp, _ := client.Do(req)
  3360. defer resp.Body.Close()
  3361. body, ioErr := ioutil.ReadAll(resp.Body)
  3362. if ioErr != nil {
  3363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3365. return
  3366. }
  3367. var respJSON map[string]interface{}
  3368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3371. return
  3372. }
  3373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3374. userJSONBytes, _ := json.Marshal(respJSON)
  3375. fmt.Println("log")
  3376. fmt.Println(string(userJSONBytes))
  3377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3378. utils.ErrorLog("解析失败:%v", err)
  3379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3380. return
  3381. }
  3382. } else {
  3383. if miConfig.Code == "H15049901371" {
  3384. 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)
  3385. var dat map[string]interface{}
  3386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3387. fmt.Println(dat)
  3388. } else {
  3389. fmt.Println(err)
  3390. }
  3391. saveLog(result, request_log, "2204", "上传费用明细")
  3392. userJSONBytes, _ := json.Marshal(dat)
  3393. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3394. utils.ErrorLog("解析失败:%v", err)
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3396. return
  3397. }
  3398. res.InfRefmsgid = resFour10265.InfRefmsgid
  3399. res.Output = resFour10265.Output
  3400. res.ErrMsg = resFour10265.ErrMsg
  3401. res.Cainfo = resFour10265.Cainfo
  3402. res.WarnMsg = resFour10265.WarnMsg
  3403. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3404. res.Infcode = infocode
  3405. } else {
  3406. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3407. var dat map[string]interface{}
  3408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3409. fmt.Println(dat)
  3410. } else {
  3411. fmt.Println(err)
  3412. }
  3413. saveLog(result, request_log, "2204", "上传费用明细")
  3414. userJSONBytes, _ := json.Marshal(dat)
  3415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3416. utils.ErrorLog("解析失败:%v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. }
  3421. }
  3422. if res.Infcode == 0 {
  3423. order := &models.HisOrder{
  3424. UserOrgId: adminUser.CurrentOrgId,
  3425. HisPatientId: his.ID,
  3426. PatientId: his.PatientId,
  3427. SettleAccountsDate: recordDateTime,
  3428. Ctime: time.Now().Unix(),
  3429. Mtime: time.Now().Unix(),
  3430. Status: 1,
  3431. Number: chrg_bchno,
  3432. Infcode: res.Infcode,
  3433. WarnMsg: res.WarnMsg,
  3434. Cainfo: res.Cainfo,
  3435. ErrMsg: res.ErrMsg,
  3436. RespondTime: res.RefmsgTime,
  3437. InfRefmsgid: res.InfRefmsgid,
  3438. OrderStatus: 1,
  3439. PayWay: pay_way,
  3440. PayPrice: pay_price,
  3441. PayCardNo: pay_card_no,
  3442. DiscountPrice: discount_price,
  3443. PreferentialPrice: preferential_price,
  3444. RealityPrice: reality_price,
  3445. FoundPrice: found_price,
  3446. MedicalInsurancePrice: medical_insurance_price,
  3447. PrivatePrice: private_price,
  3448. IsMedicineInsurance: 1,
  3449. SettleType: settle_accounts_type,
  3450. SettleStartTime: start_time,
  3451. SettleEndTime: end_time,
  3452. Creator: roles.AdminUserId,
  3453. Modify: roles.AdminUserId,
  3454. FaPiaoNumber: fapiao_number,
  3455. FaPiaoCode: fapiao_code,
  3456. PType: 2,
  3457. Diagnosis: diagnosis_id,
  3458. }
  3459. err = service.CreateOrder(order)
  3460. if err != nil {
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3462. return
  3463. }
  3464. for _, item := range res.Output.Result {
  3465. temp := strings.Split(item.FeedetlSn, "-")
  3466. var advice_id int64 = 0
  3467. var project_id int64 = 0
  3468. var types int64 = 0
  3469. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3470. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3471. if temp[1] == "1" {
  3472. advice_id = id
  3473. project_id = 0
  3474. } else if temp[1] == "2" {
  3475. advice_id = 0
  3476. project_id = id
  3477. }
  3478. info := &models.HisOrderInfo{
  3479. OrderNumber: order.Number,
  3480. FeedetlSn: item.FeedetlSn,
  3481. UploadDate: time.Now().Unix(),
  3482. AdviceId: advice_id,
  3483. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3484. Cnt: item.Cnt,
  3485. Pric: float64(item.Pric),
  3486. PatientId: his.PatientId,
  3487. PricUplmtAmt: item.PricUplmtAmt,
  3488. SelfpayProp: item.SelfpayProp,
  3489. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3490. OverlmtAmt: item.OverlmtAmt,
  3491. PreselfpayAmt: item.PreselfpayAmt,
  3492. BasMednFlag: item.BasMednFlag,
  3493. MedChrgitmType: item.MedChrgitmType,
  3494. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3495. Status: 1,
  3496. Memo: item.Memo,
  3497. Mtime: time.Now().Unix(),
  3498. InscpScpAmt: item.InscpScpAmt,
  3499. DrtReimFlag: item.DrtReimFlag,
  3500. Ctime: time.Now().Unix(),
  3501. ListSpItemFlag: item.ListSpItemFlag,
  3502. ChldMedcFlag: item.ChldMedcFlag,
  3503. LmtUsedFlag: item.LmtUsedFlag,
  3504. ChrgitmLv: item.ChrgitmLv,
  3505. UserOrgId: adminUser.CurrentOrgId,
  3506. HisPatientId: his.ID,
  3507. OrderId: order.ID,
  3508. ProjectId: project_id,
  3509. Type: types,
  3510. }
  3511. service.CreateOrderInfo(info)
  3512. }
  3513. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3514. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3515. var total float64
  3516. for _, item := range prescriptions {
  3517. if item.Type == 1 { //药品
  3518. for _, subItem := range item.HisDoctorAdviceInfo {
  3519. total = total + (subItem.Price * subItem.PrescribingNumber)
  3520. }
  3521. }
  3522. if item.Type == 2 { //项目
  3523. for _, subItem := range item.HisPrescriptionProject {
  3524. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3525. total = total + (subItem.Price * cnt)
  3526. }
  3527. }
  3528. }
  3529. for _, item := range prescriptions {
  3530. for _, subItem := range item.HisAdditionalCharge {
  3531. total = total + (subItem.Price * float64(subItem.Count))
  3532. }
  3533. }
  3534. var allTotal string
  3535. if adminUser.CurrentOrgId == 9919 {
  3536. allTotal = fmt.Sprintf("%.4f", total)
  3537. } else {
  3538. allTotal = fmt.Sprintf("%.4f", total)
  3539. }
  3540. if res.Infcode == 0 {
  3541. var rf []*ResultFive
  3542. json.Unmarshal([]byte(his.Iinfo), &rf)
  3543. chrg_bchno := chrg_bchno
  3544. cert_no := his.Certno
  3545. var insutypes []string
  3546. var insutype string
  3547. var is390 int = 0
  3548. var is310 int = 0
  3549. for _, item := range rf {
  3550. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3551. insutypes = append(insutypes, item.Insutype)
  3552. }
  3553. }
  3554. if len(insutypes) == 1 {
  3555. insutype = insutypes[0]
  3556. } else {
  3557. for _, i := range insutypes {
  3558. if i == "390" {
  3559. is390 = 1
  3560. }
  3561. if i == "310" {
  3562. is310 = 1
  3563. }
  3564. }
  3565. }
  3566. if is390 == 1 {
  3567. insutype = "390"
  3568. }
  3569. if is310 == 1 {
  3570. insutype = "310"
  3571. }
  3572. if len(insutypes) == 0 {
  3573. insutype = "310"
  3574. }
  3575. if len(insutypes) == 2 {
  3576. insutype = strconv.FormatInt(his.SocialType, 10)
  3577. }
  3578. insutype = strconv.FormatInt(his.SocialType, 10)
  3579. //insutype = "390"
  3580. if his.IdCardType == 1 {
  3581. // cert_no = his.MedicalInsuranceNumber
  3582. cert_no = his.Certno
  3583. } else {
  3584. cert_no = his.Certno
  3585. }
  3586. var res ResultSeven
  3587. var resSeven10265 ResultSeven10265
  3588. var src_resquest string
  3589. var result2 string
  3590. var acct_used_flag string
  3591. fmt.Println("pay_way")
  3592. fmt.Println(pay_way)
  3593. fmt.Println("pay_way")
  3594. if pay_way == 4 {
  3595. acct_used_flag = "1"
  3596. } else {
  3597. acct_used_flag = "0"
  3598. }
  3599. if miConfig.MdtrtareaAdmvs == "421300" {
  3600. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3601. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3602. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3603. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3604. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3605. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3606. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3607. resp, requestErr := http.Get(api)
  3608. if requestErr != nil {
  3609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3610. return
  3611. }
  3612. body, ioErr := ioutil.ReadAll(resp.Body)
  3613. if ioErr != nil {
  3614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. var respJSON map[string]interface{}
  3619. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3622. return
  3623. }
  3624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3625. result, _ := json.Marshal(respJSON)
  3626. if miConfig.Code == "H15049901371" {
  3627. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3628. utils.ErrorLog("解析失败:%v", err)
  3629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3630. return
  3631. }
  3632. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3633. res.Output = resSeven10265.Output
  3634. res.ErrMsg = resSeven10265.ErrMsg
  3635. res.Cainfo = resSeven10265.Cainfo
  3636. res.WarnMsg = resSeven10265.WarnMsg
  3637. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3638. res.Infcode = infocode
  3639. } else {
  3640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3641. utils.ErrorLog("解析失败:%v", err)
  3642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3643. return
  3644. }
  3645. }
  3646. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3647. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3648. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3649. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3650. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3651. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3652. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3653. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  3654. resp, requestErr := http.Get(api)
  3655. if requestErr != nil {
  3656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3657. return
  3658. }
  3659. body, ioErr := ioutil.ReadAll(resp.Body)
  3660. if ioErr != nil {
  3661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3663. return
  3664. }
  3665. var respJSON map[string]interface{}
  3666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3669. return
  3670. }
  3671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3672. result, _ := json.Marshal(respJSON)
  3673. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3674. utils.ErrorLog("解析失败:%v", err)
  3675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. return
  3677. }
  3678. } else {
  3679. if miConfig.Code == "H15049901371" {
  3680. //赤峰地区国家医保医疗类别
  3681. //职工透析:医疗类别选特殊情况门诊990502
  3682. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3683. var med_type string
  3684. if his.Insutype == "390" {
  3685. if reg_type == 14 {
  3686. med_type = "9933"
  3687. } else if reg_type == 11 {
  3688. med_type = "11"
  3689. }
  3690. } else if his.Insutype == "310" {
  3691. if reg_type == 14 {
  3692. med_type = "990502"
  3693. } else if reg_type == 11 {
  3694. med_type = "11"
  3695. }
  3696. }
  3697. 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)
  3698. } else {
  3699. 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3700. }
  3701. //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)
  3702. var dat map[string]interface{}
  3703. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3704. fmt.Println(dat)
  3705. } else {
  3706. fmt.Println(err)
  3707. }
  3708. saveLog(result2, src_resquest, "2207", "结算")
  3709. userJSONBytes, _ := json.Marshal(dat)
  3710. if miConfig.Code == "H15049901371" {
  3711. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3712. utils.ErrorLog("解析失败:%v", err)
  3713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3714. return
  3715. }
  3716. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3717. res.Output = resSeven10265.Output
  3718. res.ErrMsg = resSeven10265.ErrMsg
  3719. res.Cainfo = resSeven10265.Cainfo
  3720. res.WarnMsg = resSeven10265.WarnMsg
  3721. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3722. res.Infcode = infocode
  3723. } else {
  3724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3725. utils.ErrorLog("解析失败:%v", err)
  3726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3727. return
  3728. }
  3729. }
  3730. }
  3731. if res.Infcode != 0 {
  3732. errlog := &models.HisOrderError{
  3733. UserOrgId: adminUser.CurrentOrgId,
  3734. Ctime: time.Now().Unix(),
  3735. Mtime: time.Now().Unix(),
  3736. Number: chrg_bchno,
  3737. ErrMsg: res.ErrMsg,
  3738. Status: 1,
  3739. PatientId: id,
  3740. RecordTime: recordDateTime,
  3741. Stage: 6,
  3742. }
  3743. service.CreateErrMsgLog(errlog)
  3744. c.ServeSuccessJSON(map[string]interface{}{
  3745. "failed_code": -10,
  3746. "msg": res.ErrMsg,
  3747. })
  3748. return
  3749. } else {
  3750. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3751. order.OrderStatus = 2
  3752. order.Status = 1
  3753. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3754. order.SetlId = res.Output.Setlinfo.SetlID
  3755. order.PsnNo = res.Output.Setlinfo.PsnNo
  3756. order.PsnName = res.Output.Setlinfo.PsnName
  3757. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3758. order.Certno = res.Output.Setlinfo.Certno
  3759. order.Gend = res.Output.Setlinfo.Gend
  3760. order.Naty = res.Output.Setlinfo.Naty
  3761. order.Age = res.Output.Setlinfo.Age
  3762. order.Insutype = res.Output.Setlinfo.Insutype
  3763. order.PsnType = res.Output.Setlinfo.PsnType
  3764. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3765. order.SetlTime = res.Output.Setlinfo.SetlTime
  3766. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3767. if res.Output.Setlinfo.MedType == "140101" {
  3768. order.MedType = "14"
  3769. } else {
  3770. order.MedType = res.Output.Setlinfo.MedType
  3771. }
  3772. if reg_type == 1112 {
  3773. order.MedType = "1112"
  3774. }
  3775. if reg_type == 1111 {
  3776. order.MedType = "1111"
  3777. }
  3778. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3779. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3780. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3781. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3782. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3783. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3784. order.HifpPay = res.Output.Setlinfo.HifpPay
  3785. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3786. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3787. order.HifesPay = res.Output.Setlinfo.HifesPay
  3788. order.HifobPay = res.Output.Setlinfo.HifobPay
  3789. order.MafPay = res.Output.Setlinfo.MafPay
  3790. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3791. order.OthPay = res.Output.Setlinfo.OthPay
  3792. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3793. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3794. order.AcctPay = res.Output.Setlinfo.AcctPay
  3795. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3796. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3797. order.Balc = res.Output.Setlinfo.Balc
  3798. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3799. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3800. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3801. order.ClrWay = res.Output.Setlinfo.ClrWay
  3802. order.Creator = order.Creator
  3803. order.Modify = roles.AdminUserId
  3804. order.RequestLog = src_resquest
  3805. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3806. detailStr := string(setlDetail)
  3807. order.SetlDetail = detailStr
  3808. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3809. err = service.UpDateOrder(order)
  3810. if err == nil {
  3811. c.ServeSuccessJSON(map[string]interface{}{
  3812. "msg": "结算成功",
  3813. })
  3814. } else {
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3816. return
  3817. }
  3818. }
  3819. } else {
  3820. adminUser := c.GetAdminUserInfo()
  3821. errlog := &models.HisOrderError{
  3822. UserOrgId: adminUser.CurrentOrgId,
  3823. Ctime: time.Now().Unix(),
  3824. Mtime: time.Now().Unix(),
  3825. ErrMsg: res.ErrMsg,
  3826. Status: 1,
  3827. PatientId: id,
  3828. RecordTime: recordDateTime,
  3829. Stage: 4,
  3830. }
  3831. service.CreateErrMsgLog(errlog)
  3832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3833. return
  3834. }
  3835. } else {
  3836. adminUser := c.GetAdminUserInfo()
  3837. errlog := &models.HisOrderError{
  3838. UserOrgId: adminUser.CurrentOrgId,
  3839. Ctime: time.Now().Unix(),
  3840. Mtime: time.Now().Unix(),
  3841. ErrMsg: res.ErrMsg,
  3842. Status: 1,
  3843. PatientId: id,
  3844. RecordTime: recordDateTime,
  3845. Stage: 4,
  3846. }
  3847. service.CreateErrMsgLog(errlog)
  3848. c.ServeSuccessJSON(map[string]interface{}{
  3849. "failed_code": -10,
  3850. "msg": res.ErrMsg,
  3851. })
  3852. return
  3853. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3854. //return
  3855. }
  3856. }
  3857. }
  3858. } else if tempOrder.ID > 0 {
  3859. if tempOrder.IsPre == 1 {
  3860. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3861. var rf []*ResultFive
  3862. json.Unmarshal([]byte(his.Iinfo), &rf)
  3863. chrg_bchno := tempOrder.Number
  3864. cert_no := his.Certno
  3865. var insutypes []string
  3866. var insutype string
  3867. var is390 int = 0
  3868. var is310 int = 0
  3869. for _, item := range rf {
  3870. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3871. insutypes = append(insutypes, item.Insutype)
  3872. }
  3873. }
  3874. if len(insutypes) == 1 {
  3875. insutype = insutypes[0]
  3876. } else {
  3877. for _, i := range insutypes {
  3878. if i == "390" {
  3879. is390 = 1
  3880. }
  3881. if i == "310" {
  3882. is310 = 1
  3883. }
  3884. }
  3885. }
  3886. if is390 == 1 {
  3887. insutype = "390"
  3888. }
  3889. if is310 == 1 {
  3890. insutype = "310"
  3891. }
  3892. if len(insutypes) == 0 {
  3893. insutype = "310"
  3894. }
  3895. if len(insutypes) == 2 {
  3896. insutype = strconv.FormatInt(his.SocialType, 64)
  3897. }
  3898. //insutype = "390"
  3899. if his.IdCardType == 1 {
  3900. // cert_no = his.MedicalInsuranceNumber
  3901. cert_no = his.Certno
  3902. } else {
  3903. cert_no = his.Certno
  3904. }
  3905. var res ResultSeven
  3906. var resSeven10265 ResultSeven10265
  3907. var src_resquest string
  3908. var result2 string
  3909. var acct_used_flag string
  3910. fmt.Println("pay_way")
  3911. fmt.Println(pay_way)
  3912. fmt.Println("pay_way")
  3913. if pay_way == 4 {
  3914. acct_used_flag = "1"
  3915. } else {
  3916. acct_used_flag = "0"
  3917. }
  3918. if miConfig.MdtrtareaAdmvs == "421300" {
  3919. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3920. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3921. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3922. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3923. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3924. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3925. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3926. resp, requestErr := http.Get(api)
  3927. if requestErr != nil {
  3928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3929. return
  3930. }
  3931. body, ioErr := ioutil.ReadAll(resp.Body)
  3932. if ioErr != nil {
  3933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3935. return
  3936. }
  3937. var respJSON map[string]interface{}
  3938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3941. return
  3942. }
  3943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3944. result, _ := json.Marshal(respJSON)
  3945. fmt.Println("log")
  3946. fmt.Println(string(result))
  3947. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3948. utils.ErrorLog("解析失败:%v", err)
  3949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3950. return
  3951. }
  3952. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3953. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3954. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3955. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3956. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3957. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3958. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3959. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  3960. resp, requestErr := http.Get(api)
  3961. if requestErr != nil {
  3962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. return
  3964. }
  3965. body, ioErr := ioutil.ReadAll(resp.Body)
  3966. if ioErr != nil {
  3967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3969. return
  3970. }
  3971. var respJSON map[string]interface{}
  3972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3975. return
  3976. }
  3977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3978. result, _ := json.Marshal(respJSON)
  3979. fmt.Println("log")
  3980. fmt.Println(string(result))
  3981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3982. utils.ErrorLog("解析失败:%v", err)
  3983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3984. return
  3985. }
  3986. } else {
  3987. var src_resquest string
  3988. if miConfig.Code == "H15049901371" {
  3989. //赤峰地区国家医保医疗类别
  3990. //职工透析:医疗类别选特殊情况门诊990502
  3991. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3992. var med_type string
  3993. if his.Insutype == "390" {
  3994. if reg_type == 14 {
  3995. med_type = "9933"
  3996. } else if reg_type == 11 {
  3997. med_type = "11"
  3998. }
  3999. } else if his.Insutype == "310" {
  4000. if reg_type == 14 {
  4001. med_type = "990502"
  4002. } else if reg_type == 11 {
  4003. med_type = "11"
  4004. }
  4005. }
  4006. 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)
  4007. } else {
  4008. 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4009. }
  4010. var dat map[string]interface{}
  4011. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4012. fmt.Println(dat)
  4013. } else {
  4014. fmt.Println(err)
  4015. }
  4016. saveLog(result2, src_resquest, "2207", "结算")
  4017. userJSONBytes, _ := json.Marshal(dat)
  4018. if miConfig.Code == "H15049901371" {
  4019. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4020. utils.ErrorLog("解析失败:%v", err)
  4021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4022. return
  4023. }
  4024. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4025. res.Output = resSeven10265.Output
  4026. res.ErrMsg = resSeven10265.ErrMsg
  4027. res.Cainfo = resSeven10265.Cainfo
  4028. res.WarnMsg = resSeven10265.WarnMsg
  4029. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4030. res.Infcode = infocode
  4031. } else {
  4032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4033. utils.ErrorLog("解析失败:%v", err)
  4034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4035. return
  4036. }
  4037. }
  4038. }
  4039. if res.Infcode != 0 {
  4040. errlog := &models.HisOrderError{
  4041. UserOrgId: adminUser.CurrentOrgId,
  4042. Ctime: time.Now().Unix(),
  4043. Mtime: time.Now().Unix(),
  4044. Number: chrg_bchno,
  4045. ErrMsg: res.ErrMsg,
  4046. Status: 1,
  4047. PatientId: id,
  4048. RecordTime: recordDateTime,
  4049. Stage: 6,
  4050. }
  4051. service.CreateErrMsgLog(errlog)
  4052. c.ServeSuccessJSON(map[string]interface{}{
  4053. "failed_code": -10,
  4054. "msg": res.ErrMsg,
  4055. })
  4056. return
  4057. } else {
  4058. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4059. order.OrderStatus = 2
  4060. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4061. order.SetlId = res.Output.Setlinfo.SetlID
  4062. order.PsnNo = res.Output.Setlinfo.PsnNo
  4063. order.PsnName = res.Output.Setlinfo.PsnName
  4064. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4065. order.Certno = res.Output.Setlinfo.Certno
  4066. order.Gend = res.Output.Setlinfo.Gend
  4067. order.Naty = res.Output.Setlinfo.Naty
  4068. order.Age = res.Output.Setlinfo.Age
  4069. order.Insutype = res.Output.Setlinfo.Insutype
  4070. order.PsnType = res.Output.Setlinfo.PsnType
  4071. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4072. order.SetlTime = res.Output.Setlinfo.SetlTime
  4073. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4074. //order.MedType = res.Output.Setlinfo.MedType
  4075. if reg_type == 1112 {
  4076. order.MedType = "1112"
  4077. }
  4078. if reg_type == 1111 {
  4079. order.MedType = "1111"
  4080. }
  4081. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4082. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4083. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4084. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4085. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4086. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4087. order.HifpPay = res.Output.Setlinfo.HifpPay
  4088. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4089. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4090. order.HifesPay = res.Output.Setlinfo.HifesPay
  4091. order.HifobPay = res.Output.Setlinfo.HifobPay
  4092. order.MafPay = res.Output.Setlinfo.MafPay
  4093. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4094. order.OthPay = res.Output.Setlinfo.OthPay
  4095. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4096. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4097. order.AcctPay = res.Output.Setlinfo.AcctPay
  4098. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4099. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4100. order.Balc = res.Output.Setlinfo.Balc
  4101. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4102. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4103. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4104. order.ClrWay = res.Output.Setlinfo.ClrWay
  4105. order.Creator = order.Creator
  4106. order.Modify = roles.AdminUserId
  4107. order.RequestLog = src_resquest
  4108. order.Diagnosis = diagnosis_id
  4109. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4110. detailStr := string(setlDetail)
  4111. order.SetlDetail = detailStr
  4112. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4113. err = service.UpDateOrder(order)
  4114. if err == nil {
  4115. c.ServeSuccessJSON(map[string]interface{}{
  4116. "msg": "结算成功",
  4117. })
  4118. } else {
  4119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4120. return
  4121. }
  4122. }
  4123. }
  4124. }
  4125. }
  4126. //func (c *HisApiController) GetPreUploadInfo() {
  4127. // id, _ := c.GetInt64("id")
  4128. // record_time := c.GetString("record_time")
  4129. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4130. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4131. //
  4132. // timeLayout := "2006-01-02"
  4133. // loc, _ := time.LoadLocation("Local")
  4134. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4135. // if err != nil {
  4136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4137. // return
  4138. // }
  4139. // recordDateTime := theTime.Unix()
  4140. // adminUser := c.GetAdminUserInfo()
  4141. //
  4142. // var prescriptions []*models.HisPrescription
  4143. //
  4144. // var start_time int64
  4145. // var end_time int64
  4146. //
  4147. // data := make(map[string]interface{})
  4148. // if settle_accounts_type == 1 { //日结
  4149. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4150. // data["pre"] = prescriptions
  4151. //
  4152. // } else { //月结
  4153. // start_time_str := c.GetString("start_time")
  4154. // end_time_str := c.GetString("end_time")
  4155. // timeLayout := "2006-01-02"
  4156. // loc, _ := time.LoadLocation("Local")
  4157. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4158. // if err != nil {
  4159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4160. // return
  4161. // }
  4162. // recordStartTime := theStartTime.Unix()
  4163. // start_time = recordStartTime
  4164. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4165. // if err != nil {
  4166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4167. // return
  4168. // }
  4169. // recordEndTime := theEndTime.Unix()
  4170. // end_time = recordEndTime
  4171. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4172. // data["pre"] = prescriptions
  4173. //
  4174. // }
  4175. //
  4176. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4177. //
  4178. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4179. // timestamp := time.Now().Unix()
  4180. // tempTime := time.Unix(timestamp, 0)
  4181. // timeFormat := tempTime.Format("20060102150405")
  4182. // chrgBchno := rand.Intn(100000) + 10000
  4183. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4184. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4185. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4186. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4187. // strconv.FormatInt(his.PatientId, 10)
  4188. // client := &http.Client{}
  4189. // data["psn_no"] = his.PsnNo
  4190. // data["mdtrt_id"] = his.Number
  4191. // data["chrg_bchno"] = chrg_bchno
  4192. // data["org_name"] = miConfig.OrgName
  4193. // data["doctor"] = roles.UserName
  4194. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4195. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4196. // data["fixmedins_code"] = miConfig.Code
  4197. // data["dept_code"] = department.Number
  4198. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4199. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4200. // data["secret_key"] = miConfig.SecretKey
  4201. // var ids []int64
  4202. //
  4203. // for _, item := range prescriptions {
  4204. // ids = append(ids, item.ID)
  4205. // }
  4206. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4207. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4208. // bytesData, _ := json.Marshal(data)
  4209. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4210. // resp, _ := client.Do(req)
  4211. // defer resp.Body.Close()
  4212. // body, ioErr := ioutil.ReadAll(resp.Body)
  4213. // if ioErr != nil {
  4214. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4216. // return
  4217. // }
  4218. // var respJSON map[string]interface{}
  4219. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4220. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4222. // return
  4223. // }
  4224. //
  4225. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4226. // userJSONBytes, _ := json.Marshal(respJSON)
  4227. // var res ResultFour
  4228. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4229. // utils.ErrorLog("解析失败:%v", err)
  4230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4231. // return
  4232. // }
  4233. //
  4234. // if res.Infcode == 0 {
  4235. // order := &models.HisOrder{
  4236. // UserOrgId: adminUser.CurrentOrgId,
  4237. // HisPatientId: his.ID,
  4238. // PatientId: his.PatientId,
  4239. // SettleAccountsDate: recordDateTime,
  4240. // Ctime: time.Now().Unix(),
  4241. // Mtime: time.Now().Unix(),
  4242. // Status: 1,
  4243. // Number: chrg_bchno,
  4244. // Infcode: res.Infcode,
  4245. // WarnMsg: res.WarnMsg,
  4246. // Cainfo: res.Cainfo,
  4247. // ErrMsg: res.ErrMsg,
  4248. // RespondTime: res.RefmsgTime,
  4249. // InfRefmsgid: res.InfRefmsgid,
  4250. // OrderStatus: 1,
  4251. // IsMedicineInsurance: 1,
  4252. // SettleType: settle_accounts_type,
  4253. // SettleStartTime: start_time,
  4254. // SettleEndTime: end_time,
  4255. // Creator: roles.ID,
  4256. // Modify: roles.ID,
  4257. // PType: 2,
  4258. // }
  4259. // err = service.CreateOrder(order)
  4260. // if err != nil {
  4261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4262. // return
  4263. // }
  4264. //
  4265. // for _, item := range res.Output.Result {
  4266. // temp := strings.Split(item.FeedetlSn, "-")
  4267. // var advice_id int64 = 0
  4268. // var project_id int64 = 0
  4269. // var types int64 = 0
  4270. //
  4271. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4272. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4273. //
  4274. // if temp[1] == "1" {
  4275. // advice_id = id
  4276. // project_id = 0
  4277. // } else if temp[1] == "2" {
  4278. // advice_id = 0
  4279. // project_id = id
  4280. // }
  4281. //
  4282. // info := &models.HisOrderInfo{
  4283. // OrderNumber: order.Number,
  4284. // FeedetlSn: item.FeedetlSn,
  4285. // UploadDate: time.Now().Unix(),
  4286. // AdviceId: advice_id,
  4287. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4288. // Cnt: item.Cnt,
  4289. // Pric: float64(item.Pric),
  4290. // PatientId: his.PatientId,
  4291. // PricUplmtAmt: item.PricUplmtAmt,
  4292. // SelfpayProp: item.SelfpayProp,
  4293. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4294. // OverlmtAmt: item.OverlmtAmt,
  4295. // PreselfpayAmt: item.PreselfpayAmt,
  4296. // BasMednFlag: item.BasMednFlag,
  4297. // MedChrgitmType: item.MedChrgitmType,
  4298. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4299. // Status: 1,
  4300. // Memo: item.Memo,
  4301. // Mtime: time.Now().Unix(),
  4302. // InscpScpAmt: item.InscpScpAmt,
  4303. // DrtReimFlag: item.DrtReimFlag,
  4304. // Ctime: time.Now().Unix(),
  4305. // ListSpItemFlag: item.ListSpItemFlag,
  4306. // ChldMedcFlag: item.ChldMedcFlag,
  4307. // LmtUsedFlag: item.LmtUsedFlag,
  4308. // ChrgitmLv: item.ChrgitmLv,
  4309. // UserOrgId: adminUser.CurrentOrgId,
  4310. // HisPatientId: his.ID,
  4311. // OrderId: order.ID,
  4312. // ProjectId: project_id,
  4313. // Type: types,
  4314. // }
  4315. // service.CreateOrderInfo(info)
  4316. //
  4317. // }
  4318. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4319. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4320. //
  4321. // var total float64
  4322. // for _, item := range prescriptions {
  4323. // if item.Type == 1 { //药品
  4324. // for _, subItem := range item.HisDoctorAdviceInfo {
  4325. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4326. // }
  4327. // }
  4328. // if item.Type == 2 { //项目
  4329. // for _, subItem := range item.HisPrescriptionProject {
  4330. // total = total + (subItem.Price * float64(subItem.Count))
  4331. // }
  4332. // }
  4333. // }
  4334. //
  4335. // for _, item := range prescriptions {
  4336. // for _, subItem := range item.HisAdditionalCharge {
  4337. // total = total + (subItem.Price * float64(subItem.Count))
  4338. // }
  4339. // }
  4340. //
  4341. // allTotal := fmt.Sprintf("%.2f", total)
  4342. // if res.Infcode == 0 {
  4343. // var rf []*ResultFive
  4344. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4345. // psn_no := his.PsnNo
  4346. // mdtrt_id := his.Number
  4347. // chrg_bchno := chrg_bchno
  4348. // cert_no := his.Certno
  4349. // insutype := rf[0].Insutype
  4350. //
  4351. // if his.IdCardType == 1 {
  4352. // cert_no = his.MedicalInsuranceNumber
  4353. //
  4354. // } else {
  4355. //
  4356. // cert_no = his.Certno
  4357. //
  4358. // }
  4359. //
  4360. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4361. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4362. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4363. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4364. // resp, requestErr := http.Get(api)
  4365. // if requestErr != nil {
  4366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. // return
  4368. // }
  4369. // defer resp.Body.Close()
  4370. // body, ioErr := ioutil.ReadAll(resp.Body)
  4371. // if ioErr != nil {
  4372. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4374. // return
  4375. // }
  4376. // var respJSON map[string]interface{}
  4377. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4380. // return
  4381. // }
  4382. // fmt.Println(respJSON)
  4383. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4384. // userJSONBytes, _ := json.Marshal(respJSON)
  4385. // var res ResultSeven
  4386. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4387. // utils.ErrorLog("解析失败:%v", err)
  4388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4389. // return
  4390. // }
  4391. // if res.Infcode != 0 {
  4392. // errlog := &models.HisOrderError{
  4393. // UserOrgId: adminUser.CurrentOrgId,
  4394. // Ctime: time.Now().Unix(),
  4395. // Mtime: time.Now().Unix(),
  4396. // Number: chrg_bchno,
  4397. // ErrMsg: res.ErrMsg,
  4398. // Status: 1,
  4399. // PatientId: id,
  4400. // RecordTime: recordDateTime,
  4401. // Stage: 7,
  4402. // }
  4403. // service.CreateErrMsgLog(errlog)
  4404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4405. // return
  4406. // } else {
  4407. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4408. // order.OrderStatus = 1
  4409. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4410. // order.SetlId = res.Output.Setlinfo.SetlID
  4411. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4412. // order.PsnName = res.Output.Setlinfo.PsnName
  4413. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4414. // order.Certno = res.Output.Setlinfo.Certno
  4415. // order.Gend = res.Output.Setlinfo.Gend
  4416. // order.Naty = res.Output.Setlinfo.Naty
  4417. // order.Age = res.Output.Setlinfo.Age
  4418. // order.Insutype = res.Output.Setlinfo.Insutype
  4419. // order.PsnType = res.Output.Setlinfo.PsnType
  4420. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4421. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4422. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4423. // order.MedType = res.Output.Setlinfo.MedType
  4424. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4425. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4426. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4427. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4428. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4429. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4430. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4431. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4432. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4433. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4434. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4435. // order.MafPay = res.Output.Setlinfo.MafPay
  4436. // order.OthPay = res.Output.Setlinfo.OthPay
  4437. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4438. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4439. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4440. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4441. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4442. // order.Balc = res.Output.Setlinfo.Balc
  4443. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4444. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4445. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4446. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4447. // order.Creator = order.Creator
  4448. // order.Modify = roles.ID
  4449. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4450. // detailStr := string(setlDetail)
  4451. // order.SetlDetail = detailStr
  4452. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4453. // err = service.UpDateOrder(order)
  4454. // if err == nil {
  4455. // c.ServeSuccessJSON(map[string]interface{}{
  4456. // "msg": "预结算成功",
  4457. // })
  4458. // } else {
  4459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4460. // return
  4461. // }
  4462. // }
  4463. // } else {
  4464. // adminUser := c.GetAdminUserInfo()
  4465. // errlog := &models.HisOrderError{
  4466. // UserOrgId: adminUser.CurrentOrgId,
  4467. // Ctime: time.Now().Unix(),
  4468. // Mtime: time.Now().Unix(),
  4469. // ErrMsg: res.ErrMsg,
  4470. // Status: 1,
  4471. // PatientId: id,
  4472. // RecordTime: recordDateTime,
  4473. // Stage: 4,
  4474. // }
  4475. // service.CreateErrMsgLog(errlog)
  4476. //
  4477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4478. // return
  4479. // }
  4480. // } else {
  4481. // adminUser := c.GetAdminUserInfo()
  4482. // errlog := &models.HisOrderError{
  4483. // UserOrgId: adminUser.CurrentOrgId,
  4484. // Ctime: time.Now().Unix(),
  4485. // Mtime: time.Now().Unix(),
  4486. // ErrMsg: res.ErrMsg,
  4487. // Status: 1,
  4488. // PatientId: id,
  4489. // RecordTime: recordDateTime,
  4490. // Stage: 4,
  4491. // }
  4492. // service.CreateErrMsgLog(errlog)
  4493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4494. // return
  4495. // }
  4496. //
  4497. // } else {
  4498. // var total float64
  4499. // for _, item := range prescriptions {
  4500. // if item.Type == 1 { //药品
  4501. // for _, subItem := range item.HisDoctorAdviceInfo {
  4502. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4503. // }
  4504. // }
  4505. // if item.Type == 2 { //项目
  4506. // for _, subItem := range item.HisPrescriptionProject {
  4507. // total = total + (subItem.Price * float64(subItem.Count))
  4508. // }
  4509. // }
  4510. //
  4511. // for _, subItem := range item.HisAdditionalCharge {
  4512. // total = total + (subItem.Price * float64(subItem.Count))
  4513. // }
  4514. // }
  4515. //
  4516. // allTotal := fmt.Sprintf("%.2f", total)
  4517. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4518. // order := &models.HisOrder{
  4519. // UserOrgId: adminUser.CurrentOrgId,
  4520. // HisPatientId: his.ID,
  4521. // PatientId: id,
  4522. // SettleAccountsDate: recordDateTime,
  4523. // Ctime: time.Now().Unix(),
  4524. // Mtime: time.Now().Unix(),
  4525. // Status: 1,
  4526. // OrderStatus: 2,
  4527. // Number: chrg_bchno,
  4528. // MedfeeSumamt: totals,
  4529. // }
  4530. // err = service.CreateOrder(order)
  4531. // if err != nil {
  4532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4533. // return
  4534. // }
  4535. //
  4536. // var customs []*Custom
  4537. // for _, item := range prescriptions {
  4538. //
  4539. // if item.Type == 1 { //药品
  4540. // for _, subItem := range item.HisDoctorAdviceInfo {
  4541. // cus := &Custom{
  4542. // AdviceId: subItem.ID,
  4543. // ProjectId: 0,
  4544. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4545. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4546. // FeedetlSn: subItem.FeedetlSn,
  4547. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4548. // MedListCodg: subItem.MedListCodg,
  4549. // Type: 1,
  4550. // }
  4551. // customs = append(customs, cus)
  4552. // }
  4553. // }
  4554. //
  4555. // if item.Type == 2 { //项目
  4556. // for _, subItem := range item.HisPrescriptionProject {
  4557. //
  4558. // cus := &Custom{
  4559. // AdviceId: 0,
  4560. // ProjectId: subItem.ID,
  4561. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4562. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4563. // FeedetlSn: subItem.FeedetlSn,
  4564. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4565. // MedListCodg: subItem.MedListCodg,
  4566. // Type: 2,
  4567. // }
  4568. //
  4569. // customs = append(customs, cus)
  4570. // }
  4571. // }
  4572. //
  4573. // for _, item := range item.HisAdditionalCharge {
  4574. // cus := &Custom{
  4575. // ItemId: item.ID,
  4576. // AdviceId: 0,
  4577. // ProjectId: 0,
  4578. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4579. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4580. // FeedetlSn: item.FeedetlSn,
  4581. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4582. // MedListCodg: item.XtHisAddtionConfig.Code,
  4583. // Type: 3,
  4584. // }
  4585. //
  4586. // customs = append(customs, cus)
  4587. // }
  4588. //
  4589. // }
  4590. //
  4591. // for _, item := range customs {
  4592. // var advice_id int64 = 0
  4593. // var project_id int64 = 0
  4594. // var item_id int64 = 0
  4595. //
  4596. // var types int64 = 0
  4597. //
  4598. // if item.Type == 1 {
  4599. // advice_id = item.AdviceId
  4600. // project_id = 0
  4601. // item_id = 0
  4602. // } else if item.Type == 2 {
  4603. // advice_id = 0
  4604. // item_id = 0
  4605. //
  4606. // project_id = item.ProjectId
  4607. // } else if item.Type == 3 {
  4608. // advice_id = 0
  4609. // item_id = item.ItemId
  4610. // project_id = 0
  4611. // }
  4612. //
  4613. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4614. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4615. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4616. //
  4617. // info := &models.HisOrderInfo{
  4618. // OrderNumber: order.Number,
  4619. // UploadDate: time.Now().Unix(),
  4620. // AdviceId: advice_id,
  4621. // DetItemFeeSumamt: detItemFeeSumamt,
  4622. // Cnt: cut,
  4623. // Pric: pric,
  4624. // PatientId: id,
  4625. // Status: 1,
  4626. // Mtime: time.Now().Unix(),
  4627. // Ctime: time.Now().Unix(),
  4628. // UserOrgId: adminUser.CurrentOrgId,
  4629. // HisPatientId: his.ID,
  4630. // OrderId: order.ID,
  4631. // ProjectId: project_id,
  4632. // Type: types,
  4633. // ItemId: item_id,
  4634. // }
  4635. // service.CreateOrderInfo(info)
  4636. // }
  4637. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4638. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4639. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4640. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4641. // if err == nil {
  4642. // c.ServeSuccessJSON(map[string]interface{}{
  4643. // "msg": "结算成功",
  4644. // })
  4645. // } else {
  4646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4647. // return
  4648. // }
  4649. // }
  4650. //}
  4651. //上传明细-预结算-
  4652. func (c *HisApiController) GetPreUploadInfo() {
  4653. id, _ := c.GetInt64("id")
  4654. record_time := c.GetString("record_time")
  4655. his_patient_id, _ := c.GetInt64("his_patient_id")
  4656. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4657. admin_user_id, _ := c.GetInt64("admin_user_id")
  4658. diagnosis_id := c.GetString("diagnosis")
  4659. sick_type, _ := c.GetInt64("sick_type")
  4660. reg_type, _ := c.GetInt64("p_type")
  4661. begin_time := c.GetString("begin_time")
  4662. id_str := c.GetString("ids")
  4663. ids_arr := strings.Split(id_str, ",")
  4664. timeLayout := "2006-01-02"
  4665. loc, _ := time.LoadLocation("Local")
  4666. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4667. if err != nil {
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4669. return
  4670. }
  4671. recordDateTime := theTime.Unix()
  4672. adminUser := c.GetAdminUserInfo()
  4673. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4674. var config []*models.HisXtDiagnoseConfig
  4675. for _, item := range diagnosis_ids {
  4676. id, _ := strconv.ParseInt(item, 10, 64)
  4677. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4678. config = append(config, &diagnosisConfig)
  4679. }
  4680. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4681. sickConfig, _ := service.FindSickById(sick_type)
  4682. var prescriptions []*models.HisPrescription
  4683. var start_time int64
  4684. var end_time int64
  4685. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4686. fmt.Println(his_patient_id)
  4687. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4688. timestamp := time.Now().Unix()
  4689. tempTime := time.Unix(timestamp, 0)
  4690. timeFormat := tempTime.Format("20060102150405")
  4691. chrgBchno := rand.Intn(100000) + 10000
  4692. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4694. var patientPrescription models.HisPrescriptionInfo
  4695. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4696. if patientPrescription.ID == 0 {
  4697. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4698. }
  4699. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4700. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4701. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4702. strconv.FormatInt(his.PatientId, 10)
  4703. var res2 ResultSix
  4704. var resSix10265 ResultSix10265
  4705. if miConfig.InsuplcAdmdvs == "421300" {
  4706. data := make(map[string]interface{})
  4707. client := &http.Client{}
  4708. data["psn_no"] = his.PsnNo
  4709. data["mdtrt_id"] = his.Number
  4710. data["doctor"] = roles.UserName
  4711. data["department"] = department.Name
  4712. data["org_name"] = miConfig.OrgName
  4713. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4714. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4715. data["fixmedins_code"] = miConfig.Code
  4716. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4717. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4718. data["secret_key"] = miConfig.SecretKey
  4719. data["sick_code"] = sickConfig.CountryCode
  4720. data["sick_name"] = sickConfig.ClassName
  4721. data["begin_time"] = begin_time
  4722. data["dept"] = strconv.FormatInt(department.ID, 10)
  4723. data["config"] = config
  4724. fmt.Println(data)
  4725. bytesData, _ := json.Marshal(data)
  4726. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4727. resp, _ := client.Do(req)
  4728. defer resp.Body.Close()
  4729. body, ioErr := ioutil.ReadAll(resp.Body)
  4730. if ioErr != nil {
  4731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. var respJSON map[string]interface{}
  4736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4739. return
  4740. }
  4741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4742. userJSONBytes, _ := json.Marshal(respJSON)
  4743. fmt.Println("log")
  4744. fmt.Println(string(userJSONBytes))
  4745. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4746. utils.ErrorLog("解析失败:%v", err)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. } else if miConfig.InsuplcAdmdvs == "320921" {
  4751. data := make(map[string]interface{})
  4752. client := &http.Client{}
  4753. data["psn_no"] = his.PsnNo
  4754. data["mdtrt_id"] = his.Number
  4755. data["doctor"] = roles.UserName
  4756. data["department"] = department.Name
  4757. data["org_name"] = miConfig.OrgName
  4758. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4759. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4760. data["fixmedins_code"] = miConfig.Code
  4761. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4762. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4763. data["secret_key"] = miConfig.SecretKey
  4764. data["sick_code"] = sickConfig.CountryCode
  4765. data["sick_name"] = sickConfig.ClassName
  4766. data["begin_time"] = begin_time
  4767. data["dept"] = strconv.FormatInt(department.ID, 10)
  4768. data["config"] = config
  4769. fmt.Println(data)
  4770. bytesData, _ := json.Marshal(data)
  4771. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4772. resp, _ := client.Do(req)
  4773. defer resp.Body.Close()
  4774. body, ioErr := ioutil.ReadAll(resp.Body)
  4775. if ioErr != nil {
  4776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4778. return
  4779. }
  4780. var respJSON map[string]interface{}
  4781. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4784. return
  4785. }
  4786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4787. userJSONBytes, _ := json.Marshal(respJSON)
  4788. fmt.Println("log")
  4789. fmt.Println(string(userJSONBytes))
  4790. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4791. utils.ErrorLog("解析失败:%v", err)
  4792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4793. return
  4794. }
  4795. } else {
  4796. var result string
  4797. var requestLog string
  4798. if miConfig.InsuplcAdmdvs == "440781" { //
  4799. 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)
  4800. } else {
  4801. if miConfig.Code == "H15049901371" {
  4802. //赤峰地区国家医保医疗类别
  4803. //职工透析:医疗类别选特殊情况门诊990502
  4804. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4805. var med_type string
  4806. if his.Insutype == "390" {
  4807. if reg_type == 14 {
  4808. med_type = "9933"
  4809. } else if reg_type == 11 {
  4810. med_type = "11"
  4811. }
  4812. } else if his.Insutype == "310" {
  4813. if reg_type == 14 {
  4814. med_type = "990502"
  4815. } else if reg_type == 11 {
  4816. med_type = "11"
  4817. }
  4818. }
  4819. 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)
  4820. } else {
  4821. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  4822. }
  4823. saveLog(result, requestLog, "2203", "上传就诊信息")
  4824. var respJSON2 map[string]interface{}
  4825. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4828. return
  4829. }
  4830. userJSONBytes2, _ := json.Marshal(respJSON2)
  4831. if miConfig.Code == "H15049901371" {
  4832. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4833. utils.ErrorLog("解析失败:%v", err)
  4834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4835. return
  4836. }
  4837. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4838. res2.Output = resSix10265.Output
  4839. res2.ErrMsg = resSix10265.ErrMsg
  4840. res2.Cainfo = resSix10265.Cainfo
  4841. res2.WarnMsg = resSix10265.WarnMsg
  4842. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4843. res2.Infcode = infocode
  4844. } else {
  4845. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4846. utils.ErrorLog("解析失败:%v", err)
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. }
  4851. }
  4852. }
  4853. if res2.Infcode != 0 {
  4854. adminUser := c.GetAdminUserInfo()
  4855. errlog := &models.HisOrderError{
  4856. UserOrgId: adminUser.CurrentOrgId,
  4857. Ctime: time.Now().Unix(),
  4858. Mtime: time.Now().Unix(),
  4859. ErrMsg: res2.ErrMsg,
  4860. Status: 1,
  4861. PatientId: id,
  4862. RecordTime: recordDateTime,
  4863. Stage: 3,
  4864. }
  4865. service.CreateErrMsgLog(errlog)
  4866. c.ServeSuccessJSON(map[string]interface{}{
  4867. "failed_code": -10,
  4868. "msg": res2.ErrMsg,
  4869. })
  4870. return
  4871. } else {
  4872. his.Diagnosis = diagnosis_id
  4873. his.SickType = sickConfig.ID
  4874. his.PType = fmt.Sprintf("%d", reg_type)
  4875. service.UpdateHisPatientThree(&his)
  4876. data := make(map[string]interface{})
  4877. if settle_accounts_type == 1 { //日结
  4878. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4879. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4880. } else {
  4881. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4882. }
  4883. data["pre"] = prescriptions
  4884. } else { //月结
  4885. start_time_str := c.GetString("start_time")
  4886. end_time_str := c.GetString("end_time")
  4887. timeLayout := "2006-01-02"
  4888. loc, _ := time.LoadLocation("Local")
  4889. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4890. if err != nil {
  4891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4892. return
  4893. }
  4894. recordStartTime := theStartTime.Unix()
  4895. start_time = recordStartTime
  4896. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4897. if err != nil {
  4898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4899. return
  4900. }
  4901. recordEndTime := theEndTime.Unix()
  4902. end_time = recordEndTime
  4903. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4904. data["pre"] = prescriptions
  4905. }
  4906. client := &http.Client{}
  4907. data["psn_no"] = his.PsnNo
  4908. data["mdtrt_id"] = his.Number
  4909. data["chrg_bchno"] = chrg_bchno
  4910. data["org_name"] = miConfig.OrgName
  4911. data["doctor"] = roles.UserName
  4912. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4913. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4914. data["fixmedins_code"] = miConfig.Code
  4915. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4916. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4917. data["dept_code"] = "15"
  4918. } else {
  4919. data["dept_code"] = department.Number
  4920. }
  4921. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4922. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4923. data["secret_key"] = miConfig.SecretKey
  4924. data["url"] = miConfig.Url
  4925. data["ak"] = miConfig.ChannelNumber
  4926. data["new_doctor_name"] = patientPrescription.Doctor
  4927. var ids []int64
  4928. for _, item := range prescriptions {
  4929. ids = append(ids, item.ID)
  4930. }
  4931. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4932. if config.IsOpen == 1 { //对接了医保,走医保流程
  4933. var res ResultFour
  4934. var resFour10265 ResultFour10265
  4935. if miConfig.MdtrtareaAdmvs == "421300" {
  4936. bytesData, _ := json.Marshal(data)
  4937. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4938. resp, _ := client.Do(req)
  4939. defer resp.Body.Close()
  4940. body, ioErr := ioutil.ReadAll(resp.Body)
  4941. if ioErr != nil {
  4942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4944. return
  4945. }
  4946. var respJSON map[string]interface{}
  4947. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4953. userJSONBytes, _ := json.Marshal(respJSON)
  4954. fmt.Println("log")
  4955. fmt.Println(string(userJSONBytes))
  4956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4957. utils.ErrorLog("解析失败:%v", err)
  4958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4959. return
  4960. }
  4961. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4962. bytesData, _ := json.Marshal(data)
  4963. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4964. resp, _ := client.Do(req)
  4965. defer resp.Body.Close()
  4966. body, ioErr := ioutil.ReadAll(resp.Body)
  4967. if ioErr != nil {
  4968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4970. return
  4971. }
  4972. var respJSON map[string]interface{}
  4973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4976. return
  4977. }
  4978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4979. userJSONBytes, _ := json.Marshal(respJSON)
  4980. fmt.Println("log")
  4981. fmt.Println(string(userJSONBytes))
  4982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4983. utils.ErrorLog("解析失败:%v", err)
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. } else {
  4988. if miConfig.Code == "H15049901371" {
  4989. 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)
  4990. var dat map[string]interface{}
  4991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4992. fmt.Println(dat)
  4993. } else {
  4994. fmt.Println(err)
  4995. }
  4996. saveLog(result, request_log, "2204", "上传费用明细")
  4997. userJSONBytes, _ := json.Marshal(dat)
  4998. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4999. utils.ErrorLog("解析失败:%v", err)
  5000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5001. return
  5002. }
  5003. res.InfRefmsgid = resFour10265.InfRefmsgid
  5004. res.Output = resFour10265.Output
  5005. res.ErrMsg = resFour10265.ErrMsg
  5006. res.Cainfo = resFour10265.Cainfo
  5007. res.WarnMsg = resFour10265.WarnMsg
  5008. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5009. res.Infcode = infocode
  5010. } else {
  5011. 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)
  5012. var dat map[string]interface{}
  5013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5014. fmt.Println(dat)
  5015. } else {
  5016. fmt.Println(err)
  5017. }
  5018. saveLog(result, request_log, "2204", "上传费用明细")
  5019. userJSONBytes, _ := json.Marshal(dat)
  5020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5021. utils.ErrorLog("解析失败:%v", err)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5023. return
  5024. }
  5025. }
  5026. }
  5027. if res.Infcode == 0 {
  5028. order := &models.HisOrder{
  5029. UserOrgId: adminUser.CurrentOrgId,
  5030. HisPatientId: his.ID,
  5031. PatientId: his.PatientId,
  5032. SettleAccountsDate: recordDateTime,
  5033. Ctime: time.Now().Unix(),
  5034. Mtime: time.Now().Unix(),
  5035. Status: 1,
  5036. Number: chrg_bchno,
  5037. Infcode: res.Infcode,
  5038. WarnMsg: res.WarnMsg,
  5039. Cainfo: res.Cainfo,
  5040. ErrMsg: res.ErrMsg,
  5041. RespondTime: res.RefmsgTime,
  5042. InfRefmsgid: res.InfRefmsgid,
  5043. OrderStatus: 1,
  5044. IsMedicineInsurance: 1,
  5045. SettleType: settle_accounts_type,
  5046. SettleStartTime: start_time,
  5047. SettleEndTime: end_time,
  5048. Creator: roles.AdminUserId,
  5049. Modify: roles.AdminUserId,
  5050. PType: 2,
  5051. Diagnosis: diagnosis_id,
  5052. }
  5053. err = service.CreateOrder(order)
  5054. if err != nil {
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5056. return
  5057. }
  5058. for _, item := range res.Output.Result {
  5059. temp := strings.Split(item.FeedetlSn, "-")
  5060. var advice_id int64 = 0
  5061. var project_id int64 = 0
  5062. var types int64 = 0
  5063. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5064. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5065. if temp[1] == "1" {
  5066. advice_id = id
  5067. project_id = 0
  5068. } else if temp[1] == "2" {
  5069. advice_id = 0
  5070. project_id = id
  5071. }
  5072. info := &models.HisOrderInfo{
  5073. OrderNumber: order.Number,
  5074. FeedetlSn: item.FeedetlSn,
  5075. UploadDate: time.Now().Unix(),
  5076. AdviceId: advice_id,
  5077. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5078. Cnt: item.Cnt,
  5079. Pric: float64(item.Pric),
  5080. PatientId: his.PatientId,
  5081. PricUplmtAmt: item.PricUplmtAmt,
  5082. SelfpayProp: item.SelfpayProp,
  5083. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5084. OverlmtAmt: item.OverlmtAmt,
  5085. PreselfpayAmt: item.PreselfpayAmt,
  5086. BasMednFlag: item.BasMednFlag,
  5087. MedChrgitmType: item.MedChrgitmType,
  5088. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5089. Status: 1,
  5090. Memo: item.Memo,
  5091. Mtime: time.Now().Unix(),
  5092. InscpScpAmt: item.InscpScpAmt,
  5093. DrtReimFlag: item.DrtReimFlag,
  5094. Ctime: time.Now().Unix(),
  5095. ListSpItemFlag: item.ListSpItemFlag,
  5096. ChldMedcFlag: item.ChldMedcFlag,
  5097. LmtUsedFlag: item.LmtUsedFlag,
  5098. ChrgitmLv: item.ChrgitmLv,
  5099. UserOrgId: adminUser.CurrentOrgId,
  5100. HisPatientId: his.ID,
  5101. OrderId: order.ID,
  5102. ProjectId: project_id,
  5103. Type: types,
  5104. }
  5105. service.CreateOrderInfo(info)
  5106. }
  5107. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5108. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5109. var total float64
  5110. for _, item := range prescriptions {
  5111. if item.Type == 1 { //药品
  5112. for _, subItem := range item.HisDoctorAdviceInfo {
  5113. total = total + (subItem.Price * subItem.PrescribingNumber)
  5114. }
  5115. }
  5116. if item.Type == 2 { //项目
  5117. for _, subItem := range item.HisPrescriptionProject {
  5118. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5119. total = total + (subItem.Price * cnt)
  5120. }
  5121. }
  5122. }
  5123. for _, item := range prescriptions {
  5124. for _, subItem := range item.HisAdditionalCharge {
  5125. total = total + (subItem.Price * float64(subItem.Count))
  5126. }
  5127. }
  5128. allTotal := fmt.Sprintf("%.4f", total)
  5129. if res.Infcode == 0 {
  5130. var rf []*ResultFive
  5131. json.Unmarshal([]byte(his.Iinfo), &rf)
  5132. chrg_bchno := chrg_bchno
  5133. cert_no := his.Certno
  5134. var insutypes []string
  5135. var insutype string
  5136. var is390 int = 0
  5137. var is310 int = 0
  5138. for _, item := range rf {
  5139. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5140. insutypes = append(insutypes, item.Insutype)
  5141. }
  5142. }
  5143. if len(insutypes) == 1 {
  5144. insutype = insutypes[0]
  5145. } else {
  5146. for _, i := range insutypes {
  5147. if i == "390" {
  5148. is390 = 1
  5149. }
  5150. if i == "310" {
  5151. is310 = 1
  5152. }
  5153. }
  5154. }
  5155. if is390 == 1 {
  5156. insutype = "390"
  5157. }
  5158. if is310 == 1 {
  5159. insutype = "310"
  5160. }
  5161. if len(insutypes) == 0 {
  5162. insutype = "310"
  5163. }
  5164. if len(insutypes) == 2 {
  5165. insutype = strconv.FormatInt(his.SocialType, 64)
  5166. }
  5167. //insutype = "390"
  5168. if his.IdCardType == 1 {
  5169. cert_no = his.MedicalInsuranceNumber
  5170. } else {
  5171. cert_no = his.Certno
  5172. }
  5173. var res ResultSeven
  5174. var resSeven10265 ResultSeven10265
  5175. if miConfig.MdtrtareaAdmvs == "421300" {
  5176. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5177. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5178. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5179. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5180. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5181. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5182. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5183. resp, requestErr := http.Get(api)
  5184. if requestErr != nil {
  5185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5186. return
  5187. }
  5188. body, ioErr := ioutil.ReadAll(resp.Body)
  5189. if ioErr != nil {
  5190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. return
  5193. }
  5194. var respJSON map[string]interface{}
  5195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. return
  5199. }
  5200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5201. result, _ := json.Marshal(respJSON)
  5202. fmt.Println("log")
  5203. fmt.Println(string(result))
  5204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5205. utils.ErrorLog("解析失败:%v", err)
  5206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5207. return
  5208. }
  5209. } else {
  5210. var result string
  5211. var request_log string
  5212. if miConfig.Code == "H15049901371" {
  5213. //赤峰地区国家医保医疗类别
  5214. //职工透析:医疗类别选特殊情况门诊990502
  5215. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5216. var med_type string
  5217. if his.Insutype == "390" {
  5218. if reg_type == 14 {
  5219. med_type = "9933"
  5220. } else if reg_type == 11 {
  5221. med_type = "11"
  5222. }
  5223. } else if his.Insutype == "310" {
  5224. if reg_type == 14 {
  5225. med_type = "990502"
  5226. } else if reg_type == 11 {
  5227. med_type = "11"
  5228. }
  5229. }
  5230. 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)
  5231. } else {
  5232. result, request_log = service.Gdyb2206(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)
  5233. }
  5234. var dat map[string]interface{}
  5235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5236. fmt.Println(dat)
  5237. } else {
  5238. fmt.Println(err)
  5239. }
  5240. saveLog(result, request_log, "2206", "预结算")
  5241. //userJSONBytes, _ := json.Marshal(dat)
  5242. //
  5243. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5244. // utils.ErrorLog("解析失败:%v", err)
  5245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5246. // return
  5247. //}
  5248. userJSONBytes, _ := json.Marshal(dat)
  5249. if miConfig.Code == "H15049901371" {
  5250. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5251. utils.ErrorLog("解析失败:%v", err)
  5252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5253. return
  5254. }
  5255. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5256. res.Output = resSeven10265.Output
  5257. res.ErrMsg = resSeven10265.ErrMsg
  5258. res.Cainfo = resSeven10265.Cainfo
  5259. res.WarnMsg = resSeven10265.WarnMsg
  5260. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5261. res.Infcode = infocode
  5262. } else {
  5263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5264. utils.ErrorLog("解析失败:%v", err)
  5265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5266. return
  5267. }
  5268. }
  5269. }
  5270. if res.Infcode != 0 {
  5271. errlog := &models.HisOrderError{
  5272. UserOrgId: adminUser.CurrentOrgId,
  5273. Ctime: time.Now().Unix(),
  5274. Mtime: time.Now().Unix(),
  5275. Number: chrg_bchno,
  5276. ErrMsg: res.ErrMsg,
  5277. Status: 1,
  5278. PatientId: id,
  5279. RecordTime: recordDateTime,
  5280. Stage: 20,
  5281. }
  5282. service.CreateErrMsgLog(errlog)
  5283. c.ServeSuccessJSON(map[string]interface{}{
  5284. "failed_code": -10,
  5285. "msg": res.ErrMsg,
  5286. })
  5287. return
  5288. } else {
  5289. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5290. order.OrderStatus = 1
  5291. order.IsPre = 1
  5292. order.Status = 1
  5293. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5294. order.SetlId = res.Output.Setlinfo.SetlID
  5295. order.PsnNo = res.Output.Setlinfo.PsnNo
  5296. order.PsnName = res.Output.Setlinfo.PsnName
  5297. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5298. order.Certno = res.Output.Setlinfo.Certno
  5299. order.Gend = res.Output.Setlinfo.Gend
  5300. order.Naty = res.Output.Setlinfo.Naty
  5301. order.Age = res.Output.Setlinfo.Age
  5302. order.Insutype = res.Output.Setlinfo.Insutype
  5303. order.PsnType = res.Output.Setlinfo.PsnType
  5304. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5305. order.SetlTime = res.Output.Setlinfo.SetlTime
  5306. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5307. if res.Output.Setlinfo.MedType == "140101" {
  5308. order.MedType = "14"
  5309. } else {
  5310. order.MedType = res.Output.Setlinfo.MedType
  5311. }
  5312. if reg_type == 1112 {
  5313. order.MedType = "1112"
  5314. }
  5315. if reg_type == 1111 {
  5316. order.MedType = "1111"
  5317. }
  5318. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5319. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5320. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5321. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5322. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5323. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5324. order.HifpPay = res.Output.Setlinfo.HifpPay
  5325. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5326. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5327. order.HifesPay = res.Output.Setlinfo.HifesPay
  5328. order.HifobPay = res.Output.Setlinfo.HifobPay
  5329. order.MafPay = res.Output.Setlinfo.MafPay
  5330. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5331. order.OthPay = res.Output.Setlinfo.OthPay
  5332. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5333. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5334. order.AcctPay = res.Output.Setlinfo.AcctPay
  5335. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5336. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5337. order.Balc = res.Output.Setlinfo.Balc
  5338. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5339. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5340. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5341. order.ClrWay = res.Output.Setlinfo.ClrWay
  5342. order.Creator = order.Creator
  5343. order.Modify = roles.AdminUserId
  5344. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5345. detailStr := string(setlDetail)
  5346. order.SetlDetail = detailStr
  5347. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5348. err = service.UpDateOrder(order)
  5349. if err == nil {
  5350. c.ServeSuccessJSON(map[string]interface{}{
  5351. "msg": "预结算成功",
  5352. })
  5353. } else {
  5354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5355. return
  5356. }
  5357. }
  5358. } else {
  5359. adminUser := c.GetAdminUserInfo()
  5360. errlog := &models.HisOrderError{
  5361. UserOrgId: adminUser.CurrentOrgId,
  5362. Ctime: time.Now().Unix(),
  5363. Mtime: time.Now().Unix(),
  5364. ErrMsg: res.ErrMsg,
  5365. Status: 1,
  5366. PatientId: id,
  5367. RecordTime: recordDateTime,
  5368. Stage: 4,
  5369. }
  5370. service.CreateErrMsgLog(errlog)
  5371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5372. return
  5373. }
  5374. } else {
  5375. adminUser := c.GetAdminUserInfo()
  5376. errlog := &models.HisOrderError{
  5377. UserOrgId: adminUser.CurrentOrgId,
  5378. Ctime: time.Now().Unix(),
  5379. Mtime: time.Now().Unix(),
  5380. ErrMsg: res.ErrMsg,
  5381. Status: 1,
  5382. PatientId: id,
  5383. RecordTime: recordDateTime,
  5384. Stage: 4,
  5385. }
  5386. service.CreateErrMsgLog(errlog)
  5387. c.ServeSuccessJSON(map[string]interface{}{
  5388. "failed_code": -10,
  5389. "msg": res.ErrMsg,
  5390. })
  5391. return
  5392. }
  5393. }
  5394. }
  5395. }
  5396. //func (c *HisApiController) GetSettleInfo() {
  5397. // id, _ := c.GetInt64("id")
  5398. // order_id, _ := c.GetInt64("order_id")
  5399. //
  5400. // record_time := c.GetString("record_time")
  5401. // pay_way, _ := c.GetInt64("pay_way")
  5402. // pay_price, _ := c.GetFloat("pay_price")
  5403. // pay_card_no := c.GetString("pay_card_no")
  5404. // discount_price, _ := c.GetFloat("discount_price")
  5405. // preferential_price, _ := c.GetFloat("preferential_price")
  5406. // reality_price, _ := c.GetFloat("reality_price")
  5407. // found_price, _ := c.GetFloat("found_price")
  5408. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5409. // private_price, _ := c.GetFloat("private_price")
  5410. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5411. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5412. //
  5413. // timeLayout := "2006-01-02"
  5414. // loc, _ := time.LoadLocation("Local")
  5415. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5416. // if err != nil {
  5417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5418. // return
  5419. // }
  5420. // recordDateTime := theTime.Unix()
  5421. // adminUser := c.GetAdminUserInfo()
  5422. //
  5423. // var prescriptions []*models.HisPrescription
  5424. //
  5425. // data := make(map[string]interface{})
  5426. // if settle_accounts_type == 1 { //日结
  5427. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5428. // data["pre"] = prescriptions
  5429. //
  5430. // } else { //月结
  5431. // start_time_str := c.GetString("start_time")
  5432. // end_time_str := c.GetString("end_time")
  5433. // timeLayout := "2006-01-02"
  5434. // loc, _ := time.LoadLocation("Local")
  5435. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5436. // if err != nil {
  5437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5438. // return
  5439. // }
  5440. // recordStartTime := theStartTime.Unix()
  5441. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5442. // if err != nil {
  5443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5444. // return
  5445. // }
  5446. // recordEndTime := theEndTime.Unix()
  5447. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5448. // data["pre"] = prescriptions
  5449. //
  5450. // }
  5451. //
  5452. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5453. //
  5454. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5455. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5456. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5457. // strconv.FormatInt(his.PatientId, 10)
  5458. //
  5459. // order_src, _ := service.GetHisOrderByID(order_id)
  5460. //
  5461. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5462. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5463. //
  5464. // var total float64
  5465. // for _, item := range prescriptions {
  5466. // if item.Type == 1 { //药品
  5467. // for _, subItem := range item.HisDoctorAdviceInfo {
  5468. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5469. // }
  5470. // }
  5471. // if item.Type == 2 { //项目
  5472. // for _, subItem := range item.HisPrescriptionProject {
  5473. // total = total + (subItem.Price * float64(subItem.Count))
  5474. // }
  5475. // }
  5476. // }
  5477. //
  5478. // for _, item := range prescriptions {
  5479. // for _, subItem := range item.HisAdditionalCharge {
  5480. // total = total + (subItem.Price * float64(subItem.Count))
  5481. // }
  5482. // }
  5483. //
  5484. // allTotal := fmt.Sprintf("%.2f", total)
  5485. // var rf []*ResultFive
  5486. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5487. // psn_no := order_src.PsnNo
  5488. // mdtrt_id := order_src.MdtrtId
  5489. // chrg_bchno := order_src.Number
  5490. // cert_no := order_src.Certno
  5491. // insutype := rf[0].Insutype
  5492. //
  5493. // if his.IdCardType == 1 {
  5494. // cert_no = his.MedicalInsuranceNumber
  5495. // } else {
  5496. // cert_no = his.Certno
  5497. // }
  5498. //
  5499. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  5500. // var dat map[string]interface{}
  5501. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5502. // fmt.Println(dat)
  5503. // } else {
  5504. // fmt.Println(err)
  5505. // }
  5506. //
  5507. // userJSONBytes, _ := json.Marshal(dat)
  5508. //
  5509. //
  5510. //
  5511. // var res ResultSeven
  5512. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5513. // utils.ErrorLog("解析失败:%v", err)
  5514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5515. // return
  5516. // }
  5517. // if res.Infcode == -1 {
  5518. // errlog := &models.HisOrderError{
  5519. // UserOrgId: adminUser.CurrentOrgId,
  5520. // Ctime: time.Now().Unix(),
  5521. // Mtime: time.Now().Unix(),
  5522. // Number: chrg_bchno,
  5523. // ErrMsg: res.ErrMsg,
  5524. // Status: 1,
  5525. // PatientId: id,
  5526. // RecordTime: recordDateTime,
  5527. // Stage: 6,
  5528. // }
  5529. // service.CreateErrMsgLog(errlog)
  5530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5531. // return
  5532. // } else {
  5533. // order_src.OrderStatus = 2
  5534. // order_src.PayWay = pay_way
  5535. // order_src.PayPrice = pay_price
  5536. // order_src.PayCardNo = pay_card_no
  5537. // order_src.DiscountPrice = discount_price
  5538. // order_src.PreferentialPrice = preferential_price
  5539. // order_src.RealityPrice = reality_price
  5540. // order_src.FoundPrice = found_price
  5541. // order_src.MedicalInsurancePrice = medical_insurance_price
  5542. // order_src.PrivatePrice = private_price
  5543. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5544. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5545. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5546. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5547. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5548. // order_src.Certno = res.Output.Setlinfo.Certno
  5549. // order_src.Gend = res.Output.Setlinfo.Gend
  5550. // order_src.Naty = res.Output.Setlinfo.Naty
  5551. // order_src.Age = res.Output.Setlinfo.Age
  5552. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5553. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5554. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5555. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5556. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5557. // order_src.MedType = res.Output.Setlinfo.MedType
  5558. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5559. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5560. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5561. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5562. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5563. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5564. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5565. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5566. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5567. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5568. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5569. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5570. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5571. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5572. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5573. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5574. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5575. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5576. // order_src.Balc = res.Output.Setlinfo.Balc
  5577. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5578. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5579. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5580. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5581. // order_src.Creator = order_src.Creator
  5582. // order_src.Modify = roles.ID
  5583. // order_src.RequestLog = src_resquest
  5584. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5585. // detailStr := string(setlDetail)
  5586. // order_src.SetlDetail = detailStr
  5587. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5588. // err = service.UpDateOrder(order_src)
  5589. //
  5590. // if err == nil {
  5591. // c.ServeSuccessJSON(map[string]interface{}{
  5592. // "msg": "结算成功",
  5593. // })
  5594. // } else {
  5595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5596. // return
  5597. // }
  5598. // }
  5599. // }
  5600. //}
  5601. //退款
  5602. func (c *HisApiController) Refund() {
  5603. order_id, _ := c.GetInt64("order_id")
  5604. admin_user_id, _ := c.GetInt64("admin_user_id")
  5605. adminUser := c.GetAdminUserInfo()
  5606. var order models.HisOrder
  5607. order, _ = service.GetHisOrderByID(order_id)
  5608. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5609. if order.ID == 0 {
  5610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5611. return
  5612. }
  5613. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5614. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5615. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5616. if config.IsOpen == 1 { //对接了医保,走医保流程
  5617. var res ResultSixteen
  5618. var resSixteen10265 ResultSixteen10265
  5619. var src_resquest string
  5620. var result string
  5621. if miConfig.MdtrtareaAdmvs == "421300" {
  5622. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5623. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5625. resp3, requestErr3 := http.Get(api3)
  5626. if requestErr3 != nil {
  5627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5628. return
  5629. }
  5630. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5631. if ioErr3 != nil {
  5632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5634. return
  5635. }
  5636. var respJSON3 map[string]interface{}
  5637. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5640. return
  5641. }
  5642. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5643. userJSONBytes3, _ := json.Marshal(respJSON3)
  5644. fmt.Println("log")
  5645. fmt.Println(string(userJSONBytes3))
  5646. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5647. utils.ErrorLog("解析失败:%v", err)
  5648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5649. return
  5650. }
  5651. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5652. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5653. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5655. resp3, requestErr3 := http.Get(api3)
  5656. if requestErr3 != nil {
  5657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5658. return
  5659. }
  5660. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5661. if ioErr3 != nil {
  5662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5664. return
  5665. }
  5666. var respJSON3 map[string]interface{}
  5667. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5670. return
  5671. }
  5672. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5673. userJSONBytes3, _ := json.Marshal(respJSON3)
  5674. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5675. utils.ErrorLog("解析失败:%v", err)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. } else {
  5680. if miConfig.Code == "H15049901371" {
  5681. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5682. var dat map[string]interface{}
  5683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5684. fmt.Println(dat)
  5685. } else {
  5686. fmt.Println(err)
  5687. }
  5688. saveLog(result, src_resquest, "2208", "退费")
  5689. userJSONBytes, _ := json.Marshal(dat)
  5690. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5691. utils.ErrorLog("解析失败:%v", err)
  5692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5693. return
  5694. }
  5695. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5696. res.Output = resSixteen10265.Output
  5697. res.ErrMsg = resSixteen10265.ErrMsg
  5698. res.Cainfo = resSixteen10265.Cainfo
  5699. res.WarnMsg = resSixteen10265.WarnMsg
  5700. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5701. res.Infcode = infocode
  5702. } else {
  5703. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5704. var dat map[string]interface{}
  5705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5706. fmt.Println(dat)
  5707. } else {
  5708. fmt.Println(err)
  5709. }
  5710. saveLog(result, src_resquest, "2208", "退费")
  5711. userJSONBytes, _ := json.Marshal(dat)
  5712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5713. utils.ErrorLog("解析失败:%v", err)
  5714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5715. return
  5716. }
  5717. }
  5718. }
  5719. if res.Infcode == 0 {
  5720. var res2 ResultSix
  5721. var resSix10265 ResultSix10265
  5722. if miConfig.MdtrtareaAdmvs == "421300" {
  5723. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5724. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5725. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5726. resp3, requestErr3 := http.Get(api3)
  5727. if requestErr3 != nil {
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. return
  5730. }
  5731. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5732. if ioErr3 != nil {
  5733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5735. return
  5736. }
  5737. var respJSON3 map[string]interface{}
  5738. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5741. return
  5742. }
  5743. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5744. userJSONBytes3, _ := json.Marshal(respJSON3)
  5745. fmt.Println("log")
  5746. fmt.Println(string(userJSONBytes3))
  5747. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5748. utils.ErrorLog("解析失败:%v", err)
  5749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5750. return
  5751. }
  5752. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5753. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5754. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5755. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5756. resp3, requestErr3 := http.Get(api3)
  5757. if requestErr3 != nil {
  5758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5759. return
  5760. }
  5761. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5762. if ioErr3 != nil {
  5763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5765. return
  5766. }
  5767. var respJSON3 map[string]interface{}
  5768. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. return
  5772. }
  5773. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5774. userJSONBytes3, _ := json.Marshal(respJSON3)
  5775. fmt.Println("log")
  5776. fmt.Println(string(userJSONBytes3))
  5777. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5778. utils.ErrorLog("解析失败:%v", err)
  5779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5780. return
  5781. }
  5782. } else {
  5783. if miConfig.Code == "H15049901371" {
  5784. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5785. var dat map[string]interface{}
  5786. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5787. fmt.Println(dat)
  5788. } else {
  5789. fmt.Println(err)
  5790. }
  5791. saveLog(result2, src_request, "2205", "撤销明细")
  5792. userJSONBytes, _ := json.Marshal(dat)
  5793. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5794. utils.ErrorLog("解析失败:%v", err)
  5795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5796. return
  5797. }
  5798. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5799. res2.Output = resSix10265.Output
  5800. res2.ErrMsg = resSix10265.ErrMsg
  5801. res2.Cainfo = resSix10265.Cainfo
  5802. res2.WarnMsg = resSix10265.WarnMsg
  5803. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5804. res2.Infcode = infocode
  5805. } else {
  5806. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5807. var dat map[string]interface{}
  5808. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5809. fmt.Println(dat)
  5810. } else {
  5811. fmt.Println(err)
  5812. }
  5813. saveLog(result2, src_request, "2205", "撤销明细")
  5814. userJSONBytes, _ := json.Marshal(dat)
  5815. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5816. utils.ErrorLog("解析失败:%v", err)
  5817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5818. return
  5819. }
  5820. }
  5821. }
  5822. if res2.Infcode == 0 {
  5823. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5824. if err == nil {
  5825. c.ServeSuccessJSON(map[string]interface{}{
  5826. "msg": "退费成功",
  5827. })
  5828. } else {
  5829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5830. return
  5831. }
  5832. } else {
  5833. c.ServeSuccessJSON(map[string]interface{}{
  5834. "code": -10,
  5835. "msg": res2.ErrMsg,
  5836. })
  5837. }
  5838. } else {
  5839. c.ServeSuccessJSON(map[string]interface{}{
  5840. "code": -10,
  5841. "msg": res.ErrMsg,
  5842. })
  5843. }
  5844. }
  5845. }
  5846. func (c *HisApiController) RefundNumber() {
  5847. record_time := c.GetString("record_time")
  5848. //patient_id, _ := c.GetInt64("patient_id")
  5849. admin_user_id, _ := c.GetInt64("admin_user_id")
  5850. his_patient_id, _ := c.GetInt64("id")
  5851. timeLayout := "2006-01-02"
  5852. loc, _ := time.LoadLocation("Local")
  5853. adminUser := c.GetAdminUserInfo()
  5854. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5855. fmt.Println(err)
  5856. if err != nil {
  5857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5858. return
  5859. }
  5860. recordDateTime := theTime.Unix()
  5861. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5862. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5863. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5864. //order, _ := service.GetHisOrderByID(order_id)
  5865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5866. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5867. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5868. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5869. if count > 0 {
  5870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5871. return
  5872. }
  5873. if config.IsOpen == 1 { //对接了医保,走医保流程
  5874. var res2 ResultSix
  5875. var resSix10265 ResultSix10265
  5876. if miConfig.MdtrtareaAdmvs == "421300" {
  5877. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5878. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5879. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5880. resp3, requestErr3 := http.Get(api3)
  5881. if requestErr3 != nil {
  5882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5883. return
  5884. }
  5885. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5886. if ioErr3 != nil {
  5887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. return
  5890. }
  5891. var respJSON3 map[string]interface{}
  5892. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5895. return
  5896. }
  5897. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5898. userJSONBytes3, _ := json.Marshal(respJSON3)
  5899. fmt.Println("log")
  5900. fmt.Println(string(userJSONBytes3))
  5901. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5902. utils.ErrorLog("解析失败:%v", err)
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5904. return
  5905. }
  5906. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5907. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5908. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5910. resp3, requestErr3 := http.Get(api3)
  5911. if requestErr3 != nil {
  5912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5913. return
  5914. }
  5915. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5916. if ioErr3 != nil {
  5917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5919. return
  5920. }
  5921. var respJSON3 map[string]interface{}
  5922. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5925. return
  5926. }
  5927. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5928. userJSONBytes3, _ := json.Marshal(respJSON3)
  5929. fmt.Println("log")
  5930. fmt.Println(string(userJSONBytes3))
  5931. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. } else {
  5937. var api3 string
  5938. if miConfig.Code == "H15049901371" {
  5939. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5940. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5941. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5942. } else {
  5943. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5944. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5945. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5946. }
  5947. resp3, requestErr3 := http.Get(api3)
  5948. if requestErr3 != nil {
  5949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5950. return
  5951. }
  5952. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5953. if ioErr3 != nil {
  5954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. return
  5957. }
  5958. var respJSON3 map[string]interface{}
  5959. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5962. return
  5963. }
  5964. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5965. userJSONBytes3, _ := json.Marshal(respJSON3)
  5966. if miConfig.Code == "H15049901371" {
  5967. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5968. utils.ErrorLog("解析失败:%v", err)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5973. res2.Output = resSix10265.Output
  5974. res2.ErrMsg = resSix10265.ErrMsg
  5975. res2.Cainfo = resSix10265.Cainfo
  5976. res2.WarnMsg = resSix10265.WarnMsg
  5977. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5978. res2.Infcode = infocode
  5979. } else {
  5980. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5981. utils.ErrorLog("解析失败:%v", err)
  5982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5983. return
  5984. }
  5985. }
  5986. }
  5987. if res2.Infcode == 0 {
  5988. if err == nil {
  5989. c.ServeSuccessJSON(map[string]interface{}{
  5990. "msg": "退号成功",
  5991. })
  5992. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5993. } else {
  5994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5995. return
  5996. }
  5997. } else {
  5998. c.ServeSuccessJSON(map[string]interface{}{
  5999. "code": -10,
  6000. "msg": res2.ErrMsg,
  6001. })
  6002. }
  6003. } else {
  6004. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6005. //if err == nil {
  6006. // c.ServeSuccessJSON(map[string]interface{}{
  6007. // "msg": "退费成功",
  6008. // })
  6009. //} else {
  6010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6011. // return
  6012. //}
  6013. }
  6014. }
  6015. func (c *HisApiController) RefundDetail() {
  6016. order_id, _ := c.GetInt64("order_id")
  6017. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6018. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6019. number := c.GetString("number")
  6020. record_time := c.GetString("record_time")
  6021. patient_id, _ := c.GetInt64("patient_id")
  6022. timeLayout := "2006-01-02"
  6023. loc, _ := time.LoadLocation("Local")
  6024. adminUser := c.GetAdminUserInfo()
  6025. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6026. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6027. fmt.Println(err)
  6028. if err != nil {
  6029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6030. return
  6031. }
  6032. recordDateTime := theTime.Unix()
  6033. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6034. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6036. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6037. var order models.HisOrder
  6038. order, _ = service.GetHisOrderByID(order_id)
  6039. if order.ID == 0 {
  6040. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6041. }
  6042. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6043. if config.IsOpen == 1 { //对接了医保,走医保流程
  6044. var res2 ResultSix
  6045. if miConfig.MdtrtareaAdmvs == "421300" {
  6046. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6047. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6048. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6049. resp3, requestErr3 := http.Get(api3)
  6050. if requestErr3 != nil {
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6055. if ioErr3 != nil {
  6056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. return
  6059. }
  6060. var respJSON3 map[string]interface{}
  6061. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6064. return
  6065. }
  6066. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6067. userJSONBytes3, _ := json.Marshal(respJSON3)
  6068. fmt.Println("log")
  6069. fmt.Println(string(userJSONBytes3))
  6070. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6071. utils.ErrorLog("解析失败:%v", err)
  6072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6073. return
  6074. }
  6075. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6076. if err == nil {
  6077. c.ServeSuccessJSON(map[string]interface{}{
  6078. "msg": "撤销明细成功",
  6079. })
  6080. return
  6081. } else {
  6082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6083. return
  6084. }
  6085. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6086. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6087. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6088. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6089. resp3, requestErr3 := http.Get(api3)
  6090. if requestErr3 != nil {
  6091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. return
  6093. }
  6094. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6095. if ioErr3 != nil {
  6096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6098. return
  6099. }
  6100. var respJSON3 map[string]interface{}
  6101. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. return
  6105. }
  6106. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6107. userJSONBytes3, _ := json.Marshal(respJSON3)
  6108. fmt.Println("log")
  6109. fmt.Println(string(userJSONBytes3))
  6110. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6111. utils.ErrorLog("解析失败:%v", err)
  6112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6113. return
  6114. }
  6115. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6116. if err == nil {
  6117. c.ServeSuccessJSON(map[string]interface{}{
  6118. "msg": "撤销明细成功",
  6119. })
  6120. return
  6121. } else {
  6122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6123. return
  6124. }
  6125. } else {
  6126. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6127. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6129. resp2, requestErr2 := http.Get(api2)
  6130. if requestErr2 != nil {
  6131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6132. return
  6133. }
  6134. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6135. if ioErr2 != nil {
  6136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6138. return
  6139. }
  6140. var respJSON2 map[string]interface{}
  6141. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6144. return
  6145. }
  6146. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6147. if err == nil {
  6148. c.ServeSuccessJSON(map[string]interface{}{
  6149. "msg": "撤销明细成功",
  6150. })
  6151. return
  6152. } else {
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return
  6155. }
  6156. }
  6157. } else {
  6158. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6159. if err == nil {
  6160. c.ServeSuccessJSON(map[string]interface{}{
  6161. "msg": "退费成功",
  6162. })
  6163. } else {
  6164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6165. return
  6166. }
  6167. }
  6168. }
  6169. //对账
  6170. func (c *HisApiController) GetCheckAccount() {
  6171. start_time := c.GetString("start_time")
  6172. end_time := c.GetString("end_time")
  6173. insutype := c.GetString("insutype")
  6174. clr_type := c.GetString("clr_type")
  6175. clr_org := c.GetString("clr_optins")
  6176. admin_user_id, _ := c.GetInt64("admin_user_id")
  6177. adminUser := c.GetAdminUserInfo()
  6178. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6179. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6180. if len(clr_org) == 0 {
  6181. clr_org = miConfig.MdtrtareaAdmvs
  6182. }
  6183. timeLayout := "2006-01-02"
  6184. loc, _ := time.LoadLocation("Local")
  6185. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6186. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6187. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6188. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  6189. fixmedins_setl_cnt := int64(len(orders))
  6190. //
  6191. ////撤销的算2条数据为一笔
  6192. //for _, item := range orders_two {
  6193. // if item.OrderStatus == 3 {
  6194. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  6195. // }
  6196. //}
  6197. var medfee_sumamt float64
  6198. var acct_pay float64
  6199. var fund_pay_sumamt float64
  6200. for _, item := range orders {
  6201. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6202. acct_pay = acct_pay + item.AcctPay
  6203. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6204. }
  6205. var user_name string
  6206. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6207. if role.ID == 0 {
  6208. user_name = "xxx"
  6209. } else {
  6210. user_name = role.UserName
  6211. }
  6212. if config.IsOpen == 1 {
  6213. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6214. "insutype=" + insutype +
  6215. "&clr_type=" + clr_type +
  6216. "&setl_optins=" + clr_org +
  6217. "&stmt_begndate=" + start_time +
  6218. "&stm_enddate=" + end_time +
  6219. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6220. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6221. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6222. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6223. "&fixmedins_code=" + miConfig.Code +
  6224. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6225. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6226. "&secret_key=" + miConfig.SecretKey +
  6227. "&org_name=" + miConfig.OrgName +
  6228. "&doctor=" + user_name
  6229. fmt.Println(api)
  6230. resp, requestErr := http.Get(api)
  6231. if requestErr != nil {
  6232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6233. return
  6234. }
  6235. body, ioErr := ioutil.ReadAll(resp.Body)
  6236. fmt.Println(body)
  6237. if ioErr != nil {
  6238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6240. return
  6241. }
  6242. var respJSON map[string]interface{}
  6243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6246. return
  6247. }
  6248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6249. userJSONBytes, _ := json.Marshal(respJSON)
  6250. var res ResultEight
  6251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6252. utils.ErrorLog("解析失败:%v", err)
  6253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. return
  6255. }
  6256. if res.Infcode == 0 {
  6257. if res.Output.Stmtinfo.StmtRslt == "0" {
  6258. micc := &models.MedicalInsuranceCostCompare{
  6259. StartTime: startime.Unix(),
  6260. EndTime: endtime.Unix(),
  6261. Insutype: insutype,
  6262. CheckType: 1,
  6263. Num: fixmedins_setl_cnt,
  6264. Mtime: time.Now().Unix(),
  6265. Status: 1,
  6266. UserOrgId: adminUser.CurrentOrgId,
  6267. CostTotal: medfee_sumamt,
  6268. FuncTotal: fund_pay_sumamt,
  6269. PsnPay: acct_pay,
  6270. Creator: admin_user_id,
  6271. Ctime: time.Now().Unix(),
  6272. }
  6273. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6274. if err == nil {
  6275. c.ServeSuccessJSON(map[string]interface{}{
  6276. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6277. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6278. })
  6279. } else {
  6280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6281. }
  6282. } else {
  6283. c.ServeSuccessJSON(map[string]interface{}{
  6284. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6285. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6286. })
  6287. }
  6288. } else {
  6289. c.ServeSuccessJSON(map[string]interface{}{
  6290. "code": -10,
  6291. "msg": res.ErrMsg,
  6292. })
  6293. }
  6294. }
  6295. }
  6296. func (c *HisApiController) Check310() {
  6297. adminUser := c.GetAdminUserInfo()
  6298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6299. var user_name string
  6300. user_name = "xxx"
  6301. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6302. "insutype=" + "310" +
  6303. "&clr_type=" + "11" +
  6304. "&setl_optins=" + "定点医保中心" +
  6305. "&stmt_begndate=" + "2021-03-01" +
  6306. "&stm_enddate=" + "2021-03-31" +
  6307. "&medfee_sumamt=" + "11521" +
  6308. "&fund_pay_sumamt=" + "10166.66" +
  6309. "&acct_pay=" + "0" +
  6310. "&fixmedins_setl_cnt=" + "7" +
  6311. "&fixmedins_code=" + miConfig.Code +
  6312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6313. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6314. "&secret_key=" + miConfig.SecretKey +
  6315. "&org_name=" + miConfig.OrgName +
  6316. "&doctor=" + user_name
  6317. fmt.Println(api)
  6318. resp, requestErr := http.Get(api)
  6319. if requestErr != nil {
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return
  6322. }
  6323. body, ioErr := ioutil.ReadAll(resp.Body)
  6324. fmt.Println(body)
  6325. if ioErr != nil {
  6326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6328. return
  6329. }
  6330. var respJSON map[string]interface{}
  6331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6334. return
  6335. }
  6336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6337. userJSONBytes, _ := json.Marshal(respJSON)
  6338. var res ResultEight
  6339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6340. utils.ErrorLog("解析失败:%v", err)
  6341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6342. return
  6343. }
  6344. }
  6345. func (c *HisApiController) Check390() {
  6346. adminUser := c.GetAdminUserInfo()
  6347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6348. var user_name string
  6349. user_name = "张俊杰"
  6350. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6351. "insutype=" + "390" +
  6352. "&clr_type=" + "11" +
  6353. "&setl_optins=" + "定点医保中心" +
  6354. "&stmt_begndate=" + "2021-03-01" +
  6355. "&stm_enddate=" + "2021-03-31" +
  6356. "&medfee_sumamt=" + "209318.43" +
  6357. "&fund_pay_sumamt=" + "188029.12" +
  6358. "&acct_pay=" + "0" +
  6359. "&fixmedins_setl_cnt=" + "48" +
  6360. "&fixmedins_code=" + miConfig.Code +
  6361. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6362. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6363. "&secret_key=" + miConfig.SecretKey +
  6364. "&org_name=" + miConfig.OrgName +
  6365. "&doctor=" + user_name
  6366. fmt.Println(api)
  6367. resp, requestErr := http.Get(api)
  6368. if requestErr != nil {
  6369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6370. return
  6371. }
  6372. body, ioErr := ioutil.ReadAll(resp.Body)
  6373. fmt.Println(body)
  6374. if ioErr != nil {
  6375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6377. return
  6378. }
  6379. var respJSON map[string]interface{}
  6380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6383. return
  6384. }
  6385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6386. userJSONBytes, _ := json.Marshal(respJSON)
  6387. var res ResultEight
  6388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6389. utils.ErrorLog("解析失败:%v", err)
  6390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6391. return
  6392. }
  6393. }
  6394. //对账明细
  6395. func (c *HisApiController) GetCheckDetailAccount() {
  6396. start_time := c.GetString("start_time")
  6397. end_time := c.GetString("end_time")
  6398. admin_user_id, _ := c.GetInt64("admin_user_id")
  6399. adminUser := c.GetAdminUserInfo()
  6400. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6401. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6402. timeLayout := "2006-01-02"
  6403. loc, _ := time.LoadLocation("Local")
  6404. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6405. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6406. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6407. Mkdir(miConfig.OrgName)
  6408. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6409. file_name := file + ".txt"
  6410. zip_name := file + ".zip"
  6411. zip_path := miConfig.OrgName + "/" + zip_name
  6412. file_path := miConfig.OrgName + "/" + file_name
  6413. decimal.DivisionPrecision = 2
  6414. var medfee_sumamt float64
  6415. var psn_cash_pay float64
  6416. var fund_pay_sumamt float64
  6417. fixmedins_setl_cnt := int64(len(orders))
  6418. for _, item := range orders {
  6419. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6420. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6421. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6422. }
  6423. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6424. defer f.Close()
  6425. if err != nil {
  6426. fmt.Println(err.Error())
  6427. } else {
  6428. for _, item := range orders {
  6429. var refd_setl_flag string
  6430. if item.OrderStatus == 2 {
  6431. refd_setl_flag = "0"
  6432. var str string
  6433. str = item.SetlId + " " +
  6434. item.MdtrtId + " " +
  6435. item.PsnNo + " " +
  6436. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6437. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6438. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6439. _, err = f.Write([]byte(str))
  6440. }
  6441. if item.OrderStatus == 3 {
  6442. var str string
  6443. str = item.SetlId + " " +
  6444. item.MdtrtId + " " +
  6445. item.PsnNo + " " +
  6446. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6447. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6448. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6449. _, err = f.Write([]byte(str))
  6450. var str2 string
  6451. str2 = item.SetlId + " " +
  6452. item.MdtrtId + " " +
  6453. item.PsnNo + " " +
  6454. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6455. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6456. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6457. _, err = f.Write([]byte(str2))
  6458. }
  6459. }
  6460. }
  6461. Zip(file_path, zip_path)
  6462. fmt.Println(ReadFile(zip_path))
  6463. fmt.Println(string(ReadFile(zip_path)))
  6464. if config.IsOpen == 1 {
  6465. var user_name string
  6466. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6467. if role.ID == 0 {
  6468. user_name = "管理员"
  6469. } else {
  6470. user_name = role.UserName
  6471. }
  6472. baseParams := models.BaseParams{
  6473. SecretKey: miConfig.SecretKey,
  6474. FixmedinsCode: miConfig.Code,
  6475. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6476. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6477. OrgName: miConfig.OrgName,
  6478. Doctor: user_name,
  6479. }
  6480. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6481. var dat map[string]interface{}
  6482. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6483. fmt.Println(dat)
  6484. } else {
  6485. fmt.Println(err)
  6486. }
  6487. userJSONBytes, _ := json.Marshal(dat)
  6488. var res ResultNine
  6489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6490. utils.ErrorLog("解析失败:%v", err)
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6492. return
  6493. }
  6494. if res.Infcode == 0 {
  6495. fileNo := res.Output.FileQuryNo
  6496. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6497. "file_qury_no=" + fileNo +
  6498. "&setl_optins=" + "定点医保中心" +
  6499. "&stmt_begndate=" + start_time +
  6500. "&stm_enddate=" + end_time +
  6501. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6502. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6503. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6504. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6505. "&fixmedins_code=" + miConfig.Code +
  6506. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6507. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6508. "&secret_key=" + miConfig.SecretKey +
  6509. "&org_name=" + miConfig.OrgName +
  6510. "&doctor=" + user_name
  6511. resp, requestErr := http.Get(api)
  6512. if requestErr != nil {
  6513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. return
  6515. }
  6516. body, ioErr := ioutil.ReadAll(resp.Body)
  6517. if ioErr != nil {
  6518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. return
  6521. }
  6522. var respJSON map[string]interface{}
  6523. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. return
  6527. }
  6528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6529. userJSONBytes, _ := json.Marshal(respJSON)
  6530. var res ResultTen
  6531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6532. utils.ErrorLog("解析失败:%v", err)
  6533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6534. return
  6535. }
  6536. if res.Infcode == 0 {
  6537. service.Gdyb9102(baseParams, zip_name, fileNo)
  6538. micc := &models.MedicalInsuranceCostCompare{
  6539. StartTime: startime.Unix(),
  6540. EndTime: endtime.Unix(),
  6541. Insutype: "0",
  6542. CheckType: 2,
  6543. Num: fixmedins_setl_cnt,
  6544. Mtime: time.Now().Unix(),
  6545. Status: 1,
  6546. UserOrgId: adminUser.CurrentOrgId,
  6547. CostTotal: medfee_sumamt,
  6548. FuncTotal: fund_pay_sumamt,
  6549. PsnPay: psn_cash_pay,
  6550. Creator: admin_user_id,
  6551. Ctime: time.Now().Unix(),
  6552. }
  6553. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6554. c.ServeSuccessJSON(map[string]interface{}{
  6555. "msg": "明细对账成功",
  6556. })
  6557. }
  6558. } else {
  6559. }
  6560. }
  6561. }
  6562. type CustomOrderInfo struct {
  6563. Name string
  6564. Spec string
  6565. Unit string
  6566. Count float64
  6567. Price float64
  6568. Total float64
  6569. }
  6570. func (c *HisApiController) GetSettleAccounts() {
  6571. //id, _ := c.GetInt64("id")
  6572. //record_time := c.GetString("record_time")
  6573. order_id, _ := c.GetInt64("order_id")
  6574. admin_user_id, _ := c.GetInt64("admin_user_id")
  6575. //timeLayout := "2006-01-02"
  6576. //loc, _ := time.LoadLocation("Local")
  6577. //
  6578. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6579. //if err != nil {
  6580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6581. // return
  6582. //}
  6583. //recordDateTime := theTime.Unix()
  6584. adminUser := c.GetAdminUserInfo()
  6585. order, _ := service.GetHisOrderByID(order_id)
  6586. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6587. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6588. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6589. orderInfos = append(orderInfos, orderInfos_two...)
  6590. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6591. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6592. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6593. //var config []*models.HisXtDiagnoseConfig
  6594. var name string
  6595. for _, item := range diagnosis_ids {
  6596. id, _ := strconv.ParseInt(item, 10, 64)
  6597. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6598. if len(name) == 0 {
  6599. name = diagnosisConfig.ClassName
  6600. } else {
  6601. name = name + "," + diagnosisConfig.ClassName
  6602. }
  6603. }
  6604. var bedCostTotal float64 = 0 //床位总费
  6605. var bedCostSelfTotal float64 = 0 //床位自费
  6606. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6607. var operationCostTotal float64 = 0 //手术费
  6608. var operationCostSelfTotal float64 = 0 //手术费
  6609. var operationCostPartSelfTotal float64 = 0 //手术费
  6610. var otherCostTotal float64 = 0 //其他费用
  6611. var otherCostSelfTotal float64 = 0 //其他费用
  6612. var otherCostPartSelfTotal float64 = 0 //其他费用
  6613. var materialCostTotal float64 = 0 //材料费
  6614. var materialCostSelfTotal float64 = 0 //材料费
  6615. var materialCostPartSelfTotal float64 = 0 //材料费
  6616. var westernMedicineCostTotal float64 = 0 //西药费
  6617. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6618. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6619. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6620. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6621. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6622. var checkCostTotal float64 = 0 //检查费
  6623. var checkCostSelfTotal float64 = 0 //检查费
  6624. var checkCostPartSelfTotal float64 = 0 //检查费
  6625. var laboratoryCostTotal float64 = 0 //化验费
  6626. var laboratoryCostSelfTotal float64 = 0 //化验费
  6627. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6628. var treatCostTotal float64 = 0 //治疗费用
  6629. var treatCostSelfTotal float64 = 0 //治疗费用
  6630. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6631. decimal.DivisionPrecision = 2
  6632. for _, item := range orderInfos {
  6633. if item.MedChrgitmType == "01" { //床位费
  6634. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6635. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6636. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6637. }
  6638. if item.MedChrgitmType == "03" { //检查费
  6639. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6640. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6641. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6642. }
  6643. if item.MedChrgitmType == "04" { //化验费
  6644. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6645. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6646. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6647. }
  6648. if item.MedChrgitmType == "05" { //治疗费
  6649. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6650. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6651. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6652. }
  6653. if item.MedChrgitmType == "06" { //手术费
  6654. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6655. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6656. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6657. }
  6658. if item.MedChrgitmType == "08" { //材料费
  6659. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6660. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6661. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6662. }
  6663. if item.MedChrgitmType == "09" { //西药费
  6664. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6665. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6666. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6667. }
  6668. if item.MedChrgitmType == "11" { //中成费
  6669. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6670. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6671. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6672. }
  6673. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6674. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6675. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6676. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6677. }
  6678. }
  6679. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6680. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6681. var user_name string
  6682. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6683. if role.ID == 0 {
  6684. user_name = "管理员"
  6685. } else {
  6686. user_name = role.UserName
  6687. }
  6688. baseParams := models.BaseParams{
  6689. SecretKey: miConfig.SecretKey,
  6690. FixmedinsCode: miConfig.Code,
  6691. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6692. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6693. OrgName: miConfig.OrgName,
  6694. Doctor: user_name,
  6695. }
  6696. businessParams := models.BusinessParams{
  6697. PsnNo: order.PsnNo,
  6698. MdtrtId: order.MdtrtId,
  6699. SetlId: order.SetlId,
  6700. }
  6701. var res ResultEleven
  6702. var resEleven10265 ResultEleven10265
  6703. if config.IsOpen == 1 {
  6704. if miConfig.MdtrtareaAdmvs == "421300" {
  6705. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6706. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6707. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6708. resp, requestErr := http.Get(api)
  6709. if requestErr != nil {
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. body, ioErr := ioutil.ReadAll(resp.Body)
  6714. if ioErr != nil {
  6715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. return
  6718. }
  6719. var respJSON map[string]interface{}
  6720. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. return
  6724. }
  6725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6726. result, _ := json.Marshal(respJSON)
  6727. fmt.Println("log")
  6728. fmt.Println(string(result))
  6729. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6730. utils.ErrorLog("解析失败:%v", err)
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. return
  6733. }
  6734. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6735. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6736. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6737. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6738. resp, requestErr := http.Get(api)
  6739. if requestErr != nil {
  6740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6741. return
  6742. }
  6743. body, ioErr := ioutil.ReadAll(resp.Body)
  6744. if ioErr != nil {
  6745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. return
  6748. }
  6749. var respJSON map[string]interface{}
  6750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6756. result, _ := json.Marshal(respJSON)
  6757. fmt.Println("log")
  6758. fmt.Println(string(result))
  6759. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6760. utils.ErrorLog("解析失败:%v", err)
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. return
  6763. }
  6764. } else {
  6765. result2 := service.Gdyb5204(baseParams, businessParams)
  6766. saveLog(result2, "", "5204", "查询")
  6767. result := service.Gdyb5203(baseParams, businessParams)
  6768. var dat map[string]interface{}
  6769. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6770. fmt.Println(dat)
  6771. } else {
  6772. fmt.Println(err)
  6773. }
  6774. userJSONBytes, _ := json.Marshal(dat)
  6775. if miConfig.Code == "H15049901371" {
  6776. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6777. utils.ErrorLog("解析失败:%v", err)
  6778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6779. return
  6780. }
  6781. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6782. res.Output = resEleven10265.Output
  6783. res.ErrMsg = resEleven10265.ErrMsg
  6784. res.Cainfo = resEleven10265.Cainfo
  6785. res.WarnMsg = resEleven10265.WarnMsg
  6786. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6787. res.Infcode = infocode
  6788. } else {
  6789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6790. utils.ErrorLog("解析失败:%v", err)
  6791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6792. return
  6793. }
  6794. }
  6795. }
  6796. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6797. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6798. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6799. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6800. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6801. var doctor_name string
  6802. if roles.ID == 0 {
  6803. doctor_name = "管理员"
  6804. } else {
  6805. doctor_name = roles.UserName
  6806. }
  6807. yiliao_leibie := ""
  6808. switch order.MedType {
  6809. case "11":
  6810. yiliao_leibie = "普通门诊"
  6811. break
  6812. case "12":
  6813. yiliao_leibie = "门诊挂号"
  6814. break
  6815. case "13":
  6816. yiliao_leibie = "急诊"
  6817. break
  6818. case "14":
  6819. yiliao_leibie = "门诊特殊病"
  6820. break
  6821. case "15":
  6822. yiliao_leibie = "门诊统筹"
  6823. break
  6824. case "16":
  6825. yiliao_leibie = "门诊慢性病"
  6826. break
  6827. case "21":
  6828. yiliao_leibie = "普通住院"
  6829. break
  6830. }
  6831. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6832. if res.Infcode == 0 {
  6833. c.ServeSuccessJSON(map[string]interface{}{
  6834. "diagnosis": name,
  6835. "order_infos": orderInfos,
  6836. "number": order.MdtrtId,
  6837. "date": order.SettleAccountsDate,
  6838. "charge_admin": charge_admin,
  6839. "printor_admin": printor_admin,
  6840. "info": res.Output.Setlinfo,
  6841. "bedCostTotal": bedCostTotal,
  6842. "bedCostSelfTotal": bedCostSelfTotal,
  6843. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6844. "operationCostTotal": operationCostTotal,
  6845. "operationCostSelfTotal": operationCostSelfTotal,
  6846. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6847. "otherCostTotal": otherCostTotal,
  6848. "otherCostSelfTotal": otherCostSelfTotal,
  6849. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6850. "materialCostTotal": materialCostTotal,
  6851. "materialCostSelfTotal": materialCostSelfTotal,
  6852. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6853. "westernMedicineCostTotal": westernMedicineCostTotal,
  6854. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6855. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6856. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6857. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6858. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6859. "checkCostTotal": checkCostTotal,
  6860. "checkCostSelfTotal": checkCostSelfTotal,
  6861. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6862. "laboratoryCostTotal": laboratoryCostTotal,
  6863. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6864. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6865. "treatCostTotal": treatCostTotal,
  6866. "treatCostSelfTotal": treatCostSelfTotal,
  6867. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6868. "doctor_code": adminRole_two.DoctorCode,
  6869. "doctor_name": doctor_name,
  6870. "health_card_no": order.PsnNo,
  6871. "department": departments.Name,
  6872. "yiliao_leibie": yiliao_leibie,
  6873. "after_money": order.AccountPrice,
  6874. "patient": patient,
  6875. "org_name": miConfig.OrgName,
  6876. "org_code": miConfig.Code,
  6877. "order_number": order.Number,
  6878. //"check_order_info": cus_slice,
  6879. })
  6880. }
  6881. }
  6882. }
  6883. func (c *HisApiController) CheckTreatment() {
  6884. patient_id, _ := c.GetInt64("patient_id")
  6885. id_card_no := c.GetString("id_card_no")
  6886. insutype := c.GetString("insutype")
  6887. med_type := c.GetString("med_type")
  6888. admin_user_id, _ := c.GetInt64("admin_user_id")
  6889. adminUser := c.GetAdminUserInfo()
  6890. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6892. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6893. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6894. if miConfig.MdtrtareaAdmvs == "421300" {
  6895. var res ResultTwo
  6896. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  6897. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6898. "&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)
  6899. resp, requestErr := http.Get(api)
  6900. if requestErr != nil {
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. return
  6903. }
  6904. body, ioErr := ioutil.ReadAll(resp.Body)
  6905. if ioErr != nil {
  6906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. return
  6909. }
  6910. var respJSON map[string]interface{}
  6911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6914. return
  6915. }
  6916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6917. result, _ := json.Marshal(respJSON)
  6918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6919. utils.ErrorLog("解析失败:%v", err)
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6921. return
  6922. }
  6923. if res.Infcode == 0 {
  6924. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  6925. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6926. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  6927. resp, requestErr := http.Get(api)
  6928. if requestErr != nil {
  6929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6930. return
  6931. }
  6932. body, ioErr := ioutil.ReadAll(resp.Body)
  6933. if ioErr != nil {
  6934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6936. return
  6937. }
  6938. var respJSON map[string]interface{}
  6939. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. return
  6943. }
  6944. var res Result2001
  6945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6946. result2, _ := json.Marshal(respJSON)
  6947. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6948. utils.ErrorLog("解析失败:%v", err)
  6949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. return
  6951. }
  6952. if res.Infcode == 0 {
  6953. c.ServeSuccessJSON(map[string]interface{}{
  6954. "msg": res.Output.Trtinfo,
  6955. })
  6956. }
  6957. } else {
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6959. return
  6960. }
  6961. } else {
  6962. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  6963. var dat map[string]interface{}
  6964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6965. fmt.Println(dat)
  6966. } else {
  6967. fmt.Println(err)
  6968. }
  6969. userJSONBytes, _ := json.Marshal(dat)
  6970. var res ResultTwo
  6971. var res10265 ResultTwo10265
  6972. if miConfig.Code == "H15049901371" {
  6973. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6974. utils.ErrorLog("解析失败:%v", err)
  6975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6976. return
  6977. }
  6978. res.ErrMsg = res10265.ErrMsg
  6979. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6980. res.Infcode = infocode
  6981. res.Output = res10265.Output
  6982. res.InfRefmsgid = res10265.InfRefmsgid
  6983. } else {
  6984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6985. utils.ErrorLog("解析失败:%v", err)
  6986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. return
  6988. }
  6989. }
  6990. var user_name string
  6991. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6992. if role.ID == 0 {
  6993. user_name = "xxx"
  6994. } else {
  6995. user_name = role.UserName
  6996. }
  6997. baseParams := models.BaseParams{
  6998. SecretKey: miConfig.SecretKey,
  6999. FixmedinsCode: miConfig.Code,
  7000. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7001. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7002. OrgName: miConfig.OrgName,
  7003. Doctor: user_name,
  7004. }
  7005. if config.IsOpen == 1 {
  7006. if miConfig.Code == "H15049901371" {
  7007. if med_type == "14" {
  7008. if insutype == "390" {
  7009. med_type = "9933"
  7010. } else if insutype == "310" {
  7011. med_type = "990502"
  7012. }
  7013. } else if med_type == "11" {
  7014. med_type = "11"
  7015. }
  7016. }
  7017. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7018. var dat map[string]interface{}
  7019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7020. fmt.Println(dat)
  7021. } else {
  7022. fmt.Println(err)
  7023. }
  7024. var res Result2001
  7025. var res10265 Result2001Org10265
  7026. if miConfig.Code == "H15049901371" {
  7027. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7028. utils.ErrorLog("解析失败:%v", err)
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7030. return
  7031. }
  7032. res.ErrMsg = res10265.ErrMsg
  7033. res.Output = res10265.Output
  7034. res.InfRefmsgid = res10265.InfRefmsgid
  7035. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7036. res.Infcode = infocode
  7037. } else {
  7038. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7039. utils.ErrorLog("解析失败:%v", err)
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. }
  7044. if res.Infcode == 0 {
  7045. c.ServeSuccessJSON(map[string]interface{}{
  7046. "msg": res.Output.Trtinfo,
  7047. })
  7048. }
  7049. }
  7050. }
  7051. }
  7052. //func (c *HisApiController) PutRecord() {
  7053. // id, _ := c.GetInt64("id")
  7054. // record_time := c.GetString("record_time")
  7055. // timeLayout := "2006-01-02"
  7056. // loc, _ := time.LoadLocation("Local")
  7057. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7058. // if err != nil {
  7059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7060. // return
  7061. // }
  7062. // recordDateTime := theTime.Unix()
  7063. //
  7064. // adminInfo := c.GetAdminUserInfo()
  7065. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7066. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7067. //
  7068. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7069. //
  7070. // fmt.Println(miConfig.SecretKey)
  7071. //
  7072. // if patient == nil {
  7073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7074. // return
  7075. // }
  7076. // if len(patient.IdCardNo) == 0 {
  7077. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7078. // return
  7079. // }
  7080. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7081. // if config.IsOpen == 1 {
  7082. // 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
  7083. // resp, requestErr := http.Get(api)
  7084. // if requestErr != nil {
  7085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7086. // return
  7087. // }
  7088. // defer resp.Body.Close()
  7089. // body, ioErr := ioutil.ReadAll(resp.Body)
  7090. // if ioErr != nil {
  7091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. // return
  7094. // }
  7095. // var respJSON map[string]interface{}
  7096. //
  7097. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7098. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7100. // return
  7101. // }
  7102. //
  7103. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7104. // userJSONBytes, _ := json.Marshal(userJSON)
  7105. // var res ResultTwo
  7106. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7107. // utils.ErrorLog("解析失败:%v", err)
  7108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. // return
  7110. // }
  7111. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7112. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7113. // infoStr := string(Iinfos)
  7114. // idetinfoStr := string(Idetinfos)
  7115. //
  7116. // if res.Infcode == 0 {
  7117. // his := models.VMHisPatient{
  7118. // Status: 1,
  7119. // Ctime: time.Now().Unix(),
  7120. // Mtime: time.Now().Unix(),
  7121. // PsnNo: res.Output.Baseinfo.PsnNo,
  7122. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7123. // Certno: res.Output.Baseinfo.Certno,
  7124. // PsnName: res.Output.Baseinfo.PsnName,
  7125. // Gend: res.Output.Baseinfo.Gend,
  7126. // Naty: res.Output.Baseinfo.Naty,
  7127. // Brdy: res.Output.Baseinfo.Brdy,
  7128. // Age: res.Output.Baseinfo.Age,
  7129. // Iinfo: infoStr,
  7130. // Idetinfo: idetinfoStr,
  7131. // PatientId: patient.ID,
  7132. // RecordDate: theTime.Unix(),
  7133. // UserOrgId: adminInfo.CurrentOrgId,
  7134. // AdminUserId: adminInfo.AdminUser.Id,
  7135. // IsReturn: 1,
  7136. // }
  7137. //
  7138. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7139. // //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")
  7140. // //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")
  7141. //
  7142. // //var dat map[string]interface{}
  7143. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7144. // // fmt.Println(dat)
  7145. // //} else {
  7146. // // fmt.Println(err)
  7147. // //}
  7148. //
  7149. // var dat2 map[string]interface{}
  7150. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7151. // fmt.Println(dat2)
  7152. // } else {
  7153. // fmt.Println(err)
  7154. // }
  7155. //
  7156. // } else {
  7157. // adminUser := c.GetAdminUserInfo()
  7158. // errlog := &models.HisOrderError{
  7159. // UserOrgId: adminUser.CurrentOrgId,
  7160. // Ctime: time.Now().Unix(),
  7161. // Mtime: time.Now().Unix(),
  7162. // ErrMsg: res.ErrMsg,
  7163. // Status: 1,
  7164. // PatientId: id,
  7165. // RecordTime: recordDateTime,
  7166. // Stage: 1,
  7167. // }
  7168. // service.CreateErrMsgLog(errlog)
  7169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7170. // return
  7171. // }
  7172. // }
  7173. //
  7174. //}
  7175. //func (c *HisApiController) GetUploadDiag() {
  7176. // id, _ := c.GetInt64("id")
  7177. // record_time := c.GetString("record_time")
  7178. //
  7179. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7180. // sick_type, _ := c.GetInt64("sick_type")
  7181. // reg_type, _ := c.GetInt64("reg_type")
  7182. //
  7183. // timeLayout := "2006-01-02"
  7184. // loc, _ := time.LoadLocation("Local")
  7185. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7186. // if err != nil {
  7187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7188. // return
  7189. // }
  7190. //
  7191. // var patientPrescription models.HisPrescriptionInfo
  7192. // recordDateTime := theTime.Unix()
  7193. // adminInfo := c.GetAdminUserInfo()
  7194. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7195. //
  7196. // if patientPrescription.ID == 0 {
  7197. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7198. // }
  7199. //
  7200. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7201. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7202. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7203. // sickConfig, _ := service.FindSickById(sick_type)
  7204. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7205. //
  7206. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7207. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7208. // "&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 +
  7209. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7210. // resp2, requestErr2 := http.Get(api2)
  7211. // if requestErr2 != nil {
  7212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. // return
  7214. // }
  7215. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7216. // if ioErr2 != nil {
  7217. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7218. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. // return
  7220. // }
  7221. // var respJSON2 map[string]interface{}
  7222. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7223. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7225. // return
  7226. // }
  7227. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7228. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7229. //
  7230. // var res2 ResultSix
  7231. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7232. // utils.ErrorLog("解析失败:%v", err)
  7233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7234. // return
  7235. // }
  7236. // if res2.Infcode != 0 {
  7237. // adminUser := c.GetAdminUserInfo()
  7238. // errlog := &models.HisOrderError{
  7239. // UserOrgId: adminUser.CurrentOrgId,
  7240. // Ctime: time.Now().Unix(),
  7241. // Mtime: time.Now().Unix(),
  7242. // ErrMsg: res2.ErrMsg,
  7243. // Status: 1,
  7244. // PatientId: id,
  7245. // RecordTime: recordDateTime,
  7246. // Stage: 3,
  7247. // }
  7248. // service.CreateErrMsgLog(errlog)
  7249. //
  7250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7251. // return
  7252. // }
  7253. //
  7254. // c.ServeSuccessJSON(map[string]interface{}{
  7255. // "msg": "上传成功",
  7256. // })
  7257. //
  7258. //}
  7259. type QueryResult struct {
  7260. ID int64
  7261. Name string
  7262. Code string
  7263. List_type_code string
  7264. }
  7265. func (c *HisApiController) GetCheckCode() {
  7266. ids_str := c.GetString("ids")
  7267. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7268. ids_arr := strings.Split(ids_str, ",")
  7269. var queryResult []QueryResult
  7270. ids := make([]int64, 0)
  7271. for _, item := range ids_arr {
  7272. id, _ := strconv.ParseInt(item, 10, 64)
  7273. ids = append(ids, id)
  7274. }
  7275. if record_type == 1 {
  7276. drugs, _ := service.GetBatchDrugList(ids)
  7277. for _, item := range drugs {
  7278. result := QueryResult{
  7279. ID: item.ID,
  7280. Name: item.DrugName,
  7281. Code: item.MedicalInsuranceNumber,
  7282. List_type_code: "101",
  7283. }
  7284. queryResult = append(queryResult, result)
  7285. }
  7286. } else if record_type == 2 {
  7287. goods, _ := service.GetBatchGoodInformationList(ids)
  7288. for _, item := range goods {
  7289. result := QueryResult{
  7290. ID: item.ID,
  7291. Name: item.GoodName,
  7292. Code: item.MedicalInsuranceNumber,
  7293. List_type_code: "301",
  7294. }
  7295. queryResult = append(queryResult, result)
  7296. }
  7297. } else if record_type == 3 {
  7298. projects, _ := service.GetBathchMyPorjecgList(ids)
  7299. for _, item := range projects {
  7300. result := QueryResult{
  7301. ID: item.ID,
  7302. Name: item.ProjectName,
  7303. Code: item.MedicalCode,
  7304. List_type_code: "201",
  7305. }
  7306. queryResult = append(queryResult, result)
  7307. }
  7308. }
  7309. admin_user_id, _ := c.GetInt64("admin_user_id")
  7310. adminUser := c.GetAdminUserInfo()
  7311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7312. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7313. var user_name string
  7314. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7315. if role.ID == 0 {
  7316. user_name = "xxx"
  7317. } else {
  7318. user_name = role.UserName
  7319. }
  7320. baseParams := &models.BaseParams{
  7321. SecretKey: miConfig.SecretKey,
  7322. FixmedinsCode: miConfig.Code,
  7323. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7324. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7325. OrgName: miConfig.OrgName,
  7326. Doctor: user_name,
  7327. }
  7328. if config.IsOpen == 1 {
  7329. for _, item := range queryResult {
  7330. var result string
  7331. if record_type == 1 {
  7332. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7333. } else if record_type == 2 {
  7334. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7335. } else if record_type == 3 {
  7336. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7337. }
  7338. var dat map[string]interface{}
  7339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7340. fmt.Println(dat)
  7341. } else {
  7342. fmt.Println(err)
  7343. }
  7344. userJSONBytes, _ := json.Marshal(dat)
  7345. var res ResultSix
  7346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7347. utils.ErrorLog("解析失败:%v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. if res.Infcode == 0 {
  7352. if record_type == 1 {
  7353. service.UpdateBaseDrugById(item.ID)
  7354. } else if record_type == 2 {
  7355. service.UpdateGoodInformaitonByDetail(item.ID)
  7356. } else if record_type == 3 {
  7357. service.UpdateProjectById(item.ID)
  7358. }
  7359. c.ServeSuccessJSON(map[string]interface{}{
  7360. "failed_code": 0,
  7361. "msg": "目录对照成功",
  7362. })
  7363. } else {
  7364. c.ServeSuccessJSON(map[string]interface{}{
  7365. "failed_code": -10,
  7366. "msg": res.ErrMsg,
  7367. })
  7368. }
  7369. }
  7370. }
  7371. }
  7372. func (c *HisApiController) UnCheckCode() {
  7373. ids_str := c.GetString("ids")
  7374. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7375. admin_user_id, _ := c.GetInt64("admin_user_id")
  7376. ids_arr := strings.Split(ids_str, ",")
  7377. var queryResult []QueryResult
  7378. ids := make([]int64, 0)
  7379. for _, item := range ids_arr {
  7380. id, _ := strconv.ParseInt(item, 10, 64)
  7381. ids = append(ids, id)
  7382. }
  7383. if record_type == 1 {
  7384. drugs, _ := service.GetBatchDrugList(ids)
  7385. for _, item := range drugs {
  7386. result := QueryResult{
  7387. ID: item.ID,
  7388. Name: item.DrugName,
  7389. Code: item.MedicalInsuranceNumber,
  7390. List_type_code: "101",
  7391. }
  7392. queryResult = append(queryResult, result)
  7393. }
  7394. } else if record_type == 2 {
  7395. goods, _ := service.GetBatchGoodInformationList(ids)
  7396. for _, item := range goods {
  7397. result := QueryResult{
  7398. ID: item.ID,
  7399. Name: item.GoodName,
  7400. Code: item.MedicalInsuranceNumber,
  7401. List_type_code: "301",
  7402. }
  7403. queryResult = append(queryResult, result)
  7404. }
  7405. } else if record_type == 3 {
  7406. projects, _ := service.GetBathchMyPorjecgList(ids)
  7407. for _, item := range projects {
  7408. result := QueryResult{
  7409. ID: item.ID,
  7410. Name: item.ProjectName,
  7411. Code: item.MedicalCode,
  7412. List_type_code: "201",
  7413. }
  7414. queryResult = append(queryResult, result)
  7415. }
  7416. }
  7417. adminUser := c.GetAdminUserInfo()
  7418. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7419. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7420. var user_name string
  7421. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7422. if role.ID == 0 {
  7423. user_name = "xxx"
  7424. } else {
  7425. user_name = role.UserName
  7426. }
  7427. baseParams := &models.BaseParams{
  7428. SecretKey: miConfig.SecretKey,
  7429. FixmedinsCode: miConfig.Code,
  7430. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7431. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7432. OrgName: miConfig.OrgName,
  7433. Doctor: user_name,
  7434. }
  7435. if config.IsOpen == 1 {
  7436. for _, item := range queryResult {
  7437. var result string
  7438. if record_type == 1 {
  7439. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7440. } else if record_type == 2 {
  7441. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7442. } else if record_type == 3 {
  7443. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7444. }
  7445. var dat2 map[string]interface{}
  7446. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7447. fmt.Println(dat2)
  7448. } else {
  7449. fmt.Println(err)
  7450. }
  7451. userJSONBytes, _ := json.Marshal(dat2)
  7452. var res ResultSix
  7453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7454. utils.ErrorLog("解析失败:%v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. if res.Infcode == 0 {
  7459. if record_type == 1 {
  7460. service.UpdateDrugByIdDetail(item.ID)
  7461. } else if record_type == 2 {
  7462. service.UpdateGoodInfoById(item.ID)
  7463. } else if record_type == 3 {
  7464. service.UpdateMyProjectById(item.ID)
  7465. }
  7466. c.ServeSuccessJSON(map[string]interface{}{
  7467. "failed_code": 0,
  7468. "msg": "撤销目录对照成功",
  7469. })
  7470. } else {
  7471. c.ServeSuccessJSON(map[string]interface{}{
  7472. "failed_code": -10,
  7473. "msg": res.ErrMsg,
  7474. })
  7475. }
  7476. }
  7477. }
  7478. }
  7479. func (c *HisApiController) GetPatientInfo() {
  7480. id_card_no := c.GetString("id_card_no")
  7481. admin_user_id, _ := c.GetInt64("admin_user_id")
  7482. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7483. if patient.ID == 0 {
  7484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7485. return
  7486. }
  7487. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7488. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7489. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7490. if config.IsOpen == 1 {
  7491. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7492. var dat map[string]interface{}
  7493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7494. fmt.Println(dat)
  7495. } else {
  7496. fmt.Println(err)
  7497. }
  7498. userJSONBytes, _ := json.Marshal(dat)
  7499. var res ResultTwo
  7500. var res10265 ResultTwo10265
  7501. if miConfig.Code == "H15049901371" {
  7502. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7503. utils.ErrorLog("解析失败:%v", err)
  7504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. return
  7506. }
  7507. res.ErrMsg = res10265.ErrMsg
  7508. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7509. res.Infcode = infocode
  7510. res.Output = res10265.Output
  7511. res.InfRefmsgid = res10265.InfRefmsgid
  7512. } else {
  7513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7514. utils.ErrorLog("解析失败:%v", err)
  7515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7516. return
  7517. }
  7518. }
  7519. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7520. // utils.ErrorLog("解析失败:%v", err)
  7521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7522. // return
  7523. //}
  7524. if res.Infcode != 0 {
  7525. c.ServeSuccessJSON(map[string]interface{}{
  7526. "failed_code": -10,
  7527. "msg": res.ErrMsg,
  7528. })
  7529. } else {
  7530. c.ServeSuccessJSON(map[string]interface{}{
  7531. "failed_code": 0,
  7532. "info": res,
  7533. })
  7534. }
  7535. }
  7536. }
  7537. func (c *HisApiController) PsnPutOnRecord() {
  7538. record_type, _ := c.GetInt64("type")
  7539. patient_id, _ := c.GetInt64("patient_id")
  7540. admin_user_id, _ := c.GetInt64("admin_user_id")
  7541. start_time := c.GetString("start_time")
  7542. end_time := c.GetString("end_time")
  7543. adminUser := c.GetAdminUserInfo()
  7544. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7545. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7546. var patients []*models.Patients
  7547. if record_type == 1 { //全部备案
  7548. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7549. patients = append(patients, patient...)
  7550. } else { //单个备案
  7551. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7552. patients = append(patients, patient)
  7553. }
  7554. var user_name string
  7555. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7556. if role.ID == 0 {
  7557. user_name = "xxx"
  7558. } else {
  7559. user_name = role.UserName
  7560. }
  7561. if config.IsOpen == 1 {
  7562. for _, item := range patients {
  7563. 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
  7564. resp, requestErr := http.Get(api)
  7565. if requestErr != nil {
  7566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7567. return
  7568. }
  7569. defer resp.Body.Close()
  7570. body, ioErr := ioutil.ReadAll(resp.Body)
  7571. if ioErr != nil {
  7572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. var respJSON map[string]interface{}
  7577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. return
  7581. }
  7582. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7583. userJSONBytes, _ := json.Marshal(userJSON)
  7584. var res ResultTwo
  7585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7586. utils.ErrorLog("解析失败:%v", err)
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7588. return
  7589. }
  7590. if res.Infcode == 0 {
  7591. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7592. var dat map[string]interface{}
  7593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7594. fmt.Println(dat)
  7595. } else {
  7596. fmt.Println(err)
  7597. }
  7598. userJSONBytes, _ := json.Marshal(dat)
  7599. var res2 ResultThirteen
  7600. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7601. utils.ErrorLog("解析失败:%v", err)
  7602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7603. return
  7604. }
  7605. if res2.Infcode == 0 {
  7606. psnResult := &models.GdybPsnRecord{
  7607. UserOrgId: adminUser.CurrentOrgId,
  7608. PatientId: item.ID,
  7609. PsnNo: res.Output.Baseinfo.PsnNo,
  7610. Ctime: time.Now().Unix(),
  7611. Mtime: time.Now().Unix(),
  7612. Status: 1,
  7613. IsCancel: 1,
  7614. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7615. }
  7616. service.CreatePsnRecord(psnResult)
  7617. } else {
  7618. c.ServeSuccessJSON(map[string]interface{}{
  7619. "failed_code": -10,
  7620. "msg": res2.ErrMsg,
  7621. })
  7622. return
  7623. }
  7624. }
  7625. }
  7626. }
  7627. }
  7628. func (c *HisApiController) PsnUnPutOnRecord() {
  7629. id, _ := c.GetInt64("id")
  7630. //record_type, _ := c.GetInt64("type")
  7631. admin_user_id, _ := c.GetInt64("admin_user_id")
  7632. adminUser := c.GetAdminUserInfo()
  7633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7634. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7635. var user_name string
  7636. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7637. if role.ID == 0 {
  7638. user_name = "xxx"
  7639. } else {
  7640. user_name = role.UserName
  7641. }
  7642. psn_record, _ := service.GetPsnRecordById(id)
  7643. if psn_record.ID == 0 {
  7644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7645. return
  7646. }
  7647. if config.IsOpen == 1 {
  7648. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7649. var dat map[string]interface{}
  7650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7651. fmt.Println(dat)
  7652. } else {
  7653. fmt.Println(err)
  7654. }
  7655. userJSONBytes, _ := json.Marshal(dat)
  7656. var res ResultFourteen
  7657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7658. utils.ErrorLog("解析失败:%v", err)
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7660. return
  7661. }
  7662. if res.Infcode == 0 {
  7663. psn_record.IsCancel = 2
  7664. service.CreatePsnRecord(&psn_record)
  7665. } else {
  7666. c.ServeSuccessJSON(map[string]interface{}{
  7667. "failed_code": -10,
  7668. "msg": res.ErrMsg,
  7669. })
  7670. return
  7671. }
  7672. }
  7673. }
  7674. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7675. patient_id, _ := c.GetInt64("patient_id")
  7676. insutype_two := c.GetString("insutype")
  7677. psn_no := c.GetString("psn_no")
  7678. doctor_id, _ := c.GetInt64("doctor_id")
  7679. sick_id, _ := c.GetInt64("sick_id")
  7680. department_id, _ := c.GetInt64("department_id")
  7681. start_time := c.GetString("start_time")
  7682. end_time := c.GetString("end_time")
  7683. check_time := c.GetString("check_time")
  7684. adminUser := c.GetAdminUserInfo()
  7685. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7686. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7688. sick, _ := service.FindSickById(sick_id)
  7689. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7690. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7691. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7692. var res ResultTwo
  7693. var res10265 ResultTwo10265
  7694. if miConfig.Code == "H15049901371" {
  7695. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7696. utils.ErrorLog("解析失败:%v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. res.ErrMsg = res10265.ErrMsg
  7701. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7702. res.Infcode = infocode
  7703. res.Output = res10265.Output
  7704. res.InfRefmsgid = res10265.InfRefmsgid
  7705. } else {
  7706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7707. utils.ErrorLog("解析失败:%v", err)
  7708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7709. return
  7710. }
  7711. }
  7712. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7713. infoStr := string(Iinfos)
  7714. var rf []*ResultFive
  7715. json.Unmarshal([]byte(infoStr), &rf)
  7716. var insuplc_admdvs string
  7717. var insutype string
  7718. var is390 int = 0
  7719. var is310 int = 0
  7720. var insutypes []*ResultFive
  7721. for _, item := range rf {
  7722. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7723. insutypes = append(insutypes, item)
  7724. }
  7725. }
  7726. if len(insutypes) == 1 {
  7727. insutype = insutypes[0].Insutype
  7728. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7729. } else {
  7730. for _, i := range insutypes {
  7731. if i.Insutype == "390" {
  7732. is390 = 1
  7733. }
  7734. if i.Insutype == "310" {
  7735. is310 = 1
  7736. }
  7737. }
  7738. }
  7739. if is390 == 1 {
  7740. insutype = "390"
  7741. }
  7742. if is310 == 1 {
  7743. insutype = "310"
  7744. }
  7745. if len(insutypes) == 2 {
  7746. insutype = insutype_two
  7747. }
  7748. if len(insutypes) == 0 {
  7749. insutype = "310"
  7750. }
  7751. insutype = insutype_two
  7752. fmt.Println(insutype)
  7753. for _, item := range rf {
  7754. fmt.Println(item.Insutype)
  7755. fmt.Println(insutype)
  7756. if item.Insutype == insutype {
  7757. fmt.Println(item.Insutype)
  7758. fmt.Println(insutype)
  7759. insuplc_admdvs = item.InsuplcAdmdvs
  7760. }
  7761. }
  7762. fmt.Println(insuplc_admdvs)
  7763. if config.IsOpen == 1 {
  7764. 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)
  7765. var dat map[string]interface{}
  7766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7767. fmt.Println(dat)
  7768. } else {
  7769. fmt.Println(err)
  7770. }
  7771. userJSONBytes, _ := json.Marshal(dat)
  7772. var res2 ResultThirteen
  7773. var res10265 ResultThirteen10265
  7774. if miConfig.Code == "H15049901371" {
  7775. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7776. utils.ErrorLog("解析失败:%v", err)
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. return
  7779. }
  7780. res2.ErrMsg = res10265.ErrMsg
  7781. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7782. res2.Infcode = infocode
  7783. res2.Output = res10265.Output
  7784. res2.InfRefmsgid = res10265.InfRefmsgid
  7785. } else {
  7786. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7787. utils.ErrorLog("解析失败:%v", err)
  7788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7789. return
  7790. }
  7791. }
  7792. if res2.Infcode == 0 {
  7793. psnResult := &models.GdybPsnNcdsRecord{
  7794. UserOrgId: adminUser.CurrentOrgId,
  7795. PatientId: patient.ID,
  7796. PsnNo: psn_no,
  7797. DoctorId: doctor.AdminUserId,
  7798. DepartmentId: department_id,
  7799. SickType: sick_id,
  7800. Insutype: insutype,
  7801. Ctime: time.Now().Unix(),
  7802. Mtime: time.Now().Unix(),
  7803. Status: 1,
  7804. IsCancel: 1,
  7805. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7806. }
  7807. service.CreatePsnNCDSRecord(psnResult)
  7808. c.ServeSuccessJSON(map[string]interface{}{
  7809. "failed_code": 0,
  7810. "msg": "备案成功",
  7811. "result": psnResult,
  7812. })
  7813. } else {
  7814. c.ServeSuccessJSON(map[string]interface{}{
  7815. "failed_code": -10,
  7816. "msg": res2.ErrMsg,
  7817. })
  7818. return
  7819. }
  7820. }
  7821. }
  7822. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7823. id, _ := c.GetInt64("id")
  7824. admin_user_id, _ := c.GetInt64("admin_user_id")
  7825. adminUser := c.GetAdminUserInfo()
  7826. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7827. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7828. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7829. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7830. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7831. //var user_name string
  7832. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7833. //if role.ID == 0 {
  7834. // user_name = "xxx"
  7835. //} else {
  7836. // user_name = role.UserName
  7837. //}
  7838. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7839. if psn_record.ID == 0 {
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7841. return
  7842. }
  7843. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7844. var res ResultTwo
  7845. var res10265 ResultTwo10265
  7846. if miConfig.Code == "H15049901371" {
  7847. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7848. utils.ErrorLog("解析失败:%v", err)
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. res.ErrMsg = res10265.ErrMsg
  7853. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7854. res.Infcode = infocode
  7855. res.Output = res10265.Output
  7856. res.InfRefmsgid = res10265.InfRefmsgid
  7857. } else {
  7858. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7859. utils.ErrorLog("解析失败:%v", err)
  7860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7861. return
  7862. }
  7863. }
  7864. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7865. infoStr := string(Iinfos)
  7866. var rf []*ResultFive
  7867. json.Unmarshal([]byte(infoStr), &rf)
  7868. var insuplc_admdvs string
  7869. var insutype string
  7870. var is390 int = 0
  7871. var is310 int = 0
  7872. var insutypes []*ResultFive
  7873. for _, item := range rf {
  7874. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7875. insutypes = append(insutypes, item)
  7876. }
  7877. }
  7878. if len(insutypes) == 1 {
  7879. insutype = insutypes[0].Insutype
  7880. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7881. } else {
  7882. for _, i := range insutypes {
  7883. if i.Insutype == "390" {
  7884. is390 = 1
  7885. }
  7886. if i.Insutype == "310" {
  7887. is310 = 1
  7888. }
  7889. }
  7890. }
  7891. if is390 == 1 {
  7892. insutype = "390"
  7893. }
  7894. if is310 == 1 {
  7895. insutype = "310"
  7896. }
  7897. if len(insutypes) == 0 {
  7898. insutype = "310"
  7899. }
  7900. insutype = psn_record.Insutype
  7901. for _, item := range rf {
  7902. if item.Insutype == insutype {
  7903. insuplc_admdvs = item.InsuplcAdmdvs
  7904. }
  7905. }
  7906. if config.IsOpen == 1 {
  7907. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7908. var dat map[string]interface{}
  7909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7910. fmt.Println(dat)
  7911. } else {
  7912. fmt.Println(err)
  7913. }
  7914. userJSONBytes, _ := json.Marshal(dat)
  7915. var res ResultFourteen
  7916. var res10265 ResultFourteen10265
  7917. if miConfig.Code == "H15049901371" {
  7918. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7919. utils.ErrorLog("解析失败:%v", err)
  7920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7921. return
  7922. }
  7923. res.ErrMsg = res10265.ErrMsg
  7924. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7925. res.Infcode = infocode
  7926. res.Output = res10265.Output
  7927. res.InfRefmsgid = res10265.InfRefmsgid
  7928. } else {
  7929. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7930. utils.ErrorLog("解析失败:%v", err)
  7931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. return
  7933. }
  7934. }
  7935. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7936. // utils.ErrorLog("解析失败:%v", err)
  7937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7938. // return
  7939. //}
  7940. if res.Infcode == 0 {
  7941. psn_record.IsCancel = 2
  7942. service.CreatePsnNCDSRecord(&psn_record)
  7943. c.ServeSuccessJSON(map[string]interface{}{
  7944. "failed_code": 0,
  7945. "msg": "撤销备案成功",
  7946. })
  7947. } else {
  7948. c.ServeSuccessJSON(map[string]interface{}{
  7949. "failed_code": -10,
  7950. "msg": res.ErrMsg,
  7951. })
  7952. return
  7953. }
  7954. }
  7955. }
  7956. func (c *HisApiController) TestTest() {
  7957. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  7958. fmt.Println(patient.Iinfo)
  7959. }
  7960. type CustomData struct {
  7961. MsgId string
  7962. PsnNo string
  7963. Info string
  7964. }
  7965. func (c *HisApiController) ReversalData() {
  7966. var customData []*CustomData
  7967. custom := &CustomData{
  7968. MsgId: "H44022900158202103301714472004",
  7969. PsnNo: "44020000001101329945",
  7970. Info: "2207",
  7971. }
  7972. customData = append(customData, custom)
  7973. custom1 := &CustomData{
  7974. MsgId: "H4402290015820210330172057803",
  7975. PsnNo: "44020000001101161813",
  7976. Info: "2207",
  7977. }
  7978. customData = append(customData, custom1)
  7979. custom2 := &CustomData{
  7980. MsgId: "H44022900158202103301705198813",
  7981. PsnNo: "44190000133097375417",
  7982. Info: "2207",
  7983. }
  7984. customData = append(customData, custom2)
  7985. custom3 := &CustomData{
  7986. MsgId: "H44022900158202103301715524756",
  7987. PsnNo: "44020000001100187221",
  7988. Info: "2207",
  7989. }
  7990. customData = append(customData, custom3)
  7991. custom4 := &CustomData{
  7992. MsgId: "H44022900158202103301730376224",
  7993. PsnNo: "44020000001101959155",
  7994. Info: "2207",
  7995. }
  7996. customData = append(customData, custom4)
  7997. custom5 := &CustomData{
  7998. MsgId: "H44022900158202103301748008725",
  7999. PsnNo: "44020000001104246641",
  8000. Info: "2207",
  8001. }
  8002. customData = append(customData, custom5)
  8003. custom6 := &CustomData{
  8004. MsgId: "H44022900158202103301718096755",
  8005. PsnNo: "44020000001102211860",
  8006. Info: "2207",
  8007. }
  8008. customData = append(customData, custom6)
  8009. custom7 := &CustomData{
  8010. MsgId: "H44022900158202103301736551640",
  8011. PsnNo: "44020000001102687718",
  8012. Info: "2207",
  8013. }
  8014. customData = append(customData, custom7)
  8015. custom8 := &CustomData{
  8016. MsgId: "H44022900158202103301743097676",
  8017. PsnNo: "44020000001102127785",
  8018. Info: "2207",
  8019. }
  8020. customData = append(customData, custom8)
  8021. custom9 := &CustomData{
  8022. MsgId: "H44022900158202103301712304203",
  8023. PsnNo: "44020000001101518097",
  8024. Info: "2207",
  8025. }
  8026. customData = append(customData, custom9)
  8027. custom10 := &CustomData{
  8028. MsgId: "H44022900158202103301738448785",
  8029. PsnNo: "44020000001100500813",
  8030. Info: "2207",
  8031. }
  8032. customData = append(customData, custom10)
  8033. custom11 := &CustomData{
  8034. MsgId: "H44022900158202103301732455843",
  8035. PsnNo: "44020000001102690557",
  8036. Info: "2207",
  8037. }
  8038. customData = append(customData, custom11)
  8039. custom12 := &CustomData{
  8040. MsgId: "H44022900158202103301745421708",
  8041. PsnNo: "44020000001102211928",
  8042. Info: "2207",
  8043. }
  8044. customData = append(customData, custom12)
  8045. custom1212 := &CustomData{
  8046. MsgId: "H440229001582021033017351627",
  8047. PsnNo: "44020000001102481733",
  8048. Info: "2207",
  8049. }
  8050. customData = append(customData, custom1212)
  8051. custom13 := &CustomData{
  8052. MsgId: "H44022900158202103301740327951",
  8053. PsnNo: "44020000001103174866",
  8054. Info: "2207",
  8055. }
  8056. customData = append(customData, custom13)
  8057. custom14 := &CustomData{
  8058. MsgId: "H4402290015820210330174922668",
  8059. PsnNo: "44020000001102927272",
  8060. Info: "2207",
  8061. }
  8062. customData = append(customData, custom14)
  8063. custom15 := &CustomData{
  8064. MsgId: "H44022900158202103301752362273",
  8065. PsnNo: "44020000001102942890",
  8066. Info: "2207",
  8067. }
  8068. customData = append(customData, custom15)
  8069. custom16 := &CustomData{
  8070. MsgId: "H44022900158202103301751082917",
  8071. PsnNo: "44020000001101662162",
  8072. Info: "2207",
  8073. }
  8074. customData = append(customData, custom16)
  8075. custom17 := &CustomData{
  8076. MsgId: "H44022900158202103301754147728",
  8077. PsnNo: "44020000000229014511",
  8078. Info: "2207",
  8079. }
  8080. customData = append(customData, custom17)
  8081. adminUser := c.GetAdminUserInfo()
  8082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8083. for _, item := range customData {
  8084. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8085. fmt.Println(result)
  8086. }
  8087. }
  8088. func (c *HisApiController) ReversalOtherData() {
  8089. var customData []*CustomData
  8090. custom := &CustomData{
  8091. MsgId: "H44022900158202103301714472004",
  8092. PsnNo: "44020000001101329945",
  8093. Info: "2208",
  8094. }
  8095. customData = append(customData, custom)
  8096. custom1 := &CustomData{
  8097. MsgId: "H4402290015820210330172057803",
  8098. PsnNo: "44020000001101161813",
  8099. Info: "2208",
  8100. }
  8101. customData = append(customData, custom1)
  8102. custom2 := &CustomData{
  8103. MsgId: "H44022900158202103301705198813",
  8104. PsnNo: "44190000133097375417",
  8105. Info: "2208",
  8106. }
  8107. customData = append(customData, custom2)
  8108. custom3 := &CustomData{
  8109. MsgId: "H44022900158202103301715524756",
  8110. PsnNo: "44020000001100187221",
  8111. Info: "2208",
  8112. }
  8113. customData = append(customData, custom3)
  8114. custom4 := &CustomData{
  8115. MsgId: "H44022900158202103301730376224",
  8116. PsnNo: "44020000001101959155",
  8117. Info: "2208",
  8118. }
  8119. customData = append(customData, custom4)
  8120. custom5 := &CustomData{
  8121. MsgId: "H44022900158202103301748008725",
  8122. PsnNo: "44020000001104246641",
  8123. Info: "2208",
  8124. }
  8125. customData = append(customData, custom5)
  8126. custom6 := &CustomData{
  8127. MsgId: "H44022900158202103301718096755",
  8128. PsnNo: "44020000001102211860",
  8129. Info: "2208",
  8130. }
  8131. customData = append(customData, custom6)
  8132. custom7 := &CustomData{
  8133. MsgId: "H44022900158202103301736551640",
  8134. PsnNo: "44020000001102687718",
  8135. Info: "2208",
  8136. }
  8137. customData = append(customData, custom7)
  8138. custom8 := &CustomData{
  8139. MsgId: "H44022900158202103301743097676",
  8140. PsnNo: "44020000001102127785",
  8141. Info: "2208",
  8142. }
  8143. customData = append(customData, custom8)
  8144. custom9 := &CustomData{
  8145. MsgId: "H44022900158202103301712304203",
  8146. PsnNo: "44020000001101518097",
  8147. Info: "2208",
  8148. }
  8149. customData = append(customData, custom9)
  8150. custom10 := &CustomData{
  8151. MsgId: "H44022900158202103301738448785",
  8152. PsnNo: "44020000001100500813",
  8153. Info: "2208",
  8154. }
  8155. customData = append(customData, custom10)
  8156. custom11 := &CustomData{
  8157. MsgId: "H44022900158202103301732455843",
  8158. PsnNo: "44020000001102690557",
  8159. Info: "2208",
  8160. }
  8161. customData = append(customData, custom11)
  8162. custom12 := &CustomData{
  8163. MsgId: "H44022900158202103301745421708",
  8164. PsnNo: "44020000001102211928",
  8165. Info: "2208",
  8166. }
  8167. customData = append(customData, custom12)
  8168. custom1212 := &CustomData{
  8169. MsgId: "H440229001582021033017351627",
  8170. PsnNo: "44020000001102481733",
  8171. Info: "2208",
  8172. }
  8173. customData = append(customData, custom1212)
  8174. custom13 := &CustomData{
  8175. MsgId: "H44022900158202103301740327951",
  8176. PsnNo: "44020000001103174866",
  8177. Info: "2208",
  8178. }
  8179. customData = append(customData, custom13)
  8180. custom14 := &CustomData{
  8181. MsgId: "H4402290015820210330174922668",
  8182. PsnNo: "44020000001102927272",
  8183. Info: "2208",
  8184. }
  8185. customData = append(customData, custom14)
  8186. custom15 := &CustomData{
  8187. MsgId: "H44022900158202103301752362273",
  8188. PsnNo: "44020000001102942890",
  8189. Info: "2208",
  8190. }
  8191. customData = append(customData, custom15)
  8192. custom16 := &CustomData{
  8193. MsgId: "H44022900158202103301751082917",
  8194. PsnNo: "44020000001101662162",
  8195. Info: "2208",
  8196. }
  8197. customData = append(customData, custom16)
  8198. custom17 := &CustomData{
  8199. MsgId: "H44022900158202103301754147728",
  8200. PsnNo: "44020000000229014511",
  8201. Info: "2208",
  8202. }
  8203. customData = append(customData, custom17)
  8204. adminUser := c.GetAdminUserInfo()
  8205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8206. for _, item := range customData {
  8207. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8208. fmt.Println(result)
  8209. }
  8210. }
  8211. func PathExists(path string) (bool, error) {
  8212. _, err := os.Stat(path)
  8213. if err == nil {
  8214. return true, nil
  8215. }
  8216. if os.IsNotExist(err) {
  8217. return false, nil
  8218. }
  8219. return false, err
  8220. }
  8221. //创建文件夹
  8222. func Mkdir(dir string) {
  8223. // 创建文件夹
  8224. exist, err := PathExists(dir)
  8225. if err != nil {
  8226. fmt.Println(err.Error())
  8227. } else {
  8228. if exist {
  8229. fmt.Println(dir + "文件夹已存在!")
  8230. } else {
  8231. // 文件夹名称,权限
  8232. err := os.Mkdir(dir, os.ModePerm)
  8233. if err != nil {
  8234. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8235. } else {
  8236. fmt.Println(dir + "文件夹创建成功!")
  8237. }
  8238. }
  8239. }
  8240. }
  8241. //压缩文件
  8242. func Zip(srcFile string, destZip string) error {
  8243. zipfile, err := os.Create(destZip)
  8244. if err != nil {
  8245. return err
  8246. }
  8247. defer zipfile.Close()
  8248. archive := zip.NewWriter(zipfile)
  8249. defer archive.Close()
  8250. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8251. if err != nil {
  8252. return err
  8253. }
  8254. header, err := zip.FileInfoHeader(info)
  8255. if err != nil {
  8256. return err
  8257. }
  8258. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8259. // header.Name = path
  8260. if info.IsDir() {
  8261. header.Name += "/"
  8262. } else {
  8263. header.Method = zip.Deflate
  8264. }
  8265. writer, err := archive.CreateHeader(header)
  8266. if err != nil {
  8267. return err
  8268. }
  8269. if !info.IsDir() {
  8270. file, err := os.Open(path)
  8271. if err != nil {
  8272. return err
  8273. }
  8274. defer file.Close()
  8275. _, err = io.Copy(writer, file)
  8276. }
  8277. return err
  8278. })
  8279. return err
  8280. }
  8281. func ReadFile(filePath string) []byte {
  8282. f, err := os.Open(filePath)
  8283. if err != nil {
  8284. fmt.Println("read file fail", err)
  8285. return nil
  8286. }
  8287. defer f.Close()
  8288. fd, err := ioutil.ReadAll(f)
  8289. if err != nil {
  8290. fmt.Println("read to fd fail", err)
  8291. return nil
  8292. }
  8293. return fd
  8294. }
  8295. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  8296. newArr = make([]*models.HisOrderInfo, 0)
  8297. for i := 0; i < len(arr); i++ {
  8298. repeat := false
  8299. for j := i + 1; j < len(arr); j++ {
  8300. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  8301. repeat = true
  8302. break
  8303. }
  8304. }
  8305. if !repeat {
  8306. newArr = append(newArr, arr[i])
  8307. }
  8308. }
  8309. return
  8310. }
  8311. func saveRegisterLog(result string) {
  8312. org_id, _ := beego.AppConfig.Int64("org_id")
  8313. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8314. dir := miConfig.OrgName + "日志"
  8315. utils.Mkdir(dir)
  8316. month := time.Unix(1557042972, 0).Format("1")
  8317. year := time.Now().Format("2006")
  8318. month = time.Now().Format("01")
  8319. day := time.Now().Format("02")
  8320. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8321. file_name := file + ".txt"
  8322. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8323. exist, _ := utils.PathExists(file_path)
  8324. if exist { //存在
  8325. fmt.Println("存在")
  8326. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8327. if err != nil {
  8328. fmt.Println("read fail")
  8329. }
  8330. content := "\r\n" + result
  8331. n, _ := f.Seek(0, 2)
  8332. _, err = f.WriteAt([]byte(content), n)
  8333. } else { //不存在
  8334. fmt.Println("文件不存在,创建文件")
  8335. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8336. defer f.Close()
  8337. if err != nil {
  8338. } else {
  8339. _, err = f.Write([]byte("记录日志"))
  8340. }
  8341. }
  8342. }
  8343. func saveLog(result string, request string, infno string, desc string) {
  8344. org_id, _ := beego.AppConfig.Int64("org_id")
  8345. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8346. dir := miConfig.OrgName + "日志"
  8347. utils.Mkdir(dir)
  8348. month := time.Unix(1557042972, 0).Format("1")
  8349. year := time.Now().Format("2006")
  8350. month = time.Now().Format("01")
  8351. day := time.Now().Format("02")
  8352. hour := time.Now().Format("15")
  8353. min := time.Now().Format("04")
  8354. sec := time.Now().Format("05")
  8355. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8356. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8357. file_name := file + ".txt"
  8358. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8359. exist, _ := utils.PathExists(file_path)
  8360. if exist { //存在
  8361. fmt.Println("存在")
  8362. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8363. if err != nil {
  8364. fmt.Println("read fail")
  8365. }
  8366. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8367. n, _ := f.Seek(0, 2)
  8368. _, err = f.WriteAt([]byte(content), n)
  8369. } else { //不存在
  8370. fmt.Println("文件不存在,创建文件")
  8371. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8372. defer f.Close()
  8373. if err != nil {
  8374. } else {
  8375. _, err = f.Write([]byte("记录日志"))
  8376. }
  8377. }
  8378. }
  8379. type Charset string
  8380. const (
  8381. UTF8 = Charset("UTF-8")
  8382. GB18030 = Charset("GB18030")
  8383. )
  8384. func ConvertToString(src string, srcCode string, tagCode string) string {
  8385. srcCoder := mahonia.NewDecoder(srcCode)
  8386. srcResult := srcCoder.ConvertString(src)
  8387. tagCoder := mahonia.NewDecoder(tagCode)
  8388. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8389. result := string(cdata)
  8390. return result
  8391. }