his_api_controller.go 426KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655
  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/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := c.GetString("trig_scen")
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.FixmedinsCode = miConfig.Code
  109. pp.RequestUrl = miConfig.Url
  110. pp.Cainfo = miConfig.Cainfo
  111. pp.SecretKey = miConfig.SecretKey
  112. pp.AccessKey = miConfig.AccessKey
  113. pp.OpterName = roles.UserName
  114. var config []*models.HisXtDiagnoseConfig
  115. for _, item := range diagnosis_ids {
  116. id, _ := strconv.ParseInt(item, 10, 64)
  117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  118. config = append(config, &diagnosisConfig)
  119. }
  120. var pd models.PatientDtos
  121. pd.PatnID = his.PsnNo
  122. pd.PatnName = his.Name
  123. pd.Gend = his.Gend
  124. pd.Brdy = his.Brdy
  125. pd.Poolarea = his.InsuplcAdmdvs
  126. pd.CurrMdtrtID = his.Number
  127. var fed models.FsiEncounterDtos
  128. fed.MdtrtID = his.Number
  129. fed.MedinsID = miConfig.Code
  130. fed.MedinsName = miConfig.OrgName
  131. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  132. fed.MedMdtrtType = "1"
  133. fed.MedinsType = "1"
  134. fed.MedinsLv = "11"
  135. tm := time.Unix(his.RecordDate, 0)
  136. s_tm := tm.Format("2006-01-02 15:04:05")
  137. fed.AdmDate = s_tm
  138. fed.DscgDate = s_tm
  139. fed.DscgMainDiseCodg = config[0].CountryCode
  140. fed.DscgMainDiseName = config[0].CountryContentName
  141. //诊断信息
  142. var fdds []*models.FsiDiagnoseDtos
  143. for index, item := range config {
  144. if index == 0 {
  145. var fdd models.FsiDiagnoseDtos
  146. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  147. fdd.InoutDiseType = "1"
  148. fdd.MaindiseFlag = "1"
  149. fdd.DiseDate = s_tm
  150. fdd.DiasSrtNo = "1"
  151. fdd.DiseName = item.CountryContentName
  152. fdd.DiseCodg = item.CountryCode
  153. fdds = append(fdds, &fdd)
  154. } else {
  155. var fdd models.FsiDiagnoseDtos
  156. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  157. fdd.InoutDiseType = "1"
  158. fdd.MaindiseFlag = "1"
  159. fdd.DiseDate = s_tm
  160. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  161. fdd.DiseName = item.CountryContentName
  162. fdd.DiseCodg = item.CountryCode
  163. fdds = append(fdds, &fdd)
  164. }
  165. }
  166. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  167. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.AdmDeptName = department.Name
  169. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  170. fed.DscgDeptName = department.Name
  171. fed.MedMdtrtType = "1"
  172. if his.Insutype == "390" {
  173. fed.MedType = "1402"
  174. } else {
  175. fed.MedType = "9933"
  176. }
  177. var orders []*models.FsiOrderDtos
  178. if trig_scen == "2" {
  179. //处方医嘱信息
  180. for _, item := range prescriptions {
  181. for _, subItem := range item.HisDoctorAdviceInfo {
  182. var order models.FsiOrderDtos
  183. order.RxID = strconv.FormatInt(item.ID, 10)
  184. order.Rxno = strconv.FormatInt(item.ID, 10)
  185. order.LongDrordFlag = "0"
  186. order.HilistType = "1"
  187. order.ChrgType = "1"
  188. order.DrordBhvr = "-"
  189. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  190. order.HosplistName = subItem.BaseDrugLib.DrugName
  191. order.HilistLv = "1"
  192. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  193. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  194. order.HosplistName = subItem.BaseDrugLib.DrugName
  195. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  196. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  197. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  198. order.OwnpayAmt = ""
  199. order.SelfpayAmt = ""
  200. order.Spec = ""
  201. order.SpecUnt = ""
  202. order.DrordBegnDate = s_tm
  203. order.DrordStopDate = ""
  204. order.DrordDrCodg = "1"
  205. order.DrordDeptName = department.Name
  206. order.DrordDrCodg = "1"
  207. order.DrordDrName = doctor_info.UserName
  208. order.DrordDrProfttl = ""
  209. order.CurrDrordFlag = "1"
  210. orders = append(orders, &order)
  211. }
  212. for _, subItem := range item.HisPrescriptionProject {
  213. if subItem.Type == 2 {
  214. var order models.FsiOrderDtos
  215. order.RxID = strconv.FormatInt(item.ID, 10)
  216. order.Rxno = strconv.FormatInt(item.ID, 10)
  217. order.LongDrordFlag = "0"
  218. order.HilistType = "1"
  219. order.ChrgType = "1"
  220. order.DrordBhvr = "-"
  221. order.HilistCode = subItem.HisProject.MedicalCode
  222. order.HosplistName = subItem.HisProject.ProjectName
  223. order.HilistLv = "1"
  224. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.HosplistCode = subItem.HisProject.MedicalCode
  226. order.HosplistName = subItem.HisProject.ProjectName
  227. order.Cnt = subItem.Count
  228. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  229. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  230. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  231. order.OwnpayAmt = ""
  232. order.SelfpayAmt = ""
  233. order.Spec = ""
  234. order.SpecUnt = ""
  235. order.DrordBegnDate = s_tm
  236. order.DrordStopDate = ""
  237. order.DrordDrCodg = "1"
  238. order.DrordDeptName = department.Name
  239. order.DrordDrCodg = "1"
  240. order.DrordDrName = doctor_info.UserName
  241. order.DrordDrProfttl = ""
  242. order.CurrDrordFlag = "1"
  243. orders = append(orders, &order)
  244. }
  245. if subItem.Type == 3 {
  246. var order models.FsiOrderDtos
  247. order.RxID = strconv.FormatInt(item.ID, 10)
  248. order.Rxno = strconv.FormatInt(item.ID, 10)
  249. order.LongDrordFlag = "0"
  250. order.HilistType = "1"
  251. order.ChrgType = "1"
  252. order.DrordBhvr = "-"
  253. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  254. order.HosplistName = subItem.GoodInfo.GoodName
  255. order.HilistLv = "1"
  256. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  257. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  258. order.HosplistName = subItem.GoodInfo.GoodName
  259. order.Cnt = subItem.Count
  260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  261. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  262. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  263. order.OwnpayAmt = ""
  264. order.SelfpayAmt = ""
  265. order.Spec = ""
  266. order.SpecUnt = ""
  267. order.DrordBegnDate = s_tm
  268. order.DrordStopDate = ""
  269. order.DrordDrCodg = "1"
  270. order.DrordDeptName = department.Name
  271. order.DrordDrCodg = "1"
  272. order.DrordDrName = doctor_info.UserName
  273. order.DrordDrProfttl = ""
  274. order.CurrDrordFlag = "1"
  275. orders = append(orders, &order)
  276. }
  277. }
  278. }
  279. //处方医嘱信息
  280. }
  281. fed.MatnStas = "0"
  282. fed.MedfeeSumamt = "0"
  283. fed.OwnpayAmt = "0"
  284. fed.SelfpayAmt = "0"
  285. fed.AcctPayamt = "0"
  286. fed.MaAmt = "0"
  287. fed.HifpPayamt = "0"
  288. fed.SetlTotlnum = "1"
  289. fed.Insutype = his.Insutype
  290. fed.ReimFlag = "0"
  291. fed.OutSetlFlag = "0"
  292. var fopd []*models.FsiOperationDtosData
  293. data := make(map[string]interface{})
  294. data["fed"] = fed
  295. data["fdd"] = fdds
  296. data["fod"] = orders
  297. data["pd"] = pd
  298. data["pp"] = pp
  299. data["fopd"] = fopd
  300. data["trig_scen"] = trig_scen
  301. fmt.Println(data)
  302. fmt.Println(fed)
  303. fmt.Println(fdds)
  304. fmt.Println(orders)
  305. fmt.Println(pd)
  306. fmt.Println(pp)
  307. fmt.Println(fopd)
  308. client := &http.Client{}
  309. bytesData, _ := json.Marshal(data)
  310. var req *http.Request
  311. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  312. resp, _ := client.Do(req)
  313. defer resp.Body.Close()
  314. body, ioErr := ioutil.ReadAll(resp.Body)
  315. if ioErr != nil {
  316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  318. return
  319. }
  320. var respJSON map[string]interface{}
  321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. //手术操作集合
  327. //手术操作集合
  328. }
  329. func (c *HisApiController) Check3102() {
  330. patient_id, _ := c.GetInt64("patient_id")
  331. order_id, _ := c.GetInt64("order_id")
  332. his_patient_id, _ := c.GetInt64("his_patient_id")
  333. admin_user_id, _ := c.GetInt64("admin_user_id")
  334. trig_scen := c.GetString("trig_scen")
  335. adminUser := c.GetAdminUserInfo()
  336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  337. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  339. record_time := c.GetString("record_time")
  340. order, _ := service.GetHisOrderByID(order_id)
  341. timeLayout := "2006-01-02"
  342. loc, _ := time.LoadLocation("Local")
  343. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  344. if err != nil {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  346. return
  347. }
  348. recordDateTime := theTime.Unix()
  349. var patientPrescription models.HisPrescriptionInfo
  350. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  351. if patientPrescription.ID == 0 {
  352. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  353. }
  354. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  355. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  356. //
  357. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  358. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  359. var pp models.PublicParams
  360. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  361. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  362. pp.FixmedinsName = miConfig.OrgName
  363. pp.FixmedinsCode = miConfig.Code
  364. pp.RequestUrl = miConfig.Url
  365. pp.Cainfo = miConfig.Cainfo
  366. pp.SecretKey = miConfig.SecretKey
  367. pp.AccessKey = miConfig.AccessKey
  368. pp.OpterName = roles.UserName
  369. var config []*models.HisXtDiagnoseConfig
  370. for _, item := range diagnosis_ids {
  371. id, _ := strconv.ParseInt(item, 10, 64)
  372. diagnosisConfig, _ := service.FindDiagnoseById(id)
  373. config = append(config, &diagnosisConfig)
  374. }
  375. var pd models.PatientDtos
  376. pd.PatnID = his.PsnNo
  377. pd.PatnName = his.Name
  378. pd.Gend = his.Gend
  379. pd.Brdy = his.Brdy
  380. pd.Poolarea = his.InsuplcAdmdvs
  381. pd.CurrMdtrtID = his.Number
  382. var fed models.FsiEncounterDtos
  383. fed.MdtrtID = his.Number
  384. fed.MedinsID = miConfig.Code
  385. fed.MedinsName = miConfig.OrgName
  386. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  387. fed.MedMdtrtType = "1"
  388. fed.MedinsType = "1"
  389. fed.MedinsLv = "11"
  390. tm := time.Unix(his.RecordDate, 0)
  391. s_tm := tm.Format("2006-01-02 15:04:05")
  392. fed.AdmDate = s_tm
  393. fed.DscgDate = s_tm
  394. fed.DscgMainDiseCodg = config[0].CountryCode
  395. fed.DscgMainDiseName = config[0].CountryContentName
  396. //诊断信息
  397. var fdds []*models.FsiDiagnoseDtos
  398. for index, item := range config {
  399. if index == 0 {
  400. var fdd models.FsiDiagnoseDtos
  401. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  402. fdd.InoutDiseType = "1"
  403. fdd.MaindiseFlag = "1"
  404. fdd.DiseDate = s_tm
  405. fdd.DiasSrtNo = "1"
  406. fdd.DiseName = item.CountryContentName
  407. fdd.DiseCodg = item.CountryCode
  408. fdds = append(fdds, &fdd)
  409. } else {
  410. var fdd models.FsiDiagnoseDtos
  411. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  412. fdd.InoutDiseType = "1"
  413. fdd.MaindiseFlag = "1"
  414. fdd.DiseDate = s_tm
  415. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  416. fdd.DiseName = item.CountryContentName
  417. fdd.DiseCodg = item.CountryCode
  418. fdds = append(fdds, &fdd)
  419. }
  420. }
  421. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  422. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  423. fed.AdmDeptName = department.Name
  424. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  425. fed.DscgDeptName = department.Name
  426. fed.MedMdtrtType = ""
  427. fed.MedType = order.MedType
  428. //处方医嘱信息
  429. var orders []*models.FsiOrderDtos
  430. //for _, item := range prescriptions {
  431. // for _, subItem := range item.HisDoctorAdviceInfo {
  432. // var order models.FsiOrderDtos
  433. // order.RxID = strconv.FormatInt(item.ID, 10)
  434. // order.Rxno = strconv.FormatInt(item.ID, 10)
  435. // order.LongDrordFlag = "0"
  436. // order.HilistType = "1"
  437. // order.ChrgType = "1"
  438. // order.DrordBhvr = "-"
  439. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  440. // order.HosplistName = subItem.BaseDrugLib.DrugName
  441. // order.HilistLv = "1"
  442. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  443. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  444. // order.HosplistName = subItem.BaseDrugLib.DrugName
  445. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  446. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  447. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  448. // order.OwnpayAmt = ""
  449. // order.SelfpayAmt = ""
  450. // order.Spec = ""
  451. // order.SpecUnt = ""
  452. // order.DrordBegnDate = s_tm
  453. // order.DrordStopDate = ""
  454. // order.DrordDrCodg = "1"
  455. // order.DrordDeptName = department.Name
  456. // order.DrordDrCodg = "1"
  457. // order.DrordDrName = doctor_info.UserName
  458. // order.DrordDrProfttl = ""
  459. // order.CurrDrordFlag = "1"
  460. // orders = append(orders, &order)
  461. // }
  462. // for _, subItem := range item.HisPrescriptionProject {
  463. // if subItem.Type == 2 {
  464. // var order models.FsiOrderDtos
  465. // order.RxID = strconv.FormatInt(item.ID, 10)
  466. // order.Rxno = strconv.FormatInt(item.ID, 10)
  467. // order.LongDrordFlag = "0"
  468. // order.HilistType = "1"
  469. // order.ChrgType = "1"
  470. // order.DrordBhvr = "-"
  471. // order.HilistCode = subItem.HisProject.MedicalCode
  472. // order.HosplistName = subItem.HisProject.ProjectName
  473. // order.HilistLv = "1"
  474. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  475. // order.HosplistCode = subItem.HisProject.MedicalCode
  476. // order.HosplistName = subItem.HisProject.ProjectName
  477. // order.Cnt = subItem.Count
  478. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  479. //
  480. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  481. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  482. // order.OwnpayAmt = ""
  483. // order.SelfpayAmt = ""
  484. // order.Spec = ""
  485. // order.SpecUnt = ""
  486. // order.DrordBegnDate = s_tm
  487. // order.DrordStopDate = ""
  488. // order.DrordDrCodg = "1"
  489. // order.DrordDeptName = department.Name
  490. // order.DrordDrCodg = "1"
  491. // order.DrordDrName = doctor_info.UserName
  492. // order.DrordDrProfttl = ""
  493. // order.CurrDrordFlag = "1"
  494. // orders = append(orders, &order)
  495. //
  496. // }
  497. // if subItem.Type == 3 {
  498. //
  499. // var order models.FsiOrderDtos
  500. // order.RxID = strconv.FormatInt(item.ID, 10)
  501. // order.Rxno = strconv.FormatInt(item.ID, 10)
  502. // order.LongDrordFlag = "0"
  503. // order.HilistType = "1"
  504. // order.ChrgType = "1"
  505. // order.DrordBhvr = "-"
  506. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  507. // order.HosplistName = subItem.GoodInfo.GoodName
  508. // order.HilistLv = "1"
  509. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  510. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  511. // order.HosplistName = subItem.GoodInfo.GoodName
  512. // order.Cnt = subItem.Count
  513. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  514. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  515. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  516. // order.OwnpayAmt = ""
  517. // order.SelfpayAmt = ""
  518. // order.Spec = ""
  519. // order.SpecUnt = ""
  520. // order.DrordBegnDate = s_tm
  521. // order.DrordStopDate = ""
  522. // order.DrordDrCodg = "1"
  523. // order.DrordDeptName = department.Name
  524. // order.DrordDrCodg = "1"
  525. // order.DrordDrName = doctor_info.UserName
  526. // order.DrordDrProfttl = ""
  527. // order.CurrDrordFlag = "1"
  528. // orders = append(orders, &order)
  529. //
  530. // }
  531. // }
  532. //}
  533. for _, item := range prescriptions {
  534. for _, subItem := range item.HisDoctorAdviceInfo {
  535. var order models.FsiOrderDtos
  536. order.RxID = strconv.FormatInt(item.ID, 10)
  537. order.Rxno = strconv.FormatInt(item.ID, 10)
  538. order.LongDrordFlag = "0"
  539. order.HilistType = "1"
  540. order.ChrgType = "1"
  541. order.DrordBhvr = "-"
  542. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  543. order.HosplistName = subItem.BaseDrugLib.DrugName
  544. order.HilistLv = "1"
  545. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  546. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  547. order.HosplistName = subItem.BaseDrugLib.DrugName
  548. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  549. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  550. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  551. order.OwnpayAmt = ""
  552. order.SelfpayAmt = ""
  553. order.Spec = ""
  554. order.SpecUnt = ""
  555. order.DrordBegnDate = s_tm
  556. order.DrordStopDate = ""
  557. order.DrordDrCodg = "1"
  558. order.DrordDeptName = department.Name
  559. order.DrordDrCodg = "1"
  560. order.DrordDrName = doctor_info.UserName
  561. order.DrordDrProfttl = ""
  562. order.CurrDrordFlag = "1"
  563. orders = append(orders, &order)
  564. }
  565. for _, subItem := range item.HisPrescriptionProject {
  566. if subItem.Type == 2 {
  567. var order models.FsiOrderDtos
  568. order.RxID = strconv.FormatInt(item.ID, 10)
  569. order.Rxno = strconv.FormatInt(item.ID, 10)
  570. order.LongDrordFlag = "0"
  571. order.HilistType = "1"
  572. order.ChrgType = "1"
  573. order.DrordBhvr = "-"
  574. order.HilistCode = subItem.HisProject.MedicalCode
  575. order.HosplistName = subItem.HisProject.ProjectName
  576. order.HilistLv = "1"
  577. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  578. order.HosplistCode = subItem.HisProject.MedicalCode
  579. order.HosplistName = subItem.HisProject.ProjectName
  580. order.Cnt = subItem.Count
  581. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  582. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  583. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  584. order.OwnpayAmt = ""
  585. order.SelfpayAmt = ""
  586. order.Spec = ""
  587. order.SpecUnt = ""
  588. order.DrordBegnDate = s_tm
  589. order.DrordStopDate = ""
  590. order.DrordDrCodg = "1"
  591. order.DrordDeptName = department.Name
  592. order.DrordDrCodg = "1"
  593. order.DrordDrName = doctor_info.UserName
  594. order.DrordDrProfttl = ""
  595. order.CurrDrordFlag = "1"
  596. orders = append(orders, &order)
  597. }
  598. if subItem.Type == 3 {
  599. var order models.FsiOrderDtos
  600. order.RxID = strconv.FormatInt(item.ID, 10)
  601. order.Rxno = strconv.FormatInt(item.ID, 10)
  602. order.LongDrordFlag = "0"
  603. order.HilistType = "1"
  604. order.ChrgType = "1"
  605. order.DrordBhvr = "-"
  606. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  607. order.HosplistName = subItem.GoodInfo.GoodName
  608. order.HilistLv = "1"
  609. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  610. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  611. order.HosplistName = subItem.GoodInfo.GoodName
  612. order.Cnt = subItem.Count
  613. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  616. order.OwnpayAmt = ""
  617. order.SelfpayAmt = ""
  618. order.Spec = ""
  619. order.SpecUnt = ""
  620. order.DrordBegnDate = s_tm
  621. order.DrordStopDate = ""
  622. order.DrordDrCodg = "1"
  623. order.DrordDeptName = department.Name
  624. order.DrordDrCodg = "1"
  625. order.DrordDrName = doctor_info.UserName
  626. order.DrordDrProfttl = ""
  627. order.CurrDrordFlag = "1"
  628. orders = append(orders, &order)
  629. }
  630. }
  631. }
  632. //处方医嘱信息
  633. fed.MatnStas = "0"
  634. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  635. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  636. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  637. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  638. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  639. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  640. fed.SetlTotlnum = "1"
  641. fed.Insutype = his.Insutype
  642. fed.ReimFlag = "0"
  643. fed.OutSetlFlag = "0"
  644. var fopd []*models.FsiOperationDtosData
  645. data := make(map[string]interface{})
  646. data["fed"] = fed
  647. data["fdd"] = fdds
  648. data["fod"] = orders
  649. data["pd"] = pd
  650. data["pp"] = pp
  651. data["fopd"] = fopd
  652. data["trig_scen"] = trig_scen
  653. fmt.Println(data)
  654. fmt.Println(fed)
  655. fmt.Println(fdds)
  656. fmt.Println(orders)
  657. fmt.Println(pd)
  658. fmt.Println(pp)
  659. fmt.Println(fopd)
  660. client := &http.Client{}
  661. bytesData, _ := json.Marshal(data)
  662. var req *http.Request
  663. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  664. resp, _ := client.Do(req)
  665. defer resp.Body.Close()
  666. body, ioErr := ioutil.ReadAll(resp.Body)
  667. if ioErr != nil {
  668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. var respJSON map[string]interface{}
  673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  676. return
  677. }
  678. //手术操作集合
  679. //手术操作集合
  680. }
  681. func (c *HisApiController) Check() {
  682. psn_no := c.GetString("psn_no")
  683. in := c.GetString("in")
  684. mt := c.GetString("mt")
  685. baseParams := models.BaseParams{
  686. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  687. FixmedinsCode: "H15049901371",
  688. InsuplcAdmdvs: "150499",
  689. MdtrtareaAdmvs: "150499",
  690. OrgName: "赤峰费森血液透析中心",
  691. Doctor: "1111",
  692. }
  693. service.Gdyb2001(baseParams, psn_no, in, mt)
  694. }
  695. func (c *HisApiController) GetPsnNcdsInfo() {
  696. admin_user_id, _ := c.GetInt64("admin_user_id")
  697. patient_id, _ := c.GetInt64("patient_id")
  698. id, _ := c.GetInt64("id")
  699. adminUser := c.GetAdminUserInfo()
  700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  701. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  702. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  703. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  704. psn_record, _ := service.GetPsnNCDSRecordById(id)
  705. //
  706. //if psn_record.ID == 0 {
  707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  708. // return
  709. //}
  710. var res Result5301
  711. var res10265 Result5301For10265
  712. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  713. psn_info, _ := service.GetPsnByPatientId(patient_id)
  714. var api string
  715. if miConfig.MdtrtareaAdmvs == "320921" {
  716. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  717. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  718. } else {
  719. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  720. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  721. }
  722. resp, requestErr := http.Get(api)
  723. if requestErr != nil {
  724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  725. return
  726. }
  727. body, ioErr := ioutil.ReadAll(resp.Body)
  728. if ioErr != nil {
  729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  731. return
  732. }
  733. var respJSON map[string]interface{}
  734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  737. return
  738. }
  739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  740. result, _ := json.Marshal(respJSON)
  741. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  742. utils.ErrorLog("解析失败:%v", err)
  743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  744. return
  745. }
  746. res.ErrMsg = res10265.ErrMsg
  747. res.Output = res10265.Output
  748. res.InfRefmsgid = res10265.InfRefmsgid
  749. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  750. res.Infcode = infocode
  751. } else {
  752. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  753. var dat map[string]interface{}
  754. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  755. fmt.Println(dat)
  756. } else {
  757. fmt.Println(err)
  758. }
  759. userJSONBytes, _ := json.Marshal(dat)
  760. if miConfig.Code == "H15049901371" {
  761. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  762. utils.ErrorLog("解析失败:%v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. res.InfRefmsgid = res10265.InfRefmsgid
  767. res.Output = res10265.Output
  768. res.ErrMsg = res10265.ErrMsg
  769. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  770. res.Infcode = infocode
  771. } else {
  772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  773. utils.ErrorLog("解析失败:%v", err)
  774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  775. return
  776. }
  777. }
  778. }
  779. if res.Infcode == 0 {
  780. c.ServeSuccessJSON(map[string]interface{}{
  781. "result": res.Output.Result,
  782. })
  783. }
  784. }
  785. func (c *HisApiController) CheckInsutype() {
  786. his_patient_id, _ := c.GetInt64("his_patient_id")
  787. admin_user_id, _ := c.GetInt64("admin_user_id")
  788. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  789. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  790. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  791. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  792. var dat map[string]interface{}
  793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  794. fmt.Println(dat)
  795. } else {
  796. fmt.Println(err)
  797. }
  798. userJSONBytes, _ := json.Marshal(dat)
  799. var res Result90100
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. if res.Infcode != 0 {
  806. c.ServeSuccessJSON(map[string]interface{}{
  807. "failed_code": -10,
  808. "msg": res.ErrMsg,
  809. })
  810. return
  811. } else {
  812. fmt.Println(res)
  813. }
  814. }
  815. func (c *HisApiController) CheckCardPWD() {
  816. card_pwd := c.GetString("card_pwd")
  817. his_patient_id, _ := c.GetInt64("his_patient_id")
  818. admin_user_id, _ := c.GetInt64("admin_user_id")
  819. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  820. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  821. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  822. psn, _ := service.GetPsnByPatientId(his.PatientId)
  823. bas := strings.Split(psn.CardInfo, "|")
  824. basNumber := bas[2]
  825. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  826. var dat map[string]interface{}
  827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  828. fmt.Println(dat)
  829. } else {
  830. fmt.Println(err)
  831. }
  832. userJSONBytes, _ := json.Marshal(dat)
  833. var res Result90991
  834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  835. utils.ErrorLog("解析失败:%v", err)
  836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  837. return
  838. }
  839. if res.Infcode != 0 {
  840. c.ServeSuccessJSON(map[string]interface{}{
  841. "failed_code": -10,
  842. "msg": res.ErrMsg,
  843. })
  844. return
  845. } else {
  846. if res.Output.Result.CheckStat == "0" {
  847. var msg string
  848. switch res.Output.Result.CardStat {
  849. case "00":
  850. msg = "未激活"
  851. break
  852. case "10":
  853. msg = "激活"
  854. break
  855. case "20":
  856. msg = "窗口挂失"
  857. break
  858. case "21":
  859. msg = "电话挂失"
  860. break
  861. case "22":
  862. msg = "单位网上申报挂失"
  863. break
  864. case "23":
  865. msg = "保健办挂失"
  866. break
  867. case "24":
  868. msg = "个人网上挂失"
  869. break
  870. case "25":
  871. msg = "网上服务大厅挂失"
  872. break
  873. case "30":
  874. msg = "注销"
  875. break
  876. case "40":
  877. msg = "回收"
  878. break
  879. case "99":
  880. msg = "制卡中(无效卡)"
  881. break
  882. }
  883. c.ServeSuccessJSON(map[string]interface{}{
  884. "failed_code": -10,
  885. "msg": msg,
  886. })
  887. return
  888. } else {
  889. c.ServeSuccessJSON(map[string]interface{}{
  890. "msg": "校验成功",
  891. })
  892. return
  893. }
  894. }
  895. }
  896. func (c *HisApiController) ReadCard() {
  897. id_card_type, _ := c.GetInt64("id_card_type")
  898. admin_user_id, _ := c.GetInt64("admin_user_id")
  899. certificates, _ := c.GetInt64("certificates")
  900. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  901. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  902. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  903. switch id_card_type {
  904. case 1:
  905. if miConfig.MdtrtareaAdmvs == "421300" {
  906. var res ResultTwo
  907. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  908. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  909. "&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)
  910. resp, requestErr := http.Get(api)
  911. if requestErr != nil {
  912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  913. return
  914. }
  915. body, ioErr := ioutil.ReadAll(resp.Body)
  916. if ioErr != nil {
  917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. var respJSON map[string]interface{}
  922. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  925. return
  926. }
  927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  928. result, _ := json.Marshal(respJSON)
  929. fmt.Println("log")
  930. fmt.Println(string(result))
  931. if err := json.Unmarshal([]byte(result), &res); err != nil {
  932. utils.ErrorLog("解析失败:%v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. if res.Infcode == 0 {
  937. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  938. if err == gorm.ErrRecordNotFound {
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  940. return
  941. } else if err != nil {
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  943. return
  944. } else {
  945. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  946. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  947. infoStr := string(Iinfos)
  948. idetinfoStr := string(Idetinfos)
  949. psn := &models.HisPsn{
  950. PsnNo: res.Output.Baseinfo.PsnNo,
  951. Age: res.Output.Baseinfo.Age,
  952. PatientId: patient.ID,
  953. Certno: res.Output.Baseinfo.Certno,
  954. Brdy: res.Output.Baseinfo.Brdy,
  955. Gend: res.Output.Baseinfo.Gend,
  956. Naty: res.Output.Baseinfo.Naty,
  957. PsnCertType: res.Output.Baseinfo.PsnCertType,
  958. PsnName: res.Output.Baseinfo.PsnName,
  959. Idetinfo: idetinfoStr,
  960. Insuinfo: infoStr,
  961. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  962. }
  963. service.CreateHisPsn(psn)
  964. c.ServeSuccessJSON(map[string]interface{}{
  965. "patient": patient,
  966. "number": res.Output.Baseinfo.Certno,
  967. })
  968. }
  969. } else {
  970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  971. return
  972. }
  973. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  974. var api string
  975. if miConfig.MdtrtareaAdmvs == "320921" {
  976. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  977. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  978. fmt.Println(api)
  979. } else {
  980. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  982. }
  983. resp, requestErr := http.Get(api)
  984. if requestErr != nil {
  985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  986. return
  987. }
  988. body, ioErr := ioutil.ReadAll(resp.Body)
  989. if ioErr != nil {
  990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. var respJSON map[string]interface{}
  995. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  998. return
  999. }
  1000. var status string
  1001. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1002. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1003. //console.log()
  1004. fmt.Println("type===")
  1005. fmt.Println(card_type)
  1006. var token string
  1007. var res ResultTwo //1101结果
  1008. var res10265 ResultTwo10265 //1101结果
  1009. var card_info string //卡信息
  1010. var busi_card_info string
  1011. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1012. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1013. if status == "0" { //读卡成功
  1014. if card_type == "1" {
  1015. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1016. result, _ := json.Marshal(respJSON)
  1017. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1018. utils.ErrorLog("解析失败:%v", err)
  1019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1020. return
  1021. }
  1022. res.ErrMsg = res10265.ErrMsg
  1023. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1024. res.Infcode = infocode
  1025. res.Output = res10265.Output
  1026. res.InfRefmsgid = res10265.InfRefmsgid
  1027. } else {
  1028. //var card_info string //卡信息
  1029. //var busi_card_info string
  1030. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1031. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1032. //fmt.Println(card_info)
  1033. //fmt.Println(busi_card_info)
  1034. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1035. result, _ := json.Marshal(respJSON)
  1036. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. res.ErrMsg = res10265.ErrMsg
  1042. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1043. res.Infcode = infocode
  1044. res.Output = res10265.Output
  1045. res.InfRefmsgid = res10265.InfRefmsgid
  1046. }
  1047. if res.Infcode == 0 {
  1048. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1049. if err == gorm.ErrRecordNotFound {
  1050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1051. return
  1052. } else if err != nil {
  1053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1054. return
  1055. } else {
  1056. if card_type == "1" {
  1057. bas := strings.Split(card_info, "|")
  1058. basNumber := bas[2]
  1059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1060. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1061. infoStr := string(Iinfos)
  1062. idetinfoStr := string(Idetinfos)
  1063. psn := &models.HisPsn{
  1064. PsnNo: res.Output.Baseinfo.PsnNo,
  1065. Age: res.Output.Baseinfo.Age,
  1066. PatientId: patient.ID,
  1067. Certno: res.Output.Baseinfo.Certno,
  1068. Brdy: res.Output.Baseinfo.Brdy,
  1069. Gend: res.Output.Baseinfo.Gend,
  1070. Naty: res.Output.Baseinfo.Naty,
  1071. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1072. PsnName: res.Output.Baseinfo.PsnName,
  1073. Idetinfo: idetinfoStr,
  1074. Insuinfo: infoStr,
  1075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1076. CardInfo: card_info,
  1077. VerifyNumber: busi_card_info,
  1078. }
  1079. service.CreateHisPsn(psn)
  1080. c.ServeSuccessJSON(map[string]interface{}{
  1081. "patient": patient,
  1082. "number": basNumber,
  1083. })
  1084. } else {
  1085. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1086. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1087. infoStr := string(Iinfos)
  1088. idetinfoStr := string(Idetinfos)
  1089. psn := &models.HisPsn{
  1090. PsnNo: res.Output.Baseinfo.PsnNo,
  1091. Age: res.Output.Baseinfo.Age,
  1092. PatientId: patient.ID,
  1093. Certno: res.Output.Baseinfo.Certno,
  1094. Brdy: res.Output.Baseinfo.Brdy,
  1095. Gend: res.Output.Baseinfo.Gend,
  1096. Naty: res.Output.Baseinfo.Naty,
  1097. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1098. PsnName: res.Output.Baseinfo.PsnName,
  1099. Idetinfo: idetinfoStr,
  1100. Insuinfo: infoStr,
  1101. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1102. CardInfo: card_info,
  1103. VerifyNumber: token,
  1104. }
  1105. service.CreateHisPsn(psn)
  1106. c.ServeSuccessJSON(map[string]interface{}{
  1107. "patient": patient,
  1108. "number": token,
  1109. })
  1110. }
  1111. }
  1112. } else {
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1114. return
  1115. }
  1116. } else { //读卡失败
  1117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1118. return
  1119. }
  1120. } else {
  1121. if initFlag == 0 {
  1122. c.TestGetBasBaseInit()
  1123. }
  1124. basStr := c.GetBasBaseInfo()
  1125. if len(basStr) == 0 {
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1127. return
  1128. }
  1129. fmt.Println(basStr)
  1130. bas := strings.Split(basStr, "|")
  1131. basNumber := bas[1]
  1132. fmt.Println(basNumber)
  1133. card_sn := bas[3]
  1134. fmt.Println(card_sn)
  1135. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1136. var dat map[string]interface{}
  1137. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1138. fmt.Println(dat)
  1139. } else {
  1140. fmt.Println(err)
  1141. }
  1142. userJSONBytes, _ := json.Marshal(dat)
  1143. var res ResultTwo
  1144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1145. utils.ErrorLog("解析失败:%v", err)
  1146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1147. return
  1148. }
  1149. if res.Infcode == 0 {
  1150. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1151. if err == gorm.ErrRecordNotFound {
  1152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1153. return
  1154. } else if err != nil {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1156. return
  1157. } else {
  1158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1160. infoStr := string(Iinfos)
  1161. idetinfoStr := string(Idetinfos)
  1162. psn := &models.HisPsn{
  1163. PsnNo: res.Output.Baseinfo.PsnNo,
  1164. Age: res.Output.Baseinfo.Age,
  1165. PatientId: patient.ID,
  1166. Certno: res.Output.Baseinfo.Certno,
  1167. Brdy: res.Output.Baseinfo.Brdy,
  1168. Gend: res.Output.Baseinfo.Gend,
  1169. Naty: res.Output.Baseinfo.Naty,
  1170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1171. PsnName: res.Output.Baseinfo.PsnName,
  1172. Idetinfo: idetinfoStr,
  1173. Insuinfo: infoStr,
  1174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1175. CardInfo: basStr,
  1176. VerifyNumber: "",
  1177. }
  1178. service.CreateHisPsn(psn)
  1179. c.ServeSuccessJSON(map[string]interface{}{
  1180. "patient": patient,
  1181. "number": basNumber,
  1182. })
  1183. }
  1184. } else {
  1185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1186. return
  1187. }
  1188. break
  1189. }
  1190. case 2:
  1191. SFZStr := c.GetSFZBaseInfo()
  1192. id_card_str := strings.Split(SFZStr, "^")
  1193. id_card_number := id_card_str[0]
  1194. card_sn := ""
  1195. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1196. var dat map[string]interface{}
  1197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1198. fmt.Println(dat)
  1199. } else {
  1200. fmt.Println(err)
  1201. }
  1202. userJSONBytes, _ := json.Marshal(dat)
  1203. var res ResultTwo
  1204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1205. utils.ErrorLog("解析失败:%v", err)
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1207. return
  1208. }
  1209. if res.Infcode == 0 {
  1210. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1211. if err == gorm.ErrRecordNotFound {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1213. return
  1214. } else if err != nil {
  1215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1216. return
  1217. } else {
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": id_card_number,
  1221. })
  1222. }
  1223. } else {
  1224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1225. return
  1226. }
  1227. break
  1228. case 3:
  1229. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1230. var api string
  1231. if miConfig.MdtrtareaAdmvs == "320921" {
  1232. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1234. fmt.Println(api)
  1235. } else {
  1236. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1237. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1238. }
  1239. resp, requestErr := http.Get(api)
  1240. if requestErr != nil {
  1241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1242. return
  1243. }
  1244. body, ioErr := ioutil.ReadAll(resp.Body)
  1245. if ioErr != nil {
  1246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1248. return
  1249. }
  1250. var respJSON map[string]interface{}
  1251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1254. return
  1255. }
  1256. var status string
  1257. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1258. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1259. var token string
  1260. var res ResultTwo //1101结果
  1261. var res10265 ResultTwo10265 //1101结果
  1262. var card_info string //卡信息
  1263. var busi_card_info string
  1264. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1265. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1266. if status == "0" { //读卡成功
  1267. if card_type == "1" {
  1268. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1269. result, _ := json.Marshal(respJSON)
  1270. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1271. utils.ErrorLog("解析失败:%v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. return
  1274. }
  1275. res.ErrMsg = res10265.ErrMsg
  1276. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1277. res.Infcode = infocode
  1278. res.Output = res10265.Output
  1279. res.InfRefmsgid = res10265.InfRefmsgid
  1280. } else {
  1281. //var card_info string //卡信息
  1282. //var busi_card_info string
  1283. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1284. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1285. //fmt.Println(card_info)
  1286. //fmt.Println(busi_card_info)
  1287. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1288. result, _ := json.Marshal(respJSON)
  1289. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1290. utils.ErrorLog("解析失败:%v", err)
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1292. return
  1293. }
  1294. res.ErrMsg = res10265.ErrMsg
  1295. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1296. res.Infcode = infocode
  1297. res.Output = res10265.Output
  1298. res.InfRefmsgid = res10265.InfRefmsgid
  1299. }
  1300. if res.Infcode == 0 {
  1301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1302. if err == gorm.ErrRecordNotFound {
  1303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1304. return
  1305. } else if err != nil {
  1306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1307. return
  1308. } else {
  1309. if card_type == "1" {
  1310. bas := strings.Split(card_info, "|")
  1311. basNumber := bas[2]
  1312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1314. infoStr := string(Iinfos)
  1315. idetinfoStr := string(Idetinfos)
  1316. psn := &models.HisPsn{
  1317. PsnNo: res.Output.Baseinfo.PsnNo,
  1318. Age: res.Output.Baseinfo.Age,
  1319. PatientId: patient.ID,
  1320. Certno: res.Output.Baseinfo.Certno,
  1321. Brdy: res.Output.Baseinfo.Brdy,
  1322. Gend: res.Output.Baseinfo.Gend,
  1323. Naty: res.Output.Baseinfo.Naty,
  1324. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1325. PsnName: res.Output.Baseinfo.PsnName,
  1326. Idetinfo: idetinfoStr,
  1327. Insuinfo: infoStr,
  1328. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1329. CardInfo: card_info,
  1330. VerifyNumber: busi_card_info,
  1331. }
  1332. service.CreateHisPsn(psn)
  1333. c.ServeSuccessJSON(map[string]interface{}{
  1334. "patient": patient,
  1335. "number": basNumber,
  1336. })
  1337. } else {
  1338. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1339. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1340. infoStr := string(Iinfos)
  1341. idetinfoStr := string(Idetinfos)
  1342. psn := &models.HisPsn{
  1343. PsnNo: res.Output.Baseinfo.PsnNo,
  1344. Age: res.Output.Baseinfo.Age,
  1345. PatientId: patient.ID,
  1346. Certno: res.Output.Baseinfo.Certno,
  1347. Brdy: res.Output.Baseinfo.Brdy,
  1348. Gend: res.Output.Baseinfo.Gend,
  1349. Naty: res.Output.Baseinfo.Naty,
  1350. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1351. PsnName: res.Output.Baseinfo.PsnName,
  1352. Idetinfo: idetinfoStr,
  1353. Insuinfo: infoStr,
  1354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1355. CardInfo: card_info,
  1356. VerifyNumber: token,
  1357. }
  1358. service.CreateHisPsn(psn)
  1359. c.ServeSuccessJSON(map[string]interface{}{
  1360. "patient": patient,
  1361. "number": token,
  1362. })
  1363. }
  1364. }
  1365. } else {
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1367. return
  1368. }
  1369. } else { //读卡失败
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1371. return
  1372. }
  1373. }
  1374. break
  1375. case 4:
  1376. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1377. var api string
  1378. if miConfig.MdtrtareaAdmvs == "320921" {
  1379. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1380. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1381. fmt.Println(api)
  1382. } else {
  1383. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1384. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1385. }
  1386. resp, requestErr := http.Get(api)
  1387. if requestErr != nil {
  1388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1389. return
  1390. }
  1391. body, ioErr := ioutil.ReadAll(resp.Body)
  1392. if ioErr != nil {
  1393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1395. return
  1396. }
  1397. var respJSON map[string]interface{}
  1398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1401. return
  1402. }
  1403. var status string
  1404. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1405. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1406. var token string
  1407. var res ResultTwo //1101结果
  1408. var res10265 ResultTwo10265 //1101结果
  1409. if status == "0" { //读卡成功
  1410. var card_info string //卡信息
  1411. var busi_card_info string
  1412. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1413. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1414. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1415. fmt.Println(card_info)
  1416. fmt.Println(busi_card_info)
  1417. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1418. result, _ := json.Marshal(respJSON)
  1419. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1420. utils.ErrorLog("解析失败:%v", err)
  1421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1422. return
  1423. }
  1424. res.ErrMsg = res10265.ErrMsg
  1425. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1426. res.Infcode = infocode
  1427. res.Output = res10265.Output
  1428. res.InfRefmsgid = res10265.InfRefmsgid
  1429. if res.Infcode == 0 {
  1430. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1431. if err == gorm.ErrRecordNotFound {
  1432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1433. return
  1434. } else if err != nil {
  1435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1436. return
  1437. } else {
  1438. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1439. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1440. infoStr := string(Iinfos)
  1441. idetinfoStr := string(Idetinfos)
  1442. psn := &models.HisPsn{
  1443. PsnNo: res.Output.Baseinfo.PsnNo,
  1444. Age: res.Output.Baseinfo.Age,
  1445. PatientId: patient.ID,
  1446. Certno: res.Output.Baseinfo.Certno,
  1447. Brdy: res.Output.Baseinfo.Brdy,
  1448. Gend: res.Output.Baseinfo.Gend,
  1449. Naty: res.Output.Baseinfo.Naty,
  1450. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1451. PsnName: res.Output.Baseinfo.PsnName,
  1452. Idetinfo: idetinfoStr,
  1453. Insuinfo: infoStr,
  1454. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1455. CardInfo: card_info,
  1456. VerifyNumber: token,
  1457. }
  1458. service.CreateHisPsn(psn)
  1459. c.ServeSuccessJSON(map[string]interface{}{
  1460. "patient": patient,
  1461. "number": token,
  1462. })
  1463. }
  1464. } else {
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1466. return
  1467. }
  1468. } else { //读卡失败
  1469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1470. return
  1471. }
  1472. }
  1473. break
  1474. }
  1475. }
  1476. var initFlag int64 = 0
  1477. func (c *HisApiController) TestGetBasBaseInit() {
  1478. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1479. Iinit := DllDef.MustFindProc("Init")
  1480. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1481. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1482. if ret != 0 {
  1483. fmt.Println("SSCard的报错原因:", err)
  1484. fmt.Println("SSCard的运算结果为:", ret)
  1485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1486. return
  1487. }
  1488. result := int(ret)
  1489. fmt.Println("SSCard的运算结果为1:", result)
  1490. initFlag = 1
  1491. return
  1492. }
  1493. func (c *HisApiController) GetSFZBaseInfo() string {
  1494. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1495. readCard := DllDef.MustFindProc("ReadSFZ")
  1496. if readCard == nil {
  1497. fmt.Println("readcard is nil")
  1498. readCard = DllDef.MustFindProc("ReadSFZ")
  1499. }
  1500. str := make([]byte, 256)
  1501. str1 := make([]byte, 256)
  1502. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1503. fmt.Println(r)
  1504. return string(str)
  1505. }
  1506. func (c *HisApiController) GetBasBaseInfo() string {
  1507. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1508. readCard := DllDef.MustFindProc("ReadCardBas")
  1509. if readCard == nil {
  1510. fmt.Println("readcard is nil")
  1511. readCard = DllDef.MustFindProc("ReadCardBas")
  1512. }
  1513. str := make([]byte, 1024)
  1514. str1 := make([]byte, 1024)
  1515. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1516. fmt.Println(string(str1))
  1517. fmt.Println(string(str))
  1518. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1519. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1520. if ret2 != 0 {
  1521. return ""
  1522. }
  1523. return string(str)
  1524. }
  1525. type CustomFundPay struct {
  1526. FundPayType string `json:"fund_pay_type"`
  1527. FundPayamt float64 `json:"fund_payamt"`
  1528. }
  1529. func (c *HisApiController) GetSettleList() {
  1530. order_id, _ := c.GetInt64("order_id")
  1531. admin_user_id, _ := c.GetInt64("admin_user_id")
  1532. order, _ := service.GetHisOrderByIDTwo(order_id)
  1533. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1534. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1535. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1536. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1537. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1538. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1539. if order.ID == 0 {
  1540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1541. return
  1542. }
  1543. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1544. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1545. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1546. fmt.Println(count)
  1547. var zero string
  1548. number := count + 1
  1549. if number >= 1000 {
  1550. zero = "0000" + strconv.FormatInt(number, 10)
  1551. } else if number >= 10000 {
  1552. zero = "000" + strconv.FormatInt(number, 10)
  1553. } else if number >= 100000 {
  1554. zero = "00" + strconv.FormatInt(number, 10)
  1555. } else if number >= 1000000 {
  1556. zero = "0" + strconv.FormatInt(number, 10)
  1557. } else {
  1558. zero = strconv.FormatInt(number, 10)
  1559. }
  1560. fmt.Println(zero)
  1561. struct4101 := service.Struct4101{
  1562. PsnNo: order.PsnNo,
  1563. MdtrtId: order.MdtrtId,
  1564. SetlId: order.SetlId,
  1565. PsnName: order.PsnName,
  1566. Gend: order.Gend,
  1567. Brdy: his.Brdy,
  1568. Age: his.Age,
  1569. Naty: order.Naty,
  1570. PatnCertType: "01",
  1571. Certno: order.Certno,
  1572. Prfs: "90",
  1573. ConerName: roles[0].UserName,
  1574. PatnRlts: "99",
  1575. ConerAddr: miConfig.OrgName,
  1576. ConerTel: admin.Mobile,
  1577. HiType: order.Insutype,
  1578. Insuplc: miConfig.InsuplcAdmdvs,
  1579. MaindiagFlag: "1",
  1580. BillCode: last_order.FaPiaoCode,
  1581. BillNo: zero,
  1582. BizSn: order.Number,
  1583. PsnSelfPay: order.PsnPartAmt,
  1584. PsnOwnPay: order.PsnPartAmt,
  1585. AcctPay: order.AcctPay,
  1586. PsnCashpay: order.PsnCashPay,
  1587. HiPaymtd: "1",
  1588. Hsorg: miConfig.InsuplcAdmdvs,
  1589. HsorgOpter: miConfig.InsuplcAdmdvs,
  1590. MedinsFillPsn: curRoles.UserName,
  1591. MedinsFillDept: depart.Name,
  1592. IptMedType: "2",
  1593. }
  1594. struct4101.SetlBegnDate = order.SetlTime
  1595. struct4101.SetlEndDate = order.SetlTime
  1596. time_arr := strings.Split(order.SetlTime, " ")
  1597. struct4101.AdmTime = time_arr[0]
  1598. struct4101.AdmEndTime = time_arr[0]
  1599. var rf []CustomFundPay
  1600. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1601. var tempFunPays []service.CustomStruct
  1602. for _, item := range rf {
  1603. var tempFunPay service.CustomStruct
  1604. tempFunPay.FundPayamt = item.FundPayamt
  1605. tempFunPay.FundPayType = item.FundPayType
  1606. tempFunPays = append(tempFunPays, tempFunPay)
  1607. }
  1608. struct4101.CustomStruct = tempFunPays
  1609. var tempDiaginfos []service.DiaginfoStructTwo
  1610. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1611. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1612. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1613. var config []*models.HisXtDiagnoseConfig
  1614. for _, item := range diagnosis_ids {
  1615. id, _ := strconv.ParseInt(item, 10, 64)
  1616. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1617. config = append(config, &diagnosisConfig)
  1618. }
  1619. for index, item := range config {
  1620. if index == 0 {
  1621. var tempDiaginfo service.DiaginfoStructTwo
  1622. tempDiaginfo.DiagCode = item.CountryCode
  1623. tempDiaginfo.DiagName = item.CountryContentName
  1624. tempDiaginfo.DiagType = "1"
  1625. tempDiaginfo.MaindiagFlag = "1"
  1626. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1627. } else {
  1628. var tempDiaginfo service.DiaginfoStructTwo
  1629. tempDiaginfo.DiagCode = item.CountryCode
  1630. tempDiaginfo.DiagName = item.CountryContentName
  1631. tempDiaginfo.DiagType = "2"
  1632. tempDiaginfo.MaindiagFlag = "0"
  1633. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1634. }
  1635. }
  1636. struct4101.Diseinfo = tempDiaginfos
  1637. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1638. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1639. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1640. tempOpspdiseinfo2.OprnOprtCode = ""
  1641. tempOpspdiseinfo2.OprnOprtName = ""
  1642. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1643. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1644. var iteminfo service.IteminfoStruct
  1645. var bedCostTotal float64 = 0 //床位总费
  1646. var bedCostSelfTotal float64 = 0 //床位自费
  1647. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1648. var operationCostTotal float64 = 0 //手术费
  1649. var operationCostSelfTotal float64 = 0 //手术费
  1650. var operationCostPartSelfTotal float64 = 0 //手术费
  1651. var otherCostTotal float64 = 0 //其他费用
  1652. var otherCostSelfTotal float64 = 0 //其他费用
  1653. var otherCostPartSelfTotal float64 = 0 //其他费用
  1654. var materialCostTotal float64 = 0 //材料费
  1655. var materialCostSelfTotal float64 = 0 //材料费
  1656. var materialCostPartSelfTotal float64 = 0 //材料费
  1657. var westernMedicineCostTotal float64 = 0 //西药费
  1658. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1659. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1660. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1661. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1662. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1663. var checkCostTotal float64 = 0 //检查费
  1664. var checkCostSelfTotal float64 = 0 //检查费
  1665. var checkCostPartSelfTotal float64 = 0 //检查费
  1666. var laboratoryCostTotal float64 = 0 //化验费
  1667. var laboratoryCostSelfTotal float64 = 0 //化验费
  1668. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1669. var treatCostTotal float64 = 0 //治疗费用
  1670. var treatCostSelfTotal float64 = 0 //治疗费用
  1671. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1672. decimal.DivisionPrecision = 2
  1673. var bed_fulamt_ownpay_amt float64 = 0
  1674. var operation_fulamt_ownpay_amt float64 = 0
  1675. var other_fulamt_ownpay_amt float64 = 0
  1676. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1677. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1678. var check_fulamt_ownpay_amt float64 = 0
  1679. var material_fulamt_ownpay_amt float64 = 0
  1680. var laboratory_fulamt_ownpay_amt float64 = 0
  1681. var treat_fulamt_ownpay_amt float64 = 0
  1682. var bed_claa_sunmfee float64 = 0
  1683. var bed_clab_amt float64 = 0
  1684. var bed_other_amt float64 = 0
  1685. var operation_claa_sunmfee float64 = 0
  1686. var operation_clab_amt float64 = 0
  1687. var operation_other_amt float64 = 0
  1688. var other_claa_sunmfee float64 = 0
  1689. var other_clab_amt float64 = 0
  1690. var other_other_amt float64 = 0
  1691. var westernMedicine_claa_sunmfee float64 = 0
  1692. var westernMedicine_clab_amt float64 = 0
  1693. var westernMedicine_other_amt float64 = 0
  1694. var chineseTraditional_claa_sunmfee float64 = 0
  1695. var chineseTraditional_clab_amt float64 = 0
  1696. var chineseTraditional_other_amt float64 = 0
  1697. var check_claa_sunmfee float64 = 0
  1698. var check_clab_amt float64 = 0
  1699. var check_other_amt float64 = 0
  1700. var material_claa_sunmfee float64 = 0
  1701. var material_clab_amt float64 = 0
  1702. var material_other_amt float64 = 0
  1703. var laboratory_claa_sunmfee float64 = 0
  1704. var laboratory_clab_amt float64 = 0
  1705. var laboratory_other_amt float64 = 0
  1706. var treat_claa_sunmfee float64 = 0
  1707. var treat_clab_amt float64 = 0
  1708. var treat_other_amt float64 = 0
  1709. for _, item := range order.HisOrderInfo {
  1710. if item.MedChrgitmType == "01" { //床位费
  1711. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1712. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1713. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1714. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1715. if item.ChrgitmLv == "1" {
  1716. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1717. }
  1718. if item.ChrgitmLv == "2" {
  1719. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1720. }
  1721. if item.ChrgitmLv == "3" {
  1722. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1723. }
  1724. }
  1725. if item.MedChrgitmType == "03" { //检查费
  1726. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1727. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1728. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1729. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1730. if item.ChrgitmLv == "1" {
  1731. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1732. }
  1733. if item.ChrgitmLv == "2" {
  1734. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1735. }
  1736. if item.ChrgitmLv == "3" {
  1737. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1738. }
  1739. }
  1740. if item.MedChrgitmType == "04" { //化验费
  1741. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1742. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1743. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1744. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1745. if item.ChrgitmLv == "1" {
  1746. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1747. }
  1748. if item.ChrgitmLv == "2" {
  1749. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1750. }
  1751. if item.ChrgitmLv == "3" {
  1752. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1753. }
  1754. }
  1755. if item.MedChrgitmType == "05" { //治疗费
  1756. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1757. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1758. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1759. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1760. if item.ChrgitmLv == "1" {
  1761. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1762. }
  1763. if item.ChrgitmLv == "2" {
  1764. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1765. }
  1766. if item.ChrgitmLv == "3" {
  1767. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1768. }
  1769. }
  1770. if item.MedChrgitmType == "06" { //手术费
  1771. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1772. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1773. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1774. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1775. if item.ChrgitmLv == "1" {
  1776. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1777. }
  1778. if item.ChrgitmLv == "2" {
  1779. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1780. }
  1781. if item.ChrgitmLv == "3" {
  1782. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1783. }
  1784. }
  1785. if item.MedChrgitmType == "08" { //材料费
  1786. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1787. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1788. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1789. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1790. if item.ChrgitmLv == "1" {
  1791. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1792. }
  1793. if item.ChrgitmLv == "2" {
  1794. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1795. }
  1796. if item.ChrgitmLv == "3" {
  1797. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1798. }
  1799. }
  1800. if item.MedChrgitmType == "09" { //西药费
  1801. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1802. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1803. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1804. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1805. if item.ChrgitmLv == "1" {
  1806. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1807. }
  1808. if item.ChrgitmLv == "2" {
  1809. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1810. }
  1811. if item.ChrgitmLv == "3" {
  1812. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1813. }
  1814. }
  1815. if item.MedChrgitmType == "11" { //中成费
  1816. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1817. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1818. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1819. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1820. if item.ChrgitmLv == "1" {
  1821. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1822. }
  1823. if item.ChrgitmLv == "2" {
  1824. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1825. }
  1826. if item.ChrgitmLv == "3" {
  1827. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1828. }
  1829. }
  1830. if item.MedChrgitmType == "14" { //其他费
  1831. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1832. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1833. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1834. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1835. if item.ChrgitmLv == "1" {
  1836. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1837. }
  1838. if item.ChrgitmLv == "2" {
  1839. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1840. }
  1841. if item.ChrgitmLv == "3" {
  1842. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1843. }
  1844. }
  1845. }
  1846. var iteminfoStructs []service.IteminfoStruct
  1847. if bedCostTotal != 0 {
  1848. iteminfo.MedChrgitm = "01"
  1849. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1850. iteminfo.Amt = bedCostTotal
  1851. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1852. iteminfo.ClabAmt = bed_clab_amt
  1853. iteminfo.OthAmt = bed_other_amt
  1854. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1855. }
  1856. if checkCostTotal != 0 {
  1857. iteminfo.MedChrgitm = "03"
  1858. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1859. iteminfo.Amt = checkCostTotal
  1860. iteminfo.ClaaSumfee = check_claa_sunmfee
  1861. iteminfo.ClabAmt = check_clab_amt
  1862. iteminfo.OthAmt = check_other_amt
  1863. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1864. }
  1865. if laboratoryCostTotal != 0 {
  1866. iteminfo.MedChrgitm = "04"
  1867. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1868. iteminfo.Amt = laboratoryCostTotal
  1869. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1870. iteminfo.ClabAmt = laboratory_clab_amt
  1871. iteminfo.OthAmt = laboratory_other_amt
  1872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1873. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1874. }
  1875. if treatCostTotal != 0 {
  1876. iteminfo.MedChrgitm = "05"
  1877. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1878. iteminfo.Amt = treatCostTotal
  1879. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1880. iteminfo.ClabAmt = treat_clab_amt
  1881. iteminfo.OthAmt = treat_other_amt
  1882. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1883. //(struct4101.IteminfoStruct, iteminfo)
  1884. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1885. }
  1886. if operationCostTotal != 0 {
  1887. iteminfo.MedChrgitm = "06"
  1888. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1889. iteminfo.Amt = operationCostTotal
  1890. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1891. iteminfo.ClabAmt = operation_clab_amt
  1892. iteminfo.OthAmt = operation_other_amt
  1893. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1895. }
  1896. if materialCostTotal != 0 {
  1897. iteminfo.MedChrgitm = "08"
  1898. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1899. iteminfo.Amt = materialCostTotal
  1900. iteminfo.ClaaSumfee = material_claa_sunmfee
  1901. iteminfo.ClabAmt = material_clab_amt
  1902. iteminfo.OthAmt = material_other_amt
  1903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1904. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1905. }
  1906. if westernMedicineCostTotal != 0 {
  1907. iteminfo.MedChrgitm = "09"
  1908. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1909. iteminfo.Amt = westernMedicineCostTotal
  1910. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1911. iteminfo.ClabAmt = westernMedicine_clab_amt
  1912. iteminfo.OthAmt = westernMedicine_other_amt
  1913. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1914. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1915. }
  1916. if chineseTraditionalMedicineCostTotal != 0 {
  1917. iteminfo.MedChrgitm = "11"
  1918. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1919. iteminfo.Amt = westernMedicineCostTotal
  1920. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1921. iteminfo.ClabAmt = westernMedicine_clab_amt
  1922. iteminfo.OthAmt = westernMedicine_other_amt
  1923. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1925. }
  1926. if otherCostTotal != 0 {
  1927. iteminfo.MedChrgitm = "14"
  1928. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1929. iteminfo.Amt = otherCostTotal
  1930. iteminfo.ClaaSumfee = other_claa_sunmfee
  1931. iteminfo.ClabAmt = other_clab_amt
  1932. iteminfo.OthAmt = other_other_amt
  1933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1935. }
  1936. struct4101.IteminfoStruct = iteminfoStructs
  1937. struct4101.Ntly = "中国"
  1938. struct4101.AdmCaty = "A03.06"
  1939. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1940. fmt.Println(result)
  1941. var dat map[string]interface{}
  1942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1943. fmt.Println(dat)
  1944. } else {
  1945. fmt.Println(err)
  1946. }
  1947. userJSONBytes, _ := json.Marshal(dat)
  1948. var res ResultSeventeen
  1949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1950. utils.ErrorLog("解析失败:%v", err)
  1951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1952. return
  1953. }
  1954. if res.Infcode != 0 {
  1955. c.ServeSuccessJSON(map[string]interface{}{
  1956. "failed_code": -10,
  1957. "msg": res.ErrMsg,
  1958. })
  1959. return
  1960. } else {
  1961. order.FaPiaoNumber = zero
  1962. order.FaPiaoCode = last_order.FaPiaoCode
  1963. service.UpdateOrder(order)
  1964. hisFundSettleListResult := &models.HisFundSettleListResult{
  1965. Number: res.Output.SetlListId,
  1966. Status: 1,
  1967. Ctime: time.Now().Unix(),
  1968. Mtime: time.Now().Unix(),
  1969. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1970. IsUpload: 1,
  1971. OrderId: order_id,
  1972. }
  1973. service.CreateUploadRecord(hisFundSettleListResult)
  1974. c.ServeSuccessJSON(map[string]interface{}{
  1975. "msg": "上传成功",
  1976. "result": hisFundSettleListResult,
  1977. })
  1978. return
  1979. }
  1980. }
  1981. func (c *HisApiController) GetSettleListHospital() {
  1982. order_id, _ := c.GetInt64("order_id")
  1983. admin_user_id, _ := c.GetInt64("admin_user_id")
  1984. order, _ := service.GetHisOrderByIDTwo(order_id)
  1985. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1986. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1987. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1988. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1989. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1991. if order.ID == 0 {
  1992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1993. return
  1994. }
  1995. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1996. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1997. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1998. fmt.Println(count)
  1999. var zero string
  2000. number := count + 1
  2001. if number >= 1000 {
  2002. zero = "0000" + strconv.FormatInt(number, 10)
  2003. } else if number >= 10000 {
  2004. zero = "000" + strconv.FormatInt(number, 10)
  2005. } else if number >= 100000 {
  2006. zero = "00" + strconv.FormatInt(number, 10)
  2007. } else if number >= 1000000 {
  2008. zero = "0" + strconv.FormatInt(number, 10)
  2009. } else {
  2010. zero = strconv.FormatInt(number, 10)
  2011. }
  2012. fmt.Println(zero)
  2013. struct4101 := service.Struct4101{
  2014. PsnNo: order.PsnNo,
  2015. MdtrtId: order.MdtrtId,
  2016. SetlId: order.SetlId,
  2017. PsnName: order.PsnName,
  2018. Gend: order.Gend,
  2019. Brdy: his.Brdy,
  2020. Age: int64(order.Age),
  2021. Naty: order.Naty,
  2022. PatnCertType: "01",
  2023. Certno: order.Certno,
  2024. Prfs: "90",
  2025. ConerName: roles[0].UserName,
  2026. PatnRlts: "99",
  2027. ConerAddr: miConfig.OrgName,
  2028. ConerTel: admin.Mobile,
  2029. HiType: order.Insutype,
  2030. Insuplc: miConfig.InsuplcAdmdvs,
  2031. MaindiagFlag: "1",
  2032. BillCode: last_order.FaPiaoCode,
  2033. BillNo: zero,
  2034. BizSn: order.Number,
  2035. PsnSelfPay: order.PsnPartAmt,
  2036. PsnOwnPay: order.PsnPartAmt,
  2037. AcctPay: order.AcctPay,
  2038. PsnCashpay: order.PsnCashPay,
  2039. HiPaymtd: "1",
  2040. Hsorg: miConfig.InsuplcAdmdvs,
  2041. HsorgOpter: miConfig.InsuplcAdmdvs,
  2042. MedinsFillPsn: curRoles.UserName,
  2043. MedinsFillDept: depart.Name,
  2044. IptMedType: "2",
  2045. AdmTime: his.InHosptialTime,
  2046. AdmEndTime: his.OutHosptialTime,
  2047. }
  2048. struct4101.SetlBegnDate = order.SetlTime
  2049. struct4101.SetlEndDate = order.SetlTime
  2050. var rf []CustomFundPay
  2051. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2052. var tempFunPays []service.CustomStruct
  2053. for _, item := range rf {
  2054. var tempFunPay service.CustomStruct
  2055. tempFunPay.FundPayamt = item.FundPayamt
  2056. tempFunPay.FundPayType = item.FundPayType
  2057. tempFunPays = append(tempFunPays, tempFunPay)
  2058. }
  2059. struct4101.CustomStruct = tempFunPays
  2060. var tempDiaginfos []service.DiaginfoStructTwo
  2061. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2062. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2063. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2064. var config []*models.HisXtDiagnoseConfig
  2065. for _, item := range diagnosis_ids {
  2066. id, _ := strconv.ParseInt(item, 10, 64)
  2067. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2068. config = append(config, &diagnosisConfig)
  2069. }
  2070. for index, item := range config {
  2071. if index == 0 {
  2072. var tempDiaginfo service.DiaginfoStructTwo
  2073. tempDiaginfo.DiagCode = item.CountryCode
  2074. tempDiaginfo.DiagName = item.CountryContentName
  2075. tempDiaginfo.DiagType = "1"
  2076. tempDiaginfo.MaindiagFlag = "1"
  2077. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2078. } else {
  2079. var tempDiaginfo service.DiaginfoStructTwo
  2080. tempDiaginfo.DiagCode = item.CountryCode
  2081. tempDiaginfo.DiagName = item.CountryContentName
  2082. tempDiaginfo.DiagType = "2"
  2083. tempDiaginfo.MaindiagFlag = "0"
  2084. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2085. }
  2086. }
  2087. struct4101.Diseinfo = tempDiaginfos
  2088. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2089. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2090. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2091. tempOpspdiseinfo2.OprnOprtCode = ""
  2092. tempOpspdiseinfo2.OprnOprtName = ""
  2093. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2094. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2095. var iteminfo service.IteminfoStruct
  2096. var bedCostTotal float64 = 0 //床位总费
  2097. var bedCostSelfTotal float64 = 0 //床位自费
  2098. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2099. var operationCostTotal float64 = 0 //手术费
  2100. var operationCostSelfTotal float64 = 0 //手术费
  2101. var operationCostPartSelfTotal float64 = 0 //手术费
  2102. var otherCostTotal float64 = 0 //其他费用
  2103. var otherCostSelfTotal float64 = 0 //其他费用
  2104. var otherCostPartSelfTotal float64 = 0 //其他费用
  2105. var materialCostTotal float64 = 0 //材料费
  2106. var materialCostSelfTotal float64 = 0 //材料费
  2107. var materialCostPartSelfTotal float64 = 0 //材料费
  2108. var westernMedicineCostTotal float64 = 0 //西药费
  2109. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2110. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2111. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2112. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2113. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2114. var checkCostTotal float64 = 0 //检查费
  2115. var checkCostSelfTotal float64 = 0 //检查费
  2116. var checkCostPartSelfTotal float64 = 0 //检查费
  2117. var laboratoryCostTotal float64 = 0 //化验费
  2118. var laboratoryCostSelfTotal float64 = 0 //化验费
  2119. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2120. var treatCostTotal float64 = 0 //治疗费用
  2121. var treatCostSelfTotal float64 = 0 //治疗费用
  2122. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2123. decimal.DivisionPrecision = 2
  2124. var bed_fulamt_ownpay_amt float64 = 0
  2125. var operation_fulamt_ownpay_amt float64 = 0
  2126. var other_fulamt_ownpay_amt float64 = 0
  2127. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2128. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2129. var check_fulamt_ownpay_amt float64 = 0
  2130. var material_fulamt_ownpay_amt float64 = 0
  2131. var laboratory_fulamt_ownpay_amt float64 = 0
  2132. var treat_fulamt_ownpay_amt float64 = 0
  2133. var bed_claa_sunmfee float64 = 0
  2134. var bed_clab_amt float64 = 0
  2135. var bed_other_amt float64 = 0
  2136. var operation_claa_sunmfee float64 = 0
  2137. var operation_clab_amt float64 = 0
  2138. var operation_other_amt float64 = 0
  2139. var other_claa_sunmfee float64 = 0
  2140. var other_clab_amt float64 = 0
  2141. var other_other_amt float64 = 0
  2142. var westernMedicine_claa_sunmfee float64 = 0
  2143. var westernMedicine_clab_amt float64 = 0
  2144. var westernMedicine_other_amt float64 = 0
  2145. var chineseTraditional_claa_sunmfee float64 = 0
  2146. var chineseTraditional_clab_amt float64 = 0
  2147. var chineseTraditional_other_amt float64 = 0
  2148. var check_claa_sunmfee float64 = 0
  2149. var check_clab_amt float64 = 0
  2150. var check_other_amt float64 = 0
  2151. var material_claa_sunmfee float64 = 0
  2152. var material_clab_amt float64 = 0
  2153. var material_other_amt float64 = 0
  2154. var laboratory_claa_sunmfee float64 = 0
  2155. var laboratory_clab_amt float64 = 0
  2156. var laboratory_other_amt float64 = 0
  2157. var treat_claa_sunmfee float64 = 0
  2158. var treat_clab_amt float64 = 0
  2159. var treat_other_amt float64 = 0
  2160. for _, item := range order.HisOrderInfo {
  2161. if item.MedChrgitmType == "01" { //床位费
  2162. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2163. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2164. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2165. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2166. if item.ChrgitmLv == "1" {
  2167. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2168. }
  2169. if item.ChrgitmLv == "2" {
  2170. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2171. }
  2172. if item.ChrgitmLv == "3" {
  2173. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2174. }
  2175. }
  2176. if item.MedChrgitmType == "03" { //检查费
  2177. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2178. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2179. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2180. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2181. if item.ChrgitmLv == "1" {
  2182. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2183. }
  2184. if item.ChrgitmLv == "2" {
  2185. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2186. }
  2187. if item.ChrgitmLv == "3" {
  2188. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2189. }
  2190. }
  2191. if item.MedChrgitmType == "04" { //化验费
  2192. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2193. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2194. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2195. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2196. if item.ChrgitmLv == "1" {
  2197. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2198. }
  2199. if item.ChrgitmLv == "2" {
  2200. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2201. }
  2202. if item.ChrgitmLv == "3" {
  2203. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2204. }
  2205. }
  2206. if item.MedChrgitmType == "05" { //治疗费
  2207. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2208. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2209. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2210. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2211. if item.ChrgitmLv == "1" {
  2212. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2213. }
  2214. if item.ChrgitmLv == "2" {
  2215. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2216. }
  2217. if item.ChrgitmLv == "3" {
  2218. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2219. }
  2220. }
  2221. if item.MedChrgitmType == "06" { //手术费
  2222. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2223. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2224. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2225. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2226. if item.ChrgitmLv == "1" {
  2227. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2228. }
  2229. if item.ChrgitmLv == "2" {
  2230. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2231. }
  2232. if item.ChrgitmLv == "3" {
  2233. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2234. }
  2235. }
  2236. if item.MedChrgitmType == "08" { //材料费
  2237. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2238. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2239. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2240. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2241. if item.ChrgitmLv == "1" {
  2242. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2243. }
  2244. if item.ChrgitmLv == "2" {
  2245. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2246. }
  2247. if item.ChrgitmLv == "3" {
  2248. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2249. }
  2250. }
  2251. if item.MedChrgitmType == "09" { //西药费
  2252. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2253. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2254. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2255. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2256. if item.ChrgitmLv == "1" {
  2257. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2258. }
  2259. if item.ChrgitmLv == "2" {
  2260. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2261. }
  2262. if item.ChrgitmLv == "3" {
  2263. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2264. }
  2265. }
  2266. if item.MedChrgitmType == "11" { //中成费
  2267. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2268. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2269. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2270. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2271. if item.ChrgitmLv == "1" {
  2272. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2273. }
  2274. if item.ChrgitmLv == "2" {
  2275. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2276. }
  2277. if item.ChrgitmLv == "3" {
  2278. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2279. }
  2280. }
  2281. if item.MedChrgitmType == "14" { //其他费
  2282. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2283. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2284. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2285. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2286. if item.ChrgitmLv == "1" {
  2287. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2288. }
  2289. if item.ChrgitmLv == "2" {
  2290. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2291. }
  2292. if item.ChrgitmLv == "3" {
  2293. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2294. }
  2295. }
  2296. }
  2297. var iteminfoStructs []service.IteminfoStruct
  2298. if bedCostTotal != 0 {
  2299. iteminfo.MedChrgitm = "01"
  2300. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2301. iteminfo.Amt = bedCostTotal
  2302. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2303. iteminfo.ClabAmt = bed_clab_amt
  2304. iteminfo.OthAmt = bed_other_amt
  2305. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2306. }
  2307. if checkCostTotal != 0 {
  2308. iteminfo.MedChrgitm = "03"
  2309. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2310. iteminfo.Amt = checkCostTotal
  2311. iteminfo.ClaaSumfee = check_claa_sunmfee
  2312. iteminfo.ClabAmt = check_clab_amt
  2313. iteminfo.OthAmt = check_other_amt
  2314. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2315. }
  2316. if laboratoryCostTotal != 0 {
  2317. iteminfo.MedChrgitm = "04"
  2318. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2319. iteminfo.Amt = laboratoryCostTotal
  2320. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2321. iteminfo.ClabAmt = laboratory_clab_amt
  2322. iteminfo.OthAmt = laboratory_other_amt
  2323. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2324. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2325. }
  2326. if treatCostTotal != 0 {
  2327. iteminfo.MedChrgitm = "05"
  2328. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2329. iteminfo.Amt = treatCostTotal
  2330. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2331. iteminfo.ClabAmt = treat_clab_amt
  2332. iteminfo.OthAmt = treat_other_amt
  2333. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2334. //(struct4101.IteminfoStruct, iteminfo)
  2335. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2336. }
  2337. if operationCostTotal != 0 {
  2338. iteminfo.MedChrgitm = "06"
  2339. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2340. iteminfo.Amt = operationCostTotal
  2341. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2342. iteminfo.ClabAmt = operation_clab_amt
  2343. iteminfo.OthAmt = operation_other_amt
  2344. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2345. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2346. }
  2347. if materialCostTotal != 0 {
  2348. iteminfo.MedChrgitm = "08"
  2349. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2350. iteminfo.Amt = materialCostTotal
  2351. iteminfo.ClaaSumfee = material_claa_sunmfee
  2352. iteminfo.ClabAmt = material_clab_amt
  2353. iteminfo.OthAmt = material_other_amt
  2354. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2355. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2356. }
  2357. if westernMedicineCostTotal != 0 {
  2358. iteminfo.MedChrgitm = "09"
  2359. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2360. iteminfo.Amt = westernMedicineCostTotal
  2361. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2362. iteminfo.ClabAmt = westernMedicine_clab_amt
  2363. iteminfo.OthAmt = westernMedicine_other_amt
  2364. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2366. }
  2367. if chineseTraditionalMedicineCostTotal != 0 {
  2368. iteminfo.MedChrgitm = "11"
  2369. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2370. iteminfo.Amt = westernMedicineCostTotal
  2371. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2372. iteminfo.ClabAmt = westernMedicine_clab_amt
  2373. iteminfo.OthAmt = westernMedicine_other_amt
  2374. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2375. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2376. }
  2377. if otherCostTotal != 0 {
  2378. iteminfo.MedChrgitm = "14"
  2379. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2380. iteminfo.Amt = otherCostTotal
  2381. iteminfo.ClaaSumfee = other_claa_sunmfee
  2382. iteminfo.ClabAmt = other_clab_amt
  2383. iteminfo.OthAmt = other_other_amt
  2384. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2385. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2386. }
  2387. struct4101.IteminfoStruct = iteminfoStructs
  2388. struct4101.Ntly = "中国"
  2389. struct4101.AdmCaty = "A03.06"
  2390. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2391. fmt.Println(result)
  2392. var dat map[string]interface{}
  2393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2394. fmt.Println(dat)
  2395. } else {
  2396. fmt.Println(err)
  2397. }
  2398. userJSONBytes, _ := json.Marshal(dat)
  2399. var res ResultSeventeen
  2400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2401. utils.ErrorLog("解析失败:%v", err)
  2402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2403. return
  2404. }
  2405. if res.Infcode != 0 {
  2406. c.ServeSuccessJSON(map[string]interface{}{
  2407. "failed_code": -10,
  2408. "msg": res.ErrMsg,
  2409. })
  2410. return
  2411. } else {
  2412. order.FaPiaoNumber = zero
  2413. order.FaPiaoCode = last_order.FaPiaoCode
  2414. service.UpdateOrder(order)
  2415. hisFundSettleListResult := &models.HisFundSettleListResult{
  2416. Number: res.Output.SetlListId,
  2417. Status: 1,
  2418. Ctime: time.Now().Unix(),
  2419. Mtime: time.Now().Unix(),
  2420. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2421. IsUpload: 1,
  2422. OrderId: order_id,
  2423. }
  2424. service.CreateUploadRecord(hisFundSettleListResult)
  2425. c.ServeSuccessJSON(map[string]interface{}{
  2426. "msg": "上传成功",
  2427. "result": hisFundSettleListResult,
  2428. })
  2429. return
  2430. }
  2431. }
  2432. func (c *HisApiController) GetBatchSettleList() {
  2433. orders, _ := service.GetAllHisOrder(10106)
  2434. for _, item := range orders {
  2435. order_id := item.ID
  2436. order, _ := service.GetHisOrderByIDTwo(order_id)
  2437. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2438. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2439. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2440. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2441. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2442. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2443. if order.ID == 0 {
  2444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2445. return
  2446. }
  2447. if his.BalanceAccountsType == 2 {
  2448. continue
  2449. }
  2450. struct4101 := service.Struct4101{
  2451. PsnNo: order.PsnNo,
  2452. MdtrtId: order.MdtrtId,
  2453. SetlId: order.SetlId,
  2454. PsnName: order.PsnName,
  2455. Gend: order.Gend,
  2456. Brdy: his.Brdy,
  2457. Age: his.Age,
  2458. Naty: order.Naty,
  2459. PatnCertType: "01",
  2460. Certno: order.Certno,
  2461. Prfs: "90",
  2462. ConerName: roles[0].UserName,
  2463. PatnRlts: "99",
  2464. ConerAddr: miConfig.OrgName,
  2465. ConerTel: admin.Mobile,
  2466. HiType: order.Insutype,
  2467. Insuplc: his.InsuplcAdmdvs,
  2468. MaindiagFlag: "1",
  2469. BillCode: order.FaPiaoCode,
  2470. BillNo: order.FaPiaoNumber,
  2471. BizSn: order.Number,
  2472. PsnSelfPay: order.PsnPartAmt,
  2473. PsnOwnPay: order.PsnPartAmt,
  2474. AcctPay: order.AcctPay,
  2475. PsnCashpay: order.PsnCashPay,
  2476. HiPaymtd: "1",
  2477. Hsorg: his.InsuplcAdmdvs,
  2478. HsorgOpter: his.InsuplcAdmdvs,
  2479. MedinsFillPsn: curRoles.UserName,
  2480. MedinsFillDept: depart.Name,
  2481. IptMedType: "2",
  2482. }
  2483. struct4101.SetlBegnDate = order.SetlTime
  2484. struct4101.SetlEndDate = order.SetlTime
  2485. //if order.SettleType == 1 {
  2486. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2487. // dateStr := t.Format("2006-01-02")
  2488. // struct4101.SetlBegnDate = dateStr
  2489. // struct4101.SetlEndDate = dateStr
  2490. //} else {
  2491. // t := time.Unix(int64(order.SettleStartTime), 0)
  2492. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2493. // dateStartStr := t.Format("2006-01-02")
  2494. // dateEndStr := t2.Format("2006-01-02")
  2495. // struct4101.SetlBegnDate = dateStartStr
  2496. // struct4101.SetlEndDate = dateEndStr
  2497. //}
  2498. var rf []CustomFundPay
  2499. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2500. var tempFunPays []service.CustomStruct
  2501. var tempFunPay610100 service.CustomStruct
  2502. for _, item := range rf {
  2503. if item.FundPayType == "610100" {
  2504. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2505. tempFunPay610100.FundPayType = item.FundPayType
  2506. } else {
  2507. var tempFunPay service.CustomStruct
  2508. tempFunPay.FundPayamt = item.FundPayamt
  2509. tempFunPay.FundPayType = item.FundPayType
  2510. tempFunPays = append(tempFunPays, tempFunPay)
  2511. }
  2512. }
  2513. tempFunPays = append(tempFunPays, tempFunPay610100)
  2514. struct4101.CustomStruct = tempFunPays
  2515. var tempDiaginfos []service.DiaginfoStructTwo
  2516. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2517. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2518. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2519. var config []*models.HisXtDiagnoseConfig
  2520. for _, item := range diagnosis_ids {
  2521. id, _ := strconv.ParseInt(item, 10, 64)
  2522. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2523. config = append(config, &diagnosisConfig)
  2524. }
  2525. for index, item := range config {
  2526. if index == 0 {
  2527. var tempDiaginfo service.DiaginfoStructTwo
  2528. tempDiaginfo.DiagCode = item.CountryCode
  2529. tempDiaginfo.DiagName = item.CountryContentName
  2530. tempDiaginfo.DiagType = "1"
  2531. tempDiaginfo.MaindiagFlag = "1"
  2532. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2533. } else {
  2534. var tempDiaginfo service.DiaginfoStructTwo
  2535. tempDiaginfo.DiagCode = item.CountryCode
  2536. tempDiaginfo.DiagName = item.CountryContentName
  2537. tempDiaginfo.DiagType = "2"
  2538. tempDiaginfo.MaindiagFlag = "0"
  2539. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2540. }
  2541. }
  2542. struct4101.Diseinfo = tempDiaginfos
  2543. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2544. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2545. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2546. tempOpspdiseinfo2.OprnOprtCode = ""
  2547. tempOpspdiseinfo2.OprnOprtName = ""
  2548. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2549. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2550. var iteminfo service.IteminfoStruct
  2551. var bedCostTotal float64 = 0 //床位总费
  2552. var bedCostSelfTotal float64 = 0 //床位自费
  2553. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2554. var examineCostTotal float64 = 0 //诊查总费
  2555. var examineCostSelfTotal float64 = 0 //诊查自费
  2556. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2557. var nursingCostTotal float64 = 0 //护理总费
  2558. var nursingCostSelfTotal float64 = 0 //护理自费
  2559. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2560. var chineseMedicineCostTotal float64 = 0 //中成药
  2561. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2562. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2563. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2564. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2565. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2566. var registerCostTotal float64 = 0 //一般诊疗费
  2567. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2568. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2569. var operationCostTotal float64 = 0 //手术费
  2570. var operationCostSelfTotal float64 = 0 //手术费
  2571. var operationCostPartSelfTotal float64 = 0 //手术费
  2572. var otherCostTotal float64 = 0 //其他费用
  2573. var otherCostSelfTotal float64 = 0 //其他费用
  2574. var otherCostPartSelfTotal float64 = 0 //其他费用
  2575. var materialCostTotal float64 = 0 //材料费
  2576. var materialCostSelfTotal float64 = 0 //材料费
  2577. var materialCostPartSelfTotal float64 = 0 //材料费
  2578. var westernMedicineCostTotal float64 = 0 //西药费
  2579. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2580. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2581. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2582. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2583. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2584. var checkCostTotal float64 = 0 //检查费
  2585. var checkCostSelfTotal float64 = 0 //检查费
  2586. var checkCostPartSelfTotal float64 = 0 //检查费
  2587. var laboratoryCostTotal float64 = 0 //化验费
  2588. var laboratoryCostSelfTotal float64 = 0 //化验费
  2589. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2590. var treatCostTotal float64 = 0 //治疗费用
  2591. var treatCostSelfTotal float64 = 0 //治疗费用
  2592. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2593. decimal.DivisionPrecision = 2
  2594. var bed_fulamt_ownpay_amt float64 = 0
  2595. var examine_fulamt_ownpay_amt float64 = 0
  2596. var nursing_fulamt_ownpay_amt float64 = 0
  2597. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2598. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2599. var register_fulamt_ownpay_amt float64 = 0
  2600. var operation_fulamt_ownpay_amt float64 = 0
  2601. var other_fulamt_ownpay_amt float64 = 0
  2602. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2603. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2604. var check_fulamt_ownpay_amt float64 = 0
  2605. var material_fulamt_ownpay_amt float64 = 0
  2606. var laboratory_fulamt_ownpay_amt float64 = 0
  2607. var treat_fulamt_ownpay_amt float64 = 0
  2608. var bed_claa_sunmfee float64 = 0
  2609. var bed_clab_amt float64 = 0
  2610. var bed_other_amt float64 = 0
  2611. var examine_claa_sunmfee float64 = 0
  2612. var examine_clab_amt float64 = 0
  2613. var examine_other_amt float64 = 0
  2614. var nursing_claa_sunmfee float64 = 0
  2615. var nursing_clab_amt float64 = 0
  2616. var nursing_other_amt float64 = 0
  2617. var chinese_medicine_claa_sunmfee float64 = 0
  2618. var chinese_medicine_clab_amt float64 = 0
  2619. var chinese_medicine_other_amt float64 = 0
  2620. var commonly_treatment_claa_sunmfee float64 = 0
  2621. var commonly_treatment_clab_amt float64 = 0
  2622. var commonly_treatment_other_amt float64 = 0
  2623. var operation_claa_sunmfee float64 = 0
  2624. var operation_clab_amt float64 = 0
  2625. var operation_other_amt float64 = 0
  2626. var other_claa_sunmfee float64 = 0
  2627. var other_clab_amt float64 = 0
  2628. var other_other_amt float64 = 0
  2629. var westernMedicine_claa_sunmfee float64 = 0
  2630. var westernMedicine_clab_amt float64 = 0
  2631. var westernMedicine_other_amt float64 = 0
  2632. var chineseTraditional_claa_sunmfee float64 = 0
  2633. var chineseTraditional_clab_amt float64 = 0
  2634. var chineseTraditional_other_amt float64 = 0
  2635. var check_claa_sunmfee float64 = 0
  2636. var check_clab_amt float64 = 0
  2637. var check_other_amt float64 = 0
  2638. var material_claa_sunmfee float64 = 0
  2639. var material_clab_amt float64 = 0
  2640. var material_other_amt float64 = 0
  2641. var laboratory_claa_sunmfee float64 = 0
  2642. var laboratory_clab_amt float64 = 0
  2643. var laboratory_other_amt float64 = 0
  2644. var treat_claa_sunmfee float64 = 0
  2645. var treat_clab_amt float64 = 0
  2646. var treat_other_amt float64 = 0
  2647. var register_claa_sunmfee float64 = 0
  2648. var register_clab_amt float64 = 0
  2649. var register_other_amt float64 = 0
  2650. for _, item := range order.HisOrderInfo {
  2651. if item.MedChrgitmType == "01" { //床位费
  2652. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2653. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2654. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2655. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2656. if item.ChrgitmLv == "1" {
  2657. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2658. }
  2659. if item.ChrgitmLv == "2" {
  2660. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2661. }
  2662. if item.ChrgitmLv == "3" {
  2663. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2664. }
  2665. }
  2666. if item.MedChrgitmType == "02" { //诊查
  2667. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2668. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2669. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2670. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2671. if item.ChrgitmLv == "1" {
  2672. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2673. }
  2674. if item.ChrgitmLv == "2" {
  2675. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2676. }
  2677. if item.ChrgitmLv == "3" {
  2678. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2679. }
  2680. }
  2681. if item.MedChrgitmType == "03" { //检查费
  2682. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2683. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2684. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2685. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2686. if item.ChrgitmLv == "1" {
  2687. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2688. }
  2689. if item.ChrgitmLv == "2" {
  2690. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2691. }
  2692. if item.ChrgitmLv == "3" {
  2693. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2694. }
  2695. }
  2696. if item.MedChrgitmType == "04" { //化验费
  2697. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2698. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2699. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2700. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2701. if item.ChrgitmLv == "1" {
  2702. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2703. }
  2704. if item.ChrgitmLv == "2" {
  2705. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2706. }
  2707. if item.ChrgitmLv == "3" {
  2708. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2709. }
  2710. }
  2711. if item.MedChrgitmType == "05" { //治疗费
  2712. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2713. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2714. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2715. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2716. if item.ChrgitmLv == "1" {
  2717. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2718. }
  2719. if item.ChrgitmLv == "2" {
  2720. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2721. }
  2722. if item.ChrgitmLv == "3" {
  2723. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2724. }
  2725. }
  2726. if item.MedChrgitmType == "06" { //手术费
  2727. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2728. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2729. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2730. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2731. if item.ChrgitmLv == "1" {
  2732. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2733. }
  2734. if item.ChrgitmLv == "2" {
  2735. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2736. }
  2737. if item.ChrgitmLv == "3" {
  2738. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2739. }
  2740. }
  2741. if item.MedChrgitmType == "07" { //手术费
  2742. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2743. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2744. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2745. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2746. if item.ChrgitmLv == "1" {
  2747. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2748. }
  2749. if item.ChrgitmLv == "2" {
  2750. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2751. }
  2752. if item.ChrgitmLv == "3" {
  2753. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2754. }
  2755. }
  2756. if item.MedChrgitmType == "08" { //材料费
  2757. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2758. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2759. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2760. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2761. if item.ChrgitmLv == "1" {
  2762. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2763. }
  2764. if item.ChrgitmLv == "2" {
  2765. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2766. }
  2767. if item.ChrgitmLv == "3" {
  2768. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2769. }
  2770. }
  2771. if item.MedChrgitmType == "09" { //西药费
  2772. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2773. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2774. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2775. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2776. if item.ChrgitmLv == "1" {
  2777. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2778. }
  2779. if item.ChrgitmLv == "2" {
  2780. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2781. }
  2782. if item.ChrgitmLv == "3" {
  2783. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2784. }
  2785. }
  2786. if item.MedChrgitmType == "10" { //中药饮片
  2787. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2788. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2789. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2790. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2791. if item.ChrgitmLv == "1" {
  2792. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2793. }
  2794. if item.ChrgitmLv == "2" {
  2795. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2796. }
  2797. if item.ChrgitmLv == "3" {
  2798. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2799. }
  2800. }
  2801. if item.MedChrgitmType == "11" { //中成费
  2802. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2803. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2804. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2805. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2806. if item.ChrgitmLv == "1" {
  2807. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2808. }
  2809. if item.ChrgitmLv == "2" {
  2810. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2811. }
  2812. if item.ChrgitmLv == "3" {
  2813. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2814. }
  2815. }
  2816. if item.MedChrgitmType == "12" { //中成费
  2817. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2818. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2819. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2820. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2821. if item.ChrgitmLv == "1" {
  2822. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2823. }
  2824. if item.ChrgitmLv == "2" {
  2825. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2826. }
  2827. if item.ChrgitmLv == "3" {
  2828. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2829. }
  2830. }
  2831. if item.MedChrgitmType == "13" { //中成费
  2832. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2833. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2834. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2835. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2836. if item.ChrgitmLv == "1" {
  2837. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2838. }
  2839. if item.ChrgitmLv == "2" {
  2840. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2841. }
  2842. if item.ChrgitmLv == "3" {
  2843. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2844. }
  2845. }
  2846. if item.MedChrgitmType == "14" { //其他费
  2847. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2848. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2849. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2850. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2851. if item.ChrgitmLv == "1" {
  2852. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2853. }
  2854. if item.ChrgitmLv == "2" {
  2855. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2856. }
  2857. if item.ChrgitmLv == "3" {
  2858. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2859. }
  2860. }
  2861. }
  2862. var iteminfoStructs []service.IteminfoStruct
  2863. if bedCostTotal != 0 {
  2864. iteminfo.MedChrgitm = "01"
  2865. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2866. iteminfo.Amt = bedCostTotal
  2867. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2868. iteminfo.ClabAmt = bed_clab_amt
  2869. iteminfo.OthAmt = bed_other_amt
  2870. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2871. }
  2872. if examineCostTotal != 0 {
  2873. iteminfo.MedChrgitm = "02"
  2874. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2875. iteminfo.Amt = examineCostTotal
  2876. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2877. iteminfo.ClabAmt = examine_clab_amt
  2878. iteminfo.OthAmt = examine_other_amt
  2879. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2880. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2881. }
  2882. if checkCostTotal != 0 {
  2883. iteminfo.MedChrgitm = "03"
  2884. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2885. iteminfo.Amt = checkCostTotal
  2886. iteminfo.ClaaSumfee = check_claa_sunmfee
  2887. iteminfo.ClabAmt = check_clab_amt
  2888. iteminfo.OthAmt = check_other_amt
  2889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2890. }
  2891. if laboratoryCostTotal != 0 {
  2892. iteminfo.MedChrgitm = "04"
  2893. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2894. iteminfo.Amt = laboratoryCostTotal
  2895. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2896. iteminfo.ClabAmt = laboratory_clab_amt
  2897. iteminfo.OthAmt = laboratory_other_amt
  2898. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2899. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2900. }
  2901. if treatCostTotal != 0 {
  2902. iteminfo.MedChrgitm = "05"
  2903. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2904. iteminfo.Amt = treatCostTotal
  2905. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2906. iteminfo.ClabAmt = treat_clab_amt
  2907. iteminfo.OthAmt = treat_other_amt
  2908. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2909. //(struct4101.IteminfoStruct, iteminfo)
  2910. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2911. }
  2912. if operationCostTotal != 0 {
  2913. iteminfo.MedChrgitm = "06"
  2914. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2915. iteminfo.Amt = operationCostTotal
  2916. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2917. iteminfo.ClabAmt = operation_clab_amt
  2918. iteminfo.OthAmt = operation_other_amt
  2919. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2920. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2921. }
  2922. if nursingCostTotal != 0 {
  2923. iteminfo.MedChrgitm = "07"
  2924. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2925. iteminfo.Amt = nursingCostTotal
  2926. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2927. iteminfo.ClabAmt = nursing_clab_amt
  2928. iteminfo.OthAmt = nursing_other_amt
  2929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2930. }
  2931. if materialCostTotal != 0 {
  2932. iteminfo.MedChrgitm = "08"
  2933. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2934. iteminfo.Amt = materialCostTotal
  2935. iteminfo.ClaaSumfee = material_claa_sunmfee
  2936. iteminfo.ClabAmt = material_clab_amt
  2937. iteminfo.OthAmt = material_other_amt
  2938. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2939. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2940. }
  2941. if westernMedicineCostTotal != 0 {
  2942. iteminfo.MedChrgitm = "09"
  2943. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2944. iteminfo.Amt = westernMedicineCostTotal
  2945. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2946. iteminfo.ClabAmt = westernMedicine_clab_amt
  2947. iteminfo.OthAmt = westernMedicine_other_amt
  2948. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2949. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2950. }
  2951. if chineseMedicineCostTotal != 0 {
  2952. iteminfo.MedChrgitm = "10"
  2953. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2954. iteminfo.Amt = chineseMedicineCostTotal
  2955. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2956. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2957. iteminfo.OthAmt = chinese_medicine_other_amt
  2958. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2959. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2960. }
  2961. if chineseTraditionalMedicineCostTotal != 0 {
  2962. iteminfo.MedChrgitm = "11"
  2963. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2964. iteminfo.Amt = westernMedicineCostTotal
  2965. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2966. iteminfo.ClabAmt = westernMedicine_clab_amt
  2967. iteminfo.OthAmt = westernMedicine_other_amt
  2968. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2969. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2970. }
  2971. if commonlyTreatmentCostTotal != 0 {
  2972. iteminfo.MedChrgitm = "12"
  2973. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2974. iteminfo.Amt = commonlyTreatmentCostTotal
  2975. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2976. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2977. iteminfo.OthAmt = commonly_treatment_other_amt
  2978. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2979. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2980. }
  2981. if registerCostTotal != 0 {
  2982. iteminfo.MedChrgitm = "13"
  2983. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2984. iteminfo.Amt = registerCostTotal
  2985. iteminfo.ClaaSumfee = register_claa_sunmfee
  2986. iteminfo.ClabAmt = register_clab_amt
  2987. iteminfo.OthAmt = register_other_amt
  2988. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2989. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2990. }
  2991. if otherCostTotal != 0 {
  2992. iteminfo.MedChrgitm = "14"
  2993. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2994. iteminfo.Amt = otherCostTotal
  2995. iteminfo.ClaaSumfee = other_claa_sunmfee
  2996. iteminfo.ClabAmt = other_clab_amt
  2997. iteminfo.OthAmt = other_other_amt
  2998. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2999. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3000. }
  3001. struct4101.IteminfoStruct = iteminfoStructs
  3002. struct4101.Ntly = "中国"
  3003. struct4101.AdmCaty = "A03.06"
  3004. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3005. fmt.Println(result)
  3006. var dat map[string]interface{}
  3007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3008. fmt.Println(dat)
  3009. } else {
  3010. fmt.Println(err)
  3011. }
  3012. userJSONBytes, _ := json.Marshal(dat)
  3013. var res ResultSeventeen
  3014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3015. utils.ErrorLog("解析失败:%v", err)
  3016. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3017. adminUser := c.GetAdminUserInfo()
  3018. errlog := &models.HisOrderError{
  3019. UserOrgId: adminUser.CurrentOrgId,
  3020. Ctime: time.Now().Unix(),
  3021. Mtime: time.Now().Unix(),
  3022. ErrMsg: res.ErrMsg + "解析失败",
  3023. Status: 1,
  3024. PatientId: order_id,
  3025. Stage: 10106,
  3026. }
  3027. service.CreateErrMsgLog(errlog)
  3028. continue
  3029. }
  3030. if res.Infcode != 0 {
  3031. adminUser := c.GetAdminUserInfo()
  3032. errlog := &models.HisOrderError{
  3033. UserOrgId: adminUser.CurrentOrgId,
  3034. Ctime: time.Now().Unix(),
  3035. Mtime: time.Now().Unix(),
  3036. ErrMsg: res.ErrMsg,
  3037. Status: 1,
  3038. PatientId: order_id,
  3039. Stage: 10106,
  3040. }
  3041. service.CreateErrMsgLog(errlog)
  3042. continue
  3043. } else {
  3044. hisFundSettleListResult := &models.HisFundSettleListResult{
  3045. Number: res.Output.SetlListId,
  3046. Status: 1,
  3047. Ctime: time.Now().Unix(),
  3048. Mtime: time.Now().Unix(),
  3049. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3050. IsUpload: 1,
  3051. OrderId: order_id,
  3052. }
  3053. service.CreateUploadRecord(hisFundSettleListResult)
  3054. continue
  3055. }
  3056. }
  3057. }
  3058. func (c *HisApiController) GetOrgInfo() {
  3059. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3060. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3061. }
  3062. func (c *HisApiController) GetHisPatientInfo() {
  3063. medical_insurance_card := c.GetString("medical_insurance_card")
  3064. id_card_type, _ := c.GetInt64("id_card_type")
  3065. id_card := c.GetString("id_card")
  3066. adminInfo := c.GetAdminUserInfo()
  3067. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3068. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3069. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3070. IdCardNo := ""
  3071. if id_card_type == 1 {
  3072. IdCardNo = medical_insurance_card
  3073. } else if id_card_type == 2 {
  3074. IdCardNo = id_card
  3075. }
  3076. if config.IsOpen == 1 {
  3077. 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
  3078. resp, requestErr := http.Get(api)
  3079. if requestErr != nil {
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return
  3082. }
  3083. defer resp.Body.Close()
  3084. body, ioErr := ioutil.ReadAll(resp.Body)
  3085. if ioErr != nil {
  3086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3088. return
  3089. }
  3090. var respJSON map[string]interface{}
  3091. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3094. return
  3095. }
  3096. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3097. userJSONBytes, _ := json.Marshal(userJSON)
  3098. var res ResultTwo
  3099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3100. utils.ErrorLog("解析失败:%v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3105. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3106. infoStr := string(Iinfos)
  3107. idetinfoStr := string(Idetinfos)
  3108. if res.Infcode == 0 {
  3109. his := models.VMHisPatient{
  3110. Status: 1,
  3111. Ctime: time.Now().Unix(),
  3112. Mtime: time.Now().Unix(),
  3113. PsnNo: res.Output.Baseinfo.PsnNo,
  3114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3115. Certno: res.Output.Baseinfo.Certno,
  3116. PsnName: res.Output.Baseinfo.PsnName,
  3117. Gend: res.Output.Baseinfo.Gend,
  3118. Naty: res.Output.Baseinfo.Naty,
  3119. Brdy: res.Output.Baseinfo.Brdy,
  3120. Age: res.Output.Baseinfo.Age,
  3121. Iinfo: infoStr,
  3122. Idetinfo: idetinfoStr,
  3123. UserOrgId: adminInfo.CurrentOrgId,
  3124. IsReturn: 1,
  3125. IdCardType: id_card_type,
  3126. }
  3127. c.ServeSuccessJSON(map[string]interface{}{
  3128. "info": his,
  3129. })
  3130. } else {
  3131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3132. return
  3133. }
  3134. }
  3135. }
  3136. //func GetBasBaseInfo() (jsonStr string, err error) {
  3137. //
  3138. // handle := syscall.NewLazyDLL("SSCard.dll")
  3139. // add := handle.NewProc("ReadCardBas")
  3140. // str := make([]byte, 1024)
  3141. // str1 := make([]byte, 1024)
  3142. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3143. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3144. //
  3145. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3146. //
  3147. // fmt.Println("> Add(4,5)的结果为:", ret)
  3148. // handle.Release()
  3149. //
  3150. // return "", nil
  3151. //
  3152. //}
  3153. //func GetQRBaseInfo() (jsonStr string, err error) {
  3154. // handle := syscall.LoadDLL("SSCard.dll")
  3155. // ReadCardBas := handle.FindProc("GetQRBase")
  3156. //
  3157. // str := make([]byte, 256)
  3158. // str1 := make([]byte, 256)
  3159. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3160. //
  3161. // fmt.Println(string(str))
  3162. // fmt.Println(r)
  3163. // return string(str), nil
  3164. //}
  3165. //func CardInit() int {
  3166. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3167. // add := DllTestDef.MustFindProc("Init")
  3168. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3169. // if err != nil {
  3170. // fmt.Println("SSCard的运算结果为:", ret)
  3171. // }
  3172. // result := int(ret)
  3173. // return result
  3174. //}
  3175. //func CardInit() int {
  3176. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3177. // if err != nil {
  3178. // fmt.Println("SSCard的运算结果为:", ret)
  3179. // }
  3180. // fmt.Println(err)
  3181. // result := int(ret)
  3182. // return result
  3183. //}
  3184. func IntPtr(n int) uintptr {
  3185. return uintptr(n)
  3186. }
  3187. func StrPtr(s string) uintptr {
  3188. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3189. }
  3190. type Result2001 struct {
  3191. Cainfo interface{} `json:"cainfo"`
  3192. ErrMsg string `json:"err_msg"`
  3193. InfRefmsgid string `json:"inf_refmsgid"`
  3194. Infcode int64 `json:"infcode"`
  3195. Output struct {
  3196. Trtinfo struct {
  3197. PsnNo string `json:"psn_no"`
  3198. TrtChkType string `json:"trt_chk_type"`
  3199. FundPayType string `json:"fund_pay_type"`
  3200. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3201. Begndate string `json:"begndate"`
  3202. Enddate string `json:"enddate"`
  3203. TrtChkRslt string `json:"trt_chk_rslt"`
  3204. } `json:"trtinfo"`
  3205. } `json:"output"`
  3206. RefmsgTime string `json:"refmsg_time"`
  3207. RespondTime string `json:"respond_time"`
  3208. Signtype interface{} `json:"signtype"`
  3209. WarnMsg interface{} `json:"warn_msg"`
  3210. }
  3211. type Result2001Org10265 struct {
  3212. Cainfo interface{} `json:"cainfo"`
  3213. ErrMsg string `json:"err_msg"`
  3214. InfRefmsgid string `json:"inf_refmsgid"`
  3215. Infcode string `json:"infcode"`
  3216. Output struct {
  3217. Trtinfo struct {
  3218. PsnNo string `json:"psn_no"`
  3219. TrtChkType string `json:"trt_chk_type"`
  3220. FundPayType string `json:"fund_pay_type"`
  3221. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3222. Begndate string `json:"begndate"`
  3223. Enddate string `json:"enddate"`
  3224. TrtChkRslt string `json:"trt_chk_rslt"`
  3225. } `json:"trtinfo"`
  3226. } `json:"output"`
  3227. RefmsgTime string `json:"refmsg_time"`
  3228. RespondTime string `json:"respond_time"`
  3229. Signtype interface{} `json:"signtype"`
  3230. WarnMsg interface{} `json:"warn_msg"`
  3231. }
  3232. type ResultTwo struct {
  3233. ErrMsg string `json:"err_msg"`
  3234. InfRefmsgid string `json:"inf_refmsgid"`
  3235. Infcode int64 `json:"infcode"`
  3236. Output struct {
  3237. Baseinfo struct {
  3238. Age float64 `json:"age"`
  3239. Brdy string `json:"brdy"`
  3240. Certno string `json:"certno"`
  3241. Gend string `json:"gend"`
  3242. Naty string `json:"naty"`
  3243. PsnCertType string `json:"psn_cert_type"`
  3244. PsnName string `json:"psn_name"`
  3245. PsnNo string `json:"psn_no"`
  3246. } `json:"baseinfo"`
  3247. Idetinfo []interface{} `json:"idetinfo"`
  3248. Iinfo []struct {
  3249. Balc float64 `json:"balc"`
  3250. CvlservFlag string `json:"cvlserv_flag"`
  3251. EmpName string `json:"emp_name"`
  3252. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3253. Insutype string `json:"insutype"`
  3254. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3255. PausInsuDate string `json:"paus_insu_date"`
  3256. PsnInsuDate string `json:"psn_insu_date"`
  3257. PsnInsuStas string `json:"psn_insu_stas"`
  3258. PsnType string `json:"psn_type"`
  3259. } `json:"insuinfo"`
  3260. } `json:"output"`
  3261. RefmsgTime string `json:"refmsg_time"`
  3262. RespondTime string `json:"respond_time"`
  3263. Signtype interface{} `json:"signtype"`
  3264. WarnInfo interface{} `json:"warn_info"`
  3265. }
  3266. type ResultTwo10265 struct {
  3267. ErrMsg string `json:"err_msg"`
  3268. InfRefmsgid string `json:"inf_refmsgid"`
  3269. Infcode string `json:"infcode"`
  3270. Output struct {
  3271. Baseinfo struct {
  3272. Age float64 `json:"age"`
  3273. Brdy string `json:"brdy"`
  3274. Certno string `json:"certno"`
  3275. Gend string `json:"gend"`
  3276. Naty string `json:"naty"`
  3277. PsnCertType string `json:"psn_cert_type"`
  3278. PsnName string `json:"psn_name"`
  3279. PsnNo string `json:"psn_no"`
  3280. } `json:"baseinfo"`
  3281. Idetinfo []interface{} `json:"idetinfo"`
  3282. Iinfo []struct {
  3283. Balc float64 `json:"balc"`
  3284. CvlservFlag string `json:"cvlserv_flag"`
  3285. EmpName string `json:"emp_name"`
  3286. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3287. Insutype string `json:"insutype"`
  3288. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3289. PausInsuDate string `json:"paus_insu_date"`
  3290. PsnInsuDate string `json:"psn_insu_date"`
  3291. PsnInsuStas string `json:"psn_insu_stas"`
  3292. PsnType string `json:"psn_type"`
  3293. } `json:"insuinfo"`
  3294. } `json:"output"`
  3295. RefmsgTime string `json:"refmsg_time"`
  3296. RespondTime string `json:"respond_time"`
  3297. Signtype interface{} `json:"signtype"`
  3298. WarnInfo interface{} `json:"warn_info"`
  3299. }
  3300. type ResultThree struct {
  3301. Cainfo interface{} `json:"cainfo"`
  3302. ErrMsg string `json:"err_msg"`
  3303. InfRefmsgid string `json:"inf_refmsgid"`
  3304. Infcode int64 `json:"infcode"`
  3305. Output struct {
  3306. Data struct {
  3307. IptOtpNo string `json:"ipt_otp_no"`
  3308. MdtrtID string `json:"mdtrt_id"`
  3309. PsnNo string `json:"psn_no"`
  3310. } `json:"data"`
  3311. } `json:"output"`
  3312. RefmsgTime string `json:"refmsg_time"`
  3313. RespondTime string `json:"respond_time"`
  3314. Signtype interface{} `json:"signtype"`
  3315. WarnMsg interface{} `json:"warn_msg"`
  3316. }
  3317. type ResultThree10265 struct {
  3318. Cainfo interface{} `json:"cainfo"`
  3319. ErrMsg string `json:"err_msg"`
  3320. InfRefmsgid string `json:"inf_refmsgid"`
  3321. Infcode string `json:"infcode"`
  3322. Output struct {
  3323. Data struct {
  3324. IptOtpNo string `json:"ipt_otp_no"`
  3325. MdtrtID string `json:"mdtrt_id"`
  3326. PsnNo string `json:"psn_no"`
  3327. } `json:"data"`
  3328. } `json:"output"`
  3329. RefmsgTime string `json:"refmsg_time"`
  3330. RespondTime string `json:"respond_time"`
  3331. Signtype interface{} `json:"signtype"`
  3332. WarnMsg interface{} `json:"warn_msg"`
  3333. }
  3334. type ResultFour struct {
  3335. Cainfo string `json:"cainfo"`
  3336. ErrMsg string `json:"err_msg"`
  3337. InfRefmsgid string `json:"inf_refmsgid"`
  3338. Infcode int64 `json:"infcode"`
  3339. Output struct {
  3340. Result []struct {
  3341. BasMednFlag string `json:"bas_medn_flag"`
  3342. ChldMedcFlag string `json:"chld_medc_flag"`
  3343. ChrgitmLv string `json:"chrgitm_lv"`
  3344. Cnt float64 `json:"cnt"`
  3345. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3346. DrtReimFlag string `json:"drt_reim_flag"`
  3347. FeedetlSn string `json:"feedetl_sn"`
  3348. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3349. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3350. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3351. ListSpItemFlag string `json:"list_sp_item_flag"`
  3352. LmtUsedFlag string `json:"lmt_used_flag"`
  3353. MedChrgitmType string `json:"med_chrgitm_type"`
  3354. Memo string `json:"memo"`
  3355. OverlmtAmt float64 `json:"overlmt_amt"`
  3356. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3357. Pric float64 `json:"pric"`
  3358. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3359. SelfpayProp float64 `json:"selfpay_prop"`
  3360. } `json:"result"`
  3361. } `json:"output"`
  3362. RefmsgTime string `json:"refmsg_time"`
  3363. RespondTime string `json:"respond_time"`
  3364. Signtype string `json:"signtype"`
  3365. WarnMsg string `json:"warn_msg"`
  3366. }
  3367. type ResultFour10265 struct {
  3368. Cainfo string `json:"cainfo"`
  3369. ErrMsg string `json:"err_msg"`
  3370. InfRefmsgid string `json:"inf_refmsgid"`
  3371. Infcode string `json:"infcode"`
  3372. Output struct {
  3373. Result []struct {
  3374. BasMednFlag string `json:"bas_medn_flag"`
  3375. ChldMedcFlag string `json:"chld_medc_flag"`
  3376. ChrgitmLv string `json:"chrgitm_lv"`
  3377. Cnt float64 `json:"cnt"`
  3378. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3379. DrtReimFlag string `json:"drt_reim_flag"`
  3380. FeedetlSn string `json:"feedetl_sn"`
  3381. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3382. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3383. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3384. ListSpItemFlag string `json:"list_sp_item_flag"`
  3385. LmtUsedFlag string `json:"lmt_used_flag"`
  3386. MedChrgitmType string `json:"med_chrgitm_type"`
  3387. Memo string `json:"memo"`
  3388. OverlmtAmt float64 `json:"overlmt_amt"`
  3389. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3390. Pric float64 `json:"pric"`
  3391. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3392. SelfpayProp float64 `json:"selfpay_prop"`
  3393. } `json:"result"`
  3394. } `json:"output"`
  3395. RefmsgTime string `json:"refmsg_time"`
  3396. RespondTime string `json:"respond_time"`
  3397. Signtype string `json:"signtype"`
  3398. WarnMsg string `json:"warn_msg"`
  3399. }
  3400. type ResultFive struct {
  3401. Balc float64 `json:"balc"`
  3402. CvlservFlag string `json:"cvlserv_flag"`
  3403. EmpName string `json:"emp_name"`
  3404. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3405. Insutype string `json:"insutype"`
  3406. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3407. PausInsuDate string `json:"paus_insu_date"`
  3408. PsnInsuDate string `json:"psn_insu_date"`
  3409. PsnInsuStas string `json:"psn_insu_stas"`
  3410. PsnType string `json:"psn_type"`
  3411. }
  3412. type ResultSix struct {
  3413. Cainfo interface{} `json:"cainfo"`
  3414. ErrMsg string `json:"err_msg"`
  3415. InfRefmsgid string `json:"inf_refmsgid"`
  3416. Infcode int64 `json:"infcode"`
  3417. Output struct {
  3418. } `json:"output"`
  3419. RefmsgTime string `json:"refmsg_time"`
  3420. RespondTime string `json:"respond_time"`
  3421. Signtype interface{} `json:"signtype"`
  3422. WarnMsg interface{} `json:"warn_msg"`
  3423. }
  3424. type ResultSix10265 struct {
  3425. Cainfo interface{} `json:"cainfo"`
  3426. ErrMsg string `json:"err_msg"`
  3427. InfRefmsgid string `json:"inf_refmsgid"`
  3428. Infcode string `json:"infcode"`
  3429. Output struct {
  3430. } `json:"output"`
  3431. RefmsgTime string `json:"refmsg_time"`
  3432. RespondTime string `json:"respond_time"`
  3433. Signtype interface{} `json:"signtype"`
  3434. WarnMsg interface{} `json:"warn_msg"`
  3435. }
  3436. type ResultSeven struct {
  3437. Cainfo string `json:"cainfo"`
  3438. ErrMsg string `json:"err_msg"`
  3439. InfRefmsgid string `json:"inf_refmsgid"`
  3440. Infcode int64 `json:"infcode"`
  3441. Output struct {
  3442. Setldetail []interface{} `json:"setldetail"`
  3443. Setlinfo struct {
  3444. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3445. AcctPay float64 `json:"acct_pay"`
  3446. ActPayDedc float64 `json:"act_pay_dedc"`
  3447. Age float64 `json:"age"`
  3448. Balc float64 `json:"balc"`
  3449. Brdy string `json:"brdy"`
  3450. Certno string `json:"certno"`
  3451. ClrOptins string `json:"clr_optins"`
  3452. ClrType string `json:"clr_type"`
  3453. ClrWay string `json:"clr_way"`
  3454. CvlservFlag string `json:"cvlserv_flag"`
  3455. CvlservPay float64 `json:"cvlserv_pay"`
  3456. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3457. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3458. Gend string `json:"gend"`
  3459. HifesPay float64 `json:"hifes_pay"`
  3460. HifmiPay float64 `json:"hifmi_pay"`
  3461. HifpPay float64 `json:"hifp_pay"`
  3462. HospPartAmt float64 `json:"hosp_part_amt"`
  3463. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3464. Insutype string `json:"insutype"`
  3465. MafPay float64 `json:"maf_pay"`
  3466. MdtrtCertType string `json:"mdtrt_cert_type"`
  3467. HifobPay float64 `json:"hifob_pay"`
  3468. MdtrtID string `json:"mdtrt_id"`
  3469. MedType string `json:"med_type"`
  3470. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3471. MedinsSetlID string `json:"medins_setl_id"`
  3472. Naty string `json:"naty"`
  3473. OthPay float64 `json:"oth_pay"`
  3474. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3475. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3476. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3477. PsnCashPay float64 `json:"psn_cash_pay"`
  3478. PsnCertType string `json:"psn_cert_type"`
  3479. PsnName string `json:"psn_name"`
  3480. PsnNo string `json:"psn_no"`
  3481. PsnPartAmt float64 `json:"psn_part_amt"`
  3482. PsnType string `json:"psn_type"`
  3483. SetlID string `json:"setl_id"`
  3484. SetlTime string `json:"setl_time"`
  3485. } `json:"setlinfo"`
  3486. } `json:"output"`
  3487. RefmsgTime string `json:"refmsg_time"`
  3488. RespondTime string `json:"respond_time"`
  3489. Signtype interface{} `json:"signtype"`
  3490. WarnMsg interface{} `json:"warn_msg"`
  3491. }
  3492. type ResultSeven10265 struct {
  3493. Cainfo string `json:"cainfo"`
  3494. ErrMsg string `json:"err_msg"`
  3495. InfRefmsgid string `json:"inf_refmsgid"`
  3496. Infcode string `json:"infcode"`
  3497. Output struct {
  3498. Setldetail []interface{} `json:"setldetail"`
  3499. Setlinfo struct {
  3500. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3501. AcctPay float64 `json:"acct_pay"`
  3502. ActPayDedc float64 `json:"act_pay_dedc"`
  3503. Age float64 `json:"age"`
  3504. Balc float64 `json:"balc"`
  3505. Brdy string `json:"brdy"`
  3506. Certno string `json:"certno"`
  3507. ClrOptins string `json:"clr_optins"`
  3508. ClrType string `json:"clr_type"`
  3509. ClrWay string `json:"clr_way"`
  3510. CvlservFlag string `json:"cvlserv_flag"`
  3511. CvlservPay float64 `json:"cvlserv_pay"`
  3512. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3513. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3514. Gend string `json:"gend"`
  3515. HifesPay float64 `json:"hifes_pay"`
  3516. HifmiPay float64 `json:"hifmi_pay"`
  3517. HifpPay float64 `json:"hifp_pay"`
  3518. HospPartAmt float64 `json:"hosp_part_amt"`
  3519. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3520. Insutype string `json:"insutype"`
  3521. MafPay float64 `json:"maf_pay"`
  3522. MdtrtCertType string `json:"mdtrt_cert_type"`
  3523. HifobPay float64 `json:"hifob_pay"`
  3524. MdtrtID string `json:"mdtrt_id"`
  3525. MedType string `json:"med_type"`
  3526. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3527. MedinsSetlID string `json:"medins_setl_id"`
  3528. Naty string `json:"naty"`
  3529. OthPay float64 `json:"oth_pay"`
  3530. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3531. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3532. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3533. PsnCashPay float64 `json:"psn_cash_pay"`
  3534. PsnCertType string `json:"psn_cert_type"`
  3535. PsnName string `json:"psn_name"`
  3536. PsnNo string `json:"psn_no"`
  3537. PsnPartAmt float64 `json:"psn_part_amt"`
  3538. PsnType string `json:"psn_type"`
  3539. SetlID string `json:"setl_id"`
  3540. SetlTime string `json:"setl_time"`
  3541. } `json:"setlinfo"`
  3542. } `json:"output"`
  3543. RefmsgTime string `json:"refmsg_time"`
  3544. RespondTime string `json:"respond_time"`
  3545. Signtype interface{} `json:"signtype"`
  3546. WarnMsg interface{} `json:"warn_msg"`
  3547. }
  3548. type ResultEight struct {
  3549. Cainfo string `json:"cainfo"`
  3550. ErrMsg string `json:"err_msg"`
  3551. InfRefmsgid string `json:"inf_refmsgid"`
  3552. Infcode int64 `json:"infcode"`
  3553. Output struct {
  3554. Stmtinfo struct {
  3555. SetlOptins string `json:"setl_optins"`
  3556. StmtRslt string `json:"stmt_rslt"`
  3557. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3558. } `json:"stmtinfo"`
  3559. } `json:"output"`
  3560. RefmsgTime string `json:"refmsg_time"`
  3561. RespondTime string `json:"respond_time"`
  3562. Signtype interface{} `json:"signtype"`
  3563. WarnMsg interface{} `json:"warn_msg"`
  3564. }
  3565. type ResultEightFor10188 struct {
  3566. Cainfo string `json:"cainfo"`
  3567. ErrMsg string `json:"err_msg"`
  3568. InfRefmsgid string `json:"inf_refmsgid"`
  3569. Infcode string `json:"infcode"`
  3570. Output struct {
  3571. Stmtinfo struct {
  3572. SetlOptins string `json:"setl_optins"`
  3573. StmtRslt string `json:"stmt_rslt"`
  3574. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3575. } `json:"stmtinfo"`
  3576. } `json:"output"`
  3577. RefmsgTime string `json:"refmsg_time"`
  3578. RespondTime string `json:"respond_time"`
  3579. Signtype interface{} `json:"signtype"`
  3580. WarnMsg interface{} `json:"warn_msg"`
  3581. }
  3582. type ResultNine struct {
  3583. Cainfo string `json:"cainfo"`
  3584. ErrMsg string `json:"err_msg"`
  3585. InfRefmsgid string `json:"inf_refmsgid"`
  3586. Infcode int64 `json:"infcode"`
  3587. Output struct {
  3588. FileQuryNo string `json:"file_qury_no"`
  3589. } `json:"output"`
  3590. RefmsgTime string `json:"refmsg_time"`
  3591. RespondTime string `json:"respond_time"`
  3592. Signtype interface{} `json:"signtype"`
  3593. WarnMsg interface{} `json:"warn_msg"`
  3594. }
  3595. type ResultTen struct {
  3596. Cainfo string `json:"cainfo"`
  3597. ErrMsg string `json:"err_msg"`
  3598. InfRefmsgid string `json:"inf_refmsgid"`
  3599. Infcode int64 `json:"infcode"`
  3600. Output struct {
  3601. DldEndtime string `json:"dld_endtime"`
  3602. FileQuryNo string `json:"file_qury_no"`
  3603. Filename string `json:"filename"`
  3604. } `json:"output"`
  3605. RefmsgTime string `json:"refmsg_time"`
  3606. RespondTime string `json:"respond_time"`
  3607. Signtype interface{} `json:"signtype"`
  3608. WarnMsg interface{} `json:"warn_msg"`
  3609. }
  3610. //type Autogenerated struct {
  3611. // Output struct {
  3612. // Setlinfo struct {
  3613. // SetlTime string `json:"setl_time"`
  3614. // CvlservPay float64 `json:"cvlserv_pay"`
  3615. // Year string `json:"year"`
  3616. // MedType string `json:"med_type"`
  3617. // PsnPay float64 `json:"psn_pay"`
  3618. // OpterID string `json:"opter_id"`
  3619. // Begndate string `json:"begndate"`
  3620. // FlxempeFlag string `json:"flxempe_flag"`
  3621. // HifmiPay float64 `json:"hifmi_pay"`
  3622. // PsnNo string `json:"psn_no"`
  3623. // ActPayDedc float64 `json:"act_pay_dedc"`
  3624. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3625. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3626. // ClrWay string `json:"clr_way"`
  3627. // OthPay float64 `json:"oth_pay"`
  3628. // Gend string `json:"gend"`
  3629. // MdtrtID string `json:"mdtrt_id"`
  3630. // AcctPay float64 `json:"acct_pay"`
  3631. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3632. // Insutype string `json:"insutype"`
  3633. // Invono interface{} `json:"invono"`
  3634. // Enddate string `json:"enddate"`
  3635. // CashPayamt float64 `json:"cash_payamt"`
  3636. // PsnType string `json:"psn_type"`
  3637. // FixmedinsName string `json:"fixmedins_name"`
  3638. // HifpPay float64 `json:"hifp_pay"`
  3639. // NewFlag interface{} `json:"new_flag"`
  3640. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3641. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3642. // PayLoc string `json:"pay_loc"`
  3643. // ClrType string `json:"clr_type"`
  3644. // RefdSetlFlag string `json:"refd_setl_flag"`
  3645. // CvlservFlag string `json:"cvlserv_flag"`
  3646. // EmpName string `json:"emp_name"`
  3647. // Brdy string `json:"brdy"`
  3648. // Naty string `json:"naty"`
  3649. // Certno string `json:"certno"`
  3650. // DiseCode string `json:"dise_code"`
  3651. // FixmedinsCode string `json:"fixmedins_code"`
  3652. // DedcHospLv string `json:"dedc_hosp_lv"`
  3653. // OpterName string `json:"opter_name"`
  3654. // Balc float64 `json:"balc"`
  3655. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3656. // PsnCertType string `json:"psn_cert_type"`
  3657. // HifobPay float64 `json:"hifob_pay"`
  3658. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3659. // HifesPay float64 `json:"hifes_pay"`
  3660. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3661. // OptTime string `json:"opt_time"`
  3662. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3663. // SetlID string `json:"setl_id"`
  3664. // MafPay float64 `json:"maf_pay"`
  3665. // PsnName string `json:"psn_name"`
  3666. // InsuOptins interface{} `json:"insu_optins"`
  3667. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3668. // ClrOptins string `json:"clr_optins"`
  3669. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3670. // DiseName string `json:"dise_name"`
  3671. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3672. // Age float64 `json:"age"`
  3673. // DtrtCertType string `json:"dtrt_cert_type"`
  3674. // HospLv string `json:"hosp_lv"`
  3675. // } `json:"setlinfo"`
  3676. // Setldetail []struct {
  3677. // FundPayType string `json:"fund_pay_type"`
  3678. // FundPayamt float64 `json:"fund_payamt"`
  3679. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3680. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3681. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3682. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3683. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3684. // } `json:"setldetail"`
  3685. // } `json:"output"`
  3686. // Infcode int `json:"infcode"`
  3687. // WarnMsg interface{} `json:"warn_msg"`
  3688. // Cainfo interface{} `json:"cainfo"`
  3689. // ErrMsg interface{} `json:"err_msg"`
  3690. // RefmsgTime string `json:"refmsg_time"`
  3691. // Signtype interface{} `json:"signtype"`
  3692. // RespondTime string `json:"respond_time"`
  3693. // InfRefmsgid string `json:"inf_refmsgid"`
  3694. //}
  3695. type ResultEleven struct {
  3696. Cainfo string `json:"cainfo"`
  3697. ErrMsg string `json:"err_msg"`
  3698. InfRefmsgid string `json:"inf_refmsgid"`
  3699. Infcode int64 `json:"infcode"`
  3700. Output struct {
  3701. Setlinfo struct {
  3702. SetlTime string `json:"setl_time"`
  3703. CvlservPay float64 `json:"cvlserv_pay"`
  3704. Year string `json:"year"`
  3705. MedType string `json:"med_type"`
  3706. PsnPay float64 `json:"psn_pay"`
  3707. OpterID string `json:"opter_id"`
  3708. Begndate string `json:"begndate"`
  3709. FlxempeFlag string `json:"flxempe_flag"`
  3710. HifmiPay float64 `json:"hifmi_pay"`
  3711. PsnNo string `json:"psn_no"`
  3712. ActPayDedc float64 `json:"act_pay_dedc"`
  3713. MedinsSetlID interface{} `json:"medins_setl_id"`
  3714. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3715. ClrWay string `json:"clr_way"`
  3716. OthPay float64 `json:"oth_pay"`
  3717. Gend string `json:"gend"`
  3718. MdtrtID string `json:"mdtrt_id"`
  3719. AcctPay float64 `json:"acct_pay"`
  3720. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3721. Insutype string `json:"insutype"`
  3722. Invono interface{} `json:"invono"`
  3723. Enddate string `json:"enddate"`
  3724. CashPayamt float64 `json:"cash_payamt"`
  3725. PsnType string `json:"psn_type"`
  3726. FixmedinsName string `json:"fixmedins_name"`
  3727. HifpPay float64 `json:"hifp_pay"`
  3728. NewFlag interface{} `json:"new_flag"`
  3729. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3730. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3731. PayLoc string `json:"pay_loc"`
  3732. ClrType string `json:"clr_type"`
  3733. RefdSetlFlag string `json:"refd_setl_flag"`
  3734. CvlservFlag string `json:"cvlserv_flag"`
  3735. EmpName string `json:"emp_name"`
  3736. Brdy string `json:"brdy"`
  3737. Naty string `json:"naty"`
  3738. Certno string `json:"certno"`
  3739. DiseCode string `json:"dise_code"`
  3740. FixmedinsCode string `json:"fixmedins_code"`
  3741. DedcHospLv string `json:"dedc_hosp_lv"`
  3742. OpterName string `json:"opter_name"`
  3743. Balc float64 `json:"balc"`
  3744. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3745. PsnCertType string `json:"psn_cert_type"`
  3746. HifobPay float64 `json:"hifob_pay"`
  3747. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3748. HifesPay float64 `json:"hifes_pay"`
  3749. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3750. OptTime string `json:"opt_time"`
  3751. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3752. SetlID string `json:"setl_id"`
  3753. MafPay float64 `json:"maf_pay"`
  3754. PsnName string `json:"psn_name"`
  3755. InsuOptins interface{} `json:"insu_optins"`
  3756. PrefFundPay interface{} `json:"pref_fund_pay"`
  3757. ClrOptins string `json:"clr_optins"`
  3758. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3759. DiseName string `json:"dise_name"`
  3760. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3761. Age float64 `json:"age"`
  3762. DtrtCertType string `json:"dtrt_cert_type"`
  3763. HospLv string `json:"hosp_lv"`
  3764. } `json:"setlinfo"`
  3765. } `json:"output"`
  3766. RefmsgTime string `json:"refmsg_time"`
  3767. RespondTime string `json:"respond_time"`
  3768. Signtype interface{} `json:"signtype"`
  3769. WarnMsg interface{} `json:"warn_msg"`
  3770. }
  3771. type ResultEleven10265 struct {
  3772. Cainfo string `json:"cainfo"`
  3773. ErrMsg string `json:"err_msg"`
  3774. InfRefmsgid string `json:"inf_refmsgid"`
  3775. Infcode string `json:"infcode"`
  3776. Output struct {
  3777. Setlinfo struct {
  3778. SetlTime string `json:"setl_time"`
  3779. CvlservPay float64 `json:"cvlserv_pay"`
  3780. Year string `json:"year"`
  3781. MedType string `json:"med_type"`
  3782. PsnPay float64 `json:"psn_pay"`
  3783. OpterID string `json:"opter_id"`
  3784. Begndate string `json:"begndate"`
  3785. FlxempeFlag string `json:"flxempe_flag"`
  3786. HifmiPay float64 `json:"hifmi_pay"`
  3787. PsnNo string `json:"psn_no"`
  3788. ActPayDedc float64 `json:"act_pay_dedc"`
  3789. MedinsSetlID interface{} `json:"medins_setl_id"`
  3790. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3791. ClrWay string `json:"clr_way"`
  3792. OthPay float64 `json:"oth_pay"`
  3793. Gend string `json:"gend"`
  3794. MdtrtID string `json:"mdtrt_id"`
  3795. AcctPay float64 `json:"acct_pay"`
  3796. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3797. Insutype string `json:"insutype"`
  3798. Invono interface{} `json:"invono"`
  3799. Enddate string `json:"enddate"`
  3800. CashPayamt float64 `json:"cash_payamt"`
  3801. PsnType string `json:"psn_type"`
  3802. FixmedinsName string `json:"fixmedins_name"`
  3803. HifpPay float64 `json:"hifp_pay"`
  3804. NewFlag interface{} `json:"new_flag"`
  3805. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3806. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3807. PayLoc string `json:"pay_loc"`
  3808. ClrType string `json:"clr_type"`
  3809. RefdSetlFlag string `json:"refd_setl_flag"`
  3810. CvlservFlag string `json:"cvlserv_flag"`
  3811. EmpName string `json:"emp_name"`
  3812. Brdy string `json:"brdy"`
  3813. Naty string `json:"naty"`
  3814. Certno string `json:"certno"`
  3815. DiseCode string `json:"dise_code"`
  3816. FixmedinsCode string `json:"fixmedins_code"`
  3817. DedcHospLv string `json:"dedc_hosp_lv"`
  3818. OpterName string `json:"opter_name"`
  3819. Balc float64 `json:"balc"`
  3820. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3821. PsnCertType string `json:"psn_cert_type"`
  3822. HifobPay float64 `json:"hifob_pay"`
  3823. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3824. HifesPay float64 `json:"hifes_pay"`
  3825. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3826. OptTime string `json:"opt_time"`
  3827. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3828. SetlID string `json:"setl_id"`
  3829. MafPay float64 `json:"maf_pay"`
  3830. PsnName string `json:"psn_name"`
  3831. InsuOptins interface{} `json:"insu_optins"`
  3832. PrefFundPay interface{} `json:"pref_fund_pay"`
  3833. ClrOptins string `json:"clr_optins"`
  3834. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3835. DiseName string `json:"dise_name"`
  3836. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3837. Age float64 `json:"age"`
  3838. DtrtCertType string `json:"dtrt_cert_type"`
  3839. HospLv string `json:"hosp_lv"`
  3840. } `json:"setlinfo"`
  3841. } `json:"output"`
  3842. RefmsgTime string `json:"refmsg_time"`
  3843. RespondTime string `json:"respond_time"`
  3844. Signtype interface{} `json:"signtype"`
  3845. WarnMsg interface{} `json:"warn_msg"`
  3846. }
  3847. type ResultTwelve struct {
  3848. Cainfo string `json:"cainfo"`
  3849. ErrMsg string `json:"err_msg"`
  3850. InfRefmsgid string `json:"inf_refmsgid"`
  3851. Infcode int64 `json:"infcode"`
  3852. Output struct {
  3853. MdtrtId string `json:"mdtrt_id"`
  3854. ChrgBchno string `json:"chrg_bchno"`
  3855. PsnNo string `json:"psn_no"`
  3856. } `json:"output"`
  3857. RefmsgTime string `json:"refmsg_time"`
  3858. RespondTime string `json:"respond_time"`
  3859. Signtype interface{} `json:"signtype"`
  3860. WarnMsg interface{} `json:"warn_msg"`
  3861. }
  3862. type ResultThirteen struct {
  3863. ErrMsg string `json:"err_msg"`
  3864. InfRefmsgid string `json:"inf_refmsgid"`
  3865. Infcode int64 `json:"infcode"`
  3866. Output struct {
  3867. Result struct {
  3868. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3869. } `json:"result"`
  3870. } `json:"output"`
  3871. RefmsgTime string `json:"refmsg_time"`
  3872. RespondTime string `json:"respond_time"`
  3873. Signtype interface{} `json:"signtype"`
  3874. WarnInfo interface{} `json:"warn_info"`
  3875. }
  3876. type ResultThirteen10265 struct {
  3877. ErrMsg string `json:"err_msg"`
  3878. InfRefmsgid string `json:"inf_refmsgid"`
  3879. Infcode string `json:"infcode"`
  3880. Output struct {
  3881. Result struct {
  3882. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3883. } `json:"result"`
  3884. } `json:"output"`
  3885. RefmsgTime string `json:"refmsg_time"`
  3886. RespondTime string `json:"respond_time"`
  3887. Signtype interface{} `json:"signtype"`
  3888. WarnInfo interface{} `json:"warn_info"`
  3889. }
  3890. type ResultFourteen struct {
  3891. ErrMsg string `json:"err_msg"`
  3892. InfRefmsgid string `json:"inf_refmsgid"`
  3893. Infcode int64 `json:"infcode"`
  3894. Output struct {
  3895. } `json:"output"`
  3896. RefmsgTime string `json:"refmsg_time"`
  3897. RespondTime string `json:"respond_time"`
  3898. Signtype interface{} `json:"signtype"`
  3899. WarnInfo interface{} `json:"warn_info"`
  3900. }
  3901. type ResultFourteen10265 struct {
  3902. ErrMsg string `json:"err_msg"`
  3903. InfRefmsgid string `json:"inf_refmsgid"`
  3904. Infcode string `json:"infcode"`
  3905. Output struct {
  3906. } `json:"output"`
  3907. RefmsgTime string `json:"refmsg_time"`
  3908. RespondTime string `json:"respond_time"`
  3909. Signtype interface{} `json:"signtype"`
  3910. WarnInfo interface{} `json:"warn_info"`
  3911. }
  3912. type ResultSixteen struct {
  3913. Cainfo string `json:"cainfo"`
  3914. ErrMsg string `json:"err_msg"`
  3915. InfRefmsgid string `json:"inf_refmsgid"`
  3916. Infcode int64 `json:"infcode"`
  3917. Output struct {
  3918. Setldetail []interface{} `json:"setldetail"`
  3919. Setlinfo struct {
  3920. MdtrtID string `json:"mdtrt_id"`
  3921. SetlID string `json:"setl_id"`
  3922. ClrOptins string `json:"clr_optins"`
  3923. SetlTime string `json:"setl_time"`
  3924. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3925. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3926. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3927. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3928. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3929. ActPayDedc float64 `json:"act_pay_dedc"`
  3930. HifpPay float64 `json:"hifp_pay"`
  3931. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3932. Lfpay float64 `json:"selfpay"`
  3933. CvlservPay float64 `json:"cvlserv_pay"`
  3934. HifesPay float64 `json:"hifes_pay"`
  3935. HifmiPay float64 `json:"hifmi_pay"`
  3936. HifobPay float64 `json:"hifob_pay"`
  3937. MafPay float64 `json:"maf_pay"`
  3938. OthPay float64 `json:"oth_pay"`
  3939. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3940. PsnPartAmt float64 `json:"psn_part_amt"`
  3941. AcctPay float64 `json:"acct_pay"`
  3942. Balc float64 `json:"balc"`
  3943. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3944. HospPartAmt float64 `json:"hosp_part_amt"`
  3945. MedinsSetlID string `json:"medins_setl_id"`
  3946. PdnCashPay string `json:"pdn_cash_pay"`
  3947. } `json:"setlinfo"`
  3948. } `json:"output"`
  3949. RefmsgTime string `json:"refmsg_time"`
  3950. RespondTime string `json:"respond_time"`
  3951. Signtype interface{} `json:"signtype"`
  3952. WarnMsg interface{} `json:"warn_msg"`
  3953. }
  3954. type ResultSixteen10265 struct {
  3955. Cainfo string `json:"cainfo"`
  3956. ErrMsg string `json:"err_msg"`
  3957. InfRefmsgid string `json:"inf_refmsgid"`
  3958. Infcode string `json:"infcode"`
  3959. Output struct {
  3960. Setldetail []interface{} `json:"setldetail"`
  3961. Setlinfo struct {
  3962. MdtrtID string `json:"mdtrt_id"`
  3963. SetlID string `json:"setl_id"`
  3964. ClrOptins string `json:"clr_optins"`
  3965. SetlTime string `json:"setl_time"`
  3966. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3967. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3968. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3969. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3970. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3971. ActPayDedc float64 `json:"act_pay_dedc"`
  3972. HifpPay float64 `json:"hifp_pay"`
  3973. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3974. Lfpay float64 `json:"selfpay"`
  3975. CvlservPay float64 `json:"cvlserv_pay"`
  3976. HifesPay float64 `json:"hifes_pay"`
  3977. HifmiPay float64 `json:"hifmi_pay"`
  3978. HifobPay float64 `json:"hifob_pay"`
  3979. MafPay float64 `json:"maf_pay"`
  3980. OthPay float64 `json:"oth_pay"`
  3981. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3982. PsnPartAmt float64 `json:"psn_part_amt"`
  3983. AcctPay float64 `json:"acct_pay"`
  3984. Balc float64 `json:"balc"`
  3985. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3986. HospPartAmt float64 `json:"hosp_part_amt"`
  3987. MedinsSetlID string `json:"medins_setl_id"`
  3988. PdnCashPay string `json:"pdn_cash_pay"`
  3989. } `json:"setlinfo"`
  3990. } `json:"output"`
  3991. RefmsgTime string `json:"refmsg_time"`
  3992. RespondTime string `json:"respond_time"`
  3993. Signtype interface{} `json:"signtype"`
  3994. WarnMsg interface{} `json:"warn_msg"`
  3995. }
  3996. type ResultSeventeen struct {
  3997. ErrMsg string `json:"err_msg"`
  3998. InfRefmsgid string `json:"inf_refmsgid"`
  3999. Infcode int64 `json:"infcode"`
  4000. Output struct {
  4001. SetlListId string `json:"setl_list_id"`
  4002. } `json:"output"`
  4003. RefmsgTime string `json:"refmsg_time"`
  4004. RespondTime string `json:"respond_time"`
  4005. Signtype string `json:"signtype"`
  4006. WarnInfo string `json:"warn_info"`
  4007. }
  4008. type Result90991 struct {
  4009. ErrMsg string `json:"err_msg"`
  4010. InfRefmsgid string `json:"inf_refmsgid"`
  4011. Infcode int64 `json:"infcode"`
  4012. Output struct {
  4013. Result struct {
  4014. PsnNo string `json:"psn_no"`
  4015. CardStat string `json:"card_stat"`
  4016. Certno string `json:"certno"`
  4017. PsnName string `json:"psn_name"`
  4018. CheckStat string `json:"check_stat"`
  4019. } `json:"result"`
  4020. } `json:"output"`
  4021. RefmsgTime string `json:"refmsg_time"`
  4022. RespondTime string `json:"respond_time"`
  4023. Signtype interface{} `json:"signtype"`
  4024. WarnInfo interface{} `json:"warn_info"`
  4025. }
  4026. type Result90100 struct {
  4027. ErrMsg string `json:"err_msg"`
  4028. InfRefmsgid string `json:"inf_refmsgid"`
  4029. Infcode int64 `json:"infcode"`
  4030. Output struct {
  4031. PoolareaNo string `json:"poolarea_no"`
  4032. PoolareaNoName string `json:"poolarea_no_name"`
  4033. Insutype string `json:"insutype"`
  4034. InsutypeName string `json:"insutype_name"`
  4035. ClctType string `json:"clct_type"`
  4036. ClctTypeName string `json:"clct_type_name"`
  4037. ClctFlag string `json:"clct_flag"`
  4038. ClctFlagName string `json:"clct_flag_name"`
  4039. AccrymBegn string `json:"accrym_begn"`
  4040. AccrymEnd string `json:"accrym_end"`
  4041. ClctTime string `json:"clct_time"`
  4042. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4043. } `json:"output"`
  4044. RefmsgTime string `json:"refmsg_time"`
  4045. RespondTime string `json:"respond_time"`
  4046. Signtype interface{} `json:"signtype"`
  4047. WarnInfo interface{} `json:"warn_info"`
  4048. }
  4049. type Custom struct {
  4050. DetItemFeeSumamt string
  4051. Cut string
  4052. FeedetlSn string
  4053. Price string
  4054. MedListCodg string
  4055. Type int64
  4056. AdviceId int64
  4057. ProjectId int64
  4058. ItemId int64
  4059. }
  4060. type Result5301 struct {
  4061. ErrMsg string `json:"err_msg"`
  4062. InfRefmsgid string `json:"inf_refmsgid"`
  4063. Infcode int64 `json:"infcode"`
  4064. Output struct {
  4065. Result []struct {
  4066. OpspDiseCode string `json:"opsp_dise_code"`
  4067. OpspDiseName string `json:"opsp_dise_name"`
  4068. Begndate string `json:"begndate"`
  4069. Enddate string `json:"enddate"`
  4070. } `json:"feedetail"`
  4071. } `json:"output"`
  4072. RefmsgTime string `json:"refmsg_time"`
  4073. RespondTime string `json:"respond_time"`
  4074. Signtype interface{} `json:"signtype"`
  4075. WarnInfo interface{} `json:"warn_info"`
  4076. }
  4077. type Result5301For10265 struct {
  4078. ErrMsg string `json:"err_msg"`
  4079. InfRefmsgid string `json:"inf_refmsgid"`
  4080. Infcode string `json:"infcode"`
  4081. Output struct {
  4082. Result []struct {
  4083. OpspDiseCode string `json:"opsp_dise_code"`
  4084. OpspDiseName string `json:"opsp_dise_name"`
  4085. Begndate string `json:"begndate"`
  4086. Enddate string `json:"enddate"`
  4087. } `json:"feedetail"`
  4088. } `json:"output"`
  4089. RefmsgTime string `json:"refmsg_time"`
  4090. RespondTime string `json:"respond_time"`
  4091. Signtype interface{} `json:"signtype"`
  4092. WarnInfo interface{} `json:"warn_info"`
  4093. }
  4094. //获取个人信息----挂号-----上传就诊信息
  4095. func (c *HisApiController) GetRegisterInfo() {
  4096. id, _ := c.GetInt64("id")
  4097. record_time := c.GetString("record_time")
  4098. settlementValue, _ := c.GetInt64("settlement_value")
  4099. medical_insurance_card := c.GetString("medical_insurance_card")
  4100. name := c.GetString("name")
  4101. id_card_type, _ := c.GetInt64("id_card_type")
  4102. certificates, _ := c.GetInt64("certificates")
  4103. medical_care, _ := c.GetInt64("medical_care")
  4104. birthday := c.GetString("birthday")
  4105. id_card := c.GetString("id_card")
  4106. register_type, _ := c.GetInt64("register")
  4107. doctor, _ := c.GetInt64("doctor")
  4108. department, _ := c.GetInt64("department")
  4109. gender, _ := c.GetInt64("sex")
  4110. registration_fee, _ := c.GetFloat("registration_fee")
  4111. medical_expenses, _ := c.GetFloat("medical_expenses")
  4112. social_type, _ := c.GetInt64("social_type")
  4113. med_type := c.GetString("social_type")
  4114. admin_user_id, _ := c.GetInt64("admin_user_id")
  4115. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4116. timeLayout := "2006-01-02"
  4117. loc, _ := time.LoadLocation("Local")
  4118. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4119. birthUnix := birthdays.Unix()
  4120. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4121. if err != nil {
  4122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4123. return
  4124. }
  4125. recordDateTime := theTime.Unix()
  4126. adminInfo := c.GetAdminUserInfo()
  4127. var patient service.Patients
  4128. if id == 0 {
  4129. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4130. } else {
  4131. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4132. }
  4133. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4134. if patientPrescription.ID == 0 {
  4135. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4136. }
  4137. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4138. if patient.ID == 0 {
  4139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4140. return
  4141. }
  4142. if len(patient.IdCardNo) == 0 {
  4143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4144. return
  4145. }
  4146. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4147. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4148. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4149. //就诊结算未完成,不能进行二次挂号
  4150. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4151. if len(his) >= 1 {
  4152. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4153. if len(his) >= 1 && order.ID == 0 {
  4154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4155. return
  4156. }
  4157. }
  4158. //var register_log string
  4159. if config.IsOpen == 1 {
  4160. var res ResultTwo
  4161. var res10265 ResultTwo10265
  4162. var PsnNo string
  4163. var PsnCertType string
  4164. var Certno string
  4165. var PsnName string
  4166. var Gend string
  4167. var Naty string
  4168. var Brdy string
  4169. var Age float64
  4170. var infoStr string
  4171. var idetinfoStr string
  4172. var infocode int64
  4173. var verify_number string
  4174. fmt.Println(verify_number)
  4175. if miConfig.MdtrtareaAdmvs == "421300" {
  4176. psn_info, _ := service.GetPsnByPatientId(id)
  4177. PsnNo = psn_info.PsnNo
  4178. PsnCertType = psn_info.PsnCertType
  4179. Certno = psn_info.Certno
  4180. PsnName = psn_info.PsnName
  4181. Gend = psn_info.Gend
  4182. Naty = psn_info.Naty
  4183. Brdy = psn_info.Brdy
  4184. Age = psn_info.Age
  4185. infoStr = psn_info.Insuinfo
  4186. idetinfoStr = psn_info.Idetinfo
  4187. infocode = 0
  4188. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4189. psn_info, _ := service.GetPsnByPatientId(id)
  4190. PsnNo = psn_info.PsnNo
  4191. PsnCertType = psn_info.PsnCertType
  4192. Certno = psn_info.Certno
  4193. PsnName = psn_info.PsnName
  4194. Gend = psn_info.Gend
  4195. Naty = psn_info.Naty
  4196. Brdy = psn_info.Brdy
  4197. Age = psn_info.Age
  4198. infoStr = psn_info.Insuinfo
  4199. idetinfoStr = psn_info.Idetinfo
  4200. infocode = 0
  4201. verify_number = psn_info.VerifyNumber
  4202. } else {
  4203. var result string
  4204. var requestLog string
  4205. if miConfig.UserOrgId == 10138 {
  4206. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4207. } else {
  4208. 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)
  4209. }
  4210. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4211. if miConfig.Code == "H15049901371" {
  4212. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4213. utils.ErrorLog("解析失败:%v", err)
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4215. return
  4216. }
  4217. res.ErrMsg = res10265.ErrMsg
  4218. res.Output = res10265.Output
  4219. res.InfRefmsgid = res10265.InfRefmsgid
  4220. } else {
  4221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4222. utils.ErrorLog("解析失败:%v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. }
  4227. PsnNo = res.Output.Baseinfo.PsnNo
  4228. PsnCertType = res.Output.Baseinfo.PsnCertType
  4229. Certno = res.Output.Baseinfo.Certno
  4230. PsnName = res.Output.Baseinfo.PsnName
  4231. Gend = res.Output.Baseinfo.Gend
  4232. Naty = res.Output.Baseinfo.Naty
  4233. Brdy = res.Output.Baseinfo.Brdy
  4234. Age = res.Output.Baseinfo.Age
  4235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4237. infoStr = string(Iinfos)
  4238. idetinfoStr = string(Idetinfos)
  4239. if miConfig.Code == "H15049901371" {
  4240. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4241. } else {
  4242. infocode = res.Infcode
  4243. }
  4244. }
  4245. if infocode == 0 {
  4246. his := models.VMHisPatient{
  4247. Name: name,
  4248. Gender: gender,
  4249. Birthday: birthUnix,
  4250. MedicalTreatmentType: medical_care,
  4251. IdType: certificates,
  4252. IdCardNo: id_card,
  4253. BalanceAccountsType: settlementValue,
  4254. SocialType: social_type,
  4255. MedicalInsuranceNumber: medical_insurance_card,
  4256. RegisterType: register_type,
  4257. RegisterCost: registration_fee,
  4258. TreatmentCost: medical_expenses,
  4259. Status: 1,
  4260. Ctime: time.Now().Unix(),
  4261. Mtime: time.Now().Unix(),
  4262. PsnNo: PsnNo,
  4263. PsnCertType: PsnCertType,
  4264. Certno: Certno,
  4265. PsnName: PsnName,
  4266. Gend: Gend,
  4267. Naty: Naty,
  4268. Brdy: Brdy,
  4269. Age: Age,
  4270. Iinfo: infoStr,
  4271. Idetinfo: idetinfoStr,
  4272. PatientId: patient.ID,
  4273. RecordDate: theTime.Unix(),
  4274. UserOrgId: adminInfo.CurrentOrgId,
  4275. AdminUserId: admin_user_id,
  4276. IsReturn: 1,
  4277. IdCardType: id_card_type,
  4278. Doctor: doctor,
  4279. Departments: department,
  4280. }
  4281. timestamp := time.Now().Unix()
  4282. tempTime := time.Unix(timestamp, 0)
  4283. timeFormat := tempTime.Format("20060102150405")
  4284. chrgBchno := rand.Intn(100000) + 10000
  4285. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4286. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4287. department, _ := service.GetDepartMentDetail(department)
  4288. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4289. IdCardNo := ""
  4290. if id_card_type == 1 {
  4291. // IdCardNo = medical_insurance_card
  4292. IdCardNo = patient.IdCardNo
  4293. } else {
  4294. IdCardNo = patient.IdCardNo
  4295. }
  4296. var rf []*ResultFive
  4297. json.Unmarshal([]byte(his.Iinfo), &rf)
  4298. var insutypes []*ResultFive
  4299. var insutype string
  4300. var insuplc_admdvs_temp string
  4301. var is390 int = 0
  4302. var is310 int = 0
  4303. for _, item := range rf {
  4304. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4305. insutypes = append(insutypes, item)
  4306. }
  4307. }
  4308. if len(insutypes) == 1 {
  4309. insutype = insutypes[0].Insutype
  4310. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4311. } else {
  4312. for _, i := range insutypes {
  4313. if i.Insutype == "390" {
  4314. is390 = 1
  4315. }
  4316. if i.Insutype == "310" {
  4317. is310 = 1
  4318. }
  4319. }
  4320. }
  4321. if is390 == 1 {
  4322. insutype = "390"
  4323. }
  4324. if is310 == 1 {
  4325. insutype = "310"
  4326. }
  4327. if len(insutypes) == 0 {
  4328. insutype = "310"
  4329. }
  4330. if len(insutypes) == 2 {
  4331. insutype = med_type
  4332. }
  4333. if len(med_type) > 0 {
  4334. insutype = med_type
  4335. }
  4336. //for _, item := range rf {
  4337. // if item.Insutype == insutype {
  4338. // insuplc_admdvs = item.InsuplcAdmdvs
  4339. // }
  4340. //}
  4341. var infocode int64
  4342. var resThree ResultThree
  4343. var resThree10265 ResultThree10265
  4344. if len(insuplc_admdvs) == 0 {
  4345. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4346. } else {
  4347. insuplc_admdvs_temp = insuplc_admdvs
  4348. }
  4349. if miConfig.MdtrtareaAdmvs == "421300" {
  4350. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4351. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4352. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  4353. resp, requestErr := http.Get(api)
  4354. if requestErr != nil {
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. return
  4357. }
  4358. body, ioErr := ioutil.ReadAll(resp.Body)
  4359. if ioErr != nil {
  4360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4362. return
  4363. }
  4364. var respJSON map[string]interface{}
  4365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4368. return
  4369. }
  4370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4371. result, _ := json.Marshal(respJSON)
  4372. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4373. utils.ErrorLog("解析失败:%v", err)
  4374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4375. return
  4376. }
  4377. infocode = resThree.Infcode
  4378. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4379. psn_info, _ := service.GetPsnByPatientId(id)
  4380. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4381. var cert_no string
  4382. if id_card_type == 3 {
  4383. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4384. cert_no = IdCardNo
  4385. } else {
  4386. bas := strings.Split(psn_info.CardInfo, "|")
  4387. cert_no = bas[2]
  4388. }
  4389. var api string
  4390. if miConfig.MdtrtareaAdmvs == "320921" {
  4391. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4392. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4393. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4394. } else {
  4395. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4396. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4397. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4398. }
  4399. resp, requestErr := http.Get(api)
  4400. if requestErr != nil {
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4402. return
  4403. }
  4404. body, ioErr := ioutil.ReadAll(resp.Body)
  4405. if ioErr != nil {
  4406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. return
  4409. }
  4410. var respJSON map[string]interface{}
  4411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4417. result, _ := json.Marshal(respJSON)
  4418. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4419. utils.ErrorLog("解析失败:%v", err)
  4420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4421. return
  4422. }
  4423. resThree.ErrMsg = resThree10265.ErrMsg
  4424. resThree.Output = resThree10265.Output
  4425. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4426. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4427. } else {
  4428. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4429. saveLog(result, requestLog, "2201A", "挂号")
  4430. if miConfig.Code == "H15049901371" {
  4431. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4432. utils.ErrorLog("解析失败:%v", err)
  4433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4434. return
  4435. }
  4436. resThree.ErrMsg = resThree10265.ErrMsg
  4437. resThree.Output = resThree10265.Output
  4438. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4439. } else {
  4440. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4441. utils.ErrorLog("解析失败:%v", err)
  4442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4443. return
  4444. }
  4445. }
  4446. if miConfig.Code == "H15049901371" {
  4447. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4448. } else {
  4449. infocode = resThree.Infcode
  4450. }
  4451. }
  4452. if infocode != 0 {
  4453. adminUser := c.GetAdminUserInfo()
  4454. errlog := &models.HisOrderError{
  4455. UserOrgId: adminUser.CurrentOrgId,
  4456. Ctime: time.Now().Unix(),
  4457. Mtime: time.Now().Unix(),
  4458. ErrMsg: resThree.ErrMsg,
  4459. Status: 1,
  4460. PatientId: id,
  4461. RecordTime: recordDateTime,
  4462. Stage: 2,
  4463. }
  4464. service.CreateErrMsgLog(errlog)
  4465. c.ServeSuccessJSON(map[string]interface{}{
  4466. "failed_code": -10,
  4467. "msg": resThree.ErrMsg,
  4468. })
  4469. return
  4470. }
  4471. his.Number = resThree.Output.Data.MdtrtID
  4472. his.PsnNo = resThree.Output.Data.PsnNo
  4473. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4474. his.IdCardNo = patient.IdCardNo
  4475. his.PhoneNumber = patient.Phone
  4476. his.UserOrgId = adminInfo.CurrentOrgId
  4477. his.Insutype = insutype
  4478. his.Ctime = time.Now().Unix()
  4479. his.Mtime = time.Now().Unix()
  4480. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4481. his.Status = 1
  4482. service.UpdateHisPatientStatus(&his)
  4483. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4484. c.ServeSuccessJSON(map[string]interface{}{
  4485. "his_info": his,
  4486. })
  4487. } else {
  4488. adminUser := c.GetAdminUserInfo()
  4489. errlog := &models.HisOrderError{
  4490. UserOrgId: adminUser.CurrentOrgId,
  4491. Ctime: time.Now().Unix(),
  4492. Mtime: time.Now().Unix(),
  4493. ErrMsg: res.ErrMsg,
  4494. Status: 1,
  4495. PatientId: id,
  4496. RecordTime: recordDateTime,
  4497. Stage: 1,
  4498. }
  4499. service.CreateErrMsgLog(errlog)
  4500. c.ServeSuccessJSON(map[string]interface{}{
  4501. "failed_code": -10,
  4502. "msg": res.ErrMsg,
  4503. })
  4504. return
  4505. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4506. }
  4507. }
  4508. }
  4509. //上传明细----预结算----确认订单
  4510. func (c *HisApiController) GetUploadInfo() {
  4511. id, _ := c.GetInt64("id")
  4512. record_time := c.GetString("record_time")
  4513. his_patient_id, _ := c.GetInt64("his_patient_id")
  4514. order_id, _ := c.GetInt64("order_id")
  4515. pay_way, _ := c.GetInt64("pay_way")
  4516. pay_price, _ := c.GetFloat("pay_price")
  4517. pay_card_no := c.GetString("pay_card_no")
  4518. discount_price, _ := c.GetFloat("discount_price")
  4519. preferential_price, _ := c.GetFloat("preferential_price")
  4520. reality_price, _ := c.GetFloat("reality_price")
  4521. found_price, _ := c.GetFloat("found_price")
  4522. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4523. private_price, _ := c.GetFloat("private_price")
  4524. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4525. admin_user_id, _ := c.GetInt64("admin_user_id")
  4526. fapiao_code := c.GetString("fapiao_code")
  4527. fapiao_number := c.GetString("fapiao_number")
  4528. diagnosis_id := c.GetString("diagnosis")
  4529. sick_type, _ := c.GetInt64("sick_type")
  4530. reg_type, _ := c.GetInt64("p_type")
  4531. begin_time := c.GetString("begin_time")
  4532. id_str := c.GetString("ids")
  4533. ids_arr := strings.Split(id_str, ",")
  4534. timeLayout := "2006-01-02"
  4535. loc, _ := time.LoadLocation("Local")
  4536. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4537. if err != nil {
  4538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4539. return
  4540. }
  4541. recordDateTime := theTime.Unix()
  4542. adminUser := c.GetAdminUserInfo()
  4543. var tempOrder models.HisOrder
  4544. tempOrder, _ = service.GetHisOrderByID(order_id)
  4545. var prescriptions []*models.HisPrescription
  4546. var start_time int64
  4547. var end_time int64
  4548. //if adminUser.CurrentOrgId == 10106{
  4549. // if len(fapiao_code) == 0{
  4550. // fapiao_code = "144072080589"
  4551. // }
  4552. // if len(fapiao_number) == 0{
  4553. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4554. // if order.ID == 0{
  4555. // fapiao_number = "00001520"
  4556. // }else{
  4557. // //fapiao_code = "00001520"
  4558. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4559. // var zero string
  4560. // if fpNumber >= 1000{
  4561. // zero = "0000" + strconv.Itoa(fpNumber)
  4562. // }else if fpNumber >= 10000{
  4563. // zero = "000" + strconv.Itoa(fpNumber)
  4564. // } else if fpNumber >= 100000{
  4565. // zero = "00" + strconv.Itoa(fpNumber)
  4566. // } else if fpNumber >= 1000000{
  4567. // zero = "0" + strconv.Itoa(fpNumber)
  4568. // }else {
  4569. // zero = strconv.Itoa(fpNumber)
  4570. // }
  4571. // fapiao_number = zero
  4572. // }
  4573. // }
  4574. //}
  4575. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4576. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4577. var patientPrescription models.HisPrescriptionInfo
  4578. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4579. if patientPrescription.ID == 0 {
  4580. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4581. }
  4582. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4583. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4584. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4585. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4586. var config []*models.HisXtDiagnoseConfig
  4587. for _, item := range diagnosis_ids {
  4588. id, _ := strconv.ParseInt(item, 10, 64)
  4589. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4590. config = append(config, &diagnosisConfig)
  4591. }
  4592. sickConfig, _ := service.FindSickById(sick_type)
  4593. //if tempOrder.ID == 0 {
  4594. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4595. //}
  4596. if tempOrder.ID == 0 {
  4597. var result string
  4598. var requestLog string
  4599. var res2 ResultSix
  4600. var ressix10265 ResultSix10265
  4601. if miConfig.MdtrtareaAdmvs == "421300" {
  4602. data := make(map[string]interface{})
  4603. client := &http.Client{}
  4604. data["psn_no"] = his.PsnNo
  4605. data["mdtrt_id"] = his.Number
  4606. data["doctor"] = roles.UserName
  4607. data["department"] = department.Name
  4608. data["org_name"] = miConfig.OrgName
  4609. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4610. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4611. data["fixmedins_code"] = miConfig.Code
  4612. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4613. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4614. data["secret_key"] = miConfig.SecretKey
  4615. data["sick_code"] = sickConfig.CountryCode
  4616. data["sick_name"] = sickConfig.ClassName
  4617. data["dept"] = strconv.FormatInt(department.ID, 10)
  4618. data["config"] = config
  4619. data["begin_time"] = begin_time
  4620. bytesData, _ := json.Marshal(data)
  4621. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4622. resp, _ := client.Do(req)
  4623. defer resp.Body.Close()
  4624. body, ioErr := ioutil.ReadAll(resp.Body)
  4625. if ioErr != nil {
  4626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4628. return
  4629. }
  4630. var respJSON map[string]interface{}
  4631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4634. return
  4635. }
  4636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4637. userJSONBytes, _ := json.Marshal(respJSON)
  4638. fmt.Println("log")
  4639. fmt.Println(string(userJSONBytes))
  4640. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4641. utils.ErrorLog("解析失败:%v", err)
  4642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. return
  4644. }
  4645. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4646. //江苏地区国家医保医疗类别
  4647. //职工透析:医疗类别选特殊情况门诊9933
  4648. //居民血透门慢: 医疗类别选门诊慢病1402
  4649. //var med_type string
  4650. //if his.Insutype == "310" {
  4651. // if reg_type == 14 {
  4652. // med_type = "9933"
  4653. // } else if reg_type == 11 {
  4654. // med_type = "11"
  4655. //
  4656. // }
  4657. //} else if his.Insutype == "390" {
  4658. // if reg_type == 14 {
  4659. // med_type = "1402"
  4660. // } else if reg_type == 11 {
  4661. // med_type = "11"
  4662. // }
  4663. //}
  4664. data := make(map[string]interface{})
  4665. client := &http.Client{}
  4666. data["psn_no"] = his.PsnNo
  4667. data["mdtrt_id"] = his.Number
  4668. data["doctor"] = roles.UserName
  4669. data["department"] = department.Name
  4670. data["org_name"] = miConfig.OrgName
  4671. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4672. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4673. data["fixmedins_code"] = miConfig.Code
  4674. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4675. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4676. data["secret_key"] = miConfig.SecretKey
  4677. data["sick_code"] = sickConfig.CountryCode
  4678. data["sick_name"] = sickConfig.ClassName
  4679. data["url"] = miConfig.Url
  4680. data["ak"] = miConfig.AccessKey
  4681. data["begin_time"] = begin_time
  4682. data["cainfo"] = miConfig.Cainfo
  4683. data["dept"] = strconv.FormatInt(department.ID, 10)
  4684. data["config"] = config
  4685. bytesData, _ := json.Marshal(data)
  4686. var req *http.Request
  4687. if miConfig.MdtrtareaAdmvs == "320921" {
  4688. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4689. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4690. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4691. } else {
  4692. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4693. }
  4694. resp, _ := client.Do(req)
  4695. defer resp.Body.Close()
  4696. body, ioErr := ioutil.ReadAll(resp.Body)
  4697. if ioErr != nil {
  4698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. return
  4701. }
  4702. var respJSON map[string]interface{}
  4703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4706. return
  4707. }
  4708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4709. userJSONBytes, _ := json.Marshal(respJSON)
  4710. fmt.Println("log")
  4711. fmt.Println(string(userJSONBytes))
  4712. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4713. utils.ErrorLog("解析失败:%v", err)
  4714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4715. return
  4716. }
  4717. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4718. res2.Output = ressix10265.Output
  4719. res2.ErrMsg = ressix10265.ErrMsg
  4720. res2.Cainfo = ressix10265.Cainfo
  4721. res2.WarnMsg = ressix10265.WarnMsg
  4722. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4723. res2.Infcode = infocode
  4724. } else {
  4725. if miConfig.MdtrtareaAdmvs == "440781" { //
  4726. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  4727. } else {
  4728. if miConfig.Code == "H15049901371" {
  4729. //赤峰地区国家医保医疗类别
  4730. //职工透析:医疗类别选特殊情况门诊990502
  4731. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4732. var med_type string
  4733. if his.Insutype == "390" {
  4734. if reg_type == 14 {
  4735. med_type = "9933"
  4736. } else if reg_type == 11 {
  4737. med_type = "11"
  4738. }
  4739. } else if his.Insutype == "310" {
  4740. if reg_type == 14 {
  4741. med_type = "990502"
  4742. } else if reg_type == 11 {
  4743. med_type = "11"
  4744. }
  4745. }
  4746. 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)
  4747. } else {
  4748. 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)
  4749. }
  4750. }
  4751. saveLog(result, requestLog, "2203", "上传就诊信息")
  4752. var respJSON2 map[string]interface{}
  4753. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return
  4757. }
  4758. userJSONBytes2, _ := json.Marshal(respJSON2)
  4759. if miConfig.Code == "H15049901371" {
  4760. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4761. utils.ErrorLog("解析失败:%v", err)
  4762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. return
  4764. }
  4765. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4766. res2.Output = ressix10265.Output
  4767. res2.ErrMsg = ressix10265.ErrMsg
  4768. res2.Cainfo = ressix10265.Cainfo
  4769. res2.WarnMsg = ressix10265.WarnMsg
  4770. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4771. res2.Infcode = infocode
  4772. } else {
  4773. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4774. utils.ErrorLog("解析失败:%v", err)
  4775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4776. return
  4777. }
  4778. }
  4779. }
  4780. if res2.Infcode != 0 {
  4781. adminUser := c.GetAdminUserInfo()
  4782. errlog := &models.HisOrderError{
  4783. UserOrgId: adminUser.CurrentOrgId,
  4784. Ctime: time.Now().Unix(),
  4785. Mtime: time.Now().Unix(),
  4786. ErrMsg: res2.ErrMsg,
  4787. Status: 1,
  4788. PatientId: id,
  4789. RecordTime: recordDateTime,
  4790. Stage: 3,
  4791. }
  4792. service.CreateErrMsgLog(errlog)
  4793. c.ServeSuccessJSON(map[string]interface{}{
  4794. "failed_code": -10,
  4795. "msg": res2.ErrMsg,
  4796. })
  4797. return
  4798. } else {
  4799. his.Diagnosis = diagnosis_id
  4800. his.SickType = sickConfig.ID
  4801. //var p_type int64
  4802. //if reg_type == 1111 || reg_type == 1112 {
  4803. // p_type = 11
  4804. //
  4805. //}
  4806. his.PType = fmt.Sprintf("%d", reg_type)
  4807. service.UpdateHisPatientThree(&his)
  4808. data := make(map[string]interface{})
  4809. if settle_accounts_type == 1 { //日结
  4810. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4811. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4812. } else {
  4813. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4814. }
  4815. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4816. data["pre"] = prescriptions
  4817. } else { //月结
  4818. start_time_str := c.GetString("start_time")
  4819. end_time_str := c.GetString("end_time")
  4820. timeLayout := "2006-01-02"
  4821. loc, _ := time.LoadLocation("Local")
  4822. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4823. if err != nil {
  4824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4825. return
  4826. }
  4827. recordStartTime := theStartTime.Unix()
  4828. start_time = recordStartTime
  4829. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4830. if err != nil {
  4831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4832. return
  4833. }
  4834. recordEndTime := theEndTime.Unix()
  4835. end_time = recordEndTime
  4836. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4837. data["pre"] = prescriptions
  4838. }
  4839. timestamp := time.Now().Unix()
  4840. tempTime := time.Unix(timestamp, 0)
  4841. timeFormat := tempTime.Format("20060102150405")
  4842. chrgBchno := rand.Intn(100000) + 10000
  4843. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4844. strconv.FormatInt(his.PatientId, 10)
  4845. client := &http.Client{}
  4846. data["psn_no"] = his.PsnNo
  4847. data["mdtrt_id"] = his.Number
  4848. data["chrg_bchno"] = chrg_bchno
  4849. data["org_name"] = miConfig.OrgName
  4850. data["doctor"] = roles.UserName
  4851. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4852. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4853. data["fixmedins_code"] = miConfig.Code
  4854. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4855. // data["dept_code"] = "15"
  4856. //} else {
  4857. data["dept_code"] = department.Number
  4858. //}
  4859. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4860. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4861. data["secret_key"] = miConfig.SecretKey
  4862. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4863. data["url"] = miConfig.Url
  4864. data["ak"] = miConfig.AccessKey
  4865. data["new_doctor_name"] = patientPrescription.Doctor
  4866. data["diag_code"] = sickConfig.CountryCode
  4867. data["cainfo"] = miConfig.Cainfo
  4868. var ids []int64
  4869. for _, item := range prescriptions {
  4870. ids = append(ids, item.ID)
  4871. }
  4872. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4873. if config.IsOpen == 1 { //对接了医保,走医保流程
  4874. var res ResultFour
  4875. var resFour10265 ResultFour10265
  4876. if miConfig.MdtrtareaAdmvs == "421300" {
  4877. bytesData, _ := json.Marshal(data)
  4878. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4879. resp, _ := client.Do(req)
  4880. defer resp.Body.Close()
  4881. body, ioErr := ioutil.ReadAll(resp.Body)
  4882. if ioErr != nil {
  4883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4885. return
  4886. }
  4887. var respJSON map[string]interface{}
  4888. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. return
  4892. }
  4893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4894. userJSONBytes, _ := json.Marshal(respJSON)
  4895. fmt.Println("log")
  4896. fmt.Println(string(userJSONBytes))
  4897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4898. utils.ErrorLog("解析失败:%v", err)
  4899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4900. return
  4901. }
  4902. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4903. bytesData, _ := json.Marshal(data)
  4904. var req *http.Request
  4905. if miConfig.MdtrtareaAdmvs == "320921" {
  4906. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4907. } else {
  4908. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4909. }
  4910. resp, _ := client.Do(req)
  4911. defer resp.Body.Close()
  4912. body, ioErr := ioutil.ReadAll(resp.Body)
  4913. if ioErr != nil {
  4914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4916. return
  4917. }
  4918. var respJSON map[string]interface{}
  4919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4922. return
  4923. }
  4924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4925. userJSONBytes, _ := json.Marshal(respJSON)
  4926. fmt.Println("log")
  4927. fmt.Println(string(userJSONBytes))
  4928. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4929. utils.ErrorLog("解析失败:%v", err)
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4931. return
  4932. }
  4933. res.InfRefmsgid = resFour10265.InfRefmsgid
  4934. res.Output = resFour10265.Output
  4935. res.ErrMsg = resFour10265.ErrMsg
  4936. res.Cainfo = resFour10265.Cainfo
  4937. res.WarnMsg = resFour10265.WarnMsg
  4938. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4939. res.Infcode = infocode
  4940. } else {
  4941. if miConfig.Code == "H15049901371" {
  4942. 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)
  4943. var dat map[string]interface{}
  4944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4945. fmt.Println(dat)
  4946. } else {
  4947. fmt.Println(err)
  4948. }
  4949. saveLog(result, request_log, "2204", "上传费用明细")
  4950. userJSONBytes, _ := json.Marshal(dat)
  4951. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4952. utils.ErrorLog("解析失败:%v", err)
  4953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4954. return
  4955. }
  4956. res.InfRefmsgid = resFour10265.InfRefmsgid
  4957. res.Output = resFour10265.Output
  4958. res.ErrMsg = resFour10265.ErrMsg
  4959. res.Cainfo = resFour10265.Cainfo
  4960. res.WarnMsg = resFour10265.WarnMsg
  4961. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4962. res.Infcode = infocode
  4963. } else {
  4964. 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)
  4965. var dat map[string]interface{}
  4966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4967. fmt.Println(dat)
  4968. } else {
  4969. fmt.Println(err)
  4970. }
  4971. saveLog(result, request_log, "2204", "上传费用明细")
  4972. userJSONBytes, _ := json.Marshal(dat)
  4973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4974. utils.ErrorLog("解析失败:%v", err)
  4975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4976. return
  4977. }
  4978. }
  4979. }
  4980. if res.Infcode == 0 {
  4981. order := &models.HisOrder{
  4982. UserOrgId: adminUser.CurrentOrgId,
  4983. HisPatientId: his.ID,
  4984. PatientId: his.PatientId,
  4985. SettleAccountsDate: recordDateTime,
  4986. MdtrtId: his.Number,
  4987. PsnNo: his.PsnNo,
  4988. MedType: strconv.FormatInt(reg_type, 10),
  4989. Ctime: time.Now().Unix(),
  4990. Mtime: time.Now().Unix(),
  4991. Status: 1,
  4992. Number: chrg_bchno,
  4993. Infcode: res.Infcode,
  4994. WarnMsg: res.WarnMsg,
  4995. Cainfo: res.Cainfo,
  4996. ErrMsg: res.ErrMsg,
  4997. RespondTime: res.RefmsgTime,
  4998. InfRefmsgid: res.InfRefmsgid,
  4999. OrderStatus: 1,
  5000. PayWay: pay_way,
  5001. PayPrice: pay_price,
  5002. PayCardNo: pay_card_no,
  5003. DiscountPrice: discount_price,
  5004. PreferentialPrice: preferential_price,
  5005. RealityPrice: reality_price,
  5006. FoundPrice: found_price,
  5007. MedicalInsurancePrice: medical_insurance_price,
  5008. PrivatePrice: private_price,
  5009. IsMedicineInsurance: 1,
  5010. SettleType: settle_accounts_type,
  5011. SettleStartTime: start_time,
  5012. SettleEndTime: end_time,
  5013. Creator: roles.AdminUserId,
  5014. Modify: roles.AdminUserId,
  5015. FaPiaoNumber: fapiao_number,
  5016. FaPiaoCode: fapiao_code,
  5017. PType: 2,
  5018. Diagnosis: diagnosis_id,
  5019. }
  5020. err = service.CreateOrder(order)
  5021. if err != nil {
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5023. return
  5024. }
  5025. for _, item := range res.Output.Result {
  5026. temp := strings.Split(item.FeedetlSn, "-")
  5027. var advice_id int64 = 0
  5028. var project_id int64 = 0
  5029. var types int64 = 0
  5030. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5031. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5032. if temp[1] == "1" {
  5033. advice_id = id
  5034. project_id = 0
  5035. } else if temp[1] == "2" {
  5036. advice_id = 0
  5037. project_id = id
  5038. }
  5039. info := &models.HisOrderInfo{
  5040. OrderNumber: order.Number,
  5041. FeedetlSn: item.FeedetlSn,
  5042. UploadDate: time.Now().Unix(),
  5043. AdviceId: advice_id,
  5044. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5045. Cnt: item.Cnt,
  5046. Pric: float64(item.Pric),
  5047. PatientId: his.PatientId,
  5048. PricUplmtAmt: item.PricUplmtAmt,
  5049. SelfpayProp: item.SelfpayProp,
  5050. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5051. OverlmtAmt: item.OverlmtAmt,
  5052. PreselfpayAmt: item.PreselfpayAmt,
  5053. BasMednFlag: item.BasMednFlag,
  5054. MedChrgitmType: item.MedChrgitmType,
  5055. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5056. Status: 1,
  5057. Memo: item.Memo,
  5058. Mtime: time.Now().Unix(),
  5059. InscpScpAmt: item.InscpScpAmt,
  5060. DrtReimFlag: item.DrtReimFlag,
  5061. Ctime: time.Now().Unix(),
  5062. ListSpItemFlag: item.ListSpItemFlag,
  5063. ChldMedcFlag: item.ChldMedcFlag,
  5064. LmtUsedFlag: item.LmtUsedFlag,
  5065. ChrgitmLv: item.ChrgitmLv,
  5066. UserOrgId: adminUser.CurrentOrgId,
  5067. HisPatientId: his.ID,
  5068. OrderId: order.ID,
  5069. ProjectId: project_id,
  5070. Type: types,
  5071. }
  5072. service.CreateOrderInfo(info)
  5073. }
  5074. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5075. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5076. var total float64
  5077. for _, item := range prescriptions {
  5078. if item.Type == 1 { //药品
  5079. for _, subItem := range item.HisDoctorAdviceInfo {
  5080. total = total + (subItem.Price * subItem.PrescribingNumber)
  5081. }
  5082. }
  5083. if item.Type == 2 { //项目
  5084. for _, subItem := range item.HisPrescriptionProject {
  5085. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5086. total = total + (subItem.Price * cnt)
  5087. }
  5088. }
  5089. }
  5090. for _, item := range prescriptions {
  5091. for _, subItem := range item.HisAdditionalCharge {
  5092. total = total + (subItem.Price * float64(subItem.Count))
  5093. }
  5094. }
  5095. var allTotal string
  5096. if adminUser.CurrentOrgId == 9919 {
  5097. allTotal = fmt.Sprintf("%.4f", total)
  5098. } else {
  5099. allTotal = fmt.Sprintf("%.4f", total)
  5100. }
  5101. if res.Infcode == 0 {
  5102. var rf []*ResultFive
  5103. json.Unmarshal([]byte(his.Iinfo), &rf)
  5104. chrg_bchno := chrg_bchno
  5105. cert_no := his.Certno
  5106. var insutypes []string
  5107. var insutype string
  5108. var is390 int = 0
  5109. var is310 int = 0
  5110. for _, item := range rf {
  5111. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5112. insutypes = append(insutypes, item.Insutype)
  5113. }
  5114. }
  5115. if len(insutypes) == 1 {
  5116. insutype = insutypes[0]
  5117. } else {
  5118. for _, i := range insutypes {
  5119. if i == "390" {
  5120. is390 = 1
  5121. }
  5122. if i == "310" {
  5123. is310 = 1
  5124. }
  5125. }
  5126. }
  5127. if is390 == 1 {
  5128. insutype = "390"
  5129. }
  5130. if is310 == 1 {
  5131. insutype = "310"
  5132. }
  5133. if len(insutypes) == 0 {
  5134. insutype = "310"
  5135. }
  5136. if len(insutypes) == 2 {
  5137. insutype = strconv.FormatInt(his.SocialType, 10)
  5138. }
  5139. insutype = strconv.FormatInt(his.SocialType, 10)
  5140. //insutype = "390"
  5141. if his.IdCardType == 1 {
  5142. // cert_no = his.MedicalInsuranceNumber
  5143. cert_no = his.Certno
  5144. } else {
  5145. cert_no = his.Certno
  5146. }
  5147. var res ResultSeven
  5148. var resSeven10265 ResultSeven10265
  5149. var src_resquest string
  5150. var result2 string
  5151. var acct_used_flag string
  5152. fmt.Println("pay_way")
  5153. fmt.Println(pay_way)
  5154. fmt.Println("pay_way")
  5155. if pay_way == 4 {
  5156. acct_used_flag = "1"
  5157. } else {
  5158. acct_used_flag = "0"
  5159. }
  5160. if miConfig.MdtrtareaAdmvs == "421300" {
  5161. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5162. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5163. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5164. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5165. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5166. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5167. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5168. resp, requestErr := http.Get(api)
  5169. if requestErr != nil {
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return
  5172. }
  5173. body, ioErr := ioutil.ReadAll(resp.Body)
  5174. if ioErr != nil {
  5175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5177. return
  5178. }
  5179. var respJSON map[string]interface{}
  5180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5183. return
  5184. }
  5185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5186. result, _ := json.Marshal(respJSON)
  5187. if miConfig.Code == "H15049901371" {
  5188. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5189. utils.ErrorLog("解析失败:%v", err)
  5190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5191. return
  5192. }
  5193. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5194. res.Output = resSeven10265.Output
  5195. res.ErrMsg = resSeven10265.ErrMsg
  5196. res.Cainfo = resSeven10265.Cainfo
  5197. res.WarnMsg = resSeven10265.WarnMsg
  5198. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5199. res.Infcode = infocode
  5200. } else {
  5201. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5202. utils.ErrorLog("解析失败:%v", err)
  5203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5204. return
  5205. }
  5206. }
  5207. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5208. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5209. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5210. //psn_info, _ := service.GetPsnByPatientId(id)
  5211. bas := strings.Split(psn_info.CardInfo, "|")
  5212. if his.IdCardType == 1 {
  5213. cert_no = bas[2]
  5214. } else if his.IdCardType == 3 {
  5215. cert_no = his.Certno
  5216. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5217. } else {
  5218. cert_no = bas[1]
  5219. }
  5220. //江苏地区国家医保医疗类别
  5221. //职工透析:医疗类别选特殊情况门诊9933
  5222. //居民血透门慢: 医疗类别选门诊慢病1402
  5223. //var med_type string
  5224. //if his.Insutype == "310" {
  5225. // if reg_type == 14 {
  5226. // med_type = "9933"
  5227. // } else if reg_type == 11 {
  5228. // med_type = "11"
  5229. //
  5230. // }
  5231. //} else if his.Insutype == "390" {
  5232. // if reg_type == 14 {
  5233. // med_type = "1402"
  5234. // } else if reg_type == 11 {
  5235. // med_type = "11"
  5236. // }
  5237. //}
  5238. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5239. var api string
  5240. if miConfig.MdtrtareaAdmvs == "320921" {
  5241. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5242. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5243. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5245. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5246. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5247. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5248. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5249. } else {
  5250. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5251. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5252. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5253. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5254. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5255. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5256. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5257. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5258. }
  5259. resp, requestErr := http.Get(api)
  5260. if requestErr != nil {
  5261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5262. return
  5263. }
  5264. body, ioErr := ioutil.ReadAll(resp.Body)
  5265. if ioErr != nil {
  5266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. return
  5269. }
  5270. var respJSON map[string]interface{}
  5271. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5277. result, _ := json.Marshal(respJSON)
  5278. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5279. utils.ErrorLog("解析失败:%v", err)
  5280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5281. return
  5282. }
  5283. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5284. res.Output = resSeven10265.Output
  5285. res.ErrMsg = resSeven10265.ErrMsg
  5286. res.Cainfo = resSeven10265.Cainfo
  5287. res.WarnMsg = resSeven10265.WarnMsg
  5288. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5289. res.Infcode = infocode
  5290. } else {
  5291. if miConfig.Code == "H15049901371" {
  5292. //赤峰地区国家医保医疗类别
  5293. //职工透析:医疗类别选特殊情况门诊990502
  5294. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5295. var med_type string
  5296. if his.Insutype == "390" {
  5297. if reg_type == 14 {
  5298. med_type = "9933"
  5299. } else if reg_type == 11 {
  5300. med_type = "11"
  5301. }
  5302. } else if his.Insutype == "310" {
  5303. if reg_type == 14 {
  5304. med_type = "990502"
  5305. } else if reg_type == 11 {
  5306. med_type = "11"
  5307. }
  5308. }
  5309. 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)
  5310. } else {
  5311. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5312. }
  5313. //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)
  5314. var dat map[string]interface{}
  5315. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5316. fmt.Println(dat)
  5317. } else {
  5318. fmt.Println(err)
  5319. }
  5320. saveLog(result2, src_resquest, "2207", "结算")
  5321. userJSONBytes, _ := json.Marshal(dat)
  5322. if miConfig.Code == "H15049901371" {
  5323. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5324. utils.ErrorLog("解析失败:%v", err)
  5325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5326. return
  5327. }
  5328. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5329. res.Output = resSeven10265.Output
  5330. res.ErrMsg = resSeven10265.ErrMsg
  5331. res.Cainfo = resSeven10265.Cainfo
  5332. res.WarnMsg = resSeven10265.WarnMsg
  5333. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5334. res.Infcode = infocode
  5335. } else {
  5336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5337. utils.ErrorLog("解析失败:%v", err)
  5338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5339. return
  5340. }
  5341. }
  5342. }
  5343. if res.Infcode != 0 {
  5344. errlog := &models.HisOrderError{
  5345. UserOrgId: adminUser.CurrentOrgId,
  5346. Ctime: time.Now().Unix(),
  5347. Mtime: time.Now().Unix(),
  5348. Number: chrg_bchno,
  5349. ErrMsg: res.ErrMsg,
  5350. Status: 1,
  5351. PatientId: id,
  5352. RecordTime: recordDateTime,
  5353. Stage: 6,
  5354. }
  5355. service.CreateErrMsgLog(errlog)
  5356. c.ServeSuccessJSON(map[string]interface{}{
  5357. "failed_code": -10,
  5358. "msg": res.ErrMsg,
  5359. })
  5360. return
  5361. } else {
  5362. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5363. order.OrderStatus = 2
  5364. order.Status = 1
  5365. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5366. order.SetlId = res.Output.Setlinfo.SetlID
  5367. order.PsnNo = res.Output.Setlinfo.PsnNo
  5368. order.PsnName = res.Output.Setlinfo.PsnName
  5369. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5370. order.Certno = res.Output.Setlinfo.Certno
  5371. order.Gend = res.Output.Setlinfo.Gend
  5372. order.Naty = res.Output.Setlinfo.Naty
  5373. order.Age = res.Output.Setlinfo.Age
  5374. order.Insutype = res.Output.Setlinfo.Insutype
  5375. order.PsnType = res.Output.Setlinfo.PsnType
  5376. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5377. order.SetlTime = res.Output.Setlinfo.SetlTime
  5378. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5379. if res.Output.Setlinfo.MedType == "140101" {
  5380. order.MedType = "14"
  5381. } else {
  5382. order.MedType = res.Output.Setlinfo.MedType
  5383. }
  5384. if reg_type == 1112 {
  5385. order.MedType = "1112"
  5386. }
  5387. if reg_type == 1111 {
  5388. order.MedType = "1111"
  5389. }
  5390. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5391. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5392. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5393. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5394. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5395. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5396. order.HifpPay = res.Output.Setlinfo.HifpPay
  5397. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5398. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5399. order.HifesPay = res.Output.Setlinfo.HifesPay
  5400. order.HifobPay = res.Output.Setlinfo.HifobPay
  5401. order.MafPay = res.Output.Setlinfo.MafPay
  5402. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5403. order.OthPay = res.Output.Setlinfo.OthPay
  5404. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5405. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5406. order.AcctPay = res.Output.Setlinfo.AcctPay
  5407. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5408. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5409. order.Balc = res.Output.Setlinfo.Balc
  5410. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5411. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5412. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5413. order.ClrType = res.Output.Setlinfo.ClrType
  5414. order.ClrWay = res.Output.Setlinfo.ClrWay
  5415. order.Creator = order.Creator
  5416. order.Modify = roles.AdminUserId
  5417. order.RequestLog = src_resquest
  5418. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5419. detailStr := string(setlDetail)
  5420. order.SetlDetail = detailStr
  5421. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5422. err = service.UpDateOrder(order)
  5423. if err == nil {
  5424. c.ServeSuccessJSON(map[string]interface{}{
  5425. "msg": "结算成功",
  5426. })
  5427. } else {
  5428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5429. return
  5430. }
  5431. }
  5432. } else {
  5433. adminUser := c.GetAdminUserInfo()
  5434. errlog := &models.HisOrderError{
  5435. UserOrgId: adminUser.CurrentOrgId,
  5436. Ctime: time.Now().Unix(),
  5437. Mtime: time.Now().Unix(),
  5438. ErrMsg: res.ErrMsg,
  5439. Status: 1,
  5440. PatientId: id,
  5441. RecordTime: recordDateTime,
  5442. Stage: 4,
  5443. }
  5444. service.CreateErrMsgLog(errlog)
  5445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5446. return
  5447. }
  5448. } else {
  5449. adminUser := c.GetAdminUserInfo()
  5450. errlog := &models.HisOrderError{
  5451. UserOrgId: adminUser.CurrentOrgId,
  5452. Ctime: time.Now().Unix(),
  5453. Mtime: time.Now().Unix(),
  5454. ErrMsg: res.ErrMsg,
  5455. Status: 1,
  5456. PatientId: id,
  5457. RecordTime: recordDateTime,
  5458. Stage: 4,
  5459. }
  5460. service.CreateErrMsgLog(errlog)
  5461. c.ServeSuccessJSON(map[string]interface{}{
  5462. "failed_code": -10,
  5463. "msg": res.ErrMsg,
  5464. })
  5465. return
  5466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5467. //return
  5468. }
  5469. }
  5470. }
  5471. } else if tempOrder.ID > 0 {
  5472. if tempOrder.IsPre == 1 {
  5473. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5474. var rf []*ResultFive
  5475. json.Unmarshal([]byte(his.Iinfo), &rf)
  5476. chrg_bchno := tempOrder.Number
  5477. cert_no := his.Certno
  5478. var insutypes []string
  5479. var insutype string
  5480. var is390 int = 0
  5481. var is310 int = 0
  5482. for _, item := range rf {
  5483. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5484. insutypes = append(insutypes, item.Insutype)
  5485. }
  5486. }
  5487. if len(insutypes) == 1 {
  5488. insutype = insutypes[0]
  5489. } else {
  5490. for _, i := range insutypes {
  5491. if i == "390" {
  5492. is390 = 1
  5493. }
  5494. if i == "310" {
  5495. is310 = 1
  5496. }
  5497. }
  5498. }
  5499. if is390 == 1 {
  5500. insutype = "390"
  5501. }
  5502. if is310 == 1 {
  5503. insutype = "310"
  5504. }
  5505. if len(insutypes) == 0 {
  5506. insutype = "310"
  5507. }
  5508. if len(insutypes) == 2 {
  5509. insutype = strconv.FormatInt(his.SocialType, 64)
  5510. }
  5511. //insutype = "390"
  5512. if his.IdCardType == 1 {
  5513. // cert_no = his.MedicalInsuranceNumber
  5514. cert_no = his.Certno
  5515. } else {
  5516. cert_no = his.Certno
  5517. }
  5518. var res ResultSeven
  5519. var resSeven10265 ResultSeven10265
  5520. var src_resquest string
  5521. var result2 string
  5522. var acct_used_flag string
  5523. fmt.Println("pay_way")
  5524. fmt.Println(pay_way)
  5525. fmt.Println("pay_way")
  5526. if pay_way == 4 {
  5527. acct_used_flag = "1"
  5528. } else {
  5529. acct_used_flag = "0"
  5530. }
  5531. if miConfig.MdtrtareaAdmvs == "421300" {
  5532. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5533. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5534. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5535. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5536. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5537. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5538. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5539. resp, requestErr := http.Get(api)
  5540. if requestErr != nil {
  5541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5542. return
  5543. }
  5544. body, ioErr := ioutil.ReadAll(resp.Body)
  5545. if ioErr != nil {
  5546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5548. return
  5549. }
  5550. var respJSON map[string]interface{}
  5551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5557. result, _ := json.Marshal(respJSON)
  5558. fmt.Println("log")
  5559. fmt.Println(string(result))
  5560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5561. utils.ErrorLog("解析失败:%v", err)
  5562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5563. return
  5564. }
  5565. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5566. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5567. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5568. //psn_info, _ := service.GetPsnByPatientId(id)
  5569. bas := strings.Split(psn_info.CardInfo, "|")
  5570. if his.IdCardType == 1 {
  5571. cert_no = bas[2]
  5572. } else {
  5573. cert_no = bas[1]
  5574. }
  5575. //江苏地区国家医保医疗类别
  5576. //职工透析:医疗类别选特殊情况门诊9933
  5577. //居民血透门慢: 医疗类别选门诊慢病1402
  5578. //var med_type string
  5579. //if his.Insutype == "310" {
  5580. // if reg_type == 14 {
  5581. // med_type = "9933"
  5582. // } else if reg_type == 11 {
  5583. // med_type = "11"
  5584. //
  5585. // }
  5586. //} else if his.Insutype == "390" {
  5587. // if reg_type == 14 {
  5588. // med_type = "1402"
  5589. // } else if reg_type == 11 {
  5590. // med_type = "11"
  5591. // }
  5592. //}
  5593. var api string
  5594. if miConfig.MdtrtareaAdmvs == "320921" {
  5595. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5596. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5597. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5598. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5599. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5600. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5601. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5602. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5603. } else {
  5604. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5605. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5606. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5607. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5608. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5609. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5610. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5611. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5612. }
  5613. resp, requestErr := http.Get(api)
  5614. if requestErr != nil {
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. return
  5617. }
  5618. body, ioErr := ioutil.ReadAll(resp.Body)
  5619. if ioErr != nil {
  5620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5622. return
  5623. }
  5624. var respJSON map[string]interface{}
  5625. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5628. return
  5629. }
  5630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5631. result, _ := json.Marshal(respJSON)
  5632. fmt.Println("log")
  5633. fmt.Println(string(result))
  5634. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5635. utils.ErrorLog("解析失败:%v", err)
  5636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5637. return
  5638. }
  5639. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5640. res.Output = resSeven10265.Output
  5641. res.ErrMsg = resSeven10265.ErrMsg
  5642. res.Cainfo = resSeven10265.Cainfo
  5643. res.WarnMsg = resSeven10265.WarnMsg
  5644. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5645. res.Infcode = infocode
  5646. } else {
  5647. var src_resquest string
  5648. if miConfig.Code == "H15049901371" {
  5649. //赤峰地区国家医保医疗类别
  5650. //职工透析:医疗类别选特殊情况门诊990502
  5651. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5652. var med_type string
  5653. if his.Insutype == "390" {
  5654. if reg_type == 14 {
  5655. med_type = "9933"
  5656. } else if reg_type == 11 {
  5657. med_type = "11"
  5658. }
  5659. } else if his.Insutype == "310" {
  5660. if reg_type == 14 {
  5661. med_type = "990502"
  5662. } else if reg_type == 11 {
  5663. med_type = "11"
  5664. }
  5665. }
  5666. 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)
  5667. } else {
  5668. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5669. }
  5670. var dat map[string]interface{}
  5671. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5672. fmt.Println(dat)
  5673. } else {
  5674. fmt.Println(err)
  5675. }
  5676. saveLog(result2, src_resquest, "2207", "结算")
  5677. userJSONBytes, _ := json.Marshal(dat)
  5678. if miConfig.Code == "H15049901371" {
  5679. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5680. utils.ErrorLog("解析失败:%v", err)
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5682. return
  5683. }
  5684. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5685. res.Output = resSeven10265.Output
  5686. res.ErrMsg = resSeven10265.ErrMsg
  5687. res.Cainfo = resSeven10265.Cainfo
  5688. res.WarnMsg = resSeven10265.WarnMsg
  5689. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5690. res.Infcode = infocode
  5691. } else {
  5692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5693. utils.ErrorLog("解析失败:%v", err)
  5694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5695. return
  5696. }
  5697. }
  5698. }
  5699. if res.Infcode != 0 {
  5700. errlog := &models.HisOrderError{
  5701. UserOrgId: adminUser.CurrentOrgId,
  5702. Ctime: time.Now().Unix(),
  5703. Mtime: time.Now().Unix(),
  5704. Number: chrg_bchno,
  5705. ErrMsg: res.ErrMsg,
  5706. Status: 1,
  5707. PatientId: id,
  5708. RecordTime: recordDateTime,
  5709. Stage: 6,
  5710. }
  5711. service.CreateErrMsgLog(errlog)
  5712. c.ServeSuccessJSON(map[string]interface{}{
  5713. "failed_code": -10,
  5714. "msg": res.ErrMsg,
  5715. })
  5716. return
  5717. } else {
  5718. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5719. order.OrderStatus = 2
  5720. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5721. order.SetlId = res.Output.Setlinfo.SetlID
  5722. order.PsnNo = res.Output.Setlinfo.PsnNo
  5723. order.PsnName = res.Output.Setlinfo.PsnName
  5724. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5725. order.Certno = res.Output.Setlinfo.Certno
  5726. order.Gend = res.Output.Setlinfo.Gend
  5727. order.Naty = res.Output.Setlinfo.Naty
  5728. order.Age = res.Output.Setlinfo.Age
  5729. order.Insutype = res.Output.Setlinfo.Insutype
  5730. order.PsnType = res.Output.Setlinfo.PsnType
  5731. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5732. order.SetlTime = res.Output.Setlinfo.SetlTime
  5733. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5734. //order.MedType = res.Output.Setlinfo.MedType
  5735. if reg_type == 1112 {
  5736. order.MedType = "1112"
  5737. }
  5738. if reg_type == 1111 {
  5739. order.MedType = "1111"
  5740. }
  5741. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5742. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5743. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5744. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5745. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5746. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5747. order.HifpPay = res.Output.Setlinfo.HifpPay
  5748. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5749. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5750. order.HifesPay = res.Output.Setlinfo.HifesPay
  5751. order.HifobPay = res.Output.Setlinfo.HifobPay
  5752. order.MafPay = res.Output.Setlinfo.MafPay
  5753. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5754. order.OthPay = res.Output.Setlinfo.OthPay
  5755. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5756. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5757. order.AcctPay = res.Output.Setlinfo.AcctPay
  5758. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5759. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5760. order.Balc = res.Output.Setlinfo.Balc
  5761. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5762. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5763. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5764. order.ClrWay = res.Output.Setlinfo.ClrWay
  5765. order.Creator = order.Creator
  5766. order.Modify = roles.AdminUserId
  5767. order.RequestLog = src_resquest
  5768. order.Diagnosis = diagnosis_id
  5769. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5770. detailStr := string(setlDetail)
  5771. order.SetlDetail = detailStr
  5772. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5773. err = service.UpDateOrder(order)
  5774. if err == nil {
  5775. c.ServeSuccessJSON(map[string]interface{}{
  5776. "msg": "结算成功",
  5777. })
  5778. } else {
  5779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5780. return
  5781. }
  5782. }
  5783. }
  5784. }
  5785. }
  5786. //func (c *HisApiController) GetPreUploadInfo() {
  5787. // id, _ := c.GetInt64("id")
  5788. // record_time := c.GetString("record_time")
  5789. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5790. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5791. //
  5792. // timeLayout := "2006-01-02"
  5793. // loc, _ := time.LoadLocation("Local")
  5794. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5795. // if err != nil {
  5796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5797. // return
  5798. // }
  5799. // recordDateTime := theTime.Unix()
  5800. // adminUser := c.GetAdminUserInfo()
  5801. //
  5802. // var prescriptions []*models.HisPrescription
  5803. //
  5804. // var start_time int64
  5805. // var end_time int64
  5806. //
  5807. // data := make(map[string]interface{})
  5808. // if settle_accounts_type == 1 { //日结
  5809. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5810. // data["pre"] = prescriptions
  5811. //
  5812. // } else { //月结
  5813. // start_time_str := c.GetString("start_time")
  5814. // end_time_str := c.GetString("end_time")
  5815. // timeLayout := "2006-01-02"
  5816. // loc, _ := time.LoadLocation("Local")
  5817. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5818. // if err != nil {
  5819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5820. // return
  5821. // }
  5822. // recordStartTime := theStartTime.Unix()
  5823. // start_time = recordStartTime
  5824. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5825. // if err != nil {
  5826. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5827. // return
  5828. // }
  5829. // recordEndTime := theEndTime.Unix()
  5830. // end_time = recordEndTime
  5831. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5832. // data["pre"] = prescriptions
  5833. //
  5834. // }
  5835. //
  5836. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5837. //
  5838. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5839. // timestamp := time.Now().Unix()
  5840. // tempTime := time.Unix(timestamp, 0)
  5841. // timeFormat := tempTime.Format("20060102150405")
  5842. // chrgBchno := rand.Intn(100000) + 10000
  5843. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5844. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5845. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5846. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5847. // strconv.FormatInt(his.PatientId, 10)
  5848. // client := &http.Client{}
  5849. // data["psn_no"] = his.PsnNo
  5850. // data["mdtrt_id"] = his.Number
  5851. // data["chrg_bchno"] = chrg_bchno
  5852. // data["org_name"] = miConfig.OrgName
  5853. // data["doctor"] = roles.UserName
  5854. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5855. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5856. // data["fixmedins_code"] = miConfig.Code
  5857. // data["dept_code"] = department.Number
  5858. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5859. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5860. // data["secret_key"] = miConfig.SecretKey
  5861. // var ids []int64
  5862. //
  5863. // for _, item := range prescriptions {
  5864. // ids = append(ids, item.ID)
  5865. // }
  5866. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5867. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5868. // bytesData, _ := json.Marshal(data)
  5869. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5870. // resp, _ := client.Do(req)
  5871. // defer resp.Body.Close()
  5872. // body, ioErr := ioutil.ReadAll(resp.Body)
  5873. // if ioErr != nil {
  5874. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5876. // return
  5877. // }
  5878. // var respJSON map[string]interface{}
  5879. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5880. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5882. // return
  5883. // }
  5884. //
  5885. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5886. // userJSONBytes, _ := json.Marshal(respJSON)
  5887. // var res ResultFour
  5888. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5889. // utils.ErrorLog("解析失败:%v", err)
  5890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5891. // return
  5892. // }
  5893. //
  5894. // if res.Infcode == 0 {
  5895. // order := &models.HisOrder{
  5896. // UserOrgId: adminUser.CurrentOrgId,
  5897. // HisPatientId: his.ID,
  5898. // PatientId: his.PatientId,
  5899. // SettleAccountsDate: recordDateTime,
  5900. // Ctime: time.Now().Unix(),
  5901. // Mtime: time.Now().Unix(),
  5902. // Status: 1,
  5903. // Number: chrg_bchno,
  5904. // Infcode: res.Infcode,
  5905. // WarnMsg: res.WarnMsg,
  5906. // Cainfo: res.Cainfo,
  5907. // ErrMsg: res.ErrMsg,
  5908. // RespondTime: res.RefmsgTime,
  5909. // InfRefmsgid: res.InfRefmsgid,
  5910. // OrderStatus: 1,
  5911. // IsMedicineInsurance: 1,
  5912. // SettleType: settle_accounts_type,
  5913. // SettleStartTime: start_time,
  5914. // SettleEndTime: end_time,
  5915. // Creator: roles.ID,
  5916. // Modify: roles.ID,
  5917. // PType: 2,
  5918. // }
  5919. // err = service.CreateOrder(order)
  5920. // if err != nil {
  5921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5922. // return
  5923. // }
  5924. //
  5925. // for _, item := range res.Output.Result {
  5926. // temp := strings.Split(item.FeedetlSn, "-")
  5927. // var advice_id int64 = 0
  5928. // var project_id int64 = 0
  5929. // var types int64 = 0
  5930. //
  5931. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5932. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5933. //
  5934. // if temp[1] == "1" {
  5935. // advice_id = id
  5936. // project_id = 0
  5937. // } else if temp[1] == "2" {
  5938. // advice_id = 0
  5939. // project_id = id
  5940. // }
  5941. //
  5942. // info := &models.HisOrderInfo{
  5943. // OrderNumber: order.Number,
  5944. // FeedetlSn: item.FeedetlSn,
  5945. // UploadDate: time.Now().Unix(),
  5946. // AdviceId: advice_id,
  5947. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5948. // Cnt: item.Cnt,
  5949. // Pric: float64(item.Pric),
  5950. // PatientId: his.PatientId,
  5951. // PricUplmtAmt: item.PricUplmtAmt,
  5952. // SelfpayProp: item.SelfpayProp,
  5953. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5954. // OverlmtAmt: item.OverlmtAmt,
  5955. // PreselfpayAmt: item.PreselfpayAmt,
  5956. // BasMednFlag: item.BasMednFlag,
  5957. // MedChrgitmType: item.MedChrgitmType,
  5958. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5959. // Status: 1,
  5960. // Memo: item.Memo,
  5961. // Mtime: time.Now().Unix(),
  5962. // InscpScpAmt: item.InscpScpAmt,
  5963. // DrtReimFlag: item.DrtReimFlag,
  5964. // Ctime: time.Now().Unix(),
  5965. // ListSpItemFlag: item.ListSpItemFlag,
  5966. // ChldMedcFlag: item.ChldMedcFlag,
  5967. // LmtUsedFlag: item.LmtUsedFlag,
  5968. // ChrgitmLv: item.ChrgitmLv,
  5969. // UserOrgId: adminUser.CurrentOrgId,
  5970. // HisPatientId: his.ID,
  5971. // OrderId: order.ID,
  5972. // ProjectId: project_id,
  5973. // Type: types,
  5974. // }
  5975. // service.CreateOrderInfo(info)
  5976. //
  5977. // }
  5978. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5979. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5980. //
  5981. // var total float64
  5982. // for _, item := range prescriptions {
  5983. // if item.Type == 1 { //药品
  5984. // for _, subItem := range item.HisDoctorAdviceInfo {
  5985. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5986. // }
  5987. // }
  5988. // if item.Type == 2 { //项目
  5989. // for _, subItem := range item.HisPrescriptionProject {
  5990. // total = total + (subItem.Price * float64(subItem.Count))
  5991. // }
  5992. // }
  5993. // }
  5994. //
  5995. // for _, item := range prescriptions {
  5996. // for _, subItem := range item.HisAdditionalCharge {
  5997. // total = total + (subItem.Price * float64(subItem.Count))
  5998. // }
  5999. // }
  6000. //
  6001. // allTotal := fmt.Sprintf("%.2f", total)
  6002. // if res.Infcode == 0 {
  6003. // var rf []*ResultFive
  6004. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6005. // psn_no := his.PsnNo
  6006. // mdtrt_id := his.Number
  6007. // chrg_bchno := chrg_bchno
  6008. // cert_no := his.Certno
  6009. // insutype := rf[0].Insutype
  6010. //
  6011. // if his.IdCardType == 1 {
  6012. // cert_no = his.MedicalInsuranceNumber
  6013. //
  6014. // } else {
  6015. //
  6016. // cert_no = his.Certno
  6017. //
  6018. // }
  6019. //
  6020. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6021. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6022. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6023. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6024. // resp, requestErr := http.Get(api)
  6025. // if requestErr != nil {
  6026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6027. // return
  6028. // }
  6029. // defer resp.Body.Close()
  6030. // body, ioErr := ioutil.ReadAll(resp.Body)
  6031. // if ioErr != nil {
  6032. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6034. // return
  6035. // }
  6036. // var respJSON map[string]interface{}
  6037. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6038. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6040. // return
  6041. // }
  6042. // fmt.Println(respJSON)
  6043. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6044. // userJSONBytes, _ := json.Marshal(respJSON)
  6045. // var res ResultSeven
  6046. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6047. // utils.ErrorLog("解析失败:%v", err)
  6048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6049. // return
  6050. // }
  6051. // if res.Infcode != 0 {
  6052. // errlog := &models.HisOrderError{
  6053. // UserOrgId: adminUser.CurrentOrgId,
  6054. // Ctime: time.Now().Unix(),
  6055. // Mtime: time.Now().Unix(),
  6056. // Number: chrg_bchno,
  6057. // ErrMsg: res.ErrMsg,
  6058. // Status: 1,
  6059. // PatientId: id,
  6060. // RecordTime: recordDateTime,
  6061. // Stage: 7,
  6062. // }
  6063. // service.CreateErrMsgLog(errlog)
  6064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6065. // return
  6066. // } else {
  6067. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6068. // order.OrderStatus = 1
  6069. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6070. // order.SetlId = res.Output.Setlinfo.SetlID
  6071. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6072. // order.PsnName = res.Output.Setlinfo.PsnName
  6073. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6074. // order.Certno = res.Output.Setlinfo.Certno
  6075. // order.Gend = res.Output.Setlinfo.Gend
  6076. // order.Naty = res.Output.Setlinfo.Naty
  6077. // order.Age = res.Output.Setlinfo.Age
  6078. // order.Insutype = res.Output.Setlinfo.Insutype
  6079. // order.PsnType = res.Output.Setlinfo.PsnType
  6080. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6081. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6082. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6083. // order.MedType = res.Output.Setlinfo.MedType
  6084. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6085. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6086. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6087. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6088. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6089. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6090. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6091. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6092. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6093. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6094. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6095. // order.MafPay = res.Output.Setlinfo.MafPay
  6096. // order.OthPay = res.Output.Setlinfo.OthPay
  6097. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6098. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6099. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6100. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6101. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6102. // order.Balc = res.Output.Setlinfo.Balc
  6103. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6104. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6105. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6106. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6107. // order.Creator = order.Creator
  6108. // order.Modify = roles.ID
  6109. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6110. // detailStr := string(setlDetail)
  6111. // order.SetlDetail = detailStr
  6112. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6113. // err = service.UpDateOrder(order)
  6114. // if err == nil {
  6115. // c.ServeSuccessJSON(map[string]interface{}{
  6116. // "msg": "预结算成功",
  6117. // })
  6118. // } else {
  6119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6120. // return
  6121. // }
  6122. // }
  6123. // } else {
  6124. // adminUser := c.GetAdminUserInfo()
  6125. // errlog := &models.HisOrderError{
  6126. // UserOrgId: adminUser.CurrentOrgId,
  6127. // Ctime: time.Now().Unix(),
  6128. // Mtime: time.Now().Unix(),
  6129. // ErrMsg: res.ErrMsg,
  6130. // Status: 1,
  6131. // PatientId: id,
  6132. // RecordTime: recordDateTime,
  6133. // Stage: 4,
  6134. // }
  6135. // service.CreateErrMsgLog(errlog)
  6136. //
  6137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6138. // return
  6139. // }
  6140. // } else {
  6141. // adminUser := c.GetAdminUserInfo()
  6142. // errlog := &models.HisOrderError{
  6143. // UserOrgId: adminUser.CurrentOrgId,
  6144. // Ctime: time.Now().Unix(),
  6145. // Mtime: time.Now().Unix(),
  6146. // ErrMsg: res.ErrMsg,
  6147. // Status: 1,
  6148. // PatientId: id,
  6149. // RecordTime: recordDateTime,
  6150. // Stage: 4,
  6151. // }
  6152. // service.CreateErrMsgLog(errlog)
  6153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6154. // return
  6155. // }
  6156. //
  6157. // } else {
  6158. // var total float64
  6159. // for _, item := range prescriptions {
  6160. // if item.Type == 1 { //药品
  6161. // for _, subItem := range item.HisDoctorAdviceInfo {
  6162. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6163. // }
  6164. // }
  6165. // if item.Type == 2 { //项目
  6166. // for _, subItem := range item.HisPrescriptionProject {
  6167. // total = total + (subItem.Price * float64(subItem.Count))
  6168. // }
  6169. // }
  6170. //
  6171. // for _, subItem := range item.HisAdditionalCharge {
  6172. // total = total + (subItem.Price * float64(subItem.Count))
  6173. // }
  6174. // }
  6175. //
  6176. // allTotal := fmt.Sprintf("%.2f", total)
  6177. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6178. // order := &models.HisOrder{
  6179. // UserOrgId: adminUser.CurrentOrgId,
  6180. // HisPatientId: his.ID,
  6181. // PatientId: id,
  6182. // SettleAccountsDate: recordDateTime,
  6183. // Ctime: time.Now().Unix(),
  6184. // Mtime: time.Now().Unix(),
  6185. // Status: 1,
  6186. // OrderStatus: 2,
  6187. // Number: chrg_bchno,
  6188. // MedfeeSumamt: totals,
  6189. // }
  6190. // err = service.CreateOrder(order)
  6191. // if err != nil {
  6192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6193. // return
  6194. // }
  6195. //
  6196. // var customs []*Custom
  6197. // for _, item := range prescriptions {
  6198. //
  6199. // if item.Type == 1 { //药品
  6200. // for _, subItem := range item.HisDoctorAdviceInfo {
  6201. // cus := &Custom{
  6202. // AdviceId: subItem.ID,
  6203. // ProjectId: 0,
  6204. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6205. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6206. // FeedetlSn: subItem.FeedetlSn,
  6207. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6208. // MedListCodg: subItem.MedListCodg,
  6209. // Type: 1,
  6210. // }
  6211. // customs = append(customs, cus)
  6212. // }
  6213. // }
  6214. //
  6215. // if item.Type == 2 { //项目
  6216. // for _, subItem := range item.HisPrescriptionProject {
  6217. //
  6218. // cus := &Custom{
  6219. // AdviceId: 0,
  6220. // ProjectId: subItem.ID,
  6221. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6222. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6223. // FeedetlSn: subItem.FeedetlSn,
  6224. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6225. // MedListCodg: subItem.MedListCodg,
  6226. // Type: 2,
  6227. // }
  6228. //
  6229. // customs = append(customs, cus)
  6230. // }
  6231. // }
  6232. //
  6233. // for _, item := range item.HisAdditionalCharge {
  6234. // cus := &Custom{
  6235. // ItemId: item.ID,
  6236. // AdviceId: 0,
  6237. // ProjectId: 0,
  6238. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6239. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6240. // FeedetlSn: item.FeedetlSn,
  6241. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6242. // MedListCodg: item.XtHisAddtionConfig.Code,
  6243. // Type: 3,
  6244. // }
  6245. //
  6246. // customs = append(customs, cus)
  6247. // }
  6248. //
  6249. // }
  6250. //
  6251. // for _, item := range customs {
  6252. // var advice_id int64 = 0
  6253. // var project_id int64 = 0
  6254. // var item_id int64 = 0
  6255. //
  6256. // var types int64 = 0
  6257. //
  6258. // if item.Type == 1 {
  6259. // advice_id = item.AdviceId
  6260. // project_id = 0
  6261. // item_id = 0
  6262. // } else if item.Type == 2 {
  6263. // advice_id = 0
  6264. // item_id = 0
  6265. //
  6266. // project_id = item.ProjectId
  6267. // } else if item.Type == 3 {
  6268. // advice_id = 0
  6269. // item_id = item.ItemId
  6270. // project_id = 0
  6271. // }
  6272. //
  6273. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6274. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6275. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6276. //
  6277. // info := &models.HisOrderInfo{
  6278. // OrderNumber: order.Number,
  6279. // UploadDate: time.Now().Unix(),
  6280. // AdviceId: advice_id,
  6281. // DetItemFeeSumamt: detItemFeeSumamt,
  6282. // Cnt: cut,
  6283. // Pric: pric,
  6284. // PatientId: id,
  6285. // Status: 1,
  6286. // Mtime: time.Now().Unix(),
  6287. // Ctime: time.Now().Unix(),
  6288. // UserOrgId: adminUser.CurrentOrgId,
  6289. // HisPatientId: his.ID,
  6290. // OrderId: order.ID,
  6291. // ProjectId: project_id,
  6292. // Type: types,
  6293. // ItemId: item_id,
  6294. // }
  6295. // service.CreateOrderInfo(info)
  6296. // }
  6297. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6298. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6299. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6300. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6301. // if err == nil {
  6302. // c.ServeSuccessJSON(map[string]interface{}{
  6303. // "msg": "结算成功",
  6304. // })
  6305. // } else {
  6306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6307. // return
  6308. // }
  6309. // }
  6310. //}
  6311. //上传明细-预结算-
  6312. func (c *HisApiController) GetPreUploadInfo() {
  6313. id, _ := c.GetInt64("id")
  6314. record_time := c.GetString("record_time")
  6315. his_patient_id, _ := c.GetInt64("his_patient_id")
  6316. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6317. admin_user_id, _ := c.GetInt64("admin_user_id")
  6318. diagnosis_id := c.GetString("diagnosis")
  6319. sick_type, _ := c.GetInt64("sick_type")
  6320. reg_type, _ := c.GetInt64("p_type")
  6321. begin_time := c.GetString("begin_time")
  6322. id_str := c.GetString("ids")
  6323. ids_arr := strings.Split(id_str, ",")
  6324. timeLayout := "2006-01-02"
  6325. loc, _ := time.LoadLocation("Local")
  6326. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6327. if err != nil {
  6328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6329. return
  6330. }
  6331. recordDateTime := theTime.Unix()
  6332. adminUser := c.GetAdminUserInfo()
  6333. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6334. var config []*models.HisXtDiagnoseConfig
  6335. for _, item := range diagnosis_ids {
  6336. id, _ := strconv.ParseInt(item, 10, 64)
  6337. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6338. config = append(config, &diagnosisConfig)
  6339. }
  6340. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6341. sickConfig, _ := service.FindSickById(sick_type)
  6342. var prescriptions []*models.HisPrescription
  6343. var start_time int64
  6344. var end_time int64
  6345. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6346. fmt.Println(his_patient_id)
  6347. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6348. timestamp := time.Now().Unix()
  6349. tempTime := time.Unix(timestamp, 0)
  6350. timeFormat := tempTime.Format("20060102150405")
  6351. chrgBchno := rand.Intn(100000) + 10000
  6352. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6353. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6354. var patientPrescription models.HisPrescriptionInfo
  6355. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6356. if patientPrescription.ID == 0 {
  6357. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6358. }
  6359. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6360. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6361. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6362. strconv.FormatInt(his.PatientId, 10)
  6363. var res2 ResultSix
  6364. var resSix10265 ResultSix10265
  6365. var time_stamp string
  6366. if miConfig.MdtrtareaAdmvs == "421300" {
  6367. data := make(map[string]interface{})
  6368. client := &http.Client{}
  6369. data["psn_no"] = his.PsnNo
  6370. data["mdtrt_id"] = his.Number
  6371. data["doctor"] = roles.UserName
  6372. data["department"] = department.Name
  6373. data["org_name"] = miConfig.OrgName
  6374. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6375. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6376. data["fixmedins_code"] = miConfig.Code
  6377. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6378. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6379. data["secret_key"] = miConfig.SecretKey
  6380. data["sick_code"] = sickConfig.CountryCode
  6381. data["sick_name"] = sickConfig.ClassName
  6382. data["begin_time"] = begin_time
  6383. data["dept"] = strconv.FormatInt(department.ID, 10)
  6384. data["config"] = config
  6385. fmt.Println(data)
  6386. bytesData, _ := json.Marshal(data)
  6387. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6388. resp, _ := client.Do(req)
  6389. defer resp.Body.Close()
  6390. body, ioErr := ioutil.ReadAll(resp.Body)
  6391. if ioErr != nil {
  6392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6394. return
  6395. }
  6396. var respJSON map[string]interface{}
  6397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6400. return
  6401. }
  6402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6403. userJSONBytes, _ := json.Marshal(respJSON)
  6404. fmt.Println("log")
  6405. fmt.Println(string(userJSONBytes))
  6406. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6407. utils.ErrorLog("解析失败:%v", err)
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6409. return
  6410. }
  6411. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6412. //江苏地区国家医保医疗类别
  6413. //职工透析:医疗类别选特殊情况门诊9933
  6414. //居民血透门慢: 医疗类别选门诊慢病1402
  6415. //var med_type string
  6416. //if his.Insutype == "310" {
  6417. // if reg_type == 14 {
  6418. // med_type = "9933"
  6419. // } else if reg_type == 11 {
  6420. // med_type = "11"
  6421. //
  6422. // }
  6423. //} else if his.Insutype == "390" {
  6424. // if reg_type == 14 {
  6425. // med_type = "1402"
  6426. // } else if reg_type == 11 {
  6427. // med_type = "11"
  6428. // }
  6429. //}
  6430. data := make(map[string]interface{})
  6431. client := &http.Client{}
  6432. data["psn_no"] = his.PsnNo
  6433. data["mdtrt_id"] = his.Number
  6434. data["doctor"] = roles.UserName
  6435. data["department"] = department.Name
  6436. data["org_name"] = miConfig.OrgName
  6437. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6438. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6439. data["fixmedins_code"] = miConfig.Code
  6440. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6441. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6442. data["secret_key"] = miConfig.SecretKey
  6443. data["sick_code"] = sickConfig.CountryCode
  6444. data["sick_name"] = sickConfig.ClassName
  6445. data["begin_time"] = begin_time
  6446. data["dept"] = strconv.FormatInt(department.ID, 10)
  6447. data["config"] = config
  6448. data["url"] = miConfig.Url
  6449. data["ak"] = miConfig.AccessKey
  6450. data["cainfo"] = miConfig.Cainfo
  6451. bytesData, _ := json.Marshal(data)
  6452. var req *http.Request
  6453. if miConfig.MdtrtareaAdmvs == "320921" {
  6454. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6455. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6456. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6457. } else {
  6458. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6459. }
  6460. resp, _ := client.Do(req)
  6461. defer resp.Body.Close()
  6462. body, ioErr := ioutil.ReadAll(resp.Body)
  6463. if ioErr != nil {
  6464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6466. return
  6467. }
  6468. var respJSON map[string]interface{}
  6469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6472. return
  6473. }
  6474. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6475. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6476. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6478. userJSONBytes, _ := json.Marshal(respJSON)
  6479. fmt.Println("log")
  6480. fmt.Println(string(userJSONBytes))
  6481. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6482. utils.ErrorLog("解析失败:%v", err)
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6484. return
  6485. }
  6486. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6487. res2.Output = resSix10265.Output
  6488. res2.ErrMsg = resSix10265.ErrMsg
  6489. res2.Cainfo = resSix10265.Cainfo
  6490. res2.WarnMsg = resSix10265.WarnMsg
  6491. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6492. res2.Infcode = infocode
  6493. } else {
  6494. var result string
  6495. var requestLog string
  6496. if miConfig.MdtrtareaAdmvs == "440781" { //
  6497. 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)
  6498. } else {
  6499. if miConfig.Code == "H15049901371" {
  6500. //赤峰地区国家医保医疗类别
  6501. //职工透析:医疗类别选特殊情况门诊990502
  6502. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6503. var med_type string
  6504. if his.Insutype == "390" {
  6505. if reg_type == 14 {
  6506. med_type = "9933"
  6507. } else if reg_type == 11 {
  6508. med_type = "11"
  6509. }
  6510. } else if his.Insutype == "310" {
  6511. if reg_type == 14 {
  6512. med_type = "990502"
  6513. } else if reg_type == 11 {
  6514. med_type = "11"
  6515. }
  6516. }
  6517. 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)
  6518. } else {
  6519. 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)
  6520. }
  6521. saveLog(result, requestLog, "2203", "上传就诊信息")
  6522. var respJSON2 map[string]interface{}
  6523. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. return
  6527. }
  6528. userJSONBytes2, _ := json.Marshal(respJSON2)
  6529. if miConfig.Code == "H15049901371" {
  6530. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6531. utils.ErrorLog("解析失败:%v", err)
  6532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6533. return
  6534. }
  6535. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6536. res2.Output = resSix10265.Output
  6537. res2.ErrMsg = resSix10265.ErrMsg
  6538. res2.Cainfo = resSix10265.Cainfo
  6539. res2.WarnMsg = resSix10265.WarnMsg
  6540. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6541. res2.Infcode = infocode
  6542. } else {
  6543. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6544. utils.ErrorLog("解析失败:%v", err)
  6545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6546. return
  6547. }
  6548. }
  6549. }
  6550. }
  6551. if res2.Infcode != 0 {
  6552. adminUser := c.GetAdminUserInfo()
  6553. errlog := &models.HisOrderError{
  6554. UserOrgId: adminUser.CurrentOrgId,
  6555. Ctime: time.Now().Unix(),
  6556. Mtime: time.Now().Unix(),
  6557. ErrMsg: res2.ErrMsg,
  6558. Status: 1,
  6559. PatientId: id,
  6560. RecordTime: recordDateTime,
  6561. Stage: 3,
  6562. }
  6563. service.CreateErrMsgLog(errlog)
  6564. c.ServeSuccessJSON(map[string]interface{}{
  6565. "failed_code": -10,
  6566. "msg": res2.ErrMsg,
  6567. })
  6568. return
  6569. } else {
  6570. his.Diagnosis = diagnosis_id
  6571. his.SickType = sickConfig.ID
  6572. his.PType = fmt.Sprintf("%d", reg_type)
  6573. service.UpdateHisPatientThree(&his)
  6574. data := make(map[string]interface{})
  6575. if settle_accounts_type == 1 { //日结
  6576. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6577. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6578. } else {
  6579. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6580. }
  6581. data["pre"] = prescriptions
  6582. } else { //月结
  6583. start_time_str := c.GetString("start_time")
  6584. end_time_str := c.GetString("end_time")
  6585. timeLayout := "2006-01-02"
  6586. loc, _ := time.LoadLocation("Local")
  6587. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6588. if err != nil {
  6589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6590. return
  6591. }
  6592. recordStartTime := theStartTime.Unix()
  6593. start_time = recordStartTime
  6594. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6595. if err != nil {
  6596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6597. return
  6598. }
  6599. recordEndTime := theEndTime.Unix()
  6600. end_time = recordEndTime
  6601. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6602. data["pre"] = prescriptions
  6603. }
  6604. client := &http.Client{}
  6605. data["psn_no"] = his.PsnNo
  6606. data["mdtrt_id"] = his.Number
  6607. data["chrg_bchno"] = chrg_bchno
  6608. data["org_name"] = miConfig.OrgName
  6609. data["doctor"] = roles.UserName
  6610. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6611. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6612. data["fixmedins_code"] = miConfig.Code
  6613. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6614. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6615. data["dept_code"] = "15"
  6616. } else {
  6617. data["dept_code"] = department.Number
  6618. }
  6619. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6620. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6621. data["secret_key"] = miConfig.SecretKey
  6622. data["url"] = miConfig.Url
  6623. data["ak"] = miConfig.AccessKey
  6624. data["new_doctor_name"] = patientPrescription.Doctor
  6625. data["diag_code"] = sickConfig.CountryCode
  6626. data["time_stamp"] = time_stamp
  6627. data["cainfo"] = miConfig.Cainfo
  6628. var ids []int64
  6629. for _, item := range prescriptions {
  6630. ids = append(ids, item.ID)
  6631. }
  6632. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6633. if config.IsOpen == 1 { //对接了医保,走医保流程
  6634. var res ResultFour
  6635. var resFour10265 ResultFour10265
  6636. if miConfig.MdtrtareaAdmvs == "421300" {
  6637. bytesData, _ := json.Marshal(data)
  6638. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6639. resp, _ := client.Do(req)
  6640. defer resp.Body.Close()
  6641. body, ioErr := ioutil.ReadAll(resp.Body)
  6642. if ioErr != nil {
  6643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. var respJSON map[string]interface{}
  6648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. return
  6652. }
  6653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6654. userJSONBytes, _ := json.Marshal(respJSON)
  6655. fmt.Println("log")
  6656. fmt.Println(string(userJSONBytes))
  6657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6658. utils.ErrorLog("解析失败:%v", err)
  6659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6660. return
  6661. }
  6662. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6663. bytesData, _ := json.Marshal(data)
  6664. var req *http.Request
  6665. if miConfig.MdtrtareaAdmvs == "320921" {
  6666. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6667. } else {
  6668. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6669. }
  6670. resp, _ := client.Do(req)
  6671. defer resp.Body.Close()
  6672. body, ioErr := ioutil.ReadAll(resp.Body)
  6673. if ioErr != nil {
  6674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6676. return
  6677. }
  6678. var respJSON map[string]interface{}
  6679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6685. userJSONBytes, _ := json.Marshal(respJSON)
  6686. fmt.Println("log")
  6687. fmt.Println(string(userJSONBytes))
  6688. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. res.InfRefmsgid = resFour10265.InfRefmsgid
  6694. res.Output = resFour10265.Output
  6695. res.ErrMsg = resFour10265.ErrMsg
  6696. res.Cainfo = resFour10265.Cainfo
  6697. res.WarnMsg = resFour10265.WarnMsg
  6698. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6699. res.Infcode = infocode
  6700. } else {
  6701. if miConfig.Code == "H15049901371" {
  6702. 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)
  6703. var dat map[string]interface{}
  6704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6705. fmt.Println(dat)
  6706. } else {
  6707. fmt.Println(err)
  6708. }
  6709. saveLog(result, request_log, "2204", "上传费用明细")
  6710. userJSONBytes, _ := json.Marshal(dat)
  6711. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6712. utils.ErrorLog("解析失败:%v", err)
  6713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6714. return
  6715. }
  6716. res.InfRefmsgid = resFour10265.InfRefmsgid
  6717. res.Output = resFour10265.Output
  6718. res.ErrMsg = resFour10265.ErrMsg
  6719. res.Cainfo = resFour10265.Cainfo
  6720. res.WarnMsg = resFour10265.WarnMsg
  6721. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6722. res.Infcode = infocode
  6723. } else {
  6724. 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)
  6725. var dat map[string]interface{}
  6726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6727. fmt.Println(dat)
  6728. } else {
  6729. fmt.Println(err)
  6730. }
  6731. saveLog(result, request_log, "2204", "上传费用明细")
  6732. userJSONBytes, _ := json.Marshal(dat)
  6733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6734. utils.ErrorLog("解析失败:%v", err)
  6735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6736. return
  6737. }
  6738. }
  6739. }
  6740. if res.Infcode == 0 {
  6741. order := &models.HisOrder{
  6742. UserOrgId: adminUser.CurrentOrgId,
  6743. HisPatientId: his.ID,
  6744. PatientId: his.PatientId,
  6745. SettleAccountsDate: recordDateTime,
  6746. Ctime: time.Now().Unix(),
  6747. Mtime: time.Now().Unix(),
  6748. MdtrtId: his.Number,
  6749. PsnNo: his.PsnNo,
  6750. MedType: strconv.FormatInt(reg_type, 10),
  6751. Status: 1,
  6752. Number: chrg_bchno,
  6753. Infcode: res.Infcode,
  6754. WarnMsg: res.WarnMsg,
  6755. Cainfo: res.Cainfo,
  6756. ErrMsg: res.ErrMsg,
  6757. RespondTime: res.RefmsgTime,
  6758. InfRefmsgid: res.InfRefmsgid,
  6759. OrderStatus: 1,
  6760. IsMedicineInsurance: 1,
  6761. SettleType: settle_accounts_type,
  6762. SettleStartTime: start_time,
  6763. SettleEndTime: end_time,
  6764. Creator: roles.AdminUserId,
  6765. Modify: roles.AdminUserId,
  6766. PType: 2,
  6767. Diagnosis: diagnosis_id,
  6768. }
  6769. err = service.CreateOrder(order)
  6770. if err != nil {
  6771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6772. return
  6773. }
  6774. for _, item := range res.Output.Result {
  6775. temp := strings.Split(item.FeedetlSn, "-")
  6776. var advice_id int64 = 0
  6777. var project_id int64 = 0
  6778. var types int64 = 0
  6779. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6780. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6781. if temp[1] == "1" {
  6782. advice_id = id
  6783. project_id = 0
  6784. } else if temp[1] == "2" {
  6785. advice_id = 0
  6786. project_id = id
  6787. }
  6788. info := &models.HisOrderInfo{
  6789. OrderNumber: order.Number,
  6790. FeedetlSn: item.FeedetlSn,
  6791. UploadDate: time.Now().Unix(),
  6792. AdviceId: advice_id,
  6793. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6794. Cnt: item.Cnt,
  6795. Pric: float64(item.Pric),
  6796. PatientId: his.PatientId,
  6797. PricUplmtAmt: item.PricUplmtAmt,
  6798. SelfpayProp: item.SelfpayProp,
  6799. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6800. OverlmtAmt: item.OverlmtAmt,
  6801. PreselfpayAmt: item.PreselfpayAmt,
  6802. BasMednFlag: item.BasMednFlag,
  6803. MedChrgitmType: item.MedChrgitmType,
  6804. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6805. Status: 1,
  6806. Memo: item.Memo,
  6807. Mtime: time.Now().Unix(),
  6808. InscpScpAmt: item.InscpScpAmt,
  6809. DrtReimFlag: item.DrtReimFlag,
  6810. Ctime: time.Now().Unix(),
  6811. ListSpItemFlag: item.ListSpItemFlag,
  6812. ChldMedcFlag: item.ChldMedcFlag,
  6813. LmtUsedFlag: item.LmtUsedFlag,
  6814. ChrgitmLv: item.ChrgitmLv,
  6815. UserOrgId: adminUser.CurrentOrgId,
  6816. HisPatientId: his.ID,
  6817. OrderId: order.ID,
  6818. ProjectId: project_id,
  6819. Type: types,
  6820. }
  6821. service.CreateOrderInfo(info)
  6822. }
  6823. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6824. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6825. var total float64
  6826. for _, item := range prescriptions {
  6827. if item.Type == 1 { //药品
  6828. for _, subItem := range item.HisDoctorAdviceInfo {
  6829. total = total + (subItem.Price * subItem.PrescribingNumber)
  6830. }
  6831. }
  6832. if item.Type == 2 { //项目
  6833. for _, subItem := range item.HisPrescriptionProject {
  6834. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6835. total = total + (subItem.Price * cnt)
  6836. }
  6837. }
  6838. }
  6839. for _, item := range prescriptions {
  6840. for _, subItem := range item.HisAdditionalCharge {
  6841. total = total + (subItem.Price * float64(subItem.Count))
  6842. }
  6843. }
  6844. allTotal := fmt.Sprintf("%.4f", total)
  6845. if res.Infcode == 0 {
  6846. var rf []*ResultFive
  6847. json.Unmarshal([]byte(his.Iinfo), &rf)
  6848. chrg_bchno := chrg_bchno
  6849. cert_no := his.Certno
  6850. var insutypes []string
  6851. var insutype string
  6852. var is390 int = 0
  6853. var is310 int = 0
  6854. for _, item := range rf {
  6855. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6856. insutypes = append(insutypes, item.Insutype)
  6857. }
  6858. }
  6859. if len(insutypes) == 1 {
  6860. insutype = insutypes[0]
  6861. } else {
  6862. for _, i := range insutypes {
  6863. if i == "390" {
  6864. is390 = 1
  6865. }
  6866. if i == "310" {
  6867. is310 = 1
  6868. }
  6869. }
  6870. }
  6871. if is390 == 1 {
  6872. insutype = "390"
  6873. }
  6874. if is310 == 1 {
  6875. insutype = "310"
  6876. }
  6877. if len(insutypes) == 0 {
  6878. insutype = "310"
  6879. }
  6880. if len(insutypes) == 2 {
  6881. insutype = strconv.FormatInt(his.SocialType, 64)
  6882. }
  6883. //insutype = "390"
  6884. if his.IdCardType == 1 {
  6885. cert_no = his.MedicalInsuranceNumber
  6886. } else {
  6887. cert_no = his.Certno
  6888. }
  6889. var res ResultSeven
  6890. var resSeven10265 ResultSeven10265
  6891. if miConfig.MdtrtareaAdmvs == "421300" {
  6892. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6893. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6894. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6895. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6896. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6897. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6898. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6899. resp, requestErr := http.Get(api)
  6900. if requestErr != nil {
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. return
  6903. }
  6904. body, ioErr := ioutil.ReadAll(resp.Body)
  6905. if ioErr != nil {
  6906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. return
  6909. }
  6910. var respJSON map[string]interface{}
  6911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6914. return
  6915. }
  6916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6917. result, _ := json.Marshal(respJSON)
  6918. fmt.Println("log")
  6919. fmt.Println(string(result))
  6920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6921. utils.ErrorLog("解析失败:%v", err)
  6922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6923. return
  6924. }
  6925. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6926. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6927. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6928. bas := strings.Split(psn_info.CardInfo, "|")
  6929. if his.IdCardType == 1 {
  6930. cert_no = bas[2]
  6931. } else {
  6932. cert_no = bas[1]
  6933. }
  6934. //江苏地区国家医保医疗类别
  6935. //职工透析:医疗类别选特殊情况门诊9933
  6936. //居民血透门慢: 医疗类别选门诊慢病1402
  6937. //var med_type string
  6938. //if his.Insutype == "310" {
  6939. // if reg_type == 14 {
  6940. // med_type = "9933"
  6941. // } else if reg_type == 11 {
  6942. // med_type = "11"
  6943. //
  6944. // }
  6945. //} else if his.Insutype == "390" {
  6946. // if reg_type == 14 {
  6947. // med_type = "1402"
  6948. // } else if reg_type == 11 {
  6949. // med_type = "11"
  6950. // }
  6951. //}
  6952. var api string
  6953. if miConfig.MdtrtareaAdmvs == "320921" {
  6954. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6955. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6956. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6958. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6959. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6960. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6961. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6962. } else {
  6963. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6964. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6965. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6966. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6968. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6969. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6970. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6971. }
  6972. resp, requestErr := http.Get(api)
  6973. if requestErr != nil {
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. body, ioErr := ioutil.ReadAll(resp.Body)
  6978. if ioErr != nil {
  6979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. var respJSON map[string]interface{}
  6984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. return
  6988. }
  6989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6990. result, _ := json.Marshal(respJSON)
  6991. fmt.Println("log")
  6992. fmt.Println(string(result))
  6993. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6994. utils.ErrorLog("解析失败:%v", err)
  6995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6996. return
  6997. }
  6998. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6999. res.Output = resSeven10265.Output
  7000. res.ErrMsg = resSeven10265.ErrMsg
  7001. res.Cainfo = resSeven10265.Cainfo
  7002. res.WarnMsg = resSeven10265.WarnMsg
  7003. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7004. res.Infcode = infocode
  7005. } else {
  7006. var result string
  7007. var request_log string
  7008. if miConfig.Code == "H15049901371" {
  7009. //赤峰地区国家医保医疗类别
  7010. //职工透析:医疗类别选特殊情况门诊990502
  7011. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7012. var med_type string
  7013. if his.Insutype == "390" {
  7014. if reg_type == 14 {
  7015. med_type = "9933"
  7016. } else if reg_type == 11 {
  7017. med_type = "11"
  7018. }
  7019. } else if his.Insutype == "310" {
  7020. if reg_type == 14 {
  7021. med_type = "990502"
  7022. } else if reg_type == 11 {
  7023. med_type = "11"
  7024. }
  7025. }
  7026. 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)
  7027. } else {
  7028. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  7029. }
  7030. var dat map[string]interface{}
  7031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7032. fmt.Println(dat)
  7033. } else {
  7034. fmt.Println(err)
  7035. }
  7036. saveLog(result, request_log, "2206", "预结算")
  7037. //userJSONBytes, _ := json.Marshal(dat)
  7038. //
  7039. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7040. // utils.ErrorLog("解析失败:%v", err)
  7041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. // return
  7043. //}
  7044. userJSONBytes, _ := json.Marshal(dat)
  7045. if miConfig.Code == "H15049901371" {
  7046. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7047. utils.ErrorLog("解析失败:%v", err)
  7048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7049. return
  7050. }
  7051. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7052. res.Output = resSeven10265.Output
  7053. res.ErrMsg = resSeven10265.ErrMsg
  7054. res.Cainfo = resSeven10265.Cainfo
  7055. res.WarnMsg = resSeven10265.WarnMsg
  7056. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7057. res.Infcode = infocode
  7058. } else {
  7059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7060. utils.ErrorLog("解析失败:%v", err)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7062. return
  7063. }
  7064. }
  7065. }
  7066. if res.Infcode != 0 {
  7067. errlog := &models.HisOrderError{
  7068. UserOrgId: adminUser.CurrentOrgId,
  7069. Ctime: time.Now().Unix(),
  7070. Mtime: time.Now().Unix(),
  7071. Number: chrg_bchno,
  7072. ErrMsg: res.ErrMsg,
  7073. Status: 1,
  7074. PatientId: id,
  7075. RecordTime: recordDateTime,
  7076. Stage: 20,
  7077. }
  7078. service.CreateErrMsgLog(errlog)
  7079. c.ServeSuccessJSON(map[string]interface{}{
  7080. "failed_code": -10,
  7081. "msg": res.ErrMsg,
  7082. })
  7083. return
  7084. } else {
  7085. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7086. order.OrderStatus = 1
  7087. order.IsPre = 1
  7088. order.Status = 1
  7089. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7090. order.SetlId = res.Output.Setlinfo.SetlID
  7091. order.PsnNo = res.Output.Setlinfo.PsnNo
  7092. order.PsnName = res.Output.Setlinfo.PsnName
  7093. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7094. order.Certno = res.Output.Setlinfo.Certno
  7095. order.Gend = res.Output.Setlinfo.Gend
  7096. order.Naty = res.Output.Setlinfo.Naty
  7097. order.Age = res.Output.Setlinfo.Age
  7098. order.Insutype = res.Output.Setlinfo.Insutype
  7099. order.PsnType = res.Output.Setlinfo.PsnType
  7100. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7101. order.SetlTime = res.Output.Setlinfo.SetlTime
  7102. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7103. if res.Output.Setlinfo.MedType == "140101" {
  7104. order.MedType = "14"
  7105. } else {
  7106. order.MedType = res.Output.Setlinfo.MedType
  7107. }
  7108. if reg_type == 1112 {
  7109. order.MedType = "1112"
  7110. }
  7111. if reg_type == 1111 {
  7112. order.MedType = "1111"
  7113. }
  7114. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7115. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7116. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7117. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7118. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7119. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7120. order.HifpPay = res.Output.Setlinfo.HifpPay
  7121. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7122. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7123. order.HifesPay = res.Output.Setlinfo.HifesPay
  7124. order.HifobPay = res.Output.Setlinfo.HifobPay
  7125. order.MafPay = res.Output.Setlinfo.MafPay
  7126. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7127. order.OthPay = res.Output.Setlinfo.OthPay
  7128. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7129. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7130. order.AcctPay = res.Output.Setlinfo.AcctPay
  7131. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7132. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7133. order.Balc = res.Output.Setlinfo.Balc
  7134. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7135. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7136. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7137. order.ClrWay = res.Output.Setlinfo.ClrWay
  7138. order.Creator = order.Creator
  7139. order.Modify = roles.AdminUserId
  7140. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7141. detailStr := string(setlDetail)
  7142. order.SetlDetail = detailStr
  7143. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7144. err = service.UpDateOrder(order)
  7145. if err == nil {
  7146. c.ServeSuccessJSON(map[string]interface{}{
  7147. "msg": "预结算成功",
  7148. })
  7149. } else {
  7150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7151. return
  7152. }
  7153. }
  7154. } else {
  7155. adminUser := c.GetAdminUserInfo()
  7156. errlog := &models.HisOrderError{
  7157. UserOrgId: adminUser.CurrentOrgId,
  7158. Ctime: time.Now().Unix(),
  7159. Mtime: time.Now().Unix(),
  7160. ErrMsg: res.ErrMsg,
  7161. Status: 1,
  7162. PatientId: id,
  7163. RecordTime: recordDateTime,
  7164. Stage: 4,
  7165. }
  7166. service.CreateErrMsgLog(errlog)
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7168. return
  7169. }
  7170. } else {
  7171. adminUser := c.GetAdminUserInfo()
  7172. errlog := &models.HisOrderError{
  7173. UserOrgId: adminUser.CurrentOrgId,
  7174. Ctime: time.Now().Unix(),
  7175. Mtime: time.Now().Unix(),
  7176. ErrMsg: res.ErrMsg,
  7177. Status: 1,
  7178. PatientId: id,
  7179. RecordTime: recordDateTime,
  7180. Stage: 4,
  7181. }
  7182. service.CreateErrMsgLog(errlog)
  7183. c.ServeSuccessJSON(map[string]interface{}{
  7184. "failed_code": -10,
  7185. "msg": res.ErrMsg,
  7186. })
  7187. return
  7188. }
  7189. }
  7190. }
  7191. }
  7192. //func (c *HisApiController) GetSettleInfo() {
  7193. // id, _ := c.GetInt64("id")
  7194. // order_id, _ := c.GetInt64("order_id")
  7195. //
  7196. // record_time := c.GetString("record_time")
  7197. // pay_way, _ := c.GetInt64("pay_way")
  7198. // pay_price, _ := c.GetFloat("pay_price")
  7199. // pay_card_no := c.GetString("pay_card_no")
  7200. // discount_price, _ := c.GetFloat("discount_price")
  7201. // preferential_price, _ := c.GetFloat("preferential_price")
  7202. // reality_price, _ := c.GetFloat("reality_price")
  7203. // found_price, _ := c.GetFloat("found_price")
  7204. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7205. // private_price, _ := c.GetFloat("private_price")
  7206. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7207. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7208. //
  7209. // timeLayout := "2006-01-02"
  7210. // loc, _ := time.LoadLocation("Local")
  7211. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7212. // if err != nil {
  7213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7214. // return
  7215. // }
  7216. // recordDateTime := theTime.Unix()
  7217. // adminUser := c.GetAdminUserInfo()
  7218. //
  7219. // var prescriptions []*models.HisPrescription
  7220. //
  7221. // data := make(map[string]interface{})
  7222. // if settle_accounts_type == 1 { //日结
  7223. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7224. // data["pre"] = prescriptions
  7225. //
  7226. // } else { //月结
  7227. // start_time_str := c.GetString("start_time")
  7228. // end_time_str := c.GetString("end_time")
  7229. // timeLayout := "2006-01-02"
  7230. // loc, _ := time.LoadLocation("Local")
  7231. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7232. // if err != nil {
  7233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7234. // return
  7235. // }
  7236. // recordStartTime := theStartTime.Unix()
  7237. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7238. // if err != nil {
  7239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7240. // return
  7241. // }
  7242. // recordEndTime := theEndTime.Unix()
  7243. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7244. // data["pre"] = prescriptions
  7245. //
  7246. // }
  7247. //
  7248. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7249. //
  7250. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7251. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7252. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7253. // strconv.FormatInt(his.PatientId, 10)
  7254. //
  7255. // order_src, _ := service.GetHisOrderByID(order_id)
  7256. //
  7257. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7258. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7259. //
  7260. // var total float64
  7261. // for _, item := range prescriptions {
  7262. // if item.Type == 1 { //药品
  7263. // for _, subItem := range item.HisDoctorAdviceInfo {
  7264. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7265. // }
  7266. // }
  7267. // if item.Type == 2 { //项目
  7268. // for _, subItem := range item.HisPrescriptionProject {
  7269. // total = total + (subItem.Price * float64(subItem.Count))
  7270. // }
  7271. // }
  7272. // }
  7273. //
  7274. // for _, item := range prescriptions {
  7275. // for _, subItem := range item.HisAdditionalCharge {
  7276. // total = total + (subItem.Price * float64(subItem.Count))
  7277. // }
  7278. // }
  7279. //
  7280. // allTotal := fmt.Sprintf("%.2f", total)
  7281. // var rf []*ResultFive
  7282. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7283. // psn_no := order_src.PsnNo
  7284. // mdtrt_id := order_src.MdtrtId
  7285. // chrg_bchno := order_src.Number
  7286. // cert_no := order_src.Certno
  7287. // insutype := rf[0].Insutype
  7288. //
  7289. // if his.IdCardType == 1 {
  7290. // cert_no = his.MedicalInsuranceNumber
  7291. // } else {
  7292. // cert_no = his.Certno
  7293. // }
  7294. //
  7295. // 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)
  7296. // var dat map[string]interface{}
  7297. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7298. // fmt.Println(dat)
  7299. // } else {
  7300. // fmt.Println(err)
  7301. // }
  7302. //
  7303. // userJSONBytes, _ := json.Marshal(dat)
  7304. //
  7305. //
  7306. //
  7307. // var res ResultSeven
  7308. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7309. // utils.ErrorLog("解析失败:%v", err)
  7310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7311. // return
  7312. // }
  7313. // if res.Infcode == -1 {
  7314. // errlog := &models.HisOrderError{
  7315. // UserOrgId: adminUser.CurrentOrgId,
  7316. // Ctime: time.Now().Unix(),
  7317. // Mtime: time.Now().Unix(),
  7318. // Number: chrg_bchno,
  7319. // ErrMsg: res.ErrMsg,
  7320. // Status: 1,
  7321. // PatientId: id,
  7322. // RecordTime: recordDateTime,
  7323. // Stage: 6,
  7324. // }
  7325. // service.CreateErrMsgLog(errlog)
  7326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7327. // return
  7328. // } else {
  7329. // order_src.OrderStatus = 2
  7330. // order_src.PayWay = pay_way
  7331. // order_src.PayPrice = pay_price
  7332. // order_src.PayCardNo = pay_card_no
  7333. // order_src.DiscountPrice = discount_price
  7334. // order_src.PreferentialPrice = preferential_price
  7335. // order_src.RealityPrice = reality_price
  7336. // order_src.FoundPrice = found_price
  7337. // order_src.MedicalInsurancePrice = medical_insurance_price
  7338. // order_src.PrivatePrice = private_price
  7339. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7340. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7341. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7342. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7343. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7344. // order_src.Certno = res.Output.Setlinfo.Certno
  7345. // order_src.Gend = res.Output.Setlinfo.Gend
  7346. // order_src.Naty = res.Output.Setlinfo.Naty
  7347. // order_src.Age = res.Output.Setlinfo.Age
  7348. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7349. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7350. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7351. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7352. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7353. // order_src.MedType = res.Output.Setlinfo.MedType
  7354. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7355. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7356. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7357. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7358. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7359. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7360. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7361. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7362. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7363. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7364. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7365. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7366. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7367. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7368. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7369. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7370. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7371. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7372. // order_src.Balc = res.Output.Setlinfo.Balc
  7373. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7374. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7375. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7376. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7377. // order_src.Creator = order_src.Creator
  7378. // order_src.Modify = roles.ID
  7379. // order_src.RequestLog = src_resquest
  7380. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7381. // detailStr := string(setlDetail)
  7382. // order_src.SetlDetail = detailStr
  7383. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7384. // err = service.UpDateOrder(order_src)
  7385. //
  7386. // if err == nil {
  7387. // c.ServeSuccessJSON(map[string]interface{}{
  7388. // "msg": "结算成功",
  7389. // })
  7390. // } else {
  7391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7392. // return
  7393. // }
  7394. // }
  7395. // }
  7396. //}
  7397. //退款
  7398. func (c *HisApiController) Refund() {
  7399. order_id, _ := c.GetInt64("order_id")
  7400. admin_user_id, _ := c.GetInt64("admin_user_id")
  7401. adminUser := c.GetAdminUserInfo()
  7402. var order models.HisOrder
  7403. order, _ = service.GetHisOrderByID(order_id)
  7404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7405. if order.ID == 0 {
  7406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7407. return
  7408. }
  7409. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7410. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7411. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7412. if config.IsOpen == 1 { //对接了医保,走医保流程
  7413. var res ResultSixteen
  7414. var resSixteen10265 ResultSixteen10265
  7415. var src_resquest string
  7416. var result string
  7417. if miConfig.MdtrtareaAdmvs == "421300" {
  7418. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7419. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7420. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7421. resp3, requestErr3 := http.Get(api3)
  7422. if requestErr3 != nil {
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. return
  7425. }
  7426. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7427. if ioErr3 != nil {
  7428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. return
  7431. }
  7432. var respJSON3 map[string]interface{}
  7433. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7436. return
  7437. }
  7438. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7439. userJSONBytes3, _ := json.Marshal(respJSON3)
  7440. fmt.Println("log")
  7441. fmt.Println(string(userJSONBytes3))
  7442. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7443. utils.ErrorLog("解析失败:%v", err)
  7444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7445. return
  7446. }
  7447. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7448. var api3 string
  7449. if miConfig.MdtrtareaAdmvs == "320921" {
  7450. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7451. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7452. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7453. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7454. } else {
  7455. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7456. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7457. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7458. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7459. }
  7460. resp3, requestErr3 := http.Get(api3)
  7461. if requestErr3 != nil {
  7462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7463. return
  7464. }
  7465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7466. if ioErr3 != nil {
  7467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. var respJSON3 map[string]interface{}
  7472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7478. userJSONBytes3, _ := json.Marshal(respJSON3)
  7479. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7480. utils.ErrorLog("解析失败:%v", err)
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7482. return
  7483. }
  7484. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7485. res.Output = resSixteen10265.Output
  7486. res.ErrMsg = resSixteen10265.ErrMsg
  7487. res.Cainfo = resSixteen10265.Cainfo
  7488. res.WarnMsg = resSixteen10265.WarnMsg
  7489. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7490. res.Infcode = infocode
  7491. } else {
  7492. if miConfig.Code == "H15049901371" {
  7493. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7494. var dat map[string]interface{}
  7495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7496. fmt.Println(dat)
  7497. } else {
  7498. fmt.Println(err)
  7499. }
  7500. saveLog(result, src_resquest, "2208", "退费")
  7501. userJSONBytes, _ := json.Marshal(dat)
  7502. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7503. utils.ErrorLog("解析失败:%v", err)
  7504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. return
  7506. }
  7507. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7508. res.Output = resSixteen10265.Output
  7509. res.ErrMsg = resSixteen10265.ErrMsg
  7510. res.Cainfo = resSixteen10265.Cainfo
  7511. res.WarnMsg = resSixteen10265.WarnMsg
  7512. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7513. res.Infcode = infocode
  7514. } else {
  7515. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7516. var dat map[string]interface{}
  7517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7518. fmt.Println(dat)
  7519. } else {
  7520. fmt.Println(err)
  7521. }
  7522. saveLog(result, src_resquest, "2208", "退费")
  7523. userJSONBytes, _ := json.Marshal(dat)
  7524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7525. utils.ErrorLog("解析失败:%v", err)
  7526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7527. return
  7528. }
  7529. }
  7530. }
  7531. if res.Infcode == 0 {
  7532. var res2 ResultSix
  7533. var resSix10265 ResultSix10265
  7534. if miConfig.MdtrtareaAdmvs == "421300" {
  7535. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7536. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7537. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7538. resp3, requestErr3 := http.Get(api3)
  7539. if requestErr3 != nil {
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7544. if ioErr3 != nil {
  7545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. var respJSON3 map[string]interface{}
  7550. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7556. userJSONBytes3, _ := json.Marshal(respJSON3)
  7557. fmt.Println("log")
  7558. fmt.Println(string(userJSONBytes3))
  7559. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7560. utils.ErrorLog("解析失败:%v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. return
  7563. }
  7564. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7565. var api3 string
  7566. if miConfig.MdtrtareaAdmvs == "320921" {
  7567. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7568. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7569. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7570. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7571. } else {
  7572. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7573. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7574. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7575. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7576. }
  7577. resp3, requestErr3 := http.Get(api3)
  7578. if requestErr3 != nil {
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. return
  7581. }
  7582. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7583. if ioErr3 != nil {
  7584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7586. return
  7587. }
  7588. var respJSON3 map[string]interface{}
  7589. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7592. return
  7593. }
  7594. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7595. userJSONBytes3, _ := json.Marshal(respJSON3)
  7596. fmt.Println("log")
  7597. fmt.Println(string(userJSONBytes3))
  7598. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7599. utils.ErrorLog("解析失败:%v", err)
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7601. return
  7602. }
  7603. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7604. res2.Output = resSix10265.Output
  7605. res2.ErrMsg = resSix10265.ErrMsg
  7606. res2.Cainfo = resSix10265.Cainfo
  7607. res2.WarnMsg = resSix10265.WarnMsg
  7608. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7609. res2.Infcode = infocode
  7610. } else {
  7611. if miConfig.Code == "H15049901371" {
  7612. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7613. var dat map[string]interface{}
  7614. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7615. fmt.Println(dat)
  7616. } else {
  7617. fmt.Println(err)
  7618. }
  7619. saveLog(result2, src_request, "2205", "撤销明细")
  7620. userJSONBytes, _ := json.Marshal(dat)
  7621. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7622. utils.ErrorLog("解析失败:%v", err)
  7623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7624. return
  7625. }
  7626. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7627. res2.Output = resSix10265.Output
  7628. res2.ErrMsg = resSix10265.ErrMsg
  7629. res2.Cainfo = resSix10265.Cainfo
  7630. res2.WarnMsg = resSix10265.WarnMsg
  7631. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7632. res2.Infcode = infocode
  7633. } else {
  7634. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7635. var dat map[string]interface{}
  7636. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7637. fmt.Println(dat)
  7638. } else {
  7639. fmt.Println(err)
  7640. }
  7641. saveLog(result2, src_request, "2205", "撤销明细")
  7642. userJSONBytes, _ := json.Marshal(dat)
  7643. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7644. utils.ErrorLog("解析失败:%v", err)
  7645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7646. return
  7647. }
  7648. }
  7649. }
  7650. if res2.Infcode == 0 {
  7651. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7652. if err == nil {
  7653. c.ServeSuccessJSON(map[string]interface{}{
  7654. "msg": "退费成功",
  7655. })
  7656. } else {
  7657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7658. return
  7659. }
  7660. } else {
  7661. c.ServeSuccessJSON(map[string]interface{}{
  7662. "code": -10,
  7663. "msg": res2.ErrMsg,
  7664. })
  7665. }
  7666. } else {
  7667. c.ServeSuccessJSON(map[string]interface{}{
  7668. "code": -10,
  7669. "msg": res.ErrMsg,
  7670. })
  7671. }
  7672. }
  7673. }
  7674. func (c *HisApiController) RefundNumber() {
  7675. record_time := c.GetString("record_time")
  7676. //patient_id, _ := c.GetInt64("patient_id")
  7677. admin_user_id, _ := c.GetInt64("admin_user_id")
  7678. his_patient_id, _ := c.GetInt64("id")
  7679. timeLayout := "2006-01-02"
  7680. loc, _ := time.LoadLocation("Local")
  7681. adminUser := c.GetAdminUserInfo()
  7682. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7683. fmt.Println(err)
  7684. if err != nil {
  7685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7686. return
  7687. }
  7688. recordDateTime := theTime.Unix()
  7689. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7690. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7691. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7692. //order, _ := service.GetHisOrderByID(order_id)
  7693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7694. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7695. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7696. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7697. if count > 0 {
  7698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7699. return
  7700. }
  7701. if config.IsOpen == 1 { //对接了医保,走医保流程
  7702. var res2 ResultSix
  7703. var resSix10265 ResultSix10265
  7704. if miConfig.MdtrtareaAdmvs == "421300" {
  7705. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7706. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7708. resp3, requestErr3 := http.Get(api3)
  7709. if requestErr3 != nil {
  7710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7711. return
  7712. }
  7713. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7714. if ioErr3 != nil {
  7715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. var respJSON3 map[string]interface{}
  7720. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7723. return
  7724. }
  7725. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7726. userJSONBytes3, _ := json.Marshal(respJSON3)
  7727. fmt.Println("log")
  7728. fmt.Println(string(userJSONBytes3))
  7729. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7730. utils.ErrorLog("解析失败:%v", err)
  7731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7732. return
  7733. }
  7734. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7735. var api3 string
  7736. if miConfig.MdtrtareaAdmvs == "320921" {
  7737. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7738. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7740. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7741. } else {
  7742. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7743. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7744. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7745. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7746. }
  7747. resp3, requestErr3 := http.Get(api3)
  7748. if requestErr3 != nil {
  7749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7750. return
  7751. }
  7752. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7753. if ioErr3 != nil {
  7754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. var respJSON3 map[string]interface{}
  7759. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7762. return
  7763. }
  7764. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7765. userJSONBytes3, _ := json.Marshal(respJSON3)
  7766. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7767. utils.ErrorLog("解析失败:%v", err)
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7769. return
  7770. }
  7771. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7772. res2.Output = resSix10265.Output
  7773. res2.ErrMsg = resSix10265.ErrMsg
  7774. res2.Cainfo = resSix10265.Cainfo
  7775. res2.WarnMsg = resSix10265.WarnMsg
  7776. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7777. res2.Infcode = infocode
  7778. } else {
  7779. var api3 string
  7780. if miConfig.Code == "H15049901371" {
  7781. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7782. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7784. } else {
  7785. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7786. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7788. }
  7789. resp3, requestErr3 := http.Get(api3)
  7790. if requestErr3 != nil {
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7795. if ioErr3 != nil {
  7796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. var respJSON3 map[string]interface{}
  7801. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. return
  7805. }
  7806. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7807. userJSONBytes3, _ := json.Marshal(respJSON3)
  7808. if miConfig.Code == "H15049901371" {
  7809. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7810. utils.ErrorLog("解析失败:%v", err)
  7811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7812. return
  7813. }
  7814. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7815. res2.Output = resSix10265.Output
  7816. res2.ErrMsg = resSix10265.ErrMsg
  7817. res2.Cainfo = resSix10265.Cainfo
  7818. res2.WarnMsg = resSix10265.WarnMsg
  7819. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7820. res2.Infcode = infocode
  7821. } else {
  7822. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7823. utils.ErrorLog("解析失败:%v", err)
  7824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7825. return
  7826. }
  7827. }
  7828. }
  7829. if res2.Infcode == 0 {
  7830. if err == nil {
  7831. c.ServeSuccessJSON(map[string]interface{}{
  7832. "msg": "退号成功",
  7833. })
  7834. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7835. } else {
  7836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7837. return
  7838. }
  7839. } else {
  7840. c.ServeSuccessJSON(map[string]interface{}{
  7841. "code": -10,
  7842. "msg": res2.ErrMsg,
  7843. })
  7844. }
  7845. } else {
  7846. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7847. //if err == nil {
  7848. // c.ServeSuccessJSON(map[string]interface{}{
  7849. // "msg": "退费成功",
  7850. // })
  7851. //} else {
  7852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7853. // return
  7854. //}
  7855. }
  7856. }
  7857. func (c *HisApiController) RefundDetail() {
  7858. order_id, _ := c.GetInt64("order_id")
  7859. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7860. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7861. number := c.GetString("number")
  7862. record_time := c.GetString("record_time")
  7863. patient_id, _ := c.GetInt64("patient_id")
  7864. //med_type, _ := c.GetInt64("med_type")
  7865. timeLayout := "2006-01-02"
  7866. loc, _ := time.LoadLocation("Local")
  7867. adminUser := c.GetAdminUserInfo()
  7868. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7869. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7870. fmt.Println(err)
  7871. if err != nil {
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7873. return
  7874. }
  7875. recordDateTime := theTime.Unix()
  7876. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7877. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7878. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7879. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7880. var order models.HisOrder
  7881. order, _ = service.GetHisOrderByID(order_id)
  7882. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7883. if config.IsOpen == 1 { //对接了医保,走医保流程
  7884. var res2 ResultSix
  7885. if miConfig.MdtrtareaAdmvs == "421300" {
  7886. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7887. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7889. resp3, requestErr3 := http.Get(api3)
  7890. if requestErr3 != nil {
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7895. if ioErr3 != nil {
  7896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. var respJSON3 map[string]interface{}
  7901. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7907. userJSONBytes3, _ := json.Marshal(respJSON3)
  7908. fmt.Println("log")
  7909. fmt.Println(string(userJSONBytes3))
  7910. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7911. utils.ErrorLog("解析失败:%v", err)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7916. if err == nil {
  7917. c.ServeSuccessJSON(map[string]interface{}{
  7918. "msg": "撤销明细成功",
  7919. })
  7920. return
  7921. } else {
  7922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7923. return
  7924. }
  7925. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7926. var resSix10265 ResultSix10265
  7927. var api3 string
  7928. if miConfig.MdtrtareaAdmvs == "320921" {
  7929. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7930. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7932. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7933. } else {
  7934. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7935. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7936. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7938. }
  7939. resp3, requestErr3 := http.Get(api3)
  7940. if requestErr3 != nil {
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7945. if ioErr3 != nil {
  7946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. var respJSON3 map[string]interface{}
  7951. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7954. return
  7955. }
  7956. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7957. userJSONBytes3, _ := json.Marshal(respJSON3)
  7958. fmt.Println("log")
  7959. fmt.Println(string(userJSONBytes3))
  7960. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7961. utils.ErrorLog("解析失败:%v", err)
  7962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7963. return
  7964. }
  7965. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7966. res2.Output = resSix10265.Output
  7967. res2.ErrMsg = resSix10265.ErrMsg
  7968. res2.Cainfo = resSix10265.Cainfo
  7969. res2.WarnMsg = resSix10265.WarnMsg
  7970. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7971. res2.Infcode = infocode
  7972. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7973. if err == nil {
  7974. c.ServeSuccessJSON(map[string]interface{}{
  7975. "msg": "撤销明细成功",
  7976. })
  7977. return
  7978. } else {
  7979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7980. return
  7981. }
  7982. } else {
  7983. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7984. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7985. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7986. resp2, requestErr2 := http.Get(api2)
  7987. if requestErr2 != nil {
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7989. return
  7990. }
  7991. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7992. if ioErr2 != nil {
  7993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7995. return
  7996. }
  7997. var respJSON2 map[string]interface{}
  7998. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8004. if err == nil {
  8005. c.ServeSuccessJSON(map[string]interface{}{
  8006. "msg": "撤销明细成功",
  8007. })
  8008. return
  8009. } else {
  8010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8011. return
  8012. }
  8013. }
  8014. } else {
  8015. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8016. if err == nil {
  8017. c.ServeSuccessJSON(map[string]interface{}{
  8018. "msg": "退费成功",
  8019. })
  8020. } else {
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. }
  8025. }
  8026. //对账
  8027. func (c *HisApiController) GetCheckAccount() {
  8028. start_time := c.GetString("start_time")
  8029. end_time := c.GetString("end_time")
  8030. insutype := c.GetString("insutype")
  8031. clr_type := c.GetString("clr_type")
  8032. clr_org := c.GetString("clr_optins")
  8033. admin_user_id, _ := c.GetInt64("admin_user_id")
  8034. adminUser := c.GetAdminUserInfo()
  8035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8036. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8037. if len(clr_org) == 0 {
  8038. clr_org = miConfig.MdtrtareaAdmvs
  8039. }
  8040. timeLayout := "2006-01-02"
  8041. loc, _ := time.LoadLocation("Local")
  8042. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8043. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8044. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  8045. fixmedins_setl_cnt := int64(len(orders))
  8046. var medfee_sumamt float64
  8047. var acct_pay float64
  8048. var fund_pay_sumamt float64
  8049. for _, item := range orders {
  8050. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8051. acct_pay = acct_pay + item.AcctPay
  8052. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8053. }
  8054. var user_name string
  8055. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8056. if role.ID == 0 {
  8057. user_name = "xxx"
  8058. } else {
  8059. user_name = role.UserName
  8060. }
  8061. var res ResultEight
  8062. var res10188 ResultEightFor10188
  8063. if config.IsOpen == 1 {
  8064. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8065. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8066. "insutype=" + insutype +
  8067. "&clr_type=" + "11" +
  8068. "&setl_optins=" + clr_org +
  8069. "&stmt_begndate=" + start_time +
  8070. "&stm_enddate=" + end_time +
  8071. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8072. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8073. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8074. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8075. "&fixmedins_code=" + miConfig.Code +
  8076. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8077. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8078. "&secret_key=" + miConfig.SecretKey +
  8079. "&org_name=" + miConfig.OrgName +
  8080. "&doctor=" + user_name +
  8081. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8082. fmt.Println(api)
  8083. resp, requestErr := http.Get(api)
  8084. if requestErr != nil {
  8085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8086. return
  8087. }
  8088. body, ioErr := ioutil.ReadAll(resp.Body)
  8089. fmt.Println(body)
  8090. if ioErr != nil {
  8091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. return
  8094. }
  8095. var respJSON map[string]interface{}
  8096. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8102. userJSONBytes, _ := json.Marshal(respJSON)
  8103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8104. utils.ErrorLog("解析失败:%v", err)
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8106. return
  8107. }
  8108. res.InfRefmsgid = res10188.InfRefmsgid
  8109. res.Output = res10188.Output
  8110. res.ErrMsg = res10188.ErrMsg
  8111. res.Cainfo = res10188.Cainfo
  8112. res.WarnMsg = res10188.WarnMsg
  8113. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8114. res.Infcode = infocode
  8115. } else {
  8116. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8117. "insutype=" + insutype +
  8118. "&clr_type=" + clr_type +
  8119. "&setl_optins=" + clr_org +
  8120. "&stmt_begndate=" + start_time +
  8121. "&stm_enddate=" + end_time +
  8122. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8123. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8124. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8125. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8126. "&fixmedins_code=" + miConfig.Code +
  8127. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8128. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8129. "&secret_key=" + miConfig.SecretKey +
  8130. "&org_name=" + miConfig.OrgName +
  8131. "&doctor=" + user_name
  8132. fmt.Println(api)
  8133. resp, requestErr := http.Get(api)
  8134. if requestErr != nil {
  8135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. return
  8137. }
  8138. body, ioErr := ioutil.ReadAll(resp.Body)
  8139. fmt.Println(body)
  8140. if ioErr != nil {
  8141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. var respJSON map[string]interface{}
  8146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8149. return
  8150. }
  8151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8152. userJSONBytes, _ := json.Marshal(respJSON)
  8153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8154. utils.ErrorLog("解析失败:%v", err)
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. }
  8159. if res.Infcode == 0 {
  8160. if res.Output.Stmtinfo.StmtRslt == "0" {
  8161. micc := &models.MedicalInsuranceCostCompare{
  8162. StartTime: startime.Unix(),
  8163. EndTime: endtime.Unix(),
  8164. Insutype: insutype,
  8165. CheckType: 1,
  8166. Num: fixmedins_setl_cnt,
  8167. Mtime: time.Now().Unix(),
  8168. Status: 1,
  8169. UserOrgId: adminUser.CurrentOrgId,
  8170. CostTotal: medfee_sumamt,
  8171. FuncTotal: fund_pay_sumamt,
  8172. PsnPay: acct_pay,
  8173. Creator: admin_user_id,
  8174. Ctime: time.Now().Unix(),
  8175. ClrType: clr_type,
  8176. }
  8177. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8178. if err == nil {
  8179. c.ServeSuccessJSON(map[string]interface{}{
  8180. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8181. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8182. })
  8183. } else {
  8184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8185. }
  8186. } else {
  8187. c.ServeSuccessJSON(map[string]interface{}{
  8188. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8189. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8190. })
  8191. }
  8192. } else {
  8193. c.ServeSuccessJSON(map[string]interface{}{
  8194. "code": -10,
  8195. "msg": res.ErrMsg,
  8196. })
  8197. }
  8198. }
  8199. }
  8200. func (c *HisApiController) Check310() {
  8201. adminUser := c.GetAdminUserInfo()
  8202. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8203. var user_name string
  8204. user_name = "高慧裕"
  8205. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8206. "insutype=" + "310" +
  8207. "&clr_type=" + "" +
  8208. "&setl_optins=" + "441202" +
  8209. "&stmt_begndate=" + "2022-03-01" +
  8210. "&stm_enddate=" + "2022-03-31" +
  8211. "&medfee_sumamt=" + "194930.12" +
  8212. "&fund_pay_sumamt=" + "188741.46" +
  8213. "&acct_pay=" + "0" +
  8214. "&fixmedins_setl_cnt=" + "452" +
  8215. "&fixmedins_code=" + miConfig.Code +
  8216. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8217. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8218. "&secret_key=" + miConfig.SecretKey +
  8219. "&org_name=" + miConfig.OrgName +
  8220. "&doctor=" + user_name
  8221. fmt.Println(api)
  8222. resp, requestErr := http.Get(api)
  8223. if requestErr != nil {
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. body, ioErr := ioutil.ReadAll(resp.Body)
  8228. fmt.Println(body)
  8229. if ioErr != nil {
  8230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8232. return
  8233. }
  8234. var respJSON map[string]interface{}
  8235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8238. return
  8239. }
  8240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8241. userJSONBytes, _ := json.Marshal(respJSON)
  8242. var res ResultEight
  8243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8244. utils.ErrorLog("解析失败:%v", err)
  8245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8246. return
  8247. }
  8248. }
  8249. func (c *HisApiController) Check390() {
  8250. adminUser := c.GetAdminUserInfo()
  8251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8252. var user_name string
  8253. user_name = "高慧裕"
  8254. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8255. "insutype=" + "390" +
  8256. "&clr_type=" + "" +
  8257. "&setl_optins=" + "441202" +
  8258. "&stmt_begndate=" + "2022-03-01" +
  8259. "&stm_enddate=" + "2022-03-31" +
  8260. "&medfee_sumamt=" + "1068448.89" +
  8261. "&fund_pay_sumamt=" + "1014677.62" +
  8262. "&acct_pay=" + "0" +
  8263. "&fixmedins_setl_cnt=" + "1950" +
  8264. "&fixmedins_code=" + miConfig.Code +
  8265. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8266. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8267. "&secret_key=" + miConfig.SecretKey +
  8268. "&org_name=" + miConfig.OrgName +
  8269. "&doctor=" + user_name
  8270. fmt.Println(api)
  8271. resp, requestErr := http.Get(api)
  8272. if requestErr != nil {
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. body, ioErr := ioutil.ReadAll(resp.Body)
  8277. fmt.Println(body)
  8278. if ioErr != nil {
  8279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8281. return
  8282. }
  8283. var respJSON map[string]interface{}
  8284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8287. return
  8288. }
  8289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8290. userJSONBytes, _ := json.Marshal(respJSON)
  8291. var res ResultEight
  8292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8293. utils.ErrorLog("解析失败:%v", err)
  8294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8295. return
  8296. }
  8297. }
  8298. //对账明细
  8299. func (c *HisApiController) GetCheckDetailAccount() {
  8300. start_time := c.GetString("start_time")
  8301. end_time := c.GetString("end_time")
  8302. admin_user_id, _ := c.GetInt64("admin_user_id")
  8303. adminUser := c.GetAdminUserInfo()
  8304. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8305. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8306. timeLayout := "2006-01-02"
  8307. loc, _ := time.LoadLocation("Local")
  8308. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8309. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8310. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8311. Mkdir(miConfig.OrgName)
  8312. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8313. file_name := file + ".txt"
  8314. zip_name := file + ".zip"
  8315. zip_path := miConfig.OrgName + "/" + zip_name
  8316. file_path := miConfig.OrgName + "/" + file_name
  8317. decimal.DivisionPrecision = 2
  8318. var medfee_sumamt float64
  8319. var psn_cash_pay float64
  8320. var fund_pay_sumamt float64
  8321. fixmedins_setl_cnt := int64(len(orders))
  8322. for _, item := range orders {
  8323. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8324. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8325. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8326. }
  8327. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8328. defer f.Close()
  8329. if err != nil {
  8330. fmt.Println(err.Error())
  8331. } else {
  8332. for _, item := range orders {
  8333. var refd_setl_flag string
  8334. if item.OrderStatus == 2 {
  8335. refd_setl_flag = "0"
  8336. var str string
  8337. str = item.SetlId + " " +
  8338. item.MdtrtId + " " +
  8339. item.PsnNo + " " +
  8340. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8341. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8342. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8343. _, err = f.Write([]byte(str))
  8344. }
  8345. if item.OrderStatus == 3 {
  8346. var str string
  8347. str = item.SetlId + " " +
  8348. item.MdtrtId + " " +
  8349. item.PsnNo + " " +
  8350. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8351. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8352. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8353. _, err = f.Write([]byte(str))
  8354. var str2 string
  8355. str2 = item.SetlId + " " +
  8356. item.MdtrtId + " " +
  8357. item.PsnNo + " " +
  8358. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8359. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8360. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8361. _, err = f.Write([]byte(str2))
  8362. }
  8363. }
  8364. }
  8365. Zip(file_path, zip_path)
  8366. fmt.Println(ReadFile(zip_path))
  8367. fmt.Println(string(ReadFile(zip_path)))
  8368. if config.IsOpen == 1 {
  8369. var user_name string
  8370. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8371. if role.ID == 0 {
  8372. user_name = "管理员"
  8373. } else {
  8374. user_name = role.UserName
  8375. }
  8376. baseParams := models.BaseParams{
  8377. SecretKey: miConfig.SecretKey,
  8378. FixmedinsCode: miConfig.Code,
  8379. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8380. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8381. OrgName: miConfig.OrgName,
  8382. Doctor: user_name,
  8383. }
  8384. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8385. var dat map[string]interface{}
  8386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8387. fmt.Println(dat)
  8388. } else {
  8389. fmt.Println(err)
  8390. }
  8391. userJSONBytes, _ := json.Marshal(dat)
  8392. var res ResultNine
  8393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8394. utils.ErrorLog("解析失败:%v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. if res.Infcode == 0 {
  8399. fileNo := res.Output.FileQuryNo
  8400. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8401. "file_qury_no=" + fileNo +
  8402. "&setl_optins=" + "定点医保中心" +
  8403. "&stmt_begndate=" + start_time +
  8404. "&stm_enddate=" + end_time +
  8405. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8406. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8407. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8408. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8409. "&fixmedins_code=" + miConfig.Code +
  8410. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8411. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8412. "&secret_key=" + miConfig.SecretKey +
  8413. "&org_name=" + miConfig.OrgName +
  8414. "&doctor=" + user_name
  8415. resp, requestErr := http.Get(api)
  8416. if requestErr != nil {
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. body, ioErr := ioutil.ReadAll(resp.Body)
  8421. if ioErr != nil {
  8422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8424. return
  8425. }
  8426. var respJSON map[string]interface{}
  8427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8433. userJSONBytes, _ := json.Marshal(respJSON)
  8434. var res ResultTen
  8435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8436. utils.ErrorLog("解析失败:%v", err)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. if res.Infcode == 0 {
  8441. service.Gdyb9102(baseParams, zip_name, fileNo)
  8442. micc := &models.MedicalInsuranceCostCompare{
  8443. StartTime: startime.Unix(),
  8444. EndTime: endtime.Unix(),
  8445. Insutype: "0",
  8446. CheckType: 2,
  8447. Num: fixmedins_setl_cnt,
  8448. Mtime: time.Now().Unix(),
  8449. Status: 1,
  8450. UserOrgId: adminUser.CurrentOrgId,
  8451. CostTotal: medfee_sumamt,
  8452. FuncTotal: fund_pay_sumamt,
  8453. PsnPay: psn_cash_pay,
  8454. Creator: admin_user_id,
  8455. Ctime: time.Now().Unix(),
  8456. }
  8457. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8458. c.ServeSuccessJSON(map[string]interface{}{
  8459. "msg": "明细对账成功",
  8460. })
  8461. }
  8462. } else {
  8463. }
  8464. }
  8465. }
  8466. type CustomOrderInfo struct {
  8467. Name string
  8468. Spec string
  8469. Unit string
  8470. Count float64
  8471. Price float64
  8472. Total float64
  8473. }
  8474. func (c *HisApiController) GetSettleAccounts() {
  8475. //id, _ := c.GetInt64("id")
  8476. //record_time := c.GetString("record_time")
  8477. order_id, _ := c.GetInt64("order_id")
  8478. admin_user_id, _ := c.GetInt64("admin_user_id")
  8479. //timeLayout := "2006-01-02"
  8480. //loc, _ := time.LoadLocation("Local")
  8481. //
  8482. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8483. //if err != nil {
  8484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8485. // return
  8486. //}
  8487. //recordDateTime := theTime.Unix()
  8488. adminUser := c.GetAdminUserInfo()
  8489. order, _ := service.GetHisOrderByID(order_id)
  8490. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8491. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8492. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8493. orderInfos = append(orderInfos, orderInfos_two...)
  8494. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8495. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8496. var diagnosis_ids []string
  8497. if his.ID > 0 {
  8498. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8499. } else {
  8500. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8501. }
  8502. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8503. var dia_config []*models.HisXtDiagnoseConfig
  8504. var name string
  8505. for _, item := range diagnosis_ids {
  8506. id, _ := strconv.ParseInt(item, 10, 64)
  8507. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8508. dia_config = append(dia_config, &diagnosisConfig)
  8509. if len(name) == 0 {
  8510. name = diagnosisConfig.ClassName
  8511. } else {
  8512. name = name + "," + diagnosisConfig.ClassName
  8513. }
  8514. }
  8515. var bedCostTotal float64 = 0 //床位总费
  8516. var bedCostSelfTotal float64 = 0 //床位自费
  8517. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8518. var operationCostTotal float64 = 0 //手术费
  8519. var operationCostSelfTotal float64 = 0 //手术费
  8520. var operationCostPartSelfTotal float64 = 0 //手术费
  8521. var otherCostTotal float64 = 0 //其他费用
  8522. var otherCostSelfTotal float64 = 0 //其他费用
  8523. var otherCostPartSelfTotal float64 = 0 //其他费用
  8524. var materialCostTotal float64 = 0 //材料费
  8525. var materialCostSelfTotal float64 = 0 //材料费
  8526. var materialCostPartSelfTotal float64 = 0 //材料费
  8527. var westernMedicineCostTotal float64 = 0 //西药费
  8528. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8529. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8530. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8531. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8532. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8533. var checkCostTotal float64 = 0 //检查费
  8534. var checkCostSelfTotal float64 = 0 //检查费
  8535. var checkCostPartSelfTotal float64 = 0 //检查费
  8536. var laboratoryCostTotal float64 = 0 //化验费
  8537. var laboratoryCostSelfTotal float64 = 0 //化验费
  8538. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8539. var treatCostTotal float64 = 0 //治疗费用
  8540. var treatCostSelfTotal float64 = 0 //治疗费用
  8541. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8542. decimal.DivisionPrecision = 2
  8543. for _, item := range orderInfos {
  8544. if item.MedChrgitmType == "01" { //床位费
  8545. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8546. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8547. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8548. }
  8549. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8550. if item.MedChrgitmType == "03" { //检查费
  8551. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8552. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8553. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8554. }
  8555. } else {
  8556. if item.MedChrgitmType == "03" { //检查费
  8557. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8558. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8559. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8560. }
  8561. }
  8562. if item.MedChrgitmType == "04" { //化验费
  8563. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8564. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8565. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8566. }
  8567. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8568. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8569. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8570. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8571. }
  8572. if item.MedChrgitmType == "06" { //手术费
  8573. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8574. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8575. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8576. }
  8577. if item.MedChrgitmType == "08" { //材料费
  8578. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8579. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8580. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8581. }
  8582. if item.MedChrgitmType == "09" { //西药费
  8583. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8584. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8585. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8586. }
  8587. if item.MedChrgitmType == "11" { //中成费
  8588. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8589. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8590. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8591. }
  8592. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8593. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8594. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8595. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8596. }
  8597. }
  8598. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8599. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8600. var user_name string
  8601. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8602. if role.ID == 0 {
  8603. user_name = "管理员"
  8604. } else {
  8605. user_name = role.UserName
  8606. }
  8607. baseParams := models.BaseParams{
  8608. SecretKey: miConfig.SecretKey,
  8609. FixmedinsCode: miConfig.Code,
  8610. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8611. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8612. OrgName: miConfig.OrgName,
  8613. Doctor: user_name,
  8614. }
  8615. businessParams := models.BusinessParams{
  8616. PsnNo: order.PsnNo,
  8617. MdtrtId: order.MdtrtId,
  8618. SetlId: order.SetlId,
  8619. }
  8620. var res ResultEleven
  8621. var resEleven10265 ResultEleven10265
  8622. if config.IsOpen == 1 {
  8623. if miConfig.MdtrtareaAdmvs == "421300" {
  8624. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8625. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8626. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8627. resp, requestErr := http.Get(api)
  8628. if requestErr != nil {
  8629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8630. return
  8631. }
  8632. body, ioErr := ioutil.ReadAll(resp.Body)
  8633. if ioErr != nil {
  8634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8636. return
  8637. }
  8638. var respJSON map[string]interface{}
  8639. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. return
  8643. }
  8644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8645. result, _ := json.Marshal(respJSON)
  8646. fmt.Println("log")
  8647. fmt.Println(string(result))
  8648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8649. utils.ErrorLog("解析失败:%v", err)
  8650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8651. return
  8652. }
  8653. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8654. var api string
  8655. if miConfig.MdtrtareaAdmvs == "320921" {
  8656. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8657. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8658. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8659. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8660. } else {
  8661. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8662. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8663. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8664. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8665. }
  8666. resp, requestErr := http.Get(api)
  8667. if requestErr != nil {
  8668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8669. return
  8670. }
  8671. body, ioErr := ioutil.ReadAll(resp.Body)
  8672. if ioErr != nil {
  8673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. var respJSON map[string]interface{}
  8678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8681. return
  8682. }
  8683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8684. result, _ := json.Marshal(respJSON)
  8685. fmt.Println("log")
  8686. fmt.Println(string(result))
  8687. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8688. utils.ErrorLog("解析失败:%v", err)
  8689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8690. return
  8691. }
  8692. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8693. res.Output = resEleven10265.Output
  8694. res.ErrMsg = resEleven10265.ErrMsg
  8695. res.Cainfo = resEleven10265.Cainfo
  8696. res.WarnMsg = resEleven10265.WarnMsg
  8697. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8698. res.Infcode = infocode
  8699. } else {
  8700. //result2 := service.Gdyb1101()
  8701. //result2 := service.Gdyb5204(baseParams, businessParams)
  8702. //saveLog(result2, "", "5204", "查询")
  8703. result := service.Gdyb5203(baseParams, businessParams)
  8704. var dat map[string]interface{}
  8705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8706. fmt.Println(dat)
  8707. } else {
  8708. fmt.Println(err)
  8709. }
  8710. userJSONBytes, _ := json.Marshal(dat)
  8711. if miConfig.Code == "H15049901371" {
  8712. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8713. utils.ErrorLog("解析失败:%v", err)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8718. res.Output = resEleven10265.Output
  8719. res.ErrMsg = resEleven10265.ErrMsg
  8720. res.Cainfo = resEleven10265.Cainfo
  8721. res.WarnMsg = resEleven10265.WarnMsg
  8722. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8723. res.Infcode = infocode
  8724. } else {
  8725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8726. utils.ErrorLog("解析失败:%v", err)
  8727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8728. return
  8729. }
  8730. }
  8731. }
  8732. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8733. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8734. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8735. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8736. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8737. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8738. var doctor_name string
  8739. if roles.ID == 0 {
  8740. doctor_name = "管理员"
  8741. } else {
  8742. doctor_name = roles.UserName
  8743. }
  8744. yiliao_leibie := ""
  8745. switch order.MedType {
  8746. case "11":
  8747. yiliao_leibie = "普通门诊"
  8748. break
  8749. case "12":
  8750. yiliao_leibie = "门诊挂号"
  8751. break
  8752. case "13":
  8753. yiliao_leibie = "急诊"
  8754. break
  8755. case "14":
  8756. yiliao_leibie = "门诊特殊病"
  8757. break
  8758. case "15":
  8759. yiliao_leibie = "门诊统筹"
  8760. break
  8761. case "16":
  8762. yiliao_leibie = "门诊慢性病"
  8763. break
  8764. case "21":
  8765. yiliao_leibie = "普通住院"
  8766. break
  8767. }
  8768. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8769. if res.Infcode == 0 {
  8770. c.ServeSuccessJSON(map[string]interface{}{
  8771. "diagnosis": name,
  8772. "order_infos": orderInfos,
  8773. "number": order.MdtrtId,
  8774. "date": order.SettleAccountsDate,
  8775. "charge_admin": charge_admin,
  8776. "printor_admin": printor_admin,
  8777. "info": res.Output.Setlinfo,
  8778. "order": order,
  8779. "bedCostTotal": bedCostTotal,
  8780. "bedCostSelfTotal": bedCostSelfTotal,
  8781. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8782. "operationCostTotal": operationCostTotal,
  8783. "operationCostSelfTotal": operationCostSelfTotal,
  8784. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8785. "otherCostTotal": otherCostTotal,
  8786. "otherCostSelfTotal": otherCostSelfTotal,
  8787. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8788. "materialCostTotal": materialCostTotal,
  8789. "materialCostSelfTotal": materialCostSelfTotal,
  8790. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8791. "westernMedicineCostTotal": westernMedicineCostTotal,
  8792. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8793. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8794. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8795. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8796. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8797. "checkCostTotal": checkCostTotal,
  8798. "checkCostSelfTotal": checkCostSelfTotal,
  8799. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8800. "laboratoryCostTotal": laboratoryCostTotal,
  8801. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8802. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8803. "treatCostTotal": treatCostTotal,
  8804. "treatCostSelfTotal": treatCostSelfTotal,
  8805. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8806. "doctor_info": doctor_info,
  8807. "doctor_code": adminRole_two.DoctorCode,
  8808. "doctor_name": doctor_name,
  8809. "health_card_no": order.PsnNo,
  8810. "department": departments.Name,
  8811. "yiliao_leibie": yiliao_leibie,
  8812. "after_money": order.AccountPrice,
  8813. "patient": patient,
  8814. "org_name": miConfig.OrgName,
  8815. "org_code": miConfig.Code,
  8816. "order_number": order.Number,
  8817. "his_hospital": his_hospital,
  8818. "his": his,
  8819. "dia_config": dia_config,
  8820. //"check_order_info": cus_slice,
  8821. })
  8822. }
  8823. }
  8824. }
  8825. func (c *HisApiController) CheckTreatment() {
  8826. patient_id, _ := c.GetInt64("patient_id")
  8827. id_card_no := c.GetString("id_card_no")
  8828. insutype := c.GetString("insutype")
  8829. med_type := c.GetString("med_type")
  8830. admin_user_id, _ := c.GetInt64("admin_user_id")
  8831. adminUser := c.GetAdminUserInfo()
  8832. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8834. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8835. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8836. if miConfig.MdtrtareaAdmvs == "421300" {
  8837. var res ResultTwo
  8838. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8839. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8840. "&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)
  8841. resp, requestErr := http.Get(api)
  8842. if requestErr != nil {
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. body, ioErr := ioutil.ReadAll(resp.Body)
  8847. if ioErr != nil {
  8848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8850. return
  8851. }
  8852. var respJSON map[string]interface{}
  8853. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8856. return
  8857. }
  8858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8859. result, _ := json.Marshal(respJSON)
  8860. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8861. utils.ErrorLog("解析失败:%v", err)
  8862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8863. return
  8864. }
  8865. if res.Infcode == 0 {
  8866. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8867. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8868. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8869. resp, requestErr := http.Get(api)
  8870. if requestErr != nil {
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. body, ioErr := ioutil.ReadAll(resp.Body)
  8875. if ioErr != nil {
  8876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. var respJSON map[string]interface{}
  8881. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8884. return
  8885. }
  8886. var res Result2001
  8887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8888. result2, _ := json.Marshal(respJSON)
  8889. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8890. utils.ErrorLog("解析失败:%v", err)
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. if res.Infcode == 0 {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "msg": res.Output.Trtinfo,
  8897. })
  8898. }
  8899. } else {
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8901. return
  8902. }
  8903. } else {
  8904. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8905. var dat map[string]interface{}
  8906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8907. fmt.Println(dat)
  8908. } else {
  8909. fmt.Println(err)
  8910. }
  8911. userJSONBytes, _ := json.Marshal(dat)
  8912. var res ResultTwo
  8913. var res10265 ResultTwo10265
  8914. if miConfig.Code == "H15049901371" {
  8915. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8916. utils.ErrorLog("解析失败:%v", err)
  8917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8918. return
  8919. }
  8920. res.ErrMsg = res10265.ErrMsg
  8921. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8922. res.Infcode = infocode
  8923. res.Output = res10265.Output
  8924. res.InfRefmsgid = res10265.InfRefmsgid
  8925. } else {
  8926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8927. utils.ErrorLog("解析失败:%v", err)
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8929. return
  8930. }
  8931. }
  8932. var user_name string
  8933. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8934. if role.ID == 0 {
  8935. user_name = "xxx"
  8936. } else {
  8937. user_name = role.UserName
  8938. }
  8939. baseParams := models.BaseParams{
  8940. SecretKey: miConfig.SecretKey,
  8941. FixmedinsCode: miConfig.Code,
  8942. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8943. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8944. OrgName: miConfig.OrgName,
  8945. Doctor: user_name,
  8946. }
  8947. if config.IsOpen == 1 {
  8948. if miConfig.Code == "H15049901371" {
  8949. if med_type == "14" {
  8950. if insutype == "390" {
  8951. med_type = "9933"
  8952. } else if insutype == "310" {
  8953. med_type = "990502"
  8954. }
  8955. } else if med_type == "11" {
  8956. med_type = "11"
  8957. }
  8958. }
  8959. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8960. var dat map[string]interface{}
  8961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8962. fmt.Println(dat)
  8963. } else {
  8964. fmt.Println(err)
  8965. }
  8966. var res Result2001
  8967. var res10265 Result2001Org10265
  8968. if miConfig.Code == "H15049901371" {
  8969. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8970. utils.ErrorLog("解析失败:%v", err)
  8971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8972. return
  8973. }
  8974. res.ErrMsg = res10265.ErrMsg
  8975. res.Output = res10265.Output
  8976. res.InfRefmsgid = res10265.InfRefmsgid
  8977. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8978. res.Infcode = infocode
  8979. } else {
  8980. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8981. utils.ErrorLog("解析失败:%v", err)
  8982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8983. return
  8984. }
  8985. }
  8986. if res.Infcode == 0 {
  8987. c.ServeSuccessJSON(map[string]interface{}{
  8988. "msg": res.Output.Trtinfo,
  8989. })
  8990. }
  8991. }
  8992. }
  8993. }
  8994. //func (c *HisApiController) PutRecord() {
  8995. // id, _ := c.GetInt64("id")
  8996. // record_time := c.GetString("record_time")
  8997. // timeLayout := "2006-01-02"
  8998. // loc, _ := time.LoadLocation("Local")
  8999. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9000. // if err != nil {
  9001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9002. // return
  9003. // }
  9004. // recordDateTime := theTime.Unix()
  9005. //
  9006. // adminInfo := c.GetAdminUserInfo()
  9007. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9008. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9009. //
  9010. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9011. //
  9012. // fmt.Println(miConfig.SecretKey)
  9013. //
  9014. // if patient == nil {
  9015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9016. // return
  9017. // }
  9018. // if len(patient.IdCardNo) == 0 {
  9019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9020. // return
  9021. // }
  9022. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9023. // if config.IsOpen == 1 {
  9024. // 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
  9025. // resp, requestErr := http.Get(api)
  9026. // if requestErr != nil {
  9027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9028. // return
  9029. // }
  9030. // defer resp.Body.Close()
  9031. // body, ioErr := ioutil.ReadAll(resp.Body)
  9032. // if ioErr != nil {
  9033. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9035. // return
  9036. // }
  9037. // var respJSON map[string]interface{}
  9038. //
  9039. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9040. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9042. // return
  9043. // }
  9044. //
  9045. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9046. // userJSONBytes, _ := json.Marshal(userJSON)
  9047. // var res ResultTwo
  9048. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9049. // utils.ErrorLog("解析失败:%v", err)
  9050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9051. // return
  9052. // }
  9053. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9054. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9055. // infoStr := string(Iinfos)
  9056. // idetinfoStr := string(Idetinfos)
  9057. //
  9058. // if res.Infcode == 0 {
  9059. // his := models.VMHisPatient{
  9060. // Status: 1,
  9061. // Ctime: time.Now().Unix(),
  9062. // Mtime: time.Now().Unix(),
  9063. // PsnNo: res.Output.Baseinfo.PsnNo,
  9064. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9065. // Certno: res.Output.Baseinfo.Certno,
  9066. // PsnName: res.Output.Baseinfo.PsnName,
  9067. // Gend: res.Output.Baseinfo.Gend,
  9068. // Naty: res.Output.Baseinfo.Naty,
  9069. // Brdy: res.Output.Baseinfo.Brdy,
  9070. // Age: res.Output.Baseinfo.Age,
  9071. // Iinfo: infoStr,
  9072. // Idetinfo: idetinfoStr,
  9073. // PatientId: patient.ID,
  9074. // RecordDate: theTime.Unix(),
  9075. // UserOrgId: adminInfo.CurrentOrgId,
  9076. // AdminUserId: adminInfo.AdminUser.Id,
  9077. // IsReturn: 1,
  9078. // }
  9079. //
  9080. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9081. // //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")
  9082. // //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")
  9083. //
  9084. // //var dat map[string]interface{}
  9085. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9086. // // fmt.Println(dat)
  9087. // //} else {
  9088. // // fmt.Println(err)
  9089. // //}
  9090. //
  9091. // var dat2 map[string]interface{}
  9092. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9093. // fmt.Println(dat2)
  9094. // } else {
  9095. // fmt.Println(err)
  9096. // }
  9097. //
  9098. // } else {
  9099. // adminUser := c.GetAdminUserInfo()
  9100. // errlog := &models.HisOrderError{
  9101. // UserOrgId: adminUser.CurrentOrgId,
  9102. // Ctime: time.Now().Unix(),
  9103. // Mtime: time.Now().Unix(),
  9104. // ErrMsg: res.ErrMsg,
  9105. // Status: 1,
  9106. // PatientId: id,
  9107. // RecordTime: recordDateTime,
  9108. // Stage: 1,
  9109. // }
  9110. // service.CreateErrMsgLog(errlog)
  9111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9112. // return
  9113. // }
  9114. // }
  9115. //
  9116. //}
  9117. //func (c *HisApiController) GetUploadDiag() {
  9118. // id, _ := c.GetInt64("id")
  9119. // record_time := c.GetString("record_time")
  9120. //
  9121. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9122. // sick_type, _ := c.GetInt64("sick_type")
  9123. // reg_type, _ := c.GetInt64("reg_type")
  9124. //
  9125. // timeLayout := "2006-01-02"
  9126. // loc, _ := time.LoadLocation("Local")
  9127. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9128. // if err != nil {
  9129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9130. // return
  9131. // }
  9132. //
  9133. // var patientPrescription models.HisPrescriptionInfo
  9134. // recordDateTime := theTime.Unix()
  9135. // adminInfo := c.GetAdminUserInfo()
  9136. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9137. //
  9138. // if patientPrescription.ID == 0 {
  9139. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9140. // }
  9141. //
  9142. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9143. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9144. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9145. // sickConfig, _ := service.FindSickById(sick_type)
  9146. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9147. //
  9148. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9149. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9150. // "&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 +
  9151. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9152. // resp2, requestErr2 := http.Get(api2)
  9153. // if requestErr2 != nil {
  9154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9155. // return
  9156. // }
  9157. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9158. // if ioErr2 != nil {
  9159. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. // return
  9162. // }
  9163. // var respJSON2 map[string]interface{}
  9164. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9165. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9167. // return
  9168. // }
  9169. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9170. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9171. //
  9172. // var res2 ResultSix
  9173. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9174. // utils.ErrorLog("解析失败:%v", err)
  9175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. // return
  9177. // }
  9178. // if res2.Infcode != 0 {
  9179. // adminUser := c.GetAdminUserInfo()
  9180. // errlog := &models.HisOrderError{
  9181. // UserOrgId: adminUser.CurrentOrgId,
  9182. // Ctime: time.Now().Unix(),
  9183. // Mtime: time.Now().Unix(),
  9184. // ErrMsg: res2.ErrMsg,
  9185. // Status: 1,
  9186. // PatientId: id,
  9187. // RecordTime: recordDateTime,
  9188. // Stage: 3,
  9189. // }
  9190. // service.CreateErrMsgLog(errlog)
  9191. //
  9192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9193. // return
  9194. // }
  9195. //
  9196. // c.ServeSuccessJSON(map[string]interface{}{
  9197. // "msg": "上传成功",
  9198. // })
  9199. //
  9200. //}
  9201. type QueryResult struct {
  9202. ID int64
  9203. Name string
  9204. Code string
  9205. List_type_code string
  9206. }
  9207. func (c *HisApiController) GetCheckCode() {
  9208. ids_str := c.GetString("ids")
  9209. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9210. ids_arr := strings.Split(ids_str, ",")
  9211. var queryResult []QueryResult
  9212. ids := make([]int64, 0)
  9213. for _, item := range ids_arr {
  9214. id, _ := strconv.ParseInt(item, 10, 64)
  9215. ids = append(ids, id)
  9216. }
  9217. if record_type == 1 {
  9218. drugs, _ := service.GetBatchDrugList(ids)
  9219. for _, item := range drugs {
  9220. result := QueryResult{
  9221. ID: item.ID,
  9222. Name: item.DrugName,
  9223. Code: item.MedicalInsuranceNumber,
  9224. List_type_code: "101",
  9225. }
  9226. queryResult = append(queryResult, result)
  9227. }
  9228. } else if record_type == 2 {
  9229. goods, _ := service.GetBatchGoodInformationList(ids)
  9230. for _, item := range goods {
  9231. result := QueryResult{
  9232. ID: item.ID,
  9233. Name: item.GoodName,
  9234. Code: item.MedicalInsuranceNumber,
  9235. List_type_code: "301",
  9236. }
  9237. queryResult = append(queryResult, result)
  9238. }
  9239. } else if record_type == 3 {
  9240. projects, _ := service.GetBathchMyPorjecgList(ids)
  9241. for _, item := range projects {
  9242. result := QueryResult{
  9243. ID: item.ID,
  9244. Name: item.ProjectName,
  9245. Code: item.MedicalCode,
  9246. List_type_code: "201",
  9247. }
  9248. queryResult = append(queryResult, result)
  9249. }
  9250. }
  9251. admin_user_id, _ := c.GetInt64("admin_user_id")
  9252. adminUser := c.GetAdminUserInfo()
  9253. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9254. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9255. var user_name string
  9256. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9257. if role.ID == 0 {
  9258. user_name = "xxx"
  9259. } else {
  9260. user_name = role.UserName
  9261. }
  9262. baseParams := &models.BaseParams{
  9263. SecretKey: miConfig.SecretKey,
  9264. FixmedinsCode: miConfig.Code,
  9265. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9266. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9267. OrgName: miConfig.OrgName,
  9268. Doctor: user_name,
  9269. }
  9270. if config.IsOpen == 1 {
  9271. for _, item := range queryResult {
  9272. var result string
  9273. if record_type == 1 {
  9274. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9275. } else if record_type == 2 {
  9276. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9277. } else if record_type == 3 {
  9278. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9279. }
  9280. var dat map[string]interface{}
  9281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9282. fmt.Println(dat)
  9283. } else {
  9284. fmt.Println(err)
  9285. }
  9286. userJSONBytes, _ := json.Marshal(dat)
  9287. var res ResultSix
  9288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9289. utils.ErrorLog("解析失败:%v", err)
  9290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9291. return
  9292. }
  9293. if res.Infcode == 0 {
  9294. if record_type == 1 {
  9295. service.UpdateBaseDrugById(item.ID)
  9296. } else if record_type == 2 {
  9297. service.UpdateGoodInformaitonByDetail(item.ID)
  9298. } else if record_type == 3 {
  9299. service.UpdateProjectById(item.ID)
  9300. }
  9301. c.ServeSuccessJSON(map[string]interface{}{
  9302. "failed_code": 0,
  9303. "msg": "目录对照成功",
  9304. })
  9305. } else {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "failed_code": -10,
  9308. "msg": res.ErrMsg,
  9309. })
  9310. }
  9311. }
  9312. }
  9313. }
  9314. func (c *HisApiController) UnCheckCode() {
  9315. ids_str := c.GetString("ids")
  9316. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9317. admin_user_id, _ := c.GetInt64("admin_user_id")
  9318. ids_arr := strings.Split(ids_str, ",")
  9319. var queryResult []QueryResult
  9320. ids := make([]int64, 0)
  9321. for _, item := range ids_arr {
  9322. id, _ := strconv.ParseInt(item, 10, 64)
  9323. ids = append(ids, id)
  9324. }
  9325. if record_type == 1 {
  9326. drugs, _ := service.GetBatchDrugList(ids)
  9327. for _, item := range drugs {
  9328. result := QueryResult{
  9329. ID: item.ID,
  9330. Name: item.DrugName,
  9331. Code: item.MedicalInsuranceNumber,
  9332. List_type_code: "101",
  9333. }
  9334. queryResult = append(queryResult, result)
  9335. }
  9336. } else if record_type == 2 {
  9337. goods, _ := service.GetBatchGoodInformationList(ids)
  9338. for _, item := range goods {
  9339. result := QueryResult{
  9340. ID: item.ID,
  9341. Name: item.GoodName,
  9342. Code: item.MedicalInsuranceNumber,
  9343. List_type_code: "301",
  9344. }
  9345. queryResult = append(queryResult, result)
  9346. }
  9347. } else if record_type == 3 {
  9348. projects, _ := service.GetBathchMyPorjecgList(ids)
  9349. for _, item := range projects {
  9350. result := QueryResult{
  9351. ID: item.ID,
  9352. Name: item.ProjectName,
  9353. Code: item.MedicalCode,
  9354. List_type_code: "201",
  9355. }
  9356. queryResult = append(queryResult, result)
  9357. }
  9358. }
  9359. adminUser := c.GetAdminUserInfo()
  9360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9362. var user_name string
  9363. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9364. if role.ID == 0 {
  9365. user_name = "xxx"
  9366. } else {
  9367. user_name = role.UserName
  9368. }
  9369. baseParams := &models.BaseParams{
  9370. SecretKey: miConfig.SecretKey,
  9371. FixmedinsCode: miConfig.Code,
  9372. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9373. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9374. OrgName: miConfig.OrgName,
  9375. Doctor: user_name,
  9376. }
  9377. if config.IsOpen == 1 {
  9378. for _, item := range queryResult {
  9379. var result string
  9380. if record_type == 1 {
  9381. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9382. } else if record_type == 2 {
  9383. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9384. } else if record_type == 3 {
  9385. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9386. }
  9387. var dat2 map[string]interface{}
  9388. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9389. fmt.Println(dat2)
  9390. } else {
  9391. fmt.Println(err)
  9392. }
  9393. userJSONBytes, _ := json.Marshal(dat2)
  9394. var res ResultSix
  9395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9396. utils.ErrorLog("解析失败:%v", err)
  9397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9398. return
  9399. }
  9400. if res.Infcode == 0 {
  9401. if record_type == 1 {
  9402. service.UpdateDrugByIdDetail(item.ID)
  9403. } else if record_type == 2 {
  9404. service.UpdateGoodInfoById(item.ID)
  9405. } else if record_type == 3 {
  9406. service.UpdateMyProjectById(item.ID)
  9407. }
  9408. c.ServeSuccessJSON(map[string]interface{}{
  9409. "failed_code": 0,
  9410. "msg": "撤销目录对照成功",
  9411. })
  9412. } else {
  9413. c.ServeSuccessJSON(map[string]interface{}{
  9414. "failed_code": -10,
  9415. "msg": res.ErrMsg,
  9416. })
  9417. }
  9418. }
  9419. }
  9420. }
  9421. func (c *HisApiController) GetPatientInfo() {
  9422. id_card_no := c.GetString("id_card_no")
  9423. admin_user_id, _ := c.GetInt64("admin_user_id")
  9424. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9425. if patient.ID == 0 {
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9427. return
  9428. }
  9429. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9430. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9431. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9432. if config.IsOpen == 1 {
  9433. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9434. var dat map[string]interface{}
  9435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9436. fmt.Println(dat)
  9437. } else {
  9438. fmt.Println(err)
  9439. }
  9440. userJSONBytes, _ := json.Marshal(dat)
  9441. var res ResultTwo
  9442. var res10265 ResultTwo10265
  9443. if miConfig.Code == "H15049901371" {
  9444. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9445. utils.ErrorLog("解析失败:%v", err)
  9446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9447. return
  9448. }
  9449. res.ErrMsg = res10265.ErrMsg
  9450. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9451. res.Infcode = infocode
  9452. res.Output = res10265.Output
  9453. res.InfRefmsgid = res10265.InfRefmsgid
  9454. } else {
  9455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9456. utils.ErrorLog("解析失败:%v", err)
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9458. return
  9459. }
  9460. }
  9461. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9462. // utils.ErrorLog("解析失败:%v", err)
  9463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9464. // return
  9465. //}
  9466. if res.Infcode != 0 {
  9467. c.ServeSuccessJSON(map[string]interface{}{
  9468. "failed_code": -10,
  9469. "msg": res.ErrMsg,
  9470. })
  9471. } else {
  9472. c.ServeSuccessJSON(map[string]interface{}{
  9473. "failed_code": 0,
  9474. "info": res,
  9475. })
  9476. }
  9477. }
  9478. }
  9479. func (c *HisApiController) PsnPutOnRecord() {
  9480. record_type, _ := c.GetInt64("type")
  9481. patient_id, _ := c.GetInt64("patient_id")
  9482. admin_user_id, _ := c.GetInt64("admin_user_id")
  9483. start_time := c.GetString("start_time")
  9484. end_time := c.GetString("end_time")
  9485. adminUser := c.GetAdminUserInfo()
  9486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9487. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9488. var patients []*models.Patients
  9489. if record_type == 1 { //全部备案
  9490. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9491. patients = append(patients, patient...)
  9492. } else { //单个备案
  9493. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9494. patients = append(patients, patient)
  9495. }
  9496. var user_name string
  9497. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9498. if role.ID == 0 {
  9499. user_name = "xxx"
  9500. } else {
  9501. user_name = role.UserName
  9502. }
  9503. if config.IsOpen == 1 {
  9504. for _, item := range patients {
  9505. 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
  9506. resp, requestErr := http.Get(api)
  9507. if requestErr != nil {
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. defer resp.Body.Close()
  9512. body, ioErr := ioutil.ReadAll(resp.Body)
  9513. if ioErr != nil {
  9514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. var respJSON map[string]interface{}
  9519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9522. return
  9523. }
  9524. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9525. userJSONBytes, _ := json.Marshal(userJSON)
  9526. var res ResultTwo
  9527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9528. utils.ErrorLog("解析失败:%v", err)
  9529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9530. return
  9531. }
  9532. if res.Infcode == 0 {
  9533. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9534. var dat map[string]interface{}
  9535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9536. fmt.Println(dat)
  9537. } else {
  9538. fmt.Println(err)
  9539. }
  9540. userJSONBytes, _ := json.Marshal(dat)
  9541. var res2 ResultThirteen
  9542. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9543. utils.ErrorLog("解析失败:%v", err)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. if res2.Infcode == 0 {
  9548. psnResult := &models.GdybPsnRecord{
  9549. UserOrgId: adminUser.CurrentOrgId,
  9550. PatientId: item.ID,
  9551. PsnNo: res.Output.Baseinfo.PsnNo,
  9552. Ctime: time.Now().Unix(),
  9553. Mtime: time.Now().Unix(),
  9554. Status: 1,
  9555. IsCancel: 1,
  9556. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9557. }
  9558. service.CreatePsnRecord(psnResult)
  9559. } else {
  9560. c.ServeSuccessJSON(map[string]interface{}{
  9561. "failed_code": -10,
  9562. "msg": res2.ErrMsg,
  9563. })
  9564. return
  9565. }
  9566. }
  9567. }
  9568. }
  9569. }
  9570. func (c *HisApiController) PsnUnPutOnRecord() {
  9571. id, _ := c.GetInt64("id")
  9572. //record_type, _ := c.GetInt64("type")
  9573. admin_user_id, _ := c.GetInt64("admin_user_id")
  9574. adminUser := c.GetAdminUserInfo()
  9575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9577. var user_name string
  9578. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9579. if role.ID == 0 {
  9580. user_name = "xxx"
  9581. } else {
  9582. user_name = role.UserName
  9583. }
  9584. psn_record, _ := service.GetPsnRecordById(id)
  9585. if psn_record.ID == 0 {
  9586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9587. return
  9588. }
  9589. if config.IsOpen == 1 {
  9590. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9591. var dat map[string]interface{}
  9592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9593. fmt.Println(dat)
  9594. } else {
  9595. fmt.Println(err)
  9596. }
  9597. userJSONBytes, _ := json.Marshal(dat)
  9598. var res ResultFourteen
  9599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9600. utils.ErrorLog("解析失败:%v", err)
  9601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9602. return
  9603. }
  9604. if res.Infcode == 0 {
  9605. psn_record.IsCancel = 2
  9606. service.CreatePsnRecord(&psn_record)
  9607. } else {
  9608. c.ServeSuccessJSON(map[string]interface{}{
  9609. "failed_code": -10,
  9610. "msg": res.ErrMsg,
  9611. })
  9612. return
  9613. }
  9614. }
  9615. }
  9616. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9617. patient_id, _ := c.GetInt64("patient_id")
  9618. insutype_two := c.GetString("insutype")
  9619. psn_no := c.GetString("psn_no")
  9620. doctor_id, _ := c.GetInt64("doctor_id")
  9621. sick_id, _ := c.GetInt64("sick_id")
  9622. department_id, _ := c.GetInt64("department_id")
  9623. start_time := c.GetString("start_time")
  9624. end_time := c.GetString("end_time")
  9625. check_time := c.GetString("check_time")
  9626. adminUser := c.GetAdminUserInfo()
  9627. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9628. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9629. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9630. sick, _ := service.FindSickById(sick_id)
  9631. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9632. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9633. var res ResultTwo
  9634. var res10265 ResultTwo10265
  9635. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9636. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9637. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9638. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9639. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  9640. resp, requestErr := http.Get(api)
  9641. if requestErr != nil {
  9642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9643. return
  9644. }
  9645. body, ioErr := ioutil.ReadAll(resp.Body)
  9646. if ioErr != nil {
  9647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9649. return
  9650. }
  9651. var respJSON map[string]interface{}
  9652. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. return
  9656. }
  9657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9658. result, _ := json.Marshal(respJSON)
  9659. fmt.Println("log")
  9660. fmt.Println(string(result))
  9661. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9662. utils.ErrorLog("解析失败:%v", err)
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9664. return
  9665. }
  9666. res.ErrMsg = res10265.ErrMsg
  9667. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9668. res.Infcode = infocode
  9669. res.Output = res10265.Output
  9670. res.InfRefmsgid = res10265.InfRefmsgid
  9671. } else {
  9672. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9673. if miConfig.Code == "H15049901371" {
  9674. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9675. utils.ErrorLog("解析失败:%v", err)
  9676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9677. return
  9678. }
  9679. res.ErrMsg = res10265.ErrMsg
  9680. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9681. res.Infcode = infocode
  9682. res.Output = res10265.Output
  9683. res.InfRefmsgid = res10265.InfRefmsgid
  9684. } else {
  9685. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9686. utils.ErrorLog("解析失败:%v", err)
  9687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9688. return
  9689. }
  9690. }
  9691. }
  9692. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9693. infoStr := string(Iinfos)
  9694. var rf []*ResultFive
  9695. json.Unmarshal([]byte(infoStr), &rf)
  9696. var insuplc_admdvs string
  9697. var insutype string
  9698. var is390 int = 0
  9699. var is310 int = 0
  9700. var insutypes []*ResultFive
  9701. for _, item := range rf {
  9702. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9703. insutypes = append(insutypes, item)
  9704. }
  9705. }
  9706. if len(insutypes) == 1 {
  9707. insutype = insutypes[0].Insutype
  9708. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9709. } else {
  9710. for _, i := range insutypes {
  9711. if i.Insutype == "390" {
  9712. is390 = 1
  9713. }
  9714. if i.Insutype == "310" {
  9715. is310 = 1
  9716. }
  9717. }
  9718. }
  9719. if is390 == 1 {
  9720. insutype = "390"
  9721. }
  9722. if is310 == 1 {
  9723. insutype = "310"
  9724. }
  9725. if len(insutypes) == 2 {
  9726. insutype = insutype_two
  9727. }
  9728. if len(insutypes) == 0 {
  9729. insutype = "310"
  9730. }
  9731. insutype = insutype_two
  9732. fmt.Println(insutype)
  9733. for _, item := range rf {
  9734. fmt.Println(item.Insutype)
  9735. fmt.Println(insutype)
  9736. if item.Insutype == insutype {
  9737. fmt.Println(item.Insutype)
  9738. fmt.Println(insutype)
  9739. insuplc_admdvs = item.InsuplcAdmdvs
  9740. }
  9741. }
  9742. fmt.Println(insuplc_admdvs)
  9743. var res2 ResultThirteen
  9744. var res10265_2 ResultThirteen10265
  9745. if config.IsOpen == 1 {
  9746. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9747. } else {
  9748. 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)
  9749. var dat map[string]interface{}
  9750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9751. fmt.Println(dat)
  9752. } else {
  9753. fmt.Println(err)
  9754. }
  9755. userJSONBytes, _ := json.Marshal(dat)
  9756. if miConfig.Code == "H15049901371" {
  9757. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9758. utils.ErrorLog("解析失败:%v", err)
  9759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9760. return
  9761. }
  9762. res2.ErrMsg = res10265_2.ErrMsg
  9763. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9764. res2.Infcode = infocode
  9765. res2.Output = res10265_2.Output
  9766. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9767. } else {
  9768. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9769. utils.ErrorLog("解析失败:%v", err)
  9770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9771. return
  9772. }
  9773. }
  9774. }
  9775. if res2.Infcode == 0 {
  9776. psnResult := &models.GdybPsnNcdsRecord{
  9777. UserOrgId: adminUser.CurrentOrgId,
  9778. PatientId: patient.ID,
  9779. PsnNo: psn_no,
  9780. DoctorId: doctor.AdminUserId,
  9781. DepartmentId: department_id,
  9782. SickType: sick_id,
  9783. Insutype: insutype,
  9784. Ctime: time.Now().Unix(),
  9785. Mtime: time.Now().Unix(),
  9786. Status: 1,
  9787. IsCancel: 1,
  9788. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9789. }
  9790. service.CreatePsnNCDSRecord(psnResult)
  9791. c.ServeSuccessJSON(map[string]interface{}{
  9792. "failed_code": 0,
  9793. "msg": "备案成功",
  9794. "result": psnResult,
  9795. })
  9796. } else {
  9797. c.ServeSuccessJSON(map[string]interface{}{
  9798. "failed_code": -10,
  9799. "msg": res2.ErrMsg,
  9800. })
  9801. return
  9802. }
  9803. }
  9804. }
  9805. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9806. id, _ := c.GetInt64("id")
  9807. admin_user_id, _ := c.GetInt64("admin_user_id")
  9808. adminUser := c.GetAdminUserInfo()
  9809. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9810. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9811. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9812. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9813. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9814. //var user_name string
  9815. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9816. //if role.ID == 0 {
  9817. // user_name = "xxx"
  9818. //} else {
  9819. // user_name = role.UserName
  9820. //}
  9821. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9822. if psn_record.ID == 0 {
  9823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9824. return
  9825. }
  9826. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9827. var res ResultTwo
  9828. var res10265 ResultTwo10265
  9829. if miConfig.Code == "H15049901371" {
  9830. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9831. utils.ErrorLog("解析失败:%v", err)
  9832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9833. return
  9834. }
  9835. res.ErrMsg = res10265.ErrMsg
  9836. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9837. res.Infcode = infocode
  9838. res.Output = res10265.Output
  9839. res.InfRefmsgid = res10265.InfRefmsgid
  9840. } else {
  9841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9842. utils.ErrorLog("解析失败:%v", err)
  9843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9844. return
  9845. }
  9846. }
  9847. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9848. infoStr := string(Iinfos)
  9849. var rf []*ResultFive
  9850. json.Unmarshal([]byte(infoStr), &rf)
  9851. var insuplc_admdvs string
  9852. var insutype string
  9853. var is390 int = 0
  9854. var is310 int = 0
  9855. var insutypes []*ResultFive
  9856. for _, item := range rf {
  9857. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9858. insutypes = append(insutypes, item)
  9859. }
  9860. }
  9861. if len(insutypes) == 1 {
  9862. insutype = insutypes[0].Insutype
  9863. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9864. } else {
  9865. for _, i := range insutypes {
  9866. if i.Insutype == "390" {
  9867. is390 = 1
  9868. }
  9869. if i.Insutype == "310" {
  9870. is310 = 1
  9871. }
  9872. }
  9873. }
  9874. if is390 == 1 {
  9875. insutype = "390"
  9876. }
  9877. if is310 == 1 {
  9878. insutype = "310"
  9879. }
  9880. if len(insutypes) == 0 {
  9881. insutype = "310"
  9882. }
  9883. insutype = psn_record.Insutype
  9884. for _, item := range rf {
  9885. if item.Insutype == insutype {
  9886. insuplc_admdvs = item.InsuplcAdmdvs
  9887. }
  9888. }
  9889. if config.IsOpen == 1 {
  9890. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9891. var dat map[string]interface{}
  9892. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9893. fmt.Println(dat)
  9894. } else {
  9895. fmt.Println(err)
  9896. }
  9897. userJSONBytes, _ := json.Marshal(dat)
  9898. var res ResultFourteen
  9899. var res10265 ResultFourteen10265
  9900. if miConfig.Code == "H15049901371" {
  9901. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9902. utils.ErrorLog("解析失败:%v", err)
  9903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9904. return
  9905. }
  9906. res.ErrMsg = res10265.ErrMsg
  9907. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9908. res.Infcode = infocode
  9909. res.Output = res10265.Output
  9910. res.InfRefmsgid = res10265.InfRefmsgid
  9911. } else {
  9912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9913. utils.ErrorLog("解析失败:%v", err)
  9914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9915. return
  9916. }
  9917. }
  9918. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9919. // utils.ErrorLog("解析失败:%v", err)
  9920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9921. // return
  9922. //}
  9923. if res.Infcode == 0 {
  9924. psn_record.IsCancel = 2
  9925. service.CreatePsnNCDSRecord(&psn_record)
  9926. c.ServeSuccessJSON(map[string]interface{}{
  9927. "failed_code": 0,
  9928. "msg": "撤销备案成功",
  9929. })
  9930. } else {
  9931. c.ServeSuccessJSON(map[string]interface{}{
  9932. "failed_code": -10,
  9933. "msg": res.ErrMsg,
  9934. })
  9935. return
  9936. }
  9937. }
  9938. }
  9939. func (c *HisApiController) TestTest() {
  9940. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9941. fmt.Println(patient.Iinfo)
  9942. }
  9943. type CustomData struct {
  9944. MsgId string
  9945. PsnNo string
  9946. Info string
  9947. }
  9948. func (c *HisApiController) ReversalData() {
  9949. var customData []*CustomData
  9950. custom := &CustomData{
  9951. MsgId: "H44022900158202103301714472004",
  9952. PsnNo: "44020000001101329945",
  9953. Info: "2207",
  9954. }
  9955. customData = append(customData, custom)
  9956. custom1 := &CustomData{
  9957. MsgId: "H4402290015820210330172057803",
  9958. PsnNo: "44020000001101161813",
  9959. Info: "2207",
  9960. }
  9961. customData = append(customData, custom1)
  9962. custom2 := &CustomData{
  9963. MsgId: "H44022900158202103301705198813",
  9964. PsnNo: "44190000133097375417",
  9965. Info: "2207",
  9966. }
  9967. customData = append(customData, custom2)
  9968. custom3 := &CustomData{
  9969. MsgId: "H44022900158202103301715524756",
  9970. PsnNo: "44020000001100187221",
  9971. Info: "2207",
  9972. }
  9973. customData = append(customData, custom3)
  9974. custom4 := &CustomData{
  9975. MsgId: "H44022900158202103301730376224",
  9976. PsnNo: "44020000001101959155",
  9977. Info: "2207",
  9978. }
  9979. customData = append(customData, custom4)
  9980. custom5 := &CustomData{
  9981. MsgId: "H44022900158202103301748008725",
  9982. PsnNo: "44020000001104246641",
  9983. Info: "2207",
  9984. }
  9985. customData = append(customData, custom5)
  9986. custom6 := &CustomData{
  9987. MsgId: "H44022900158202103301718096755",
  9988. PsnNo: "44020000001102211860",
  9989. Info: "2207",
  9990. }
  9991. customData = append(customData, custom6)
  9992. custom7 := &CustomData{
  9993. MsgId: "H44022900158202103301736551640",
  9994. PsnNo: "44020000001102687718",
  9995. Info: "2207",
  9996. }
  9997. customData = append(customData, custom7)
  9998. custom8 := &CustomData{
  9999. MsgId: "H44022900158202103301743097676",
  10000. PsnNo: "44020000001102127785",
  10001. Info: "2207",
  10002. }
  10003. customData = append(customData, custom8)
  10004. custom9 := &CustomData{
  10005. MsgId: "H44022900158202103301712304203",
  10006. PsnNo: "44020000001101518097",
  10007. Info: "2207",
  10008. }
  10009. customData = append(customData, custom9)
  10010. custom10 := &CustomData{
  10011. MsgId: "H44022900158202103301738448785",
  10012. PsnNo: "44020000001100500813",
  10013. Info: "2207",
  10014. }
  10015. customData = append(customData, custom10)
  10016. custom11 := &CustomData{
  10017. MsgId: "H44022900158202103301732455843",
  10018. PsnNo: "44020000001102690557",
  10019. Info: "2207",
  10020. }
  10021. customData = append(customData, custom11)
  10022. custom12 := &CustomData{
  10023. MsgId: "H44022900158202103301745421708",
  10024. PsnNo: "44020000001102211928",
  10025. Info: "2207",
  10026. }
  10027. customData = append(customData, custom12)
  10028. custom1212 := &CustomData{
  10029. MsgId: "H440229001582021033017351627",
  10030. PsnNo: "44020000001102481733",
  10031. Info: "2207",
  10032. }
  10033. customData = append(customData, custom1212)
  10034. custom13 := &CustomData{
  10035. MsgId: "H44022900158202103301740327951",
  10036. PsnNo: "44020000001103174866",
  10037. Info: "2207",
  10038. }
  10039. customData = append(customData, custom13)
  10040. custom14 := &CustomData{
  10041. MsgId: "H4402290015820210330174922668",
  10042. PsnNo: "44020000001102927272",
  10043. Info: "2207",
  10044. }
  10045. customData = append(customData, custom14)
  10046. custom15 := &CustomData{
  10047. MsgId: "H44022900158202103301752362273",
  10048. PsnNo: "44020000001102942890",
  10049. Info: "2207",
  10050. }
  10051. customData = append(customData, custom15)
  10052. custom16 := &CustomData{
  10053. MsgId: "H44022900158202103301751082917",
  10054. PsnNo: "44020000001101662162",
  10055. Info: "2207",
  10056. }
  10057. customData = append(customData, custom16)
  10058. custom17 := &CustomData{
  10059. MsgId: "H44022900158202103301754147728",
  10060. PsnNo: "44020000000229014511",
  10061. Info: "2207",
  10062. }
  10063. customData = append(customData, custom17)
  10064. adminUser := c.GetAdminUserInfo()
  10065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10066. for _, item := range customData {
  10067. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10068. fmt.Println(result)
  10069. }
  10070. }
  10071. func (c *HisApiController) GetAllopatry() {
  10072. year := c.GetString("year")
  10073. month := c.GetString("month")
  10074. admin_user_id, _ := c.GetInt64("admin_user_id")
  10075. adminUser := c.GetAdminUserInfo()
  10076. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10077. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10078. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10079. var dat map[string]interface{}
  10080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10081. fmt.Println(dat)
  10082. } else {
  10083. fmt.Println(err)
  10084. }
  10085. userJSONBytes, _ := json.Marshal(dat)
  10086. var res models.Result9001
  10087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10088. utils.ErrorLog("解析失败:%v", err)
  10089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10090. return
  10091. }
  10092. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10093. var dat2 map[string]interface{}
  10094. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10095. fmt.Println(dat)
  10096. } else {
  10097. fmt.Println(err)
  10098. }
  10099. userJSONBytes2, _ := json.Marshal(dat2)
  10100. var res2 models.Result3260
  10101. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10102. utils.ErrorLog("解析失败:%v", err)
  10103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10104. return
  10105. }
  10106. if res2.Infcode == 0 {
  10107. c.ServeSuccessJSON(map[string]interface{}{
  10108. "list": res2.Output.Data,
  10109. })
  10110. return
  10111. } else {
  10112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10113. return
  10114. }
  10115. }
  10116. func (c *HisApiController) ComfirmAllopatry() {
  10117. year := c.GetString("year")
  10118. month := c.GetString("month")
  10119. admin_user_id, _ := c.GetInt64("admin_user_id")
  10120. adminUser := c.GetAdminUserInfo()
  10121. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10122. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10123. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10124. var dat map[string]interface{}
  10125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10126. fmt.Println(dat)
  10127. } else {
  10128. fmt.Println(err)
  10129. }
  10130. userJSONBytes, _ := json.Marshal(dat)
  10131. var res models.Result9001
  10132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10133. utils.ErrorLog("解析失败:%v", err)
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10135. return
  10136. }
  10137. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10138. var dat2 map[string]interface{}
  10139. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10140. fmt.Println(dat)
  10141. } else {
  10142. fmt.Println(err)
  10143. }
  10144. userJSONBytes2, _ := json.Marshal(dat2)
  10145. var res2 models.Result3260
  10146. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10147. utils.ErrorLog("解析失败:%v", err)
  10148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10149. return
  10150. }
  10151. if res2.Infcode == 0 {
  10152. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10153. var dat map[string]interface{}
  10154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10155. fmt.Println(dat)
  10156. } else {
  10157. fmt.Println(err)
  10158. }
  10159. userJSONBytes, _ := json.Marshal(dat)
  10160. var res3 models.Result3261
  10161. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. if res3.Infcode == 0 {
  10167. record := &models.HisYidiClearRecord{
  10168. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10169. Ctime: time.Now().Unix(),
  10170. Mtime: time.Now().Unix(),
  10171. Status: 1,
  10172. MsgId: msgId,
  10173. }
  10174. service.SaveClearRecord(record)
  10175. c.ServeSuccessJSON(map[string]interface{}{
  10176. "msg": "提取成功",
  10177. })
  10178. }
  10179. }
  10180. }
  10181. func (c *HisApiController) RefundAllopatry() {
  10182. year := c.GetString("year")
  10183. month := c.GetString("month")
  10184. id, _ := c.GetInt64("id")
  10185. admin_user_id, _ := c.GetInt64("admin_user_id")
  10186. adminUser := c.GetAdminUserInfo()
  10187. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10188. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10189. record, _ := service.GetClearRecordById(id)
  10190. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10191. var dat map[string]interface{}
  10192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10193. fmt.Println(dat)
  10194. } else {
  10195. fmt.Println(err)
  10196. }
  10197. userJSONBytes, _ := json.Marshal(dat)
  10198. var empty ResultFourteen
  10199. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10200. utils.ErrorLog("解析失败:%v", err)
  10201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10202. return
  10203. }
  10204. if empty.Infcode == 0 {
  10205. c.ServeSuccessJSON(map[string]interface{}{
  10206. "msg": "撤销成功",
  10207. })
  10208. return
  10209. }
  10210. }
  10211. func (c *HisApiController) ReversalOtherData() {
  10212. var customData []*CustomData
  10213. custom := &CustomData{
  10214. MsgId: "H44022900158202103301714472004",
  10215. PsnNo: "44020000001101329945",
  10216. Info: "2208",
  10217. }
  10218. customData = append(customData, custom)
  10219. custom1 := &CustomData{
  10220. MsgId: "H4402290015820210330172057803",
  10221. PsnNo: "44020000001101161813",
  10222. Info: "2208",
  10223. }
  10224. customData = append(customData, custom1)
  10225. custom2 := &CustomData{
  10226. MsgId: "H44022900158202103301705198813",
  10227. PsnNo: "44190000133097375417",
  10228. Info: "2208",
  10229. }
  10230. customData = append(customData, custom2)
  10231. custom3 := &CustomData{
  10232. MsgId: "H44022900158202103301715524756",
  10233. PsnNo: "44020000001100187221",
  10234. Info: "2208",
  10235. }
  10236. customData = append(customData, custom3)
  10237. custom4 := &CustomData{
  10238. MsgId: "H44022900158202103301730376224",
  10239. PsnNo: "44020000001101959155",
  10240. Info: "2208",
  10241. }
  10242. customData = append(customData, custom4)
  10243. custom5 := &CustomData{
  10244. MsgId: "H44022900158202103301748008725",
  10245. PsnNo: "44020000001104246641",
  10246. Info: "2208",
  10247. }
  10248. customData = append(customData, custom5)
  10249. custom6 := &CustomData{
  10250. MsgId: "H44022900158202103301718096755",
  10251. PsnNo: "44020000001102211860",
  10252. Info: "2208",
  10253. }
  10254. customData = append(customData, custom6)
  10255. custom7 := &CustomData{
  10256. MsgId: "H44022900158202103301736551640",
  10257. PsnNo: "44020000001102687718",
  10258. Info: "2208",
  10259. }
  10260. customData = append(customData, custom7)
  10261. custom8 := &CustomData{
  10262. MsgId: "H44022900158202103301743097676",
  10263. PsnNo: "44020000001102127785",
  10264. Info: "2208",
  10265. }
  10266. customData = append(customData, custom8)
  10267. custom9 := &CustomData{
  10268. MsgId: "H44022900158202103301712304203",
  10269. PsnNo: "44020000001101518097",
  10270. Info: "2208",
  10271. }
  10272. customData = append(customData, custom9)
  10273. custom10 := &CustomData{
  10274. MsgId: "H44022900158202103301738448785",
  10275. PsnNo: "44020000001100500813",
  10276. Info: "2208",
  10277. }
  10278. customData = append(customData, custom10)
  10279. custom11 := &CustomData{
  10280. MsgId: "H44022900158202103301732455843",
  10281. PsnNo: "44020000001102690557",
  10282. Info: "2208",
  10283. }
  10284. customData = append(customData, custom11)
  10285. custom12 := &CustomData{
  10286. MsgId: "H44022900158202103301745421708",
  10287. PsnNo: "44020000001102211928",
  10288. Info: "2208",
  10289. }
  10290. customData = append(customData, custom12)
  10291. custom1212 := &CustomData{
  10292. MsgId: "H440229001582021033017351627",
  10293. PsnNo: "44020000001102481733",
  10294. Info: "2208",
  10295. }
  10296. customData = append(customData, custom1212)
  10297. custom13 := &CustomData{
  10298. MsgId: "H44022900158202103301740327951",
  10299. PsnNo: "44020000001103174866",
  10300. Info: "2208",
  10301. }
  10302. customData = append(customData, custom13)
  10303. custom14 := &CustomData{
  10304. MsgId: "H4402290015820210330174922668",
  10305. PsnNo: "44020000001102927272",
  10306. Info: "2208",
  10307. }
  10308. customData = append(customData, custom14)
  10309. custom15 := &CustomData{
  10310. MsgId: "H44022900158202103301752362273",
  10311. PsnNo: "44020000001102942890",
  10312. Info: "2208",
  10313. }
  10314. customData = append(customData, custom15)
  10315. custom16 := &CustomData{
  10316. MsgId: "H44022900158202103301751082917",
  10317. PsnNo: "44020000001101662162",
  10318. Info: "2208",
  10319. }
  10320. customData = append(customData, custom16)
  10321. custom17 := &CustomData{
  10322. MsgId: "H44022900158202103301754147728",
  10323. PsnNo: "44020000000229014511",
  10324. Info: "2208",
  10325. }
  10326. customData = append(customData, custom17)
  10327. adminUser := c.GetAdminUserInfo()
  10328. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10329. for _, item := range customData {
  10330. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10331. fmt.Println(result)
  10332. }
  10333. }
  10334. func PathExists(path string) (bool, error) {
  10335. _, err := os.Stat(path)
  10336. if err == nil {
  10337. return true, nil
  10338. }
  10339. if os.IsNotExist(err) {
  10340. return false, nil
  10341. }
  10342. return false, err
  10343. }
  10344. //创建文件夹
  10345. func Mkdir(dir string) {
  10346. // 创建文件夹
  10347. exist, err := PathExists(dir)
  10348. if err != nil {
  10349. fmt.Println(err.Error())
  10350. } else {
  10351. if exist {
  10352. fmt.Println(dir + "文件夹已存在!")
  10353. } else {
  10354. // 文件夹名称,权限
  10355. err := os.Mkdir(dir, os.ModePerm)
  10356. if err != nil {
  10357. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10358. } else {
  10359. fmt.Println(dir + "文件夹创建成功!")
  10360. }
  10361. }
  10362. }
  10363. }
  10364. //压缩文件
  10365. func Zip(srcFile string, destZip string) error {
  10366. zipfile, err := os.Create(destZip)
  10367. if err != nil {
  10368. return err
  10369. }
  10370. defer zipfile.Close()
  10371. archive := zip.NewWriter(zipfile)
  10372. defer archive.Close()
  10373. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10374. if err != nil {
  10375. return err
  10376. }
  10377. header, err := zip.FileInfoHeader(info)
  10378. if err != nil {
  10379. return err
  10380. }
  10381. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10382. // header.Name = path
  10383. if info.IsDir() {
  10384. header.Name += "/"
  10385. } else {
  10386. header.Method = zip.Deflate
  10387. }
  10388. writer, err := archive.CreateHeader(header)
  10389. if err != nil {
  10390. return err
  10391. }
  10392. if !info.IsDir() {
  10393. file, err := os.Open(path)
  10394. if err != nil {
  10395. return err
  10396. }
  10397. defer file.Close()
  10398. _, err = io.Copy(writer, file)
  10399. }
  10400. return err
  10401. })
  10402. return err
  10403. }
  10404. func ReadFile(filePath string) []byte {
  10405. f, err := os.Open(filePath)
  10406. if err != nil {
  10407. fmt.Println("read file fail", err)
  10408. return nil
  10409. }
  10410. defer f.Close()
  10411. fd, err := ioutil.ReadAll(f)
  10412. if err != nil {
  10413. fmt.Println("read to fd fail", err)
  10414. return nil
  10415. }
  10416. return fd
  10417. }
  10418. func saveLog(result string, request string, infno string, desc string) {
  10419. org_id, _ := beego.AppConfig.Int64("org_id")
  10420. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10421. dir := miConfig.OrgName + "日志"
  10422. utils.Mkdir(dir)
  10423. month := time.Unix(1557042972, 0).Format("1")
  10424. year := time.Now().Format("2006")
  10425. month = time.Now().Format("01")
  10426. day := time.Now().Format("02")
  10427. hour := time.Now().Format("15")
  10428. min := time.Now().Format("04")
  10429. sec := time.Now().Format("05")
  10430. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10431. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10432. file_name := file + ".txt"
  10433. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10434. exist, _ := utils.PathExists(file_path)
  10435. if exist { //存在
  10436. fmt.Println("存在")
  10437. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10438. if err != nil {
  10439. fmt.Println("read fail")
  10440. }
  10441. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10442. n, _ := f.Seek(0, 2)
  10443. _, err = f.WriteAt([]byte(content), n)
  10444. } else { //不存在
  10445. fmt.Println("文件不存在,创建文件")
  10446. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10447. defer f.Close()
  10448. if err != nil {
  10449. } else {
  10450. _, err = f.Write([]byte("记录日志"))
  10451. }
  10452. }
  10453. }
  10454. type Charset string
  10455. const (
  10456. UTF8 = Charset("UTF-8")
  10457. GB18030 = Charset("GB18030")
  10458. )
  10459. func ConvertToString(src string, srcCode string, tagCode string) string {
  10460. srcCoder := mahonia.NewDecoder(srcCode)
  10461. srcResult := srcCoder.ConvertString(src)
  10462. tagCoder := mahonia.NewDecoder(tagCode)
  10463. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10464. result := string(cdata)
  10465. return result
  10466. }