his_api_controller.go 303KB

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