his_api_controller.go 427KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685
  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.MedType = order.MedType
  427. //处方医嘱信息
  428. var orders []*models.FsiOrderDtos
  429. //for _, item := range prescriptions {
  430. // for _, subItem := range item.HisDoctorAdviceInfo {
  431. // var order models.FsiOrderDtos
  432. // order.RxID = strconv.FormatInt(item.ID, 10)
  433. // order.Rxno = strconv.FormatInt(item.ID, 10)
  434. // order.LongDrordFlag = "0"
  435. // order.HilistType = "1"
  436. // order.ChrgType = "1"
  437. // order.DrordBhvr = "-"
  438. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  439. // order.HosplistName = subItem.BaseDrugLib.DrugName
  440. // order.HilistLv = "1"
  441. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  442. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  443. // order.HosplistName = subItem.BaseDrugLib.DrugName
  444. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  445. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  446. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  447. // order.OwnpayAmt = ""
  448. // order.SelfpayAmt = ""
  449. // order.Spec = ""
  450. // order.SpecUnt = ""
  451. // order.DrordBegnDate = s_tm
  452. // order.DrordStopDate = ""
  453. // order.DrordDrCodg = "1"
  454. // order.DrordDeptName = department.Name
  455. // order.DrordDrCodg = "1"
  456. // order.DrordDrName = doctor_info.UserName
  457. // order.DrordDrProfttl = ""
  458. // order.CurrDrordFlag = "1"
  459. // orders = append(orders, &order)
  460. // }
  461. // for _, subItem := range item.HisPrescriptionProject {
  462. // if subItem.Type == 2 {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.HisProject.MedicalCode
  471. // order.HosplistName = subItem.HisProject.ProjectName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.HisProject.MedicalCode
  475. // order.HosplistName = subItem.HisProject.ProjectName
  476. // order.Cnt = subItem.Count
  477. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  478. //
  479. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  480. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  481. // order.OwnpayAmt = ""
  482. // order.SelfpayAmt = ""
  483. // order.Spec = ""
  484. // order.SpecUnt = ""
  485. // order.DrordBegnDate = s_tm
  486. // order.DrordStopDate = ""
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDeptName = department.Name
  489. // order.DrordDrCodg = "1"
  490. // order.DrordDrName = doctor_info.UserName
  491. // order.DrordDrProfttl = ""
  492. // order.CurrDrordFlag = "1"
  493. // orders = append(orders, &order)
  494. //
  495. // }
  496. // if subItem.Type == 3 {
  497. //
  498. // var order models.FsiOrderDtos
  499. // order.RxID = strconv.FormatInt(item.ID, 10)
  500. // order.Rxno = strconv.FormatInt(item.ID, 10)
  501. // order.LongDrordFlag = "0"
  502. // order.HilistType = "1"
  503. // order.ChrgType = "1"
  504. // order.DrordBhvr = "-"
  505. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  506. // order.HosplistName = subItem.GoodInfo.GoodName
  507. // order.HilistLv = "1"
  508. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  509. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  510. // order.HosplistName = subItem.GoodInfo.GoodName
  511. // order.Cnt = subItem.Count
  512. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  513. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  514. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  515. // order.OwnpayAmt = ""
  516. // order.SelfpayAmt = ""
  517. // order.Spec = ""
  518. // order.SpecUnt = ""
  519. // order.DrordBegnDate = s_tm
  520. // order.DrordStopDate = ""
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDeptName = department.Name
  523. // order.DrordDrCodg = "1"
  524. // order.DrordDrName = doctor_info.UserName
  525. // order.DrordDrProfttl = ""
  526. // order.CurrDrordFlag = "1"
  527. // orders = append(orders, &order)
  528. //
  529. // }
  530. // }
  531. //}
  532. for _, item := range prescriptions {
  533. for _, subItem := range item.HisDoctorAdviceInfo {
  534. var order models.FsiOrderDtos
  535. order.RxID = strconv.FormatInt(item.ID, 10)
  536. order.Rxno = strconv.FormatInt(item.ID, 10)
  537. order.LongDrordFlag = "0"
  538. order.HilistType = "1"
  539. order.ChrgType = "1"
  540. order.DrordBhvr = "-"
  541. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  542. order.HosplistName = subItem.BaseDrugLib.DrugName
  543. order.HilistLv = "1"
  544. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  545. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  546. order.HosplistName = subItem.BaseDrugLib.DrugName
  547. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  548. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  549. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  550. order.OwnpayAmt = ""
  551. order.SelfpayAmt = ""
  552. order.Spec = ""
  553. order.SpecUnt = ""
  554. order.DrordBegnDate = s_tm
  555. order.DrordStopDate = ""
  556. order.DrordDrCodg = "1"
  557. order.DrordDeptName = department.Name
  558. order.DrordDrCodg = "1"
  559. order.DrordDrName = doctor_info.UserName
  560. order.DrordDrProfttl = ""
  561. order.CurrDrordFlag = "1"
  562. orders = append(orders, &order)
  563. }
  564. for _, subItem := range item.HisPrescriptionProject {
  565. if subItem.Type == 2 {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.HisProject.MedicalCode
  574. order.HosplistName = subItem.HisProject.ProjectName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.HisProject.MedicalCode
  578. order.HosplistName = subItem.HisProject.ProjectName
  579. order.Cnt = subItem.Count
  580. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  581. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  582. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  583. order.OwnpayAmt = ""
  584. order.SelfpayAmt = ""
  585. order.Spec = ""
  586. order.SpecUnt = ""
  587. order.DrordBegnDate = s_tm
  588. order.DrordStopDate = ""
  589. order.DrordDrCodg = "1"
  590. order.DrordDeptName = department.Name
  591. order.DrordDrCodg = "1"
  592. order.DrordDrName = doctor_info.UserName
  593. order.DrordDrProfttl = ""
  594. order.CurrDrordFlag = "1"
  595. orders = append(orders, &order)
  596. }
  597. if subItem.Type == 3 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  606. order.HosplistName = subItem.GoodInfo.GoodName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  610. order.HosplistName = subItem.GoodInfo.GoodName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. }
  630. }
  631. //处方医嘱信息
  632. fed.MatnStas = "0"
  633. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  634. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  635. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  636. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  637. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  638. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  639. fed.SetlTotlnum = "1"
  640. fed.Insutype = his.Insutype
  641. fed.ReimFlag = "0"
  642. fed.OutSetlFlag = "0"
  643. var fopd []*models.FsiOperationDtosData
  644. data := make(map[string]interface{})
  645. data["fed"] = fed
  646. data["fdd"] = fdds
  647. data["fod"] = orders
  648. data["pd"] = pd
  649. data["pp"] = pp
  650. data["fopd"] = fopd
  651. data["trig_scen"] = trig_scen
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  656. resp, _ := client.Do(req)
  657. defer resp.Body.Close()
  658. body, ioErr := ioutil.ReadAll(resp.Body)
  659. if ioErr != nil {
  660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  662. return
  663. }
  664. var respJSON map[string]interface{}
  665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  668. return
  669. }
  670. //手术操作集合
  671. //手术操作集合
  672. }
  673. func (c *HisApiController) Check() {
  674. psn_no := c.GetString("psn_no")
  675. in := c.GetString("in")
  676. mt := c.GetString("mt")
  677. baseParams := models.BaseParams{
  678. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  679. FixmedinsCode: "H15049901371",
  680. InsuplcAdmdvs: "150499",
  681. MdtrtareaAdmvs: "150499",
  682. OrgName: "赤峰费森血液透析中心",
  683. Doctor: "1111",
  684. }
  685. service.Gdyb2001(baseParams, psn_no, in, mt)
  686. }
  687. func (c *HisApiController) GetPsnNcdsInfo() {
  688. admin_user_id, _ := c.GetInt64("admin_user_id")
  689. patient_id, _ := c.GetInt64("patient_id")
  690. id, _ := c.GetInt64("id")
  691. adminUser := c.GetAdminUserInfo()
  692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  693. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  694. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  695. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  696. psn_record, _ := service.GetPsnNCDSRecordById(id)
  697. //
  698. //if psn_record.ID == 0 {
  699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  700. // return
  701. //}
  702. var res Result5301
  703. var res10265 Result5301For10265
  704. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  705. psn_info, _ := service.GetPsnByPatientId(patient_id)
  706. var api string
  707. if miConfig.MdtrtareaAdmvs == "320921" {
  708. 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 +
  709. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  710. } else {
  711. 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 +
  712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  713. }
  714. resp, requestErr := http.Get(api)
  715. if requestErr != nil {
  716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  717. return
  718. }
  719. body, ioErr := ioutil.ReadAll(resp.Body)
  720. if ioErr != nil {
  721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  723. return
  724. }
  725. var respJSON map[string]interface{}
  726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. return
  730. }
  731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  732. result, _ := json.Marshal(respJSON)
  733. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  734. utils.ErrorLog("解析失败:%v", err)
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  736. return
  737. }
  738. res.ErrMsg = res10265.ErrMsg
  739. res.Output = res10265.Output
  740. res.InfRefmsgid = res10265.InfRefmsgid
  741. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  742. res.Infcode = infocode
  743. } else {
  744. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  745. var dat map[string]interface{}
  746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  747. fmt.Println(dat)
  748. } else {
  749. fmt.Println(err)
  750. }
  751. userJSONBytes, _ := json.Marshal(dat)
  752. if miConfig.Code == "H15049901371" {
  753. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  754. utils.ErrorLog("解析失败:%v", err)
  755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  756. return
  757. }
  758. res.InfRefmsgid = res10265.InfRefmsgid
  759. res.Output = res10265.Output
  760. res.ErrMsg = res10265.ErrMsg
  761. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  762. res.Infcode = infocode
  763. } else {
  764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  765. utils.ErrorLog("解析失败:%v", err)
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  767. return
  768. }
  769. }
  770. }
  771. if res.Infcode == 0 {
  772. c.ServeSuccessJSON(map[string]interface{}{
  773. "result": res.Output.Result,
  774. })
  775. }
  776. }
  777. func (c *HisApiController) CheckInsutype() {
  778. his_patient_id, _ := c.GetInt64("his_patient_id")
  779. admin_user_id, _ := c.GetInt64("admin_user_id")
  780. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  781. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  782. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  783. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  784. var dat map[string]interface{}
  785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  786. fmt.Println(dat)
  787. } else {
  788. fmt.Println(err)
  789. }
  790. userJSONBytes, _ := json.Marshal(dat)
  791. var res Result90100
  792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  793. utils.ErrorLog("解析失败:%v", err)
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. if res.Infcode != 0 {
  798. c.ServeSuccessJSON(map[string]interface{}{
  799. "failed_code": -10,
  800. "msg": res.ErrMsg,
  801. })
  802. return
  803. } else {
  804. fmt.Println(res)
  805. }
  806. }
  807. func (c *HisApiController) CheckCardPWD() {
  808. card_pwd := c.GetString("card_pwd")
  809. his_patient_id, _ := c.GetInt64("his_patient_id")
  810. admin_user_id, _ := c.GetInt64("admin_user_id")
  811. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  813. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  814. psn, _ := service.GetPsnByPatientId(his.PatientId)
  815. bas := strings.Split(psn.CardInfo, "|")
  816. basNumber := bas[2]
  817. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  818. var dat map[string]interface{}
  819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  820. fmt.Println(dat)
  821. } else {
  822. fmt.Println(err)
  823. }
  824. userJSONBytes, _ := json.Marshal(dat)
  825. var res Result90991
  826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  827. utils.ErrorLog("解析失败:%v", err)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. if res.Infcode != 0 {
  832. c.ServeSuccessJSON(map[string]interface{}{
  833. "failed_code": -10,
  834. "msg": res.ErrMsg,
  835. })
  836. return
  837. } else {
  838. if res.Output.Result.CheckStat == "0" {
  839. var msg string
  840. switch res.Output.Result.CardStat {
  841. case "00":
  842. msg = "未激活"
  843. break
  844. case "10":
  845. msg = "激活"
  846. break
  847. case "20":
  848. msg = "窗口挂失"
  849. break
  850. case "21":
  851. msg = "电话挂失"
  852. break
  853. case "22":
  854. msg = "单位网上申报挂失"
  855. break
  856. case "23":
  857. msg = "保健办挂失"
  858. break
  859. case "24":
  860. msg = "个人网上挂失"
  861. break
  862. case "25":
  863. msg = "网上服务大厅挂失"
  864. break
  865. case "30":
  866. msg = "注销"
  867. break
  868. case "40":
  869. msg = "回收"
  870. break
  871. case "99":
  872. msg = "制卡中(无效卡)"
  873. break
  874. }
  875. c.ServeSuccessJSON(map[string]interface{}{
  876. "failed_code": -10,
  877. "msg": msg,
  878. })
  879. return
  880. } else {
  881. c.ServeSuccessJSON(map[string]interface{}{
  882. "msg": "校验成功",
  883. })
  884. return
  885. }
  886. }
  887. }
  888. func (c *HisApiController) ReadCard() {
  889. id_card_type, _ := c.GetInt64("id_card_type")
  890. admin_user_id, _ := c.GetInt64("admin_user_id")
  891. certificates, _ := c.GetInt64("certificates")
  892. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  893. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  894. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  895. switch id_card_type {
  896. case 1:
  897. if miConfig.MdtrtareaAdmvs == "421300" {
  898. var res ResultTwo
  899. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  900. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  901. "&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)
  902. resp, requestErr := http.Get(api)
  903. if requestErr != nil {
  904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  905. return
  906. }
  907. body, ioErr := ioutil.ReadAll(resp.Body)
  908. if ioErr != nil {
  909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var respJSON map[string]interface{}
  914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. }
  919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  920. result, _ := json.Marshal(respJSON)
  921. fmt.Println("log")
  922. fmt.Println(string(result))
  923. if err := json.Unmarshal([]byte(result), &res); err != nil {
  924. utils.ErrorLog("解析失败:%v", err)
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  926. return
  927. }
  928. if res.Infcode == 0 {
  929. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  930. if err == gorm.ErrRecordNotFound {
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  932. return
  933. } else if err != nil {
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  935. return
  936. } else {
  937. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  938. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  939. infoStr := string(Iinfos)
  940. idetinfoStr := string(Idetinfos)
  941. psn := &models.HisPsn{
  942. PsnNo: res.Output.Baseinfo.PsnNo,
  943. Age: res.Output.Baseinfo.Age,
  944. PatientId: patient.ID,
  945. Certno: res.Output.Baseinfo.Certno,
  946. Brdy: res.Output.Baseinfo.Brdy,
  947. Gend: res.Output.Baseinfo.Gend,
  948. Naty: res.Output.Baseinfo.Naty,
  949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  950. PsnName: res.Output.Baseinfo.PsnName,
  951. Idetinfo: idetinfoStr,
  952. Insuinfo: infoStr,
  953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  954. }
  955. service.CreateHisPsn(psn)
  956. c.ServeSuccessJSON(map[string]interface{}{
  957. "patient": patient,
  958. "number": res.Output.Baseinfo.Certno,
  959. })
  960. }
  961. } else {
  962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  963. return
  964. }
  965. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  966. var api string
  967. if miConfig.MdtrtareaAdmvs == "320921" {
  968. 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 +
  969. "&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
  970. fmt.Println(api)
  971. } else {
  972. 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 +
  973. "&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)
  974. }
  975. resp, requestErr := http.Get(api)
  976. if requestErr != nil {
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. body, ioErr := ioutil.ReadAll(resp.Body)
  981. if ioErr != nil {
  982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. var respJSON map[string]interface{}
  987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. var status string
  993. status = respJSON["data"].(map[string]interface{})["status"].(string)
  994. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  995. //console.log()
  996. fmt.Println("type===")
  997. fmt.Println(card_type)
  998. var token string
  999. var res ResultTwo //1101结果
  1000. var res10265 ResultTwo10265 //1101结果
  1001. var card_info string //卡信息
  1002. var busi_card_info string
  1003. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1004. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1005. if status == "0" { //读卡成功
  1006. if card_type == "1" {
  1007. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1008. result, _ := json.Marshal(respJSON)
  1009. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1010. utils.ErrorLog("解析失败:%v", err)
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. res.ErrMsg = res10265.ErrMsg
  1015. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1016. res.Infcode = infocode
  1017. res.Output = res10265.Output
  1018. res.InfRefmsgid = res10265.InfRefmsgid
  1019. } else {
  1020. //var card_info string //卡信息
  1021. //var busi_card_info string
  1022. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1023. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1024. //fmt.Println(card_info)
  1025. //fmt.Println(busi_card_info)
  1026. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1027. result, _ := json.Marshal(respJSON)
  1028. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1029. utils.ErrorLog("解析失败:%v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. res.ErrMsg = res10265.ErrMsg
  1034. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1035. res.Infcode = infocode
  1036. res.Output = res10265.Output
  1037. res.InfRefmsgid = res10265.InfRefmsgid
  1038. }
  1039. if res.Infcode == 0 {
  1040. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1041. if err == gorm.ErrRecordNotFound {
  1042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1043. return
  1044. } else if err != nil {
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1046. return
  1047. } else {
  1048. if card_type == "1" {
  1049. bas := strings.Split(card_info, "|")
  1050. basNumber := bas[2]
  1051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1053. infoStr := string(Iinfos)
  1054. idetinfoStr := string(Idetinfos)
  1055. psn := &models.HisPsn{
  1056. PsnNo: res.Output.Baseinfo.PsnNo,
  1057. Age: res.Output.Baseinfo.Age,
  1058. PatientId: patient.ID,
  1059. Certno: res.Output.Baseinfo.Certno,
  1060. Brdy: res.Output.Baseinfo.Brdy,
  1061. Gend: res.Output.Baseinfo.Gend,
  1062. Naty: res.Output.Baseinfo.Naty,
  1063. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1064. PsnName: res.Output.Baseinfo.PsnName,
  1065. Idetinfo: idetinfoStr,
  1066. Insuinfo: infoStr,
  1067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1068. CardInfo: card_info,
  1069. VerifyNumber: busi_card_info,
  1070. }
  1071. service.CreateHisPsn(psn)
  1072. c.ServeSuccessJSON(map[string]interface{}{
  1073. "patient": patient,
  1074. "number": basNumber,
  1075. })
  1076. } else {
  1077. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1078. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1079. infoStr := string(Iinfos)
  1080. idetinfoStr := string(Idetinfos)
  1081. psn := &models.HisPsn{
  1082. PsnNo: res.Output.Baseinfo.PsnNo,
  1083. Age: res.Output.Baseinfo.Age,
  1084. PatientId: patient.ID,
  1085. Certno: res.Output.Baseinfo.Certno,
  1086. Brdy: res.Output.Baseinfo.Brdy,
  1087. Gend: res.Output.Baseinfo.Gend,
  1088. Naty: res.Output.Baseinfo.Naty,
  1089. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1090. PsnName: res.Output.Baseinfo.PsnName,
  1091. Idetinfo: idetinfoStr,
  1092. Insuinfo: infoStr,
  1093. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1094. CardInfo: card_info,
  1095. VerifyNumber: token,
  1096. }
  1097. service.CreateHisPsn(psn)
  1098. c.ServeSuccessJSON(map[string]interface{}{
  1099. "patient": patient,
  1100. "number": token,
  1101. })
  1102. }
  1103. }
  1104. } else {
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1106. return
  1107. }
  1108. } else { //读卡失败
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1110. return
  1111. }
  1112. } else {
  1113. if initFlag == 0 {
  1114. c.TestGetBasBaseInit()
  1115. }
  1116. basStr := c.GetBasBaseInfo()
  1117. if len(basStr) == 0 {
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1119. return
  1120. }
  1121. fmt.Println(basStr)
  1122. bas := strings.Split(basStr, "|")
  1123. basNumber := bas[1]
  1124. fmt.Println(basNumber)
  1125. card_sn := bas[3]
  1126. fmt.Println(card_sn)
  1127. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1128. var dat map[string]interface{}
  1129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1130. fmt.Println(dat)
  1131. } else {
  1132. fmt.Println(err)
  1133. }
  1134. userJSONBytes, _ := json.Marshal(dat)
  1135. var res ResultTwo
  1136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. if res.Infcode == 0 {
  1142. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1143. if err == gorm.ErrRecordNotFound {
  1144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1145. return
  1146. } else if err != nil {
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1148. return
  1149. } else {
  1150. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1151. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1152. infoStr := string(Iinfos)
  1153. idetinfoStr := string(Idetinfos)
  1154. psn := &models.HisPsn{
  1155. PsnNo: res.Output.Baseinfo.PsnNo,
  1156. Age: res.Output.Baseinfo.Age,
  1157. PatientId: patient.ID,
  1158. Certno: res.Output.Baseinfo.Certno,
  1159. Brdy: res.Output.Baseinfo.Brdy,
  1160. Gend: res.Output.Baseinfo.Gend,
  1161. Naty: res.Output.Baseinfo.Naty,
  1162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1163. PsnName: res.Output.Baseinfo.PsnName,
  1164. Idetinfo: idetinfoStr,
  1165. Insuinfo: infoStr,
  1166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1167. CardInfo: basStr,
  1168. VerifyNumber: "",
  1169. }
  1170. service.CreateHisPsn(psn)
  1171. c.ServeSuccessJSON(map[string]interface{}{
  1172. "patient": patient,
  1173. "number": basNumber,
  1174. })
  1175. }
  1176. } else {
  1177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1178. return
  1179. }
  1180. break
  1181. }
  1182. case 2:
  1183. SFZStr := c.GetSFZBaseInfo()
  1184. id_card_str := strings.Split(SFZStr, "^")
  1185. id_card_number := id_card_str[0]
  1186. card_sn := ""
  1187. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1188. var dat map[string]interface{}
  1189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1190. fmt.Println(dat)
  1191. } else {
  1192. fmt.Println(err)
  1193. }
  1194. userJSONBytes, _ := json.Marshal(dat)
  1195. var res ResultTwo
  1196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1197. utils.ErrorLog("解析失败:%v", err)
  1198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1199. return
  1200. }
  1201. if res.Infcode == 0 {
  1202. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1203. if err == gorm.ErrRecordNotFound {
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1205. return
  1206. } else if err != nil {
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1208. return
  1209. } else {
  1210. c.ServeSuccessJSON(map[string]interface{}{
  1211. "patient": patient,
  1212. "number": id_card_number,
  1213. })
  1214. }
  1215. } else {
  1216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1217. return
  1218. }
  1219. break
  1220. case 3:
  1221. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1222. var api string
  1223. if miConfig.MdtrtareaAdmvs == "320921" {
  1224. 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 +
  1225. "&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
  1226. fmt.Println(api)
  1227. } else {
  1228. 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 +
  1229. "&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)
  1230. }
  1231. resp, requestErr := http.Get(api)
  1232. if requestErr != nil {
  1233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1234. return
  1235. }
  1236. body, ioErr := ioutil.ReadAll(resp.Body)
  1237. if ioErr != nil {
  1238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1240. return
  1241. }
  1242. var respJSON map[string]interface{}
  1243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1246. return
  1247. }
  1248. var status string
  1249. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1250. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1251. var token string
  1252. var res ResultTwo //1101结果
  1253. var res10265 ResultTwo10265 //1101结果
  1254. var card_info string //卡信息
  1255. var busi_card_info string
  1256. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1257. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1258. if status == "0" { //读卡成功
  1259. if card_type == "1" {
  1260. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1261. result, _ := json.Marshal(respJSON)
  1262. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1263. utils.ErrorLog("解析失败:%v", err)
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1265. return
  1266. }
  1267. res.ErrMsg = res10265.ErrMsg
  1268. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1269. res.Infcode = infocode
  1270. res.Output = res10265.Output
  1271. res.InfRefmsgid = res10265.InfRefmsgid
  1272. } else {
  1273. //var card_info string //卡信息
  1274. //var busi_card_info string
  1275. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1276. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1277. //fmt.Println(card_info)
  1278. //fmt.Println(busi_card_info)
  1279. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1280. result, _ := json.Marshal(respJSON)
  1281. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1282. utils.ErrorLog("解析失败:%v", err)
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1284. return
  1285. }
  1286. res.ErrMsg = res10265.ErrMsg
  1287. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1288. res.Infcode = infocode
  1289. res.Output = res10265.Output
  1290. res.InfRefmsgid = res10265.InfRefmsgid
  1291. }
  1292. if res.Infcode == 0 {
  1293. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1294. if err == gorm.ErrRecordNotFound {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1296. return
  1297. } else if err != nil {
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1299. return
  1300. } else {
  1301. if card_type == "1" {
  1302. bas := strings.Split(card_info, "|")
  1303. basNumber := bas[2]
  1304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1306. infoStr := string(Iinfos)
  1307. idetinfoStr := string(Idetinfos)
  1308. psn := &models.HisPsn{
  1309. PsnNo: res.Output.Baseinfo.PsnNo,
  1310. Age: res.Output.Baseinfo.Age,
  1311. PatientId: patient.ID,
  1312. Certno: res.Output.Baseinfo.Certno,
  1313. Brdy: res.Output.Baseinfo.Brdy,
  1314. Gend: res.Output.Baseinfo.Gend,
  1315. Naty: res.Output.Baseinfo.Naty,
  1316. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1317. PsnName: res.Output.Baseinfo.PsnName,
  1318. Idetinfo: idetinfoStr,
  1319. Insuinfo: infoStr,
  1320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1321. CardInfo: card_info,
  1322. VerifyNumber: busi_card_info,
  1323. }
  1324. service.CreateHisPsn(psn)
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "patient": patient,
  1327. "number": basNumber,
  1328. })
  1329. } else {
  1330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1331. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1332. infoStr := string(Iinfos)
  1333. idetinfoStr := string(Idetinfos)
  1334. psn := &models.HisPsn{
  1335. PsnNo: res.Output.Baseinfo.PsnNo,
  1336. Age: res.Output.Baseinfo.Age,
  1337. PatientId: patient.ID,
  1338. Certno: res.Output.Baseinfo.Certno,
  1339. Brdy: res.Output.Baseinfo.Brdy,
  1340. Gend: res.Output.Baseinfo.Gend,
  1341. Naty: res.Output.Baseinfo.Naty,
  1342. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1343. PsnName: res.Output.Baseinfo.PsnName,
  1344. Idetinfo: idetinfoStr,
  1345. Insuinfo: infoStr,
  1346. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1347. CardInfo: card_info,
  1348. VerifyNumber: token,
  1349. }
  1350. service.CreateHisPsn(psn)
  1351. c.ServeSuccessJSON(map[string]interface{}{
  1352. "patient": patient,
  1353. "number": token,
  1354. })
  1355. }
  1356. }
  1357. } else {
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1359. return
  1360. }
  1361. } else { //读卡失败
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1363. return
  1364. }
  1365. }
  1366. break
  1367. case 4:
  1368. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1369. var api string
  1370. if miConfig.MdtrtareaAdmvs == "320921" {
  1371. 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 +
  1372. "&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
  1373. fmt.Println(api)
  1374. } else {
  1375. 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 +
  1376. "&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)
  1377. }
  1378. resp, requestErr := http.Get(api)
  1379. if requestErr != nil {
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1381. return
  1382. }
  1383. body, ioErr := ioutil.ReadAll(resp.Body)
  1384. if ioErr != nil {
  1385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. return
  1388. }
  1389. var respJSON map[string]interface{}
  1390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1393. return
  1394. }
  1395. var status string
  1396. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1397. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1398. var token string
  1399. var res ResultTwo //1101结果
  1400. var res10265 ResultTwo10265 //1101结果
  1401. if status == "0" { //读卡成功
  1402. var card_info string //卡信息
  1403. var busi_card_info string
  1404. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1405. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1406. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1407. fmt.Println(card_info)
  1408. fmt.Println(busi_card_info)
  1409. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1410. result, _ := json.Marshal(respJSON)
  1411. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1412. utils.ErrorLog("解析失败:%v", err)
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. return
  1415. }
  1416. res.ErrMsg = res10265.ErrMsg
  1417. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1418. res.Infcode = infocode
  1419. res.Output = res10265.Output
  1420. res.InfRefmsgid = res10265.InfRefmsgid
  1421. if res.Infcode == 0 {
  1422. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1423. if err == gorm.ErrRecordNotFound {
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1425. return
  1426. } else if err != nil {
  1427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1428. return
  1429. } else {
  1430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1432. infoStr := string(Iinfos)
  1433. idetinfoStr := string(Idetinfos)
  1434. psn := &models.HisPsn{
  1435. PsnNo: res.Output.Baseinfo.PsnNo,
  1436. Age: res.Output.Baseinfo.Age,
  1437. PatientId: patient.ID,
  1438. Certno: res.Output.Baseinfo.Certno,
  1439. Brdy: res.Output.Baseinfo.Brdy,
  1440. Gend: res.Output.Baseinfo.Gend,
  1441. Naty: res.Output.Baseinfo.Naty,
  1442. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1443. PsnName: res.Output.Baseinfo.PsnName,
  1444. Idetinfo: idetinfoStr,
  1445. Insuinfo: infoStr,
  1446. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1447. CardInfo: card_info,
  1448. VerifyNumber: token,
  1449. }
  1450. service.CreateHisPsn(psn)
  1451. c.ServeSuccessJSON(map[string]interface{}{
  1452. "patient": patient,
  1453. "number": token,
  1454. })
  1455. }
  1456. } else {
  1457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1458. return
  1459. }
  1460. } else { //读卡失败
  1461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1462. return
  1463. }
  1464. }
  1465. break
  1466. }
  1467. }
  1468. var initFlag int64 = 0
  1469. func (c *HisApiController) TestGetBasBaseInit() {
  1470. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1471. Iinit := DllDef.MustFindProc("Init")
  1472. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1473. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1474. if ret != 0 {
  1475. fmt.Println("SSCard的报错原因:", err)
  1476. fmt.Println("SSCard的运算结果为:", ret)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1478. return
  1479. }
  1480. result := int(ret)
  1481. fmt.Println("SSCard的运算结果为1:", result)
  1482. initFlag = 1
  1483. return
  1484. }
  1485. func (c *HisApiController) GetSFZBaseInfo() string {
  1486. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1487. readCard := DllDef.MustFindProc("ReadSFZ")
  1488. if readCard == nil {
  1489. fmt.Println("readcard is nil")
  1490. readCard = DllDef.MustFindProc("ReadSFZ")
  1491. }
  1492. str := make([]byte, 256)
  1493. str1 := make([]byte, 256)
  1494. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1495. fmt.Println(r)
  1496. return string(str)
  1497. }
  1498. func (c *HisApiController) GetBasBaseInfo() string {
  1499. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1500. readCard := DllDef.MustFindProc("ReadCardBas")
  1501. if readCard == nil {
  1502. fmt.Println("readcard is nil")
  1503. readCard = DllDef.MustFindProc("ReadCardBas")
  1504. }
  1505. str := make([]byte, 1024)
  1506. str1 := make([]byte, 1024)
  1507. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1508. fmt.Println(string(str1))
  1509. fmt.Println(string(str))
  1510. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1511. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1512. if ret2 != 0 {
  1513. return ""
  1514. }
  1515. return string(str)
  1516. }
  1517. type CustomFundPay struct {
  1518. FundPayType string `json:"fund_pay_type"`
  1519. FundPayamt float64 `json:"fund_payamt"`
  1520. }
  1521. func (c *HisApiController) GetSettleList() {
  1522. order_id, _ := c.GetInt64("order_id")
  1523. admin_user_id, _ := c.GetInt64("admin_user_id")
  1524. order, _ := service.GetHisOrderByIDTwo(order_id)
  1525. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1526. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1527. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1528. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1529. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1531. if order.ID == 0 {
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1533. return
  1534. }
  1535. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1536. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1537. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1538. fmt.Println(count)
  1539. var zero string
  1540. number := count + 1
  1541. if number >= 1000 {
  1542. zero = "0000" + strconv.FormatInt(number, 10)
  1543. } else if number >= 10000 {
  1544. zero = "000" + strconv.FormatInt(number, 10)
  1545. } else if number >= 100000 {
  1546. zero = "00" + strconv.FormatInt(number, 10)
  1547. } else if number >= 1000000 {
  1548. zero = "0" + strconv.FormatInt(number, 10)
  1549. } else {
  1550. zero = strconv.FormatInt(number, 10)
  1551. }
  1552. fmt.Println(zero)
  1553. struct4101 := service.Struct4101{
  1554. PsnNo: order.PsnNo,
  1555. MdtrtId: order.MdtrtId,
  1556. SetlId: order.SetlId,
  1557. PsnName: order.PsnName,
  1558. Gend: order.Gend,
  1559. Brdy: his.Brdy,
  1560. Age: his.Age,
  1561. Naty: order.Naty,
  1562. PatnCertType: "01",
  1563. Certno: order.Certno,
  1564. Prfs: "90",
  1565. ConerName: roles[0].UserName,
  1566. PatnRlts: "99",
  1567. ConerAddr: miConfig.OrgName,
  1568. ConerTel: admin.Mobile,
  1569. HiType: order.Insutype,
  1570. Insuplc: miConfig.InsuplcAdmdvs,
  1571. MaindiagFlag: "1",
  1572. BillCode: last_order.FaPiaoCode,
  1573. BillNo: zero,
  1574. BizSn: order.Number,
  1575. PsnSelfPay: order.PsnPartAmt,
  1576. PsnOwnPay: order.PsnPartAmt,
  1577. AcctPay: order.AcctPay,
  1578. PsnCashpay: order.PsnCashPay,
  1579. HiPaymtd: "1",
  1580. Hsorg: miConfig.InsuplcAdmdvs,
  1581. HsorgOpter: miConfig.InsuplcAdmdvs,
  1582. MedinsFillPsn: curRoles.UserName,
  1583. MedinsFillDept: depart.Name,
  1584. IptMedType: "2",
  1585. }
  1586. struct4101.SetlBegnDate = order.SetlTime
  1587. struct4101.SetlEndDate = order.SetlTime
  1588. time_arr := strings.Split(order.SetlTime, " ")
  1589. struct4101.AdmTime = time_arr[0]
  1590. struct4101.AdmEndTime = time_arr[0]
  1591. var rf []CustomFundPay
  1592. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1593. var tempFunPays []service.CustomStruct
  1594. for _, item := range rf {
  1595. var tempFunPay service.CustomStruct
  1596. tempFunPay.FundPayamt = item.FundPayamt
  1597. tempFunPay.FundPayType = item.FundPayType
  1598. tempFunPays = append(tempFunPays, tempFunPay)
  1599. }
  1600. struct4101.CustomStruct = tempFunPays
  1601. var tempDiaginfos []service.DiaginfoStructTwo
  1602. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1603. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1604. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1605. var config []*models.HisXtDiagnoseConfig
  1606. for _, item := range diagnosis_ids {
  1607. id, _ := strconv.ParseInt(item, 10, 64)
  1608. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1609. config = append(config, &diagnosisConfig)
  1610. }
  1611. for index, item := range config {
  1612. if index == 0 {
  1613. var tempDiaginfo service.DiaginfoStructTwo
  1614. tempDiaginfo.DiagCode = item.CountryCode
  1615. tempDiaginfo.DiagName = item.CountryContentName
  1616. tempDiaginfo.DiagType = "1"
  1617. tempDiaginfo.MaindiagFlag = "1"
  1618. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1619. } else {
  1620. var tempDiaginfo service.DiaginfoStructTwo
  1621. tempDiaginfo.DiagCode = item.CountryCode
  1622. tempDiaginfo.DiagName = item.CountryContentName
  1623. tempDiaginfo.DiagType = "2"
  1624. tempDiaginfo.MaindiagFlag = "0"
  1625. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1626. }
  1627. }
  1628. struct4101.Diseinfo = tempDiaginfos
  1629. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1630. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1631. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1632. tempOpspdiseinfo2.OprnOprtCode = ""
  1633. tempOpspdiseinfo2.OprnOprtName = ""
  1634. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1635. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1636. var iteminfo service.IteminfoStruct
  1637. var bedCostTotal float64 = 0 //床位总费
  1638. var bedCostSelfTotal float64 = 0 //床位自费
  1639. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1640. var operationCostTotal float64 = 0 //手术费
  1641. var operationCostSelfTotal float64 = 0 //手术费
  1642. var operationCostPartSelfTotal float64 = 0 //手术费
  1643. var otherCostTotal float64 = 0 //其他费用
  1644. var otherCostSelfTotal float64 = 0 //其他费用
  1645. var otherCostPartSelfTotal float64 = 0 //其他费用
  1646. var materialCostTotal float64 = 0 //材料费
  1647. var materialCostSelfTotal float64 = 0 //材料费
  1648. var materialCostPartSelfTotal float64 = 0 //材料费
  1649. var westernMedicineCostTotal float64 = 0 //西药费
  1650. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1651. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1652. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1653. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1654. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1655. var checkCostTotal float64 = 0 //检查费
  1656. var checkCostSelfTotal float64 = 0 //检查费
  1657. var checkCostPartSelfTotal float64 = 0 //检查费
  1658. var laboratoryCostTotal float64 = 0 //化验费
  1659. var laboratoryCostSelfTotal float64 = 0 //化验费
  1660. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1661. var treatCostTotal float64 = 0 //治疗费用
  1662. var treatCostSelfTotal float64 = 0 //治疗费用
  1663. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1664. decimal.DivisionPrecision = 2
  1665. var bed_fulamt_ownpay_amt float64 = 0
  1666. var operation_fulamt_ownpay_amt float64 = 0
  1667. var other_fulamt_ownpay_amt float64 = 0
  1668. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1669. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1670. var check_fulamt_ownpay_amt float64 = 0
  1671. var material_fulamt_ownpay_amt float64 = 0
  1672. var laboratory_fulamt_ownpay_amt float64 = 0
  1673. var treat_fulamt_ownpay_amt float64 = 0
  1674. var bed_claa_sunmfee float64 = 0
  1675. var bed_clab_amt float64 = 0
  1676. var bed_other_amt float64 = 0
  1677. var operation_claa_sunmfee float64 = 0
  1678. var operation_clab_amt float64 = 0
  1679. var operation_other_amt float64 = 0
  1680. var other_claa_sunmfee float64 = 0
  1681. var other_clab_amt float64 = 0
  1682. var other_other_amt float64 = 0
  1683. var westernMedicine_claa_sunmfee float64 = 0
  1684. var westernMedicine_clab_amt float64 = 0
  1685. var westernMedicine_other_amt float64 = 0
  1686. var chineseTraditional_claa_sunmfee float64 = 0
  1687. var chineseTraditional_clab_amt float64 = 0
  1688. var chineseTraditional_other_amt float64 = 0
  1689. var check_claa_sunmfee float64 = 0
  1690. var check_clab_amt float64 = 0
  1691. var check_other_amt float64 = 0
  1692. var material_claa_sunmfee float64 = 0
  1693. var material_clab_amt float64 = 0
  1694. var material_other_amt float64 = 0
  1695. var laboratory_claa_sunmfee float64 = 0
  1696. var laboratory_clab_amt float64 = 0
  1697. var laboratory_other_amt float64 = 0
  1698. var treat_claa_sunmfee float64 = 0
  1699. var treat_clab_amt float64 = 0
  1700. var treat_other_amt float64 = 0
  1701. for _, item := range order.HisOrderInfo {
  1702. if item.MedChrgitmType == "01" { //床位费
  1703. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1704. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1705. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1706. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1707. if item.ChrgitmLv == "1" {
  1708. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1709. }
  1710. if item.ChrgitmLv == "2" {
  1711. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1712. }
  1713. if item.ChrgitmLv == "3" {
  1714. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1715. }
  1716. }
  1717. if item.MedChrgitmType == "03" { //检查费
  1718. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1719. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1720. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1721. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1722. if item.ChrgitmLv == "1" {
  1723. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1724. }
  1725. if item.ChrgitmLv == "2" {
  1726. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1727. }
  1728. if item.ChrgitmLv == "3" {
  1729. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1730. }
  1731. }
  1732. if item.MedChrgitmType == "04" { //化验费
  1733. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1734. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1735. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1736. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1737. if item.ChrgitmLv == "1" {
  1738. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1739. }
  1740. if item.ChrgitmLv == "2" {
  1741. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1742. }
  1743. if item.ChrgitmLv == "3" {
  1744. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1745. }
  1746. }
  1747. if item.MedChrgitmType == "05" { //治疗费
  1748. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1749. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1750. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1751. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1752. if item.ChrgitmLv == "1" {
  1753. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1754. }
  1755. if item.ChrgitmLv == "2" {
  1756. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1757. }
  1758. if item.ChrgitmLv == "3" {
  1759. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1760. }
  1761. }
  1762. if item.MedChrgitmType == "06" { //手术费
  1763. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1764. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1765. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1766. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1767. if item.ChrgitmLv == "1" {
  1768. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1769. }
  1770. if item.ChrgitmLv == "2" {
  1771. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1772. }
  1773. if item.ChrgitmLv == "3" {
  1774. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1775. }
  1776. }
  1777. if item.MedChrgitmType == "08" { //材料费
  1778. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1779. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1780. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1781. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1782. if item.ChrgitmLv == "1" {
  1783. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1784. }
  1785. if item.ChrgitmLv == "2" {
  1786. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1787. }
  1788. if item.ChrgitmLv == "3" {
  1789. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1790. }
  1791. }
  1792. if item.MedChrgitmType == "09" { //西药费
  1793. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1794. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1795. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1796. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1797. if item.ChrgitmLv == "1" {
  1798. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1799. }
  1800. if item.ChrgitmLv == "2" {
  1801. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1802. }
  1803. if item.ChrgitmLv == "3" {
  1804. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1805. }
  1806. }
  1807. if item.MedChrgitmType == "11" { //中成费
  1808. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1809. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1810. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1811. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1812. if item.ChrgitmLv == "1" {
  1813. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1814. }
  1815. if item.ChrgitmLv == "2" {
  1816. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1817. }
  1818. if item.ChrgitmLv == "3" {
  1819. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1820. }
  1821. }
  1822. if item.MedChrgitmType == "14" { //其他费
  1823. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1824. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1825. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1826. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1827. if item.ChrgitmLv == "1" {
  1828. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1829. }
  1830. if item.ChrgitmLv == "2" {
  1831. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1832. }
  1833. if item.ChrgitmLv == "3" {
  1834. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1835. }
  1836. }
  1837. }
  1838. var iteminfoStructs []service.IteminfoStruct
  1839. if bedCostTotal != 0 {
  1840. iteminfo.MedChrgitm = "01"
  1841. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1842. iteminfo.Amt = bedCostTotal
  1843. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1844. iteminfo.ClabAmt = bed_clab_amt
  1845. iteminfo.OthAmt = bed_other_amt
  1846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1847. }
  1848. if checkCostTotal != 0 {
  1849. iteminfo.MedChrgitm = "03"
  1850. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1851. iteminfo.Amt = checkCostTotal
  1852. iteminfo.ClaaSumfee = check_claa_sunmfee
  1853. iteminfo.ClabAmt = check_clab_amt
  1854. iteminfo.OthAmt = check_other_amt
  1855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1856. }
  1857. if laboratoryCostTotal != 0 {
  1858. iteminfo.MedChrgitm = "04"
  1859. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1860. iteminfo.Amt = laboratoryCostTotal
  1861. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1862. iteminfo.ClabAmt = laboratory_clab_amt
  1863. iteminfo.OthAmt = laboratory_other_amt
  1864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1866. }
  1867. if treatCostTotal != 0 {
  1868. iteminfo.MedChrgitm = "05"
  1869. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1870. iteminfo.Amt = treatCostTotal
  1871. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1872. iteminfo.ClabAmt = treat_clab_amt
  1873. iteminfo.OthAmt = treat_other_amt
  1874. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1875. //(struct4101.IteminfoStruct, iteminfo)
  1876. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1877. }
  1878. if operationCostTotal != 0 {
  1879. iteminfo.MedChrgitm = "06"
  1880. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1881. iteminfo.Amt = operationCostTotal
  1882. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1883. iteminfo.ClabAmt = operation_clab_amt
  1884. iteminfo.OthAmt = operation_other_amt
  1885. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1887. }
  1888. if materialCostTotal != 0 {
  1889. iteminfo.MedChrgitm = "08"
  1890. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1891. iteminfo.Amt = materialCostTotal
  1892. iteminfo.ClaaSumfee = material_claa_sunmfee
  1893. iteminfo.ClabAmt = material_clab_amt
  1894. iteminfo.OthAmt = material_other_amt
  1895. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1896. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1897. }
  1898. if westernMedicineCostTotal != 0 {
  1899. iteminfo.MedChrgitm = "09"
  1900. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1901. iteminfo.Amt = westernMedicineCostTotal
  1902. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1903. iteminfo.ClabAmt = westernMedicine_clab_amt
  1904. iteminfo.OthAmt = westernMedicine_other_amt
  1905. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1906. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1907. }
  1908. if chineseTraditionalMedicineCostTotal != 0 {
  1909. iteminfo.MedChrgitm = "11"
  1910. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1911. iteminfo.Amt = westernMedicineCostTotal
  1912. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1913. iteminfo.ClabAmt = westernMedicine_clab_amt
  1914. iteminfo.OthAmt = westernMedicine_other_amt
  1915. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1916. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1917. }
  1918. if otherCostTotal != 0 {
  1919. iteminfo.MedChrgitm = "14"
  1920. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1921. iteminfo.Amt = otherCostTotal
  1922. iteminfo.ClaaSumfee = other_claa_sunmfee
  1923. iteminfo.ClabAmt = other_clab_amt
  1924. iteminfo.OthAmt = other_other_amt
  1925. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1927. }
  1928. struct4101.IteminfoStruct = iteminfoStructs
  1929. struct4101.Ntly = "中国"
  1930. struct4101.AdmCaty = "A03.06"
  1931. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1932. fmt.Println(result)
  1933. var dat map[string]interface{}
  1934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1935. fmt.Println(dat)
  1936. } else {
  1937. fmt.Println(err)
  1938. }
  1939. userJSONBytes, _ := json.Marshal(dat)
  1940. var res ResultSeventeen
  1941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1942. utils.ErrorLog("解析失败:%v", err)
  1943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1944. return
  1945. }
  1946. if res.Infcode != 0 {
  1947. c.ServeSuccessJSON(map[string]interface{}{
  1948. "failed_code": -10,
  1949. "msg": res.ErrMsg,
  1950. })
  1951. return
  1952. } else {
  1953. order.FaPiaoNumber = zero
  1954. order.FaPiaoCode = last_order.FaPiaoCode
  1955. service.UpdateOrder(order)
  1956. hisFundSettleListResult := &models.HisFundSettleListResult{
  1957. Number: res.Output.SetlListId,
  1958. Status: 1,
  1959. Ctime: time.Now().Unix(),
  1960. Mtime: time.Now().Unix(),
  1961. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1962. IsUpload: 1,
  1963. OrderId: order_id,
  1964. }
  1965. service.CreateUploadRecord(hisFundSettleListResult)
  1966. c.ServeSuccessJSON(map[string]interface{}{
  1967. "msg": "上传成功",
  1968. "result": hisFundSettleListResult,
  1969. })
  1970. return
  1971. }
  1972. }
  1973. func (c *HisApiController) GetSettleListHospital() {
  1974. order_id, _ := c.GetInt64("order_id")
  1975. admin_user_id, _ := c.GetInt64("admin_user_id")
  1976. order, _ := service.GetHisOrderByIDTwo(order_id)
  1977. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1978. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1979. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1980. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1981. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1983. if order.ID == 0 {
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1985. return
  1986. }
  1987. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1988. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1989. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1990. fmt.Println(count)
  1991. var zero string
  1992. number := count + 1
  1993. if number >= 1000 {
  1994. zero = "0000" + strconv.FormatInt(number, 10)
  1995. } else if number >= 10000 {
  1996. zero = "000" + strconv.FormatInt(number, 10)
  1997. } else if number >= 100000 {
  1998. zero = "00" + strconv.FormatInt(number, 10)
  1999. } else if number >= 1000000 {
  2000. zero = "0" + strconv.FormatInt(number, 10)
  2001. } else {
  2002. zero = strconv.FormatInt(number, 10)
  2003. }
  2004. fmt.Println(zero)
  2005. struct4101 := service.Struct4101{
  2006. PsnNo: order.PsnNo,
  2007. MdtrtId: order.MdtrtId,
  2008. SetlId: order.SetlId,
  2009. PsnName: order.PsnName,
  2010. Gend: order.Gend,
  2011. Brdy: his.Brdy,
  2012. Age: int64(order.Age),
  2013. Naty: order.Naty,
  2014. PatnCertType: "01",
  2015. Certno: order.Certno,
  2016. Prfs: "90",
  2017. ConerName: roles[0].UserName,
  2018. PatnRlts: "99",
  2019. ConerAddr: miConfig.OrgName,
  2020. ConerTel: admin.Mobile,
  2021. HiType: order.Insutype,
  2022. Insuplc: miConfig.InsuplcAdmdvs,
  2023. MaindiagFlag: "1",
  2024. BillCode: last_order.FaPiaoCode,
  2025. BillNo: zero,
  2026. BizSn: order.Number,
  2027. PsnSelfPay: order.PsnPartAmt,
  2028. PsnOwnPay: order.PsnPartAmt,
  2029. AcctPay: order.AcctPay,
  2030. PsnCashpay: order.PsnCashPay,
  2031. HiPaymtd: "1",
  2032. Hsorg: miConfig.InsuplcAdmdvs,
  2033. HsorgOpter: miConfig.InsuplcAdmdvs,
  2034. MedinsFillPsn: curRoles.UserName,
  2035. MedinsFillDept: depart.Name,
  2036. IptMedType: "2",
  2037. AdmTime: his.InHosptialTime,
  2038. AdmEndTime: his.OutHosptialTime,
  2039. }
  2040. struct4101.SetlBegnDate = order.SetlTime
  2041. struct4101.SetlEndDate = order.SetlTime
  2042. var rf []CustomFundPay
  2043. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2044. var tempFunPays []service.CustomStruct
  2045. for _, item := range rf {
  2046. var tempFunPay service.CustomStruct
  2047. tempFunPay.FundPayamt = item.FundPayamt
  2048. tempFunPay.FundPayType = item.FundPayType
  2049. tempFunPays = append(tempFunPays, tempFunPay)
  2050. }
  2051. struct4101.CustomStruct = tempFunPays
  2052. var tempDiaginfos []service.DiaginfoStructTwo
  2053. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2054. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2055. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2056. var config []*models.HisXtDiagnoseConfig
  2057. for _, item := range diagnosis_ids {
  2058. id, _ := strconv.ParseInt(item, 10, 64)
  2059. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2060. config = append(config, &diagnosisConfig)
  2061. }
  2062. for index, item := range config {
  2063. if index == 0 {
  2064. var tempDiaginfo service.DiaginfoStructTwo
  2065. tempDiaginfo.DiagCode = item.CountryCode
  2066. tempDiaginfo.DiagName = item.CountryContentName
  2067. tempDiaginfo.DiagType = "1"
  2068. tempDiaginfo.MaindiagFlag = "1"
  2069. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2070. } else {
  2071. var tempDiaginfo service.DiaginfoStructTwo
  2072. tempDiaginfo.DiagCode = item.CountryCode
  2073. tempDiaginfo.DiagName = item.CountryContentName
  2074. tempDiaginfo.DiagType = "2"
  2075. tempDiaginfo.MaindiagFlag = "0"
  2076. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2077. }
  2078. }
  2079. struct4101.Diseinfo = tempDiaginfos
  2080. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2081. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2082. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2083. tempOpspdiseinfo2.OprnOprtCode = ""
  2084. tempOpspdiseinfo2.OprnOprtName = ""
  2085. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2086. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2087. var iteminfo service.IteminfoStruct
  2088. var bedCostTotal float64 = 0 //床位总费
  2089. var bedCostSelfTotal float64 = 0 //床位自费
  2090. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2091. var operationCostTotal float64 = 0 //手术费
  2092. var operationCostSelfTotal float64 = 0 //手术费
  2093. var operationCostPartSelfTotal float64 = 0 //手术费
  2094. var otherCostTotal float64 = 0 //其他费用
  2095. var otherCostSelfTotal float64 = 0 //其他费用
  2096. var otherCostPartSelfTotal float64 = 0 //其他费用
  2097. var materialCostTotal float64 = 0 //材料费
  2098. var materialCostSelfTotal float64 = 0 //材料费
  2099. var materialCostPartSelfTotal float64 = 0 //材料费
  2100. var westernMedicineCostTotal float64 = 0 //西药费
  2101. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2102. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2103. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2104. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2105. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2106. var checkCostTotal float64 = 0 //检查费
  2107. var checkCostSelfTotal float64 = 0 //检查费
  2108. var checkCostPartSelfTotal float64 = 0 //检查费
  2109. var laboratoryCostTotal float64 = 0 //化验费
  2110. var laboratoryCostSelfTotal float64 = 0 //化验费
  2111. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2112. var treatCostTotal float64 = 0 //治疗费用
  2113. var treatCostSelfTotal float64 = 0 //治疗费用
  2114. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2115. decimal.DivisionPrecision = 2
  2116. var bed_fulamt_ownpay_amt float64 = 0
  2117. var operation_fulamt_ownpay_amt float64 = 0
  2118. var other_fulamt_ownpay_amt float64 = 0
  2119. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2120. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2121. var check_fulamt_ownpay_amt float64 = 0
  2122. var material_fulamt_ownpay_amt float64 = 0
  2123. var laboratory_fulamt_ownpay_amt float64 = 0
  2124. var treat_fulamt_ownpay_amt float64 = 0
  2125. var bed_claa_sunmfee float64 = 0
  2126. var bed_clab_amt float64 = 0
  2127. var bed_other_amt float64 = 0
  2128. var operation_claa_sunmfee float64 = 0
  2129. var operation_clab_amt float64 = 0
  2130. var operation_other_amt float64 = 0
  2131. var other_claa_sunmfee float64 = 0
  2132. var other_clab_amt float64 = 0
  2133. var other_other_amt float64 = 0
  2134. var westernMedicine_claa_sunmfee float64 = 0
  2135. var westernMedicine_clab_amt float64 = 0
  2136. var westernMedicine_other_amt float64 = 0
  2137. var chineseTraditional_claa_sunmfee float64 = 0
  2138. var chineseTraditional_clab_amt float64 = 0
  2139. var chineseTraditional_other_amt float64 = 0
  2140. var check_claa_sunmfee float64 = 0
  2141. var check_clab_amt float64 = 0
  2142. var check_other_amt float64 = 0
  2143. var material_claa_sunmfee float64 = 0
  2144. var material_clab_amt float64 = 0
  2145. var material_other_amt float64 = 0
  2146. var laboratory_claa_sunmfee float64 = 0
  2147. var laboratory_clab_amt float64 = 0
  2148. var laboratory_other_amt float64 = 0
  2149. var treat_claa_sunmfee float64 = 0
  2150. var treat_clab_amt float64 = 0
  2151. var treat_other_amt float64 = 0
  2152. for _, item := range order.HisOrderInfo {
  2153. if item.MedChrgitmType == "01" { //床位费
  2154. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2155. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2156. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2157. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2158. if item.ChrgitmLv == "1" {
  2159. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2160. }
  2161. if item.ChrgitmLv == "2" {
  2162. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2163. }
  2164. if item.ChrgitmLv == "3" {
  2165. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2166. }
  2167. }
  2168. if item.MedChrgitmType == "03" { //检查费
  2169. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2170. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2171. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2172. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2173. if item.ChrgitmLv == "1" {
  2174. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2175. }
  2176. if item.ChrgitmLv == "2" {
  2177. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2178. }
  2179. if item.ChrgitmLv == "3" {
  2180. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2181. }
  2182. }
  2183. if item.MedChrgitmType == "04" { //化验费
  2184. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2185. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2186. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2187. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2188. if item.ChrgitmLv == "1" {
  2189. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2190. }
  2191. if item.ChrgitmLv == "2" {
  2192. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2193. }
  2194. if item.ChrgitmLv == "3" {
  2195. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2196. }
  2197. }
  2198. if item.MedChrgitmType == "05" { //治疗费
  2199. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2200. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2201. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2202. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2203. if item.ChrgitmLv == "1" {
  2204. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2205. }
  2206. if item.ChrgitmLv == "2" {
  2207. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2208. }
  2209. if item.ChrgitmLv == "3" {
  2210. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2211. }
  2212. }
  2213. if item.MedChrgitmType == "06" { //手术费
  2214. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2215. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2216. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2217. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2218. if item.ChrgitmLv == "1" {
  2219. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2220. }
  2221. if item.ChrgitmLv == "2" {
  2222. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2223. }
  2224. if item.ChrgitmLv == "3" {
  2225. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2226. }
  2227. }
  2228. if item.MedChrgitmType == "08" { //材料费
  2229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2233. if item.ChrgitmLv == "1" {
  2234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2235. }
  2236. if item.ChrgitmLv == "2" {
  2237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2238. }
  2239. if item.ChrgitmLv == "3" {
  2240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2241. }
  2242. }
  2243. if item.MedChrgitmType == "09" { //西药费
  2244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2248. if item.ChrgitmLv == "1" {
  2249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2250. }
  2251. if item.ChrgitmLv == "2" {
  2252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2253. }
  2254. if item.ChrgitmLv == "3" {
  2255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2256. }
  2257. }
  2258. if item.MedChrgitmType == "11" { //中成费
  2259. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2260. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2261. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2262. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2263. if item.ChrgitmLv == "1" {
  2264. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2265. }
  2266. if item.ChrgitmLv == "2" {
  2267. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2268. }
  2269. if item.ChrgitmLv == "3" {
  2270. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2271. }
  2272. }
  2273. if item.MedChrgitmType == "14" { //其他费
  2274. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2275. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2276. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2277. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2278. if item.ChrgitmLv == "1" {
  2279. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2280. }
  2281. if item.ChrgitmLv == "2" {
  2282. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2283. }
  2284. if item.ChrgitmLv == "3" {
  2285. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2286. }
  2287. }
  2288. }
  2289. var iteminfoStructs []service.IteminfoStruct
  2290. if bedCostTotal != 0 {
  2291. iteminfo.MedChrgitm = "01"
  2292. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2293. iteminfo.Amt = bedCostTotal
  2294. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2295. iteminfo.ClabAmt = bed_clab_amt
  2296. iteminfo.OthAmt = bed_other_amt
  2297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2298. }
  2299. if checkCostTotal != 0 {
  2300. iteminfo.MedChrgitm = "03"
  2301. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2302. iteminfo.Amt = checkCostTotal
  2303. iteminfo.ClaaSumfee = check_claa_sunmfee
  2304. iteminfo.ClabAmt = check_clab_amt
  2305. iteminfo.OthAmt = check_other_amt
  2306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2307. }
  2308. if laboratoryCostTotal != 0 {
  2309. iteminfo.MedChrgitm = "04"
  2310. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2311. iteminfo.Amt = laboratoryCostTotal
  2312. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2313. iteminfo.ClabAmt = laboratory_clab_amt
  2314. iteminfo.OthAmt = laboratory_other_amt
  2315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2317. }
  2318. if treatCostTotal != 0 {
  2319. iteminfo.MedChrgitm = "05"
  2320. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2321. iteminfo.Amt = treatCostTotal
  2322. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2323. iteminfo.ClabAmt = treat_clab_amt
  2324. iteminfo.OthAmt = treat_other_amt
  2325. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2326. //(struct4101.IteminfoStruct, iteminfo)
  2327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2328. }
  2329. if operationCostTotal != 0 {
  2330. iteminfo.MedChrgitm = "06"
  2331. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2332. iteminfo.Amt = operationCostTotal
  2333. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2334. iteminfo.ClabAmt = operation_clab_amt
  2335. iteminfo.OthAmt = operation_other_amt
  2336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2338. }
  2339. if materialCostTotal != 0 {
  2340. iteminfo.MedChrgitm = "08"
  2341. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2342. iteminfo.Amt = materialCostTotal
  2343. iteminfo.ClaaSumfee = material_claa_sunmfee
  2344. iteminfo.ClabAmt = material_clab_amt
  2345. iteminfo.OthAmt = material_other_amt
  2346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2348. }
  2349. if westernMedicineCostTotal != 0 {
  2350. iteminfo.MedChrgitm = "09"
  2351. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2352. iteminfo.Amt = westernMedicineCostTotal
  2353. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2354. iteminfo.ClabAmt = westernMedicine_clab_amt
  2355. iteminfo.OthAmt = westernMedicine_other_amt
  2356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2358. }
  2359. if chineseTraditionalMedicineCostTotal != 0 {
  2360. iteminfo.MedChrgitm = "11"
  2361. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2362. iteminfo.Amt = westernMedicineCostTotal
  2363. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2364. iteminfo.ClabAmt = westernMedicine_clab_amt
  2365. iteminfo.OthAmt = westernMedicine_other_amt
  2366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2368. }
  2369. if otherCostTotal != 0 {
  2370. iteminfo.MedChrgitm = "14"
  2371. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2372. iteminfo.Amt = otherCostTotal
  2373. iteminfo.ClaaSumfee = other_claa_sunmfee
  2374. iteminfo.ClabAmt = other_clab_amt
  2375. iteminfo.OthAmt = other_other_amt
  2376. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2378. }
  2379. struct4101.IteminfoStruct = iteminfoStructs
  2380. struct4101.Ntly = "中国"
  2381. struct4101.AdmCaty = "A03.06"
  2382. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2383. fmt.Println(result)
  2384. var dat map[string]interface{}
  2385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2386. fmt.Println(dat)
  2387. } else {
  2388. fmt.Println(err)
  2389. }
  2390. userJSONBytes, _ := json.Marshal(dat)
  2391. var res ResultSeventeen
  2392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2393. utils.ErrorLog("解析失败:%v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. if res.Infcode != 0 {
  2398. c.ServeSuccessJSON(map[string]interface{}{
  2399. "failed_code": -10,
  2400. "msg": res.ErrMsg,
  2401. })
  2402. return
  2403. } else {
  2404. order.FaPiaoNumber = zero
  2405. order.FaPiaoCode = last_order.FaPiaoCode
  2406. service.UpdateOrder(order)
  2407. hisFundSettleListResult := &models.HisFundSettleListResult{
  2408. Number: res.Output.SetlListId,
  2409. Status: 1,
  2410. Ctime: time.Now().Unix(),
  2411. Mtime: time.Now().Unix(),
  2412. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2413. IsUpload: 1,
  2414. OrderId: order_id,
  2415. }
  2416. service.CreateUploadRecord(hisFundSettleListResult)
  2417. c.ServeSuccessJSON(map[string]interface{}{
  2418. "msg": "上传成功",
  2419. "result": hisFundSettleListResult,
  2420. })
  2421. return
  2422. }
  2423. }
  2424. func (c *HisApiController) GetBatchSettleList() {
  2425. orders, _ := service.GetAllHisOrder(10106)
  2426. for _, item := range orders {
  2427. order_id := item.ID
  2428. order, _ := service.GetHisOrderByIDTwo(order_id)
  2429. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2430. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2431. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2432. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2433. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2435. if order.ID == 0 {
  2436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2437. return
  2438. }
  2439. if his.BalanceAccountsType == 2 {
  2440. continue
  2441. }
  2442. struct4101 := service.Struct4101{
  2443. PsnNo: order.PsnNo,
  2444. MdtrtId: order.MdtrtId,
  2445. SetlId: order.SetlId,
  2446. PsnName: order.PsnName,
  2447. Gend: order.Gend,
  2448. Brdy: his.Brdy,
  2449. Age: his.Age,
  2450. Naty: order.Naty,
  2451. PatnCertType: "01",
  2452. Certno: order.Certno,
  2453. Prfs: "90",
  2454. ConerName: roles[0].UserName,
  2455. PatnRlts: "99",
  2456. ConerAddr: miConfig.OrgName,
  2457. ConerTel: admin.Mobile,
  2458. HiType: order.Insutype,
  2459. Insuplc: his.InsuplcAdmdvs,
  2460. MaindiagFlag: "1",
  2461. BillCode: order.FaPiaoCode,
  2462. BillNo: order.FaPiaoNumber,
  2463. BizSn: order.Number,
  2464. PsnSelfPay: order.PsnPartAmt,
  2465. PsnOwnPay: order.PsnPartAmt,
  2466. AcctPay: order.AcctPay,
  2467. PsnCashpay: order.PsnCashPay,
  2468. HiPaymtd: "1",
  2469. Hsorg: his.InsuplcAdmdvs,
  2470. HsorgOpter: his.InsuplcAdmdvs,
  2471. MedinsFillPsn: curRoles.UserName,
  2472. MedinsFillDept: depart.Name,
  2473. IptMedType: "2",
  2474. }
  2475. struct4101.SetlBegnDate = order.SetlTime
  2476. struct4101.SetlEndDate = order.SetlTime
  2477. //if order.SettleType == 1 {
  2478. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2479. // dateStr := t.Format("2006-01-02")
  2480. // struct4101.SetlBegnDate = dateStr
  2481. // struct4101.SetlEndDate = dateStr
  2482. //} else {
  2483. // t := time.Unix(int64(order.SettleStartTime), 0)
  2484. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2485. // dateStartStr := t.Format("2006-01-02")
  2486. // dateEndStr := t2.Format("2006-01-02")
  2487. // struct4101.SetlBegnDate = dateStartStr
  2488. // struct4101.SetlEndDate = dateEndStr
  2489. //}
  2490. var rf []CustomFundPay
  2491. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2492. var tempFunPays []service.CustomStruct
  2493. var tempFunPay610100 service.CustomStruct
  2494. for _, item := range rf {
  2495. if item.FundPayType == "610100" {
  2496. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2497. tempFunPay610100.FundPayType = item.FundPayType
  2498. } else {
  2499. var tempFunPay service.CustomStruct
  2500. tempFunPay.FundPayamt = item.FundPayamt
  2501. tempFunPay.FundPayType = item.FundPayType
  2502. tempFunPays = append(tempFunPays, tempFunPay)
  2503. }
  2504. }
  2505. tempFunPays = append(tempFunPays, tempFunPay610100)
  2506. struct4101.CustomStruct = tempFunPays
  2507. var tempDiaginfos []service.DiaginfoStructTwo
  2508. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2509. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2510. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2511. var config []*models.HisXtDiagnoseConfig
  2512. for _, item := range diagnosis_ids {
  2513. id, _ := strconv.ParseInt(item, 10, 64)
  2514. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2515. config = append(config, &diagnosisConfig)
  2516. }
  2517. for index, item := range config {
  2518. if index == 0 {
  2519. var tempDiaginfo service.DiaginfoStructTwo
  2520. tempDiaginfo.DiagCode = item.CountryCode
  2521. tempDiaginfo.DiagName = item.CountryContentName
  2522. tempDiaginfo.DiagType = "1"
  2523. tempDiaginfo.MaindiagFlag = "1"
  2524. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2525. } else {
  2526. var tempDiaginfo service.DiaginfoStructTwo
  2527. tempDiaginfo.DiagCode = item.CountryCode
  2528. tempDiaginfo.DiagName = item.CountryContentName
  2529. tempDiaginfo.DiagType = "2"
  2530. tempDiaginfo.MaindiagFlag = "0"
  2531. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2532. }
  2533. }
  2534. struct4101.Diseinfo = tempDiaginfos
  2535. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2536. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2537. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2538. tempOpspdiseinfo2.OprnOprtCode = ""
  2539. tempOpspdiseinfo2.OprnOprtName = ""
  2540. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2541. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2542. var iteminfo service.IteminfoStruct
  2543. var bedCostTotal float64 = 0 //床位总费
  2544. var bedCostSelfTotal float64 = 0 //床位自费
  2545. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2546. var examineCostTotal float64 = 0 //诊查总费
  2547. var examineCostSelfTotal float64 = 0 //诊查自费
  2548. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2549. var nursingCostTotal float64 = 0 //护理总费
  2550. var nursingCostSelfTotal float64 = 0 //护理自费
  2551. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2552. var chineseMedicineCostTotal float64 = 0 //中成药
  2553. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2554. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2555. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2556. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2557. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2558. var registerCostTotal float64 = 0 //一般诊疗费
  2559. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2560. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2561. var operationCostTotal float64 = 0 //手术费
  2562. var operationCostSelfTotal float64 = 0 //手术费
  2563. var operationCostPartSelfTotal float64 = 0 //手术费
  2564. var otherCostTotal float64 = 0 //其他费用
  2565. var otherCostSelfTotal float64 = 0 //其他费用
  2566. var otherCostPartSelfTotal float64 = 0 //其他费用
  2567. var materialCostTotal float64 = 0 //材料费
  2568. var materialCostSelfTotal float64 = 0 //材料费
  2569. var materialCostPartSelfTotal float64 = 0 //材料费
  2570. var westernMedicineCostTotal float64 = 0 //西药费
  2571. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2572. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2573. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2574. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2575. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2576. var checkCostTotal float64 = 0 //检查费
  2577. var checkCostSelfTotal float64 = 0 //检查费
  2578. var checkCostPartSelfTotal float64 = 0 //检查费
  2579. var laboratoryCostTotal float64 = 0 //化验费
  2580. var laboratoryCostSelfTotal float64 = 0 //化验费
  2581. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2582. var treatCostTotal float64 = 0 //治疗费用
  2583. var treatCostSelfTotal float64 = 0 //治疗费用
  2584. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2585. decimal.DivisionPrecision = 2
  2586. var bed_fulamt_ownpay_amt float64 = 0
  2587. var examine_fulamt_ownpay_amt float64 = 0
  2588. var nursing_fulamt_ownpay_amt float64 = 0
  2589. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2590. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2591. var register_fulamt_ownpay_amt float64 = 0
  2592. var operation_fulamt_ownpay_amt float64 = 0
  2593. var other_fulamt_ownpay_amt float64 = 0
  2594. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2595. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2596. var check_fulamt_ownpay_amt float64 = 0
  2597. var material_fulamt_ownpay_amt float64 = 0
  2598. var laboratory_fulamt_ownpay_amt float64 = 0
  2599. var treat_fulamt_ownpay_amt float64 = 0
  2600. var bed_claa_sunmfee float64 = 0
  2601. var bed_clab_amt float64 = 0
  2602. var bed_other_amt float64 = 0
  2603. var examine_claa_sunmfee float64 = 0
  2604. var examine_clab_amt float64 = 0
  2605. var examine_other_amt float64 = 0
  2606. var nursing_claa_sunmfee float64 = 0
  2607. var nursing_clab_amt float64 = 0
  2608. var nursing_other_amt float64 = 0
  2609. var chinese_medicine_claa_sunmfee float64 = 0
  2610. var chinese_medicine_clab_amt float64 = 0
  2611. var chinese_medicine_other_amt float64 = 0
  2612. var commonly_treatment_claa_sunmfee float64 = 0
  2613. var commonly_treatment_clab_amt float64 = 0
  2614. var commonly_treatment_other_amt float64 = 0
  2615. var operation_claa_sunmfee float64 = 0
  2616. var operation_clab_amt float64 = 0
  2617. var operation_other_amt float64 = 0
  2618. var other_claa_sunmfee float64 = 0
  2619. var other_clab_amt float64 = 0
  2620. var other_other_amt float64 = 0
  2621. var westernMedicine_claa_sunmfee float64 = 0
  2622. var westernMedicine_clab_amt float64 = 0
  2623. var westernMedicine_other_amt float64 = 0
  2624. var chineseTraditional_claa_sunmfee float64 = 0
  2625. var chineseTraditional_clab_amt float64 = 0
  2626. var chineseTraditional_other_amt float64 = 0
  2627. var check_claa_sunmfee float64 = 0
  2628. var check_clab_amt float64 = 0
  2629. var check_other_amt float64 = 0
  2630. var material_claa_sunmfee float64 = 0
  2631. var material_clab_amt float64 = 0
  2632. var material_other_amt float64 = 0
  2633. var laboratory_claa_sunmfee float64 = 0
  2634. var laboratory_clab_amt float64 = 0
  2635. var laboratory_other_amt float64 = 0
  2636. var treat_claa_sunmfee float64 = 0
  2637. var treat_clab_amt float64 = 0
  2638. var treat_other_amt float64 = 0
  2639. var register_claa_sunmfee float64 = 0
  2640. var register_clab_amt float64 = 0
  2641. var register_other_amt float64 = 0
  2642. for _, item := range order.HisOrderInfo {
  2643. if item.MedChrgitmType == "01" { //床位费
  2644. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2645. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2646. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2647. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2648. if item.ChrgitmLv == "1" {
  2649. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2650. }
  2651. if item.ChrgitmLv == "2" {
  2652. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2653. }
  2654. if item.ChrgitmLv == "3" {
  2655. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2656. }
  2657. }
  2658. if item.MedChrgitmType == "02" { //诊查
  2659. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2660. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2661. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2662. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2663. if item.ChrgitmLv == "1" {
  2664. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2665. }
  2666. if item.ChrgitmLv == "2" {
  2667. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2668. }
  2669. if item.ChrgitmLv == "3" {
  2670. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2671. }
  2672. }
  2673. if item.MedChrgitmType == "03" { //检查费
  2674. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2675. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2676. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2677. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2678. if item.ChrgitmLv == "1" {
  2679. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2680. }
  2681. if item.ChrgitmLv == "2" {
  2682. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2683. }
  2684. if item.ChrgitmLv == "3" {
  2685. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2686. }
  2687. }
  2688. if item.MedChrgitmType == "04" { //化验费
  2689. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2690. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2691. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2692. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2693. if item.ChrgitmLv == "1" {
  2694. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2695. }
  2696. if item.ChrgitmLv == "2" {
  2697. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2698. }
  2699. if item.ChrgitmLv == "3" {
  2700. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2701. }
  2702. }
  2703. if item.MedChrgitmType == "05" { //治疗费
  2704. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2705. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2706. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2707. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2708. if item.ChrgitmLv == "1" {
  2709. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2710. }
  2711. if item.ChrgitmLv == "2" {
  2712. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2713. }
  2714. if item.ChrgitmLv == "3" {
  2715. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2716. }
  2717. }
  2718. if item.MedChrgitmType == "06" { //手术费
  2719. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2720. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2721. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2722. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2723. if item.ChrgitmLv == "1" {
  2724. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2725. }
  2726. if item.ChrgitmLv == "2" {
  2727. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2728. }
  2729. if item.ChrgitmLv == "3" {
  2730. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2731. }
  2732. }
  2733. if item.MedChrgitmType == "07" { //手术费
  2734. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2735. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2736. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2737. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2738. if item.ChrgitmLv == "1" {
  2739. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2740. }
  2741. if item.ChrgitmLv == "2" {
  2742. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2743. }
  2744. if item.ChrgitmLv == "3" {
  2745. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2746. }
  2747. }
  2748. if item.MedChrgitmType == "08" { //材料费
  2749. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2750. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2751. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2752. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2753. if item.ChrgitmLv == "1" {
  2754. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2755. }
  2756. if item.ChrgitmLv == "2" {
  2757. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2758. }
  2759. if item.ChrgitmLv == "3" {
  2760. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2761. }
  2762. }
  2763. if item.MedChrgitmType == "09" { //西药费
  2764. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2765. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2766. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2767. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2768. if item.ChrgitmLv == "1" {
  2769. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2770. }
  2771. if item.ChrgitmLv == "2" {
  2772. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2773. }
  2774. if item.ChrgitmLv == "3" {
  2775. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2776. }
  2777. }
  2778. if item.MedChrgitmType == "10" { //中药饮片
  2779. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2780. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2781. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2782. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2783. if item.ChrgitmLv == "1" {
  2784. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2785. }
  2786. if item.ChrgitmLv == "2" {
  2787. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2788. }
  2789. if item.ChrgitmLv == "3" {
  2790. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2791. }
  2792. }
  2793. if item.MedChrgitmType == "11" { //中成费
  2794. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2795. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2796. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2797. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2798. if item.ChrgitmLv == "1" {
  2799. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2800. }
  2801. if item.ChrgitmLv == "2" {
  2802. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2803. }
  2804. if item.ChrgitmLv == "3" {
  2805. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2806. }
  2807. }
  2808. if item.MedChrgitmType == "12" { //中成费
  2809. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2810. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2811. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2812. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2813. if item.ChrgitmLv == "1" {
  2814. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2815. }
  2816. if item.ChrgitmLv == "2" {
  2817. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2818. }
  2819. if item.ChrgitmLv == "3" {
  2820. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2821. }
  2822. }
  2823. if item.MedChrgitmType == "13" { //中成费
  2824. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2825. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2826. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2827. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2828. if item.ChrgitmLv == "1" {
  2829. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2830. }
  2831. if item.ChrgitmLv == "2" {
  2832. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2833. }
  2834. if item.ChrgitmLv == "3" {
  2835. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2836. }
  2837. }
  2838. if item.MedChrgitmType == "14" { //其他费
  2839. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2840. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2841. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2842. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2843. if item.ChrgitmLv == "1" {
  2844. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2845. }
  2846. if item.ChrgitmLv == "2" {
  2847. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2848. }
  2849. if item.ChrgitmLv == "3" {
  2850. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2851. }
  2852. }
  2853. }
  2854. var iteminfoStructs []service.IteminfoStruct
  2855. if bedCostTotal != 0 {
  2856. iteminfo.MedChrgitm = "01"
  2857. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2858. iteminfo.Amt = bedCostTotal
  2859. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2860. iteminfo.ClabAmt = bed_clab_amt
  2861. iteminfo.OthAmt = bed_other_amt
  2862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2863. }
  2864. if examineCostTotal != 0 {
  2865. iteminfo.MedChrgitm = "02"
  2866. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2867. iteminfo.Amt = examineCostTotal
  2868. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2869. iteminfo.ClabAmt = examine_clab_amt
  2870. iteminfo.OthAmt = examine_other_amt
  2871. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2873. }
  2874. if checkCostTotal != 0 {
  2875. iteminfo.MedChrgitm = "03"
  2876. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2877. iteminfo.Amt = checkCostTotal
  2878. iteminfo.ClaaSumfee = check_claa_sunmfee
  2879. iteminfo.ClabAmt = check_clab_amt
  2880. iteminfo.OthAmt = check_other_amt
  2881. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2882. }
  2883. if laboratoryCostTotal != 0 {
  2884. iteminfo.MedChrgitm = "04"
  2885. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2886. iteminfo.Amt = laboratoryCostTotal
  2887. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2888. iteminfo.ClabAmt = laboratory_clab_amt
  2889. iteminfo.OthAmt = laboratory_other_amt
  2890. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2891. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2892. }
  2893. if treatCostTotal != 0 {
  2894. iteminfo.MedChrgitm = "05"
  2895. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2896. iteminfo.Amt = treatCostTotal
  2897. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2898. iteminfo.ClabAmt = treat_clab_amt
  2899. iteminfo.OthAmt = treat_other_amt
  2900. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2901. //(struct4101.IteminfoStruct, iteminfo)
  2902. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2903. }
  2904. if operationCostTotal != 0 {
  2905. iteminfo.MedChrgitm = "06"
  2906. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2907. iteminfo.Amt = operationCostTotal
  2908. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2909. iteminfo.ClabAmt = operation_clab_amt
  2910. iteminfo.OthAmt = operation_other_amt
  2911. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2912. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2913. }
  2914. if nursingCostTotal != 0 {
  2915. iteminfo.MedChrgitm = "07"
  2916. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2917. iteminfo.Amt = nursingCostTotal
  2918. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2919. iteminfo.ClabAmt = nursing_clab_amt
  2920. iteminfo.OthAmt = nursing_other_amt
  2921. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2922. }
  2923. if materialCostTotal != 0 {
  2924. iteminfo.MedChrgitm = "08"
  2925. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2926. iteminfo.Amt = materialCostTotal
  2927. iteminfo.ClaaSumfee = material_claa_sunmfee
  2928. iteminfo.ClabAmt = material_clab_amt
  2929. iteminfo.OthAmt = material_other_amt
  2930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2932. }
  2933. if westernMedicineCostTotal != 0 {
  2934. iteminfo.MedChrgitm = "09"
  2935. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2936. iteminfo.Amt = westernMedicineCostTotal
  2937. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2938. iteminfo.ClabAmt = westernMedicine_clab_amt
  2939. iteminfo.OthAmt = westernMedicine_other_amt
  2940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2942. }
  2943. if chineseMedicineCostTotal != 0 {
  2944. iteminfo.MedChrgitm = "10"
  2945. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2946. iteminfo.Amt = chineseMedicineCostTotal
  2947. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2948. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2949. iteminfo.OthAmt = chinese_medicine_other_amt
  2950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2952. }
  2953. if chineseTraditionalMedicineCostTotal != 0 {
  2954. iteminfo.MedChrgitm = "11"
  2955. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2956. iteminfo.Amt = westernMedicineCostTotal
  2957. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2958. iteminfo.ClabAmt = westernMedicine_clab_amt
  2959. iteminfo.OthAmt = westernMedicine_other_amt
  2960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2962. }
  2963. if commonlyTreatmentCostTotal != 0 {
  2964. iteminfo.MedChrgitm = "12"
  2965. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2966. iteminfo.Amt = commonlyTreatmentCostTotal
  2967. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2968. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2969. iteminfo.OthAmt = commonly_treatment_other_amt
  2970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2972. }
  2973. if registerCostTotal != 0 {
  2974. iteminfo.MedChrgitm = "13"
  2975. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2976. iteminfo.Amt = registerCostTotal
  2977. iteminfo.ClaaSumfee = register_claa_sunmfee
  2978. iteminfo.ClabAmt = register_clab_amt
  2979. iteminfo.OthAmt = register_other_amt
  2980. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2981. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2982. }
  2983. if otherCostTotal != 0 {
  2984. iteminfo.MedChrgitm = "14"
  2985. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2986. iteminfo.Amt = otherCostTotal
  2987. iteminfo.ClaaSumfee = other_claa_sunmfee
  2988. iteminfo.ClabAmt = other_clab_amt
  2989. iteminfo.OthAmt = other_other_amt
  2990. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2991. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2992. }
  2993. struct4101.IteminfoStruct = iteminfoStructs
  2994. struct4101.Ntly = "中国"
  2995. struct4101.AdmCaty = "A03.06"
  2996. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2997. fmt.Println(result)
  2998. var dat map[string]interface{}
  2999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3000. fmt.Println(dat)
  3001. } else {
  3002. fmt.Println(err)
  3003. }
  3004. userJSONBytes, _ := json.Marshal(dat)
  3005. var res ResultSeventeen
  3006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3007. utils.ErrorLog("解析失败:%v", err)
  3008. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3009. adminUser := c.GetAdminUserInfo()
  3010. errlog := &models.HisOrderError{
  3011. UserOrgId: adminUser.CurrentOrgId,
  3012. Ctime: time.Now().Unix(),
  3013. Mtime: time.Now().Unix(),
  3014. ErrMsg: res.ErrMsg + "解析失败",
  3015. Status: 1,
  3016. PatientId: order_id,
  3017. Stage: 10106,
  3018. }
  3019. service.CreateErrMsgLog(errlog)
  3020. continue
  3021. }
  3022. if res.Infcode != 0 {
  3023. adminUser := c.GetAdminUserInfo()
  3024. errlog := &models.HisOrderError{
  3025. UserOrgId: adminUser.CurrentOrgId,
  3026. Ctime: time.Now().Unix(),
  3027. Mtime: time.Now().Unix(),
  3028. ErrMsg: res.ErrMsg,
  3029. Status: 1,
  3030. PatientId: order_id,
  3031. Stage: 10106,
  3032. }
  3033. service.CreateErrMsgLog(errlog)
  3034. continue
  3035. } else {
  3036. hisFundSettleListResult := &models.HisFundSettleListResult{
  3037. Number: res.Output.SetlListId,
  3038. Status: 1,
  3039. Ctime: time.Now().Unix(),
  3040. Mtime: time.Now().Unix(),
  3041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3042. IsUpload: 1,
  3043. OrderId: order_id,
  3044. }
  3045. service.CreateUploadRecord(hisFundSettleListResult)
  3046. continue
  3047. }
  3048. }
  3049. }
  3050. func (c *HisApiController) GetOrgInfo() {
  3051. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3052. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3053. }
  3054. func (c *HisApiController) GetHisPatientInfo() {
  3055. medical_insurance_card := c.GetString("medical_insurance_card")
  3056. id_card_type, _ := c.GetInt64("id_card_type")
  3057. id_card := c.GetString("id_card")
  3058. adminInfo := c.GetAdminUserInfo()
  3059. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3060. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3061. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3062. IdCardNo := ""
  3063. if id_card_type == 1 {
  3064. IdCardNo = medical_insurance_card
  3065. } else if id_card_type == 2 {
  3066. IdCardNo = id_card
  3067. }
  3068. if config.IsOpen == 1 {
  3069. 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
  3070. resp, requestErr := http.Get(api)
  3071. if requestErr != nil {
  3072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3073. return
  3074. }
  3075. defer resp.Body.Close()
  3076. body, ioErr := ioutil.ReadAll(resp.Body)
  3077. if ioErr != nil {
  3078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3080. return
  3081. }
  3082. var respJSON map[string]interface{}
  3083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3086. return
  3087. }
  3088. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3089. userJSONBytes, _ := json.Marshal(userJSON)
  3090. var res ResultTwo
  3091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3092. utils.ErrorLog("解析失败:%v", err)
  3093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3094. return
  3095. }
  3096. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3097. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3098. infoStr := string(Iinfos)
  3099. idetinfoStr := string(Idetinfos)
  3100. if res.Infcode == 0 {
  3101. his := models.VMHisPatient{
  3102. Status: 1,
  3103. Ctime: time.Now().Unix(),
  3104. Mtime: time.Now().Unix(),
  3105. PsnNo: res.Output.Baseinfo.PsnNo,
  3106. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3107. Certno: res.Output.Baseinfo.Certno,
  3108. PsnName: res.Output.Baseinfo.PsnName,
  3109. Gend: res.Output.Baseinfo.Gend,
  3110. Naty: res.Output.Baseinfo.Naty,
  3111. Brdy: res.Output.Baseinfo.Brdy,
  3112. Age: res.Output.Baseinfo.Age,
  3113. Iinfo: infoStr,
  3114. Idetinfo: idetinfoStr,
  3115. UserOrgId: adminInfo.CurrentOrgId,
  3116. IsReturn: 1,
  3117. IdCardType: id_card_type,
  3118. }
  3119. c.ServeSuccessJSON(map[string]interface{}{
  3120. "info": his,
  3121. })
  3122. } else {
  3123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3124. return
  3125. }
  3126. }
  3127. }
  3128. //func GetBasBaseInfo() (jsonStr string, err error) {
  3129. //
  3130. // handle := syscall.NewLazyDLL("SSCard.dll")
  3131. // add := handle.NewProc("ReadCardBas")
  3132. // str := make([]byte, 1024)
  3133. // str1 := make([]byte, 1024)
  3134. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3135. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3136. //
  3137. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3138. //
  3139. // fmt.Println("> Add(4,5)的结果为:", ret)
  3140. // handle.Release()
  3141. //
  3142. // return "", nil
  3143. //
  3144. //}
  3145. //func GetQRBaseInfo() (jsonStr string, err error) {
  3146. // handle := syscall.LoadDLL("SSCard.dll")
  3147. // ReadCardBas := handle.FindProc("GetQRBase")
  3148. //
  3149. // str := make([]byte, 256)
  3150. // str1 := make([]byte, 256)
  3151. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3152. //
  3153. // fmt.Println(string(str))
  3154. // fmt.Println(r)
  3155. // return string(str), nil
  3156. //}
  3157. //func CardInit() int {
  3158. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3159. // add := DllTestDef.MustFindProc("Init")
  3160. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3161. // if err != nil {
  3162. // fmt.Println("SSCard的运算结果为:", ret)
  3163. // }
  3164. // result := int(ret)
  3165. // return result
  3166. //}
  3167. //func CardInit() int {
  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. // fmt.Println(err)
  3173. // result := int(ret)
  3174. // return result
  3175. //}
  3176. func IntPtr(n int) uintptr {
  3177. return uintptr(n)
  3178. }
  3179. func StrPtr(s string) uintptr {
  3180. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3181. }
  3182. type Result2001 struct {
  3183. Cainfo interface{} `json:"cainfo"`
  3184. ErrMsg string `json:"err_msg"`
  3185. InfRefmsgid string `json:"inf_refmsgid"`
  3186. Infcode int64 `json:"infcode"`
  3187. Output struct {
  3188. Trtinfo struct {
  3189. PsnNo string `json:"psn_no"`
  3190. TrtChkType string `json:"trt_chk_type"`
  3191. FundPayType string `json:"fund_pay_type"`
  3192. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3193. Begndate string `json:"begndate"`
  3194. Enddate string `json:"enddate"`
  3195. TrtChkRslt string `json:"trt_chk_rslt"`
  3196. } `json:"trtinfo"`
  3197. } `json:"output"`
  3198. RefmsgTime string `json:"refmsg_time"`
  3199. RespondTime string `json:"respond_time"`
  3200. Signtype interface{} `json:"signtype"`
  3201. WarnMsg interface{} `json:"warn_msg"`
  3202. }
  3203. type Result2001Org10265 struct {
  3204. Cainfo interface{} `json:"cainfo"`
  3205. ErrMsg string `json:"err_msg"`
  3206. InfRefmsgid string `json:"inf_refmsgid"`
  3207. Infcode string `json:"infcode"`
  3208. Output struct {
  3209. Trtinfo struct {
  3210. PsnNo string `json:"psn_no"`
  3211. TrtChkType string `json:"trt_chk_type"`
  3212. FundPayType string `json:"fund_pay_type"`
  3213. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3214. Begndate string `json:"begndate"`
  3215. Enddate string `json:"enddate"`
  3216. TrtChkRslt string `json:"trt_chk_rslt"`
  3217. } `json:"trtinfo"`
  3218. } `json:"output"`
  3219. RefmsgTime string `json:"refmsg_time"`
  3220. RespondTime string `json:"respond_time"`
  3221. Signtype interface{} `json:"signtype"`
  3222. WarnMsg interface{} `json:"warn_msg"`
  3223. }
  3224. type ResultTwo struct {
  3225. ErrMsg string `json:"err_msg"`
  3226. InfRefmsgid string `json:"inf_refmsgid"`
  3227. Infcode int64 `json:"infcode"`
  3228. Output struct {
  3229. Baseinfo struct {
  3230. Age float64 `json:"age"`
  3231. Brdy string `json:"brdy"`
  3232. Certno string `json:"certno"`
  3233. Gend string `json:"gend"`
  3234. Naty string `json:"naty"`
  3235. PsnCertType string `json:"psn_cert_type"`
  3236. PsnName string `json:"psn_name"`
  3237. PsnNo string `json:"psn_no"`
  3238. } `json:"baseinfo"`
  3239. Idetinfo []interface{} `json:"idetinfo"`
  3240. Iinfo []struct {
  3241. Balc float64 `json:"balc"`
  3242. CvlservFlag string `json:"cvlserv_flag"`
  3243. EmpName string `json:"emp_name"`
  3244. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3245. Insutype string `json:"insutype"`
  3246. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3247. PausInsuDate string `json:"paus_insu_date"`
  3248. PsnInsuDate string `json:"psn_insu_date"`
  3249. PsnInsuStas string `json:"psn_insu_stas"`
  3250. PsnType string `json:"psn_type"`
  3251. } `json:"insuinfo"`
  3252. } `json:"output"`
  3253. RefmsgTime string `json:"refmsg_time"`
  3254. RespondTime string `json:"respond_time"`
  3255. Signtype interface{} `json:"signtype"`
  3256. WarnInfo interface{} `json:"warn_info"`
  3257. }
  3258. type ResultTwo10265 struct {
  3259. ErrMsg string `json:"err_msg"`
  3260. InfRefmsgid string `json:"inf_refmsgid"`
  3261. Infcode string `json:"infcode"`
  3262. Output struct {
  3263. Baseinfo struct {
  3264. Age float64 `json:"age"`
  3265. Brdy string `json:"brdy"`
  3266. Certno string `json:"certno"`
  3267. Gend string `json:"gend"`
  3268. Naty string `json:"naty"`
  3269. PsnCertType string `json:"psn_cert_type"`
  3270. PsnName string `json:"psn_name"`
  3271. PsnNo string `json:"psn_no"`
  3272. } `json:"baseinfo"`
  3273. Idetinfo []interface{} `json:"idetinfo"`
  3274. Iinfo []struct {
  3275. Balc float64 `json:"balc"`
  3276. CvlservFlag string `json:"cvlserv_flag"`
  3277. EmpName string `json:"emp_name"`
  3278. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3279. Insutype string `json:"insutype"`
  3280. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3281. PausInsuDate string `json:"paus_insu_date"`
  3282. PsnInsuDate string `json:"psn_insu_date"`
  3283. PsnInsuStas string `json:"psn_insu_stas"`
  3284. PsnType string `json:"psn_type"`
  3285. } `json:"insuinfo"`
  3286. } `json:"output"`
  3287. RefmsgTime string `json:"refmsg_time"`
  3288. RespondTime string `json:"respond_time"`
  3289. Signtype interface{} `json:"signtype"`
  3290. WarnInfo interface{} `json:"warn_info"`
  3291. }
  3292. type ResultThree struct {
  3293. Cainfo interface{} `json:"cainfo"`
  3294. ErrMsg string `json:"err_msg"`
  3295. InfRefmsgid string `json:"inf_refmsgid"`
  3296. Infcode int64 `json:"infcode"`
  3297. Output struct {
  3298. Data struct {
  3299. IptOtpNo string `json:"ipt_otp_no"`
  3300. MdtrtID string `json:"mdtrt_id"`
  3301. PsnNo string `json:"psn_no"`
  3302. } `json:"data"`
  3303. } `json:"output"`
  3304. RefmsgTime string `json:"refmsg_time"`
  3305. RespondTime string `json:"respond_time"`
  3306. Signtype interface{} `json:"signtype"`
  3307. WarnMsg interface{} `json:"warn_msg"`
  3308. }
  3309. type ResultThree10265 struct {
  3310. Cainfo interface{} `json:"cainfo"`
  3311. ErrMsg string `json:"err_msg"`
  3312. InfRefmsgid string `json:"inf_refmsgid"`
  3313. Infcode string `json:"infcode"`
  3314. Output struct {
  3315. Data struct {
  3316. IptOtpNo string `json:"ipt_otp_no"`
  3317. MdtrtID string `json:"mdtrt_id"`
  3318. PsnNo string `json:"psn_no"`
  3319. } `json:"data"`
  3320. } `json:"output"`
  3321. RefmsgTime string `json:"refmsg_time"`
  3322. RespondTime string `json:"respond_time"`
  3323. Signtype interface{} `json:"signtype"`
  3324. WarnMsg interface{} `json:"warn_msg"`
  3325. }
  3326. type ResultFour struct {
  3327. Cainfo string `json:"cainfo"`
  3328. ErrMsg string `json:"err_msg"`
  3329. InfRefmsgid string `json:"inf_refmsgid"`
  3330. Infcode int64 `json:"infcode"`
  3331. Output struct {
  3332. Result []struct {
  3333. BasMednFlag string `json:"bas_medn_flag"`
  3334. ChldMedcFlag string `json:"chld_medc_flag"`
  3335. ChrgitmLv string `json:"chrgitm_lv"`
  3336. Cnt float64 `json:"cnt"`
  3337. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3338. DrtReimFlag string `json:"drt_reim_flag"`
  3339. FeedetlSn string `json:"feedetl_sn"`
  3340. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3341. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3342. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3343. ListSpItemFlag string `json:"list_sp_item_flag"`
  3344. LmtUsedFlag string `json:"lmt_used_flag"`
  3345. MedChrgitmType string `json:"med_chrgitm_type"`
  3346. Memo string `json:"memo"`
  3347. OverlmtAmt float64 `json:"overlmt_amt"`
  3348. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3349. Pric float64 `json:"pric"`
  3350. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3351. SelfpayProp float64 `json:"selfpay_prop"`
  3352. } `json:"result"`
  3353. } `json:"output"`
  3354. RefmsgTime string `json:"refmsg_time"`
  3355. RespondTime string `json:"respond_time"`
  3356. Signtype string `json:"signtype"`
  3357. WarnMsg string `json:"warn_msg"`
  3358. }
  3359. type ResultFour10265 struct {
  3360. Cainfo string `json:"cainfo"`
  3361. ErrMsg string `json:"err_msg"`
  3362. InfRefmsgid string `json:"inf_refmsgid"`
  3363. Infcode string `json:"infcode"`
  3364. Output struct {
  3365. Result []struct {
  3366. BasMednFlag string `json:"bas_medn_flag"`
  3367. ChldMedcFlag string `json:"chld_medc_flag"`
  3368. ChrgitmLv string `json:"chrgitm_lv"`
  3369. Cnt float64 `json:"cnt"`
  3370. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3371. DrtReimFlag string `json:"drt_reim_flag"`
  3372. FeedetlSn string `json:"feedetl_sn"`
  3373. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3374. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3375. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3376. ListSpItemFlag string `json:"list_sp_item_flag"`
  3377. LmtUsedFlag string `json:"lmt_used_flag"`
  3378. MedChrgitmType string `json:"med_chrgitm_type"`
  3379. Memo string `json:"memo"`
  3380. OverlmtAmt float64 `json:"overlmt_amt"`
  3381. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3382. Pric float64 `json:"pric"`
  3383. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3384. SelfpayProp float64 `json:"selfpay_prop"`
  3385. } `json:"result"`
  3386. } `json:"output"`
  3387. RefmsgTime string `json:"refmsg_time"`
  3388. RespondTime string `json:"respond_time"`
  3389. Signtype string `json:"signtype"`
  3390. WarnMsg string `json:"warn_msg"`
  3391. }
  3392. type ResultFive struct {
  3393. Balc float64 `json:"balc"`
  3394. CvlservFlag string `json:"cvlserv_flag"`
  3395. EmpName string `json:"emp_name"`
  3396. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3397. Insutype string `json:"insutype"`
  3398. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3399. PausInsuDate string `json:"paus_insu_date"`
  3400. PsnInsuDate string `json:"psn_insu_date"`
  3401. PsnInsuStas string `json:"psn_insu_stas"`
  3402. PsnType string `json:"psn_type"`
  3403. }
  3404. type ResultSix struct {
  3405. Cainfo interface{} `json:"cainfo"`
  3406. ErrMsg string `json:"err_msg"`
  3407. InfRefmsgid string `json:"inf_refmsgid"`
  3408. Infcode int64 `json:"infcode"`
  3409. Output struct {
  3410. } `json:"output"`
  3411. RefmsgTime string `json:"refmsg_time"`
  3412. RespondTime string `json:"respond_time"`
  3413. Signtype interface{} `json:"signtype"`
  3414. WarnMsg interface{} `json:"warn_msg"`
  3415. }
  3416. type ResultSix10265 struct {
  3417. Cainfo interface{} `json:"cainfo"`
  3418. ErrMsg string `json:"err_msg"`
  3419. InfRefmsgid string `json:"inf_refmsgid"`
  3420. Infcode string `json:"infcode"`
  3421. Output struct {
  3422. } `json:"output"`
  3423. RefmsgTime string `json:"refmsg_time"`
  3424. RespondTime string `json:"respond_time"`
  3425. Signtype interface{} `json:"signtype"`
  3426. WarnMsg interface{} `json:"warn_msg"`
  3427. }
  3428. type ResultSeven struct {
  3429. Cainfo string `json:"cainfo"`
  3430. ErrMsg string `json:"err_msg"`
  3431. InfRefmsgid string `json:"inf_refmsgid"`
  3432. Infcode int64 `json:"infcode"`
  3433. Output struct {
  3434. Setldetail []interface{} `json:"setldetail"`
  3435. Setlinfo struct {
  3436. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3437. AcctPay float64 `json:"acct_pay"`
  3438. ActPayDedc float64 `json:"act_pay_dedc"`
  3439. Age float64 `json:"age"`
  3440. Balc float64 `json:"balc"`
  3441. Brdy string `json:"brdy"`
  3442. Certno string `json:"certno"`
  3443. ClrOptins string `json:"clr_optins"`
  3444. ClrType string `json:"clr_type"`
  3445. ClrWay string `json:"clr_way"`
  3446. CvlservFlag string `json:"cvlserv_flag"`
  3447. CvlservPay float64 `json:"cvlserv_pay"`
  3448. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3449. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3450. Gend string `json:"gend"`
  3451. HifesPay float64 `json:"hifes_pay"`
  3452. HifmiPay float64 `json:"hifmi_pay"`
  3453. HifpPay float64 `json:"hifp_pay"`
  3454. HospPartAmt float64 `json:"hosp_part_amt"`
  3455. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3456. Insutype string `json:"insutype"`
  3457. MafPay float64 `json:"maf_pay"`
  3458. MdtrtCertType string `json:"mdtrt_cert_type"`
  3459. HifobPay float64 `json:"hifob_pay"`
  3460. MdtrtID string `json:"mdtrt_id"`
  3461. MedType string `json:"med_type"`
  3462. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3463. MedinsSetlID string `json:"medins_setl_id"`
  3464. Naty string `json:"naty"`
  3465. OthPay float64 `json:"oth_pay"`
  3466. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3467. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3468. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3469. PsnCashPay float64 `json:"psn_cash_pay"`
  3470. PsnCertType string `json:"psn_cert_type"`
  3471. PsnName string `json:"psn_name"`
  3472. PsnNo string `json:"psn_no"`
  3473. PsnPartAmt float64 `json:"psn_part_amt"`
  3474. PsnType string `json:"psn_type"`
  3475. SetlID string `json:"setl_id"`
  3476. SetlTime string `json:"setl_time"`
  3477. } `json:"setlinfo"`
  3478. } `json:"output"`
  3479. RefmsgTime string `json:"refmsg_time"`
  3480. RespondTime string `json:"respond_time"`
  3481. Signtype interface{} `json:"signtype"`
  3482. WarnMsg interface{} `json:"warn_msg"`
  3483. }
  3484. type ResultSeven10265 struct {
  3485. Cainfo string `json:"cainfo"`
  3486. ErrMsg string `json:"err_msg"`
  3487. InfRefmsgid string `json:"inf_refmsgid"`
  3488. Infcode string `json:"infcode"`
  3489. Output struct {
  3490. Setldetail []interface{} `json:"setldetail"`
  3491. Setlinfo struct {
  3492. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3493. AcctPay float64 `json:"acct_pay"`
  3494. ActPayDedc float64 `json:"act_pay_dedc"`
  3495. Age float64 `json:"age"`
  3496. Balc float64 `json:"balc"`
  3497. Brdy string `json:"brdy"`
  3498. Certno string `json:"certno"`
  3499. ClrOptins string `json:"clr_optins"`
  3500. ClrType string `json:"clr_type"`
  3501. ClrWay string `json:"clr_way"`
  3502. CvlservFlag string `json:"cvlserv_flag"`
  3503. CvlservPay float64 `json:"cvlserv_pay"`
  3504. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3505. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3506. Gend string `json:"gend"`
  3507. HifesPay float64 `json:"hifes_pay"`
  3508. HifmiPay float64 `json:"hifmi_pay"`
  3509. HifpPay float64 `json:"hifp_pay"`
  3510. HospPartAmt float64 `json:"hosp_part_amt"`
  3511. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3512. Insutype string `json:"insutype"`
  3513. MafPay float64 `json:"maf_pay"`
  3514. MdtrtCertType string `json:"mdtrt_cert_type"`
  3515. HifobPay float64 `json:"hifob_pay"`
  3516. MdtrtID string `json:"mdtrt_id"`
  3517. MedType string `json:"med_type"`
  3518. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3519. MedinsSetlID string `json:"medins_setl_id"`
  3520. Naty string `json:"naty"`
  3521. OthPay float64 `json:"oth_pay"`
  3522. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3523. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3524. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3525. PsnCashPay float64 `json:"psn_cash_pay"`
  3526. PsnCertType string `json:"psn_cert_type"`
  3527. PsnName string `json:"psn_name"`
  3528. PsnNo string `json:"psn_no"`
  3529. PsnPartAmt float64 `json:"psn_part_amt"`
  3530. PsnType string `json:"psn_type"`
  3531. SetlID string `json:"setl_id"`
  3532. SetlTime string `json:"setl_time"`
  3533. } `json:"setlinfo"`
  3534. } `json:"output"`
  3535. RefmsgTime string `json:"refmsg_time"`
  3536. RespondTime string `json:"respond_time"`
  3537. Signtype interface{} `json:"signtype"`
  3538. WarnMsg interface{} `json:"warn_msg"`
  3539. }
  3540. type ResultEight struct {
  3541. Cainfo string `json:"cainfo"`
  3542. ErrMsg string `json:"err_msg"`
  3543. InfRefmsgid string `json:"inf_refmsgid"`
  3544. Infcode int64 `json:"infcode"`
  3545. Output struct {
  3546. Stmtinfo struct {
  3547. SetlOptins string `json:"setl_optins"`
  3548. StmtRslt string `json:"stmt_rslt"`
  3549. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3550. } `json:"stmtinfo"`
  3551. } `json:"output"`
  3552. RefmsgTime string `json:"refmsg_time"`
  3553. RespondTime string `json:"respond_time"`
  3554. Signtype interface{} `json:"signtype"`
  3555. WarnMsg interface{} `json:"warn_msg"`
  3556. }
  3557. type ResultEightFor10188 struct {
  3558. Cainfo string `json:"cainfo"`
  3559. ErrMsg string `json:"err_msg"`
  3560. InfRefmsgid string `json:"inf_refmsgid"`
  3561. Infcode string `json:"infcode"`
  3562. Output struct {
  3563. Stmtinfo struct {
  3564. SetlOptins string `json:"setl_optins"`
  3565. StmtRslt string `json:"stmt_rslt"`
  3566. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3567. } `json:"stmtinfo"`
  3568. } `json:"output"`
  3569. RefmsgTime string `json:"refmsg_time"`
  3570. RespondTime string `json:"respond_time"`
  3571. Signtype interface{} `json:"signtype"`
  3572. WarnMsg interface{} `json:"warn_msg"`
  3573. }
  3574. type ResultNine struct {
  3575. Cainfo string `json:"cainfo"`
  3576. ErrMsg string `json:"err_msg"`
  3577. InfRefmsgid string `json:"inf_refmsgid"`
  3578. Infcode int64 `json:"infcode"`
  3579. Output struct {
  3580. FileQuryNo string `json:"file_qury_no"`
  3581. } `json:"output"`
  3582. RefmsgTime string `json:"refmsg_time"`
  3583. RespondTime string `json:"respond_time"`
  3584. Signtype interface{} `json:"signtype"`
  3585. WarnMsg interface{} `json:"warn_msg"`
  3586. }
  3587. type ResultTen struct {
  3588. Cainfo string `json:"cainfo"`
  3589. ErrMsg string `json:"err_msg"`
  3590. InfRefmsgid string `json:"inf_refmsgid"`
  3591. Infcode int64 `json:"infcode"`
  3592. Output struct {
  3593. DldEndtime string `json:"dld_endtime"`
  3594. FileQuryNo string `json:"file_qury_no"`
  3595. Filename string `json:"filename"`
  3596. } `json:"output"`
  3597. RefmsgTime string `json:"refmsg_time"`
  3598. RespondTime string `json:"respond_time"`
  3599. Signtype interface{} `json:"signtype"`
  3600. WarnMsg interface{} `json:"warn_msg"`
  3601. }
  3602. //type Autogenerated struct {
  3603. // Output struct {
  3604. // Setlinfo struct {
  3605. // SetlTime string `json:"setl_time"`
  3606. // CvlservPay float64 `json:"cvlserv_pay"`
  3607. // Year string `json:"year"`
  3608. // MedType string `json:"med_type"`
  3609. // PsnPay float64 `json:"psn_pay"`
  3610. // OpterID string `json:"opter_id"`
  3611. // Begndate string `json:"begndate"`
  3612. // FlxempeFlag string `json:"flxempe_flag"`
  3613. // HifmiPay float64 `json:"hifmi_pay"`
  3614. // PsnNo string `json:"psn_no"`
  3615. // ActPayDedc float64 `json:"act_pay_dedc"`
  3616. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3617. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3618. // ClrWay string `json:"clr_way"`
  3619. // OthPay float64 `json:"oth_pay"`
  3620. // Gend string `json:"gend"`
  3621. // MdtrtID string `json:"mdtrt_id"`
  3622. // AcctPay float64 `json:"acct_pay"`
  3623. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3624. // Insutype string `json:"insutype"`
  3625. // Invono interface{} `json:"invono"`
  3626. // Enddate string `json:"enddate"`
  3627. // CashPayamt float64 `json:"cash_payamt"`
  3628. // PsnType string `json:"psn_type"`
  3629. // FixmedinsName string `json:"fixmedins_name"`
  3630. // HifpPay float64 `json:"hifp_pay"`
  3631. // NewFlag interface{} `json:"new_flag"`
  3632. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3633. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3634. // PayLoc string `json:"pay_loc"`
  3635. // ClrType string `json:"clr_type"`
  3636. // RefdSetlFlag string `json:"refd_setl_flag"`
  3637. // CvlservFlag string `json:"cvlserv_flag"`
  3638. // EmpName string `json:"emp_name"`
  3639. // Brdy string `json:"brdy"`
  3640. // Naty string `json:"naty"`
  3641. // Certno string `json:"certno"`
  3642. // DiseCode string `json:"dise_code"`
  3643. // FixmedinsCode string `json:"fixmedins_code"`
  3644. // DedcHospLv string `json:"dedc_hosp_lv"`
  3645. // OpterName string `json:"opter_name"`
  3646. // Balc float64 `json:"balc"`
  3647. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3648. // PsnCertType string `json:"psn_cert_type"`
  3649. // HifobPay float64 `json:"hifob_pay"`
  3650. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3651. // HifesPay float64 `json:"hifes_pay"`
  3652. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3653. // OptTime string `json:"opt_time"`
  3654. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3655. // SetlID string `json:"setl_id"`
  3656. // MafPay float64 `json:"maf_pay"`
  3657. // PsnName string `json:"psn_name"`
  3658. // InsuOptins interface{} `json:"insu_optins"`
  3659. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3660. // ClrOptins string `json:"clr_optins"`
  3661. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3662. // DiseName string `json:"dise_name"`
  3663. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3664. // Age float64 `json:"age"`
  3665. // DtrtCertType string `json:"dtrt_cert_type"`
  3666. // HospLv string `json:"hosp_lv"`
  3667. // } `json:"setlinfo"`
  3668. // Setldetail []struct {
  3669. // FundPayType string `json:"fund_pay_type"`
  3670. // FundPayamt float64 `json:"fund_payamt"`
  3671. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3672. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3673. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3674. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3675. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3676. // } `json:"setldetail"`
  3677. // } `json:"output"`
  3678. // Infcode int `json:"infcode"`
  3679. // WarnMsg interface{} `json:"warn_msg"`
  3680. // Cainfo interface{} `json:"cainfo"`
  3681. // ErrMsg interface{} `json:"err_msg"`
  3682. // RefmsgTime string `json:"refmsg_time"`
  3683. // Signtype interface{} `json:"signtype"`
  3684. // RespondTime string `json:"respond_time"`
  3685. // InfRefmsgid string `json:"inf_refmsgid"`
  3686. //}
  3687. type ResultEleven struct {
  3688. Cainfo string `json:"cainfo"`
  3689. ErrMsg string `json:"err_msg"`
  3690. InfRefmsgid string `json:"inf_refmsgid"`
  3691. Infcode int64 `json:"infcode"`
  3692. Output struct {
  3693. Setlinfo struct {
  3694. SetlTime string `json:"setl_time"`
  3695. CvlservPay float64 `json:"cvlserv_pay"`
  3696. Year string `json:"year"`
  3697. MedType string `json:"med_type"`
  3698. PsnPay float64 `json:"psn_pay"`
  3699. OpterID string `json:"opter_id"`
  3700. Begndate string `json:"begndate"`
  3701. FlxempeFlag string `json:"flxempe_flag"`
  3702. HifmiPay float64 `json:"hifmi_pay"`
  3703. PsnNo string `json:"psn_no"`
  3704. ActPayDedc float64 `json:"act_pay_dedc"`
  3705. MedinsSetlID interface{} `json:"medins_setl_id"`
  3706. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3707. ClrWay string `json:"clr_way"`
  3708. OthPay float64 `json:"oth_pay"`
  3709. Gend string `json:"gend"`
  3710. MdtrtID string `json:"mdtrt_id"`
  3711. AcctPay float64 `json:"acct_pay"`
  3712. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3713. Insutype string `json:"insutype"`
  3714. Invono interface{} `json:"invono"`
  3715. Enddate string `json:"enddate"`
  3716. CashPayamt float64 `json:"cash_payamt"`
  3717. PsnType string `json:"psn_type"`
  3718. FixmedinsName string `json:"fixmedins_name"`
  3719. HifpPay float64 `json:"hifp_pay"`
  3720. NewFlag interface{} `json:"new_flag"`
  3721. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3722. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3723. PayLoc string `json:"pay_loc"`
  3724. ClrType string `json:"clr_type"`
  3725. RefdSetlFlag string `json:"refd_setl_flag"`
  3726. CvlservFlag string `json:"cvlserv_flag"`
  3727. EmpName string `json:"emp_name"`
  3728. Brdy string `json:"brdy"`
  3729. Naty string `json:"naty"`
  3730. Certno string `json:"certno"`
  3731. DiseCode string `json:"dise_code"`
  3732. FixmedinsCode string `json:"fixmedins_code"`
  3733. DedcHospLv string `json:"dedc_hosp_lv"`
  3734. OpterName string `json:"opter_name"`
  3735. Balc float64 `json:"balc"`
  3736. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3737. PsnCertType string `json:"psn_cert_type"`
  3738. HifobPay float64 `json:"hifob_pay"`
  3739. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3740. HifesPay float64 `json:"hifes_pay"`
  3741. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3742. OptTime string `json:"opt_time"`
  3743. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3744. SetlID string `json:"setl_id"`
  3745. MafPay float64 `json:"maf_pay"`
  3746. PsnName string `json:"psn_name"`
  3747. InsuOptins interface{} `json:"insu_optins"`
  3748. PrefFundPay interface{} `json:"pref_fund_pay"`
  3749. ClrOptins string `json:"clr_optins"`
  3750. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3751. DiseName string `json:"dise_name"`
  3752. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3753. Age float64 `json:"age"`
  3754. DtrtCertType string `json:"dtrt_cert_type"`
  3755. HospLv string `json:"hosp_lv"`
  3756. } `json:"setlinfo"`
  3757. } `json:"output"`
  3758. RefmsgTime string `json:"refmsg_time"`
  3759. RespondTime string `json:"respond_time"`
  3760. Signtype interface{} `json:"signtype"`
  3761. WarnMsg interface{} `json:"warn_msg"`
  3762. }
  3763. type ResultEleven10265 struct {
  3764. Cainfo string `json:"cainfo"`
  3765. ErrMsg string `json:"err_msg"`
  3766. InfRefmsgid string `json:"inf_refmsgid"`
  3767. Infcode string `json:"infcode"`
  3768. Output struct {
  3769. Setlinfo struct {
  3770. SetlTime string `json:"setl_time"`
  3771. CvlservPay float64 `json:"cvlserv_pay"`
  3772. Year string `json:"year"`
  3773. MedType string `json:"med_type"`
  3774. PsnPay float64 `json:"psn_pay"`
  3775. OpterID string `json:"opter_id"`
  3776. Begndate string `json:"begndate"`
  3777. FlxempeFlag string `json:"flxempe_flag"`
  3778. HifmiPay float64 `json:"hifmi_pay"`
  3779. PsnNo string `json:"psn_no"`
  3780. ActPayDedc float64 `json:"act_pay_dedc"`
  3781. MedinsSetlID interface{} `json:"medins_setl_id"`
  3782. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3783. ClrWay string `json:"clr_way"`
  3784. OthPay float64 `json:"oth_pay"`
  3785. Gend string `json:"gend"`
  3786. MdtrtID string `json:"mdtrt_id"`
  3787. AcctPay float64 `json:"acct_pay"`
  3788. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3789. Insutype string `json:"insutype"`
  3790. Invono interface{} `json:"invono"`
  3791. Enddate string `json:"enddate"`
  3792. CashPayamt float64 `json:"cash_payamt"`
  3793. PsnType string `json:"psn_type"`
  3794. FixmedinsName string `json:"fixmedins_name"`
  3795. HifpPay float64 `json:"hifp_pay"`
  3796. NewFlag interface{} `json:"new_flag"`
  3797. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3798. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3799. PayLoc string `json:"pay_loc"`
  3800. ClrType string `json:"clr_type"`
  3801. RefdSetlFlag string `json:"refd_setl_flag"`
  3802. CvlservFlag string `json:"cvlserv_flag"`
  3803. EmpName string `json:"emp_name"`
  3804. Brdy string `json:"brdy"`
  3805. Naty string `json:"naty"`
  3806. Certno string `json:"certno"`
  3807. DiseCode string `json:"dise_code"`
  3808. FixmedinsCode string `json:"fixmedins_code"`
  3809. DedcHospLv string `json:"dedc_hosp_lv"`
  3810. OpterName string `json:"opter_name"`
  3811. Balc float64 `json:"balc"`
  3812. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3813. PsnCertType string `json:"psn_cert_type"`
  3814. HifobPay float64 `json:"hifob_pay"`
  3815. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3816. HifesPay float64 `json:"hifes_pay"`
  3817. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3818. OptTime string `json:"opt_time"`
  3819. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3820. SetlID string `json:"setl_id"`
  3821. MafPay float64 `json:"maf_pay"`
  3822. PsnName string `json:"psn_name"`
  3823. InsuOptins interface{} `json:"insu_optins"`
  3824. PrefFundPay interface{} `json:"pref_fund_pay"`
  3825. ClrOptins string `json:"clr_optins"`
  3826. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3827. DiseName string `json:"dise_name"`
  3828. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3829. Age float64 `json:"age"`
  3830. DtrtCertType string `json:"dtrt_cert_type"`
  3831. HospLv string `json:"hosp_lv"`
  3832. } `json:"setlinfo"`
  3833. } `json:"output"`
  3834. RefmsgTime string `json:"refmsg_time"`
  3835. RespondTime string `json:"respond_time"`
  3836. Signtype interface{} `json:"signtype"`
  3837. WarnMsg interface{} `json:"warn_msg"`
  3838. }
  3839. type ResultTwelve struct {
  3840. Cainfo string `json:"cainfo"`
  3841. ErrMsg string `json:"err_msg"`
  3842. InfRefmsgid string `json:"inf_refmsgid"`
  3843. Infcode int64 `json:"infcode"`
  3844. Output struct {
  3845. MdtrtId string `json:"mdtrt_id"`
  3846. ChrgBchno string `json:"chrg_bchno"`
  3847. PsnNo string `json:"psn_no"`
  3848. } `json:"output"`
  3849. RefmsgTime string `json:"refmsg_time"`
  3850. RespondTime string `json:"respond_time"`
  3851. Signtype interface{} `json:"signtype"`
  3852. WarnMsg interface{} `json:"warn_msg"`
  3853. }
  3854. type ResultThirteen struct {
  3855. ErrMsg string `json:"err_msg"`
  3856. InfRefmsgid string `json:"inf_refmsgid"`
  3857. Infcode int64 `json:"infcode"`
  3858. Output struct {
  3859. Result struct {
  3860. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3861. } `json:"result"`
  3862. } `json:"output"`
  3863. RefmsgTime string `json:"refmsg_time"`
  3864. RespondTime string `json:"respond_time"`
  3865. Signtype interface{} `json:"signtype"`
  3866. WarnInfo interface{} `json:"warn_info"`
  3867. }
  3868. type ResultThirteen10265 struct {
  3869. ErrMsg string `json:"err_msg"`
  3870. InfRefmsgid string `json:"inf_refmsgid"`
  3871. Infcode string `json:"infcode"`
  3872. Output struct {
  3873. Result struct {
  3874. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3875. } `json:"result"`
  3876. } `json:"output"`
  3877. RefmsgTime string `json:"refmsg_time"`
  3878. RespondTime string `json:"respond_time"`
  3879. Signtype interface{} `json:"signtype"`
  3880. WarnInfo interface{} `json:"warn_info"`
  3881. }
  3882. type ResultFourteen struct {
  3883. ErrMsg string `json:"err_msg"`
  3884. InfRefmsgid string `json:"inf_refmsgid"`
  3885. Infcode int64 `json:"infcode"`
  3886. Output struct {
  3887. } `json:"output"`
  3888. RefmsgTime string `json:"refmsg_time"`
  3889. RespondTime string `json:"respond_time"`
  3890. Signtype interface{} `json:"signtype"`
  3891. WarnInfo interface{} `json:"warn_info"`
  3892. }
  3893. type ResultFourteen10265 struct {
  3894. ErrMsg string `json:"err_msg"`
  3895. InfRefmsgid string `json:"inf_refmsgid"`
  3896. Infcode string `json:"infcode"`
  3897. Output struct {
  3898. } `json:"output"`
  3899. RefmsgTime string `json:"refmsg_time"`
  3900. RespondTime string `json:"respond_time"`
  3901. Signtype interface{} `json:"signtype"`
  3902. WarnInfo interface{} `json:"warn_info"`
  3903. }
  3904. type ResultSixteen struct {
  3905. Cainfo string `json:"cainfo"`
  3906. ErrMsg string `json:"err_msg"`
  3907. InfRefmsgid string `json:"inf_refmsgid"`
  3908. Infcode int64 `json:"infcode"`
  3909. Output struct {
  3910. Setldetail []interface{} `json:"setldetail"`
  3911. Setlinfo struct {
  3912. MdtrtID string `json:"mdtrt_id"`
  3913. SetlID string `json:"setl_id"`
  3914. ClrOptins string `json:"clr_optins"`
  3915. SetlTime string `json:"setl_time"`
  3916. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3917. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3918. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3919. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3920. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3921. ActPayDedc float64 `json:"act_pay_dedc"`
  3922. HifpPay float64 `json:"hifp_pay"`
  3923. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3924. Lfpay float64 `json:"selfpay"`
  3925. CvlservPay float64 `json:"cvlserv_pay"`
  3926. HifesPay float64 `json:"hifes_pay"`
  3927. HifmiPay float64 `json:"hifmi_pay"`
  3928. HifobPay float64 `json:"hifob_pay"`
  3929. MafPay float64 `json:"maf_pay"`
  3930. OthPay float64 `json:"oth_pay"`
  3931. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3932. PsnPartAmt float64 `json:"psn_part_amt"`
  3933. AcctPay float64 `json:"acct_pay"`
  3934. Balc float64 `json:"balc"`
  3935. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3936. HospPartAmt float64 `json:"hosp_part_amt"`
  3937. MedinsSetlID string `json:"medins_setl_id"`
  3938. PdnCashPay string `json:"pdn_cash_pay"`
  3939. } `json:"setlinfo"`
  3940. } `json:"output"`
  3941. RefmsgTime string `json:"refmsg_time"`
  3942. RespondTime string `json:"respond_time"`
  3943. Signtype interface{} `json:"signtype"`
  3944. WarnMsg interface{} `json:"warn_msg"`
  3945. }
  3946. type ResultSixteen10265 struct {
  3947. Cainfo string `json:"cainfo"`
  3948. ErrMsg string `json:"err_msg"`
  3949. InfRefmsgid string `json:"inf_refmsgid"`
  3950. Infcode string `json:"infcode"`
  3951. Output struct {
  3952. Setldetail []interface{} `json:"setldetail"`
  3953. Setlinfo struct {
  3954. MdtrtID string `json:"mdtrt_id"`
  3955. SetlID string `json:"setl_id"`
  3956. ClrOptins string `json:"clr_optins"`
  3957. SetlTime string `json:"setl_time"`
  3958. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3959. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3960. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3961. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3963. ActPayDedc float64 `json:"act_pay_dedc"`
  3964. HifpPay float64 `json:"hifp_pay"`
  3965. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3966. Lfpay float64 `json:"selfpay"`
  3967. CvlservPay float64 `json:"cvlserv_pay"`
  3968. HifesPay float64 `json:"hifes_pay"`
  3969. HifmiPay float64 `json:"hifmi_pay"`
  3970. HifobPay float64 `json:"hifob_pay"`
  3971. MafPay float64 `json:"maf_pay"`
  3972. OthPay float64 `json:"oth_pay"`
  3973. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3974. PsnPartAmt float64 `json:"psn_part_amt"`
  3975. AcctPay float64 `json:"acct_pay"`
  3976. Balc float64 `json:"balc"`
  3977. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3978. HospPartAmt float64 `json:"hosp_part_amt"`
  3979. MedinsSetlID string `json:"medins_setl_id"`
  3980. PdnCashPay string `json:"pdn_cash_pay"`
  3981. } `json:"setlinfo"`
  3982. } `json:"output"`
  3983. RefmsgTime string `json:"refmsg_time"`
  3984. RespondTime string `json:"respond_time"`
  3985. Signtype interface{} `json:"signtype"`
  3986. WarnMsg interface{} `json:"warn_msg"`
  3987. }
  3988. type ResultSeventeen struct {
  3989. ErrMsg string `json:"err_msg"`
  3990. InfRefmsgid string `json:"inf_refmsgid"`
  3991. Infcode int64 `json:"infcode"`
  3992. Output struct {
  3993. SetlListId string `json:"setl_list_id"`
  3994. } `json:"output"`
  3995. RefmsgTime string `json:"refmsg_time"`
  3996. RespondTime string `json:"respond_time"`
  3997. Signtype string `json:"signtype"`
  3998. WarnInfo string `json:"warn_info"`
  3999. }
  4000. type Result90991 struct {
  4001. ErrMsg string `json:"err_msg"`
  4002. InfRefmsgid string `json:"inf_refmsgid"`
  4003. Infcode int64 `json:"infcode"`
  4004. Output struct {
  4005. Result struct {
  4006. PsnNo string `json:"psn_no"`
  4007. CardStat string `json:"card_stat"`
  4008. Certno string `json:"certno"`
  4009. PsnName string `json:"psn_name"`
  4010. CheckStat string `json:"check_stat"`
  4011. } `json:"result"`
  4012. } `json:"output"`
  4013. RefmsgTime string `json:"refmsg_time"`
  4014. RespondTime string `json:"respond_time"`
  4015. Signtype interface{} `json:"signtype"`
  4016. WarnInfo interface{} `json:"warn_info"`
  4017. }
  4018. type Result90100 struct {
  4019. ErrMsg string `json:"err_msg"`
  4020. InfRefmsgid string `json:"inf_refmsgid"`
  4021. Infcode int64 `json:"infcode"`
  4022. Output struct {
  4023. PoolareaNo string `json:"poolarea_no"`
  4024. PoolareaNoName string `json:"poolarea_no_name"`
  4025. Insutype string `json:"insutype"`
  4026. InsutypeName string `json:"insutype_name"`
  4027. ClctType string `json:"clct_type"`
  4028. ClctTypeName string `json:"clct_type_name"`
  4029. ClctFlag string `json:"clct_flag"`
  4030. ClctFlagName string `json:"clct_flag_name"`
  4031. AccrymBegn string `json:"accrym_begn"`
  4032. AccrymEnd string `json:"accrym_end"`
  4033. ClctTime string `json:"clct_time"`
  4034. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4035. } `json:"output"`
  4036. RefmsgTime string `json:"refmsg_time"`
  4037. RespondTime string `json:"respond_time"`
  4038. Signtype interface{} `json:"signtype"`
  4039. WarnInfo interface{} `json:"warn_info"`
  4040. }
  4041. type Custom struct {
  4042. DetItemFeeSumamt string
  4043. Cut string
  4044. FeedetlSn string
  4045. Price string
  4046. MedListCodg string
  4047. Type int64
  4048. AdviceId int64
  4049. ProjectId int64
  4050. ItemId int64
  4051. }
  4052. type Result5301 struct {
  4053. ErrMsg string `json:"err_msg"`
  4054. InfRefmsgid string `json:"inf_refmsgid"`
  4055. Infcode int64 `json:"infcode"`
  4056. Output struct {
  4057. Result []struct {
  4058. OpspDiseCode string `json:"opsp_dise_code"`
  4059. OpspDiseName string `json:"opsp_dise_name"`
  4060. Begndate string `json:"begndate"`
  4061. Enddate string `json:"enddate"`
  4062. } `json:"feedetail"`
  4063. } `json:"output"`
  4064. RefmsgTime string `json:"refmsg_time"`
  4065. RespondTime string `json:"respond_time"`
  4066. Signtype interface{} `json:"signtype"`
  4067. WarnInfo interface{} `json:"warn_info"`
  4068. }
  4069. type Result5301For10265 struct {
  4070. ErrMsg string `json:"err_msg"`
  4071. InfRefmsgid string `json:"inf_refmsgid"`
  4072. Infcode string `json:"infcode"`
  4073. Output struct {
  4074. Result []struct {
  4075. OpspDiseCode string `json:"opsp_dise_code"`
  4076. OpspDiseName string `json:"opsp_dise_name"`
  4077. Begndate string `json:"begndate"`
  4078. Enddate string `json:"enddate"`
  4079. } `json:"feedetail"`
  4080. } `json:"output"`
  4081. RefmsgTime string `json:"refmsg_time"`
  4082. RespondTime string `json:"respond_time"`
  4083. Signtype interface{} `json:"signtype"`
  4084. WarnInfo interface{} `json:"warn_info"`
  4085. }
  4086. //获取个人信息----挂号-----上传就诊信息
  4087. func (c *HisApiController) GetRegisterInfo() {
  4088. id, _ := c.GetInt64("id")
  4089. record_time := c.GetString("record_time")
  4090. settlementValue, _ := c.GetInt64("settlement_value")
  4091. medical_insurance_card := c.GetString("medical_insurance_card")
  4092. name := c.GetString("name")
  4093. id_card_type, _ := c.GetInt64("id_card_type")
  4094. certificates, _ := c.GetInt64("certificates")
  4095. medical_care, _ := c.GetInt64("medical_care")
  4096. birthday := c.GetString("birthday")
  4097. id_card := c.GetString("id_card")
  4098. register_type, _ := c.GetInt64("register")
  4099. doctor, _ := c.GetInt64("doctor")
  4100. department, _ := c.GetInt64("department")
  4101. gender, _ := c.GetInt64("sex")
  4102. registration_fee, _ := c.GetFloat("registration_fee")
  4103. medical_expenses, _ := c.GetFloat("medical_expenses")
  4104. social_type, _ := c.GetInt64("social_type")
  4105. med_type := c.GetString("social_type")
  4106. admin_user_id, _ := c.GetInt64("admin_user_id")
  4107. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4108. timeLayout := "2006-01-02"
  4109. loc, _ := time.LoadLocation("Local")
  4110. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4111. birthUnix := birthdays.Unix()
  4112. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4113. if err != nil {
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4115. return
  4116. }
  4117. recordDateTime := theTime.Unix()
  4118. adminInfo := c.GetAdminUserInfo()
  4119. var patient service.Patients
  4120. if id == 0 {
  4121. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4122. } else {
  4123. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4124. }
  4125. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4126. if patientPrescription.ID == 0 {
  4127. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4128. }
  4129. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4130. if patient.ID == 0 {
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4132. return
  4133. }
  4134. if len(patient.IdCardNo) == 0 {
  4135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4136. return
  4137. }
  4138. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4139. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4140. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4141. //就诊结算未完成,不能进行二次挂号
  4142. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4143. if len(his) >= 1 {
  4144. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4145. if len(his) >= 1 && order.ID == 0 {
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4147. return
  4148. }
  4149. }
  4150. //var register_log string
  4151. if config.IsOpen == 1 {
  4152. var res ResultTwo
  4153. var res10265 ResultTwo10265
  4154. var PsnNo string
  4155. var PsnCertType string
  4156. var Certno string
  4157. var PsnName string
  4158. var Gend string
  4159. var Naty string
  4160. var Brdy string
  4161. var Age float64
  4162. var infoStr string
  4163. var idetinfoStr string
  4164. var infocode int64
  4165. var verify_number string
  4166. fmt.Println(verify_number)
  4167. if miConfig.MdtrtareaAdmvs == "421300" {
  4168. psn_info, _ := service.GetPsnByPatientId(id)
  4169. PsnNo = psn_info.PsnNo
  4170. PsnCertType = psn_info.PsnCertType
  4171. Certno = psn_info.Certno
  4172. PsnName = psn_info.PsnName
  4173. Gend = psn_info.Gend
  4174. Naty = psn_info.Naty
  4175. Brdy = psn_info.Brdy
  4176. Age = psn_info.Age
  4177. infoStr = psn_info.Insuinfo
  4178. idetinfoStr = psn_info.Idetinfo
  4179. infocode = 0
  4180. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4181. psn_info, _ := service.GetPsnByPatientId(id)
  4182. PsnNo = psn_info.PsnNo
  4183. PsnCertType = psn_info.PsnCertType
  4184. Certno = psn_info.Certno
  4185. PsnName = psn_info.PsnName
  4186. Gend = psn_info.Gend
  4187. Naty = psn_info.Naty
  4188. Brdy = psn_info.Brdy
  4189. Age = psn_info.Age
  4190. infoStr = psn_info.Insuinfo
  4191. idetinfoStr = psn_info.Idetinfo
  4192. infocode = 0
  4193. verify_number = psn_info.VerifyNumber
  4194. } else {
  4195. var result string
  4196. var requestLog string
  4197. if miConfig.UserOrgId == 10138 {
  4198. 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)
  4199. } else {
  4200. 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)
  4201. }
  4202. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4203. if miConfig.Code == "H15049901371" {
  4204. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4205. utils.ErrorLog("解析失败:%v", err)
  4206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4207. return
  4208. }
  4209. res.ErrMsg = res10265.ErrMsg
  4210. res.Output = res10265.Output
  4211. res.InfRefmsgid = res10265.InfRefmsgid
  4212. } else {
  4213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4214. utils.ErrorLog("解析失败:%v", err)
  4215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4216. return
  4217. }
  4218. }
  4219. PsnNo = res.Output.Baseinfo.PsnNo
  4220. PsnCertType = res.Output.Baseinfo.PsnCertType
  4221. Certno = res.Output.Baseinfo.Certno
  4222. PsnName = res.Output.Baseinfo.PsnName
  4223. Gend = res.Output.Baseinfo.Gend
  4224. Naty = res.Output.Baseinfo.Naty
  4225. Brdy = res.Output.Baseinfo.Brdy
  4226. Age = res.Output.Baseinfo.Age
  4227. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4228. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4229. infoStr = string(Iinfos)
  4230. idetinfoStr = string(Idetinfos)
  4231. if miConfig.Code == "H15049901371" {
  4232. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4233. } else {
  4234. infocode = res.Infcode
  4235. }
  4236. }
  4237. if infocode == 0 {
  4238. his := models.VMHisPatient{
  4239. Name: name,
  4240. Gender: gender,
  4241. Birthday: birthUnix,
  4242. MedicalTreatmentType: medical_care,
  4243. IdType: certificates,
  4244. IdCardNo: id_card,
  4245. BalanceAccountsType: settlementValue,
  4246. SocialType: social_type,
  4247. MedicalInsuranceNumber: medical_insurance_card,
  4248. RegisterType: register_type,
  4249. RegisterCost: registration_fee,
  4250. TreatmentCost: medical_expenses,
  4251. Status: 1,
  4252. Ctime: time.Now().Unix(),
  4253. Mtime: time.Now().Unix(),
  4254. PsnNo: PsnNo,
  4255. PsnCertType: PsnCertType,
  4256. Certno: Certno,
  4257. PsnName: PsnName,
  4258. Gend: Gend,
  4259. Naty: Naty,
  4260. Brdy: Brdy,
  4261. Age: Age,
  4262. Iinfo: infoStr,
  4263. Idetinfo: idetinfoStr,
  4264. PatientId: patient.ID,
  4265. RecordDate: theTime.Unix(),
  4266. UserOrgId: adminInfo.CurrentOrgId,
  4267. AdminUserId: admin_user_id,
  4268. IsReturn: 1,
  4269. IdCardType: id_card_type,
  4270. Doctor: doctor,
  4271. Departments: department,
  4272. }
  4273. timestamp := time.Now().Unix()
  4274. tempTime := time.Unix(timestamp, 0)
  4275. timeFormat := tempTime.Format("20060102150405")
  4276. chrgBchno := rand.Intn(100000) + 10000
  4277. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4278. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4279. department, _ := service.GetDepartMentDetail(department)
  4280. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4281. IdCardNo := ""
  4282. if id_card_type == 1 {
  4283. // IdCardNo = medical_insurance_card
  4284. IdCardNo = patient.IdCardNo
  4285. } else {
  4286. IdCardNo = patient.IdCardNo
  4287. }
  4288. var rf []*ResultFive
  4289. json.Unmarshal([]byte(his.Iinfo), &rf)
  4290. var insutypes []*ResultFive
  4291. var insutype string
  4292. var insuplc_admdvs_temp string
  4293. var is390 int = 0
  4294. var is310 int = 0
  4295. for _, item := range rf {
  4296. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4297. insutypes = append(insutypes, item)
  4298. }
  4299. }
  4300. if len(insutypes) == 1 {
  4301. insutype = insutypes[0].Insutype
  4302. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4303. } else {
  4304. for _, i := range insutypes {
  4305. if i.Insutype == "390" {
  4306. is390 = 1
  4307. }
  4308. if i.Insutype == "310" {
  4309. is310 = 1
  4310. }
  4311. }
  4312. }
  4313. if is390 == 1 {
  4314. insutype = "390"
  4315. }
  4316. if is310 == 1 {
  4317. insutype = "310"
  4318. }
  4319. if len(insutypes) == 0 {
  4320. insutype = "310"
  4321. }
  4322. if len(insutypes) == 2 {
  4323. insutype = med_type
  4324. }
  4325. if len(med_type) > 0 {
  4326. insutype = med_type
  4327. }
  4328. //for _, item := range rf {
  4329. // if item.Insutype == insutype {
  4330. // insuplc_admdvs = item.InsuplcAdmdvs
  4331. // }
  4332. //}
  4333. var infocode int64
  4334. var resThree ResultThree
  4335. var resThree10265 ResultThree10265
  4336. if len(insuplc_admdvs) == 0 {
  4337. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4338. } else {
  4339. insuplc_admdvs_temp = insuplc_admdvs
  4340. }
  4341. if miConfig.MdtrtareaAdmvs == "421300" {
  4342. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4343. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4344. "&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
  4345. resp, requestErr := http.Get(api)
  4346. if requestErr != nil {
  4347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4348. return
  4349. }
  4350. body, ioErr := ioutil.ReadAll(resp.Body)
  4351. if ioErr != nil {
  4352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4354. return
  4355. }
  4356. var respJSON map[string]interface{}
  4357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4360. return
  4361. }
  4362. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4363. result, _ := json.Marshal(respJSON)
  4364. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4365. utils.ErrorLog("解析失败:%v", err)
  4366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. return
  4368. }
  4369. infocode = resThree.Infcode
  4370. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4371. psn_info, _ := service.GetPsnByPatientId(id)
  4372. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4373. var cert_no string
  4374. if id_card_type == 3 {
  4375. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4376. cert_no = IdCardNo
  4377. } else {
  4378. bas := strings.Split(psn_info.CardInfo, "|")
  4379. cert_no = bas[2]
  4380. }
  4381. var api string
  4382. if miConfig.MdtrtareaAdmvs == "320921" {
  4383. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4384. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4385. "&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
  4386. } else {
  4387. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4388. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4389. "&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
  4390. }
  4391. resp, requestErr := http.Get(api)
  4392. if requestErr != nil {
  4393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. return
  4395. }
  4396. body, ioErr := ioutil.ReadAll(resp.Body)
  4397. if ioErr != nil {
  4398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. return
  4401. }
  4402. var respJSON map[string]interface{}
  4403. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4406. return
  4407. }
  4408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4409. result, _ := json.Marshal(respJSON)
  4410. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4411. utils.ErrorLog("解析失败:%v", err)
  4412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4413. return
  4414. }
  4415. resThree.ErrMsg = resThree10265.ErrMsg
  4416. resThree.Output = resThree10265.Output
  4417. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4418. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4419. } else {
  4420. 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)
  4421. saveLog(result, requestLog, "2201A", "挂号")
  4422. if miConfig.Code == "H15049901371" {
  4423. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4424. utils.ErrorLog("解析失败:%v", err)
  4425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4426. return
  4427. }
  4428. resThree.ErrMsg = resThree10265.ErrMsg
  4429. resThree.Output = resThree10265.Output
  4430. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4431. } else {
  4432. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4433. utils.ErrorLog("解析失败:%v", err)
  4434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4435. return
  4436. }
  4437. }
  4438. if miConfig.Code == "H15049901371" {
  4439. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4440. } else {
  4441. infocode = resThree.Infcode
  4442. }
  4443. }
  4444. if infocode != 0 {
  4445. adminUser := c.GetAdminUserInfo()
  4446. errlog := &models.HisOrderError{
  4447. UserOrgId: adminUser.CurrentOrgId,
  4448. Ctime: time.Now().Unix(),
  4449. Mtime: time.Now().Unix(),
  4450. ErrMsg: resThree.ErrMsg,
  4451. Status: 1,
  4452. PatientId: id,
  4453. RecordTime: recordDateTime,
  4454. Stage: 2,
  4455. }
  4456. service.CreateErrMsgLog(errlog)
  4457. c.ServeSuccessJSON(map[string]interface{}{
  4458. "failed_code": -10,
  4459. "msg": resThree.ErrMsg,
  4460. })
  4461. return
  4462. }
  4463. his.Number = resThree.Output.Data.MdtrtID
  4464. his.PsnNo = resThree.Output.Data.PsnNo
  4465. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4466. his.IdCardNo = patient.IdCardNo
  4467. his.PhoneNumber = patient.Phone
  4468. his.UserOrgId = adminInfo.CurrentOrgId
  4469. his.Insutype = insutype
  4470. his.Ctime = time.Now().Unix()
  4471. his.Mtime = time.Now().Unix()
  4472. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4473. his.Status = 1
  4474. service.UpdateHisPatientStatus(&his)
  4475. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4476. c.ServeSuccessJSON(map[string]interface{}{
  4477. "his_info": his,
  4478. })
  4479. } else {
  4480. adminUser := c.GetAdminUserInfo()
  4481. errlog := &models.HisOrderError{
  4482. UserOrgId: adminUser.CurrentOrgId,
  4483. Ctime: time.Now().Unix(),
  4484. Mtime: time.Now().Unix(),
  4485. ErrMsg: res.ErrMsg,
  4486. Status: 1,
  4487. PatientId: id,
  4488. RecordTime: recordDateTime,
  4489. Stage: 1,
  4490. }
  4491. service.CreateErrMsgLog(errlog)
  4492. c.ServeSuccessJSON(map[string]interface{}{
  4493. "failed_code": -10,
  4494. "msg": res.ErrMsg,
  4495. })
  4496. return
  4497. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4498. }
  4499. }
  4500. }
  4501. //上传明细----预结算----确认订单
  4502. func (c *HisApiController) GetUploadInfo() {
  4503. id, _ := c.GetInt64("id")
  4504. record_time := c.GetString("record_time")
  4505. his_patient_id, _ := c.GetInt64("his_patient_id")
  4506. order_id, _ := c.GetInt64("order_id")
  4507. pay_way, _ := c.GetInt64("pay_way")
  4508. pay_price, _ := c.GetFloat("pay_price")
  4509. pay_card_no := c.GetString("pay_card_no")
  4510. discount_price, _ := c.GetFloat("discount_price")
  4511. preferential_price, _ := c.GetFloat("preferential_price")
  4512. reality_price, _ := c.GetFloat("reality_price")
  4513. found_price, _ := c.GetFloat("found_price")
  4514. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4515. private_price, _ := c.GetFloat("private_price")
  4516. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4517. admin_user_id, _ := c.GetInt64("admin_user_id")
  4518. fapiao_code := c.GetString("fapiao_code")
  4519. fapiao_number := c.GetString("fapiao_number")
  4520. diagnosis_id := c.GetString("diagnosis")
  4521. sick_type, _ := c.GetInt64("sick_type")
  4522. reg_type, _ := c.GetInt64("p_type")
  4523. begin_time := c.GetString("begin_time")
  4524. id_str := c.GetString("ids")
  4525. ids_arr := strings.Split(id_str, ",")
  4526. timeLayout := "2006-01-02"
  4527. loc, _ := time.LoadLocation("Local")
  4528. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4529. if err != nil {
  4530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4531. return
  4532. }
  4533. recordDateTime := theTime.Unix()
  4534. adminUser := c.GetAdminUserInfo()
  4535. var tempOrder models.HisOrder
  4536. tempOrder, _ = service.GetHisOrderByID(order_id)
  4537. var prescriptions []*models.HisPrescription
  4538. var start_time int64
  4539. var end_time int64
  4540. //if adminUser.CurrentOrgId == 10106{
  4541. // if len(fapiao_code) == 0{
  4542. // fapiao_code = "144072080589"
  4543. // }
  4544. // if len(fapiao_number) == 0{
  4545. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4546. // if order.ID == 0{
  4547. // fapiao_number = "00001520"
  4548. // }else{
  4549. // //fapiao_code = "00001520"
  4550. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4551. // var zero string
  4552. // if fpNumber >= 1000{
  4553. // zero = "0000" + strconv.Itoa(fpNumber)
  4554. // }else if fpNumber >= 10000{
  4555. // zero = "000" + strconv.Itoa(fpNumber)
  4556. // } else if fpNumber >= 100000{
  4557. // zero = "00" + strconv.Itoa(fpNumber)
  4558. // } else if fpNumber >= 1000000{
  4559. // zero = "0" + strconv.Itoa(fpNumber)
  4560. // }else {
  4561. // zero = strconv.Itoa(fpNumber)
  4562. // }
  4563. // fapiao_number = zero
  4564. // }
  4565. // }
  4566. //}
  4567. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4568. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4569. var patientPrescription models.HisPrescriptionInfo
  4570. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4571. if patientPrescription.ID == 0 {
  4572. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4573. }
  4574. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4575. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4576. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4577. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4578. var config []*models.HisXtDiagnoseConfig
  4579. for _, item := range diagnosis_ids {
  4580. id, _ := strconv.ParseInt(item, 10, 64)
  4581. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4582. config = append(config, &diagnosisConfig)
  4583. }
  4584. sickConfig, _ := service.FindSickById(sick_type)
  4585. //if tempOrder.ID == 0 {
  4586. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4587. //}
  4588. if tempOrder.ID == 0 {
  4589. var result string
  4590. var requestLog string
  4591. var res2 ResultSix
  4592. var ressix10265 ResultSix10265
  4593. if miConfig.MdtrtareaAdmvs == "421300" {
  4594. data := make(map[string]interface{})
  4595. client := &http.Client{}
  4596. data["psn_no"] = his.PsnNo
  4597. data["mdtrt_id"] = his.Number
  4598. data["doctor"] = roles.UserName
  4599. data["department"] = department.Name
  4600. data["org_name"] = miConfig.OrgName
  4601. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4602. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4603. data["fixmedins_code"] = miConfig.Code
  4604. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4605. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4606. data["secret_key"] = miConfig.SecretKey
  4607. data["sick_code"] = sickConfig.CountryCode
  4608. data["sick_name"] = sickConfig.ClassName
  4609. data["dept"] = strconv.FormatInt(department.ID, 10)
  4610. data["config"] = config
  4611. data["begin_time"] = begin_time
  4612. bytesData, _ := json.Marshal(data)
  4613. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4614. resp, _ := client.Do(req)
  4615. defer resp.Body.Close()
  4616. body, ioErr := ioutil.ReadAll(resp.Body)
  4617. if ioErr != nil {
  4618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4620. return
  4621. }
  4622. var respJSON map[string]interface{}
  4623. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4626. return
  4627. }
  4628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4629. userJSONBytes, _ := json.Marshal(respJSON)
  4630. fmt.Println("log")
  4631. fmt.Println(string(userJSONBytes))
  4632. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4633. utils.ErrorLog("解析失败:%v", err)
  4634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4635. return
  4636. }
  4637. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4638. //江苏地区国家医保医疗类别
  4639. //职工透析:医疗类别选特殊情况门诊9933
  4640. //居民血透门慢: 医疗类别选门诊慢病1402
  4641. //var med_type string
  4642. //if his.Insutype == "310" {
  4643. // if reg_type == 14 {
  4644. // med_type = "9933"
  4645. // } else if reg_type == 11 {
  4646. // med_type = "11"
  4647. //
  4648. // }
  4649. //} else if his.Insutype == "390" {
  4650. // if reg_type == 14 {
  4651. // med_type = "1402"
  4652. // } else if reg_type == 11 {
  4653. // med_type = "11"
  4654. // }
  4655. //}
  4656. data := make(map[string]interface{})
  4657. client := &http.Client{}
  4658. data["psn_no"] = his.PsnNo
  4659. data["mdtrt_id"] = his.Number
  4660. data["doctor"] = roles.UserName
  4661. data["department"] = department.Name
  4662. data["org_name"] = miConfig.OrgName
  4663. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4664. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4665. data["fixmedins_code"] = miConfig.Code
  4666. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4667. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4668. data["secret_key"] = miConfig.SecretKey
  4669. data["sick_code"] = sickConfig.CountryCode
  4670. data["sick_name"] = sickConfig.ClassName
  4671. data["url"] = miConfig.Url
  4672. data["ak"] = miConfig.AccessKey
  4673. data["begin_time"] = begin_time
  4674. data["cainfo"] = miConfig.Cainfo
  4675. data["dept"] = strconv.FormatInt(department.ID, 10)
  4676. data["config"] = config
  4677. bytesData, _ := json.Marshal(data)
  4678. var req *http.Request
  4679. if miConfig.MdtrtareaAdmvs == "320921" {
  4680. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4681. //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 +
  4682. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4683. } else {
  4684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4685. }
  4686. resp, _ := client.Do(req)
  4687. defer resp.Body.Close()
  4688. body, ioErr := ioutil.ReadAll(resp.Body)
  4689. if ioErr != nil {
  4690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4692. return
  4693. }
  4694. var respJSON map[string]interface{}
  4695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4698. return
  4699. }
  4700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4701. userJSONBytes, _ := json.Marshal(respJSON)
  4702. fmt.Println("log")
  4703. fmt.Println(string(userJSONBytes))
  4704. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4705. utils.ErrorLog("解析失败:%v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4710. res2.Output = ressix10265.Output
  4711. res2.ErrMsg = ressix10265.ErrMsg
  4712. res2.Cainfo = ressix10265.Cainfo
  4713. res2.WarnMsg = ressix10265.WarnMsg
  4714. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4715. res2.Infcode = infocode
  4716. } else {
  4717. if miConfig.MdtrtareaAdmvs == "440781" { //
  4718. 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)
  4719. } else {
  4720. if miConfig.Code == "H15049901371" {
  4721. //赤峰地区国家医保医疗类别
  4722. //职工透析:医疗类别选特殊情况门诊990502
  4723. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4724. var med_type string
  4725. if his.Insutype == "390" {
  4726. if reg_type == 14 {
  4727. med_type = "9933"
  4728. } else if reg_type == 11 {
  4729. med_type = "11"
  4730. }
  4731. } else if his.Insutype == "310" {
  4732. if reg_type == 14 {
  4733. med_type = "990502"
  4734. } else if reg_type == 11 {
  4735. med_type = "11"
  4736. }
  4737. }
  4738. 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)
  4739. } else {
  4740. 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)
  4741. }
  4742. }
  4743. saveLog(result, requestLog, "2203", "上传就诊信息")
  4744. var respJSON2 map[string]interface{}
  4745. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. userJSONBytes2, _ := json.Marshal(respJSON2)
  4751. if miConfig.Code == "H15049901371" {
  4752. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4753. utils.ErrorLog("解析失败:%v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4758. res2.Output = ressix10265.Output
  4759. res2.ErrMsg = ressix10265.ErrMsg
  4760. res2.Cainfo = ressix10265.Cainfo
  4761. res2.WarnMsg = ressix10265.WarnMsg
  4762. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4763. res2.Infcode = infocode
  4764. } else {
  4765. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4766. utils.ErrorLog("解析失败:%v", err)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. }
  4771. }
  4772. if res2.Infcode != 0 {
  4773. adminUser := c.GetAdminUserInfo()
  4774. errlog := &models.HisOrderError{
  4775. UserOrgId: adminUser.CurrentOrgId,
  4776. Ctime: time.Now().Unix(),
  4777. Mtime: time.Now().Unix(),
  4778. ErrMsg: res2.ErrMsg,
  4779. Status: 1,
  4780. PatientId: id,
  4781. RecordTime: recordDateTime,
  4782. Stage: 3,
  4783. }
  4784. service.CreateErrMsgLog(errlog)
  4785. c.ServeSuccessJSON(map[string]interface{}{
  4786. "failed_code": -10,
  4787. "msg": res2.ErrMsg,
  4788. })
  4789. return
  4790. } else {
  4791. his.Diagnosis = diagnosis_id
  4792. his.SickType = sickConfig.ID
  4793. //var p_type int64
  4794. //if reg_type == 1111 || reg_type == 1112 {
  4795. // p_type = 11
  4796. //
  4797. //}
  4798. his.PType = fmt.Sprintf("%d", reg_type)
  4799. service.UpdateHisPatientThree(&his)
  4800. data := make(map[string]interface{})
  4801. if settle_accounts_type == 1 { //日结
  4802. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4803. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4804. } else {
  4805. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4806. }
  4807. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4808. data["pre"] = prescriptions
  4809. } else { //月结
  4810. start_time_str := c.GetString("start_time")
  4811. end_time_str := c.GetString("end_time")
  4812. timeLayout := "2006-01-02"
  4813. loc, _ := time.LoadLocation("Local")
  4814. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4815. if err != nil {
  4816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4817. return
  4818. }
  4819. recordStartTime := theStartTime.Unix()
  4820. start_time = recordStartTime
  4821. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4822. if err != nil {
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4824. return
  4825. }
  4826. recordEndTime := theEndTime.Unix()
  4827. end_time = recordEndTime
  4828. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4829. data["pre"] = prescriptions
  4830. }
  4831. timestamp := time.Now().Unix()
  4832. tempTime := time.Unix(timestamp, 0)
  4833. timeFormat := tempTime.Format("20060102150405")
  4834. chrgBchno := rand.Intn(100000) + 10000
  4835. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4836. strconv.FormatInt(his.PatientId, 10)
  4837. client := &http.Client{}
  4838. data["psn_no"] = his.PsnNo
  4839. data["mdtrt_id"] = his.Number
  4840. data["chrg_bchno"] = chrg_bchno
  4841. data["org_name"] = miConfig.OrgName
  4842. data["doctor"] = roles.UserName
  4843. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4844. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4845. data["fixmedins_code"] = miConfig.Code
  4846. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4847. // data["dept_code"] = "15"
  4848. //} else {
  4849. data["dept_code"] = department.Number
  4850. //}
  4851. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4852. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4853. data["secret_key"] = miConfig.SecretKey
  4854. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4855. data["url"] = miConfig.Url
  4856. data["ak"] = miConfig.AccessKey
  4857. data["new_doctor_name"] = patientPrescription.Doctor
  4858. data["diag_code"] = sickConfig.CountryCode
  4859. data["cainfo"] = miConfig.Cainfo
  4860. var ids []int64
  4861. for _, item := range prescriptions {
  4862. ids = append(ids, item.ID)
  4863. }
  4864. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4865. if config.IsOpen == 1 { //对接了医保,走医保流程
  4866. var res ResultFour
  4867. var resFour10265 ResultFour10265
  4868. if miConfig.MdtrtareaAdmvs == "421300" {
  4869. bytesData, _ := json.Marshal(data)
  4870. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4871. resp, _ := client.Do(req)
  4872. defer resp.Body.Close()
  4873. body, ioErr := ioutil.ReadAll(resp.Body)
  4874. if ioErr != nil {
  4875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4877. return
  4878. }
  4879. var respJSON map[string]interface{}
  4880. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4883. return
  4884. }
  4885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4886. userJSONBytes, _ := json.Marshal(respJSON)
  4887. fmt.Println("log")
  4888. fmt.Println(string(userJSONBytes))
  4889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4890. utils.ErrorLog("解析失败:%v", err)
  4891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4892. return
  4893. }
  4894. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4895. bytesData, _ := json.Marshal(data)
  4896. var req *http.Request
  4897. if miConfig.MdtrtareaAdmvs == "320921" {
  4898. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4899. } else {
  4900. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4901. }
  4902. resp, _ := client.Do(req)
  4903. defer resp.Body.Close()
  4904. body, ioErr := ioutil.ReadAll(resp.Body)
  4905. if ioErr != nil {
  4906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return
  4909. }
  4910. var respJSON map[string]interface{}
  4911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4914. return
  4915. }
  4916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4917. userJSONBytes, _ := json.Marshal(respJSON)
  4918. fmt.Println("log")
  4919. fmt.Println(string(userJSONBytes))
  4920. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4921. utils.ErrorLog("解析失败:%v", err)
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4923. return
  4924. }
  4925. res.InfRefmsgid = resFour10265.InfRefmsgid
  4926. res.Output = resFour10265.Output
  4927. res.ErrMsg = resFour10265.ErrMsg
  4928. res.Cainfo = resFour10265.Cainfo
  4929. res.WarnMsg = resFour10265.WarnMsg
  4930. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4931. res.Infcode = infocode
  4932. } else {
  4933. if miConfig.Code == "H15049901371" {
  4934. 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)
  4935. var dat map[string]interface{}
  4936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4937. fmt.Println(dat)
  4938. } else {
  4939. fmt.Println(err)
  4940. }
  4941. saveLog(result, request_log, "2204", "上传费用明细")
  4942. userJSONBytes, _ := json.Marshal(dat)
  4943. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4944. utils.ErrorLog("解析失败:%v", err)
  4945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4946. return
  4947. }
  4948. res.InfRefmsgid = resFour10265.InfRefmsgid
  4949. res.Output = resFour10265.Output
  4950. res.ErrMsg = resFour10265.ErrMsg
  4951. res.Cainfo = resFour10265.Cainfo
  4952. res.WarnMsg = resFour10265.WarnMsg
  4953. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4954. res.Infcode = infocode
  4955. } else {
  4956. 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)
  4957. var dat map[string]interface{}
  4958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4959. fmt.Println(dat)
  4960. } else {
  4961. fmt.Println(err)
  4962. }
  4963. saveLog(result, request_log, "2204", "上传费用明细")
  4964. userJSONBytes, _ := json.Marshal(dat)
  4965. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4966. utils.ErrorLog("解析失败:%v", err)
  4967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4968. return
  4969. }
  4970. }
  4971. }
  4972. if res.Infcode == 0 {
  4973. order := &models.HisOrder{
  4974. UserOrgId: adminUser.CurrentOrgId,
  4975. HisPatientId: his.ID,
  4976. PatientId: his.PatientId,
  4977. SettleAccountsDate: recordDateTime,
  4978. MdtrtId: his.Number,
  4979. PsnNo: his.PsnNo,
  4980. MedType: strconv.FormatInt(reg_type, 10),
  4981. Ctime: time.Now().Unix(),
  4982. Mtime: time.Now().Unix(),
  4983. Status: 1,
  4984. Number: chrg_bchno,
  4985. Infcode: res.Infcode,
  4986. WarnMsg: res.WarnMsg,
  4987. Cainfo: res.Cainfo,
  4988. ErrMsg: res.ErrMsg,
  4989. RespondTime: res.RefmsgTime,
  4990. InfRefmsgid: res.InfRefmsgid,
  4991. OrderStatus: 1,
  4992. PayWay: pay_way,
  4993. PayPrice: pay_price,
  4994. PayCardNo: pay_card_no,
  4995. DiscountPrice: discount_price,
  4996. PreferentialPrice: preferential_price,
  4997. RealityPrice: reality_price,
  4998. FoundPrice: found_price,
  4999. MedicalInsurancePrice: medical_insurance_price,
  5000. PrivatePrice: private_price,
  5001. IsMedicineInsurance: 1,
  5002. SettleType: settle_accounts_type,
  5003. SettleStartTime: start_time,
  5004. SettleEndTime: end_time,
  5005. Creator: roles.AdminUserId,
  5006. Modify: roles.AdminUserId,
  5007. FaPiaoNumber: fapiao_number,
  5008. FaPiaoCode: fapiao_code,
  5009. PType: 2,
  5010. Diagnosis: diagnosis_id,
  5011. }
  5012. err = service.CreateOrder(order)
  5013. if err != nil {
  5014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5015. return
  5016. }
  5017. for _, item := range res.Output.Result {
  5018. temp := strings.Split(item.FeedetlSn, "-")
  5019. var advice_id int64 = 0
  5020. var project_id int64 = 0
  5021. var types int64 = 0
  5022. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5023. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5024. if temp[1] == "1" {
  5025. advice_id = id
  5026. project_id = 0
  5027. } else if temp[1] == "2" {
  5028. advice_id = 0
  5029. project_id = id
  5030. }
  5031. info := &models.HisOrderInfo{
  5032. OrderNumber: order.Number,
  5033. FeedetlSn: item.FeedetlSn,
  5034. UploadDate: time.Now().Unix(),
  5035. AdviceId: advice_id,
  5036. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5037. Cnt: item.Cnt,
  5038. Pric: float64(item.Pric),
  5039. PatientId: his.PatientId,
  5040. PricUplmtAmt: item.PricUplmtAmt,
  5041. SelfpayProp: item.SelfpayProp,
  5042. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5043. OverlmtAmt: item.OverlmtAmt,
  5044. PreselfpayAmt: item.PreselfpayAmt,
  5045. BasMednFlag: item.BasMednFlag,
  5046. MedChrgitmType: item.MedChrgitmType,
  5047. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5048. Status: 1,
  5049. Memo: item.Memo,
  5050. Mtime: time.Now().Unix(),
  5051. InscpScpAmt: item.InscpScpAmt,
  5052. DrtReimFlag: item.DrtReimFlag,
  5053. Ctime: time.Now().Unix(),
  5054. ListSpItemFlag: item.ListSpItemFlag,
  5055. ChldMedcFlag: item.ChldMedcFlag,
  5056. LmtUsedFlag: item.LmtUsedFlag,
  5057. ChrgitmLv: item.ChrgitmLv,
  5058. UserOrgId: adminUser.CurrentOrgId,
  5059. HisPatientId: his.ID,
  5060. OrderId: order.ID,
  5061. ProjectId: project_id,
  5062. Type: types,
  5063. }
  5064. service.CreateOrderInfo(info)
  5065. }
  5066. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5067. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5068. var total float64
  5069. for _, item := range prescriptions {
  5070. if item.Type == 1 { //药品
  5071. for _, subItem := range item.HisDoctorAdviceInfo {
  5072. total = total + (subItem.Price * subItem.PrescribingNumber)
  5073. }
  5074. }
  5075. if item.Type == 2 { //项目
  5076. for _, subItem := range item.HisPrescriptionProject {
  5077. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5078. total = total + (subItem.Price * cnt)
  5079. }
  5080. }
  5081. }
  5082. for _, item := range prescriptions {
  5083. for _, subItem := range item.HisAdditionalCharge {
  5084. total = total + (subItem.Price * float64(subItem.Count))
  5085. }
  5086. }
  5087. var allTotal string
  5088. if adminUser.CurrentOrgId == 9919 {
  5089. allTotal = fmt.Sprintf("%.4f", total)
  5090. } else {
  5091. allTotal = fmt.Sprintf("%.4f", total)
  5092. }
  5093. if res.Infcode == 0 {
  5094. var rf []*ResultFive
  5095. json.Unmarshal([]byte(his.Iinfo), &rf)
  5096. chrg_bchno := chrg_bchno
  5097. cert_no := his.Certno
  5098. var insutypes []string
  5099. var insutype string
  5100. var is390 int = 0
  5101. var is310 int = 0
  5102. for _, item := range rf {
  5103. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5104. insutypes = append(insutypes, item.Insutype)
  5105. }
  5106. }
  5107. if len(insutypes) == 1 {
  5108. insutype = insutypes[0]
  5109. } else {
  5110. for _, i := range insutypes {
  5111. if i == "390" {
  5112. is390 = 1
  5113. }
  5114. if i == "310" {
  5115. is310 = 1
  5116. }
  5117. }
  5118. }
  5119. if is390 == 1 {
  5120. insutype = "390"
  5121. }
  5122. if is310 == 1 {
  5123. insutype = "310"
  5124. }
  5125. if len(insutypes) == 0 {
  5126. insutype = "310"
  5127. }
  5128. if len(insutypes) == 2 {
  5129. insutype = strconv.FormatInt(his.SocialType, 10)
  5130. }
  5131. insutype = strconv.FormatInt(his.SocialType, 10)
  5132. //insutype = "390"
  5133. if his.IdCardType == 1 {
  5134. // cert_no = his.MedicalInsuranceNumber
  5135. cert_no = his.Certno
  5136. } else {
  5137. cert_no = his.Certno
  5138. }
  5139. var res ResultSeven
  5140. var resSeven10265 ResultSeven10265
  5141. var src_resquest string
  5142. var result2 string
  5143. var acct_used_flag string
  5144. fmt.Println("pay_way")
  5145. fmt.Println(pay_way)
  5146. fmt.Println("pay_way")
  5147. if pay_way == 4 {
  5148. acct_used_flag = "1"
  5149. } else {
  5150. acct_used_flag = "0"
  5151. }
  5152. if miConfig.MdtrtareaAdmvs == "421300" {
  5153. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5154. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5155. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5156. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5157. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5158. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5159. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5160. resp, requestErr := http.Get(api)
  5161. if requestErr != nil {
  5162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5163. return
  5164. }
  5165. body, ioErr := ioutil.ReadAll(resp.Body)
  5166. if ioErr != nil {
  5167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5169. return
  5170. }
  5171. var respJSON map[string]interface{}
  5172. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5175. return
  5176. }
  5177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5178. result, _ := json.Marshal(respJSON)
  5179. if miConfig.Code == "H15049901371" {
  5180. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5181. utils.ErrorLog("解析失败:%v", err)
  5182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5183. return
  5184. }
  5185. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5186. res.Output = resSeven10265.Output
  5187. res.ErrMsg = resSeven10265.ErrMsg
  5188. res.Cainfo = resSeven10265.Cainfo
  5189. res.WarnMsg = resSeven10265.WarnMsg
  5190. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5191. res.Infcode = infocode
  5192. } else {
  5193. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5194. utils.ErrorLog("解析失败:%v", err)
  5195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5196. return
  5197. }
  5198. }
  5199. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5200. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5201. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5202. //psn_info, _ := service.GetPsnByPatientId(id)
  5203. bas := strings.Split(psn_info.CardInfo, "|")
  5204. if his.IdCardType == 1 {
  5205. cert_no = bas[2]
  5206. } else if his.IdCardType == 3 {
  5207. cert_no = his.Certno
  5208. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5209. } else {
  5210. cert_no = bas[1]
  5211. }
  5212. //江苏地区国家医保医疗类别
  5213. //职工透析:医疗类别选特殊情况门诊9933
  5214. //居民血透门慢: 医疗类别选门诊慢病1402
  5215. //var med_type string
  5216. //if his.Insutype == "310" {
  5217. // if reg_type == 14 {
  5218. // med_type = "9933"
  5219. // } else if reg_type == 11 {
  5220. // med_type = "11"
  5221. //
  5222. // }
  5223. //} else if his.Insutype == "390" {
  5224. // if reg_type == 14 {
  5225. // med_type = "1402"
  5226. // } else if reg_type == 11 {
  5227. // med_type = "11"
  5228. // }
  5229. //}
  5230. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5231. var api string
  5232. if miConfig.MdtrtareaAdmvs == "320921" {
  5233. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5234. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5235. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5236. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5237. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5238. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5239. "&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
  5240. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5241. } else {
  5242. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5243. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5244. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5245. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5246. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5247. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5248. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5249. "&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
  5250. }
  5251. resp, requestErr := http.Get(api)
  5252. if requestErr != nil {
  5253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5254. return
  5255. }
  5256. body, ioErr := ioutil.ReadAll(resp.Body)
  5257. if ioErr != nil {
  5258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5260. return
  5261. }
  5262. var respJSON map[string]interface{}
  5263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5266. return
  5267. }
  5268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5269. result, _ := json.Marshal(respJSON)
  5270. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5271. utils.ErrorLog("解析失败:%v", err)
  5272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5273. return
  5274. }
  5275. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5276. res.Output = resSeven10265.Output
  5277. res.ErrMsg = resSeven10265.ErrMsg
  5278. res.Cainfo = resSeven10265.Cainfo
  5279. res.WarnMsg = resSeven10265.WarnMsg
  5280. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5281. res.Infcode = infocode
  5282. } else {
  5283. if miConfig.Code == "H15049901371" {
  5284. //赤峰地区国家医保医疗类别
  5285. //职工透析:医疗类别选特殊情况门诊990502
  5286. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5287. var med_type string
  5288. if his.Insutype == "390" {
  5289. if reg_type == 14 {
  5290. med_type = "9933"
  5291. } else if reg_type == 11 {
  5292. med_type = "11"
  5293. }
  5294. } else if his.Insutype == "310" {
  5295. if reg_type == 14 {
  5296. med_type = "990502"
  5297. } else if reg_type == 11 {
  5298. med_type = "11"
  5299. }
  5300. }
  5301. 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)
  5302. } else {
  5303. 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)
  5304. }
  5305. //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)
  5306. var dat map[string]interface{}
  5307. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5308. fmt.Println(dat)
  5309. } else {
  5310. fmt.Println(err)
  5311. }
  5312. saveLog(result2, src_resquest, "2207", "结算")
  5313. userJSONBytes, _ := json.Marshal(dat)
  5314. if miConfig.Code == "H15049901371" {
  5315. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5316. utils.ErrorLog("解析失败:%v", err)
  5317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5318. return
  5319. }
  5320. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5321. res.Output = resSeven10265.Output
  5322. res.ErrMsg = resSeven10265.ErrMsg
  5323. res.Cainfo = resSeven10265.Cainfo
  5324. res.WarnMsg = resSeven10265.WarnMsg
  5325. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5326. res.Infcode = infocode
  5327. } else {
  5328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5329. utils.ErrorLog("解析失败:%v", err)
  5330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5331. return
  5332. }
  5333. }
  5334. }
  5335. if res.Infcode != 0 {
  5336. errlog := &models.HisOrderError{
  5337. UserOrgId: adminUser.CurrentOrgId,
  5338. Ctime: time.Now().Unix(),
  5339. Mtime: time.Now().Unix(),
  5340. Number: chrg_bchno,
  5341. ErrMsg: res.ErrMsg,
  5342. Status: 1,
  5343. PatientId: id,
  5344. RecordTime: recordDateTime,
  5345. Stage: 6,
  5346. }
  5347. service.CreateErrMsgLog(errlog)
  5348. c.ServeSuccessJSON(map[string]interface{}{
  5349. "failed_code": -10,
  5350. "msg": res.ErrMsg,
  5351. })
  5352. return
  5353. } else {
  5354. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5355. order.OrderStatus = 2
  5356. order.Status = 1
  5357. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5358. order.SetlId = res.Output.Setlinfo.SetlID
  5359. order.PsnNo = res.Output.Setlinfo.PsnNo
  5360. order.PsnName = res.Output.Setlinfo.PsnName
  5361. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5362. order.Certno = res.Output.Setlinfo.Certno
  5363. order.Gend = res.Output.Setlinfo.Gend
  5364. order.Naty = res.Output.Setlinfo.Naty
  5365. order.Age = res.Output.Setlinfo.Age
  5366. order.Insutype = res.Output.Setlinfo.Insutype
  5367. order.PsnType = res.Output.Setlinfo.PsnType
  5368. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5369. order.SetlTime = res.Output.Setlinfo.SetlTime
  5370. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5371. if res.Output.Setlinfo.MedType == "140101" {
  5372. order.MedType = "14"
  5373. } else {
  5374. order.MedType = res.Output.Setlinfo.MedType
  5375. }
  5376. if reg_type == 1112 {
  5377. order.MedType = "1112"
  5378. }
  5379. if reg_type == 1111 {
  5380. order.MedType = "1111"
  5381. }
  5382. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5383. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5384. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5385. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5386. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5387. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5388. order.HifpPay = res.Output.Setlinfo.HifpPay
  5389. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5390. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5391. order.HifesPay = res.Output.Setlinfo.HifesPay
  5392. order.HifobPay = res.Output.Setlinfo.HifobPay
  5393. order.MafPay = res.Output.Setlinfo.MafPay
  5394. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5395. order.OthPay = res.Output.Setlinfo.OthPay
  5396. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5397. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5398. order.AcctPay = res.Output.Setlinfo.AcctPay
  5399. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5400. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5401. order.Balc = res.Output.Setlinfo.Balc
  5402. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5403. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5404. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5405. order.ClrType = res.Output.Setlinfo.ClrType
  5406. order.ClrWay = res.Output.Setlinfo.ClrWay
  5407. order.Creator = order.Creator
  5408. order.Modify = roles.AdminUserId
  5409. order.RequestLog = src_resquest
  5410. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5411. detailStr := string(setlDetail)
  5412. order.SetlDetail = detailStr
  5413. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5414. err = service.UpDateOrder(order)
  5415. if err == nil {
  5416. c.ServeSuccessJSON(map[string]interface{}{
  5417. "msg": "结算成功",
  5418. })
  5419. } else {
  5420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5421. return
  5422. }
  5423. }
  5424. } else {
  5425. adminUser := c.GetAdminUserInfo()
  5426. errlog := &models.HisOrderError{
  5427. UserOrgId: adminUser.CurrentOrgId,
  5428. Ctime: time.Now().Unix(),
  5429. Mtime: time.Now().Unix(),
  5430. ErrMsg: res.ErrMsg,
  5431. Status: 1,
  5432. PatientId: id,
  5433. RecordTime: recordDateTime,
  5434. Stage: 4,
  5435. }
  5436. service.CreateErrMsgLog(errlog)
  5437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5438. return
  5439. }
  5440. } else {
  5441. adminUser := c.GetAdminUserInfo()
  5442. errlog := &models.HisOrderError{
  5443. UserOrgId: adminUser.CurrentOrgId,
  5444. Ctime: time.Now().Unix(),
  5445. Mtime: time.Now().Unix(),
  5446. ErrMsg: res.ErrMsg,
  5447. Status: 1,
  5448. PatientId: id,
  5449. RecordTime: recordDateTime,
  5450. Stage: 4,
  5451. }
  5452. service.CreateErrMsgLog(errlog)
  5453. c.ServeSuccessJSON(map[string]interface{}{
  5454. "failed_code": -10,
  5455. "msg": res.ErrMsg,
  5456. })
  5457. return
  5458. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5459. //return
  5460. }
  5461. }
  5462. }
  5463. } else if tempOrder.ID > 0 {
  5464. if tempOrder.IsPre == 1 {
  5465. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5466. var rf []*ResultFive
  5467. json.Unmarshal([]byte(his.Iinfo), &rf)
  5468. chrg_bchno := tempOrder.Number
  5469. cert_no := his.Certno
  5470. var insutypes []string
  5471. var insutype string
  5472. var is390 int = 0
  5473. var is310 int = 0
  5474. for _, item := range rf {
  5475. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5476. insutypes = append(insutypes, item.Insutype)
  5477. }
  5478. }
  5479. if len(insutypes) == 1 {
  5480. insutype = insutypes[0]
  5481. } else {
  5482. for _, i := range insutypes {
  5483. if i == "390" {
  5484. is390 = 1
  5485. }
  5486. if i == "310" {
  5487. is310 = 1
  5488. }
  5489. }
  5490. }
  5491. if is390 == 1 {
  5492. insutype = "390"
  5493. }
  5494. if is310 == 1 {
  5495. insutype = "310"
  5496. }
  5497. if len(insutypes) == 0 {
  5498. insutype = "310"
  5499. }
  5500. if len(insutypes) == 2 {
  5501. insutype = strconv.FormatInt(his.SocialType, 64)
  5502. }
  5503. //insutype = "390"
  5504. if his.IdCardType == 1 {
  5505. // cert_no = his.MedicalInsuranceNumber
  5506. cert_no = his.Certno
  5507. } else {
  5508. cert_no = his.Certno
  5509. }
  5510. var res ResultSeven
  5511. var resSeven10265 ResultSeven10265
  5512. var src_resquest string
  5513. var result2 string
  5514. var acct_used_flag string
  5515. fmt.Println("pay_way")
  5516. fmt.Println(pay_way)
  5517. fmt.Println("pay_way")
  5518. if pay_way == 4 {
  5519. acct_used_flag = "1"
  5520. } else {
  5521. acct_used_flag = "0"
  5522. }
  5523. if miConfig.MdtrtareaAdmvs == "421300" {
  5524. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5525. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5526. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5527. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5528. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5529. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5530. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5531. resp, requestErr := http.Get(api)
  5532. if requestErr != nil {
  5533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5534. return
  5535. }
  5536. body, ioErr := ioutil.ReadAll(resp.Body)
  5537. if ioErr != nil {
  5538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5540. return
  5541. }
  5542. var respJSON map[string]interface{}
  5543. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5546. return
  5547. }
  5548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5549. result, _ := json.Marshal(respJSON)
  5550. fmt.Println("log")
  5551. fmt.Println(string(result))
  5552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5553. utils.ErrorLog("解析失败:%v", err)
  5554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5555. return
  5556. }
  5557. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5558. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5559. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5560. //psn_info, _ := service.GetPsnByPatientId(id)
  5561. bas := strings.Split(psn_info.CardInfo, "|")
  5562. if his.IdCardType == 1 {
  5563. cert_no = bas[2]
  5564. } else {
  5565. cert_no = bas[1]
  5566. }
  5567. //江苏地区国家医保医疗类别
  5568. //职工透析:医疗类别选特殊情况门诊9933
  5569. //居民血透门慢: 医疗类别选门诊慢病1402
  5570. //var med_type string
  5571. //if his.Insutype == "310" {
  5572. // if reg_type == 14 {
  5573. // med_type = "9933"
  5574. // } else if reg_type == 11 {
  5575. // med_type = "11"
  5576. //
  5577. // }
  5578. //} else if his.Insutype == "390" {
  5579. // if reg_type == 14 {
  5580. // med_type = "1402"
  5581. // } else if reg_type == 11 {
  5582. // med_type = "11"
  5583. // }
  5584. //}
  5585. var api string
  5586. if miConfig.MdtrtareaAdmvs == "320921" {
  5587. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5588. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5589. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5590. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5591. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5592. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5593. "&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
  5594. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5595. } else {
  5596. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5597. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5598. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5599. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5601. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5602. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5603. "&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
  5604. }
  5605. resp, requestErr := http.Get(api)
  5606. if requestErr != nil {
  5607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5608. return
  5609. }
  5610. body, ioErr := ioutil.ReadAll(resp.Body)
  5611. if ioErr != nil {
  5612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5614. return
  5615. }
  5616. var respJSON map[string]interface{}
  5617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5620. return
  5621. }
  5622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5623. result, _ := json.Marshal(respJSON)
  5624. fmt.Println("log")
  5625. fmt.Println(string(result))
  5626. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5627. utils.ErrorLog("解析失败:%v", err)
  5628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5629. return
  5630. }
  5631. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5632. res.Output = resSeven10265.Output
  5633. res.ErrMsg = resSeven10265.ErrMsg
  5634. res.Cainfo = resSeven10265.Cainfo
  5635. res.WarnMsg = resSeven10265.WarnMsg
  5636. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5637. res.Infcode = infocode
  5638. } else {
  5639. var src_resquest string
  5640. if miConfig.Code == "H15049901371" {
  5641. //赤峰地区国家医保医疗类别
  5642. //职工透析:医疗类别选特殊情况门诊990502
  5643. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5644. var med_type string
  5645. if his.Insutype == "390" {
  5646. if reg_type == 14 {
  5647. med_type = "9933"
  5648. } else if reg_type == 11 {
  5649. med_type = "11"
  5650. }
  5651. } else if his.Insutype == "310" {
  5652. if reg_type == 14 {
  5653. med_type = "990502"
  5654. } else if reg_type == 11 {
  5655. med_type = "11"
  5656. }
  5657. }
  5658. 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)
  5659. } else {
  5660. 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)
  5661. }
  5662. var dat map[string]interface{}
  5663. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5664. fmt.Println(dat)
  5665. } else {
  5666. fmt.Println(err)
  5667. }
  5668. saveLog(result2, src_resquest, "2207", "结算")
  5669. userJSONBytes, _ := json.Marshal(dat)
  5670. if miConfig.Code == "H15049901371" {
  5671. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5672. utils.ErrorLog("解析失败:%v", err)
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5674. return
  5675. }
  5676. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5677. res.Output = resSeven10265.Output
  5678. res.ErrMsg = resSeven10265.ErrMsg
  5679. res.Cainfo = resSeven10265.Cainfo
  5680. res.WarnMsg = resSeven10265.WarnMsg
  5681. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5682. res.Infcode = infocode
  5683. } else {
  5684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5685. utils.ErrorLog("解析失败:%v", err)
  5686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5687. return
  5688. }
  5689. }
  5690. }
  5691. if res.Infcode != 0 {
  5692. errlog := &models.HisOrderError{
  5693. UserOrgId: adminUser.CurrentOrgId,
  5694. Ctime: time.Now().Unix(),
  5695. Mtime: time.Now().Unix(),
  5696. Number: chrg_bchno,
  5697. ErrMsg: res.ErrMsg,
  5698. Status: 1,
  5699. PatientId: id,
  5700. RecordTime: recordDateTime,
  5701. Stage: 6,
  5702. }
  5703. service.CreateErrMsgLog(errlog)
  5704. c.ServeSuccessJSON(map[string]interface{}{
  5705. "failed_code": -10,
  5706. "msg": res.ErrMsg,
  5707. })
  5708. return
  5709. } else {
  5710. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5711. order.OrderStatus = 2
  5712. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5713. order.SetlId = res.Output.Setlinfo.SetlID
  5714. order.PsnNo = res.Output.Setlinfo.PsnNo
  5715. order.PsnName = res.Output.Setlinfo.PsnName
  5716. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5717. order.Certno = res.Output.Setlinfo.Certno
  5718. order.Gend = res.Output.Setlinfo.Gend
  5719. order.Naty = res.Output.Setlinfo.Naty
  5720. order.Age = res.Output.Setlinfo.Age
  5721. order.Insutype = res.Output.Setlinfo.Insutype
  5722. order.PsnType = res.Output.Setlinfo.PsnType
  5723. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5724. order.SetlTime = res.Output.Setlinfo.SetlTime
  5725. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5726. //order.MedType = res.Output.Setlinfo.MedType
  5727. if reg_type == 1112 {
  5728. order.MedType = "1112"
  5729. }
  5730. if reg_type == 1111 {
  5731. order.MedType = "1111"
  5732. }
  5733. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5734. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5735. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5736. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5737. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5738. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5739. order.HifpPay = res.Output.Setlinfo.HifpPay
  5740. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5741. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5742. order.HifesPay = res.Output.Setlinfo.HifesPay
  5743. order.HifobPay = res.Output.Setlinfo.HifobPay
  5744. order.MafPay = res.Output.Setlinfo.MafPay
  5745. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5746. order.OthPay = res.Output.Setlinfo.OthPay
  5747. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5748. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5749. order.AcctPay = res.Output.Setlinfo.AcctPay
  5750. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5751. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5752. order.Balc = res.Output.Setlinfo.Balc
  5753. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5754. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5755. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5756. order.ClrWay = res.Output.Setlinfo.ClrWay
  5757. order.Creator = order.Creator
  5758. order.Modify = roles.AdminUserId
  5759. order.RequestLog = src_resquest
  5760. order.Diagnosis = diagnosis_id
  5761. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5762. detailStr := string(setlDetail)
  5763. order.SetlDetail = detailStr
  5764. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5765. err = service.UpDateOrder(order)
  5766. if err == nil {
  5767. c.ServeSuccessJSON(map[string]interface{}{
  5768. "msg": "结算成功",
  5769. })
  5770. } else {
  5771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5772. return
  5773. }
  5774. }
  5775. }
  5776. }
  5777. }
  5778. //func (c *HisApiController) GetPreUploadInfo() {
  5779. // id, _ := c.GetInt64("id")
  5780. // record_time := c.GetString("record_time")
  5781. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5782. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5783. //
  5784. // timeLayout := "2006-01-02"
  5785. // loc, _ := time.LoadLocation("Local")
  5786. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5787. // if err != nil {
  5788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5789. // return
  5790. // }
  5791. // recordDateTime := theTime.Unix()
  5792. // adminUser := c.GetAdminUserInfo()
  5793. //
  5794. // var prescriptions []*models.HisPrescription
  5795. //
  5796. // var start_time int64
  5797. // var end_time int64
  5798. //
  5799. // data := make(map[string]interface{})
  5800. // if settle_accounts_type == 1 { //日结
  5801. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5802. // data["pre"] = prescriptions
  5803. //
  5804. // } else { //月结
  5805. // start_time_str := c.GetString("start_time")
  5806. // end_time_str := c.GetString("end_time")
  5807. // timeLayout := "2006-01-02"
  5808. // loc, _ := time.LoadLocation("Local")
  5809. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5810. // if err != nil {
  5811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5812. // return
  5813. // }
  5814. // recordStartTime := theStartTime.Unix()
  5815. // start_time = recordStartTime
  5816. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5817. // if err != nil {
  5818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5819. // return
  5820. // }
  5821. // recordEndTime := theEndTime.Unix()
  5822. // end_time = recordEndTime
  5823. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5824. // data["pre"] = prescriptions
  5825. //
  5826. // }
  5827. //
  5828. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5829. //
  5830. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5831. // timestamp := time.Now().Unix()
  5832. // tempTime := time.Unix(timestamp, 0)
  5833. // timeFormat := tempTime.Format("20060102150405")
  5834. // chrgBchno := rand.Intn(100000) + 10000
  5835. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5836. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5837. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5838. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5839. // strconv.FormatInt(his.PatientId, 10)
  5840. // client := &http.Client{}
  5841. // data["psn_no"] = his.PsnNo
  5842. // data["mdtrt_id"] = his.Number
  5843. // data["chrg_bchno"] = chrg_bchno
  5844. // data["org_name"] = miConfig.OrgName
  5845. // data["doctor"] = roles.UserName
  5846. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5847. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5848. // data["fixmedins_code"] = miConfig.Code
  5849. // data["dept_code"] = department.Number
  5850. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5851. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5852. // data["secret_key"] = miConfig.SecretKey
  5853. // var ids []int64
  5854. //
  5855. // for _, item := range prescriptions {
  5856. // ids = append(ids, item.ID)
  5857. // }
  5858. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5859. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5860. // bytesData, _ := json.Marshal(data)
  5861. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5862. // resp, _ := client.Do(req)
  5863. // defer resp.Body.Close()
  5864. // body, ioErr := ioutil.ReadAll(resp.Body)
  5865. // if ioErr != nil {
  5866. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5868. // return
  5869. // }
  5870. // var respJSON map[string]interface{}
  5871. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5872. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5874. // return
  5875. // }
  5876. //
  5877. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5878. // userJSONBytes, _ := json.Marshal(respJSON)
  5879. // var res ResultFour
  5880. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5881. // utils.ErrorLog("解析失败:%v", err)
  5882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5883. // return
  5884. // }
  5885. //
  5886. // if res.Infcode == 0 {
  5887. // order := &models.HisOrder{
  5888. // UserOrgId: adminUser.CurrentOrgId,
  5889. // HisPatientId: his.ID,
  5890. // PatientId: his.PatientId,
  5891. // SettleAccountsDate: recordDateTime,
  5892. // Ctime: time.Now().Unix(),
  5893. // Mtime: time.Now().Unix(),
  5894. // Status: 1,
  5895. // Number: chrg_bchno,
  5896. // Infcode: res.Infcode,
  5897. // WarnMsg: res.WarnMsg,
  5898. // Cainfo: res.Cainfo,
  5899. // ErrMsg: res.ErrMsg,
  5900. // RespondTime: res.RefmsgTime,
  5901. // InfRefmsgid: res.InfRefmsgid,
  5902. // OrderStatus: 1,
  5903. // IsMedicineInsurance: 1,
  5904. // SettleType: settle_accounts_type,
  5905. // SettleStartTime: start_time,
  5906. // SettleEndTime: end_time,
  5907. // Creator: roles.ID,
  5908. // Modify: roles.ID,
  5909. // PType: 2,
  5910. // }
  5911. // err = service.CreateOrder(order)
  5912. // if err != nil {
  5913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5914. // return
  5915. // }
  5916. //
  5917. // for _, item := range res.Output.Result {
  5918. // temp := strings.Split(item.FeedetlSn, "-")
  5919. // var advice_id int64 = 0
  5920. // var project_id int64 = 0
  5921. // var types int64 = 0
  5922. //
  5923. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5924. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5925. //
  5926. // if temp[1] == "1" {
  5927. // advice_id = id
  5928. // project_id = 0
  5929. // } else if temp[1] == "2" {
  5930. // advice_id = 0
  5931. // project_id = id
  5932. // }
  5933. //
  5934. // info := &models.HisOrderInfo{
  5935. // OrderNumber: order.Number,
  5936. // FeedetlSn: item.FeedetlSn,
  5937. // UploadDate: time.Now().Unix(),
  5938. // AdviceId: advice_id,
  5939. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5940. // Cnt: item.Cnt,
  5941. // Pric: float64(item.Pric),
  5942. // PatientId: his.PatientId,
  5943. // PricUplmtAmt: item.PricUplmtAmt,
  5944. // SelfpayProp: item.SelfpayProp,
  5945. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5946. // OverlmtAmt: item.OverlmtAmt,
  5947. // PreselfpayAmt: item.PreselfpayAmt,
  5948. // BasMednFlag: item.BasMednFlag,
  5949. // MedChrgitmType: item.MedChrgitmType,
  5950. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5951. // Status: 1,
  5952. // Memo: item.Memo,
  5953. // Mtime: time.Now().Unix(),
  5954. // InscpScpAmt: item.InscpScpAmt,
  5955. // DrtReimFlag: item.DrtReimFlag,
  5956. // Ctime: time.Now().Unix(),
  5957. // ListSpItemFlag: item.ListSpItemFlag,
  5958. // ChldMedcFlag: item.ChldMedcFlag,
  5959. // LmtUsedFlag: item.LmtUsedFlag,
  5960. // ChrgitmLv: item.ChrgitmLv,
  5961. // UserOrgId: adminUser.CurrentOrgId,
  5962. // HisPatientId: his.ID,
  5963. // OrderId: order.ID,
  5964. // ProjectId: project_id,
  5965. // Type: types,
  5966. // }
  5967. // service.CreateOrderInfo(info)
  5968. //
  5969. // }
  5970. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5971. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5972. //
  5973. // var total float64
  5974. // for _, item := range prescriptions {
  5975. // if item.Type == 1 { //药品
  5976. // for _, subItem := range item.HisDoctorAdviceInfo {
  5977. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5978. // }
  5979. // }
  5980. // if item.Type == 2 { //项目
  5981. // for _, subItem := range item.HisPrescriptionProject {
  5982. // total = total + (subItem.Price * float64(subItem.Count))
  5983. // }
  5984. // }
  5985. // }
  5986. //
  5987. // for _, item := range prescriptions {
  5988. // for _, subItem := range item.HisAdditionalCharge {
  5989. // total = total + (subItem.Price * float64(subItem.Count))
  5990. // }
  5991. // }
  5992. //
  5993. // allTotal := fmt.Sprintf("%.2f", total)
  5994. // if res.Infcode == 0 {
  5995. // var rf []*ResultFive
  5996. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5997. // psn_no := his.PsnNo
  5998. // mdtrt_id := his.Number
  5999. // chrg_bchno := chrg_bchno
  6000. // cert_no := his.Certno
  6001. // insutype := rf[0].Insutype
  6002. //
  6003. // if his.IdCardType == 1 {
  6004. // cert_no = his.MedicalInsuranceNumber
  6005. //
  6006. // } else {
  6007. //
  6008. // cert_no = his.Certno
  6009. //
  6010. // }
  6011. //
  6012. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6013. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6014. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6015. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6016. // resp, requestErr := http.Get(api)
  6017. // if requestErr != nil {
  6018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6019. // return
  6020. // }
  6021. // defer resp.Body.Close()
  6022. // body, ioErr := ioutil.ReadAll(resp.Body)
  6023. // if ioErr != nil {
  6024. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6026. // return
  6027. // }
  6028. // var respJSON map[string]interface{}
  6029. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6030. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6032. // return
  6033. // }
  6034. // fmt.Println(respJSON)
  6035. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6036. // userJSONBytes, _ := json.Marshal(respJSON)
  6037. // var res ResultSeven
  6038. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6039. // utils.ErrorLog("解析失败:%v", err)
  6040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6041. // return
  6042. // }
  6043. // if res.Infcode != 0 {
  6044. // errlog := &models.HisOrderError{
  6045. // UserOrgId: adminUser.CurrentOrgId,
  6046. // Ctime: time.Now().Unix(),
  6047. // Mtime: time.Now().Unix(),
  6048. // Number: chrg_bchno,
  6049. // ErrMsg: res.ErrMsg,
  6050. // Status: 1,
  6051. // PatientId: id,
  6052. // RecordTime: recordDateTime,
  6053. // Stage: 7,
  6054. // }
  6055. // service.CreateErrMsgLog(errlog)
  6056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6057. // return
  6058. // } else {
  6059. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6060. // order.OrderStatus = 1
  6061. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6062. // order.SetlId = res.Output.Setlinfo.SetlID
  6063. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6064. // order.PsnName = res.Output.Setlinfo.PsnName
  6065. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6066. // order.Certno = res.Output.Setlinfo.Certno
  6067. // order.Gend = res.Output.Setlinfo.Gend
  6068. // order.Naty = res.Output.Setlinfo.Naty
  6069. // order.Age = res.Output.Setlinfo.Age
  6070. // order.Insutype = res.Output.Setlinfo.Insutype
  6071. // order.PsnType = res.Output.Setlinfo.PsnType
  6072. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6073. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6074. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6075. // order.MedType = res.Output.Setlinfo.MedType
  6076. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6077. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6078. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6079. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6080. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6081. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6082. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6083. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6084. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6085. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6086. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6087. // order.MafPay = res.Output.Setlinfo.MafPay
  6088. // order.OthPay = res.Output.Setlinfo.OthPay
  6089. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6090. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6091. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6092. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6093. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6094. // order.Balc = res.Output.Setlinfo.Balc
  6095. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6096. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6097. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6098. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6099. // order.Creator = order.Creator
  6100. // order.Modify = roles.ID
  6101. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6102. // detailStr := string(setlDetail)
  6103. // order.SetlDetail = detailStr
  6104. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6105. // err = service.UpDateOrder(order)
  6106. // if err == nil {
  6107. // c.ServeSuccessJSON(map[string]interface{}{
  6108. // "msg": "预结算成功",
  6109. // })
  6110. // } else {
  6111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6112. // return
  6113. // }
  6114. // }
  6115. // } else {
  6116. // adminUser := c.GetAdminUserInfo()
  6117. // errlog := &models.HisOrderError{
  6118. // UserOrgId: adminUser.CurrentOrgId,
  6119. // Ctime: time.Now().Unix(),
  6120. // Mtime: time.Now().Unix(),
  6121. // ErrMsg: res.ErrMsg,
  6122. // Status: 1,
  6123. // PatientId: id,
  6124. // RecordTime: recordDateTime,
  6125. // Stage: 4,
  6126. // }
  6127. // service.CreateErrMsgLog(errlog)
  6128. //
  6129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6130. // return
  6131. // }
  6132. // } else {
  6133. // adminUser := c.GetAdminUserInfo()
  6134. // errlog := &models.HisOrderError{
  6135. // UserOrgId: adminUser.CurrentOrgId,
  6136. // Ctime: time.Now().Unix(),
  6137. // Mtime: time.Now().Unix(),
  6138. // ErrMsg: res.ErrMsg,
  6139. // Status: 1,
  6140. // PatientId: id,
  6141. // RecordTime: recordDateTime,
  6142. // Stage: 4,
  6143. // }
  6144. // service.CreateErrMsgLog(errlog)
  6145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6146. // return
  6147. // }
  6148. //
  6149. // } else {
  6150. // var total float64
  6151. // for _, item := range prescriptions {
  6152. // if item.Type == 1 { //药品
  6153. // for _, subItem := range item.HisDoctorAdviceInfo {
  6154. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6155. // }
  6156. // }
  6157. // if item.Type == 2 { //项目
  6158. // for _, subItem := range item.HisPrescriptionProject {
  6159. // total = total + (subItem.Price * float64(subItem.Count))
  6160. // }
  6161. // }
  6162. //
  6163. // for _, subItem := range item.HisAdditionalCharge {
  6164. // total = total + (subItem.Price * float64(subItem.Count))
  6165. // }
  6166. // }
  6167. //
  6168. // allTotal := fmt.Sprintf("%.2f", total)
  6169. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6170. // order := &models.HisOrder{
  6171. // UserOrgId: adminUser.CurrentOrgId,
  6172. // HisPatientId: his.ID,
  6173. // PatientId: id,
  6174. // SettleAccountsDate: recordDateTime,
  6175. // Ctime: time.Now().Unix(),
  6176. // Mtime: time.Now().Unix(),
  6177. // Status: 1,
  6178. // OrderStatus: 2,
  6179. // Number: chrg_bchno,
  6180. // MedfeeSumamt: totals,
  6181. // }
  6182. // err = service.CreateOrder(order)
  6183. // if err != nil {
  6184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6185. // return
  6186. // }
  6187. //
  6188. // var customs []*Custom
  6189. // for _, item := range prescriptions {
  6190. //
  6191. // if item.Type == 1 { //药品
  6192. // for _, subItem := range item.HisDoctorAdviceInfo {
  6193. // cus := &Custom{
  6194. // AdviceId: subItem.ID,
  6195. // ProjectId: 0,
  6196. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6197. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6198. // FeedetlSn: subItem.FeedetlSn,
  6199. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6200. // MedListCodg: subItem.MedListCodg,
  6201. // Type: 1,
  6202. // }
  6203. // customs = append(customs, cus)
  6204. // }
  6205. // }
  6206. //
  6207. // if item.Type == 2 { //项目
  6208. // for _, subItem := range item.HisPrescriptionProject {
  6209. //
  6210. // cus := &Custom{
  6211. // AdviceId: 0,
  6212. // ProjectId: subItem.ID,
  6213. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6214. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6215. // FeedetlSn: subItem.FeedetlSn,
  6216. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6217. // MedListCodg: subItem.MedListCodg,
  6218. // Type: 2,
  6219. // }
  6220. //
  6221. // customs = append(customs, cus)
  6222. // }
  6223. // }
  6224. //
  6225. // for _, item := range item.HisAdditionalCharge {
  6226. // cus := &Custom{
  6227. // ItemId: item.ID,
  6228. // AdviceId: 0,
  6229. // ProjectId: 0,
  6230. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6231. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6232. // FeedetlSn: item.FeedetlSn,
  6233. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6234. // MedListCodg: item.XtHisAddtionConfig.Code,
  6235. // Type: 3,
  6236. // }
  6237. //
  6238. // customs = append(customs, cus)
  6239. // }
  6240. //
  6241. // }
  6242. //
  6243. // for _, item := range customs {
  6244. // var advice_id int64 = 0
  6245. // var project_id int64 = 0
  6246. // var item_id int64 = 0
  6247. //
  6248. // var types int64 = 0
  6249. //
  6250. // if item.Type == 1 {
  6251. // advice_id = item.AdviceId
  6252. // project_id = 0
  6253. // item_id = 0
  6254. // } else if item.Type == 2 {
  6255. // advice_id = 0
  6256. // item_id = 0
  6257. //
  6258. // project_id = item.ProjectId
  6259. // } else if item.Type == 3 {
  6260. // advice_id = 0
  6261. // item_id = item.ItemId
  6262. // project_id = 0
  6263. // }
  6264. //
  6265. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6266. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6267. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6268. //
  6269. // info := &models.HisOrderInfo{
  6270. // OrderNumber: order.Number,
  6271. // UploadDate: time.Now().Unix(),
  6272. // AdviceId: advice_id,
  6273. // DetItemFeeSumamt: detItemFeeSumamt,
  6274. // Cnt: cut,
  6275. // Pric: pric,
  6276. // PatientId: id,
  6277. // Status: 1,
  6278. // Mtime: time.Now().Unix(),
  6279. // Ctime: time.Now().Unix(),
  6280. // UserOrgId: adminUser.CurrentOrgId,
  6281. // HisPatientId: his.ID,
  6282. // OrderId: order.ID,
  6283. // ProjectId: project_id,
  6284. // Type: types,
  6285. // ItemId: item_id,
  6286. // }
  6287. // service.CreateOrderInfo(info)
  6288. // }
  6289. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6290. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6291. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6292. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6293. // if err == nil {
  6294. // c.ServeSuccessJSON(map[string]interface{}{
  6295. // "msg": "结算成功",
  6296. // })
  6297. // } else {
  6298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6299. // return
  6300. // }
  6301. // }
  6302. //}
  6303. //上传明细-预结算-
  6304. func (c *HisApiController) GetPreUploadInfo() {
  6305. id, _ := c.GetInt64("id")
  6306. record_time := c.GetString("record_time")
  6307. his_patient_id, _ := c.GetInt64("his_patient_id")
  6308. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6309. admin_user_id, _ := c.GetInt64("admin_user_id")
  6310. diagnosis_id := c.GetString("diagnosis")
  6311. sick_type, _ := c.GetInt64("sick_type")
  6312. reg_type, _ := c.GetInt64("p_type")
  6313. begin_time := c.GetString("begin_time")
  6314. id_str := c.GetString("ids")
  6315. ids_arr := strings.Split(id_str, ",")
  6316. timeLayout := "2006-01-02"
  6317. loc, _ := time.LoadLocation("Local")
  6318. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6319. if err != nil {
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6321. return
  6322. }
  6323. recordDateTime := theTime.Unix()
  6324. adminUser := c.GetAdminUserInfo()
  6325. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6326. var config []*models.HisXtDiagnoseConfig
  6327. for _, item := range diagnosis_ids {
  6328. id, _ := strconv.ParseInt(item, 10, 64)
  6329. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6330. config = append(config, &diagnosisConfig)
  6331. }
  6332. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6333. sickConfig, _ := service.FindSickById(sick_type)
  6334. var prescriptions []*models.HisPrescription
  6335. var start_time int64
  6336. var end_time int64
  6337. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6338. fmt.Println(his_patient_id)
  6339. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6340. timestamp := time.Now().Unix()
  6341. tempTime := time.Unix(timestamp, 0)
  6342. timeFormat := tempTime.Format("20060102150405")
  6343. chrgBchno := rand.Intn(100000) + 10000
  6344. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6346. var patientPrescription models.HisPrescriptionInfo
  6347. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6348. if patientPrescription.ID == 0 {
  6349. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6350. }
  6351. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6352. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6353. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6354. strconv.FormatInt(his.PatientId, 10)
  6355. var res2 ResultSix
  6356. var resSix10265 ResultSix10265
  6357. var time_stamp string
  6358. if miConfig.MdtrtareaAdmvs == "421300" {
  6359. data := make(map[string]interface{})
  6360. client := &http.Client{}
  6361. data["psn_no"] = his.PsnNo
  6362. data["mdtrt_id"] = his.Number
  6363. data["doctor"] = roles.UserName
  6364. data["department"] = department.Name
  6365. data["org_name"] = miConfig.OrgName
  6366. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6367. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6368. data["fixmedins_code"] = miConfig.Code
  6369. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6370. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6371. data["secret_key"] = miConfig.SecretKey
  6372. data["sick_code"] = sickConfig.CountryCode
  6373. data["sick_name"] = sickConfig.ClassName
  6374. data["begin_time"] = begin_time
  6375. data["dept"] = strconv.FormatInt(department.ID, 10)
  6376. data["config"] = config
  6377. fmt.Println(data)
  6378. bytesData, _ := json.Marshal(data)
  6379. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6380. resp, _ := client.Do(req)
  6381. defer resp.Body.Close()
  6382. body, ioErr := ioutil.ReadAll(resp.Body)
  6383. if ioErr != nil {
  6384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6386. return
  6387. }
  6388. var respJSON map[string]interface{}
  6389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6392. return
  6393. }
  6394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6395. userJSONBytes, _ := json.Marshal(respJSON)
  6396. fmt.Println("log")
  6397. fmt.Println(string(userJSONBytes))
  6398. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6399. utils.ErrorLog("解析失败:%v", err)
  6400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6401. return
  6402. }
  6403. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6404. //江苏地区国家医保医疗类别
  6405. //职工透析:医疗类别选特殊情况门诊9933
  6406. //居民血透门慢: 医疗类别选门诊慢病1402
  6407. //var med_type string
  6408. //if his.Insutype == "310" {
  6409. // if reg_type == 14 {
  6410. // med_type = "9933"
  6411. // } else if reg_type == 11 {
  6412. // med_type = "11"
  6413. //
  6414. // }
  6415. //} else if his.Insutype == "390" {
  6416. // if reg_type == 14 {
  6417. // med_type = "1402"
  6418. // } else if reg_type == 11 {
  6419. // med_type = "11"
  6420. // }
  6421. //}
  6422. data := make(map[string]interface{})
  6423. client := &http.Client{}
  6424. data["psn_no"] = his.PsnNo
  6425. data["mdtrt_id"] = his.Number
  6426. data["doctor"] = roles.UserName
  6427. data["department"] = department.Name
  6428. data["org_name"] = miConfig.OrgName
  6429. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6430. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6431. data["fixmedins_code"] = miConfig.Code
  6432. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6433. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6434. data["secret_key"] = miConfig.SecretKey
  6435. data["sick_code"] = sickConfig.CountryCode
  6436. data["sick_name"] = sickConfig.ClassName
  6437. data["begin_time"] = begin_time
  6438. data["dept"] = strconv.FormatInt(department.ID, 10)
  6439. data["config"] = config
  6440. data["url"] = miConfig.Url
  6441. data["ak"] = miConfig.AccessKey
  6442. data["cainfo"] = miConfig.Cainfo
  6443. bytesData, _ := json.Marshal(data)
  6444. var req *http.Request
  6445. if miConfig.MdtrtareaAdmvs == "320921" {
  6446. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6447. //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 +
  6448. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6449. } else {
  6450. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6451. }
  6452. resp, _ := client.Do(req)
  6453. defer resp.Body.Close()
  6454. body, ioErr := ioutil.ReadAll(resp.Body)
  6455. if ioErr != nil {
  6456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. return
  6459. }
  6460. var respJSON map[string]interface{}
  6461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6464. return
  6465. }
  6466. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6467. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6468. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6469. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6470. userJSONBytes, _ := json.Marshal(respJSON)
  6471. fmt.Println("log")
  6472. fmt.Println(string(userJSONBytes))
  6473. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6474. utils.ErrorLog("解析失败:%v", err)
  6475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6476. return
  6477. }
  6478. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6479. res2.Output = resSix10265.Output
  6480. res2.ErrMsg = resSix10265.ErrMsg
  6481. res2.Cainfo = resSix10265.Cainfo
  6482. res2.WarnMsg = resSix10265.WarnMsg
  6483. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6484. res2.Infcode = infocode
  6485. } else {
  6486. var result string
  6487. var requestLog string
  6488. if miConfig.MdtrtareaAdmvs == "440781" { //
  6489. 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)
  6490. } else {
  6491. if miConfig.Code == "H15049901371" {
  6492. //赤峰地区国家医保医疗类别
  6493. //职工透析:医疗类别选特殊情况门诊990502
  6494. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6495. var med_type string
  6496. if his.Insutype == "390" {
  6497. if reg_type == 14 {
  6498. med_type = "9933"
  6499. } else if reg_type == 11 {
  6500. med_type = "11"
  6501. }
  6502. } else if his.Insutype == "310" {
  6503. if reg_type == 14 {
  6504. med_type = "990502"
  6505. } else if reg_type == 11 {
  6506. med_type = "11"
  6507. }
  6508. }
  6509. 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)
  6510. } else {
  6511. 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)
  6512. }
  6513. saveLog(result, requestLog, "2203", "上传就诊信息")
  6514. var respJSON2 map[string]interface{}
  6515. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6518. return
  6519. }
  6520. userJSONBytes2, _ := json.Marshal(respJSON2)
  6521. if miConfig.Code == "H15049901371" {
  6522. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6523. utils.ErrorLog("解析失败:%v", err)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. return
  6526. }
  6527. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6528. res2.Output = resSix10265.Output
  6529. res2.ErrMsg = resSix10265.ErrMsg
  6530. res2.Cainfo = resSix10265.Cainfo
  6531. res2.WarnMsg = resSix10265.WarnMsg
  6532. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6533. res2.Infcode = infocode
  6534. } else {
  6535. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6536. utils.ErrorLog("解析失败:%v", err)
  6537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6538. return
  6539. }
  6540. }
  6541. }
  6542. }
  6543. if res2.Infcode != 0 {
  6544. adminUser := c.GetAdminUserInfo()
  6545. errlog := &models.HisOrderError{
  6546. UserOrgId: adminUser.CurrentOrgId,
  6547. Ctime: time.Now().Unix(),
  6548. Mtime: time.Now().Unix(),
  6549. ErrMsg: res2.ErrMsg,
  6550. Status: 1,
  6551. PatientId: id,
  6552. RecordTime: recordDateTime,
  6553. Stage: 3,
  6554. }
  6555. service.CreateErrMsgLog(errlog)
  6556. c.ServeSuccessJSON(map[string]interface{}{
  6557. "failed_code": -10,
  6558. "msg": res2.ErrMsg,
  6559. })
  6560. return
  6561. } else {
  6562. his.Diagnosis = diagnosis_id
  6563. his.SickType = sickConfig.ID
  6564. his.PType = fmt.Sprintf("%d", reg_type)
  6565. service.UpdateHisPatientThree(&his)
  6566. data := make(map[string]interface{})
  6567. if settle_accounts_type == 1 { //日结
  6568. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6569. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6570. } else {
  6571. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6572. }
  6573. data["pre"] = prescriptions
  6574. } else { //月结
  6575. start_time_str := c.GetString("start_time")
  6576. end_time_str := c.GetString("end_time")
  6577. timeLayout := "2006-01-02"
  6578. loc, _ := time.LoadLocation("Local")
  6579. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6580. if err != nil {
  6581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6582. return
  6583. }
  6584. recordStartTime := theStartTime.Unix()
  6585. start_time = recordStartTime
  6586. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6587. if err != nil {
  6588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6589. return
  6590. }
  6591. recordEndTime := theEndTime.Unix()
  6592. end_time = recordEndTime
  6593. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6594. data["pre"] = prescriptions
  6595. }
  6596. client := &http.Client{}
  6597. data["psn_no"] = his.PsnNo
  6598. data["mdtrt_id"] = his.Number
  6599. data["chrg_bchno"] = chrg_bchno
  6600. data["org_name"] = miConfig.OrgName
  6601. data["doctor"] = roles.UserName
  6602. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6603. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6604. data["fixmedins_code"] = miConfig.Code
  6605. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6606. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6607. data["dept_code"] = "15"
  6608. } else {
  6609. data["dept_code"] = department.Number
  6610. }
  6611. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6612. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6613. data["secret_key"] = miConfig.SecretKey
  6614. data["url"] = miConfig.Url
  6615. data["ak"] = miConfig.AccessKey
  6616. data["new_doctor_name"] = patientPrescription.Doctor
  6617. data["diag_code"] = sickConfig.CountryCode
  6618. data["time_stamp"] = time_stamp
  6619. data["cainfo"] = miConfig.Cainfo
  6620. var ids []int64
  6621. for _, item := range prescriptions {
  6622. ids = append(ids, item.ID)
  6623. }
  6624. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6625. if config.IsOpen == 1 { //对接了医保,走医保流程
  6626. var res ResultFour
  6627. var resFour10265 ResultFour10265
  6628. if miConfig.MdtrtareaAdmvs == "421300" {
  6629. bytesData, _ := json.Marshal(data)
  6630. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6631. resp, _ := client.Do(req)
  6632. defer resp.Body.Close()
  6633. body, ioErr := ioutil.ReadAll(resp.Body)
  6634. if ioErr != nil {
  6635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. return
  6638. }
  6639. var respJSON map[string]interface{}
  6640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6643. return
  6644. }
  6645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6646. userJSONBytes, _ := json.Marshal(respJSON)
  6647. fmt.Println("log")
  6648. fmt.Println(string(userJSONBytes))
  6649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6650. utils.ErrorLog("解析失败:%v", err)
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6652. return
  6653. }
  6654. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6655. bytesData, _ := json.Marshal(data)
  6656. var req *http.Request
  6657. if miConfig.MdtrtareaAdmvs == "320921" {
  6658. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6659. } else {
  6660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6661. }
  6662. resp, _ := client.Do(req)
  6663. defer resp.Body.Close()
  6664. body, ioErr := ioutil.ReadAll(resp.Body)
  6665. if ioErr != nil {
  6666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6668. return
  6669. }
  6670. var respJSON map[string]interface{}
  6671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6674. return
  6675. }
  6676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6677. userJSONBytes, _ := json.Marshal(respJSON)
  6678. fmt.Println("log")
  6679. fmt.Println(string(userJSONBytes))
  6680. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6681. utils.ErrorLog("解析失败:%v", err)
  6682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6683. return
  6684. }
  6685. res.InfRefmsgid = resFour10265.InfRefmsgid
  6686. res.Output = resFour10265.Output
  6687. res.ErrMsg = resFour10265.ErrMsg
  6688. res.Cainfo = resFour10265.Cainfo
  6689. res.WarnMsg = resFour10265.WarnMsg
  6690. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6691. res.Infcode = infocode
  6692. } else {
  6693. if miConfig.Code == "H15049901371" {
  6694. 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)
  6695. var dat map[string]interface{}
  6696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6697. fmt.Println(dat)
  6698. } else {
  6699. fmt.Println(err)
  6700. }
  6701. saveLog(result, request_log, "2204", "上传费用明细")
  6702. userJSONBytes, _ := json.Marshal(dat)
  6703. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6704. utils.ErrorLog("解析失败:%v", err)
  6705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6706. return
  6707. }
  6708. res.InfRefmsgid = resFour10265.InfRefmsgid
  6709. res.Output = resFour10265.Output
  6710. res.ErrMsg = resFour10265.ErrMsg
  6711. res.Cainfo = resFour10265.Cainfo
  6712. res.WarnMsg = resFour10265.WarnMsg
  6713. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6714. res.Infcode = infocode
  6715. } else {
  6716. 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)
  6717. var dat map[string]interface{}
  6718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6719. fmt.Println(dat)
  6720. } else {
  6721. fmt.Println(err)
  6722. }
  6723. saveLog(result, request_log, "2204", "上传费用明细")
  6724. userJSONBytes, _ := json.Marshal(dat)
  6725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6726. utils.ErrorLog("解析失败:%v", err)
  6727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6728. return
  6729. }
  6730. }
  6731. }
  6732. if res.Infcode == 0 {
  6733. order := &models.HisOrder{
  6734. UserOrgId: adminUser.CurrentOrgId,
  6735. HisPatientId: his.ID,
  6736. PatientId: his.PatientId,
  6737. SettleAccountsDate: recordDateTime,
  6738. Ctime: time.Now().Unix(),
  6739. Mtime: time.Now().Unix(),
  6740. MdtrtId: his.Number,
  6741. PsnNo: his.PsnNo,
  6742. MedType: strconv.FormatInt(reg_type, 10),
  6743. Status: 1,
  6744. Number: chrg_bchno,
  6745. Infcode: res.Infcode,
  6746. WarnMsg: res.WarnMsg,
  6747. Cainfo: res.Cainfo,
  6748. ErrMsg: res.ErrMsg,
  6749. RespondTime: res.RefmsgTime,
  6750. InfRefmsgid: res.InfRefmsgid,
  6751. OrderStatus: 1,
  6752. IsMedicineInsurance: 1,
  6753. SettleType: settle_accounts_type,
  6754. SettleStartTime: start_time,
  6755. SettleEndTime: end_time,
  6756. Creator: roles.AdminUserId,
  6757. Modify: roles.AdminUserId,
  6758. PType: 2,
  6759. Diagnosis: diagnosis_id,
  6760. }
  6761. err = service.CreateOrder(order)
  6762. if err != nil {
  6763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6764. return
  6765. }
  6766. for _, item := range res.Output.Result {
  6767. temp := strings.Split(item.FeedetlSn, "-")
  6768. var advice_id int64 = 0
  6769. var project_id int64 = 0
  6770. var types int64 = 0
  6771. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6772. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6773. if temp[1] == "1" {
  6774. advice_id = id
  6775. project_id = 0
  6776. } else if temp[1] == "2" {
  6777. advice_id = 0
  6778. project_id = id
  6779. }
  6780. info := &models.HisOrderInfo{
  6781. OrderNumber: order.Number,
  6782. FeedetlSn: item.FeedetlSn,
  6783. UploadDate: time.Now().Unix(),
  6784. AdviceId: advice_id,
  6785. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6786. Cnt: item.Cnt,
  6787. Pric: float64(item.Pric),
  6788. PatientId: his.PatientId,
  6789. PricUplmtAmt: item.PricUplmtAmt,
  6790. SelfpayProp: item.SelfpayProp,
  6791. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6792. OverlmtAmt: item.OverlmtAmt,
  6793. PreselfpayAmt: item.PreselfpayAmt,
  6794. BasMednFlag: item.BasMednFlag,
  6795. MedChrgitmType: item.MedChrgitmType,
  6796. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6797. Status: 1,
  6798. Memo: item.Memo,
  6799. Mtime: time.Now().Unix(),
  6800. InscpScpAmt: item.InscpScpAmt,
  6801. DrtReimFlag: item.DrtReimFlag,
  6802. Ctime: time.Now().Unix(),
  6803. ListSpItemFlag: item.ListSpItemFlag,
  6804. ChldMedcFlag: item.ChldMedcFlag,
  6805. LmtUsedFlag: item.LmtUsedFlag,
  6806. ChrgitmLv: item.ChrgitmLv,
  6807. UserOrgId: adminUser.CurrentOrgId,
  6808. HisPatientId: his.ID,
  6809. OrderId: order.ID,
  6810. ProjectId: project_id,
  6811. Type: types,
  6812. }
  6813. service.CreateOrderInfo(info)
  6814. }
  6815. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6816. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6817. var total float64
  6818. for _, item := range prescriptions {
  6819. if item.Type == 1 { //药品
  6820. for _, subItem := range item.HisDoctorAdviceInfo {
  6821. total = total + (subItem.Price * subItem.PrescribingNumber)
  6822. }
  6823. }
  6824. if item.Type == 2 { //项目
  6825. for _, subItem := range item.HisPrescriptionProject {
  6826. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6827. total = total + (subItem.Price * cnt)
  6828. }
  6829. }
  6830. }
  6831. for _, item := range prescriptions {
  6832. for _, subItem := range item.HisAdditionalCharge {
  6833. total = total + (subItem.Price * float64(subItem.Count))
  6834. }
  6835. }
  6836. allTotal := fmt.Sprintf("%.4f", total)
  6837. if res.Infcode == 0 {
  6838. var rf []*ResultFive
  6839. json.Unmarshal([]byte(his.Iinfo), &rf)
  6840. chrg_bchno := chrg_bchno
  6841. cert_no := his.Certno
  6842. var insutypes []string
  6843. var insutype string
  6844. var is390 int = 0
  6845. var is310 int = 0
  6846. for _, item := range rf {
  6847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6848. insutypes = append(insutypes, item.Insutype)
  6849. }
  6850. }
  6851. if len(insutypes) == 1 {
  6852. insutype = insutypes[0]
  6853. } else {
  6854. for _, i := range insutypes {
  6855. if i == "390" {
  6856. is390 = 1
  6857. }
  6858. if i == "310" {
  6859. is310 = 1
  6860. }
  6861. }
  6862. }
  6863. if is390 == 1 {
  6864. insutype = "390"
  6865. }
  6866. if is310 == 1 {
  6867. insutype = "310"
  6868. }
  6869. if len(insutypes) == 0 {
  6870. insutype = "310"
  6871. }
  6872. if len(insutypes) == 2 {
  6873. insutype = strconv.FormatInt(his.SocialType, 64)
  6874. }
  6875. //insutype = "390"
  6876. if his.IdCardType == 1 {
  6877. cert_no = his.MedicalInsuranceNumber
  6878. } else {
  6879. cert_no = his.Certno
  6880. }
  6881. var res ResultSeven
  6882. var resSeven10265 ResultSeven10265
  6883. if miConfig.MdtrtareaAdmvs == "421300" {
  6884. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6885. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6886. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6887. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6888. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6889. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6890. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6891. resp, requestErr := http.Get(api)
  6892. if requestErr != nil {
  6893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6894. return
  6895. }
  6896. body, ioErr := ioutil.ReadAll(resp.Body)
  6897. if ioErr != nil {
  6898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6900. return
  6901. }
  6902. var respJSON map[string]interface{}
  6903. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6906. return
  6907. }
  6908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6909. result, _ := json.Marshal(respJSON)
  6910. fmt.Println("log")
  6911. fmt.Println(string(result))
  6912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6913. utils.ErrorLog("解析失败:%v", err)
  6914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6915. return
  6916. }
  6917. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6918. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6919. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6920. bas := strings.Split(psn_info.CardInfo, "|")
  6921. if his.IdCardType == 1 {
  6922. cert_no = bas[2]
  6923. } else {
  6924. cert_no = bas[1]
  6925. }
  6926. //江苏地区国家医保医疗类别
  6927. //职工透析:医疗类别选特殊情况门诊9933
  6928. //居民血透门慢: 医疗类别选门诊慢病1402
  6929. //var med_type string
  6930. //if his.Insutype == "310" {
  6931. // if reg_type == 14 {
  6932. // med_type = "9933"
  6933. // } else if reg_type == 11 {
  6934. // med_type = "11"
  6935. //
  6936. // }
  6937. //} else if his.Insutype == "390" {
  6938. // if reg_type == 14 {
  6939. // med_type = "1402"
  6940. // } else if reg_type == 11 {
  6941. // med_type = "11"
  6942. // }
  6943. //}
  6944. var api string
  6945. if miConfig.MdtrtareaAdmvs == "320921" {
  6946. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6947. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6948. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6950. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6951. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6952. "&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
  6953. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6954. } else {
  6955. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6956. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6957. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6958. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6960. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6961. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6962. "&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
  6963. }
  6964. resp, requestErr := http.Get(api)
  6965. if requestErr != nil {
  6966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6967. return
  6968. }
  6969. body, ioErr := ioutil.ReadAll(resp.Body)
  6970. if ioErr != nil {
  6971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6973. return
  6974. }
  6975. var respJSON map[string]interface{}
  6976. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. return
  6980. }
  6981. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6982. result, _ := json.Marshal(respJSON)
  6983. fmt.Println("log")
  6984. fmt.Println(string(result))
  6985. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6986. utils.ErrorLog("解析失败:%v", err)
  6987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6988. return
  6989. }
  6990. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6991. res.Output = resSeven10265.Output
  6992. res.ErrMsg = resSeven10265.ErrMsg
  6993. res.Cainfo = resSeven10265.Cainfo
  6994. res.WarnMsg = resSeven10265.WarnMsg
  6995. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6996. res.Infcode = infocode
  6997. } else {
  6998. var result string
  6999. var request_log string
  7000. if miConfig.Code == "H15049901371" {
  7001. //赤峰地区国家医保医疗类别
  7002. //职工透析:医疗类别选特殊情况门诊990502
  7003. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7004. var med_type string
  7005. if his.Insutype == "390" {
  7006. if reg_type == 14 {
  7007. med_type = "9933"
  7008. } else if reg_type == 11 {
  7009. med_type = "11"
  7010. }
  7011. } else if his.Insutype == "310" {
  7012. if reg_type == 14 {
  7013. med_type = "990502"
  7014. } else if reg_type == 11 {
  7015. med_type = "11"
  7016. }
  7017. }
  7018. 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)
  7019. } else {
  7020. 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)
  7021. }
  7022. var dat map[string]interface{}
  7023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7024. fmt.Println(dat)
  7025. } else {
  7026. fmt.Println(err)
  7027. }
  7028. saveLog(result, request_log, "2206", "预结算")
  7029. //userJSONBytes, _ := json.Marshal(dat)
  7030. //
  7031. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7032. // utils.ErrorLog("解析失败:%v", err)
  7033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7034. // return
  7035. //}
  7036. userJSONBytes, _ := json.Marshal(dat)
  7037. if miConfig.Code == "H15049901371" {
  7038. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7039. utils.ErrorLog("解析失败:%v", err)
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7044. res.Output = resSeven10265.Output
  7045. res.ErrMsg = resSeven10265.ErrMsg
  7046. res.Cainfo = resSeven10265.Cainfo
  7047. res.WarnMsg = resSeven10265.WarnMsg
  7048. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7049. res.Infcode = infocode
  7050. } else {
  7051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7052. utils.ErrorLog("解析失败:%v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. }
  7057. }
  7058. if res.Infcode != 0 {
  7059. errlog := &models.HisOrderError{
  7060. UserOrgId: adminUser.CurrentOrgId,
  7061. Ctime: time.Now().Unix(),
  7062. Mtime: time.Now().Unix(),
  7063. Number: chrg_bchno,
  7064. ErrMsg: res.ErrMsg,
  7065. Status: 1,
  7066. PatientId: id,
  7067. RecordTime: recordDateTime,
  7068. Stage: 20,
  7069. }
  7070. service.CreateErrMsgLog(errlog)
  7071. c.ServeSuccessJSON(map[string]interface{}{
  7072. "failed_code": -10,
  7073. "msg": res.ErrMsg,
  7074. })
  7075. return
  7076. } else {
  7077. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7078. order.OrderStatus = 1
  7079. order.IsPre = 1
  7080. order.Status = 1
  7081. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7082. order.SetlId = res.Output.Setlinfo.SetlID
  7083. order.PsnNo = res.Output.Setlinfo.PsnNo
  7084. order.PsnName = res.Output.Setlinfo.PsnName
  7085. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7086. order.Certno = res.Output.Setlinfo.Certno
  7087. order.Gend = res.Output.Setlinfo.Gend
  7088. order.Naty = res.Output.Setlinfo.Naty
  7089. order.Age = res.Output.Setlinfo.Age
  7090. order.Insutype = res.Output.Setlinfo.Insutype
  7091. order.PsnType = res.Output.Setlinfo.PsnType
  7092. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7093. order.SetlTime = res.Output.Setlinfo.SetlTime
  7094. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7095. if res.Output.Setlinfo.MedType == "140101" {
  7096. order.MedType = "14"
  7097. } else {
  7098. order.MedType = res.Output.Setlinfo.MedType
  7099. }
  7100. if reg_type == 1112 {
  7101. order.MedType = "1112"
  7102. }
  7103. if reg_type == 1111 {
  7104. order.MedType = "1111"
  7105. }
  7106. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7107. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7108. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7109. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7110. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7111. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7112. order.HifpPay = res.Output.Setlinfo.HifpPay
  7113. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7114. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7115. order.HifesPay = res.Output.Setlinfo.HifesPay
  7116. order.HifobPay = res.Output.Setlinfo.HifobPay
  7117. order.MafPay = res.Output.Setlinfo.MafPay
  7118. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7119. order.OthPay = res.Output.Setlinfo.OthPay
  7120. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7121. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7122. order.AcctPay = res.Output.Setlinfo.AcctPay
  7123. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7124. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7125. order.Balc = res.Output.Setlinfo.Balc
  7126. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7127. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7128. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7129. order.ClrWay = res.Output.Setlinfo.ClrWay
  7130. order.Creator = order.Creator
  7131. order.Modify = roles.AdminUserId
  7132. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7133. detailStr := string(setlDetail)
  7134. order.SetlDetail = detailStr
  7135. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7136. err = service.UpDateOrder(order)
  7137. if err == nil {
  7138. c.ServeSuccessJSON(map[string]interface{}{
  7139. "msg": "预结算成功",
  7140. })
  7141. } else {
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7143. return
  7144. }
  7145. }
  7146. } else {
  7147. adminUser := c.GetAdminUserInfo()
  7148. errlog := &models.HisOrderError{
  7149. UserOrgId: adminUser.CurrentOrgId,
  7150. Ctime: time.Now().Unix(),
  7151. Mtime: time.Now().Unix(),
  7152. ErrMsg: res.ErrMsg,
  7153. Status: 1,
  7154. PatientId: id,
  7155. RecordTime: recordDateTime,
  7156. Stage: 4,
  7157. }
  7158. service.CreateErrMsgLog(errlog)
  7159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7160. return
  7161. }
  7162. } else {
  7163. adminUser := c.GetAdminUserInfo()
  7164. errlog := &models.HisOrderError{
  7165. UserOrgId: adminUser.CurrentOrgId,
  7166. Ctime: time.Now().Unix(),
  7167. Mtime: time.Now().Unix(),
  7168. ErrMsg: res.ErrMsg,
  7169. Status: 1,
  7170. PatientId: id,
  7171. RecordTime: recordDateTime,
  7172. Stage: 4,
  7173. }
  7174. service.CreateErrMsgLog(errlog)
  7175. c.ServeSuccessJSON(map[string]interface{}{
  7176. "failed_code": -10,
  7177. "msg": res.ErrMsg,
  7178. })
  7179. return
  7180. }
  7181. }
  7182. }
  7183. }
  7184. //func (c *HisApiController) GetSettleInfo() {
  7185. // id, _ := c.GetInt64("id")
  7186. // order_id, _ := c.GetInt64("order_id")
  7187. //
  7188. // record_time := c.GetString("record_time")
  7189. // pay_way, _ := c.GetInt64("pay_way")
  7190. // pay_price, _ := c.GetFloat("pay_price")
  7191. // pay_card_no := c.GetString("pay_card_no")
  7192. // discount_price, _ := c.GetFloat("discount_price")
  7193. // preferential_price, _ := c.GetFloat("preferential_price")
  7194. // reality_price, _ := c.GetFloat("reality_price")
  7195. // found_price, _ := c.GetFloat("found_price")
  7196. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7197. // private_price, _ := c.GetFloat("private_price")
  7198. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7199. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7200. //
  7201. // timeLayout := "2006-01-02"
  7202. // loc, _ := time.LoadLocation("Local")
  7203. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7204. // if err != nil {
  7205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7206. // return
  7207. // }
  7208. // recordDateTime := theTime.Unix()
  7209. // adminUser := c.GetAdminUserInfo()
  7210. //
  7211. // var prescriptions []*models.HisPrescription
  7212. //
  7213. // data := make(map[string]interface{})
  7214. // if settle_accounts_type == 1 { //日结
  7215. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7216. // data["pre"] = prescriptions
  7217. //
  7218. // } else { //月结
  7219. // start_time_str := c.GetString("start_time")
  7220. // end_time_str := c.GetString("end_time")
  7221. // timeLayout := "2006-01-02"
  7222. // loc, _ := time.LoadLocation("Local")
  7223. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7224. // if err != nil {
  7225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7226. // return
  7227. // }
  7228. // recordStartTime := theStartTime.Unix()
  7229. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7230. // if err != nil {
  7231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7232. // return
  7233. // }
  7234. // recordEndTime := theEndTime.Unix()
  7235. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7236. // data["pre"] = prescriptions
  7237. //
  7238. // }
  7239. //
  7240. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7241. //
  7242. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7243. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7244. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7245. // strconv.FormatInt(his.PatientId, 10)
  7246. //
  7247. // order_src, _ := service.GetHisOrderByID(order_id)
  7248. //
  7249. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7250. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7251. //
  7252. // var total float64
  7253. // for _, item := range prescriptions {
  7254. // if item.Type == 1 { //药品
  7255. // for _, subItem := range item.HisDoctorAdviceInfo {
  7256. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7257. // }
  7258. // }
  7259. // if item.Type == 2 { //项目
  7260. // for _, subItem := range item.HisPrescriptionProject {
  7261. // total = total + (subItem.Price * float64(subItem.Count))
  7262. // }
  7263. // }
  7264. // }
  7265. //
  7266. // for _, item := range prescriptions {
  7267. // for _, subItem := range item.HisAdditionalCharge {
  7268. // total = total + (subItem.Price * float64(subItem.Count))
  7269. // }
  7270. // }
  7271. //
  7272. // allTotal := fmt.Sprintf("%.2f", total)
  7273. // var rf []*ResultFive
  7274. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7275. // psn_no := order_src.PsnNo
  7276. // mdtrt_id := order_src.MdtrtId
  7277. // chrg_bchno := order_src.Number
  7278. // cert_no := order_src.Certno
  7279. // insutype := rf[0].Insutype
  7280. //
  7281. // if his.IdCardType == 1 {
  7282. // cert_no = his.MedicalInsuranceNumber
  7283. // } else {
  7284. // cert_no = his.Certno
  7285. // }
  7286. //
  7287. // 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)
  7288. // var dat map[string]interface{}
  7289. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7290. // fmt.Println(dat)
  7291. // } else {
  7292. // fmt.Println(err)
  7293. // }
  7294. //
  7295. // userJSONBytes, _ := json.Marshal(dat)
  7296. //
  7297. //
  7298. //
  7299. // var res ResultSeven
  7300. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7301. // utils.ErrorLog("解析失败:%v", err)
  7302. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7303. // return
  7304. // }
  7305. // if res.Infcode == -1 {
  7306. // errlog := &models.HisOrderError{
  7307. // UserOrgId: adminUser.CurrentOrgId,
  7308. // Ctime: time.Now().Unix(),
  7309. // Mtime: time.Now().Unix(),
  7310. // Number: chrg_bchno,
  7311. // ErrMsg: res.ErrMsg,
  7312. // Status: 1,
  7313. // PatientId: id,
  7314. // RecordTime: recordDateTime,
  7315. // Stage: 6,
  7316. // }
  7317. // service.CreateErrMsgLog(errlog)
  7318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7319. // return
  7320. // } else {
  7321. // order_src.OrderStatus = 2
  7322. // order_src.PayWay = pay_way
  7323. // order_src.PayPrice = pay_price
  7324. // order_src.PayCardNo = pay_card_no
  7325. // order_src.DiscountPrice = discount_price
  7326. // order_src.PreferentialPrice = preferential_price
  7327. // order_src.RealityPrice = reality_price
  7328. // order_src.FoundPrice = found_price
  7329. // order_src.MedicalInsurancePrice = medical_insurance_price
  7330. // order_src.PrivatePrice = private_price
  7331. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7332. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7333. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7334. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7335. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7336. // order_src.Certno = res.Output.Setlinfo.Certno
  7337. // order_src.Gend = res.Output.Setlinfo.Gend
  7338. // order_src.Naty = res.Output.Setlinfo.Naty
  7339. // order_src.Age = res.Output.Setlinfo.Age
  7340. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7341. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7342. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7343. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7344. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7345. // order_src.MedType = res.Output.Setlinfo.MedType
  7346. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7347. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7348. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7349. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7350. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7351. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7352. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7353. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7354. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7355. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7356. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7357. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7358. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7359. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7360. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7361. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7362. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7363. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7364. // order_src.Balc = res.Output.Setlinfo.Balc
  7365. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7366. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7367. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7368. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7369. // order_src.Creator = order_src.Creator
  7370. // order_src.Modify = roles.ID
  7371. // order_src.RequestLog = src_resquest
  7372. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7373. // detailStr := string(setlDetail)
  7374. // order_src.SetlDetail = detailStr
  7375. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7376. // err = service.UpDateOrder(order_src)
  7377. //
  7378. // if err == nil {
  7379. // c.ServeSuccessJSON(map[string]interface{}{
  7380. // "msg": "结算成功",
  7381. // })
  7382. // } else {
  7383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7384. // return
  7385. // }
  7386. // }
  7387. // }
  7388. //}
  7389. //退款
  7390. func (c *HisApiController) Refund() {
  7391. order_id, _ := c.GetInt64("order_id")
  7392. admin_user_id, _ := c.GetInt64("admin_user_id")
  7393. adminUser := c.GetAdminUserInfo()
  7394. var order models.HisOrder
  7395. order, _ = service.GetHisOrderByID(order_id)
  7396. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7397. if order.ID == 0 {
  7398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7399. return
  7400. }
  7401. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7403. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7404. if config.IsOpen == 1 { //对接了医保,走医保流程
  7405. var res ResultSixteen
  7406. var resSixteen10265 ResultSixteen10265
  7407. var src_resquest string
  7408. var result string
  7409. if miConfig.MdtrtareaAdmvs == "421300" {
  7410. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7411. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7413. resp3, requestErr3 := http.Get(api3)
  7414. if requestErr3 != nil {
  7415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7416. return
  7417. }
  7418. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7419. if ioErr3 != nil {
  7420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7422. return
  7423. }
  7424. var respJSON3 map[string]interface{}
  7425. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7428. return
  7429. }
  7430. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7431. userJSONBytes3, _ := json.Marshal(respJSON3)
  7432. fmt.Println("log")
  7433. fmt.Println(string(userJSONBytes3))
  7434. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7435. utils.ErrorLog("解析失败:%v", err)
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7437. return
  7438. }
  7439. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7440. var api3 string
  7441. if miConfig.MdtrtareaAdmvs == "320921" {
  7442. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7443. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7444. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7445. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7446. } else {
  7447. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7448. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7449. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7450. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7451. }
  7452. resp3, requestErr3 := http.Get(api3)
  7453. if requestErr3 != nil {
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7458. if ioErr3 != nil {
  7459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. var respJSON3 map[string]interface{}
  7464. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7470. userJSONBytes3, _ := json.Marshal(respJSON3)
  7471. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7472. utils.ErrorLog("解析失败:%v", err)
  7473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7474. return
  7475. }
  7476. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7477. res.Output = resSixteen10265.Output
  7478. res.ErrMsg = resSixteen10265.ErrMsg
  7479. res.Cainfo = resSixteen10265.Cainfo
  7480. res.WarnMsg = resSixteen10265.WarnMsg
  7481. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7482. res.Infcode = infocode
  7483. } else {
  7484. if miConfig.Code == "H15049901371" {
  7485. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7486. var dat map[string]interface{}
  7487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7488. fmt.Println(dat)
  7489. } else {
  7490. fmt.Println(err)
  7491. }
  7492. saveLog(result, src_resquest, "2208", "退费")
  7493. userJSONBytes, _ := json.Marshal(dat)
  7494. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7495. utils.ErrorLog("解析失败:%v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7500. res.Output = resSixteen10265.Output
  7501. res.ErrMsg = resSixteen10265.ErrMsg
  7502. res.Cainfo = resSixteen10265.Cainfo
  7503. res.WarnMsg = resSixteen10265.WarnMsg
  7504. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7505. res.Infcode = infocode
  7506. } else {
  7507. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7508. var dat map[string]interface{}
  7509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7510. fmt.Println(dat)
  7511. } else {
  7512. fmt.Println(err)
  7513. }
  7514. saveLog(result, src_resquest, "2208", "退费")
  7515. userJSONBytes, _ := json.Marshal(dat)
  7516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7517. utils.ErrorLog("解析失败:%v", err)
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. return
  7520. }
  7521. }
  7522. }
  7523. if res.Infcode == 0 {
  7524. var res2 ResultSix
  7525. var resSix10265 ResultSix10265
  7526. if miConfig.MdtrtareaAdmvs == "421300" {
  7527. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7528. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7529. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7530. resp3, requestErr3 := http.Get(api3)
  7531. if requestErr3 != nil {
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. return
  7534. }
  7535. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7536. if ioErr3 != nil {
  7537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7539. return
  7540. }
  7541. var respJSON3 map[string]interface{}
  7542. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. return
  7546. }
  7547. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7548. userJSONBytes3, _ := json.Marshal(respJSON3)
  7549. fmt.Println("log")
  7550. fmt.Println(string(userJSONBytes3))
  7551. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7552. utils.ErrorLog("解析失败:%v", err)
  7553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7554. return
  7555. }
  7556. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7557. var api3 string
  7558. if miConfig.MdtrtareaAdmvs == "320921" {
  7559. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7560. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7562. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7563. } else {
  7564. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7565. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7566. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7568. }
  7569. resp3, requestErr3 := http.Get(api3)
  7570. if requestErr3 != nil {
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return
  7573. }
  7574. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7575. if ioErr3 != nil {
  7576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. return
  7579. }
  7580. var respJSON3 map[string]interface{}
  7581. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. return
  7585. }
  7586. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7587. userJSONBytes3, _ := json.Marshal(respJSON3)
  7588. fmt.Println("log")
  7589. fmt.Println(string(userJSONBytes3))
  7590. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7591. utils.ErrorLog("解析失败:%v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7596. res2.Output = resSix10265.Output
  7597. res2.ErrMsg = resSix10265.ErrMsg
  7598. res2.Cainfo = resSix10265.Cainfo
  7599. res2.WarnMsg = resSix10265.WarnMsg
  7600. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7601. res2.Infcode = infocode
  7602. } else {
  7603. if miConfig.Code == "H15049901371" {
  7604. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7605. var dat map[string]interface{}
  7606. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7607. fmt.Println(dat)
  7608. } else {
  7609. fmt.Println(err)
  7610. }
  7611. saveLog(result2, src_request, "2205", "撤销明细")
  7612. userJSONBytes, _ := json.Marshal(dat)
  7613. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7614. utils.ErrorLog("解析失败:%v", err)
  7615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7616. return
  7617. }
  7618. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7619. res2.Output = resSix10265.Output
  7620. res2.ErrMsg = resSix10265.ErrMsg
  7621. res2.Cainfo = resSix10265.Cainfo
  7622. res2.WarnMsg = resSix10265.WarnMsg
  7623. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7624. res2.Infcode = infocode
  7625. } else {
  7626. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7627. var dat map[string]interface{}
  7628. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7629. fmt.Println(dat)
  7630. } else {
  7631. fmt.Println(err)
  7632. }
  7633. saveLog(result2, src_request, "2205", "撤销明细")
  7634. userJSONBytes, _ := json.Marshal(dat)
  7635. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7636. utils.ErrorLog("解析失败:%v", err)
  7637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7638. return
  7639. }
  7640. }
  7641. }
  7642. if res2.Infcode == 0 {
  7643. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7644. if err == nil {
  7645. c.ServeSuccessJSON(map[string]interface{}{
  7646. "msg": "退费成功",
  7647. })
  7648. } else {
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. return
  7651. }
  7652. } else {
  7653. c.ServeSuccessJSON(map[string]interface{}{
  7654. "code": -10,
  7655. "msg": res2.ErrMsg,
  7656. })
  7657. }
  7658. } else {
  7659. c.ServeSuccessJSON(map[string]interface{}{
  7660. "code": -10,
  7661. "msg": res.ErrMsg,
  7662. })
  7663. }
  7664. }
  7665. }
  7666. func (c *HisApiController) RefundNumber() {
  7667. record_time := c.GetString("record_time")
  7668. //patient_id, _ := c.GetInt64("patient_id")
  7669. admin_user_id, _ := c.GetInt64("admin_user_id")
  7670. his_patient_id, _ := c.GetInt64("id")
  7671. timeLayout := "2006-01-02"
  7672. loc, _ := time.LoadLocation("Local")
  7673. adminUser := c.GetAdminUserInfo()
  7674. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7675. fmt.Println(err)
  7676. if err != nil {
  7677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7678. return
  7679. }
  7680. recordDateTime := theTime.Unix()
  7681. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7682. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7683. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7684. //order, _ := service.GetHisOrderByID(order_id)
  7685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7686. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7687. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7688. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7689. if count > 0 {
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7691. return
  7692. }
  7693. if config.IsOpen == 1 { //对接了医保,走医保流程
  7694. var res2 ResultSix
  7695. var resSix10265 ResultSix10265
  7696. if miConfig.MdtrtareaAdmvs == "421300" {
  7697. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7698. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7699. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7700. resp3, requestErr3 := http.Get(api3)
  7701. if requestErr3 != nil {
  7702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7703. return
  7704. }
  7705. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7706. if ioErr3 != nil {
  7707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7709. return
  7710. }
  7711. var respJSON3 map[string]interface{}
  7712. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7715. return
  7716. }
  7717. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7718. userJSONBytes3, _ := json.Marshal(respJSON3)
  7719. fmt.Println("log")
  7720. fmt.Println(string(userJSONBytes3))
  7721. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7722. utils.ErrorLog("解析失败:%v", err)
  7723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7724. return
  7725. }
  7726. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7727. var api3 string
  7728. if miConfig.MdtrtareaAdmvs == "320921" {
  7729. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7730. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7731. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7732. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7733. } else {
  7734. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7735. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7736. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7737. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7738. }
  7739. resp3, requestErr3 := http.Get(api3)
  7740. if requestErr3 != nil {
  7741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7742. return
  7743. }
  7744. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7745. if ioErr3 != nil {
  7746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7748. return
  7749. }
  7750. var respJSON3 map[string]interface{}
  7751. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7754. return
  7755. }
  7756. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7757. userJSONBytes3, _ := json.Marshal(respJSON3)
  7758. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7759. utils.ErrorLog("解析失败:%v", err)
  7760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7761. return
  7762. }
  7763. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7764. res2.Output = resSix10265.Output
  7765. res2.ErrMsg = resSix10265.ErrMsg
  7766. res2.Cainfo = resSix10265.Cainfo
  7767. res2.WarnMsg = resSix10265.WarnMsg
  7768. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7769. res2.Infcode = infocode
  7770. } else {
  7771. var api3 string
  7772. if miConfig.Code == "H15049901371" {
  7773. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7774. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7775. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7776. } else {
  7777. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7778. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7780. }
  7781. resp3, requestErr3 := http.Get(api3)
  7782. if requestErr3 != nil {
  7783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. return
  7785. }
  7786. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7787. if ioErr3 != nil {
  7788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7790. return
  7791. }
  7792. var respJSON3 map[string]interface{}
  7793. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. return
  7797. }
  7798. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7799. userJSONBytes3, _ := json.Marshal(respJSON3)
  7800. if miConfig.Code == "H15049901371" {
  7801. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7802. utils.ErrorLog("解析失败:%v", err)
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. return
  7805. }
  7806. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7807. res2.Output = resSix10265.Output
  7808. res2.ErrMsg = resSix10265.ErrMsg
  7809. res2.Cainfo = resSix10265.Cainfo
  7810. res2.WarnMsg = resSix10265.WarnMsg
  7811. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7812. res2.Infcode = infocode
  7813. } else {
  7814. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7815. utils.ErrorLog("解析失败:%v", err)
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. }
  7820. }
  7821. if res2.Infcode == 0 {
  7822. if err == nil {
  7823. c.ServeSuccessJSON(map[string]interface{}{
  7824. "msg": "退号成功",
  7825. })
  7826. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7827. } else {
  7828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7829. return
  7830. }
  7831. } else {
  7832. c.ServeSuccessJSON(map[string]interface{}{
  7833. "code": -10,
  7834. "msg": res2.ErrMsg,
  7835. })
  7836. }
  7837. } else {
  7838. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7839. //if err == nil {
  7840. // c.ServeSuccessJSON(map[string]interface{}{
  7841. // "msg": "退费成功",
  7842. // })
  7843. //} else {
  7844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7845. // return
  7846. //}
  7847. }
  7848. }
  7849. func (c *HisApiController) RefundDetail() {
  7850. order_id, _ := c.GetInt64("order_id")
  7851. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7852. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7853. number := c.GetString("number")
  7854. record_time := c.GetString("record_time")
  7855. patient_id, _ := c.GetInt64("patient_id")
  7856. //med_type, _ := c.GetInt64("med_type")
  7857. timeLayout := "2006-01-02"
  7858. loc, _ := time.LoadLocation("Local")
  7859. adminUser := c.GetAdminUserInfo()
  7860. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7861. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7862. fmt.Println(err)
  7863. if err != nil {
  7864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7865. return
  7866. }
  7867. recordDateTime := theTime.Unix()
  7868. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7869. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7871. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7872. var order models.HisOrder
  7873. order, _ = service.GetHisOrderByID(order_id)
  7874. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7875. if config.IsOpen == 1 { //对接了医保,走医保流程
  7876. var res2 ResultSix
  7877. if miConfig.MdtrtareaAdmvs == "421300" {
  7878. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7879. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7880. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7881. resp3, requestErr3 := http.Get(api3)
  7882. if requestErr3 != nil {
  7883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7884. return
  7885. }
  7886. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7887. if ioErr3 != nil {
  7888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. return
  7891. }
  7892. var respJSON3 map[string]interface{}
  7893. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7899. userJSONBytes3, _ := json.Marshal(respJSON3)
  7900. fmt.Println("log")
  7901. fmt.Println(string(userJSONBytes3))
  7902. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7903. utils.ErrorLog("解析失败:%v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7908. if err == nil {
  7909. c.ServeSuccessJSON(map[string]interface{}{
  7910. "msg": "撤销明细成功",
  7911. })
  7912. return
  7913. } else {
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7918. var resSix10265 ResultSix10265
  7919. var api3 string
  7920. if miConfig.MdtrtareaAdmvs == "320921" {
  7921. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7922. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7923. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7924. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7925. } else {
  7926. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7927. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7928. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7929. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7930. }
  7931. resp3, requestErr3 := http.Get(api3)
  7932. if requestErr3 != nil {
  7933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7934. return
  7935. }
  7936. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7937. if ioErr3 != nil {
  7938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7940. return
  7941. }
  7942. var respJSON3 map[string]interface{}
  7943. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. return
  7947. }
  7948. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7949. userJSONBytes3, _ := json.Marshal(respJSON3)
  7950. fmt.Println("log")
  7951. fmt.Println(string(userJSONBytes3))
  7952. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7953. utils.ErrorLog("解析失败:%v", err)
  7954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7955. return
  7956. }
  7957. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7958. res2.Output = resSix10265.Output
  7959. res2.ErrMsg = resSix10265.ErrMsg
  7960. res2.Cainfo = resSix10265.Cainfo
  7961. res2.WarnMsg = resSix10265.WarnMsg
  7962. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7963. res2.Infcode = infocode
  7964. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7965. if err == nil {
  7966. c.ServeSuccessJSON(map[string]interface{}{
  7967. "msg": "撤销明细成功",
  7968. })
  7969. return
  7970. } else {
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. } else {
  7975. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7976. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7978. resp2, requestErr2 := http.Get(api2)
  7979. if requestErr2 != nil {
  7980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7981. return
  7982. }
  7983. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7984. if ioErr2 != nil {
  7985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. var respJSON2 map[string]interface{}
  7990. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7996. if err == nil {
  7997. c.ServeSuccessJSON(map[string]interface{}{
  7998. "msg": "撤销明细成功",
  7999. })
  8000. return
  8001. } else {
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. }
  8006. } else {
  8007. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8008. if err == nil {
  8009. c.ServeSuccessJSON(map[string]interface{}{
  8010. "msg": "退费成功",
  8011. })
  8012. } else {
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8014. return
  8015. }
  8016. }
  8017. }
  8018. //对账
  8019. func (c *HisApiController) GetCheckAccount() {
  8020. start_time := c.GetString("start_time")
  8021. end_time := c.GetString("end_time")
  8022. insutype := c.GetString("insutype")
  8023. clr_type := c.GetString("clr_type")
  8024. clr_org := c.GetString("clr_optins")
  8025. admin_user_id, _ := c.GetInt64("admin_user_id")
  8026. adminUser := c.GetAdminUserInfo()
  8027. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8028. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8029. if len(clr_org) == 0 {
  8030. clr_org = miConfig.MdtrtareaAdmvs
  8031. }
  8032. timeLayout := "2006-01-02"
  8033. loc, _ := time.LoadLocation("Local")
  8034. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8035. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8036. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  8037. fixmedins_setl_cnt := int64(len(orders))
  8038. var medfee_sumamt float64
  8039. var acct_pay float64
  8040. var fund_pay_sumamt float64
  8041. for _, item := range orders {
  8042. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8043. acct_pay = acct_pay + item.AcctPay
  8044. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8045. }
  8046. var user_name string
  8047. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8048. if role.ID == 0 {
  8049. user_name = "xxx"
  8050. } else {
  8051. user_name = role.UserName
  8052. }
  8053. var res ResultEight
  8054. var res10188 ResultEightFor10188
  8055. if config.IsOpen == 1 {
  8056. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8057. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8058. "insutype=" + insutype +
  8059. "&clr_type=" + "11" +
  8060. "&setl_optins=" + clr_org +
  8061. "&stmt_begndate=" + start_time +
  8062. "&stm_enddate=" + end_time +
  8063. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8064. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8065. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8066. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8067. "&fixmedins_code=" + miConfig.Code +
  8068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8069. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8070. "&secret_key=" + miConfig.SecretKey +
  8071. "&org_name=" + miConfig.OrgName +
  8072. "&doctor=" + user_name +
  8073. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8074. fmt.Println(api)
  8075. resp, requestErr := http.Get(api)
  8076. if requestErr != nil {
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. body, ioErr := ioutil.ReadAll(resp.Body)
  8081. fmt.Println(body)
  8082. if ioErr != nil {
  8083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8085. return
  8086. }
  8087. var respJSON map[string]interface{}
  8088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8091. return
  8092. }
  8093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8094. userJSONBytes, _ := json.Marshal(respJSON)
  8095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8096. utils.ErrorLog("解析失败:%v", err)
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. res.InfRefmsgid = res10188.InfRefmsgid
  8101. res.Output = res10188.Output
  8102. res.ErrMsg = res10188.ErrMsg
  8103. res.Cainfo = res10188.Cainfo
  8104. res.WarnMsg = res10188.WarnMsg
  8105. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8106. res.Infcode = infocode
  8107. } else {
  8108. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8109. "insutype=" + insutype +
  8110. "&clr_type=" + clr_type +
  8111. "&setl_optins=" + clr_org +
  8112. "&stmt_begndate=" + start_time +
  8113. "&stm_enddate=" + end_time +
  8114. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8115. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8116. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8117. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8118. "&fixmedins_code=" + miConfig.Code +
  8119. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8120. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8121. "&secret_key=" + miConfig.SecretKey +
  8122. "&org_name=" + miConfig.OrgName +
  8123. "&doctor=" + user_name
  8124. fmt.Println(api)
  8125. resp, requestErr := http.Get(api)
  8126. if requestErr != nil {
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8128. return
  8129. }
  8130. body, ioErr := ioutil.ReadAll(resp.Body)
  8131. fmt.Println(body)
  8132. if ioErr != nil {
  8133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. var respJSON map[string]interface{}
  8138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8144. userJSONBytes, _ := json.Marshal(respJSON)
  8145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8146. utils.ErrorLog("解析失败:%v", err)
  8147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8148. return
  8149. }
  8150. }
  8151. if res.Infcode == 0 {
  8152. if res.Output.Stmtinfo.StmtRslt == "0" {
  8153. micc := &models.MedicalInsuranceCostCompare{
  8154. StartTime: startime.Unix(),
  8155. EndTime: endtime.Unix(),
  8156. Insutype: insutype,
  8157. CheckType: 1,
  8158. Num: fixmedins_setl_cnt,
  8159. Mtime: time.Now().Unix(),
  8160. Status: 1,
  8161. UserOrgId: adminUser.CurrentOrgId,
  8162. CostTotal: medfee_sumamt,
  8163. FuncTotal: fund_pay_sumamt,
  8164. PsnPay: acct_pay,
  8165. Creator: admin_user_id,
  8166. Ctime: time.Now().Unix(),
  8167. ClrType: clr_type,
  8168. }
  8169. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8170. if err == nil {
  8171. c.ServeSuccessJSON(map[string]interface{}{
  8172. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8173. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8174. })
  8175. } else {
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. }
  8178. } else {
  8179. c.ServeSuccessJSON(map[string]interface{}{
  8180. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8181. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8182. })
  8183. }
  8184. } else {
  8185. c.ServeSuccessJSON(map[string]interface{}{
  8186. "code": -10,
  8187. "msg": res.ErrMsg,
  8188. })
  8189. }
  8190. }
  8191. }
  8192. func (c *HisApiController) Check310() {
  8193. adminUser := c.GetAdminUserInfo()
  8194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8195. var user_name string
  8196. user_name = "高慧裕"
  8197. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8198. "insutype=" + "310" +
  8199. "&clr_type=" + "" +
  8200. "&setl_optins=" + "441202" +
  8201. "&stmt_begndate=" + "2022-03-01" +
  8202. "&stm_enddate=" + "2022-03-31" +
  8203. "&medfee_sumamt=" + "194930.12" +
  8204. "&fund_pay_sumamt=" + "188741.46" +
  8205. "&acct_pay=" + "0" +
  8206. "&fixmedins_setl_cnt=" + "452" +
  8207. "&fixmedins_code=" + miConfig.Code +
  8208. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8209. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8210. "&secret_key=" + miConfig.SecretKey +
  8211. "&org_name=" + miConfig.OrgName +
  8212. "&doctor=" + user_name
  8213. fmt.Println(api)
  8214. resp, requestErr := http.Get(api)
  8215. if requestErr != nil {
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. body, ioErr := ioutil.ReadAll(resp.Body)
  8220. fmt.Println(body)
  8221. if ioErr != nil {
  8222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. return
  8225. }
  8226. var respJSON map[string]interface{}
  8227. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8230. return
  8231. }
  8232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8233. userJSONBytes, _ := json.Marshal(respJSON)
  8234. var res ResultEight
  8235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8236. utils.ErrorLog("解析失败:%v", err)
  8237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8238. return
  8239. }
  8240. }
  8241. func (c *HisApiController) Check390() {
  8242. adminUser := c.GetAdminUserInfo()
  8243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8244. var user_name string
  8245. user_name = "高慧裕"
  8246. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8247. "insutype=" + "390" +
  8248. "&clr_type=" + "" +
  8249. "&setl_optins=" + "441202" +
  8250. "&stmt_begndate=" + "2022-03-01" +
  8251. "&stm_enddate=" + "2022-03-31" +
  8252. "&medfee_sumamt=" + "1068448.89" +
  8253. "&fund_pay_sumamt=" + "1014677.62" +
  8254. "&acct_pay=" + "0" +
  8255. "&fixmedins_setl_cnt=" + "1950" +
  8256. "&fixmedins_code=" + miConfig.Code +
  8257. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8258. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8259. "&secret_key=" + miConfig.SecretKey +
  8260. "&org_name=" + miConfig.OrgName +
  8261. "&doctor=" + user_name
  8262. fmt.Println(api)
  8263. resp, requestErr := http.Get(api)
  8264. if requestErr != nil {
  8265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8266. return
  8267. }
  8268. body, ioErr := ioutil.ReadAll(resp.Body)
  8269. fmt.Println(body)
  8270. if ioErr != nil {
  8271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8273. return
  8274. }
  8275. var respJSON map[string]interface{}
  8276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. return
  8280. }
  8281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8282. userJSONBytes, _ := json.Marshal(respJSON)
  8283. var res ResultEight
  8284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8285. utils.ErrorLog("解析失败:%v", err)
  8286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8287. return
  8288. }
  8289. }
  8290. //对账明细
  8291. func (c *HisApiController) GetCheckDetailAccount() {
  8292. start_time := c.GetString("start_time")
  8293. end_time := c.GetString("end_time")
  8294. admin_user_id, _ := c.GetInt64("admin_user_id")
  8295. adminUser := c.GetAdminUserInfo()
  8296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8297. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8298. timeLayout := "2006-01-02"
  8299. loc, _ := time.LoadLocation("Local")
  8300. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8301. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8302. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8303. Mkdir(miConfig.OrgName)
  8304. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8305. file_name := file + ".txt"
  8306. zip_name := file + ".zip"
  8307. zip_path := miConfig.OrgName + "/" + zip_name
  8308. file_path := miConfig.OrgName + "/" + file_name
  8309. decimal.DivisionPrecision = 2
  8310. var medfee_sumamt float64
  8311. var psn_cash_pay float64
  8312. var fund_pay_sumamt float64
  8313. fixmedins_setl_cnt := int64(len(orders))
  8314. for _, item := range orders {
  8315. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8316. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8317. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8318. }
  8319. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8320. defer f.Close()
  8321. if err != nil {
  8322. fmt.Println(err.Error())
  8323. } else {
  8324. for _, item := range orders {
  8325. var refd_setl_flag string
  8326. if item.OrderStatus == 2 {
  8327. refd_setl_flag = "0"
  8328. var str string
  8329. str = item.SetlId + " " +
  8330. item.MdtrtId + " " +
  8331. item.PsnNo + " " +
  8332. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8333. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8334. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8335. _, err = f.Write([]byte(str))
  8336. }
  8337. if item.OrderStatus == 3 {
  8338. var str string
  8339. str = item.SetlId + " " +
  8340. item.MdtrtId + " " +
  8341. item.PsnNo + " " +
  8342. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8343. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8344. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8345. _, err = f.Write([]byte(str))
  8346. var str2 string
  8347. str2 = item.SetlId + " " +
  8348. item.MdtrtId + " " +
  8349. item.PsnNo + " " +
  8350. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8351. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8352. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8353. _, err = f.Write([]byte(str2))
  8354. }
  8355. }
  8356. }
  8357. Zip(file_path, zip_path)
  8358. fmt.Println(ReadFile(zip_path))
  8359. fmt.Println(string(ReadFile(zip_path)))
  8360. if config.IsOpen == 1 {
  8361. var user_name string
  8362. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8363. if role.ID == 0 {
  8364. user_name = "管理员"
  8365. } else {
  8366. user_name = role.UserName
  8367. }
  8368. baseParams := models.BaseParams{
  8369. SecretKey: miConfig.SecretKey,
  8370. FixmedinsCode: miConfig.Code,
  8371. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8372. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8373. OrgName: miConfig.OrgName,
  8374. Doctor: user_name,
  8375. }
  8376. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8377. var dat map[string]interface{}
  8378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8379. fmt.Println(dat)
  8380. } else {
  8381. fmt.Println(err)
  8382. }
  8383. userJSONBytes, _ := json.Marshal(dat)
  8384. var res ResultNine
  8385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8386. utils.ErrorLog("解析失败:%v", err)
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. return
  8389. }
  8390. if res.Infcode == 0 {
  8391. fileNo := res.Output.FileQuryNo
  8392. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8393. "file_qury_no=" + fileNo +
  8394. "&setl_optins=" + "定点医保中心" +
  8395. "&stmt_begndate=" + start_time +
  8396. "&stm_enddate=" + end_time +
  8397. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8398. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8399. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8400. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8401. "&fixmedins_code=" + miConfig.Code +
  8402. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8403. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8404. "&secret_key=" + miConfig.SecretKey +
  8405. "&org_name=" + miConfig.OrgName +
  8406. "&doctor=" + user_name
  8407. resp, requestErr := http.Get(api)
  8408. if requestErr != nil {
  8409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8410. return
  8411. }
  8412. body, ioErr := ioutil.ReadAll(resp.Body)
  8413. if ioErr != nil {
  8414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. var respJSON map[string]interface{}
  8419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8422. return
  8423. }
  8424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8425. userJSONBytes, _ := json.Marshal(respJSON)
  8426. var res ResultTen
  8427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8428. utils.ErrorLog("解析失败:%v", err)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. if res.Infcode == 0 {
  8433. service.Gdyb9102(baseParams, zip_name, fileNo)
  8434. micc := &models.MedicalInsuranceCostCompare{
  8435. StartTime: startime.Unix(),
  8436. EndTime: endtime.Unix(),
  8437. Insutype: "0",
  8438. CheckType: 2,
  8439. Num: fixmedins_setl_cnt,
  8440. Mtime: time.Now().Unix(),
  8441. Status: 1,
  8442. UserOrgId: adminUser.CurrentOrgId,
  8443. CostTotal: medfee_sumamt,
  8444. FuncTotal: fund_pay_sumamt,
  8445. PsnPay: psn_cash_pay,
  8446. Creator: admin_user_id,
  8447. Ctime: time.Now().Unix(),
  8448. }
  8449. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8450. c.ServeSuccessJSON(map[string]interface{}{
  8451. "msg": "明细对账成功",
  8452. })
  8453. }
  8454. } else {
  8455. }
  8456. }
  8457. }
  8458. type CustomOrderInfo struct {
  8459. Name string
  8460. Spec string
  8461. Unit string
  8462. Count float64
  8463. Price float64
  8464. Total float64
  8465. }
  8466. func (c *HisApiController) GetSettleAccounts() {
  8467. //id, _ := c.GetInt64("id")
  8468. //record_time := c.GetString("record_time")
  8469. order_id, _ := c.GetInt64("order_id")
  8470. admin_user_id, _ := c.GetInt64("admin_user_id")
  8471. //timeLayout := "2006-01-02"
  8472. //loc, _ := time.LoadLocation("Local")
  8473. //
  8474. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8475. //if err != nil {
  8476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8477. // return
  8478. //}
  8479. //recordDateTime := theTime.Unix()
  8480. adminUser := c.GetAdminUserInfo()
  8481. order, _ := service.GetHisOrderByID(order_id)
  8482. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8483. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8484. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8485. orderInfos = append(orderInfos, orderInfos_two...)
  8486. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8487. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8488. var diagnosis_ids []string
  8489. if his.ID > 0 {
  8490. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8491. } else {
  8492. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8493. }
  8494. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8495. var dia_config []*models.HisXtDiagnoseConfig
  8496. var name string
  8497. for _, item := range diagnosis_ids {
  8498. id, _ := strconv.ParseInt(item, 10, 64)
  8499. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8500. dia_config = append(dia_config, &diagnosisConfig)
  8501. if len(name) == 0 {
  8502. name = diagnosisConfig.ClassName
  8503. } else {
  8504. name = name + "," + diagnosisConfig.ClassName
  8505. }
  8506. }
  8507. var bedCostTotal float64 = 0 //床位总费
  8508. var bedCostSelfTotal float64 = 0 //床位自费
  8509. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8510. var operationCostTotal float64 = 0 //手术费
  8511. var operationCostSelfTotal float64 = 0 //手术费
  8512. var operationCostPartSelfTotal float64 = 0 //手术费
  8513. var otherCostTotal float64 = 0 //其他费用
  8514. var otherCostSelfTotal float64 = 0 //其他费用
  8515. var otherCostPartSelfTotal float64 = 0 //其他费用
  8516. var materialCostTotal float64 = 0 //材料费
  8517. var materialCostSelfTotal float64 = 0 //材料费
  8518. var materialCostPartSelfTotal float64 = 0 //材料费
  8519. var westernMedicineCostTotal float64 = 0 //西药费
  8520. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8521. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8522. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8523. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8524. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8525. var checkCostTotal float64 = 0 //检查费
  8526. var checkCostSelfTotal float64 = 0 //检查费
  8527. var checkCostPartSelfTotal float64 = 0 //检查费
  8528. var laboratoryCostTotal float64 = 0 //化验费
  8529. var laboratoryCostSelfTotal float64 = 0 //化验费
  8530. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8531. var treatCostTotal float64 = 0 //治疗费用
  8532. var treatCostSelfTotal float64 = 0 //治疗费用
  8533. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8534. decimal.DivisionPrecision = 2
  8535. for _, item := range orderInfos {
  8536. if item.MedChrgitmType == "01" { //床位费
  8537. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8538. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8539. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8540. }
  8541. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8542. if item.MedChrgitmType == "03" { //检查费
  8543. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8544. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8545. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8546. }
  8547. } else {
  8548. if item.MedChrgitmType == "03" { //检查费
  8549. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8550. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8551. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8552. }
  8553. }
  8554. if item.MedChrgitmType == "04" { //化验费
  8555. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8556. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8557. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8558. }
  8559. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8560. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8561. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8562. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8563. }
  8564. if item.MedChrgitmType == "06" { //手术费
  8565. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8566. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8567. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8568. }
  8569. if item.MedChrgitmType == "08" { //材料费
  8570. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8571. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8572. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8573. }
  8574. if item.MedChrgitmType == "09" { //西药费
  8575. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8576. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8577. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8578. }
  8579. if item.MedChrgitmType == "11" { //中成费
  8580. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8581. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8582. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8583. }
  8584. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8585. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8586. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8587. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8588. }
  8589. }
  8590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8591. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8592. var user_name string
  8593. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8594. if role.ID == 0 {
  8595. user_name = "管理员"
  8596. } else {
  8597. user_name = role.UserName
  8598. }
  8599. baseParams := models.BaseParams{
  8600. SecretKey: miConfig.SecretKey,
  8601. FixmedinsCode: miConfig.Code,
  8602. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8603. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8604. OrgName: miConfig.OrgName,
  8605. Doctor: user_name,
  8606. }
  8607. businessParams := models.BusinessParams{
  8608. PsnNo: order.PsnNo,
  8609. MdtrtId: order.MdtrtId,
  8610. SetlId: order.SetlId,
  8611. }
  8612. var res ResultEleven
  8613. var resEleven10265 ResultEleven10265
  8614. if config.IsOpen == 1 {
  8615. if miConfig.MdtrtareaAdmvs == "421300" {
  8616. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8617. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8619. resp, requestErr := http.Get(api)
  8620. if requestErr != nil {
  8621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8622. return
  8623. }
  8624. body, ioErr := ioutil.ReadAll(resp.Body)
  8625. if ioErr != nil {
  8626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. var respJSON map[string]interface{}
  8631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8634. return
  8635. }
  8636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8637. result, _ := json.Marshal(respJSON)
  8638. fmt.Println("log")
  8639. fmt.Println(string(result))
  8640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8641. utils.ErrorLog("解析失败:%v", err)
  8642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8643. return
  8644. }
  8645. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8646. var api string
  8647. if miConfig.MdtrtareaAdmvs == "320921" {
  8648. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8649. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8650. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8651. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8652. } else {
  8653. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8654. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8655. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8656. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8657. }
  8658. resp, requestErr := http.Get(api)
  8659. if requestErr != nil {
  8660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8661. return
  8662. }
  8663. body, ioErr := ioutil.ReadAll(resp.Body)
  8664. if ioErr != nil {
  8665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. var respJSON map[string]interface{}
  8670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8673. return
  8674. }
  8675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8676. result, _ := json.Marshal(respJSON)
  8677. fmt.Println("log")
  8678. fmt.Println(string(result))
  8679. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8680. utils.ErrorLog("解析失败:%v", err)
  8681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8682. return
  8683. }
  8684. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8685. res.Output = resEleven10265.Output
  8686. res.ErrMsg = resEleven10265.ErrMsg
  8687. res.Cainfo = resEleven10265.Cainfo
  8688. res.WarnMsg = resEleven10265.WarnMsg
  8689. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8690. res.Infcode = infocode
  8691. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8692. fmt.Println("~~~~~~~")
  8693. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8694. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8695. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8696. resp, requestErr := http.Get(api)
  8697. if requestErr != nil {
  8698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8699. return
  8700. }
  8701. body, ioErr := ioutil.ReadAll(resp.Body)
  8702. if ioErr != nil {
  8703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8705. return
  8706. }
  8707. var respJSON map[string]interface{}
  8708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8714. result, _ := json.Marshal(respJSON)
  8715. fmt.Println("log")
  8716. fmt.Println(string(result))
  8717. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8718. utils.ErrorLog("解析失败:%v", err)
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8723. res.Output = resEleven10265.Output
  8724. res.ErrMsg = resEleven10265.ErrMsg
  8725. res.Cainfo = resEleven10265.Cainfo
  8726. res.WarnMsg = resEleven10265.WarnMsg
  8727. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8728. res.Infcode = infocode
  8729. } else {
  8730. result := service.Gdyb5203(baseParams, businessParams)
  8731. var dat map[string]interface{}
  8732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8733. fmt.Println(dat)
  8734. } else {
  8735. fmt.Println(err)
  8736. }
  8737. userJSONBytes, _ := json.Marshal(dat)
  8738. if miConfig.Code == "H15049901371" {
  8739. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8740. utils.ErrorLog("解析失败:%v", err)
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8745. res.Output = resEleven10265.Output
  8746. res.ErrMsg = resEleven10265.ErrMsg
  8747. res.Cainfo = resEleven10265.Cainfo
  8748. res.WarnMsg = resEleven10265.WarnMsg
  8749. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8750. res.Infcode = infocode
  8751. } else {
  8752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8753. utils.ErrorLog("解析失败:%v", err)
  8754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. return
  8756. }
  8757. }
  8758. }
  8759. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8760. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8761. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8762. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8763. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8764. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8765. var doctor_name string
  8766. if roles.ID == 0 {
  8767. doctor_name = "管理员"
  8768. } else {
  8769. doctor_name = roles.UserName
  8770. }
  8771. yiliao_leibie := ""
  8772. switch order.MedType {
  8773. case "11":
  8774. yiliao_leibie = "普通门诊"
  8775. break
  8776. case "12":
  8777. yiliao_leibie = "门诊挂号"
  8778. break
  8779. case "13":
  8780. yiliao_leibie = "急诊"
  8781. break
  8782. case "14":
  8783. yiliao_leibie = "门诊特殊病"
  8784. break
  8785. case "15":
  8786. yiliao_leibie = "门诊统筹"
  8787. break
  8788. case "16":
  8789. yiliao_leibie = "门诊慢性病"
  8790. break
  8791. case "21":
  8792. yiliao_leibie = "普通住院"
  8793. break
  8794. }
  8795. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8796. if res.Infcode == 0 {
  8797. c.ServeSuccessJSON(map[string]interface{}{
  8798. "diagnosis": name,
  8799. "order_infos": orderInfos,
  8800. "number": order.MdtrtId,
  8801. "date": order.SettleAccountsDate,
  8802. "charge_admin": charge_admin,
  8803. "printor_admin": printor_admin,
  8804. "info": res.Output.Setlinfo,
  8805. "order": order,
  8806. "bedCostTotal": bedCostTotal,
  8807. "bedCostSelfTotal": bedCostSelfTotal,
  8808. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8809. "operationCostTotal": operationCostTotal,
  8810. "operationCostSelfTotal": operationCostSelfTotal,
  8811. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8812. "otherCostTotal": otherCostTotal,
  8813. "otherCostSelfTotal": otherCostSelfTotal,
  8814. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8815. "materialCostTotal": materialCostTotal,
  8816. "materialCostSelfTotal": materialCostSelfTotal,
  8817. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8818. "westernMedicineCostTotal": westernMedicineCostTotal,
  8819. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8820. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8821. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8822. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8823. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8824. "checkCostTotal": checkCostTotal,
  8825. "checkCostSelfTotal": checkCostSelfTotal,
  8826. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8827. "laboratoryCostTotal": laboratoryCostTotal,
  8828. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8829. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8830. "treatCostTotal": treatCostTotal,
  8831. "treatCostSelfTotal": treatCostSelfTotal,
  8832. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8833. "doctor_info": doctor_info,
  8834. "doctor_code": adminRole_two.DoctorCode,
  8835. "doctor_name": doctor_name,
  8836. "health_card_no": order.PsnNo,
  8837. "department": departments.Name,
  8838. "yiliao_leibie": yiliao_leibie,
  8839. "after_money": order.AccountPrice,
  8840. "patient": patient,
  8841. "org_name": miConfig.OrgName,
  8842. "org_code": miConfig.Code,
  8843. "order_number": order.Number,
  8844. "his_hospital": his_hospital,
  8845. "his": his,
  8846. "dia_config": dia_config,
  8847. //"check_order_info": cus_slice,
  8848. })
  8849. }
  8850. }
  8851. }
  8852. func (c *HisApiController) CheckTreatment() {
  8853. patient_id, _ := c.GetInt64("patient_id")
  8854. id_card_no := c.GetString("id_card_no")
  8855. insutype := c.GetString("insutype")
  8856. med_type := c.GetString("med_type")
  8857. admin_user_id, _ := c.GetInt64("admin_user_id")
  8858. adminUser := c.GetAdminUserInfo()
  8859. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8860. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8861. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8862. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8863. if miConfig.MdtrtareaAdmvs == "421300" {
  8864. var res ResultTwo
  8865. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8866. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8867. "&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)
  8868. resp, requestErr := http.Get(api)
  8869. if requestErr != nil {
  8870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. return
  8872. }
  8873. body, ioErr := ioutil.ReadAll(resp.Body)
  8874. if ioErr != nil {
  8875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. var respJSON map[string]interface{}
  8880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8886. result, _ := json.Marshal(respJSON)
  8887. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8888. utils.ErrorLog("解析失败:%v", err)
  8889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8890. return
  8891. }
  8892. if res.Infcode == 0 {
  8893. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8894. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8895. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8896. resp, requestErr := http.Get(api)
  8897. if requestErr != nil {
  8898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8899. return
  8900. }
  8901. body, ioErr := ioutil.ReadAll(resp.Body)
  8902. if ioErr != nil {
  8903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8905. return
  8906. }
  8907. var respJSON map[string]interface{}
  8908. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8911. return
  8912. }
  8913. var res Result2001
  8914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8915. result2, _ := json.Marshal(respJSON)
  8916. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8917. utils.ErrorLog("解析失败:%v", err)
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. if res.Infcode == 0 {
  8922. c.ServeSuccessJSON(map[string]interface{}{
  8923. "msg": res.Output.Trtinfo,
  8924. })
  8925. }
  8926. } else {
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8928. return
  8929. }
  8930. } else {
  8931. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8932. var dat map[string]interface{}
  8933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8934. fmt.Println(dat)
  8935. } else {
  8936. fmt.Println(err)
  8937. }
  8938. userJSONBytes, _ := json.Marshal(dat)
  8939. var res ResultTwo
  8940. var res10265 ResultTwo10265
  8941. if miConfig.Code == "H15049901371" {
  8942. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8943. utils.ErrorLog("解析失败:%v", err)
  8944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8945. return
  8946. }
  8947. res.ErrMsg = res10265.ErrMsg
  8948. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8949. res.Infcode = infocode
  8950. res.Output = res10265.Output
  8951. res.InfRefmsgid = res10265.InfRefmsgid
  8952. } else {
  8953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8954. utils.ErrorLog("解析失败:%v", err)
  8955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8956. return
  8957. }
  8958. }
  8959. var user_name string
  8960. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8961. if role.ID == 0 {
  8962. user_name = "xxx"
  8963. } else {
  8964. user_name = role.UserName
  8965. }
  8966. baseParams := models.BaseParams{
  8967. SecretKey: miConfig.SecretKey,
  8968. FixmedinsCode: miConfig.Code,
  8969. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8970. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8971. OrgName: miConfig.OrgName,
  8972. Doctor: user_name,
  8973. }
  8974. if config.IsOpen == 1 {
  8975. if miConfig.Code == "H15049901371" {
  8976. if med_type == "14" {
  8977. if insutype == "390" {
  8978. med_type = "9933"
  8979. } else if insutype == "310" {
  8980. med_type = "990502"
  8981. }
  8982. } else if med_type == "11" {
  8983. med_type = "11"
  8984. }
  8985. }
  8986. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8987. var dat map[string]interface{}
  8988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8989. fmt.Println(dat)
  8990. } else {
  8991. fmt.Println(err)
  8992. }
  8993. var res Result2001
  8994. var res10265 Result2001Org10265
  8995. if miConfig.Code == "H15049901371" {
  8996. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8997. utils.ErrorLog("解析失败:%v", err)
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. res.ErrMsg = res10265.ErrMsg
  9002. res.Output = res10265.Output
  9003. res.InfRefmsgid = res10265.InfRefmsgid
  9004. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9005. res.Infcode = infocode
  9006. } else {
  9007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9008. utils.ErrorLog("解析失败:%v", err)
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. }
  9013. if res.Infcode == 0 {
  9014. c.ServeSuccessJSON(map[string]interface{}{
  9015. "msg": res.Output.Trtinfo,
  9016. })
  9017. }
  9018. }
  9019. }
  9020. }
  9021. //func (c *HisApiController) PutRecord() {
  9022. // id, _ := c.GetInt64("id")
  9023. // record_time := c.GetString("record_time")
  9024. // timeLayout := "2006-01-02"
  9025. // loc, _ := time.LoadLocation("Local")
  9026. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9027. // if err != nil {
  9028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9029. // return
  9030. // }
  9031. // recordDateTime := theTime.Unix()
  9032. //
  9033. // adminInfo := c.GetAdminUserInfo()
  9034. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9035. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9036. //
  9037. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9038. //
  9039. // fmt.Println(miConfig.SecretKey)
  9040. //
  9041. // if patient == nil {
  9042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9043. // return
  9044. // }
  9045. // if len(patient.IdCardNo) == 0 {
  9046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9047. // return
  9048. // }
  9049. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9050. // if config.IsOpen == 1 {
  9051. // 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
  9052. // resp, requestErr := http.Get(api)
  9053. // if requestErr != nil {
  9054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9055. // return
  9056. // }
  9057. // defer resp.Body.Close()
  9058. // body, ioErr := ioutil.ReadAll(resp.Body)
  9059. // if ioErr != nil {
  9060. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. // return
  9063. // }
  9064. // var respJSON map[string]interface{}
  9065. //
  9066. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9067. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9069. // return
  9070. // }
  9071. //
  9072. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9073. // userJSONBytes, _ := json.Marshal(userJSON)
  9074. // var res ResultTwo
  9075. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9076. // utils.ErrorLog("解析失败:%v", err)
  9077. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. // return
  9079. // }
  9080. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9081. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9082. // infoStr := string(Iinfos)
  9083. // idetinfoStr := string(Idetinfos)
  9084. //
  9085. // if res.Infcode == 0 {
  9086. // his := models.VMHisPatient{
  9087. // Status: 1,
  9088. // Ctime: time.Now().Unix(),
  9089. // Mtime: time.Now().Unix(),
  9090. // PsnNo: res.Output.Baseinfo.PsnNo,
  9091. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9092. // Certno: res.Output.Baseinfo.Certno,
  9093. // PsnName: res.Output.Baseinfo.PsnName,
  9094. // Gend: res.Output.Baseinfo.Gend,
  9095. // Naty: res.Output.Baseinfo.Naty,
  9096. // Brdy: res.Output.Baseinfo.Brdy,
  9097. // Age: res.Output.Baseinfo.Age,
  9098. // Iinfo: infoStr,
  9099. // Idetinfo: idetinfoStr,
  9100. // PatientId: patient.ID,
  9101. // RecordDate: theTime.Unix(),
  9102. // UserOrgId: adminInfo.CurrentOrgId,
  9103. // AdminUserId: adminInfo.AdminUser.Id,
  9104. // IsReturn: 1,
  9105. // }
  9106. //
  9107. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9108. // //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")
  9109. // //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")
  9110. //
  9111. // //var dat map[string]interface{}
  9112. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9113. // // fmt.Println(dat)
  9114. // //} else {
  9115. // // fmt.Println(err)
  9116. // //}
  9117. //
  9118. // var dat2 map[string]interface{}
  9119. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9120. // fmt.Println(dat2)
  9121. // } else {
  9122. // fmt.Println(err)
  9123. // }
  9124. //
  9125. // } else {
  9126. // adminUser := c.GetAdminUserInfo()
  9127. // errlog := &models.HisOrderError{
  9128. // UserOrgId: adminUser.CurrentOrgId,
  9129. // Ctime: time.Now().Unix(),
  9130. // Mtime: time.Now().Unix(),
  9131. // ErrMsg: res.ErrMsg,
  9132. // Status: 1,
  9133. // PatientId: id,
  9134. // RecordTime: recordDateTime,
  9135. // Stage: 1,
  9136. // }
  9137. // service.CreateErrMsgLog(errlog)
  9138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9139. // return
  9140. // }
  9141. // }
  9142. //
  9143. //}
  9144. //func (c *HisApiController) GetUploadDiag() {
  9145. // id, _ := c.GetInt64("id")
  9146. // record_time := c.GetString("record_time")
  9147. //
  9148. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9149. // sick_type, _ := c.GetInt64("sick_type")
  9150. // reg_type, _ := c.GetInt64("reg_type")
  9151. //
  9152. // timeLayout := "2006-01-02"
  9153. // loc, _ := time.LoadLocation("Local")
  9154. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9155. // if err != nil {
  9156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9157. // return
  9158. // }
  9159. //
  9160. // var patientPrescription models.HisPrescriptionInfo
  9161. // recordDateTime := theTime.Unix()
  9162. // adminInfo := c.GetAdminUserInfo()
  9163. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9164. //
  9165. // if patientPrescription.ID == 0 {
  9166. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9167. // }
  9168. //
  9169. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9170. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9171. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9172. // sickConfig, _ := service.FindSickById(sick_type)
  9173. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9174. //
  9175. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9176. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9177. // "&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 +
  9178. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9179. // resp2, requestErr2 := http.Get(api2)
  9180. // if requestErr2 != nil {
  9181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9182. // return
  9183. // }
  9184. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9185. // if ioErr2 != nil {
  9186. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. // return
  9189. // }
  9190. // var respJSON2 map[string]interface{}
  9191. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9192. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. // return
  9195. // }
  9196. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9198. //
  9199. // var res2 ResultSix
  9200. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9201. // utils.ErrorLog("解析失败:%v", err)
  9202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9203. // return
  9204. // }
  9205. // if res2.Infcode != 0 {
  9206. // adminUser := c.GetAdminUserInfo()
  9207. // errlog := &models.HisOrderError{
  9208. // UserOrgId: adminUser.CurrentOrgId,
  9209. // Ctime: time.Now().Unix(),
  9210. // Mtime: time.Now().Unix(),
  9211. // ErrMsg: res2.ErrMsg,
  9212. // Status: 1,
  9213. // PatientId: id,
  9214. // RecordTime: recordDateTime,
  9215. // Stage: 3,
  9216. // }
  9217. // service.CreateErrMsgLog(errlog)
  9218. //
  9219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9220. // return
  9221. // }
  9222. //
  9223. // c.ServeSuccessJSON(map[string]interface{}{
  9224. // "msg": "上传成功",
  9225. // })
  9226. //
  9227. //}
  9228. type QueryResult struct {
  9229. ID int64
  9230. Name string
  9231. Code string
  9232. List_type_code string
  9233. }
  9234. func (c *HisApiController) GetCheckCode() {
  9235. ids_str := c.GetString("ids")
  9236. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9237. ids_arr := strings.Split(ids_str, ",")
  9238. var queryResult []QueryResult
  9239. ids := make([]int64, 0)
  9240. for _, item := range ids_arr {
  9241. id, _ := strconv.ParseInt(item, 10, 64)
  9242. ids = append(ids, id)
  9243. }
  9244. if record_type == 1 {
  9245. drugs, _ := service.GetBatchDrugList(ids)
  9246. for _, item := range drugs {
  9247. result := QueryResult{
  9248. ID: item.ID,
  9249. Name: item.DrugName,
  9250. Code: item.MedicalInsuranceNumber,
  9251. List_type_code: "101",
  9252. }
  9253. queryResult = append(queryResult, result)
  9254. }
  9255. } else if record_type == 2 {
  9256. goods, _ := service.GetBatchGoodInformationList(ids)
  9257. for _, item := range goods {
  9258. result := QueryResult{
  9259. ID: item.ID,
  9260. Name: item.GoodName,
  9261. Code: item.MedicalInsuranceNumber,
  9262. List_type_code: "301",
  9263. }
  9264. queryResult = append(queryResult, result)
  9265. }
  9266. } else if record_type == 3 {
  9267. projects, _ := service.GetBathchMyPorjecgList(ids)
  9268. for _, item := range projects {
  9269. result := QueryResult{
  9270. ID: item.ID,
  9271. Name: item.ProjectName,
  9272. Code: item.MedicalCode,
  9273. List_type_code: "201",
  9274. }
  9275. queryResult = append(queryResult, result)
  9276. }
  9277. }
  9278. admin_user_id, _ := c.GetInt64("admin_user_id")
  9279. adminUser := c.GetAdminUserInfo()
  9280. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9281. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9282. var user_name string
  9283. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9284. if role.ID == 0 {
  9285. user_name = "xxx"
  9286. } else {
  9287. user_name = role.UserName
  9288. }
  9289. baseParams := &models.BaseParams{
  9290. SecretKey: miConfig.SecretKey,
  9291. FixmedinsCode: miConfig.Code,
  9292. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9293. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9294. OrgName: miConfig.OrgName,
  9295. Doctor: user_name,
  9296. }
  9297. if config.IsOpen == 1 {
  9298. for _, item := range queryResult {
  9299. var result string
  9300. if record_type == 1 {
  9301. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9302. } else if record_type == 2 {
  9303. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9304. } else if record_type == 3 {
  9305. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9306. }
  9307. var dat map[string]interface{}
  9308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9309. fmt.Println(dat)
  9310. } else {
  9311. fmt.Println(err)
  9312. }
  9313. userJSONBytes, _ := json.Marshal(dat)
  9314. var res ResultSix
  9315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9316. utils.ErrorLog("解析失败:%v", err)
  9317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9318. return
  9319. }
  9320. if res.Infcode == 0 {
  9321. if record_type == 1 {
  9322. service.UpdateBaseDrugById(item.ID)
  9323. } else if record_type == 2 {
  9324. service.UpdateGoodInformaitonByDetail(item.ID)
  9325. } else if record_type == 3 {
  9326. service.UpdateProjectById(item.ID)
  9327. }
  9328. c.ServeSuccessJSON(map[string]interface{}{
  9329. "failed_code": 0,
  9330. "msg": "目录对照成功",
  9331. })
  9332. } else {
  9333. c.ServeSuccessJSON(map[string]interface{}{
  9334. "failed_code": -10,
  9335. "msg": res.ErrMsg,
  9336. })
  9337. }
  9338. }
  9339. }
  9340. }
  9341. func (c *HisApiController) UnCheckCode() {
  9342. ids_str := c.GetString("ids")
  9343. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9344. admin_user_id, _ := c.GetInt64("admin_user_id")
  9345. ids_arr := strings.Split(ids_str, ",")
  9346. var queryResult []QueryResult
  9347. ids := make([]int64, 0)
  9348. for _, item := range ids_arr {
  9349. id, _ := strconv.ParseInt(item, 10, 64)
  9350. ids = append(ids, id)
  9351. }
  9352. if record_type == 1 {
  9353. drugs, _ := service.GetBatchDrugList(ids)
  9354. for _, item := range drugs {
  9355. result := QueryResult{
  9356. ID: item.ID,
  9357. Name: item.DrugName,
  9358. Code: item.MedicalInsuranceNumber,
  9359. List_type_code: "101",
  9360. }
  9361. queryResult = append(queryResult, result)
  9362. }
  9363. } else if record_type == 2 {
  9364. goods, _ := service.GetBatchGoodInformationList(ids)
  9365. for _, item := range goods {
  9366. result := QueryResult{
  9367. ID: item.ID,
  9368. Name: item.GoodName,
  9369. Code: item.MedicalInsuranceNumber,
  9370. List_type_code: "301",
  9371. }
  9372. queryResult = append(queryResult, result)
  9373. }
  9374. } else if record_type == 3 {
  9375. projects, _ := service.GetBathchMyPorjecgList(ids)
  9376. for _, item := range projects {
  9377. result := QueryResult{
  9378. ID: item.ID,
  9379. Name: item.ProjectName,
  9380. Code: item.MedicalCode,
  9381. List_type_code: "201",
  9382. }
  9383. queryResult = append(queryResult, result)
  9384. }
  9385. }
  9386. adminUser := c.GetAdminUserInfo()
  9387. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9388. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9389. var user_name string
  9390. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9391. if role.ID == 0 {
  9392. user_name = "xxx"
  9393. } else {
  9394. user_name = role.UserName
  9395. }
  9396. baseParams := &models.BaseParams{
  9397. SecretKey: miConfig.SecretKey,
  9398. FixmedinsCode: miConfig.Code,
  9399. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9400. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9401. OrgName: miConfig.OrgName,
  9402. Doctor: user_name,
  9403. }
  9404. if config.IsOpen == 1 {
  9405. for _, item := range queryResult {
  9406. var result string
  9407. if record_type == 1 {
  9408. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9409. } else if record_type == 2 {
  9410. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9411. } else if record_type == 3 {
  9412. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9413. }
  9414. var dat2 map[string]interface{}
  9415. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9416. fmt.Println(dat2)
  9417. } else {
  9418. fmt.Println(err)
  9419. }
  9420. userJSONBytes, _ := json.Marshal(dat2)
  9421. var res ResultSix
  9422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9423. utils.ErrorLog("解析失败:%v", err)
  9424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9425. return
  9426. }
  9427. if res.Infcode == 0 {
  9428. if record_type == 1 {
  9429. service.UpdateDrugByIdDetail(item.ID)
  9430. } else if record_type == 2 {
  9431. service.UpdateGoodInfoById(item.ID)
  9432. } else if record_type == 3 {
  9433. service.UpdateMyProjectById(item.ID)
  9434. }
  9435. c.ServeSuccessJSON(map[string]interface{}{
  9436. "failed_code": 0,
  9437. "msg": "撤销目录对照成功",
  9438. })
  9439. } else {
  9440. c.ServeSuccessJSON(map[string]interface{}{
  9441. "failed_code": -10,
  9442. "msg": res.ErrMsg,
  9443. })
  9444. }
  9445. }
  9446. }
  9447. }
  9448. func (c *HisApiController) GetPatientInfo() {
  9449. id_card_no := c.GetString("id_card_no")
  9450. admin_user_id, _ := c.GetInt64("admin_user_id")
  9451. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9452. if patient.ID == 0 {
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9454. return
  9455. }
  9456. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9457. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9458. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9459. if config.IsOpen == 1 {
  9460. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9461. var dat map[string]interface{}
  9462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9463. fmt.Println(dat)
  9464. } else {
  9465. fmt.Println(err)
  9466. }
  9467. userJSONBytes, _ := json.Marshal(dat)
  9468. var res ResultTwo
  9469. var res10265 ResultTwo10265
  9470. if miConfig.Code == "H15049901371" {
  9471. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9472. utils.ErrorLog("解析失败:%v", err)
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. return
  9475. }
  9476. res.ErrMsg = res10265.ErrMsg
  9477. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9478. res.Infcode = infocode
  9479. res.Output = res10265.Output
  9480. res.InfRefmsgid = res10265.InfRefmsgid
  9481. } else {
  9482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9483. utils.ErrorLog("解析失败:%v", err)
  9484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9485. return
  9486. }
  9487. }
  9488. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9489. // utils.ErrorLog("解析失败:%v", err)
  9490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9491. // return
  9492. //}
  9493. if res.Infcode != 0 {
  9494. c.ServeSuccessJSON(map[string]interface{}{
  9495. "failed_code": -10,
  9496. "msg": res.ErrMsg,
  9497. })
  9498. } else {
  9499. c.ServeSuccessJSON(map[string]interface{}{
  9500. "failed_code": 0,
  9501. "info": res,
  9502. })
  9503. }
  9504. }
  9505. }
  9506. func (c *HisApiController) PsnPutOnRecord() {
  9507. record_type, _ := c.GetInt64("type")
  9508. patient_id, _ := c.GetInt64("patient_id")
  9509. admin_user_id, _ := c.GetInt64("admin_user_id")
  9510. start_time := c.GetString("start_time")
  9511. end_time := c.GetString("end_time")
  9512. adminUser := c.GetAdminUserInfo()
  9513. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9514. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9515. var patients []*models.Patients
  9516. if record_type == 1 { //全部备案
  9517. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9518. patients = append(patients, patient...)
  9519. } else { //单个备案
  9520. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9521. patients = append(patients, patient)
  9522. }
  9523. var user_name string
  9524. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9525. if role.ID == 0 {
  9526. user_name = "xxx"
  9527. } else {
  9528. user_name = role.UserName
  9529. }
  9530. if config.IsOpen == 1 {
  9531. for _, item := range patients {
  9532. 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
  9533. resp, requestErr := http.Get(api)
  9534. if requestErr != nil {
  9535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9536. return
  9537. }
  9538. defer resp.Body.Close()
  9539. body, ioErr := ioutil.ReadAll(resp.Body)
  9540. if ioErr != nil {
  9541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9543. return
  9544. }
  9545. var respJSON map[string]interface{}
  9546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9552. userJSONBytes, _ := json.Marshal(userJSON)
  9553. var res ResultTwo
  9554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9555. utils.ErrorLog("解析失败:%v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. if res.Infcode == 0 {
  9560. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9561. var dat map[string]interface{}
  9562. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9563. fmt.Println(dat)
  9564. } else {
  9565. fmt.Println(err)
  9566. }
  9567. userJSONBytes, _ := json.Marshal(dat)
  9568. var res2 ResultThirteen
  9569. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9570. utils.ErrorLog("解析失败:%v", err)
  9571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9572. return
  9573. }
  9574. if res2.Infcode == 0 {
  9575. psnResult := &models.GdybPsnRecord{
  9576. UserOrgId: adminUser.CurrentOrgId,
  9577. PatientId: item.ID,
  9578. PsnNo: res.Output.Baseinfo.PsnNo,
  9579. Ctime: time.Now().Unix(),
  9580. Mtime: time.Now().Unix(),
  9581. Status: 1,
  9582. IsCancel: 1,
  9583. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9584. }
  9585. service.CreatePsnRecord(psnResult)
  9586. } else {
  9587. c.ServeSuccessJSON(map[string]interface{}{
  9588. "failed_code": -10,
  9589. "msg": res2.ErrMsg,
  9590. })
  9591. return
  9592. }
  9593. }
  9594. }
  9595. }
  9596. }
  9597. func (c *HisApiController) PsnUnPutOnRecord() {
  9598. id, _ := c.GetInt64("id")
  9599. //record_type, _ := c.GetInt64("type")
  9600. admin_user_id, _ := c.GetInt64("admin_user_id")
  9601. adminUser := c.GetAdminUserInfo()
  9602. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9603. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9604. var user_name string
  9605. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9606. if role.ID == 0 {
  9607. user_name = "xxx"
  9608. } else {
  9609. user_name = role.UserName
  9610. }
  9611. psn_record, _ := service.GetPsnRecordById(id)
  9612. if psn_record.ID == 0 {
  9613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9614. return
  9615. }
  9616. if config.IsOpen == 1 {
  9617. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9618. var dat map[string]interface{}
  9619. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9620. fmt.Println(dat)
  9621. } else {
  9622. fmt.Println(err)
  9623. }
  9624. userJSONBytes, _ := json.Marshal(dat)
  9625. var res ResultFourteen
  9626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9627. utils.ErrorLog("解析失败:%v", err)
  9628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9629. return
  9630. }
  9631. if res.Infcode == 0 {
  9632. psn_record.IsCancel = 2
  9633. service.CreatePsnRecord(&psn_record)
  9634. } else {
  9635. c.ServeSuccessJSON(map[string]interface{}{
  9636. "failed_code": -10,
  9637. "msg": res.ErrMsg,
  9638. })
  9639. return
  9640. }
  9641. }
  9642. }
  9643. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9644. patient_id, _ := c.GetInt64("patient_id")
  9645. insutype_two := c.GetString("insutype")
  9646. psn_no := c.GetString("psn_no")
  9647. doctor_id, _ := c.GetInt64("doctor_id")
  9648. sick_id, _ := c.GetInt64("sick_id")
  9649. department_id, _ := c.GetInt64("department_id")
  9650. start_time := c.GetString("start_time")
  9651. end_time := c.GetString("end_time")
  9652. check_time := c.GetString("check_time")
  9653. adminUser := c.GetAdminUserInfo()
  9654. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9655. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9656. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9657. sick, _ := service.FindSickById(sick_id)
  9658. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9659. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9660. var res ResultTwo
  9661. var res10265 ResultTwo10265
  9662. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9663. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9664. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9665. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9666. "&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
  9667. resp, requestErr := http.Get(api)
  9668. if requestErr != nil {
  9669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9670. return
  9671. }
  9672. body, ioErr := ioutil.ReadAll(resp.Body)
  9673. if ioErr != nil {
  9674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9676. return
  9677. }
  9678. var respJSON map[string]interface{}
  9679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9682. return
  9683. }
  9684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9685. result, _ := json.Marshal(respJSON)
  9686. fmt.Println("log")
  9687. fmt.Println(string(result))
  9688. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9689. utils.ErrorLog("解析失败:%v", err)
  9690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9691. return
  9692. }
  9693. res.ErrMsg = res10265.ErrMsg
  9694. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9695. res.Infcode = infocode
  9696. res.Output = res10265.Output
  9697. res.InfRefmsgid = res10265.InfRefmsgid
  9698. } else {
  9699. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9700. if miConfig.Code == "H15049901371" {
  9701. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9702. utils.ErrorLog("解析失败:%v", err)
  9703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9704. return
  9705. }
  9706. res.ErrMsg = res10265.ErrMsg
  9707. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9708. res.Infcode = infocode
  9709. res.Output = res10265.Output
  9710. res.InfRefmsgid = res10265.InfRefmsgid
  9711. } else {
  9712. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9713. utils.ErrorLog("解析失败:%v", err)
  9714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9715. return
  9716. }
  9717. }
  9718. }
  9719. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9720. infoStr := string(Iinfos)
  9721. var rf []*ResultFive
  9722. json.Unmarshal([]byte(infoStr), &rf)
  9723. var insuplc_admdvs string
  9724. var insutype string
  9725. var is390 int = 0
  9726. var is310 int = 0
  9727. var insutypes []*ResultFive
  9728. for _, item := range rf {
  9729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9730. insutypes = append(insutypes, item)
  9731. }
  9732. }
  9733. if len(insutypes) == 1 {
  9734. insutype = insutypes[0].Insutype
  9735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9736. } else {
  9737. for _, i := range insutypes {
  9738. if i.Insutype == "390" {
  9739. is390 = 1
  9740. }
  9741. if i.Insutype == "310" {
  9742. is310 = 1
  9743. }
  9744. }
  9745. }
  9746. if is390 == 1 {
  9747. insutype = "390"
  9748. }
  9749. if is310 == 1 {
  9750. insutype = "310"
  9751. }
  9752. if len(insutypes) == 2 {
  9753. insutype = insutype_two
  9754. }
  9755. if len(insutypes) == 0 {
  9756. insutype = "310"
  9757. }
  9758. insutype = insutype_two
  9759. fmt.Println(insutype)
  9760. for _, item := range rf {
  9761. fmt.Println(item.Insutype)
  9762. fmt.Println(insutype)
  9763. if item.Insutype == insutype {
  9764. fmt.Println(item.Insutype)
  9765. fmt.Println(insutype)
  9766. insuplc_admdvs = item.InsuplcAdmdvs
  9767. }
  9768. }
  9769. fmt.Println(insuplc_admdvs)
  9770. var res2 ResultThirteen
  9771. var res10265_2 ResultThirteen10265
  9772. if config.IsOpen == 1 {
  9773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9774. } else {
  9775. 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)
  9776. var dat map[string]interface{}
  9777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9778. fmt.Println(dat)
  9779. } else {
  9780. fmt.Println(err)
  9781. }
  9782. userJSONBytes, _ := json.Marshal(dat)
  9783. if miConfig.Code == "H15049901371" {
  9784. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9785. utils.ErrorLog("解析失败:%v", err)
  9786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9787. return
  9788. }
  9789. res2.ErrMsg = res10265_2.ErrMsg
  9790. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9791. res2.Infcode = infocode
  9792. res2.Output = res10265_2.Output
  9793. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9794. } else {
  9795. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9796. utils.ErrorLog("解析失败:%v", err)
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. return
  9799. }
  9800. }
  9801. }
  9802. if res2.Infcode == 0 {
  9803. psnResult := &models.GdybPsnNcdsRecord{
  9804. UserOrgId: adminUser.CurrentOrgId,
  9805. PatientId: patient.ID,
  9806. PsnNo: psn_no,
  9807. DoctorId: doctor.AdminUserId,
  9808. DepartmentId: department_id,
  9809. SickType: sick_id,
  9810. Insutype: insutype,
  9811. Ctime: time.Now().Unix(),
  9812. Mtime: time.Now().Unix(),
  9813. Status: 1,
  9814. IsCancel: 1,
  9815. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9816. }
  9817. service.CreatePsnNCDSRecord(psnResult)
  9818. c.ServeSuccessJSON(map[string]interface{}{
  9819. "failed_code": 0,
  9820. "msg": "备案成功",
  9821. "result": psnResult,
  9822. })
  9823. } else {
  9824. c.ServeSuccessJSON(map[string]interface{}{
  9825. "failed_code": -10,
  9826. "msg": res2.ErrMsg,
  9827. })
  9828. return
  9829. }
  9830. }
  9831. }
  9832. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9833. id, _ := c.GetInt64("id")
  9834. admin_user_id, _ := c.GetInt64("admin_user_id")
  9835. adminUser := c.GetAdminUserInfo()
  9836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9837. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9838. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9839. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9840. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9841. //var user_name string
  9842. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9843. //if role.ID == 0 {
  9844. // user_name = "xxx"
  9845. //} else {
  9846. // user_name = role.UserName
  9847. //}
  9848. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9849. if psn_record.ID == 0 {
  9850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9851. return
  9852. }
  9853. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9854. var res ResultTwo
  9855. var res10265 ResultTwo10265
  9856. if miConfig.Code == "H15049901371" {
  9857. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9858. utils.ErrorLog("解析失败:%v", err)
  9859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9860. return
  9861. }
  9862. res.ErrMsg = res10265.ErrMsg
  9863. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9864. res.Infcode = infocode
  9865. res.Output = res10265.Output
  9866. res.InfRefmsgid = res10265.InfRefmsgid
  9867. } else {
  9868. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9869. utils.ErrorLog("解析失败:%v", err)
  9870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9871. return
  9872. }
  9873. }
  9874. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9875. infoStr := string(Iinfos)
  9876. var rf []*ResultFive
  9877. json.Unmarshal([]byte(infoStr), &rf)
  9878. var insuplc_admdvs string
  9879. var insutype string
  9880. var is390 int = 0
  9881. var is310 int = 0
  9882. var insutypes []*ResultFive
  9883. for _, item := range rf {
  9884. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9885. insutypes = append(insutypes, item)
  9886. }
  9887. }
  9888. if len(insutypes) == 1 {
  9889. insutype = insutypes[0].Insutype
  9890. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9891. } else {
  9892. for _, i := range insutypes {
  9893. if i.Insutype == "390" {
  9894. is390 = 1
  9895. }
  9896. if i.Insutype == "310" {
  9897. is310 = 1
  9898. }
  9899. }
  9900. }
  9901. if is390 == 1 {
  9902. insutype = "390"
  9903. }
  9904. if is310 == 1 {
  9905. insutype = "310"
  9906. }
  9907. if len(insutypes) == 0 {
  9908. insutype = "310"
  9909. }
  9910. insutype = psn_record.Insutype
  9911. for _, item := range rf {
  9912. if item.Insutype == insutype {
  9913. insuplc_admdvs = item.InsuplcAdmdvs
  9914. }
  9915. }
  9916. if config.IsOpen == 1 {
  9917. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9918. var dat map[string]interface{}
  9919. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9920. fmt.Println(dat)
  9921. } else {
  9922. fmt.Println(err)
  9923. }
  9924. userJSONBytes, _ := json.Marshal(dat)
  9925. var res ResultFourteen
  9926. var res10265 ResultFourteen10265
  9927. if miConfig.Code == "H15049901371" {
  9928. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9929. utils.ErrorLog("解析失败:%v", err)
  9930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9931. return
  9932. }
  9933. res.ErrMsg = res10265.ErrMsg
  9934. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9935. res.Infcode = infocode
  9936. res.Output = res10265.Output
  9937. res.InfRefmsgid = res10265.InfRefmsgid
  9938. } else {
  9939. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9940. utils.ErrorLog("解析失败:%v", err)
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. }
  9945. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9946. // utils.ErrorLog("解析失败:%v", err)
  9947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9948. // return
  9949. //}
  9950. if res.Infcode == 0 {
  9951. psn_record.IsCancel = 2
  9952. service.CreatePsnNCDSRecord(&psn_record)
  9953. c.ServeSuccessJSON(map[string]interface{}{
  9954. "failed_code": 0,
  9955. "msg": "撤销备案成功",
  9956. })
  9957. } else {
  9958. c.ServeSuccessJSON(map[string]interface{}{
  9959. "failed_code": -10,
  9960. "msg": res.ErrMsg,
  9961. })
  9962. return
  9963. }
  9964. }
  9965. }
  9966. func (c *HisApiController) TestTest() {
  9967. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9968. fmt.Println(patient.Iinfo)
  9969. }
  9970. type CustomData struct {
  9971. MsgId string
  9972. PsnNo string
  9973. Info string
  9974. }
  9975. func (c *HisApiController) ReversalData() {
  9976. var customData []*CustomData
  9977. custom := &CustomData{
  9978. MsgId: "H44022900158202103301714472004",
  9979. PsnNo: "44020000001101329945",
  9980. Info: "2207",
  9981. }
  9982. customData = append(customData, custom)
  9983. custom1 := &CustomData{
  9984. MsgId: "H4402290015820210330172057803",
  9985. PsnNo: "44020000001101161813",
  9986. Info: "2207",
  9987. }
  9988. customData = append(customData, custom1)
  9989. custom2 := &CustomData{
  9990. MsgId: "H44022900158202103301705198813",
  9991. PsnNo: "44190000133097375417",
  9992. Info: "2207",
  9993. }
  9994. customData = append(customData, custom2)
  9995. custom3 := &CustomData{
  9996. MsgId: "H44022900158202103301715524756",
  9997. PsnNo: "44020000001100187221",
  9998. Info: "2207",
  9999. }
  10000. customData = append(customData, custom3)
  10001. custom4 := &CustomData{
  10002. MsgId: "H44022900158202103301730376224",
  10003. PsnNo: "44020000001101959155",
  10004. Info: "2207",
  10005. }
  10006. customData = append(customData, custom4)
  10007. custom5 := &CustomData{
  10008. MsgId: "H44022900158202103301748008725",
  10009. PsnNo: "44020000001104246641",
  10010. Info: "2207",
  10011. }
  10012. customData = append(customData, custom5)
  10013. custom6 := &CustomData{
  10014. MsgId: "H44022900158202103301718096755",
  10015. PsnNo: "44020000001102211860",
  10016. Info: "2207",
  10017. }
  10018. customData = append(customData, custom6)
  10019. custom7 := &CustomData{
  10020. MsgId: "H44022900158202103301736551640",
  10021. PsnNo: "44020000001102687718",
  10022. Info: "2207",
  10023. }
  10024. customData = append(customData, custom7)
  10025. custom8 := &CustomData{
  10026. MsgId: "H44022900158202103301743097676",
  10027. PsnNo: "44020000001102127785",
  10028. Info: "2207",
  10029. }
  10030. customData = append(customData, custom8)
  10031. custom9 := &CustomData{
  10032. MsgId: "H44022900158202103301712304203",
  10033. PsnNo: "44020000001101518097",
  10034. Info: "2207",
  10035. }
  10036. customData = append(customData, custom9)
  10037. custom10 := &CustomData{
  10038. MsgId: "H44022900158202103301738448785",
  10039. PsnNo: "44020000001100500813",
  10040. Info: "2207",
  10041. }
  10042. customData = append(customData, custom10)
  10043. custom11 := &CustomData{
  10044. MsgId: "H44022900158202103301732455843",
  10045. PsnNo: "44020000001102690557",
  10046. Info: "2207",
  10047. }
  10048. customData = append(customData, custom11)
  10049. custom12 := &CustomData{
  10050. MsgId: "H44022900158202103301745421708",
  10051. PsnNo: "44020000001102211928",
  10052. Info: "2207",
  10053. }
  10054. customData = append(customData, custom12)
  10055. custom1212 := &CustomData{
  10056. MsgId: "H440229001582021033017351627",
  10057. PsnNo: "44020000001102481733",
  10058. Info: "2207",
  10059. }
  10060. customData = append(customData, custom1212)
  10061. custom13 := &CustomData{
  10062. MsgId: "H44022900158202103301740327951",
  10063. PsnNo: "44020000001103174866",
  10064. Info: "2207",
  10065. }
  10066. customData = append(customData, custom13)
  10067. custom14 := &CustomData{
  10068. MsgId: "H4402290015820210330174922668",
  10069. PsnNo: "44020000001102927272",
  10070. Info: "2207",
  10071. }
  10072. customData = append(customData, custom14)
  10073. custom15 := &CustomData{
  10074. MsgId: "H44022900158202103301752362273",
  10075. PsnNo: "44020000001102942890",
  10076. Info: "2207",
  10077. }
  10078. customData = append(customData, custom15)
  10079. custom16 := &CustomData{
  10080. MsgId: "H44022900158202103301751082917",
  10081. PsnNo: "44020000001101662162",
  10082. Info: "2207",
  10083. }
  10084. customData = append(customData, custom16)
  10085. custom17 := &CustomData{
  10086. MsgId: "H44022900158202103301754147728",
  10087. PsnNo: "44020000000229014511",
  10088. Info: "2207",
  10089. }
  10090. customData = append(customData, custom17)
  10091. adminUser := c.GetAdminUserInfo()
  10092. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10093. for _, item := range customData {
  10094. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10095. fmt.Println(result)
  10096. }
  10097. }
  10098. func (c *HisApiController) GetAllopatry() {
  10099. year := c.GetString("year")
  10100. month := c.GetString("month")
  10101. admin_user_id, _ := c.GetInt64("admin_user_id")
  10102. adminUser := c.GetAdminUserInfo()
  10103. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10104. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10105. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10106. var dat map[string]interface{}
  10107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10108. fmt.Println(dat)
  10109. } else {
  10110. fmt.Println(err)
  10111. }
  10112. userJSONBytes, _ := json.Marshal(dat)
  10113. var res models.Result9001
  10114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10115. utils.ErrorLog("解析失败:%v", err)
  10116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10117. return
  10118. }
  10119. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10120. var dat2 map[string]interface{}
  10121. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10122. fmt.Println(dat)
  10123. } else {
  10124. fmt.Println(err)
  10125. }
  10126. userJSONBytes2, _ := json.Marshal(dat2)
  10127. var res2 models.Result3260
  10128. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10129. utils.ErrorLog("解析失败:%v", err)
  10130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10131. return
  10132. }
  10133. if res2.Infcode == 0 {
  10134. c.ServeSuccessJSON(map[string]interface{}{
  10135. "list": res2.Output.Data,
  10136. })
  10137. return
  10138. } else {
  10139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10140. return
  10141. }
  10142. }
  10143. func (c *HisApiController) ComfirmAllopatry() {
  10144. year := c.GetString("year")
  10145. month := c.GetString("month")
  10146. admin_user_id, _ := c.GetInt64("admin_user_id")
  10147. adminUser := c.GetAdminUserInfo()
  10148. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10149. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10150. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10151. var dat map[string]interface{}
  10152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10153. fmt.Println(dat)
  10154. } else {
  10155. fmt.Println(err)
  10156. }
  10157. userJSONBytes, _ := json.Marshal(dat)
  10158. var res models.Result9001
  10159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10165. var dat2 map[string]interface{}
  10166. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10167. fmt.Println(dat)
  10168. } else {
  10169. fmt.Println(err)
  10170. }
  10171. userJSONBytes2, _ := json.Marshal(dat2)
  10172. var res2 models.Result3260
  10173. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10174. utils.ErrorLog("解析失败:%v", err)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return
  10177. }
  10178. if res2.Infcode == 0 {
  10179. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10180. var dat map[string]interface{}
  10181. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10182. fmt.Println(dat)
  10183. } else {
  10184. fmt.Println(err)
  10185. }
  10186. userJSONBytes, _ := json.Marshal(dat)
  10187. var res3 models.Result3261
  10188. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10189. utils.ErrorLog("解析失败:%v", err)
  10190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10191. return
  10192. }
  10193. if res3.Infcode == 0 {
  10194. record := &models.HisYidiClearRecord{
  10195. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10196. Ctime: time.Now().Unix(),
  10197. Mtime: time.Now().Unix(),
  10198. Status: 1,
  10199. MsgId: msgId,
  10200. }
  10201. service.SaveClearRecord(record)
  10202. c.ServeSuccessJSON(map[string]interface{}{
  10203. "msg": "提取成功",
  10204. })
  10205. }
  10206. }
  10207. }
  10208. func (c *HisApiController) RefundAllopatry() {
  10209. year := c.GetString("year")
  10210. month := c.GetString("month")
  10211. id, _ := c.GetInt64("id")
  10212. admin_user_id, _ := c.GetInt64("admin_user_id")
  10213. adminUser := c.GetAdminUserInfo()
  10214. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10215. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10216. record, _ := service.GetClearRecordById(id)
  10217. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10218. var dat map[string]interface{}
  10219. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10220. fmt.Println(dat)
  10221. } else {
  10222. fmt.Println(err)
  10223. }
  10224. userJSONBytes, _ := json.Marshal(dat)
  10225. var empty ResultFourteen
  10226. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10227. utils.ErrorLog("解析失败:%v", err)
  10228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10229. return
  10230. }
  10231. if empty.Infcode == 0 {
  10232. c.ServeSuccessJSON(map[string]interface{}{
  10233. "msg": "撤销成功",
  10234. })
  10235. return
  10236. }
  10237. }
  10238. func (c *HisApiController) ReversalOtherData() {
  10239. var customData []*CustomData
  10240. custom := &CustomData{
  10241. MsgId: "H44022900158202103301714472004",
  10242. PsnNo: "44020000001101329945",
  10243. Info: "2208",
  10244. }
  10245. customData = append(customData, custom)
  10246. custom1 := &CustomData{
  10247. MsgId: "H4402290015820210330172057803",
  10248. PsnNo: "44020000001101161813",
  10249. Info: "2208",
  10250. }
  10251. customData = append(customData, custom1)
  10252. custom2 := &CustomData{
  10253. MsgId: "H44022900158202103301705198813",
  10254. PsnNo: "44190000133097375417",
  10255. Info: "2208",
  10256. }
  10257. customData = append(customData, custom2)
  10258. custom3 := &CustomData{
  10259. MsgId: "H44022900158202103301715524756",
  10260. PsnNo: "44020000001100187221",
  10261. Info: "2208",
  10262. }
  10263. customData = append(customData, custom3)
  10264. custom4 := &CustomData{
  10265. MsgId: "H44022900158202103301730376224",
  10266. PsnNo: "44020000001101959155",
  10267. Info: "2208",
  10268. }
  10269. customData = append(customData, custom4)
  10270. custom5 := &CustomData{
  10271. MsgId: "H44022900158202103301748008725",
  10272. PsnNo: "44020000001104246641",
  10273. Info: "2208",
  10274. }
  10275. customData = append(customData, custom5)
  10276. custom6 := &CustomData{
  10277. MsgId: "H44022900158202103301718096755",
  10278. PsnNo: "44020000001102211860",
  10279. Info: "2208",
  10280. }
  10281. customData = append(customData, custom6)
  10282. custom7 := &CustomData{
  10283. MsgId: "H44022900158202103301736551640",
  10284. PsnNo: "44020000001102687718",
  10285. Info: "2208",
  10286. }
  10287. customData = append(customData, custom7)
  10288. custom8 := &CustomData{
  10289. MsgId: "H44022900158202103301743097676",
  10290. PsnNo: "44020000001102127785",
  10291. Info: "2208",
  10292. }
  10293. customData = append(customData, custom8)
  10294. custom9 := &CustomData{
  10295. MsgId: "H44022900158202103301712304203",
  10296. PsnNo: "44020000001101518097",
  10297. Info: "2208",
  10298. }
  10299. customData = append(customData, custom9)
  10300. custom10 := &CustomData{
  10301. MsgId: "H44022900158202103301738448785",
  10302. PsnNo: "44020000001100500813",
  10303. Info: "2208",
  10304. }
  10305. customData = append(customData, custom10)
  10306. custom11 := &CustomData{
  10307. MsgId: "H44022900158202103301732455843",
  10308. PsnNo: "44020000001102690557",
  10309. Info: "2208",
  10310. }
  10311. customData = append(customData, custom11)
  10312. custom12 := &CustomData{
  10313. MsgId: "H44022900158202103301745421708",
  10314. PsnNo: "44020000001102211928",
  10315. Info: "2208",
  10316. }
  10317. customData = append(customData, custom12)
  10318. custom1212 := &CustomData{
  10319. MsgId: "H440229001582021033017351627",
  10320. PsnNo: "44020000001102481733",
  10321. Info: "2208",
  10322. }
  10323. customData = append(customData, custom1212)
  10324. custom13 := &CustomData{
  10325. MsgId: "H44022900158202103301740327951",
  10326. PsnNo: "44020000001103174866",
  10327. Info: "2208",
  10328. }
  10329. customData = append(customData, custom13)
  10330. custom14 := &CustomData{
  10331. MsgId: "H4402290015820210330174922668",
  10332. PsnNo: "44020000001102927272",
  10333. Info: "2208",
  10334. }
  10335. customData = append(customData, custom14)
  10336. custom15 := &CustomData{
  10337. MsgId: "H44022900158202103301752362273",
  10338. PsnNo: "44020000001102942890",
  10339. Info: "2208",
  10340. }
  10341. customData = append(customData, custom15)
  10342. custom16 := &CustomData{
  10343. MsgId: "H44022900158202103301751082917",
  10344. PsnNo: "44020000001101662162",
  10345. Info: "2208",
  10346. }
  10347. customData = append(customData, custom16)
  10348. custom17 := &CustomData{
  10349. MsgId: "H44022900158202103301754147728",
  10350. PsnNo: "44020000000229014511",
  10351. Info: "2208",
  10352. }
  10353. customData = append(customData, custom17)
  10354. adminUser := c.GetAdminUserInfo()
  10355. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10356. for _, item := range customData {
  10357. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10358. fmt.Println(result)
  10359. }
  10360. }
  10361. func PathExists(path string) (bool, error) {
  10362. _, err := os.Stat(path)
  10363. if err == nil {
  10364. return true, nil
  10365. }
  10366. if os.IsNotExist(err) {
  10367. return false, nil
  10368. }
  10369. return false, err
  10370. }
  10371. //创建文件夹
  10372. func Mkdir(dir string) {
  10373. // 创建文件夹
  10374. exist, err := PathExists(dir)
  10375. if err != nil {
  10376. fmt.Println(err.Error())
  10377. } else {
  10378. if exist {
  10379. fmt.Println(dir + "文件夹已存在!")
  10380. } else {
  10381. // 文件夹名称,权限
  10382. err := os.Mkdir(dir, os.ModePerm)
  10383. if err != nil {
  10384. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10385. } else {
  10386. fmt.Println(dir + "文件夹创建成功!")
  10387. }
  10388. }
  10389. }
  10390. }
  10391. //压缩文件
  10392. func Zip(srcFile string, destZip string) error {
  10393. zipfile, err := os.Create(destZip)
  10394. if err != nil {
  10395. return err
  10396. }
  10397. defer zipfile.Close()
  10398. archive := zip.NewWriter(zipfile)
  10399. defer archive.Close()
  10400. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10401. if err != nil {
  10402. return err
  10403. }
  10404. header, err := zip.FileInfoHeader(info)
  10405. if err != nil {
  10406. return err
  10407. }
  10408. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10409. // header.Name = path
  10410. if info.IsDir() {
  10411. header.Name += "/"
  10412. } else {
  10413. header.Method = zip.Deflate
  10414. }
  10415. writer, err := archive.CreateHeader(header)
  10416. if err != nil {
  10417. return err
  10418. }
  10419. if !info.IsDir() {
  10420. file, err := os.Open(path)
  10421. if err != nil {
  10422. return err
  10423. }
  10424. defer file.Close()
  10425. _, err = io.Copy(writer, file)
  10426. }
  10427. return err
  10428. })
  10429. return err
  10430. }
  10431. func ReadFile(filePath string) []byte {
  10432. f, err := os.Open(filePath)
  10433. if err != nil {
  10434. fmt.Println("read file fail", err)
  10435. return nil
  10436. }
  10437. defer f.Close()
  10438. fd, err := ioutil.ReadAll(f)
  10439. if err != nil {
  10440. fmt.Println("read to fd fail", err)
  10441. return nil
  10442. }
  10443. return fd
  10444. }
  10445. func saveLog(result string, request string, infno string, desc string) {
  10446. org_id, _ := beego.AppConfig.Int64("org_id")
  10447. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10448. dir := miConfig.OrgName + "日志"
  10449. utils.Mkdir(dir)
  10450. month := time.Unix(1557042972, 0).Format("1")
  10451. year := time.Now().Format("2006")
  10452. month = time.Now().Format("01")
  10453. day := time.Now().Format("02")
  10454. hour := time.Now().Format("15")
  10455. min := time.Now().Format("04")
  10456. sec := time.Now().Format("05")
  10457. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10458. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10459. file_name := file + ".txt"
  10460. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10461. exist, _ := utils.PathExists(file_path)
  10462. if exist { //存在
  10463. fmt.Println("存在")
  10464. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10465. if err != nil {
  10466. fmt.Println("read fail")
  10467. }
  10468. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10469. n, _ := f.Seek(0, 2)
  10470. _, err = f.WriteAt([]byte(content), n)
  10471. } else { //不存在
  10472. fmt.Println("文件不存在,创建文件")
  10473. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10474. defer f.Close()
  10475. if err != nil {
  10476. } else {
  10477. _, err = f.Write([]byte("记录日志"))
  10478. }
  10479. }
  10480. }
  10481. type Charset string
  10482. const (
  10483. UTF8 = Charset("UTF-8")
  10484. GB18030 = Charset("GB18030")
  10485. )
  10486. func ConvertToString(src string, srcCode string, tagCode string) string {
  10487. srcCoder := mahonia.NewDecoder(srcCode)
  10488. srcResult := srcCoder.ConvertString(src)
  10489. tagCoder := mahonia.NewDecoder(tagCode)
  10490. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10491. result := string(cdata)
  10492. return result
  10493. }