his_api_controller.go 337KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372
  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. id_card := c.GetString("id_card")
  2617. register_type, _ := c.GetInt64("register")
  2618. doctor, _ := c.GetInt64("doctor")
  2619. department, _ := c.GetInt64("department")
  2620. gender, _ := c.GetInt64("sex")
  2621. registration_fee, _ := c.GetFloat("registration_fee")
  2622. medical_expenses, _ := c.GetFloat("medical_expenses")
  2623. social_type, _ := c.GetInt64("social_type")
  2624. med_type := c.GetString("social_type")
  2625. admin_user_id, _ := c.GetInt64("admin_user_id")
  2626. timeLayout := "2006-01-02"
  2627. loc, _ := time.LoadLocation("Local")
  2628. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2629. birthUnix := birthdays.Unix()
  2630. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2631. if err != nil {
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2633. return
  2634. }
  2635. recordDateTime := theTime.Unix()
  2636. adminInfo := c.GetAdminUserInfo()
  2637. var patient service.Patients
  2638. if id == 0 {
  2639. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2640. } else {
  2641. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2642. }
  2643. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2644. if patientPrescription.ID == 0 {
  2645. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2646. }
  2647. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2648. if patient.ID == 0 {
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2650. return
  2651. }
  2652. if len(patient.IdCardNo) == 0 {
  2653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2654. return
  2655. }
  2656. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2657. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2658. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2659. //就诊结算未完成,不能进行二次挂号
  2660. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2661. if len(his) >= 1 {
  2662. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2663. if len(his) >= 1 && order.ID == 0 {
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2665. return
  2666. }
  2667. }
  2668. //var register_log string
  2669. if config.IsOpen == 1 {
  2670. var res ResultTwo
  2671. var res10265 ResultTwo10265
  2672. var PsnNo string
  2673. var PsnCertType string
  2674. var Certno string
  2675. var PsnName string
  2676. var Gend string
  2677. var Naty string
  2678. var Brdy string
  2679. var Age float64
  2680. var infoStr string
  2681. var idetinfoStr string
  2682. var infocode int64
  2683. var verify_number string
  2684. if miConfig.MdtrtareaAdmvs == "421300" {
  2685. psn_info, _ := service.GetPsnByPatientId(id)
  2686. PsnNo = psn_info.PsnNo
  2687. PsnCertType = psn_info.PsnCertType
  2688. Certno = psn_info.Certno
  2689. PsnName = psn_info.PsnName
  2690. Gend = psn_info.Gend
  2691. Naty = psn_info.Naty
  2692. Brdy = psn_info.Brdy
  2693. Age = psn_info.Age
  2694. infoStr = psn_info.Insuinfo
  2695. idetinfoStr = psn_info.Idetinfo
  2696. infocode = 0
  2697. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2698. psn_info, _ := service.GetPsnByPatientId(id)
  2699. PsnNo = psn_info.PsnNo
  2700. PsnCertType = psn_info.PsnCertType
  2701. Certno = psn_info.Certno
  2702. PsnName = psn_info.PsnName
  2703. Gend = psn_info.Gend
  2704. Naty = psn_info.Naty
  2705. Brdy = psn_info.Brdy
  2706. Age = psn_info.Age
  2707. infoStr = psn_info.Insuinfo
  2708. idetinfoStr = psn_info.Idetinfo
  2709. infocode = 0
  2710. verify_number = psn_info.VerifyNumber
  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 + "&verify_number" + verify_number
  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, &ressix10265); err != nil {
  3168. utils.ErrorLog("解析失败:%v", err)
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3170. return
  3171. }
  3172. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3173. res2.Output = ressix10265.Output
  3174. res2.ErrMsg = ressix10265.ErrMsg
  3175. res2.Cainfo = ressix10265.Cainfo
  3176. res2.WarnMsg = ressix10265.WarnMsg
  3177. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3178. res2.Infcode = infocode
  3179. } else {
  3180. if miConfig.MdtrtareaAdmvs == "440781" { //
  3181. 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)
  3182. } else {
  3183. if miConfig.Code == "H15049901371" {
  3184. //赤峰地区国家医保医疗类别
  3185. //职工透析:医疗类别选特殊情况门诊990502
  3186. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3187. var med_type string
  3188. if his.Insutype == "390" {
  3189. if reg_type == 14 {
  3190. med_type = "9933"
  3191. } else if reg_type == 11 {
  3192. med_type = "11"
  3193. }
  3194. } else if his.Insutype == "310" {
  3195. if reg_type == 14 {
  3196. med_type = "990502"
  3197. } else if reg_type == 11 {
  3198. med_type = "11"
  3199. }
  3200. }
  3201. 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)
  3202. } else {
  3203. 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)
  3204. }
  3205. }
  3206. saveLog(result, requestLog, "2203", "上传就诊信息")
  3207. var respJSON2 map[string]interface{}
  3208. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3211. return
  3212. }
  3213. userJSONBytes2, _ := json.Marshal(respJSON2)
  3214. if miConfig.Code == "H15049901371" {
  3215. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3216. utils.ErrorLog("解析失败:%v", err)
  3217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. return
  3219. }
  3220. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3221. res2.Output = ressix10265.Output
  3222. res2.ErrMsg = ressix10265.ErrMsg
  3223. res2.Cainfo = ressix10265.Cainfo
  3224. res2.WarnMsg = ressix10265.WarnMsg
  3225. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3226. res2.Infcode = infocode
  3227. } else {
  3228. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3229. utils.ErrorLog("解析失败:%v", err)
  3230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3231. return
  3232. }
  3233. }
  3234. }
  3235. if res2.Infcode != 0 {
  3236. adminUser := c.GetAdminUserInfo()
  3237. errlog := &models.HisOrderError{
  3238. UserOrgId: adminUser.CurrentOrgId,
  3239. Ctime: time.Now().Unix(),
  3240. Mtime: time.Now().Unix(),
  3241. ErrMsg: res2.ErrMsg,
  3242. Status: 1,
  3243. PatientId: id,
  3244. RecordTime: recordDateTime,
  3245. Stage: 3,
  3246. }
  3247. service.CreateErrMsgLog(errlog)
  3248. c.ServeSuccessJSON(map[string]interface{}{
  3249. "failed_code": -10,
  3250. "msg": res2.ErrMsg,
  3251. })
  3252. return
  3253. } else {
  3254. his.Diagnosis = diagnosis_id
  3255. his.SickType = sickConfig.ID
  3256. var p_type int64
  3257. if reg_type == 1111 || reg_type == 1112 {
  3258. p_type = 11
  3259. }
  3260. his.PType = fmt.Sprintf("%d", p_type)
  3261. service.UpdateHisPatientThree(&his)
  3262. data := make(map[string]interface{})
  3263. if settle_accounts_type == 1 { //日结
  3264. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3265. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3266. } else {
  3267. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3268. }
  3269. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3270. data["pre"] = prescriptions
  3271. } else { //月结
  3272. start_time_str := c.GetString("start_time")
  3273. end_time_str := c.GetString("end_time")
  3274. timeLayout := "2006-01-02"
  3275. loc, _ := time.LoadLocation("Local")
  3276. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3277. if err != nil {
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3279. return
  3280. }
  3281. recordStartTime := theStartTime.Unix()
  3282. start_time = recordStartTime
  3283. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3284. if err != nil {
  3285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3286. return
  3287. }
  3288. recordEndTime := theEndTime.Unix()
  3289. end_time = recordEndTime
  3290. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3291. data["pre"] = prescriptions
  3292. }
  3293. timestamp := time.Now().Unix()
  3294. tempTime := time.Unix(timestamp, 0)
  3295. timeFormat := tempTime.Format("20060102150405")
  3296. chrgBchno := rand.Intn(100000) + 10000
  3297. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3298. strconv.FormatInt(his.PatientId, 10)
  3299. client := &http.Client{}
  3300. data["psn_no"] = his.PsnNo
  3301. data["mdtrt_id"] = his.Number
  3302. data["chrg_bchno"] = chrg_bchno
  3303. data["org_name"] = miConfig.OrgName
  3304. data["doctor"] = roles.UserName
  3305. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3306. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3307. data["fixmedins_code"] = miConfig.Code
  3308. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3309. data["dept_code"] = "15"
  3310. } else {
  3311. data["dept_code"] = department.Number
  3312. }
  3313. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3314. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3315. data["secret_key"] = miConfig.SecretKey
  3316. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3317. data["url"] = miConfig.Url
  3318. data["ak"] = miConfig.ChannelNumber
  3319. data["new_doctor_name"] = patientPrescription.Doctor
  3320. var ids []int64
  3321. for _, item := range prescriptions {
  3322. ids = append(ids, item.ID)
  3323. }
  3324. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3325. if config.IsOpen == 1 { //对接了医保,走医保流程
  3326. var res ResultFour
  3327. var resFour10265 ResultFour10265
  3328. if miConfig.MdtrtareaAdmvs == "421300" {
  3329. bytesData, _ := json.Marshal(data)
  3330. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3331. resp, _ := client.Do(req)
  3332. defer resp.Body.Close()
  3333. body, ioErr := ioutil.ReadAll(resp.Body)
  3334. if ioErr != nil {
  3335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3337. return
  3338. }
  3339. var respJSON map[string]interface{}
  3340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3346. userJSONBytes, _ := json.Marshal(respJSON)
  3347. fmt.Println("log")
  3348. fmt.Println(string(userJSONBytes))
  3349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3350. utils.ErrorLog("解析失败:%v", err)
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3352. return
  3353. }
  3354. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3355. bytesData, _ := json.Marshal(data)
  3356. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3357. resp, _ := client.Do(req)
  3358. defer resp.Body.Close()
  3359. body, ioErr := ioutil.ReadAll(resp.Body)
  3360. if ioErr != nil {
  3361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3363. return
  3364. }
  3365. var respJSON map[string]interface{}
  3366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3369. return
  3370. }
  3371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3372. userJSONBytes, _ := json.Marshal(respJSON)
  3373. fmt.Println("log")
  3374. fmt.Println(string(userJSONBytes))
  3375. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3376. utils.ErrorLog("解析失败:%v", err)
  3377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3378. return
  3379. }
  3380. res.InfRefmsgid = resFour10265.InfRefmsgid
  3381. res.Output = resFour10265.Output
  3382. res.ErrMsg = resFour10265.ErrMsg
  3383. res.Cainfo = resFour10265.Cainfo
  3384. res.WarnMsg = resFour10265.WarnMsg
  3385. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3386. res.Infcode = infocode
  3387. } else {
  3388. if miConfig.Code == "H15049901371" {
  3389. 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)
  3390. var dat map[string]interface{}
  3391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3392. fmt.Println(dat)
  3393. } else {
  3394. fmt.Println(err)
  3395. }
  3396. saveLog(result, request_log, "2204", "上传费用明细")
  3397. userJSONBytes, _ := json.Marshal(dat)
  3398. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3399. utils.ErrorLog("解析失败:%v", err)
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. res.InfRefmsgid = resFour10265.InfRefmsgid
  3404. res.Output = resFour10265.Output
  3405. res.ErrMsg = resFour10265.ErrMsg
  3406. res.Cainfo = resFour10265.Cainfo
  3407. res.WarnMsg = resFour10265.WarnMsg
  3408. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3409. res.Infcode = infocode
  3410. } else {
  3411. 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)
  3412. var dat map[string]interface{}
  3413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3414. fmt.Println(dat)
  3415. } else {
  3416. fmt.Println(err)
  3417. }
  3418. saveLog(result, request_log, "2204", "上传费用明细")
  3419. userJSONBytes, _ := json.Marshal(dat)
  3420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3421. utils.ErrorLog("解析失败:%v", err)
  3422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3423. return
  3424. }
  3425. }
  3426. }
  3427. if res.Infcode == 0 {
  3428. order := &models.HisOrder{
  3429. UserOrgId: adminUser.CurrentOrgId,
  3430. HisPatientId: his.ID,
  3431. PatientId: his.PatientId,
  3432. SettleAccountsDate: recordDateTime,
  3433. Ctime: time.Now().Unix(),
  3434. Mtime: time.Now().Unix(),
  3435. Status: 1,
  3436. Number: chrg_bchno,
  3437. Infcode: res.Infcode,
  3438. WarnMsg: res.WarnMsg,
  3439. Cainfo: res.Cainfo,
  3440. ErrMsg: res.ErrMsg,
  3441. RespondTime: res.RefmsgTime,
  3442. InfRefmsgid: res.InfRefmsgid,
  3443. OrderStatus: 1,
  3444. PayWay: pay_way,
  3445. PayPrice: pay_price,
  3446. PayCardNo: pay_card_no,
  3447. DiscountPrice: discount_price,
  3448. PreferentialPrice: preferential_price,
  3449. RealityPrice: reality_price,
  3450. FoundPrice: found_price,
  3451. MedicalInsurancePrice: medical_insurance_price,
  3452. PrivatePrice: private_price,
  3453. IsMedicineInsurance: 1,
  3454. SettleType: settle_accounts_type,
  3455. SettleStartTime: start_time,
  3456. SettleEndTime: end_time,
  3457. Creator: roles.AdminUserId,
  3458. Modify: roles.AdminUserId,
  3459. FaPiaoNumber: fapiao_number,
  3460. FaPiaoCode: fapiao_code,
  3461. PType: 2,
  3462. Diagnosis: diagnosis_id,
  3463. }
  3464. err = service.CreateOrder(order)
  3465. if err != nil {
  3466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3467. return
  3468. }
  3469. for _, item := range res.Output.Result {
  3470. temp := strings.Split(item.FeedetlSn, "-")
  3471. var advice_id int64 = 0
  3472. var project_id int64 = 0
  3473. var types int64 = 0
  3474. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3475. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3476. if temp[1] == "1" {
  3477. advice_id = id
  3478. project_id = 0
  3479. } else if temp[1] == "2" {
  3480. advice_id = 0
  3481. project_id = id
  3482. }
  3483. info := &models.HisOrderInfo{
  3484. OrderNumber: order.Number,
  3485. FeedetlSn: item.FeedetlSn,
  3486. UploadDate: time.Now().Unix(),
  3487. AdviceId: advice_id,
  3488. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3489. Cnt: item.Cnt,
  3490. Pric: float64(item.Pric),
  3491. PatientId: his.PatientId,
  3492. PricUplmtAmt: item.PricUplmtAmt,
  3493. SelfpayProp: item.SelfpayProp,
  3494. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3495. OverlmtAmt: item.OverlmtAmt,
  3496. PreselfpayAmt: item.PreselfpayAmt,
  3497. BasMednFlag: item.BasMednFlag,
  3498. MedChrgitmType: item.MedChrgitmType,
  3499. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3500. Status: 1,
  3501. Memo: item.Memo,
  3502. Mtime: time.Now().Unix(),
  3503. InscpScpAmt: item.InscpScpAmt,
  3504. DrtReimFlag: item.DrtReimFlag,
  3505. Ctime: time.Now().Unix(),
  3506. ListSpItemFlag: item.ListSpItemFlag,
  3507. ChldMedcFlag: item.ChldMedcFlag,
  3508. LmtUsedFlag: item.LmtUsedFlag,
  3509. ChrgitmLv: item.ChrgitmLv,
  3510. UserOrgId: adminUser.CurrentOrgId,
  3511. HisPatientId: his.ID,
  3512. OrderId: order.ID,
  3513. ProjectId: project_id,
  3514. Type: types,
  3515. }
  3516. service.CreateOrderInfo(info)
  3517. }
  3518. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3519. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3520. var total float64
  3521. for _, item := range prescriptions {
  3522. if item.Type == 1 { //药品
  3523. for _, subItem := range item.HisDoctorAdviceInfo {
  3524. total = total + (subItem.Price * subItem.PrescribingNumber)
  3525. }
  3526. }
  3527. if item.Type == 2 { //项目
  3528. for _, subItem := range item.HisPrescriptionProject {
  3529. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3530. total = total + (subItem.Price * cnt)
  3531. }
  3532. }
  3533. }
  3534. for _, item := range prescriptions {
  3535. for _, subItem := range item.HisAdditionalCharge {
  3536. total = total + (subItem.Price * float64(subItem.Count))
  3537. }
  3538. }
  3539. var allTotal string
  3540. if adminUser.CurrentOrgId == 9919 {
  3541. allTotal = fmt.Sprintf("%.4f", total)
  3542. } else {
  3543. allTotal = fmt.Sprintf("%.4f", total)
  3544. }
  3545. if res.Infcode == 0 {
  3546. var rf []*ResultFive
  3547. json.Unmarshal([]byte(his.Iinfo), &rf)
  3548. chrg_bchno := chrg_bchno
  3549. cert_no := his.Certno
  3550. var insutypes []string
  3551. var insutype string
  3552. var is390 int = 0
  3553. var is310 int = 0
  3554. for _, item := range rf {
  3555. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3556. insutypes = append(insutypes, item.Insutype)
  3557. }
  3558. }
  3559. if len(insutypes) == 1 {
  3560. insutype = insutypes[0]
  3561. } else {
  3562. for _, i := range insutypes {
  3563. if i == "390" {
  3564. is390 = 1
  3565. }
  3566. if i == "310" {
  3567. is310 = 1
  3568. }
  3569. }
  3570. }
  3571. if is390 == 1 {
  3572. insutype = "390"
  3573. }
  3574. if is310 == 1 {
  3575. insutype = "310"
  3576. }
  3577. if len(insutypes) == 0 {
  3578. insutype = "310"
  3579. }
  3580. if len(insutypes) == 2 {
  3581. insutype = strconv.FormatInt(his.SocialType, 10)
  3582. }
  3583. insutype = strconv.FormatInt(his.SocialType, 10)
  3584. //insutype = "390"
  3585. if his.IdCardType == 1 {
  3586. // cert_no = his.MedicalInsuranceNumber
  3587. cert_no = his.Certno
  3588. } else {
  3589. cert_no = his.Certno
  3590. }
  3591. var res ResultSeven
  3592. var resSeven10265 ResultSeven10265
  3593. var src_resquest string
  3594. var result2 string
  3595. var acct_used_flag string
  3596. fmt.Println("pay_way")
  3597. fmt.Println(pay_way)
  3598. fmt.Println("pay_way")
  3599. if pay_way == 4 {
  3600. acct_used_flag = "1"
  3601. } else {
  3602. acct_used_flag = "0"
  3603. }
  3604. if miConfig.MdtrtareaAdmvs == "421300" {
  3605. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3606. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3607. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3608. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3609. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3610. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3611. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3612. resp, requestErr := http.Get(api)
  3613. if requestErr != nil {
  3614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3615. return
  3616. }
  3617. body, ioErr := ioutil.ReadAll(resp.Body)
  3618. if ioErr != nil {
  3619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3621. return
  3622. }
  3623. var respJSON map[string]interface{}
  3624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3627. return
  3628. }
  3629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3630. result, _ := json.Marshal(respJSON)
  3631. if miConfig.Code == "H15049901371" {
  3632. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3633. utils.ErrorLog("解析失败:%v", err)
  3634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3635. return
  3636. }
  3637. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3638. res.Output = resSeven10265.Output
  3639. res.ErrMsg = resSeven10265.ErrMsg
  3640. res.Cainfo = resSeven10265.Cainfo
  3641. res.WarnMsg = resSeven10265.WarnMsg
  3642. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3643. res.Infcode = infocode
  3644. } else {
  3645. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3646. utils.ErrorLog("解析失败:%v", err)
  3647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3648. return
  3649. }
  3650. }
  3651. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3652. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3653. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3654. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3655. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3656. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3657. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3658. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  3659. resp, requestErr := http.Get(api)
  3660. if requestErr != nil {
  3661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3662. return
  3663. }
  3664. body, ioErr := ioutil.ReadAll(resp.Body)
  3665. if ioErr != nil {
  3666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. var respJSON map[string]interface{}
  3671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3674. return
  3675. }
  3676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3677. result, _ := json.Marshal(respJSON)
  3678. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3679. utils.ErrorLog("解析失败:%v", err)
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. return
  3682. }
  3683. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3684. res.Output = resSeven10265.Output
  3685. res.ErrMsg = resSeven10265.ErrMsg
  3686. res.Cainfo = resSeven10265.Cainfo
  3687. res.WarnMsg = resSeven10265.WarnMsg
  3688. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3689. res.Infcode = infocode
  3690. } else {
  3691. if miConfig.Code == "H15049901371" {
  3692. //赤峰地区国家医保医疗类别
  3693. //职工透析:医疗类别选特殊情况门诊990502
  3694. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3695. var med_type string
  3696. if his.Insutype == "390" {
  3697. if reg_type == 14 {
  3698. med_type = "9933"
  3699. } else if reg_type == 11 {
  3700. med_type = "11"
  3701. }
  3702. } else if his.Insutype == "310" {
  3703. if reg_type == 14 {
  3704. med_type = "990502"
  3705. } else if reg_type == 11 {
  3706. med_type = "11"
  3707. }
  3708. }
  3709. 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)
  3710. } else {
  3711. 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)
  3712. }
  3713. //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)
  3714. var dat map[string]interface{}
  3715. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3716. fmt.Println(dat)
  3717. } else {
  3718. fmt.Println(err)
  3719. }
  3720. saveLog(result2, src_resquest, "2207", "结算")
  3721. userJSONBytes, _ := json.Marshal(dat)
  3722. if miConfig.Code == "H15049901371" {
  3723. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3724. utils.ErrorLog("解析失败:%v", err)
  3725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3726. return
  3727. }
  3728. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3729. res.Output = resSeven10265.Output
  3730. res.ErrMsg = resSeven10265.ErrMsg
  3731. res.Cainfo = resSeven10265.Cainfo
  3732. res.WarnMsg = resSeven10265.WarnMsg
  3733. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3734. res.Infcode = infocode
  3735. } else {
  3736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3737. utils.ErrorLog("解析失败:%v", err)
  3738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. return
  3740. }
  3741. }
  3742. }
  3743. if res.Infcode != 0 {
  3744. errlog := &models.HisOrderError{
  3745. UserOrgId: adminUser.CurrentOrgId,
  3746. Ctime: time.Now().Unix(),
  3747. Mtime: time.Now().Unix(),
  3748. Number: chrg_bchno,
  3749. ErrMsg: res.ErrMsg,
  3750. Status: 1,
  3751. PatientId: id,
  3752. RecordTime: recordDateTime,
  3753. Stage: 6,
  3754. }
  3755. service.CreateErrMsgLog(errlog)
  3756. c.ServeSuccessJSON(map[string]interface{}{
  3757. "failed_code": -10,
  3758. "msg": res.ErrMsg,
  3759. })
  3760. return
  3761. } else {
  3762. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3763. order.OrderStatus = 2
  3764. order.Status = 1
  3765. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3766. order.SetlId = res.Output.Setlinfo.SetlID
  3767. order.PsnNo = res.Output.Setlinfo.PsnNo
  3768. order.PsnName = res.Output.Setlinfo.PsnName
  3769. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3770. order.Certno = res.Output.Setlinfo.Certno
  3771. order.Gend = res.Output.Setlinfo.Gend
  3772. order.Naty = res.Output.Setlinfo.Naty
  3773. order.Age = res.Output.Setlinfo.Age
  3774. order.Insutype = res.Output.Setlinfo.Insutype
  3775. order.PsnType = res.Output.Setlinfo.PsnType
  3776. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3777. order.SetlTime = res.Output.Setlinfo.SetlTime
  3778. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3779. if res.Output.Setlinfo.MedType == "140101" {
  3780. order.MedType = "14"
  3781. } else {
  3782. order.MedType = res.Output.Setlinfo.MedType
  3783. }
  3784. if reg_type == 1112 {
  3785. order.MedType = "1112"
  3786. }
  3787. if reg_type == 1111 {
  3788. order.MedType = "1111"
  3789. }
  3790. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3791. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3792. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3793. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3794. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3795. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3796. order.HifpPay = res.Output.Setlinfo.HifpPay
  3797. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3798. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3799. order.HifesPay = res.Output.Setlinfo.HifesPay
  3800. order.HifobPay = res.Output.Setlinfo.HifobPay
  3801. order.MafPay = res.Output.Setlinfo.MafPay
  3802. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3803. order.OthPay = res.Output.Setlinfo.OthPay
  3804. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3805. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3806. order.AcctPay = res.Output.Setlinfo.AcctPay
  3807. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3808. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3809. order.Balc = res.Output.Setlinfo.Balc
  3810. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3811. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3812. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3813. order.ClrWay = res.Output.Setlinfo.ClrWay
  3814. order.Creator = order.Creator
  3815. order.Modify = roles.AdminUserId
  3816. order.RequestLog = src_resquest
  3817. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3818. detailStr := string(setlDetail)
  3819. order.SetlDetail = detailStr
  3820. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3821. err = service.UpDateOrder(order)
  3822. if err == nil {
  3823. c.ServeSuccessJSON(map[string]interface{}{
  3824. "msg": "结算成功",
  3825. })
  3826. } else {
  3827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3828. return
  3829. }
  3830. }
  3831. } else {
  3832. adminUser := c.GetAdminUserInfo()
  3833. errlog := &models.HisOrderError{
  3834. UserOrgId: adminUser.CurrentOrgId,
  3835. Ctime: time.Now().Unix(),
  3836. Mtime: time.Now().Unix(),
  3837. ErrMsg: res.ErrMsg,
  3838. Status: 1,
  3839. PatientId: id,
  3840. RecordTime: recordDateTime,
  3841. Stage: 4,
  3842. }
  3843. service.CreateErrMsgLog(errlog)
  3844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3845. return
  3846. }
  3847. } else {
  3848. adminUser := c.GetAdminUserInfo()
  3849. errlog := &models.HisOrderError{
  3850. UserOrgId: adminUser.CurrentOrgId,
  3851. Ctime: time.Now().Unix(),
  3852. Mtime: time.Now().Unix(),
  3853. ErrMsg: res.ErrMsg,
  3854. Status: 1,
  3855. PatientId: id,
  3856. RecordTime: recordDateTime,
  3857. Stage: 4,
  3858. }
  3859. service.CreateErrMsgLog(errlog)
  3860. c.ServeSuccessJSON(map[string]interface{}{
  3861. "failed_code": -10,
  3862. "msg": res.ErrMsg,
  3863. })
  3864. return
  3865. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3866. //return
  3867. }
  3868. }
  3869. }
  3870. } else if tempOrder.ID > 0 {
  3871. if tempOrder.IsPre == 1 {
  3872. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3873. var rf []*ResultFive
  3874. json.Unmarshal([]byte(his.Iinfo), &rf)
  3875. chrg_bchno := tempOrder.Number
  3876. cert_no := his.Certno
  3877. var insutypes []string
  3878. var insutype string
  3879. var is390 int = 0
  3880. var is310 int = 0
  3881. for _, item := range rf {
  3882. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3883. insutypes = append(insutypes, item.Insutype)
  3884. }
  3885. }
  3886. if len(insutypes) == 1 {
  3887. insutype = insutypes[0]
  3888. } else {
  3889. for _, i := range insutypes {
  3890. if i == "390" {
  3891. is390 = 1
  3892. }
  3893. if i == "310" {
  3894. is310 = 1
  3895. }
  3896. }
  3897. }
  3898. if is390 == 1 {
  3899. insutype = "390"
  3900. }
  3901. if is310 == 1 {
  3902. insutype = "310"
  3903. }
  3904. if len(insutypes) == 0 {
  3905. insutype = "310"
  3906. }
  3907. if len(insutypes) == 2 {
  3908. insutype = strconv.FormatInt(his.SocialType, 64)
  3909. }
  3910. //insutype = "390"
  3911. if his.IdCardType == 1 {
  3912. // cert_no = his.MedicalInsuranceNumber
  3913. cert_no = his.Certno
  3914. } else {
  3915. cert_no = his.Certno
  3916. }
  3917. var res ResultSeven
  3918. var resSeven10265 ResultSeven10265
  3919. var src_resquest string
  3920. var result2 string
  3921. var acct_used_flag string
  3922. fmt.Println("pay_way")
  3923. fmt.Println(pay_way)
  3924. fmt.Println("pay_way")
  3925. if pay_way == 4 {
  3926. acct_used_flag = "1"
  3927. } else {
  3928. acct_used_flag = "0"
  3929. }
  3930. if miConfig.MdtrtareaAdmvs == "421300" {
  3931. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3932. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3933. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3934. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3935. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3936. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3937. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3938. resp, requestErr := http.Get(api)
  3939. if requestErr != nil {
  3940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3941. return
  3942. }
  3943. body, ioErr := ioutil.ReadAll(resp.Body)
  3944. if ioErr != nil {
  3945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. return
  3948. }
  3949. var respJSON map[string]interface{}
  3950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3956. result, _ := json.Marshal(respJSON)
  3957. fmt.Println("log")
  3958. fmt.Println(string(result))
  3959. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3960. utils.ErrorLog("解析失败:%v", err)
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. return
  3963. }
  3964. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3965. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3966. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3967. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3968. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3969. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3970. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3971. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  3972. resp, requestErr := http.Get(api)
  3973. if requestErr != nil {
  3974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3975. return
  3976. }
  3977. body, ioErr := ioutil.ReadAll(resp.Body)
  3978. if ioErr != nil {
  3979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3981. return
  3982. }
  3983. var respJSON map[string]interface{}
  3984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3987. return
  3988. }
  3989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3990. result, _ := json.Marshal(respJSON)
  3991. fmt.Println("log")
  3992. fmt.Println(string(result))
  3993. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3994. utils.ErrorLog("解析失败:%v", err)
  3995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. return
  3997. }
  3998. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3999. res.Output = resSeven10265.Output
  4000. res.ErrMsg = resSeven10265.ErrMsg
  4001. res.Cainfo = resSeven10265.Cainfo
  4002. res.WarnMsg = resSeven10265.WarnMsg
  4003. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4004. res.Infcode = infocode
  4005. } else {
  4006. var src_resquest string
  4007. if miConfig.Code == "H15049901371" {
  4008. //赤峰地区国家医保医疗类别
  4009. //职工透析:医疗类别选特殊情况门诊990502
  4010. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4011. var med_type string
  4012. if his.Insutype == "390" {
  4013. if reg_type == 14 {
  4014. med_type = "9933"
  4015. } else if reg_type == 11 {
  4016. med_type = "11"
  4017. }
  4018. } else if his.Insutype == "310" {
  4019. if reg_type == 14 {
  4020. med_type = "990502"
  4021. } else if reg_type == 11 {
  4022. med_type = "11"
  4023. }
  4024. }
  4025. 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)
  4026. } else {
  4027. 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)
  4028. }
  4029. var dat map[string]interface{}
  4030. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4031. fmt.Println(dat)
  4032. } else {
  4033. fmt.Println(err)
  4034. }
  4035. saveLog(result2, src_resquest, "2207", "结算")
  4036. userJSONBytes, _ := json.Marshal(dat)
  4037. if miConfig.Code == "H15049901371" {
  4038. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4039. utils.ErrorLog("解析失败:%v", err)
  4040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4041. return
  4042. }
  4043. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4044. res.Output = resSeven10265.Output
  4045. res.ErrMsg = resSeven10265.ErrMsg
  4046. res.Cainfo = resSeven10265.Cainfo
  4047. res.WarnMsg = resSeven10265.WarnMsg
  4048. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4049. res.Infcode = infocode
  4050. } else {
  4051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4052. utils.ErrorLog("解析失败:%v", err)
  4053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4054. return
  4055. }
  4056. }
  4057. }
  4058. if res.Infcode != 0 {
  4059. errlog := &models.HisOrderError{
  4060. UserOrgId: adminUser.CurrentOrgId,
  4061. Ctime: time.Now().Unix(),
  4062. Mtime: time.Now().Unix(),
  4063. Number: chrg_bchno,
  4064. ErrMsg: res.ErrMsg,
  4065. Status: 1,
  4066. PatientId: id,
  4067. RecordTime: recordDateTime,
  4068. Stage: 6,
  4069. }
  4070. service.CreateErrMsgLog(errlog)
  4071. c.ServeSuccessJSON(map[string]interface{}{
  4072. "failed_code": -10,
  4073. "msg": res.ErrMsg,
  4074. })
  4075. return
  4076. } else {
  4077. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4078. order.OrderStatus = 2
  4079. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4080. order.SetlId = res.Output.Setlinfo.SetlID
  4081. order.PsnNo = res.Output.Setlinfo.PsnNo
  4082. order.PsnName = res.Output.Setlinfo.PsnName
  4083. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4084. order.Certno = res.Output.Setlinfo.Certno
  4085. order.Gend = res.Output.Setlinfo.Gend
  4086. order.Naty = res.Output.Setlinfo.Naty
  4087. order.Age = res.Output.Setlinfo.Age
  4088. order.Insutype = res.Output.Setlinfo.Insutype
  4089. order.PsnType = res.Output.Setlinfo.PsnType
  4090. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4091. order.SetlTime = res.Output.Setlinfo.SetlTime
  4092. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4093. //order.MedType = res.Output.Setlinfo.MedType
  4094. if reg_type == 1112 {
  4095. order.MedType = "1112"
  4096. }
  4097. if reg_type == 1111 {
  4098. order.MedType = "1111"
  4099. }
  4100. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4101. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4102. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4103. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4104. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4105. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4106. order.HifpPay = res.Output.Setlinfo.HifpPay
  4107. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4108. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4109. order.HifesPay = res.Output.Setlinfo.HifesPay
  4110. order.HifobPay = res.Output.Setlinfo.HifobPay
  4111. order.MafPay = res.Output.Setlinfo.MafPay
  4112. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4113. order.OthPay = res.Output.Setlinfo.OthPay
  4114. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4115. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4116. order.AcctPay = res.Output.Setlinfo.AcctPay
  4117. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4118. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4119. order.Balc = res.Output.Setlinfo.Balc
  4120. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4121. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4122. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4123. order.ClrWay = res.Output.Setlinfo.ClrWay
  4124. order.Creator = order.Creator
  4125. order.Modify = roles.AdminUserId
  4126. order.RequestLog = src_resquest
  4127. order.Diagnosis = diagnosis_id
  4128. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4129. detailStr := string(setlDetail)
  4130. order.SetlDetail = detailStr
  4131. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4132. err = service.UpDateOrder(order)
  4133. if err == nil {
  4134. c.ServeSuccessJSON(map[string]interface{}{
  4135. "msg": "结算成功",
  4136. })
  4137. } else {
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4139. return
  4140. }
  4141. }
  4142. }
  4143. }
  4144. }
  4145. //func (c *HisApiController) GetPreUploadInfo() {
  4146. // id, _ := c.GetInt64("id")
  4147. // record_time := c.GetString("record_time")
  4148. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4149. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4150. //
  4151. // timeLayout := "2006-01-02"
  4152. // loc, _ := time.LoadLocation("Local")
  4153. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4154. // if err != nil {
  4155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4156. // return
  4157. // }
  4158. // recordDateTime := theTime.Unix()
  4159. // adminUser := c.GetAdminUserInfo()
  4160. //
  4161. // var prescriptions []*models.HisPrescription
  4162. //
  4163. // var start_time int64
  4164. // var end_time int64
  4165. //
  4166. // data := make(map[string]interface{})
  4167. // if settle_accounts_type == 1 { //日结
  4168. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4169. // data["pre"] = prescriptions
  4170. //
  4171. // } else { //月结
  4172. // start_time_str := c.GetString("start_time")
  4173. // end_time_str := c.GetString("end_time")
  4174. // timeLayout := "2006-01-02"
  4175. // loc, _ := time.LoadLocation("Local")
  4176. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4177. // if err != nil {
  4178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4179. // return
  4180. // }
  4181. // recordStartTime := theStartTime.Unix()
  4182. // start_time = recordStartTime
  4183. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4184. // if err != nil {
  4185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4186. // return
  4187. // }
  4188. // recordEndTime := theEndTime.Unix()
  4189. // end_time = recordEndTime
  4190. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4191. // data["pre"] = prescriptions
  4192. //
  4193. // }
  4194. //
  4195. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4196. //
  4197. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4198. // timestamp := time.Now().Unix()
  4199. // tempTime := time.Unix(timestamp, 0)
  4200. // timeFormat := tempTime.Format("20060102150405")
  4201. // chrgBchno := rand.Intn(100000) + 10000
  4202. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4203. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4204. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4205. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4206. // strconv.FormatInt(his.PatientId, 10)
  4207. // client := &http.Client{}
  4208. // data["psn_no"] = his.PsnNo
  4209. // data["mdtrt_id"] = his.Number
  4210. // data["chrg_bchno"] = chrg_bchno
  4211. // data["org_name"] = miConfig.OrgName
  4212. // data["doctor"] = roles.UserName
  4213. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4214. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4215. // data["fixmedins_code"] = miConfig.Code
  4216. // data["dept_code"] = department.Number
  4217. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4218. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4219. // data["secret_key"] = miConfig.SecretKey
  4220. // var ids []int64
  4221. //
  4222. // for _, item := range prescriptions {
  4223. // ids = append(ids, item.ID)
  4224. // }
  4225. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4226. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4227. // bytesData, _ := json.Marshal(data)
  4228. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4229. // resp, _ := client.Do(req)
  4230. // defer resp.Body.Close()
  4231. // body, ioErr := ioutil.ReadAll(resp.Body)
  4232. // if ioErr != nil {
  4233. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4235. // return
  4236. // }
  4237. // var respJSON map[string]interface{}
  4238. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4239. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4241. // return
  4242. // }
  4243. //
  4244. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4245. // userJSONBytes, _ := json.Marshal(respJSON)
  4246. // var res ResultFour
  4247. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4248. // utils.ErrorLog("解析失败:%v", err)
  4249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4250. // return
  4251. // }
  4252. //
  4253. // if res.Infcode == 0 {
  4254. // order := &models.HisOrder{
  4255. // UserOrgId: adminUser.CurrentOrgId,
  4256. // HisPatientId: his.ID,
  4257. // PatientId: his.PatientId,
  4258. // SettleAccountsDate: recordDateTime,
  4259. // Ctime: time.Now().Unix(),
  4260. // Mtime: time.Now().Unix(),
  4261. // Status: 1,
  4262. // Number: chrg_bchno,
  4263. // Infcode: res.Infcode,
  4264. // WarnMsg: res.WarnMsg,
  4265. // Cainfo: res.Cainfo,
  4266. // ErrMsg: res.ErrMsg,
  4267. // RespondTime: res.RefmsgTime,
  4268. // InfRefmsgid: res.InfRefmsgid,
  4269. // OrderStatus: 1,
  4270. // IsMedicineInsurance: 1,
  4271. // SettleType: settle_accounts_type,
  4272. // SettleStartTime: start_time,
  4273. // SettleEndTime: end_time,
  4274. // Creator: roles.ID,
  4275. // Modify: roles.ID,
  4276. // PType: 2,
  4277. // }
  4278. // err = service.CreateOrder(order)
  4279. // if err != nil {
  4280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4281. // return
  4282. // }
  4283. //
  4284. // for _, item := range res.Output.Result {
  4285. // temp := strings.Split(item.FeedetlSn, "-")
  4286. // var advice_id int64 = 0
  4287. // var project_id int64 = 0
  4288. // var types int64 = 0
  4289. //
  4290. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4291. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4292. //
  4293. // if temp[1] == "1" {
  4294. // advice_id = id
  4295. // project_id = 0
  4296. // } else if temp[1] == "2" {
  4297. // advice_id = 0
  4298. // project_id = id
  4299. // }
  4300. //
  4301. // info := &models.HisOrderInfo{
  4302. // OrderNumber: order.Number,
  4303. // FeedetlSn: item.FeedetlSn,
  4304. // UploadDate: time.Now().Unix(),
  4305. // AdviceId: advice_id,
  4306. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4307. // Cnt: item.Cnt,
  4308. // Pric: float64(item.Pric),
  4309. // PatientId: his.PatientId,
  4310. // PricUplmtAmt: item.PricUplmtAmt,
  4311. // SelfpayProp: item.SelfpayProp,
  4312. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4313. // OverlmtAmt: item.OverlmtAmt,
  4314. // PreselfpayAmt: item.PreselfpayAmt,
  4315. // BasMednFlag: item.BasMednFlag,
  4316. // MedChrgitmType: item.MedChrgitmType,
  4317. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4318. // Status: 1,
  4319. // Memo: item.Memo,
  4320. // Mtime: time.Now().Unix(),
  4321. // InscpScpAmt: item.InscpScpAmt,
  4322. // DrtReimFlag: item.DrtReimFlag,
  4323. // Ctime: time.Now().Unix(),
  4324. // ListSpItemFlag: item.ListSpItemFlag,
  4325. // ChldMedcFlag: item.ChldMedcFlag,
  4326. // LmtUsedFlag: item.LmtUsedFlag,
  4327. // ChrgitmLv: item.ChrgitmLv,
  4328. // UserOrgId: adminUser.CurrentOrgId,
  4329. // HisPatientId: his.ID,
  4330. // OrderId: order.ID,
  4331. // ProjectId: project_id,
  4332. // Type: types,
  4333. // }
  4334. // service.CreateOrderInfo(info)
  4335. //
  4336. // }
  4337. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4338. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4339. //
  4340. // var total float64
  4341. // for _, item := range prescriptions {
  4342. // if item.Type == 1 { //药品
  4343. // for _, subItem := range item.HisDoctorAdviceInfo {
  4344. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4345. // }
  4346. // }
  4347. // if item.Type == 2 { //项目
  4348. // for _, subItem := range item.HisPrescriptionProject {
  4349. // total = total + (subItem.Price * float64(subItem.Count))
  4350. // }
  4351. // }
  4352. // }
  4353. //
  4354. // for _, item := range prescriptions {
  4355. // for _, subItem := range item.HisAdditionalCharge {
  4356. // total = total + (subItem.Price * float64(subItem.Count))
  4357. // }
  4358. // }
  4359. //
  4360. // allTotal := fmt.Sprintf("%.2f", total)
  4361. // if res.Infcode == 0 {
  4362. // var rf []*ResultFive
  4363. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4364. // psn_no := his.PsnNo
  4365. // mdtrt_id := his.Number
  4366. // chrg_bchno := chrg_bchno
  4367. // cert_no := his.Certno
  4368. // insutype := rf[0].Insutype
  4369. //
  4370. // if his.IdCardType == 1 {
  4371. // cert_no = his.MedicalInsuranceNumber
  4372. //
  4373. // } else {
  4374. //
  4375. // cert_no = his.Certno
  4376. //
  4377. // }
  4378. //
  4379. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4380. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4381. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4382. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4383. // resp, requestErr := http.Get(api)
  4384. // if requestErr != nil {
  4385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4386. // return
  4387. // }
  4388. // defer resp.Body.Close()
  4389. // body, ioErr := ioutil.ReadAll(resp.Body)
  4390. // if ioErr != nil {
  4391. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. // }
  4395. // var respJSON map[string]interface{}
  4396. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4397. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. // return
  4400. // }
  4401. // fmt.Println(respJSON)
  4402. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4403. // userJSONBytes, _ := json.Marshal(respJSON)
  4404. // var res ResultSeven
  4405. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4406. // utils.ErrorLog("解析失败:%v", err)
  4407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. // return
  4409. // }
  4410. // if res.Infcode != 0 {
  4411. // errlog := &models.HisOrderError{
  4412. // UserOrgId: adminUser.CurrentOrgId,
  4413. // Ctime: time.Now().Unix(),
  4414. // Mtime: time.Now().Unix(),
  4415. // Number: chrg_bchno,
  4416. // ErrMsg: res.ErrMsg,
  4417. // Status: 1,
  4418. // PatientId: id,
  4419. // RecordTime: recordDateTime,
  4420. // Stage: 7,
  4421. // }
  4422. // service.CreateErrMsgLog(errlog)
  4423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4424. // return
  4425. // } else {
  4426. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4427. // order.OrderStatus = 1
  4428. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4429. // order.SetlId = res.Output.Setlinfo.SetlID
  4430. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4431. // order.PsnName = res.Output.Setlinfo.PsnName
  4432. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4433. // order.Certno = res.Output.Setlinfo.Certno
  4434. // order.Gend = res.Output.Setlinfo.Gend
  4435. // order.Naty = res.Output.Setlinfo.Naty
  4436. // order.Age = res.Output.Setlinfo.Age
  4437. // order.Insutype = res.Output.Setlinfo.Insutype
  4438. // order.PsnType = res.Output.Setlinfo.PsnType
  4439. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4440. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4441. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4442. // order.MedType = res.Output.Setlinfo.MedType
  4443. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4444. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4445. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4446. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4447. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4448. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4449. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4450. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4451. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4452. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4453. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4454. // order.MafPay = res.Output.Setlinfo.MafPay
  4455. // order.OthPay = res.Output.Setlinfo.OthPay
  4456. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4457. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4458. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4459. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4460. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4461. // order.Balc = res.Output.Setlinfo.Balc
  4462. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4463. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4464. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4465. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4466. // order.Creator = order.Creator
  4467. // order.Modify = roles.ID
  4468. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4469. // detailStr := string(setlDetail)
  4470. // order.SetlDetail = detailStr
  4471. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4472. // err = service.UpDateOrder(order)
  4473. // if err == nil {
  4474. // c.ServeSuccessJSON(map[string]interface{}{
  4475. // "msg": "预结算成功",
  4476. // })
  4477. // } else {
  4478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4479. // return
  4480. // }
  4481. // }
  4482. // } else {
  4483. // adminUser := c.GetAdminUserInfo()
  4484. // errlog := &models.HisOrderError{
  4485. // UserOrgId: adminUser.CurrentOrgId,
  4486. // Ctime: time.Now().Unix(),
  4487. // Mtime: time.Now().Unix(),
  4488. // ErrMsg: res.ErrMsg,
  4489. // Status: 1,
  4490. // PatientId: id,
  4491. // RecordTime: recordDateTime,
  4492. // Stage: 4,
  4493. // }
  4494. // service.CreateErrMsgLog(errlog)
  4495. //
  4496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4497. // return
  4498. // }
  4499. // } else {
  4500. // adminUser := c.GetAdminUserInfo()
  4501. // errlog := &models.HisOrderError{
  4502. // UserOrgId: adminUser.CurrentOrgId,
  4503. // Ctime: time.Now().Unix(),
  4504. // Mtime: time.Now().Unix(),
  4505. // ErrMsg: res.ErrMsg,
  4506. // Status: 1,
  4507. // PatientId: id,
  4508. // RecordTime: recordDateTime,
  4509. // Stage: 4,
  4510. // }
  4511. // service.CreateErrMsgLog(errlog)
  4512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4513. // return
  4514. // }
  4515. //
  4516. // } else {
  4517. // var total float64
  4518. // for _, item := range prescriptions {
  4519. // if item.Type == 1 { //药品
  4520. // for _, subItem := range item.HisDoctorAdviceInfo {
  4521. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4522. // }
  4523. // }
  4524. // if item.Type == 2 { //项目
  4525. // for _, subItem := range item.HisPrescriptionProject {
  4526. // total = total + (subItem.Price * float64(subItem.Count))
  4527. // }
  4528. // }
  4529. //
  4530. // for _, subItem := range item.HisAdditionalCharge {
  4531. // total = total + (subItem.Price * float64(subItem.Count))
  4532. // }
  4533. // }
  4534. //
  4535. // allTotal := fmt.Sprintf("%.2f", total)
  4536. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4537. // order := &models.HisOrder{
  4538. // UserOrgId: adminUser.CurrentOrgId,
  4539. // HisPatientId: his.ID,
  4540. // PatientId: id,
  4541. // SettleAccountsDate: recordDateTime,
  4542. // Ctime: time.Now().Unix(),
  4543. // Mtime: time.Now().Unix(),
  4544. // Status: 1,
  4545. // OrderStatus: 2,
  4546. // Number: chrg_bchno,
  4547. // MedfeeSumamt: totals,
  4548. // }
  4549. // err = service.CreateOrder(order)
  4550. // if err != nil {
  4551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4552. // return
  4553. // }
  4554. //
  4555. // var customs []*Custom
  4556. // for _, item := range prescriptions {
  4557. //
  4558. // if item.Type == 1 { //药品
  4559. // for _, subItem := range item.HisDoctorAdviceInfo {
  4560. // cus := &Custom{
  4561. // AdviceId: subItem.ID,
  4562. // ProjectId: 0,
  4563. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4564. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4565. // FeedetlSn: subItem.FeedetlSn,
  4566. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4567. // MedListCodg: subItem.MedListCodg,
  4568. // Type: 1,
  4569. // }
  4570. // customs = append(customs, cus)
  4571. // }
  4572. // }
  4573. //
  4574. // if item.Type == 2 { //项目
  4575. // for _, subItem := range item.HisPrescriptionProject {
  4576. //
  4577. // cus := &Custom{
  4578. // AdviceId: 0,
  4579. // ProjectId: subItem.ID,
  4580. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4581. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4582. // FeedetlSn: subItem.FeedetlSn,
  4583. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4584. // MedListCodg: subItem.MedListCodg,
  4585. // Type: 2,
  4586. // }
  4587. //
  4588. // customs = append(customs, cus)
  4589. // }
  4590. // }
  4591. //
  4592. // for _, item := range item.HisAdditionalCharge {
  4593. // cus := &Custom{
  4594. // ItemId: item.ID,
  4595. // AdviceId: 0,
  4596. // ProjectId: 0,
  4597. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4598. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4599. // FeedetlSn: item.FeedetlSn,
  4600. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4601. // MedListCodg: item.XtHisAddtionConfig.Code,
  4602. // Type: 3,
  4603. // }
  4604. //
  4605. // customs = append(customs, cus)
  4606. // }
  4607. //
  4608. // }
  4609. //
  4610. // for _, item := range customs {
  4611. // var advice_id int64 = 0
  4612. // var project_id int64 = 0
  4613. // var item_id int64 = 0
  4614. //
  4615. // var types int64 = 0
  4616. //
  4617. // if item.Type == 1 {
  4618. // advice_id = item.AdviceId
  4619. // project_id = 0
  4620. // item_id = 0
  4621. // } else if item.Type == 2 {
  4622. // advice_id = 0
  4623. // item_id = 0
  4624. //
  4625. // project_id = item.ProjectId
  4626. // } else if item.Type == 3 {
  4627. // advice_id = 0
  4628. // item_id = item.ItemId
  4629. // project_id = 0
  4630. // }
  4631. //
  4632. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4633. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4634. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4635. //
  4636. // info := &models.HisOrderInfo{
  4637. // OrderNumber: order.Number,
  4638. // UploadDate: time.Now().Unix(),
  4639. // AdviceId: advice_id,
  4640. // DetItemFeeSumamt: detItemFeeSumamt,
  4641. // Cnt: cut,
  4642. // Pric: pric,
  4643. // PatientId: id,
  4644. // Status: 1,
  4645. // Mtime: time.Now().Unix(),
  4646. // Ctime: time.Now().Unix(),
  4647. // UserOrgId: adminUser.CurrentOrgId,
  4648. // HisPatientId: his.ID,
  4649. // OrderId: order.ID,
  4650. // ProjectId: project_id,
  4651. // Type: types,
  4652. // ItemId: item_id,
  4653. // }
  4654. // service.CreateOrderInfo(info)
  4655. // }
  4656. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4657. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4658. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4659. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4660. // if err == nil {
  4661. // c.ServeSuccessJSON(map[string]interface{}{
  4662. // "msg": "结算成功",
  4663. // })
  4664. // } else {
  4665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4666. // return
  4667. // }
  4668. // }
  4669. //}
  4670. //上传明细-预结算-
  4671. func (c *HisApiController) GetPreUploadInfo() {
  4672. id, _ := c.GetInt64("id")
  4673. record_time := c.GetString("record_time")
  4674. his_patient_id, _ := c.GetInt64("his_patient_id")
  4675. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4676. admin_user_id, _ := c.GetInt64("admin_user_id")
  4677. diagnosis_id := c.GetString("diagnosis")
  4678. sick_type, _ := c.GetInt64("sick_type")
  4679. reg_type, _ := c.GetInt64("p_type")
  4680. begin_time := c.GetString("begin_time")
  4681. id_str := c.GetString("ids")
  4682. ids_arr := strings.Split(id_str, ",")
  4683. timeLayout := "2006-01-02"
  4684. loc, _ := time.LoadLocation("Local")
  4685. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4686. if err != nil {
  4687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4688. return
  4689. }
  4690. recordDateTime := theTime.Unix()
  4691. adminUser := c.GetAdminUserInfo()
  4692. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4693. var config []*models.HisXtDiagnoseConfig
  4694. for _, item := range diagnosis_ids {
  4695. id, _ := strconv.ParseInt(item, 10, 64)
  4696. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4697. config = append(config, &diagnosisConfig)
  4698. }
  4699. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4700. sickConfig, _ := service.FindSickById(sick_type)
  4701. var prescriptions []*models.HisPrescription
  4702. var start_time int64
  4703. var end_time int64
  4704. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4705. fmt.Println(his_patient_id)
  4706. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4707. timestamp := time.Now().Unix()
  4708. tempTime := time.Unix(timestamp, 0)
  4709. timeFormat := tempTime.Format("20060102150405")
  4710. chrgBchno := rand.Intn(100000) + 10000
  4711. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4712. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4713. var patientPrescription models.HisPrescriptionInfo
  4714. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4715. if patientPrescription.ID == 0 {
  4716. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4717. }
  4718. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4719. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4720. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4721. strconv.FormatInt(his.PatientId, 10)
  4722. var res2 ResultSix
  4723. var resSix10265 ResultSix10265
  4724. if miConfig.InsuplcAdmdvs == "421300" {
  4725. data := make(map[string]interface{})
  4726. client := &http.Client{}
  4727. data["psn_no"] = his.PsnNo
  4728. data["mdtrt_id"] = his.Number
  4729. data["doctor"] = roles.UserName
  4730. data["department"] = department.Name
  4731. data["org_name"] = miConfig.OrgName
  4732. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4733. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4734. data["fixmedins_code"] = miConfig.Code
  4735. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4736. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4737. data["secret_key"] = miConfig.SecretKey
  4738. data["sick_code"] = sickConfig.CountryCode
  4739. data["sick_name"] = sickConfig.ClassName
  4740. data["begin_time"] = begin_time
  4741. data["dept"] = strconv.FormatInt(department.ID, 10)
  4742. data["config"] = config
  4743. fmt.Println(data)
  4744. bytesData, _ := json.Marshal(data)
  4745. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4746. resp, _ := client.Do(req)
  4747. defer resp.Body.Close()
  4748. body, ioErr := ioutil.ReadAll(resp.Body)
  4749. if ioErr != nil {
  4750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4752. return
  4753. }
  4754. var respJSON map[string]interface{}
  4755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4758. return
  4759. }
  4760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4761. userJSONBytes, _ := json.Marshal(respJSON)
  4762. fmt.Println("log")
  4763. fmt.Println(string(userJSONBytes))
  4764. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. } else if miConfig.InsuplcAdmdvs == "320921" {
  4770. data := make(map[string]interface{})
  4771. client := &http.Client{}
  4772. data["psn_no"] = his.PsnNo
  4773. data["mdtrt_id"] = his.Number
  4774. data["doctor"] = roles.UserName
  4775. data["department"] = department.Name
  4776. data["org_name"] = miConfig.OrgName
  4777. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4778. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4779. data["fixmedins_code"] = miConfig.Code
  4780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4782. data["secret_key"] = miConfig.SecretKey
  4783. data["sick_code"] = sickConfig.CountryCode
  4784. data["sick_name"] = sickConfig.ClassName
  4785. data["begin_time"] = begin_time
  4786. data["dept"] = strconv.FormatInt(department.ID, 10)
  4787. data["config"] = config
  4788. fmt.Println(data)
  4789. bytesData, _ := json.Marshal(data)
  4790. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4791. resp, _ := client.Do(req)
  4792. defer resp.Body.Close()
  4793. body, ioErr := ioutil.ReadAll(resp.Body)
  4794. if ioErr != nil {
  4795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. var respJSON map[string]interface{}
  4800. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4803. return
  4804. }
  4805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4806. userJSONBytes, _ := json.Marshal(respJSON)
  4807. fmt.Println("log")
  4808. fmt.Println(string(userJSONBytes))
  4809. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4810. utils.ErrorLog("解析失败:%v", err)
  4811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4812. return
  4813. }
  4814. } else {
  4815. var result string
  4816. var requestLog string
  4817. if miConfig.InsuplcAdmdvs == "440781" { //
  4818. 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)
  4819. } else {
  4820. if miConfig.Code == "H15049901371" {
  4821. //赤峰地区国家医保医疗类别
  4822. //职工透析:医疗类别选特殊情况门诊990502
  4823. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4824. var med_type string
  4825. if his.Insutype == "390" {
  4826. if reg_type == 14 {
  4827. med_type = "9933"
  4828. } else if reg_type == 11 {
  4829. med_type = "11"
  4830. }
  4831. } else if his.Insutype == "310" {
  4832. if reg_type == 14 {
  4833. med_type = "990502"
  4834. } else if reg_type == 11 {
  4835. med_type = "11"
  4836. }
  4837. }
  4838. 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)
  4839. } else {
  4840. 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)
  4841. }
  4842. saveLog(result, requestLog, "2203", "上传就诊信息")
  4843. var respJSON2 map[string]interface{}
  4844. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. return
  4848. }
  4849. userJSONBytes2, _ := json.Marshal(respJSON2)
  4850. if miConfig.Code == "H15049901371" {
  4851. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4852. utils.ErrorLog("解析失败:%v", err)
  4853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4854. return
  4855. }
  4856. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4857. res2.Output = resSix10265.Output
  4858. res2.ErrMsg = resSix10265.ErrMsg
  4859. res2.Cainfo = resSix10265.Cainfo
  4860. res2.WarnMsg = resSix10265.WarnMsg
  4861. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4862. res2.Infcode = infocode
  4863. } else {
  4864. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4865. utils.ErrorLog("解析失败:%v", err)
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. }
  4870. }
  4871. }
  4872. if res2.Infcode != 0 {
  4873. adminUser := c.GetAdminUserInfo()
  4874. errlog := &models.HisOrderError{
  4875. UserOrgId: adminUser.CurrentOrgId,
  4876. Ctime: time.Now().Unix(),
  4877. Mtime: time.Now().Unix(),
  4878. ErrMsg: res2.ErrMsg,
  4879. Status: 1,
  4880. PatientId: id,
  4881. RecordTime: recordDateTime,
  4882. Stage: 3,
  4883. }
  4884. service.CreateErrMsgLog(errlog)
  4885. c.ServeSuccessJSON(map[string]interface{}{
  4886. "failed_code": -10,
  4887. "msg": res2.ErrMsg,
  4888. })
  4889. return
  4890. } else {
  4891. his.Diagnosis = diagnosis_id
  4892. his.SickType = sickConfig.ID
  4893. his.PType = fmt.Sprintf("%d", reg_type)
  4894. service.UpdateHisPatientThree(&his)
  4895. data := make(map[string]interface{})
  4896. if settle_accounts_type == 1 { //日结
  4897. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4898. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4899. } else {
  4900. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4901. }
  4902. data["pre"] = prescriptions
  4903. } else { //月结
  4904. start_time_str := c.GetString("start_time")
  4905. end_time_str := c.GetString("end_time")
  4906. timeLayout := "2006-01-02"
  4907. loc, _ := time.LoadLocation("Local")
  4908. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4909. if err != nil {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4911. return
  4912. }
  4913. recordStartTime := theStartTime.Unix()
  4914. start_time = recordStartTime
  4915. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4916. if err != nil {
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4918. return
  4919. }
  4920. recordEndTime := theEndTime.Unix()
  4921. end_time = recordEndTime
  4922. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4923. data["pre"] = prescriptions
  4924. }
  4925. client := &http.Client{}
  4926. data["psn_no"] = his.PsnNo
  4927. data["mdtrt_id"] = his.Number
  4928. data["chrg_bchno"] = chrg_bchno
  4929. data["org_name"] = miConfig.OrgName
  4930. data["doctor"] = roles.UserName
  4931. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4932. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4933. data["fixmedins_code"] = miConfig.Code
  4934. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4935. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4936. data["dept_code"] = "15"
  4937. } else {
  4938. data["dept_code"] = department.Number
  4939. }
  4940. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4941. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4942. data["secret_key"] = miConfig.SecretKey
  4943. data["url"] = miConfig.Url
  4944. data["ak"] = miConfig.ChannelNumber
  4945. data["new_doctor_name"] = patientPrescription.Doctor
  4946. var ids []int64
  4947. for _, item := range prescriptions {
  4948. ids = append(ids, item.ID)
  4949. }
  4950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4951. if config.IsOpen == 1 { //对接了医保,走医保流程
  4952. var res ResultFour
  4953. var resFour10265 ResultFour10265
  4954. if miConfig.MdtrtareaAdmvs == "421300" {
  4955. bytesData, _ := json.Marshal(data)
  4956. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4957. resp, _ := client.Do(req)
  4958. defer resp.Body.Close()
  4959. body, ioErr := ioutil.ReadAll(resp.Body)
  4960. if ioErr != nil {
  4961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4963. return
  4964. }
  4965. var respJSON map[string]interface{}
  4966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4969. return
  4970. }
  4971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4972. userJSONBytes, _ := json.Marshal(respJSON)
  4973. fmt.Println("log")
  4974. fmt.Println(string(userJSONBytes))
  4975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4976. utils.ErrorLog("解析失败:%v", err)
  4977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4978. return
  4979. }
  4980. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4981. bytesData, _ := json.Marshal(data)
  4982. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4983. resp, _ := client.Do(req)
  4984. defer resp.Body.Close()
  4985. body, ioErr := ioutil.ReadAll(resp.Body)
  4986. if ioErr != nil {
  4987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4989. return
  4990. }
  4991. var respJSON map[string]interface{}
  4992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4995. return
  4996. }
  4997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4998. userJSONBytes, _ := json.Marshal(respJSON)
  4999. fmt.Println("log")
  5000. fmt.Println(string(userJSONBytes))
  5001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5002. utils.ErrorLog("解析失败:%v", err)
  5003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5004. return
  5005. }
  5006. } else {
  5007. if miConfig.Code == "H15049901371" {
  5008. 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)
  5009. var dat map[string]interface{}
  5010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5011. fmt.Println(dat)
  5012. } else {
  5013. fmt.Println(err)
  5014. }
  5015. saveLog(result, request_log, "2204", "上传费用明细")
  5016. userJSONBytes, _ := json.Marshal(dat)
  5017. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. res.InfRefmsgid = resFour10265.InfRefmsgid
  5023. res.Output = resFour10265.Output
  5024. res.ErrMsg = resFour10265.ErrMsg
  5025. res.Cainfo = resFour10265.Cainfo
  5026. res.WarnMsg = resFour10265.WarnMsg
  5027. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5028. res.Infcode = infocode
  5029. } else {
  5030. 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)
  5031. var dat map[string]interface{}
  5032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5033. fmt.Println(dat)
  5034. } else {
  5035. fmt.Println(err)
  5036. }
  5037. saveLog(result, request_log, "2204", "上传费用明细")
  5038. userJSONBytes, _ := json.Marshal(dat)
  5039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5040. utils.ErrorLog("解析失败:%v", err)
  5041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5042. return
  5043. }
  5044. }
  5045. }
  5046. if res.Infcode == 0 {
  5047. order := &models.HisOrder{
  5048. UserOrgId: adminUser.CurrentOrgId,
  5049. HisPatientId: his.ID,
  5050. PatientId: his.PatientId,
  5051. SettleAccountsDate: recordDateTime,
  5052. Ctime: time.Now().Unix(),
  5053. Mtime: time.Now().Unix(),
  5054. Status: 1,
  5055. Number: chrg_bchno,
  5056. Infcode: res.Infcode,
  5057. WarnMsg: res.WarnMsg,
  5058. Cainfo: res.Cainfo,
  5059. ErrMsg: res.ErrMsg,
  5060. RespondTime: res.RefmsgTime,
  5061. InfRefmsgid: res.InfRefmsgid,
  5062. OrderStatus: 1,
  5063. IsMedicineInsurance: 1,
  5064. SettleType: settle_accounts_type,
  5065. SettleStartTime: start_time,
  5066. SettleEndTime: end_time,
  5067. Creator: roles.AdminUserId,
  5068. Modify: roles.AdminUserId,
  5069. PType: 2,
  5070. Diagnosis: diagnosis_id,
  5071. }
  5072. err = service.CreateOrder(order)
  5073. if err != nil {
  5074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5075. return
  5076. }
  5077. for _, item := range res.Output.Result {
  5078. temp := strings.Split(item.FeedetlSn, "-")
  5079. var advice_id int64 = 0
  5080. var project_id int64 = 0
  5081. var types int64 = 0
  5082. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5083. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5084. if temp[1] == "1" {
  5085. advice_id = id
  5086. project_id = 0
  5087. } else if temp[1] == "2" {
  5088. advice_id = 0
  5089. project_id = id
  5090. }
  5091. info := &models.HisOrderInfo{
  5092. OrderNumber: order.Number,
  5093. FeedetlSn: item.FeedetlSn,
  5094. UploadDate: time.Now().Unix(),
  5095. AdviceId: advice_id,
  5096. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5097. Cnt: item.Cnt,
  5098. Pric: float64(item.Pric),
  5099. PatientId: his.PatientId,
  5100. PricUplmtAmt: item.PricUplmtAmt,
  5101. SelfpayProp: item.SelfpayProp,
  5102. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5103. OverlmtAmt: item.OverlmtAmt,
  5104. PreselfpayAmt: item.PreselfpayAmt,
  5105. BasMednFlag: item.BasMednFlag,
  5106. MedChrgitmType: item.MedChrgitmType,
  5107. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5108. Status: 1,
  5109. Memo: item.Memo,
  5110. Mtime: time.Now().Unix(),
  5111. InscpScpAmt: item.InscpScpAmt,
  5112. DrtReimFlag: item.DrtReimFlag,
  5113. Ctime: time.Now().Unix(),
  5114. ListSpItemFlag: item.ListSpItemFlag,
  5115. ChldMedcFlag: item.ChldMedcFlag,
  5116. LmtUsedFlag: item.LmtUsedFlag,
  5117. ChrgitmLv: item.ChrgitmLv,
  5118. UserOrgId: adminUser.CurrentOrgId,
  5119. HisPatientId: his.ID,
  5120. OrderId: order.ID,
  5121. ProjectId: project_id,
  5122. Type: types,
  5123. }
  5124. service.CreateOrderInfo(info)
  5125. }
  5126. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5127. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5128. var total float64
  5129. for _, item := range prescriptions {
  5130. if item.Type == 1 { //药品
  5131. for _, subItem := range item.HisDoctorAdviceInfo {
  5132. total = total + (subItem.Price * subItem.PrescribingNumber)
  5133. }
  5134. }
  5135. if item.Type == 2 { //项目
  5136. for _, subItem := range item.HisPrescriptionProject {
  5137. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5138. total = total + (subItem.Price * cnt)
  5139. }
  5140. }
  5141. }
  5142. for _, item := range prescriptions {
  5143. for _, subItem := range item.HisAdditionalCharge {
  5144. total = total + (subItem.Price * float64(subItem.Count))
  5145. }
  5146. }
  5147. allTotal := fmt.Sprintf("%.4f", total)
  5148. if res.Infcode == 0 {
  5149. var rf []*ResultFive
  5150. json.Unmarshal([]byte(his.Iinfo), &rf)
  5151. chrg_bchno := chrg_bchno
  5152. cert_no := his.Certno
  5153. var insutypes []string
  5154. var insutype string
  5155. var is390 int = 0
  5156. var is310 int = 0
  5157. for _, item := range rf {
  5158. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5159. insutypes = append(insutypes, item.Insutype)
  5160. }
  5161. }
  5162. if len(insutypes) == 1 {
  5163. insutype = insutypes[0]
  5164. } else {
  5165. for _, i := range insutypes {
  5166. if i == "390" {
  5167. is390 = 1
  5168. }
  5169. if i == "310" {
  5170. is310 = 1
  5171. }
  5172. }
  5173. }
  5174. if is390 == 1 {
  5175. insutype = "390"
  5176. }
  5177. if is310 == 1 {
  5178. insutype = "310"
  5179. }
  5180. if len(insutypes) == 0 {
  5181. insutype = "310"
  5182. }
  5183. if len(insutypes) == 2 {
  5184. insutype = strconv.FormatInt(his.SocialType, 64)
  5185. }
  5186. //insutype = "390"
  5187. if his.IdCardType == 1 {
  5188. cert_no = his.MedicalInsuranceNumber
  5189. } else {
  5190. cert_no = his.Certno
  5191. }
  5192. var res ResultSeven
  5193. var resSeven10265 ResultSeven10265
  5194. if miConfig.MdtrtareaAdmvs == "421300" {
  5195. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5198. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5201. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5202. resp, requestErr := http.Get(api)
  5203. if requestErr != nil {
  5204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5205. return
  5206. }
  5207. body, ioErr := ioutil.ReadAll(resp.Body)
  5208. if ioErr != nil {
  5209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5211. return
  5212. }
  5213. var respJSON map[string]interface{}
  5214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5217. return
  5218. }
  5219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5220. result, _ := json.Marshal(respJSON)
  5221. fmt.Println("log")
  5222. fmt.Println(string(result))
  5223. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5224. utils.ErrorLog("解析失败:%v", err)
  5225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5226. return
  5227. }
  5228. } else {
  5229. var result string
  5230. var request_log string
  5231. if miConfig.Code == "H15049901371" {
  5232. //赤峰地区国家医保医疗类别
  5233. //职工透析:医疗类别选特殊情况门诊990502
  5234. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5235. var med_type string
  5236. if his.Insutype == "390" {
  5237. if reg_type == 14 {
  5238. med_type = "9933"
  5239. } else if reg_type == 11 {
  5240. med_type = "11"
  5241. }
  5242. } else if his.Insutype == "310" {
  5243. if reg_type == 14 {
  5244. med_type = "990502"
  5245. } else if reg_type == 11 {
  5246. med_type = "11"
  5247. }
  5248. }
  5249. 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)
  5250. } else {
  5251. 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)
  5252. }
  5253. var dat map[string]interface{}
  5254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5255. fmt.Println(dat)
  5256. } else {
  5257. fmt.Println(err)
  5258. }
  5259. saveLog(result, request_log, "2206", "预结算")
  5260. //userJSONBytes, _ := json.Marshal(dat)
  5261. //
  5262. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5263. // utils.ErrorLog("解析失败:%v", err)
  5264. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5265. // return
  5266. //}
  5267. userJSONBytes, _ := json.Marshal(dat)
  5268. if miConfig.Code == "H15049901371" {
  5269. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5270. utils.ErrorLog("解析失败:%v", err)
  5271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5272. return
  5273. }
  5274. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5275. res.Output = resSeven10265.Output
  5276. res.ErrMsg = resSeven10265.ErrMsg
  5277. res.Cainfo = resSeven10265.Cainfo
  5278. res.WarnMsg = resSeven10265.WarnMsg
  5279. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5280. res.Infcode = infocode
  5281. } else {
  5282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5283. utils.ErrorLog("解析失败:%v", err)
  5284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5285. return
  5286. }
  5287. }
  5288. }
  5289. if res.Infcode != 0 {
  5290. errlog := &models.HisOrderError{
  5291. UserOrgId: adminUser.CurrentOrgId,
  5292. Ctime: time.Now().Unix(),
  5293. Mtime: time.Now().Unix(),
  5294. Number: chrg_bchno,
  5295. ErrMsg: res.ErrMsg,
  5296. Status: 1,
  5297. PatientId: id,
  5298. RecordTime: recordDateTime,
  5299. Stage: 20,
  5300. }
  5301. service.CreateErrMsgLog(errlog)
  5302. c.ServeSuccessJSON(map[string]interface{}{
  5303. "failed_code": -10,
  5304. "msg": res.ErrMsg,
  5305. })
  5306. return
  5307. } else {
  5308. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5309. order.OrderStatus = 1
  5310. order.IsPre = 1
  5311. order.Status = 1
  5312. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5313. order.SetlId = res.Output.Setlinfo.SetlID
  5314. order.PsnNo = res.Output.Setlinfo.PsnNo
  5315. order.PsnName = res.Output.Setlinfo.PsnName
  5316. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5317. order.Certno = res.Output.Setlinfo.Certno
  5318. order.Gend = res.Output.Setlinfo.Gend
  5319. order.Naty = res.Output.Setlinfo.Naty
  5320. order.Age = res.Output.Setlinfo.Age
  5321. order.Insutype = res.Output.Setlinfo.Insutype
  5322. order.PsnType = res.Output.Setlinfo.PsnType
  5323. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5324. order.SetlTime = res.Output.Setlinfo.SetlTime
  5325. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5326. if res.Output.Setlinfo.MedType == "140101" {
  5327. order.MedType = "14"
  5328. } else {
  5329. order.MedType = res.Output.Setlinfo.MedType
  5330. }
  5331. if reg_type == 1112 {
  5332. order.MedType = "1112"
  5333. }
  5334. if reg_type == 1111 {
  5335. order.MedType = "1111"
  5336. }
  5337. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5338. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5339. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5340. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5341. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5342. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5343. order.HifpPay = res.Output.Setlinfo.HifpPay
  5344. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5345. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5346. order.HifesPay = res.Output.Setlinfo.HifesPay
  5347. order.HifobPay = res.Output.Setlinfo.HifobPay
  5348. order.MafPay = res.Output.Setlinfo.MafPay
  5349. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5350. order.OthPay = res.Output.Setlinfo.OthPay
  5351. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5352. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5353. order.AcctPay = res.Output.Setlinfo.AcctPay
  5354. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5355. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5356. order.Balc = res.Output.Setlinfo.Balc
  5357. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5358. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5359. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5360. order.ClrWay = res.Output.Setlinfo.ClrWay
  5361. order.Creator = order.Creator
  5362. order.Modify = roles.AdminUserId
  5363. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5364. detailStr := string(setlDetail)
  5365. order.SetlDetail = detailStr
  5366. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5367. err = service.UpDateOrder(order)
  5368. if err == nil {
  5369. c.ServeSuccessJSON(map[string]interface{}{
  5370. "msg": "预结算成功",
  5371. })
  5372. } else {
  5373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5374. return
  5375. }
  5376. }
  5377. } else {
  5378. adminUser := c.GetAdminUserInfo()
  5379. errlog := &models.HisOrderError{
  5380. UserOrgId: adminUser.CurrentOrgId,
  5381. Ctime: time.Now().Unix(),
  5382. Mtime: time.Now().Unix(),
  5383. ErrMsg: res.ErrMsg,
  5384. Status: 1,
  5385. PatientId: id,
  5386. RecordTime: recordDateTime,
  5387. Stage: 4,
  5388. }
  5389. service.CreateErrMsgLog(errlog)
  5390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5391. return
  5392. }
  5393. } else {
  5394. adminUser := c.GetAdminUserInfo()
  5395. errlog := &models.HisOrderError{
  5396. UserOrgId: adminUser.CurrentOrgId,
  5397. Ctime: time.Now().Unix(),
  5398. Mtime: time.Now().Unix(),
  5399. ErrMsg: res.ErrMsg,
  5400. Status: 1,
  5401. PatientId: id,
  5402. RecordTime: recordDateTime,
  5403. Stage: 4,
  5404. }
  5405. service.CreateErrMsgLog(errlog)
  5406. c.ServeSuccessJSON(map[string]interface{}{
  5407. "failed_code": -10,
  5408. "msg": res.ErrMsg,
  5409. })
  5410. return
  5411. }
  5412. }
  5413. }
  5414. }
  5415. //func (c *HisApiController) GetSettleInfo() {
  5416. // id, _ := c.GetInt64("id")
  5417. // order_id, _ := c.GetInt64("order_id")
  5418. //
  5419. // record_time := c.GetString("record_time")
  5420. // pay_way, _ := c.GetInt64("pay_way")
  5421. // pay_price, _ := c.GetFloat("pay_price")
  5422. // pay_card_no := c.GetString("pay_card_no")
  5423. // discount_price, _ := c.GetFloat("discount_price")
  5424. // preferential_price, _ := c.GetFloat("preferential_price")
  5425. // reality_price, _ := c.GetFloat("reality_price")
  5426. // found_price, _ := c.GetFloat("found_price")
  5427. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5428. // private_price, _ := c.GetFloat("private_price")
  5429. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5430. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5431. //
  5432. // timeLayout := "2006-01-02"
  5433. // loc, _ := time.LoadLocation("Local")
  5434. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5435. // if err != nil {
  5436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5437. // return
  5438. // }
  5439. // recordDateTime := theTime.Unix()
  5440. // adminUser := c.GetAdminUserInfo()
  5441. //
  5442. // var prescriptions []*models.HisPrescription
  5443. //
  5444. // data := make(map[string]interface{})
  5445. // if settle_accounts_type == 1 { //日结
  5446. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5447. // data["pre"] = prescriptions
  5448. //
  5449. // } else { //月结
  5450. // start_time_str := c.GetString("start_time")
  5451. // end_time_str := c.GetString("end_time")
  5452. // timeLayout := "2006-01-02"
  5453. // loc, _ := time.LoadLocation("Local")
  5454. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5455. // if err != nil {
  5456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5457. // return
  5458. // }
  5459. // recordStartTime := theStartTime.Unix()
  5460. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5461. // if err != nil {
  5462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5463. // return
  5464. // }
  5465. // recordEndTime := theEndTime.Unix()
  5466. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5467. // data["pre"] = prescriptions
  5468. //
  5469. // }
  5470. //
  5471. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5472. //
  5473. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5474. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5475. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5476. // strconv.FormatInt(his.PatientId, 10)
  5477. //
  5478. // order_src, _ := service.GetHisOrderByID(order_id)
  5479. //
  5480. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5481. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5482. //
  5483. // var total float64
  5484. // for _, item := range prescriptions {
  5485. // if item.Type == 1 { //药品
  5486. // for _, subItem := range item.HisDoctorAdviceInfo {
  5487. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5488. // }
  5489. // }
  5490. // if item.Type == 2 { //项目
  5491. // for _, subItem := range item.HisPrescriptionProject {
  5492. // total = total + (subItem.Price * float64(subItem.Count))
  5493. // }
  5494. // }
  5495. // }
  5496. //
  5497. // for _, item := range prescriptions {
  5498. // for _, subItem := range item.HisAdditionalCharge {
  5499. // total = total + (subItem.Price * float64(subItem.Count))
  5500. // }
  5501. // }
  5502. //
  5503. // allTotal := fmt.Sprintf("%.2f", total)
  5504. // var rf []*ResultFive
  5505. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5506. // psn_no := order_src.PsnNo
  5507. // mdtrt_id := order_src.MdtrtId
  5508. // chrg_bchno := order_src.Number
  5509. // cert_no := order_src.Certno
  5510. // insutype := rf[0].Insutype
  5511. //
  5512. // if his.IdCardType == 1 {
  5513. // cert_no = his.MedicalInsuranceNumber
  5514. // } else {
  5515. // cert_no = his.Certno
  5516. // }
  5517. //
  5518. // 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)
  5519. // var dat map[string]interface{}
  5520. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5521. // fmt.Println(dat)
  5522. // } else {
  5523. // fmt.Println(err)
  5524. // }
  5525. //
  5526. // userJSONBytes, _ := json.Marshal(dat)
  5527. //
  5528. //
  5529. //
  5530. // var res ResultSeven
  5531. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5532. // utils.ErrorLog("解析失败:%v", err)
  5533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5534. // return
  5535. // }
  5536. // if res.Infcode == -1 {
  5537. // errlog := &models.HisOrderError{
  5538. // UserOrgId: adminUser.CurrentOrgId,
  5539. // Ctime: time.Now().Unix(),
  5540. // Mtime: time.Now().Unix(),
  5541. // Number: chrg_bchno,
  5542. // ErrMsg: res.ErrMsg,
  5543. // Status: 1,
  5544. // PatientId: id,
  5545. // RecordTime: recordDateTime,
  5546. // Stage: 6,
  5547. // }
  5548. // service.CreateErrMsgLog(errlog)
  5549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5550. // return
  5551. // } else {
  5552. // order_src.OrderStatus = 2
  5553. // order_src.PayWay = pay_way
  5554. // order_src.PayPrice = pay_price
  5555. // order_src.PayCardNo = pay_card_no
  5556. // order_src.DiscountPrice = discount_price
  5557. // order_src.PreferentialPrice = preferential_price
  5558. // order_src.RealityPrice = reality_price
  5559. // order_src.FoundPrice = found_price
  5560. // order_src.MedicalInsurancePrice = medical_insurance_price
  5561. // order_src.PrivatePrice = private_price
  5562. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5563. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5564. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5565. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5566. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5567. // order_src.Certno = res.Output.Setlinfo.Certno
  5568. // order_src.Gend = res.Output.Setlinfo.Gend
  5569. // order_src.Naty = res.Output.Setlinfo.Naty
  5570. // order_src.Age = res.Output.Setlinfo.Age
  5571. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5572. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5573. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5574. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5575. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5576. // order_src.MedType = res.Output.Setlinfo.MedType
  5577. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5578. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5579. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5580. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5581. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5582. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5583. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5584. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5585. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5586. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5587. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5588. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5589. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5590. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5591. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5592. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5593. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5594. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5595. // order_src.Balc = res.Output.Setlinfo.Balc
  5596. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5597. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5598. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5599. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5600. // order_src.Creator = order_src.Creator
  5601. // order_src.Modify = roles.ID
  5602. // order_src.RequestLog = src_resquest
  5603. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5604. // detailStr := string(setlDetail)
  5605. // order_src.SetlDetail = detailStr
  5606. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5607. // err = service.UpDateOrder(order_src)
  5608. //
  5609. // if err == nil {
  5610. // c.ServeSuccessJSON(map[string]interface{}{
  5611. // "msg": "结算成功",
  5612. // })
  5613. // } else {
  5614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5615. // return
  5616. // }
  5617. // }
  5618. // }
  5619. //}
  5620. //退款
  5621. func (c *HisApiController) Refund() {
  5622. order_id, _ := c.GetInt64("order_id")
  5623. admin_user_id, _ := c.GetInt64("admin_user_id")
  5624. adminUser := c.GetAdminUserInfo()
  5625. var order models.HisOrder
  5626. order, _ = service.GetHisOrderByID(order_id)
  5627. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5628. if order.ID == 0 {
  5629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5630. return
  5631. }
  5632. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5634. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5635. if config.IsOpen == 1 { //对接了医保,走医保流程
  5636. var res ResultSixteen
  5637. var resSixteen10265 ResultSixteen10265
  5638. var src_resquest string
  5639. var result string
  5640. if miConfig.MdtrtareaAdmvs == "421300" {
  5641. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5642. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5643. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5644. resp3, requestErr3 := http.Get(api3)
  5645. if requestErr3 != nil {
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return
  5648. }
  5649. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5650. if ioErr3 != nil {
  5651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5653. return
  5654. }
  5655. var respJSON3 map[string]interface{}
  5656. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5659. return
  5660. }
  5661. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5662. userJSONBytes3, _ := json.Marshal(respJSON3)
  5663. fmt.Println("log")
  5664. fmt.Println(string(userJSONBytes3))
  5665. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5666. utils.ErrorLog("解析失败:%v", err)
  5667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5668. return
  5669. }
  5670. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5671. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5672. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5673. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5674. resp3, requestErr3 := http.Get(api3)
  5675. if requestErr3 != nil {
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5680. if ioErr3 != nil {
  5681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. var respJSON3 map[string]interface{}
  5686. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5689. return
  5690. }
  5691. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5692. userJSONBytes3, _ := json.Marshal(respJSON3)
  5693. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5694. utils.ErrorLog("解析失败:%v", err)
  5695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5696. return
  5697. }
  5698. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5699. res.Output = resSixteen10265.Output
  5700. res.ErrMsg = resSixteen10265.ErrMsg
  5701. res.Cainfo = resSixteen10265.Cainfo
  5702. res.WarnMsg = resSixteen10265.WarnMsg
  5703. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5704. res.Infcode = infocode
  5705. } else {
  5706. if miConfig.Code == "H15049901371" {
  5707. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5708. var dat map[string]interface{}
  5709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5710. fmt.Println(dat)
  5711. } else {
  5712. fmt.Println(err)
  5713. }
  5714. saveLog(result, src_resquest, "2208", "退费")
  5715. userJSONBytes, _ := json.Marshal(dat)
  5716. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5717. utils.ErrorLog("解析失败:%v", err)
  5718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5719. return
  5720. }
  5721. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5722. res.Output = resSixteen10265.Output
  5723. res.ErrMsg = resSixteen10265.ErrMsg
  5724. res.Cainfo = resSixteen10265.Cainfo
  5725. res.WarnMsg = resSixteen10265.WarnMsg
  5726. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5727. res.Infcode = infocode
  5728. } else {
  5729. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5730. var dat map[string]interface{}
  5731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5732. fmt.Println(dat)
  5733. } else {
  5734. fmt.Println(err)
  5735. }
  5736. saveLog(result, src_resquest, "2208", "退费")
  5737. userJSONBytes, _ := json.Marshal(dat)
  5738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5739. utils.ErrorLog("解析失败:%v", err)
  5740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5741. return
  5742. }
  5743. }
  5744. }
  5745. if res.Infcode == 0 {
  5746. var res2 ResultSix
  5747. var resSix10265 ResultSix10265
  5748. if miConfig.MdtrtareaAdmvs == "421300" {
  5749. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5750. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5751. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5752. resp3, requestErr3 := http.Get(api3)
  5753. if requestErr3 != nil {
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5755. return
  5756. }
  5757. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5758. if ioErr3 != nil {
  5759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5761. return
  5762. }
  5763. var respJSON3 map[string]interface{}
  5764. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5767. return
  5768. }
  5769. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5770. userJSONBytes3, _ := json.Marshal(respJSON3)
  5771. fmt.Println("log")
  5772. fmt.Println(string(userJSONBytes3))
  5773. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5774. utils.ErrorLog("解析失败:%v", err)
  5775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5776. return
  5777. }
  5778. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5779. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5780. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5781. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5782. resp3, requestErr3 := http.Get(api3)
  5783. if requestErr3 != nil {
  5784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5785. return
  5786. }
  5787. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5788. if ioErr3 != nil {
  5789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. return
  5792. }
  5793. var respJSON3 map[string]interface{}
  5794. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5797. return
  5798. }
  5799. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5800. userJSONBytes3, _ := json.Marshal(respJSON3)
  5801. fmt.Println("log")
  5802. fmt.Println(string(userJSONBytes3))
  5803. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5804. utils.ErrorLog("解析失败:%v", err)
  5805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5806. return
  5807. }
  5808. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5809. res2.Output = resSix10265.Output
  5810. res2.ErrMsg = resSix10265.ErrMsg
  5811. res2.Cainfo = resSix10265.Cainfo
  5812. res2.WarnMsg = resSix10265.WarnMsg
  5813. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5814. res2.Infcode = infocode
  5815. } else {
  5816. if miConfig.Code == "H15049901371" {
  5817. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5818. var dat map[string]interface{}
  5819. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5820. fmt.Println(dat)
  5821. } else {
  5822. fmt.Println(err)
  5823. }
  5824. saveLog(result2, src_request, "2205", "撤销明细")
  5825. userJSONBytes, _ := json.Marshal(dat)
  5826. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5827. utils.ErrorLog("解析失败:%v", err)
  5828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5829. return
  5830. }
  5831. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5832. res2.Output = resSix10265.Output
  5833. res2.ErrMsg = resSix10265.ErrMsg
  5834. res2.Cainfo = resSix10265.Cainfo
  5835. res2.WarnMsg = resSix10265.WarnMsg
  5836. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5837. res2.Infcode = infocode
  5838. } else {
  5839. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5840. var dat map[string]interface{}
  5841. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5842. fmt.Println(dat)
  5843. } else {
  5844. fmt.Println(err)
  5845. }
  5846. saveLog(result2, src_request, "2205", "撤销明细")
  5847. userJSONBytes, _ := json.Marshal(dat)
  5848. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5849. utils.ErrorLog("解析失败:%v", err)
  5850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5851. return
  5852. }
  5853. }
  5854. }
  5855. if res2.Infcode == 0 {
  5856. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5857. if err == nil {
  5858. c.ServeSuccessJSON(map[string]interface{}{
  5859. "msg": "退费成功",
  5860. })
  5861. } else {
  5862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5863. return
  5864. }
  5865. } else {
  5866. c.ServeSuccessJSON(map[string]interface{}{
  5867. "code": -10,
  5868. "msg": res2.ErrMsg,
  5869. })
  5870. }
  5871. } else {
  5872. c.ServeSuccessJSON(map[string]interface{}{
  5873. "code": -10,
  5874. "msg": res.ErrMsg,
  5875. })
  5876. }
  5877. }
  5878. }
  5879. func (c *HisApiController) RefundNumber() {
  5880. record_time := c.GetString("record_time")
  5881. //patient_id, _ := c.GetInt64("patient_id")
  5882. admin_user_id, _ := c.GetInt64("admin_user_id")
  5883. his_patient_id, _ := c.GetInt64("id")
  5884. timeLayout := "2006-01-02"
  5885. loc, _ := time.LoadLocation("Local")
  5886. adminUser := c.GetAdminUserInfo()
  5887. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5888. fmt.Println(err)
  5889. if err != nil {
  5890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5891. return
  5892. }
  5893. recordDateTime := theTime.Unix()
  5894. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5895. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5896. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5897. //order, _ := service.GetHisOrderByID(order_id)
  5898. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5899. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5900. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5901. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5902. if count > 0 {
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5904. return
  5905. }
  5906. if config.IsOpen == 1 { //对接了医保,走医保流程
  5907. var res2 ResultSix
  5908. var resSix10265 ResultSix10265
  5909. if miConfig.MdtrtareaAdmvs == "421300" {
  5910. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5911. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5912. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5913. resp3, requestErr3 := http.Get(api3)
  5914. if requestErr3 != nil {
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5919. if ioErr3 != nil {
  5920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. var respJSON3 map[string]interface{}
  5925. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5931. userJSONBytes3, _ := json.Marshal(respJSON3)
  5932. fmt.Println("log")
  5933. fmt.Println(string(userJSONBytes3))
  5934. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5935. utils.ErrorLog("解析失败:%v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. return
  5938. }
  5939. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5940. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5941. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5943. resp3, requestErr3 := http.Get(api3)
  5944. if requestErr3 != nil {
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. return
  5947. }
  5948. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5949. if ioErr3 != nil {
  5950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5952. return
  5953. }
  5954. var respJSON3 map[string]interface{}
  5955. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. return
  5959. }
  5960. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5961. userJSONBytes3, _ := json.Marshal(respJSON3)
  5962. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5963. utils.ErrorLog("解析失败:%v", err)
  5964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5965. return
  5966. }
  5967. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5968. res2.Output = resSix10265.Output
  5969. res2.ErrMsg = resSix10265.ErrMsg
  5970. res2.Cainfo = resSix10265.Cainfo
  5971. res2.WarnMsg = resSix10265.WarnMsg
  5972. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5973. res2.Infcode = infocode
  5974. } else {
  5975. var api3 string
  5976. if miConfig.Code == "H15049901371" {
  5977. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5978. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5980. } else {
  5981. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5982. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5984. }
  5985. resp3, requestErr3 := http.Get(api3)
  5986. if requestErr3 != nil {
  5987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5988. return
  5989. }
  5990. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5991. if ioErr3 != nil {
  5992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5994. return
  5995. }
  5996. var respJSON3 map[string]interface{}
  5997. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return
  6001. }
  6002. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6003. userJSONBytes3, _ := json.Marshal(respJSON3)
  6004. if miConfig.Code == "H15049901371" {
  6005. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6006. utils.ErrorLog("解析失败:%v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6011. res2.Output = resSix10265.Output
  6012. res2.ErrMsg = resSix10265.ErrMsg
  6013. res2.Cainfo = resSix10265.Cainfo
  6014. res2.WarnMsg = resSix10265.WarnMsg
  6015. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6016. res2.Infcode = infocode
  6017. } else {
  6018. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6019. utils.ErrorLog("解析失败:%v", err)
  6020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. return
  6022. }
  6023. }
  6024. }
  6025. if res2.Infcode == 0 {
  6026. if err == nil {
  6027. c.ServeSuccessJSON(map[string]interface{}{
  6028. "msg": "退号成功",
  6029. })
  6030. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6031. } else {
  6032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6033. return
  6034. }
  6035. } else {
  6036. c.ServeSuccessJSON(map[string]interface{}{
  6037. "code": -10,
  6038. "msg": res2.ErrMsg,
  6039. })
  6040. }
  6041. } else {
  6042. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6043. //if err == nil {
  6044. // c.ServeSuccessJSON(map[string]interface{}{
  6045. // "msg": "退费成功",
  6046. // })
  6047. //} else {
  6048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6049. // return
  6050. //}
  6051. }
  6052. }
  6053. func (c *HisApiController) RefundDetail() {
  6054. order_id, _ := c.GetInt64("order_id")
  6055. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6056. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6057. number := c.GetString("number")
  6058. record_time := c.GetString("record_time")
  6059. patient_id, _ := c.GetInt64("patient_id")
  6060. timeLayout := "2006-01-02"
  6061. loc, _ := time.LoadLocation("Local")
  6062. adminUser := c.GetAdminUserInfo()
  6063. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6064. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6065. fmt.Println(err)
  6066. if err != nil {
  6067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6068. return
  6069. }
  6070. recordDateTime := theTime.Unix()
  6071. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6072. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6073. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6074. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6075. var order models.HisOrder
  6076. order, _ = service.GetHisOrderByID(order_id)
  6077. if order.ID == 0 {
  6078. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6079. }
  6080. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6081. if config.IsOpen == 1 { //对接了医保,走医保流程
  6082. var res2 ResultSix
  6083. if miConfig.MdtrtareaAdmvs == "421300" {
  6084. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6085. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6086. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6087. resp3, requestErr3 := http.Get(api3)
  6088. if requestErr3 != nil {
  6089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6090. return
  6091. }
  6092. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6093. if ioErr3 != nil {
  6094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6096. return
  6097. }
  6098. var respJSON3 map[string]interface{}
  6099. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6102. return
  6103. }
  6104. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6105. userJSONBytes3, _ := json.Marshal(respJSON3)
  6106. fmt.Println("log")
  6107. fmt.Println(string(userJSONBytes3))
  6108. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6109. utils.ErrorLog("解析失败:%v", err)
  6110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6111. return
  6112. }
  6113. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6114. if err == nil {
  6115. c.ServeSuccessJSON(map[string]interface{}{
  6116. "msg": "撤销明细成功",
  6117. })
  6118. return
  6119. } else {
  6120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6121. return
  6122. }
  6123. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6124. var resSix10265 ResultSix10265
  6125. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6126. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6127. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6128. resp3, requestErr3 := http.Get(api3)
  6129. if requestErr3 != nil {
  6130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6131. return
  6132. }
  6133. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6134. if ioErr3 != nil {
  6135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6137. return
  6138. }
  6139. var respJSON3 map[string]interface{}
  6140. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6143. return
  6144. }
  6145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6146. userJSONBytes3, _ := json.Marshal(respJSON3)
  6147. fmt.Println("log")
  6148. fmt.Println(string(userJSONBytes3))
  6149. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6150. utils.ErrorLog("解析失败:%v", err)
  6151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6152. return
  6153. }
  6154. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6155. res2.Output = resSix10265.Output
  6156. res2.ErrMsg = resSix10265.ErrMsg
  6157. res2.Cainfo = resSix10265.Cainfo
  6158. res2.WarnMsg = resSix10265.WarnMsg
  6159. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6160. res2.Infcode = infocode
  6161. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6162. if err == nil {
  6163. c.ServeSuccessJSON(map[string]interface{}{
  6164. "msg": "撤销明细成功",
  6165. })
  6166. return
  6167. } else {
  6168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6169. return
  6170. }
  6171. } else {
  6172. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6173. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6174. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6175. resp2, requestErr2 := http.Get(api2)
  6176. if requestErr2 != nil {
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. return
  6179. }
  6180. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6181. if ioErr2 != nil {
  6182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6184. return
  6185. }
  6186. var respJSON2 map[string]interface{}
  6187. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6190. return
  6191. }
  6192. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6193. if err == nil {
  6194. c.ServeSuccessJSON(map[string]interface{}{
  6195. "msg": "撤销明细成功",
  6196. })
  6197. return
  6198. } else {
  6199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6200. return
  6201. }
  6202. }
  6203. } else {
  6204. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6205. if err == nil {
  6206. c.ServeSuccessJSON(map[string]interface{}{
  6207. "msg": "退费成功",
  6208. })
  6209. } else {
  6210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6211. return
  6212. }
  6213. }
  6214. }
  6215. //对账
  6216. func (c *HisApiController) GetCheckAccount() {
  6217. start_time := c.GetString("start_time")
  6218. end_time := c.GetString("end_time")
  6219. insutype := c.GetString("insutype")
  6220. clr_type := c.GetString("clr_type")
  6221. clr_org := c.GetString("clr_optins")
  6222. admin_user_id, _ := c.GetInt64("admin_user_id")
  6223. adminUser := c.GetAdminUserInfo()
  6224. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6225. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6226. if len(clr_org) == 0 {
  6227. clr_org = miConfig.MdtrtareaAdmvs
  6228. }
  6229. timeLayout := "2006-01-02"
  6230. loc, _ := time.LoadLocation("Local")
  6231. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6232. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6233. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6234. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  6235. fixmedins_setl_cnt := int64(len(orders))
  6236. //
  6237. ////撤销的算2条数据为一笔
  6238. //for _, item := range orders_two {
  6239. // if item.OrderStatus == 3 {
  6240. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  6241. // }
  6242. //}
  6243. var medfee_sumamt float64
  6244. var acct_pay float64
  6245. var fund_pay_sumamt float64
  6246. for _, item := range orders {
  6247. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6248. acct_pay = acct_pay + item.AcctPay
  6249. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6250. }
  6251. var user_name string
  6252. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6253. if role.ID == 0 {
  6254. user_name = "xxx"
  6255. } else {
  6256. user_name = role.UserName
  6257. }
  6258. if config.IsOpen == 1 {
  6259. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6260. "insutype=" + insutype +
  6261. "&clr_type=" + clr_type +
  6262. "&setl_optins=" + clr_org +
  6263. "&stmt_begndate=" + start_time +
  6264. "&stm_enddate=" + end_time +
  6265. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6266. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6267. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6268. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6269. "&fixmedins_code=" + miConfig.Code +
  6270. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6271. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6272. "&secret_key=" + miConfig.SecretKey +
  6273. "&org_name=" + miConfig.OrgName +
  6274. "&doctor=" + user_name
  6275. fmt.Println(api)
  6276. resp, requestErr := http.Get(api)
  6277. if requestErr != nil {
  6278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6279. return
  6280. }
  6281. body, ioErr := ioutil.ReadAll(resp.Body)
  6282. fmt.Println(body)
  6283. if ioErr != nil {
  6284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6286. return
  6287. }
  6288. var respJSON map[string]interface{}
  6289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6292. return
  6293. }
  6294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6295. userJSONBytes, _ := json.Marshal(respJSON)
  6296. var res ResultEight
  6297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6298. utils.ErrorLog("解析失败:%v", err)
  6299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6300. return
  6301. }
  6302. if res.Infcode == 0 {
  6303. if res.Output.Stmtinfo.StmtRslt == "0" {
  6304. micc := &models.MedicalInsuranceCostCompare{
  6305. StartTime: startime.Unix(),
  6306. EndTime: endtime.Unix(),
  6307. Insutype: insutype,
  6308. CheckType: 1,
  6309. Num: fixmedins_setl_cnt,
  6310. Mtime: time.Now().Unix(),
  6311. Status: 1,
  6312. UserOrgId: adminUser.CurrentOrgId,
  6313. CostTotal: medfee_sumamt,
  6314. FuncTotal: fund_pay_sumamt,
  6315. PsnPay: acct_pay,
  6316. Creator: admin_user_id,
  6317. Ctime: time.Now().Unix(),
  6318. }
  6319. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6320. if err == nil {
  6321. c.ServeSuccessJSON(map[string]interface{}{
  6322. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6323. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6324. })
  6325. } else {
  6326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6327. }
  6328. } else {
  6329. c.ServeSuccessJSON(map[string]interface{}{
  6330. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6331. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6332. })
  6333. }
  6334. } else {
  6335. c.ServeSuccessJSON(map[string]interface{}{
  6336. "code": -10,
  6337. "msg": res.ErrMsg,
  6338. })
  6339. }
  6340. }
  6341. }
  6342. func (c *HisApiController) Check310() {
  6343. adminUser := c.GetAdminUserInfo()
  6344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6345. var user_name string
  6346. user_name = "高慧裕"
  6347. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6348. "insutype=" + "310" +
  6349. "&clr_type=" + "11" +
  6350. "&setl_optins=" + "441202" +
  6351. "&stmt_begndate=" + "2022-02-01" +
  6352. "&stm_enddate=" + "2022-02-28" +
  6353. "&medfee_sumamt=" + "155812.88" +
  6354. "&fund_pay_sumamt=" + "151026.03" +
  6355. "&acct_pay=" + "0" +
  6356. "&fixmedins_setl_cnt=" + "73" +
  6357. "&fixmedins_code=" + miConfig.Code +
  6358. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6359. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6360. "&secret_key=" + miConfig.SecretKey +
  6361. "&org_name=" + miConfig.OrgName +
  6362. "&doctor=" + user_name
  6363. fmt.Println(api)
  6364. resp, requestErr := http.Get(api)
  6365. if requestErr != nil {
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. body, ioErr := ioutil.ReadAll(resp.Body)
  6370. fmt.Println(body)
  6371. if ioErr != nil {
  6372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. return
  6375. }
  6376. var respJSON map[string]interface{}
  6377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. return
  6381. }
  6382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6383. userJSONBytes, _ := json.Marshal(respJSON)
  6384. var res ResultEight
  6385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6386. utils.ErrorLog("解析失败:%v", err)
  6387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6388. return
  6389. }
  6390. }
  6391. func (c *HisApiController) Check390() {
  6392. adminUser := c.GetAdminUserInfo()
  6393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6394. var user_name string
  6395. user_name = "高慧裕"
  6396. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6397. "insutype=" + "390" +
  6398. "&clr_type=" + "11" +
  6399. "&setl_optins=" + "441202" +
  6400. "&stmt_begndate=" + "2022-02-01" +
  6401. "&stm_enddate=" + "2022-02-28" +
  6402. "&medfee_sumamt=" + "933920.08" +
  6403. "&fund_pay_sumamt=" + "904130.94" +
  6404. "&acct_pay=" + "0" +
  6405. "&fixmedins_setl_cnt=" + "396" +
  6406. "&fixmedins_code=" + miConfig.Code +
  6407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6408. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6409. "&secret_key=" + miConfig.SecretKey +
  6410. "&org_name=" + miConfig.OrgName +
  6411. "&doctor=" + user_name
  6412. fmt.Println(api)
  6413. resp, requestErr := http.Get(api)
  6414. if requestErr != nil {
  6415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6416. return
  6417. }
  6418. body, ioErr := ioutil.ReadAll(resp.Body)
  6419. fmt.Println(body)
  6420. if ioErr != nil {
  6421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6423. return
  6424. }
  6425. var respJSON map[string]interface{}
  6426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. return
  6430. }
  6431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6432. userJSONBytes, _ := json.Marshal(respJSON)
  6433. var res ResultEight
  6434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6435. utils.ErrorLog("解析失败:%v", err)
  6436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6437. return
  6438. }
  6439. }
  6440. //对账明细
  6441. func (c *HisApiController) GetCheckDetailAccount() {
  6442. start_time := c.GetString("start_time")
  6443. end_time := c.GetString("end_time")
  6444. admin_user_id, _ := c.GetInt64("admin_user_id")
  6445. adminUser := c.GetAdminUserInfo()
  6446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6447. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6448. timeLayout := "2006-01-02"
  6449. loc, _ := time.LoadLocation("Local")
  6450. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6451. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6452. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6453. Mkdir(miConfig.OrgName)
  6454. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6455. file_name := file + ".txt"
  6456. zip_name := file + ".zip"
  6457. zip_path := miConfig.OrgName + "/" + zip_name
  6458. file_path := miConfig.OrgName + "/" + file_name
  6459. decimal.DivisionPrecision = 2
  6460. var medfee_sumamt float64
  6461. var psn_cash_pay float64
  6462. var fund_pay_sumamt float64
  6463. fixmedins_setl_cnt := int64(len(orders))
  6464. for _, item := range orders {
  6465. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6466. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6467. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6468. }
  6469. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6470. defer f.Close()
  6471. if err != nil {
  6472. fmt.Println(err.Error())
  6473. } else {
  6474. for _, item := range orders {
  6475. var refd_setl_flag string
  6476. if item.OrderStatus == 2 {
  6477. refd_setl_flag = "0"
  6478. var str string
  6479. str = item.SetlId + " " +
  6480. item.MdtrtId + " " +
  6481. item.PsnNo + " " +
  6482. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6483. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6484. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6485. _, err = f.Write([]byte(str))
  6486. }
  6487. if item.OrderStatus == 3 {
  6488. var str string
  6489. str = item.SetlId + " " +
  6490. item.MdtrtId + " " +
  6491. item.PsnNo + " " +
  6492. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6493. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6494. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6495. _, err = f.Write([]byte(str))
  6496. var str2 string
  6497. str2 = item.SetlId + " " +
  6498. item.MdtrtId + " " +
  6499. item.PsnNo + " " +
  6500. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6501. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6502. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6503. _, err = f.Write([]byte(str2))
  6504. }
  6505. }
  6506. }
  6507. Zip(file_path, zip_path)
  6508. fmt.Println(ReadFile(zip_path))
  6509. fmt.Println(string(ReadFile(zip_path)))
  6510. if config.IsOpen == 1 {
  6511. var user_name string
  6512. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6513. if role.ID == 0 {
  6514. user_name = "管理员"
  6515. } else {
  6516. user_name = role.UserName
  6517. }
  6518. baseParams := models.BaseParams{
  6519. SecretKey: miConfig.SecretKey,
  6520. FixmedinsCode: miConfig.Code,
  6521. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6522. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6523. OrgName: miConfig.OrgName,
  6524. Doctor: user_name,
  6525. }
  6526. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6527. var dat map[string]interface{}
  6528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6529. fmt.Println(dat)
  6530. } else {
  6531. fmt.Println(err)
  6532. }
  6533. userJSONBytes, _ := json.Marshal(dat)
  6534. var res ResultNine
  6535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6536. utils.ErrorLog("解析失败:%v", err)
  6537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6538. return
  6539. }
  6540. if res.Infcode == 0 {
  6541. fileNo := res.Output.FileQuryNo
  6542. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6543. "file_qury_no=" + fileNo +
  6544. "&setl_optins=" + "定点医保中心" +
  6545. "&stmt_begndate=" + start_time +
  6546. "&stm_enddate=" + end_time +
  6547. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6548. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6549. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6550. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6551. "&fixmedins_code=" + miConfig.Code +
  6552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6553. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6554. "&secret_key=" + miConfig.SecretKey +
  6555. "&org_name=" + miConfig.OrgName +
  6556. "&doctor=" + user_name
  6557. resp, requestErr := http.Get(api)
  6558. if requestErr != nil {
  6559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6560. return
  6561. }
  6562. body, ioErr := ioutil.ReadAll(resp.Body)
  6563. if ioErr != nil {
  6564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. return
  6567. }
  6568. var respJSON map[string]interface{}
  6569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6575. userJSONBytes, _ := json.Marshal(respJSON)
  6576. var res ResultTen
  6577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6578. utils.ErrorLog("解析失败:%v", err)
  6579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6580. return
  6581. }
  6582. if res.Infcode == 0 {
  6583. service.Gdyb9102(baseParams, zip_name, fileNo)
  6584. micc := &models.MedicalInsuranceCostCompare{
  6585. StartTime: startime.Unix(),
  6586. EndTime: endtime.Unix(),
  6587. Insutype: "0",
  6588. CheckType: 2,
  6589. Num: fixmedins_setl_cnt,
  6590. Mtime: time.Now().Unix(),
  6591. Status: 1,
  6592. UserOrgId: adminUser.CurrentOrgId,
  6593. CostTotal: medfee_sumamt,
  6594. FuncTotal: fund_pay_sumamt,
  6595. PsnPay: psn_cash_pay,
  6596. Creator: admin_user_id,
  6597. Ctime: time.Now().Unix(),
  6598. }
  6599. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6600. c.ServeSuccessJSON(map[string]interface{}{
  6601. "msg": "明细对账成功",
  6602. })
  6603. }
  6604. } else {
  6605. }
  6606. }
  6607. }
  6608. type CustomOrderInfo struct {
  6609. Name string
  6610. Spec string
  6611. Unit string
  6612. Count float64
  6613. Price float64
  6614. Total float64
  6615. }
  6616. func (c *HisApiController) GetSettleAccounts() {
  6617. //id, _ := c.GetInt64("id")
  6618. //record_time := c.GetString("record_time")
  6619. order_id, _ := c.GetInt64("order_id")
  6620. admin_user_id, _ := c.GetInt64("admin_user_id")
  6621. //timeLayout := "2006-01-02"
  6622. //loc, _ := time.LoadLocation("Local")
  6623. //
  6624. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6625. //if err != nil {
  6626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6627. // return
  6628. //}
  6629. //recordDateTime := theTime.Unix()
  6630. adminUser := c.GetAdminUserInfo()
  6631. order, _ := service.GetHisOrderByID(order_id)
  6632. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6633. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6634. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6635. orderInfos = append(orderInfos, orderInfos_two...)
  6636. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6637. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6638. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6639. //var config []*models.HisXtDiagnoseConfig
  6640. var name string
  6641. for _, item := range diagnosis_ids {
  6642. id, _ := strconv.ParseInt(item, 10, 64)
  6643. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6644. if len(name) == 0 {
  6645. name = diagnosisConfig.ClassName
  6646. } else {
  6647. name = name + "," + diagnosisConfig.ClassName
  6648. }
  6649. }
  6650. var bedCostTotal float64 = 0 //床位总费
  6651. var bedCostSelfTotal float64 = 0 //床位自费
  6652. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6653. var operationCostTotal float64 = 0 //手术费
  6654. var operationCostSelfTotal float64 = 0 //手术费
  6655. var operationCostPartSelfTotal float64 = 0 //手术费
  6656. var otherCostTotal float64 = 0 //其他费用
  6657. var otherCostSelfTotal float64 = 0 //其他费用
  6658. var otherCostPartSelfTotal float64 = 0 //其他费用
  6659. var materialCostTotal float64 = 0 //材料费
  6660. var materialCostSelfTotal float64 = 0 //材料费
  6661. var materialCostPartSelfTotal float64 = 0 //材料费
  6662. var westernMedicineCostTotal float64 = 0 //西药费
  6663. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6664. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6665. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6666. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6667. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6668. var checkCostTotal float64 = 0 //检查费
  6669. var checkCostSelfTotal float64 = 0 //检查费
  6670. var checkCostPartSelfTotal float64 = 0 //检查费
  6671. var laboratoryCostTotal float64 = 0 //化验费
  6672. var laboratoryCostSelfTotal float64 = 0 //化验费
  6673. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6674. var treatCostTotal float64 = 0 //治疗费用
  6675. var treatCostSelfTotal float64 = 0 //治疗费用
  6676. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6677. decimal.DivisionPrecision = 2
  6678. for _, item := range orderInfos {
  6679. if item.MedChrgitmType == "01" { //床位费
  6680. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6681. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6682. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6683. }
  6684. if item.MedChrgitmType == "03" { //检查费
  6685. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6686. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6687. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6688. }
  6689. if item.MedChrgitmType == "04" { //化验费
  6690. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6691. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6692. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6693. }
  6694. if item.MedChrgitmType == "05" { //治疗费
  6695. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6696. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6697. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6698. }
  6699. if item.MedChrgitmType == "06" { //手术费
  6700. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6701. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6702. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6703. }
  6704. if item.MedChrgitmType == "08" { //材料费
  6705. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6706. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6707. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6708. }
  6709. if item.MedChrgitmType == "09" { //西药费
  6710. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6711. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6712. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6713. }
  6714. if item.MedChrgitmType == "11" { //中成费
  6715. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6716. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6717. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6718. }
  6719. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6720. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6721. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6722. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6723. }
  6724. }
  6725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6726. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6727. var user_name string
  6728. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6729. if role.ID == 0 {
  6730. user_name = "管理员"
  6731. } else {
  6732. user_name = role.UserName
  6733. }
  6734. baseParams := models.BaseParams{
  6735. SecretKey: miConfig.SecretKey,
  6736. FixmedinsCode: miConfig.Code,
  6737. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6738. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6739. OrgName: miConfig.OrgName,
  6740. Doctor: user_name,
  6741. }
  6742. businessParams := models.BusinessParams{
  6743. PsnNo: order.PsnNo,
  6744. MdtrtId: order.MdtrtId,
  6745. SetlId: order.SetlId,
  6746. }
  6747. var res ResultEleven
  6748. var resEleven10265 ResultEleven10265
  6749. if config.IsOpen == 1 {
  6750. if miConfig.MdtrtareaAdmvs == "421300" {
  6751. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6752. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6753. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6754. resp, requestErr := http.Get(api)
  6755. if requestErr != nil {
  6756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6757. return
  6758. }
  6759. body, ioErr := ioutil.ReadAll(resp.Body)
  6760. if ioErr != nil {
  6761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6763. return
  6764. }
  6765. var respJSON map[string]interface{}
  6766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. return
  6770. }
  6771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6772. result, _ := json.Marshal(respJSON)
  6773. fmt.Println("log")
  6774. fmt.Println(string(result))
  6775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6776. utils.ErrorLog("解析失败:%v", err)
  6777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6778. return
  6779. }
  6780. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6781. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6782. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6783. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6784. resp, requestErr := http.Get(api)
  6785. if requestErr != nil {
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. return
  6788. }
  6789. body, ioErr := ioutil.ReadAll(resp.Body)
  6790. if ioErr != nil {
  6791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6793. return
  6794. }
  6795. var respJSON map[string]interface{}
  6796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6799. return
  6800. }
  6801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6802. result, _ := json.Marshal(respJSON)
  6803. fmt.Println("log")
  6804. fmt.Println(string(result))
  6805. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  6806. utils.ErrorLog("解析失败:%v", err)
  6807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6808. return
  6809. }
  6810. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6811. res.Output = resEleven10265.Output
  6812. res.ErrMsg = resEleven10265.ErrMsg
  6813. res.Cainfo = resEleven10265.Cainfo
  6814. res.WarnMsg = resEleven10265.WarnMsg
  6815. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6816. res.Infcode = infocode
  6817. } else {
  6818. result2 := service.Gdyb5204(baseParams, businessParams)
  6819. saveLog(result2, "", "5204", "查询")
  6820. result := service.Gdyb5203(baseParams, businessParams)
  6821. var dat map[string]interface{}
  6822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6823. fmt.Println(dat)
  6824. } else {
  6825. fmt.Println(err)
  6826. }
  6827. userJSONBytes, _ := json.Marshal(dat)
  6828. if miConfig.Code == "H15049901371" {
  6829. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6830. utils.ErrorLog("解析失败:%v", err)
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6832. return
  6833. }
  6834. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6835. res.Output = resEleven10265.Output
  6836. res.ErrMsg = resEleven10265.ErrMsg
  6837. res.Cainfo = resEleven10265.Cainfo
  6838. res.WarnMsg = resEleven10265.WarnMsg
  6839. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6840. res.Infcode = infocode
  6841. } else {
  6842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6843. utils.ErrorLog("解析失败:%v", err)
  6844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. return
  6846. }
  6847. }
  6848. }
  6849. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6850. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6851. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6852. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6853. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6854. var doctor_name string
  6855. if roles.ID == 0 {
  6856. doctor_name = "管理员"
  6857. } else {
  6858. doctor_name = roles.UserName
  6859. }
  6860. yiliao_leibie := ""
  6861. switch order.MedType {
  6862. case "11":
  6863. yiliao_leibie = "普通门诊"
  6864. break
  6865. case "12":
  6866. yiliao_leibie = "门诊挂号"
  6867. break
  6868. case "13":
  6869. yiliao_leibie = "急诊"
  6870. break
  6871. case "14":
  6872. yiliao_leibie = "门诊特殊病"
  6873. break
  6874. case "15":
  6875. yiliao_leibie = "门诊统筹"
  6876. break
  6877. case "16":
  6878. yiliao_leibie = "门诊慢性病"
  6879. break
  6880. case "21":
  6881. yiliao_leibie = "普通住院"
  6882. break
  6883. }
  6884. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6885. if res.Infcode == 0 {
  6886. c.ServeSuccessJSON(map[string]interface{}{
  6887. "diagnosis": name,
  6888. "order_infos": orderInfos,
  6889. "number": order.MdtrtId,
  6890. "date": order.SettleAccountsDate,
  6891. "charge_admin": charge_admin,
  6892. "printor_admin": printor_admin,
  6893. "info": res.Output.Setlinfo,
  6894. "bedCostTotal": bedCostTotal,
  6895. "bedCostSelfTotal": bedCostSelfTotal,
  6896. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6897. "operationCostTotal": operationCostTotal,
  6898. "operationCostSelfTotal": operationCostSelfTotal,
  6899. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6900. "otherCostTotal": otherCostTotal,
  6901. "otherCostSelfTotal": otherCostSelfTotal,
  6902. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6903. "materialCostTotal": materialCostTotal,
  6904. "materialCostSelfTotal": materialCostSelfTotal,
  6905. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6906. "westernMedicineCostTotal": westernMedicineCostTotal,
  6907. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6908. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6909. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6910. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6911. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6912. "checkCostTotal": checkCostTotal,
  6913. "checkCostSelfTotal": checkCostSelfTotal,
  6914. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6915. "laboratoryCostTotal": laboratoryCostTotal,
  6916. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6917. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6918. "treatCostTotal": treatCostTotal,
  6919. "treatCostSelfTotal": treatCostSelfTotal,
  6920. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6921. "doctor_code": adminRole_two.DoctorCode,
  6922. "doctor_name": doctor_name,
  6923. "health_card_no": order.PsnNo,
  6924. "department": departments.Name,
  6925. "yiliao_leibie": yiliao_leibie,
  6926. "after_money": order.AccountPrice,
  6927. "patient": patient,
  6928. "org_name": miConfig.OrgName,
  6929. "org_code": miConfig.Code,
  6930. "order_number": order.Number,
  6931. //"check_order_info": cus_slice,
  6932. })
  6933. }
  6934. }
  6935. }
  6936. func (c *HisApiController) CheckTreatment() {
  6937. patient_id, _ := c.GetInt64("patient_id")
  6938. id_card_no := c.GetString("id_card_no")
  6939. insutype := c.GetString("insutype")
  6940. med_type := c.GetString("med_type")
  6941. admin_user_id, _ := c.GetInt64("admin_user_id")
  6942. adminUser := c.GetAdminUserInfo()
  6943. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6945. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6946. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6947. if miConfig.MdtrtareaAdmvs == "421300" {
  6948. var res ResultTwo
  6949. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  6950. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6951. "&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)
  6952. resp, requestErr := http.Get(api)
  6953. if requestErr != nil {
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. body, ioErr := ioutil.ReadAll(resp.Body)
  6958. if ioErr != nil {
  6959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. return
  6962. }
  6963. var respJSON map[string]interface{}
  6964. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6967. return
  6968. }
  6969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6970. result, _ := json.Marshal(respJSON)
  6971. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6972. utils.ErrorLog("解析失败:%v", err)
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. return
  6975. }
  6976. if res.Infcode == 0 {
  6977. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  6978. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6979. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  6980. resp, requestErr := http.Get(api)
  6981. if requestErr != nil {
  6982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6983. return
  6984. }
  6985. body, ioErr := ioutil.ReadAll(resp.Body)
  6986. if ioErr != nil {
  6987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. return
  6990. }
  6991. var respJSON map[string]interface{}
  6992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. return
  6996. }
  6997. var res Result2001
  6998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6999. result2, _ := json.Marshal(respJSON)
  7000. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7001. utils.ErrorLog("解析失败:%v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. return
  7004. }
  7005. if res.Infcode == 0 {
  7006. c.ServeSuccessJSON(map[string]interface{}{
  7007. "msg": res.Output.Trtinfo,
  7008. })
  7009. }
  7010. } else {
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7012. return
  7013. }
  7014. } else {
  7015. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7016. var dat map[string]interface{}
  7017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7018. fmt.Println(dat)
  7019. } else {
  7020. fmt.Println(err)
  7021. }
  7022. userJSONBytes, _ := json.Marshal(dat)
  7023. var res ResultTwo
  7024. var res10265 ResultTwo10265
  7025. if miConfig.Code == "H15049901371" {
  7026. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7027. utils.ErrorLog("解析失败:%v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. return
  7030. }
  7031. res.ErrMsg = res10265.ErrMsg
  7032. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7033. res.Infcode = infocode
  7034. res.Output = res10265.Output
  7035. res.InfRefmsgid = res10265.InfRefmsgid
  7036. } else {
  7037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7038. utils.ErrorLog("解析失败:%v", err)
  7039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7040. return
  7041. }
  7042. }
  7043. var user_name string
  7044. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7045. if role.ID == 0 {
  7046. user_name = "xxx"
  7047. } else {
  7048. user_name = role.UserName
  7049. }
  7050. baseParams := models.BaseParams{
  7051. SecretKey: miConfig.SecretKey,
  7052. FixmedinsCode: miConfig.Code,
  7053. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7054. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7055. OrgName: miConfig.OrgName,
  7056. Doctor: user_name,
  7057. }
  7058. if config.IsOpen == 1 {
  7059. if miConfig.Code == "H15049901371" {
  7060. if med_type == "14" {
  7061. if insutype == "390" {
  7062. med_type = "9933"
  7063. } else if insutype == "310" {
  7064. med_type = "990502"
  7065. }
  7066. } else if med_type == "11" {
  7067. med_type = "11"
  7068. }
  7069. }
  7070. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7071. var dat map[string]interface{}
  7072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7073. fmt.Println(dat)
  7074. } else {
  7075. fmt.Println(err)
  7076. }
  7077. var res Result2001
  7078. var res10265 Result2001Org10265
  7079. if miConfig.Code == "H15049901371" {
  7080. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7081. utils.ErrorLog("解析失败:%v", err)
  7082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7083. return
  7084. }
  7085. res.ErrMsg = res10265.ErrMsg
  7086. res.Output = res10265.Output
  7087. res.InfRefmsgid = res10265.InfRefmsgid
  7088. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7089. res.Infcode = infocode
  7090. } else {
  7091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return
  7095. }
  7096. }
  7097. if res.Infcode == 0 {
  7098. c.ServeSuccessJSON(map[string]interface{}{
  7099. "msg": res.Output.Trtinfo,
  7100. })
  7101. }
  7102. }
  7103. }
  7104. }
  7105. //func (c *HisApiController) PutRecord() {
  7106. // id, _ := c.GetInt64("id")
  7107. // record_time := c.GetString("record_time")
  7108. // timeLayout := "2006-01-02"
  7109. // loc, _ := time.LoadLocation("Local")
  7110. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7111. // if err != nil {
  7112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7113. // return
  7114. // }
  7115. // recordDateTime := theTime.Unix()
  7116. //
  7117. // adminInfo := c.GetAdminUserInfo()
  7118. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7119. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7120. //
  7121. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7122. //
  7123. // fmt.Println(miConfig.SecretKey)
  7124. //
  7125. // if patient == nil {
  7126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7127. // return
  7128. // }
  7129. // if len(patient.IdCardNo) == 0 {
  7130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7131. // return
  7132. // }
  7133. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7134. // if config.IsOpen == 1 {
  7135. // 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
  7136. // resp, requestErr := http.Get(api)
  7137. // if requestErr != nil {
  7138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. // return
  7140. // }
  7141. // defer resp.Body.Close()
  7142. // body, ioErr := ioutil.ReadAll(resp.Body)
  7143. // if ioErr != nil {
  7144. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7146. // return
  7147. // }
  7148. // var respJSON map[string]interface{}
  7149. //
  7150. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7151. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7153. // return
  7154. // }
  7155. //
  7156. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7157. // userJSONBytes, _ := json.Marshal(userJSON)
  7158. // var res ResultTwo
  7159. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7160. // utils.ErrorLog("解析失败:%v", err)
  7161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. // return
  7163. // }
  7164. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7165. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7166. // infoStr := string(Iinfos)
  7167. // idetinfoStr := string(Idetinfos)
  7168. //
  7169. // if res.Infcode == 0 {
  7170. // his := models.VMHisPatient{
  7171. // Status: 1,
  7172. // Ctime: time.Now().Unix(),
  7173. // Mtime: time.Now().Unix(),
  7174. // PsnNo: res.Output.Baseinfo.PsnNo,
  7175. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7176. // Certno: res.Output.Baseinfo.Certno,
  7177. // PsnName: res.Output.Baseinfo.PsnName,
  7178. // Gend: res.Output.Baseinfo.Gend,
  7179. // Naty: res.Output.Baseinfo.Naty,
  7180. // Brdy: res.Output.Baseinfo.Brdy,
  7181. // Age: res.Output.Baseinfo.Age,
  7182. // Iinfo: infoStr,
  7183. // Idetinfo: idetinfoStr,
  7184. // PatientId: patient.ID,
  7185. // RecordDate: theTime.Unix(),
  7186. // UserOrgId: adminInfo.CurrentOrgId,
  7187. // AdminUserId: adminInfo.AdminUser.Id,
  7188. // IsReturn: 1,
  7189. // }
  7190. //
  7191. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7192. // //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")
  7193. // //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")
  7194. //
  7195. // //var dat map[string]interface{}
  7196. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7197. // // fmt.Println(dat)
  7198. // //} else {
  7199. // // fmt.Println(err)
  7200. // //}
  7201. //
  7202. // var dat2 map[string]interface{}
  7203. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7204. // fmt.Println(dat2)
  7205. // } else {
  7206. // fmt.Println(err)
  7207. // }
  7208. //
  7209. // } else {
  7210. // adminUser := c.GetAdminUserInfo()
  7211. // errlog := &models.HisOrderError{
  7212. // UserOrgId: adminUser.CurrentOrgId,
  7213. // Ctime: time.Now().Unix(),
  7214. // Mtime: time.Now().Unix(),
  7215. // ErrMsg: res.ErrMsg,
  7216. // Status: 1,
  7217. // PatientId: id,
  7218. // RecordTime: recordDateTime,
  7219. // Stage: 1,
  7220. // }
  7221. // service.CreateErrMsgLog(errlog)
  7222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7223. // return
  7224. // }
  7225. // }
  7226. //
  7227. //}
  7228. //func (c *HisApiController) GetUploadDiag() {
  7229. // id, _ := c.GetInt64("id")
  7230. // record_time := c.GetString("record_time")
  7231. //
  7232. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7233. // sick_type, _ := c.GetInt64("sick_type")
  7234. // reg_type, _ := c.GetInt64("reg_type")
  7235. //
  7236. // timeLayout := "2006-01-02"
  7237. // loc, _ := time.LoadLocation("Local")
  7238. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7239. // if err != nil {
  7240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7241. // return
  7242. // }
  7243. //
  7244. // var patientPrescription models.HisPrescriptionInfo
  7245. // recordDateTime := theTime.Unix()
  7246. // adminInfo := c.GetAdminUserInfo()
  7247. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7248. //
  7249. // if patientPrescription.ID == 0 {
  7250. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7251. // }
  7252. //
  7253. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7254. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7255. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7256. // sickConfig, _ := service.FindSickById(sick_type)
  7257. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7258. //
  7259. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7260. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7261. // "&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 +
  7262. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7263. // resp2, requestErr2 := http.Get(api2)
  7264. // if requestErr2 != nil {
  7265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7266. // return
  7267. // }
  7268. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7269. // if ioErr2 != nil {
  7270. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7272. // return
  7273. // }
  7274. // var respJSON2 map[string]interface{}
  7275. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7276. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7278. // return
  7279. // }
  7280. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7281. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7282. //
  7283. // var res2 ResultSix
  7284. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7285. // utils.ErrorLog("解析失败:%v", err)
  7286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7287. // return
  7288. // }
  7289. // if res2.Infcode != 0 {
  7290. // adminUser := c.GetAdminUserInfo()
  7291. // errlog := &models.HisOrderError{
  7292. // UserOrgId: adminUser.CurrentOrgId,
  7293. // Ctime: time.Now().Unix(),
  7294. // Mtime: time.Now().Unix(),
  7295. // ErrMsg: res2.ErrMsg,
  7296. // Status: 1,
  7297. // PatientId: id,
  7298. // RecordTime: recordDateTime,
  7299. // Stage: 3,
  7300. // }
  7301. // service.CreateErrMsgLog(errlog)
  7302. //
  7303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7304. // return
  7305. // }
  7306. //
  7307. // c.ServeSuccessJSON(map[string]interface{}{
  7308. // "msg": "上传成功",
  7309. // })
  7310. //
  7311. //}
  7312. type QueryResult struct {
  7313. ID int64
  7314. Name string
  7315. Code string
  7316. List_type_code string
  7317. }
  7318. func (c *HisApiController) GetCheckCode() {
  7319. ids_str := c.GetString("ids")
  7320. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7321. ids_arr := strings.Split(ids_str, ",")
  7322. var queryResult []QueryResult
  7323. ids := make([]int64, 0)
  7324. for _, item := range ids_arr {
  7325. id, _ := strconv.ParseInt(item, 10, 64)
  7326. ids = append(ids, id)
  7327. }
  7328. if record_type == 1 {
  7329. drugs, _ := service.GetBatchDrugList(ids)
  7330. for _, item := range drugs {
  7331. result := QueryResult{
  7332. ID: item.ID,
  7333. Name: item.DrugName,
  7334. Code: item.MedicalInsuranceNumber,
  7335. List_type_code: "101",
  7336. }
  7337. queryResult = append(queryResult, result)
  7338. }
  7339. } else if record_type == 2 {
  7340. goods, _ := service.GetBatchGoodInformationList(ids)
  7341. for _, item := range goods {
  7342. result := QueryResult{
  7343. ID: item.ID,
  7344. Name: item.GoodName,
  7345. Code: item.MedicalInsuranceNumber,
  7346. List_type_code: "301",
  7347. }
  7348. queryResult = append(queryResult, result)
  7349. }
  7350. } else if record_type == 3 {
  7351. projects, _ := service.GetBathchMyPorjecgList(ids)
  7352. for _, item := range projects {
  7353. result := QueryResult{
  7354. ID: item.ID,
  7355. Name: item.ProjectName,
  7356. Code: item.MedicalCode,
  7357. List_type_code: "201",
  7358. }
  7359. queryResult = append(queryResult, result)
  7360. }
  7361. }
  7362. admin_user_id, _ := c.GetInt64("admin_user_id")
  7363. adminUser := c.GetAdminUserInfo()
  7364. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7365. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7366. var user_name string
  7367. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7368. if role.ID == 0 {
  7369. user_name = "xxx"
  7370. } else {
  7371. user_name = role.UserName
  7372. }
  7373. baseParams := &models.BaseParams{
  7374. SecretKey: miConfig.SecretKey,
  7375. FixmedinsCode: miConfig.Code,
  7376. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7377. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7378. OrgName: miConfig.OrgName,
  7379. Doctor: user_name,
  7380. }
  7381. if config.IsOpen == 1 {
  7382. for _, item := range queryResult {
  7383. var result string
  7384. if record_type == 1 {
  7385. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7386. } else if record_type == 2 {
  7387. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7388. } else if record_type == 3 {
  7389. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7390. }
  7391. var dat map[string]interface{}
  7392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7393. fmt.Println(dat)
  7394. } else {
  7395. fmt.Println(err)
  7396. }
  7397. userJSONBytes, _ := json.Marshal(dat)
  7398. var res ResultSix
  7399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7400. utils.ErrorLog("解析失败:%v", err)
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. if res.Infcode == 0 {
  7405. if record_type == 1 {
  7406. service.UpdateBaseDrugById(item.ID)
  7407. } else if record_type == 2 {
  7408. service.UpdateGoodInformaitonByDetail(item.ID)
  7409. } else if record_type == 3 {
  7410. service.UpdateProjectById(item.ID)
  7411. }
  7412. c.ServeSuccessJSON(map[string]interface{}{
  7413. "failed_code": 0,
  7414. "msg": "目录对照成功",
  7415. })
  7416. } else {
  7417. c.ServeSuccessJSON(map[string]interface{}{
  7418. "failed_code": -10,
  7419. "msg": res.ErrMsg,
  7420. })
  7421. }
  7422. }
  7423. }
  7424. }
  7425. func (c *HisApiController) UnCheckCode() {
  7426. ids_str := c.GetString("ids")
  7427. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7428. admin_user_id, _ := c.GetInt64("admin_user_id")
  7429. ids_arr := strings.Split(ids_str, ",")
  7430. var queryResult []QueryResult
  7431. ids := make([]int64, 0)
  7432. for _, item := range ids_arr {
  7433. id, _ := strconv.ParseInt(item, 10, 64)
  7434. ids = append(ids, id)
  7435. }
  7436. if record_type == 1 {
  7437. drugs, _ := service.GetBatchDrugList(ids)
  7438. for _, item := range drugs {
  7439. result := QueryResult{
  7440. ID: item.ID,
  7441. Name: item.DrugName,
  7442. Code: item.MedicalInsuranceNumber,
  7443. List_type_code: "101",
  7444. }
  7445. queryResult = append(queryResult, result)
  7446. }
  7447. } else if record_type == 2 {
  7448. goods, _ := service.GetBatchGoodInformationList(ids)
  7449. for _, item := range goods {
  7450. result := QueryResult{
  7451. ID: item.ID,
  7452. Name: item.GoodName,
  7453. Code: item.MedicalInsuranceNumber,
  7454. List_type_code: "301",
  7455. }
  7456. queryResult = append(queryResult, result)
  7457. }
  7458. } else if record_type == 3 {
  7459. projects, _ := service.GetBathchMyPorjecgList(ids)
  7460. for _, item := range projects {
  7461. result := QueryResult{
  7462. ID: item.ID,
  7463. Name: item.ProjectName,
  7464. Code: item.MedicalCode,
  7465. List_type_code: "201",
  7466. }
  7467. queryResult = append(queryResult, result)
  7468. }
  7469. }
  7470. adminUser := c.GetAdminUserInfo()
  7471. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7472. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7473. var user_name string
  7474. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7475. if role.ID == 0 {
  7476. user_name = "xxx"
  7477. } else {
  7478. user_name = role.UserName
  7479. }
  7480. baseParams := &models.BaseParams{
  7481. SecretKey: miConfig.SecretKey,
  7482. FixmedinsCode: miConfig.Code,
  7483. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7484. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7485. OrgName: miConfig.OrgName,
  7486. Doctor: user_name,
  7487. }
  7488. if config.IsOpen == 1 {
  7489. for _, item := range queryResult {
  7490. var result string
  7491. if record_type == 1 {
  7492. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7493. } else if record_type == 2 {
  7494. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7495. } else if record_type == 3 {
  7496. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7497. }
  7498. var dat2 map[string]interface{}
  7499. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7500. fmt.Println(dat2)
  7501. } else {
  7502. fmt.Println(err)
  7503. }
  7504. userJSONBytes, _ := json.Marshal(dat2)
  7505. var res ResultSix
  7506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7507. utils.ErrorLog("解析失败:%v", err)
  7508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7509. return
  7510. }
  7511. if res.Infcode == 0 {
  7512. if record_type == 1 {
  7513. service.UpdateDrugByIdDetail(item.ID)
  7514. } else if record_type == 2 {
  7515. service.UpdateGoodInfoById(item.ID)
  7516. } else if record_type == 3 {
  7517. service.UpdateMyProjectById(item.ID)
  7518. }
  7519. c.ServeSuccessJSON(map[string]interface{}{
  7520. "failed_code": 0,
  7521. "msg": "撤销目录对照成功",
  7522. })
  7523. } else {
  7524. c.ServeSuccessJSON(map[string]interface{}{
  7525. "failed_code": -10,
  7526. "msg": res.ErrMsg,
  7527. })
  7528. }
  7529. }
  7530. }
  7531. }
  7532. func (c *HisApiController) GetPatientInfo() {
  7533. id_card_no := c.GetString("id_card_no")
  7534. admin_user_id, _ := c.GetInt64("admin_user_id")
  7535. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7536. if patient.ID == 0 {
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7538. return
  7539. }
  7540. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7541. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7542. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7543. if config.IsOpen == 1 {
  7544. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7545. var dat map[string]interface{}
  7546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7547. fmt.Println(dat)
  7548. } else {
  7549. fmt.Println(err)
  7550. }
  7551. userJSONBytes, _ := json.Marshal(dat)
  7552. var res ResultTwo
  7553. var res10265 ResultTwo10265
  7554. if miConfig.Code == "H15049901371" {
  7555. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7556. utils.ErrorLog("解析失败:%v", err)
  7557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7558. return
  7559. }
  7560. res.ErrMsg = res10265.ErrMsg
  7561. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7562. res.Infcode = infocode
  7563. res.Output = res10265.Output
  7564. res.InfRefmsgid = res10265.InfRefmsgid
  7565. } else {
  7566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7567. utils.ErrorLog("解析失败:%v", err)
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. }
  7572. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7573. // utils.ErrorLog("解析失败:%v", err)
  7574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. // return
  7576. //}
  7577. if res.Infcode != 0 {
  7578. c.ServeSuccessJSON(map[string]interface{}{
  7579. "failed_code": -10,
  7580. "msg": res.ErrMsg,
  7581. })
  7582. } else {
  7583. c.ServeSuccessJSON(map[string]interface{}{
  7584. "failed_code": 0,
  7585. "info": res,
  7586. })
  7587. }
  7588. }
  7589. }
  7590. func (c *HisApiController) PsnPutOnRecord() {
  7591. record_type, _ := c.GetInt64("type")
  7592. patient_id, _ := c.GetInt64("patient_id")
  7593. admin_user_id, _ := c.GetInt64("admin_user_id")
  7594. start_time := c.GetString("start_time")
  7595. end_time := c.GetString("end_time")
  7596. adminUser := c.GetAdminUserInfo()
  7597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7598. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7599. var patients []*models.Patients
  7600. if record_type == 1 { //全部备案
  7601. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7602. patients = append(patients, patient...)
  7603. } else { //单个备案
  7604. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7605. patients = append(patients, patient)
  7606. }
  7607. var user_name string
  7608. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7609. if role.ID == 0 {
  7610. user_name = "xxx"
  7611. } else {
  7612. user_name = role.UserName
  7613. }
  7614. if config.IsOpen == 1 {
  7615. for _, item := range patients {
  7616. 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
  7617. resp, requestErr := http.Get(api)
  7618. if requestErr != nil {
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7620. return
  7621. }
  7622. defer resp.Body.Close()
  7623. body, ioErr := ioutil.ReadAll(resp.Body)
  7624. if ioErr != nil {
  7625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. var respJSON map[string]interface{}
  7630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. return
  7634. }
  7635. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7636. userJSONBytes, _ := json.Marshal(userJSON)
  7637. var res ResultTwo
  7638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7639. utils.ErrorLog("解析失败:%v", err)
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. return
  7642. }
  7643. if res.Infcode == 0 {
  7644. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7645. var dat map[string]interface{}
  7646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7647. fmt.Println(dat)
  7648. } else {
  7649. fmt.Println(err)
  7650. }
  7651. userJSONBytes, _ := json.Marshal(dat)
  7652. var res2 ResultThirteen
  7653. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7654. utils.ErrorLog("解析失败:%v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. if res2.Infcode == 0 {
  7659. psnResult := &models.GdybPsnRecord{
  7660. UserOrgId: adminUser.CurrentOrgId,
  7661. PatientId: item.ID,
  7662. PsnNo: res.Output.Baseinfo.PsnNo,
  7663. Ctime: time.Now().Unix(),
  7664. Mtime: time.Now().Unix(),
  7665. Status: 1,
  7666. IsCancel: 1,
  7667. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7668. }
  7669. service.CreatePsnRecord(psnResult)
  7670. } else {
  7671. c.ServeSuccessJSON(map[string]interface{}{
  7672. "failed_code": -10,
  7673. "msg": res2.ErrMsg,
  7674. })
  7675. return
  7676. }
  7677. }
  7678. }
  7679. }
  7680. }
  7681. func (c *HisApiController) PsnUnPutOnRecord() {
  7682. id, _ := c.GetInt64("id")
  7683. //record_type, _ := c.GetInt64("type")
  7684. admin_user_id, _ := c.GetInt64("admin_user_id")
  7685. adminUser := c.GetAdminUserInfo()
  7686. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7688. var user_name string
  7689. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7690. if role.ID == 0 {
  7691. user_name = "xxx"
  7692. } else {
  7693. user_name = role.UserName
  7694. }
  7695. psn_record, _ := service.GetPsnRecordById(id)
  7696. if psn_record.ID == 0 {
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7698. return
  7699. }
  7700. if config.IsOpen == 1 {
  7701. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7702. var dat map[string]interface{}
  7703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7704. fmt.Println(dat)
  7705. } else {
  7706. fmt.Println(err)
  7707. }
  7708. userJSONBytes, _ := json.Marshal(dat)
  7709. var res ResultFourteen
  7710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7711. utils.ErrorLog("解析失败:%v", err)
  7712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7713. return
  7714. }
  7715. if res.Infcode == 0 {
  7716. psn_record.IsCancel = 2
  7717. service.CreatePsnRecord(&psn_record)
  7718. } else {
  7719. c.ServeSuccessJSON(map[string]interface{}{
  7720. "failed_code": -10,
  7721. "msg": res.ErrMsg,
  7722. })
  7723. return
  7724. }
  7725. }
  7726. }
  7727. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7728. patient_id, _ := c.GetInt64("patient_id")
  7729. insutype_two := c.GetString("insutype")
  7730. psn_no := c.GetString("psn_no")
  7731. doctor_id, _ := c.GetInt64("doctor_id")
  7732. sick_id, _ := c.GetInt64("sick_id")
  7733. department_id, _ := c.GetInt64("department_id")
  7734. start_time := c.GetString("start_time")
  7735. end_time := c.GetString("end_time")
  7736. check_time := c.GetString("check_time")
  7737. adminUser := c.GetAdminUserInfo()
  7738. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7740. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7741. sick, _ := service.FindSickById(sick_id)
  7742. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7744. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7745. var res ResultTwo
  7746. var res10265 ResultTwo10265
  7747. if miConfig.Code == "H15049901371" {
  7748. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7749. utils.ErrorLog("解析失败:%v", err)
  7750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7751. return
  7752. }
  7753. res.ErrMsg = res10265.ErrMsg
  7754. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7755. res.Infcode = infocode
  7756. res.Output = res10265.Output
  7757. res.InfRefmsgid = res10265.InfRefmsgid
  7758. } else {
  7759. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7760. utils.ErrorLog("解析失败:%v", err)
  7761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7762. return
  7763. }
  7764. }
  7765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7766. infoStr := string(Iinfos)
  7767. var rf []*ResultFive
  7768. json.Unmarshal([]byte(infoStr), &rf)
  7769. var insuplc_admdvs string
  7770. var insutype string
  7771. var is390 int = 0
  7772. var is310 int = 0
  7773. var insutypes []*ResultFive
  7774. for _, item := range rf {
  7775. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7776. insutypes = append(insutypes, item)
  7777. }
  7778. }
  7779. if len(insutypes) == 1 {
  7780. insutype = insutypes[0].Insutype
  7781. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7782. } else {
  7783. for _, i := range insutypes {
  7784. if i.Insutype == "390" {
  7785. is390 = 1
  7786. }
  7787. if i.Insutype == "310" {
  7788. is310 = 1
  7789. }
  7790. }
  7791. }
  7792. if is390 == 1 {
  7793. insutype = "390"
  7794. }
  7795. if is310 == 1 {
  7796. insutype = "310"
  7797. }
  7798. if len(insutypes) == 2 {
  7799. insutype = insutype_two
  7800. }
  7801. if len(insutypes) == 0 {
  7802. insutype = "310"
  7803. }
  7804. insutype = insutype_two
  7805. fmt.Println(insutype)
  7806. for _, item := range rf {
  7807. fmt.Println(item.Insutype)
  7808. fmt.Println(insutype)
  7809. if item.Insutype == insutype {
  7810. fmt.Println(item.Insutype)
  7811. fmt.Println(insutype)
  7812. insuplc_admdvs = item.InsuplcAdmdvs
  7813. }
  7814. }
  7815. fmt.Println(insuplc_admdvs)
  7816. if config.IsOpen == 1 {
  7817. 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)
  7818. var dat map[string]interface{}
  7819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7820. fmt.Println(dat)
  7821. } else {
  7822. fmt.Println(err)
  7823. }
  7824. userJSONBytes, _ := json.Marshal(dat)
  7825. var res2 ResultThirteen
  7826. var res10265 ResultThirteen10265
  7827. if miConfig.Code == "H15049901371" {
  7828. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7829. utils.ErrorLog("解析失败:%v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. res2.ErrMsg = res10265.ErrMsg
  7834. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7835. res2.Infcode = infocode
  7836. res2.Output = res10265.Output
  7837. res2.InfRefmsgid = res10265.InfRefmsgid
  7838. } else {
  7839. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7840. utils.ErrorLog("解析失败:%v", err)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. return
  7843. }
  7844. }
  7845. if res2.Infcode == 0 {
  7846. psnResult := &models.GdybPsnNcdsRecord{
  7847. UserOrgId: adminUser.CurrentOrgId,
  7848. PatientId: patient.ID,
  7849. PsnNo: psn_no,
  7850. DoctorId: doctor.AdminUserId,
  7851. DepartmentId: department_id,
  7852. SickType: sick_id,
  7853. Insutype: insutype,
  7854. Ctime: time.Now().Unix(),
  7855. Mtime: time.Now().Unix(),
  7856. Status: 1,
  7857. IsCancel: 1,
  7858. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7859. }
  7860. service.CreatePsnNCDSRecord(psnResult)
  7861. c.ServeSuccessJSON(map[string]interface{}{
  7862. "failed_code": 0,
  7863. "msg": "备案成功",
  7864. "result": psnResult,
  7865. })
  7866. } else {
  7867. c.ServeSuccessJSON(map[string]interface{}{
  7868. "failed_code": -10,
  7869. "msg": res2.ErrMsg,
  7870. })
  7871. return
  7872. }
  7873. }
  7874. }
  7875. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7876. id, _ := c.GetInt64("id")
  7877. admin_user_id, _ := c.GetInt64("admin_user_id")
  7878. adminUser := c.GetAdminUserInfo()
  7879. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7880. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7881. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7882. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7883. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7884. //var user_name string
  7885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7886. //if role.ID == 0 {
  7887. // user_name = "xxx"
  7888. //} else {
  7889. // user_name = role.UserName
  7890. //}
  7891. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7892. if psn_record.ID == 0 {
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7894. return
  7895. }
  7896. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7897. var res ResultTwo
  7898. var res10265 ResultTwo10265
  7899. if miConfig.Code == "H15049901371" {
  7900. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7901. utils.ErrorLog("解析失败:%v", err)
  7902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7903. return
  7904. }
  7905. res.ErrMsg = res10265.ErrMsg
  7906. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7907. res.Infcode = infocode
  7908. res.Output = res10265.Output
  7909. res.InfRefmsgid = res10265.InfRefmsgid
  7910. } else {
  7911. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7912. utils.ErrorLog("解析失败:%v", err)
  7913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7914. return
  7915. }
  7916. }
  7917. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7918. infoStr := string(Iinfos)
  7919. var rf []*ResultFive
  7920. json.Unmarshal([]byte(infoStr), &rf)
  7921. var insuplc_admdvs string
  7922. var insutype string
  7923. var is390 int = 0
  7924. var is310 int = 0
  7925. var insutypes []*ResultFive
  7926. for _, item := range rf {
  7927. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7928. insutypes = append(insutypes, item)
  7929. }
  7930. }
  7931. if len(insutypes) == 1 {
  7932. insutype = insutypes[0].Insutype
  7933. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7934. } else {
  7935. for _, i := range insutypes {
  7936. if i.Insutype == "390" {
  7937. is390 = 1
  7938. }
  7939. if i.Insutype == "310" {
  7940. is310 = 1
  7941. }
  7942. }
  7943. }
  7944. if is390 == 1 {
  7945. insutype = "390"
  7946. }
  7947. if is310 == 1 {
  7948. insutype = "310"
  7949. }
  7950. if len(insutypes) == 0 {
  7951. insutype = "310"
  7952. }
  7953. insutype = psn_record.Insutype
  7954. for _, item := range rf {
  7955. if item.Insutype == insutype {
  7956. insuplc_admdvs = item.InsuplcAdmdvs
  7957. }
  7958. }
  7959. if config.IsOpen == 1 {
  7960. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7961. var dat map[string]interface{}
  7962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7963. fmt.Println(dat)
  7964. } else {
  7965. fmt.Println(err)
  7966. }
  7967. userJSONBytes, _ := json.Marshal(dat)
  7968. var res ResultFourteen
  7969. var res10265 ResultFourteen10265
  7970. if miConfig.Code == "H15049901371" {
  7971. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7972. utils.ErrorLog("解析失败:%v", err)
  7973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7974. return
  7975. }
  7976. res.ErrMsg = res10265.ErrMsg
  7977. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7978. res.Infcode = infocode
  7979. res.Output = res10265.Output
  7980. res.InfRefmsgid = res10265.InfRefmsgid
  7981. } else {
  7982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7983. utils.ErrorLog("解析失败:%v", err)
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7985. return
  7986. }
  7987. }
  7988. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7989. // utils.ErrorLog("解析失败:%v", err)
  7990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. // return
  7992. //}
  7993. if res.Infcode == 0 {
  7994. psn_record.IsCancel = 2
  7995. service.CreatePsnNCDSRecord(&psn_record)
  7996. c.ServeSuccessJSON(map[string]interface{}{
  7997. "failed_code": 0,
  7998. "msg": "撤销备案成功",
  7999. })
  8000. } else {
  8001. c.ServeSuccessJSON(map[string]interface{}{
  8002. "failed_code": -10,
  8003. "msg": res.ErrMsg,
  8004. })
  8005. return
  8006. }
  8007. }
  8008. }
  8009. func (c *HisApiController) TestTest() {
  8010. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8011. fmt.Println(patient.Iinfo)
  8012. }
  8013. type CustomData struct {
  8014. MsgId string
  8015. PsnNo string
  8016. Info string
  8017. }
  8018. func (c *HisApiController) ReversalData() {
  8019. var customData []*CustomData
  8020. custom := &CustomData{
  8021. MsgId: "H44022900158202103301714472004",
  8022. PsnNo: "44020000001101329945",
  8023. Info: "2207",
  8024. }
  8025. customData = append(customData, custom)
  8026. custom1 := &CustomData{
  8027. MsgId: "H4402290015820210330172057803",
  8028. PsnNo: "44020000001101161813",
  8029. Info: "2207",
  8030. }
  8031. customData = append(customData, custom1)
  8032. custom2 := &CustomData{
  8033. MsgId: "H44022900158202103301705198813",
  8034. PsnNo: "44190000133097375417",
  8035. Info: "2207",
  8036. }
  8037. customData = append(customData, custom2)
  8038. custom3 := &CustomData{
  8039. MsgId: "H44022900158202103301715524756",
  8040. PsnNo: "44020000001100187221",
  8041. Info: "2207",
  8042. }
  8043. customData = append(customData, custom3)
  8044. custom4 := &CustomData{
  8045. MsgId: "H44022900158202103301730376224",
  8046. PsnNo: "44020000001101959155",
  8047. Info: "2207",
  8048. }
  8049. customData = append(customData, custom4)
  8050. custom5 := &CustomData{
  8051. MsgId: "H44022900158202103301748008725",
  8052. PsnNo: "44020000001104246641",
  8053. Info: "2207",
  8054. }
  8055. customData = append(customData, custom5)
  8056. custom6 := &CustomData{
  8057. MsgId: "H44022900158202103301718096755",
  8058. PsnNo: "44020000001102211860",
  8059. Info: "2207",
  8060. }
  8061. customData = append(customData, custom6)
  8062. custom7 := &CustomData{
  8063. MsgId: "H44022900158202103301736551640",
  8064. PsnNo: "44020000001102687718",
  8065. Info: "2207",
  8066. }
  8067. customData = append(customData, custom7)
  8068. custom8 := &CustomData{
  8069. MsgId: "H44022900158202103301743097676",
  8070. PsnNo: "44020000001102127785",
  8071. Info: "2207",
  8072. }
  8073. customData = append(customData, custom8)
  8074. custom9 := &CustomData{
  8075. MsgId: "H44022900158202103301712304203",
  8076. PsnNo: "44020000001101518097",
  8077. Info: "2207",
  8078. }
  8079. customData = append(customData, custom9)
  8080. custom10 := &CustomData{
  8081. MsgId: "H44022900158202103301738448785",
  8082. PsnNo: "44020000001100500813",
  8083. Info: "2207",
  8084. }
  8085. customData = append(customData, custom10)
  8086. custom11 := &CustomData{
  8087. MsgId: "H44022900158202103301732455843",
  8088. PsnNo: "44020000001102690557",
  8089. Info: "2207",
  8090. }
  8091. customData = append(customData, custom11)
  8092. custom12 := &CustomData{
  8093. MsgId: "H44022900158202103301745421708",
  8094. PsnNo: "44020000001102211928",
  8095. Info: "2207",
  8096. }
  8097. customData = append(customData, custom12)
  8098. custom1212 := &CustomData{
  8099. MsgId: "H440229001582021033017351627",
  8100. PsnNo: "44020000001102481733",
  8101. Info: "2207",
  8102. }
  8103. customData = append(customData, custom1212)
  8104. custom13 := &CustomData{
  8105. MsgId: "H44022900158202103301740327951",
  8106. PsnNo: "44020000001103174866",
  8107. Info: "2207",
  8108. }
  8109. customData = append(customData, custom13)
  8110. custom14 := &CustomData{
  8111. MsgId: "H4402290015820210330174922668",
  8112. PsnNo: "44020000001102927272",
  8113. Info: "2207",
  8114. }
  8115. customData = append(customData, custom14)
  8116. custom15 := &CustomData{
  8117. MsgId: "H44022900158202103301752362273",
  8118. PsnNo: "44020000001102942890",
  8119. Info: "2207",
  8120. }
  8121. customData = append(customData, custom15)
  8122. custom16 := &CustomData{
  8123. MsgId: "H44022900158202103301751082917",
  8124. PsnNo: "44020000001101662162",
  8125. Info: "2207",
  8126. }
  8127. customData = append(customData, custom16)
  8128. custom17 := &CustomData{
  8129. MsgId: "H44022900158202103301754147728",
  8130. PsnNo: "44020000000229014511",
  8131. Info: "2207",
  8132. }
  8133. customData = append(customData, custom17)
  8134. adminUser := c.GetAdminUserInfo()
  8135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8136. for _, item := range customData {
  8137. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8138. fmt.Println(result)
  8139. }
  8140. }
  8141. func (c *HisApiController) ReversalOtherData() {
  8142. var customData []*CustomData
  8143. custom := &CustomData{
  8144. MsgId: "H44022900158202103301714472004",
  8145. PsnNo: "44020000001101329945",
  8146. Info: "2208",
  8147. }
  8148. customData = append(customData, custom)
  8149. custom1 := &CustomData{
  8150. MsgId: "H4402290015820210330172057803",
  8151. PsnNo: "44020000001101161813",
  8152. Info: "2208",
  8153. }
  8154. customData = append(customData, custom1)
  8155. custom2 := &CustomData{
  8156. MsgId: "H44022900158202103301705198813",
  8157. PsnNo: "44190000133097375417",
  8158. Info: "2208",
  8159. }
  8160. customData = append(customData, custom2)
  8161. custom3 := &CustomData{
  8162. MsgId: "H44022900158202103301715524756",
  8163. PsnNo: "44020000001100187221",
  8164. Info: "2208",
  8165. }
  8166. customData = append(customData, custom3)
  8167. custom4 := &CustomData{
  8168. MsgId: "H44022900158202103301730376224",
  8169. PsnNo: "44020000001101959155",
  8170. Info: "2208",
  8171. }
  8172. customData = append(customData, custom4)
  8173. custom5 := &CustomData{
  8174. MsgId: "H44022900158202103301748008725",
  8175. PsnNo: "44020000001104246641",
  8176. Info: "2208",
  8177. }
  8178. customData = append(customData, custom5)
  8179. custom6 := &CustomData{
  8180. MsgId: "H44022900158202103301718096755",
  8181. PsnNo: "44020000001102211860",
  8182. Info: "2208",
  8183. }
  8184. customData = append(customData, custom6)
  8185. custom7 := &CustomData{
  8186. MsgId: "H44022900158202103301736551640",
  8187. PsnNo: "44020000001102687718",
  8188. Info: "2208",
  8189. }
  8190. customData = append(customData, custom7)
  8191. custom8 := &CustomData{
  8192. MsgId: "H44022900158202103301743097676",
  8193. PsnNo: "44020000001102127785",
  8194. Info: "2208",
  8195. }
  8196. customData = append(customData, custom8)
  8197. custom9 := &CustomData{
  8198. MsgId: "H44022900158202103301712304203",
  8199. PsnNo: "44020000001101518097",
  8200. Info: "2208",
  8201. }
  8202. customData = append(customData, custom9)
  8203. custom10 := &CustomData{
  8204. MsgId: "H44022900158202103301738448785",
  8205. PsnNo: "44020000001100500813",
  8206. Info: "2208",
  8207. }
  8208. customData = append(customData, custom10)
  8209. custom11 := &CustomData{
  8210. MsgId: "H44022900158202103301732455843",
  8211. PsnNo: "44020000001102690557",
  8212. Info: "2208",
  8213. }
  8214. customData = append(customData, custom11)
  8215. custom12 := &CustomData{
  8216. MsgId: "H44022900158202103301745421708",
  8217. PsnNo: "44020000001102211928",
  8218. Info: "2208",
  8219. }
  8220. customData = append(customData, custom12)
  8221. custom1212 := &CustomData{
  8222. MsgId: "H440229001582021033017351627",
  8223. PsnNo: "44020000001102481733",
  8224. Info: "2208",
  8225. }
  8226. customData = append(customData, custom1212)
  8227. custom13 := &CustomData{
  8228. MsgId: "H44022900158202103301740327951",
  8229. PsnNo: "44020000001103174866",
  8230. Info: "2208",
  8231. }
  8232. customData = append(customData, custom13)
  8233. custom14 := &CustomData{
  8234. MsgId: "H4402290015820210330174922668",
  8235. PsnNo: "44020000001102927272",
  8236. Info: "2208",
  8237. }
  8238. customData = append(customData, custom14)
  8239. custom15 := &CustomData{
  8240. MsgId: "H44022900158202103301752362273",
  8241. PsnNo: "44020000001102942890",
  8242. Info: "2208",
  8243. }
  8244. customData = append(customData, custom15)
  8245. custom16 := &CustomData{
  8246. MsgId: "H44022900158202103301751082917",
  8247. PsnNo: "44020000001101662162",
  8248. Info: "2208",
  8249. }
  8250. customData = append(customData, custom16)
  8251. custom17 := &CustomData{
  8252. MsgId: "H44022900158202103301754147728",
  8253. PsnNo: "44020000000229014511",
  8254. Info: "2208",
  8255. }
  8256. customData = append(customData, custom17)
  8257. adminUser := c.GetAdminUserInfo()
  8258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8259. for _, item := range customData {
  8260. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8261. fmt.Println(result)
  8262. }
  8263. }
  8264. func PathExists(path string) (bool, error) {
  8265. _, err := os.Stat(path)
  8266. if err == nil {
  8267. return true, nil
  8268. }
  8269. if os.IsNotExist(err) {
  8270. return false, nil
  8271. }
  8272. return false, err
  8273. }
  8274. //创建文件夹
  8275. func Mkdir(dir string) {
  8276. // 创建文件夹
  8277. exist, err := PathExists(dir)
  8278. if err != nil {
  8279. fmt.Println(err.Error())
  8280. } else {
  8281. if exist {
  8282. fmt.Println(dir + "文件夹已存在!")
  8283. } else {
  8284. // 文件夹名称,权限
  8285. err := os.Mkdir(dir, os.ModePerm)
  8286. if err != nil {
  8287. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8288. } else {
  8289. fmt.Println(dir + "文件夹创建成功!")
  8290. }
  8291. }
  8292. }
  8293. }
  8294. //压缩文件
  8295. func Zip(srcFile string, destZip string) error {
  8296. zipfile, err := os.Create(destZip)
  8297. if err != nil {
  8298. return err
  8299. }
  8300. defer zipfile.Close()
  8301. archive := zip.NewWriter(zipfile)
  8302. defer archive.Close()
  8303. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8304. if err != nil {
  8305. return err
  8306. }
  8307. header, err := zip.FileInfoHeader(info)
  8308. if err != nil {
  8309. return err
  8310. }
  8311. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8312. // header.Name = path
  8313. if info.IsDir() {
  8314. header.Name += "/"
  8315. } else {
  8316. header.Method = zip.Deflate
  8317. }
  8318. writer, err := archive.CreateHeader(header)
  8319. if err != nil {
  8320. return err
  8321. }
  8322. if !info.IsDir() {
  8323. file, err := os.Open(path)
  8324. if err != nil {
  8325. return err
  8326. }
  8327. defer file.Close()
  8328. _, err = io.Copy(writer, file)
  8329. }
  8330. return err
  8331. })
  8332. return err
  8333. }
  8334. func ReadFile(filePath string) []byte {
  8335. f, err := os.Open(filePath)
  8336. if err != nil {
  8337. fmt.Println("read file fail", err)
  8338. return nil
  8339. }
  8340. defer f.Close()
  8341. fd, err := ioutil.ReadAll(f)
  8342. if err != nil {
  8343. fmt.Println("read to fd fail", err)
  8344. return nil
  8345. }
  8346. return fd
  8347. }
  8348. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  8349. newArr = make([]*models.HisOrderInfo, 0)
  8350. for i := 0; i < len(arr); i++ {
  8351. repeat := false
  8352. for j := i + 1; j < len(arr); j++ {
  8353. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  8354. repeat = true
  8355. break
  8356. }
  8357. }
  8358. if !repeat {
  8359. newArr = append(newArr, arr[i])
  8360. }
  8361. }
  8362. return
  8363. }
  8364. func saveRegisterLog(result string) {
  8365. org_id, _ := beego.AppConfig.Int64("org_id")
  8366. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8367. dir := miConfig.OrgName + "日志"
  8368. utils.Mkdir(dir)
  8369. month := time.Unix(1557042972, 0).Format("1")
  8370. year := time.Now().Format("2006")
  8371. month = time.Now().Format("01")
  8372. day := time.Now().Format("02")
  8373. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8374. file_name := file + ".txt"
  8375. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8376. exist, _ := utils.PathExists(file_path)
  8377. if exist { //存在
  8378. fmt.Println("存在")
  8379. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8380. if err != nil {
  8381. fmt.Println("read fail")
  8382. }
  8383. content := "\r\n" + result
  8384. n, _ := f.Seek(0, 2)
  8385. _, err = f.WriteAt([]byte(content), n)
  8386. } else { //不存在
  8387. fmt.Println("文件不存在,创建文件")
  8388. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8389. defer f.Close()
  8390. if err != nil {
  8391. } else {
  8392. _, err = f.Write([]byte("记录日志"))
  8393. }
  8394. }
  8395. }
  8396. func saveLog(result string, request string, infno string, desc string) {
  8397. org_id, _ := beego.AppConfig.Int64("org_id")
  8398. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8399. dir := miConfig.OrgName + "日志"
  8400. utils.Mkdir(dir)
  8401. month := time.Unix(1557042972, 0).Format("1")
  8402. year := time.Now().Format("2006")
  8403. month = time.Now().Format("01")
  8404. day := time.Now().Format("02")
  8405. hour := time.Now().Format("15")
  8406. min := time.Now().Format("04")
  8407. sec := time.Now().Format("05")
  8408. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8409. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8410. file_name := file + ".txt"
  8411. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8412. exist, _ := utils.PathExists(file_path)
  8413. if exist { //存在
  8414. fmt.Println("存在")
  8415. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8416. if err != nil {
  8417. fmt.Println("read fail")
  8418. }
  8419. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8420. n, _ := f.Seek(0, 2)
  8421. _, err = f.WriteAt([]byte(content), n)
  8422. } else { //不存在
  8423. fmt.Println("文件不存在,创建文件")
  8424. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8425. defer f.Close()
  8426. if err != nil {
  8427. } else {
  8428. _, err = f.Write([]byte("记录日志"))
  8429. }
  8430. }
  8431. }
  8432. type Charset string
  8433. const (
  8434. UTF8 = Charset("UTF-8")
  8435. GB18030 = Charset("GB18030")
  8436. )
  8437. func ConvertToString(src string, srcCode string, tagCode string) string {
  8438. srcCoder := mahonia.NewDecoder(srcCode)
  8439. srcResult := srcCoder.ConvertString(src)
  8440. tagCoder := mahonia.NewDecoder(tagCode)
  8441. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8442. result := string(cdata)
  8443. return result
  8444. }