his_api_controller.go 334KB

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