his_api_controller.go 457KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465
  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. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  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. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  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.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  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.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  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.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  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. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. 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 +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&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)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1082. "&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
  1083. fmt.Println(api)
  1084. } else {
  1085. 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 +
  1086. "&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)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1273. saveLog(result, requestLog, "1101", "获取人员信息")
  1274. fmt.Println(errMsgLog)
  1275. var dat map[string]interface{}
  1276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1277. fmt.Println(dat)
  1278. } else {
  1279. fmt.Println(err)
  1280. }
  1281. userJSONBytes, _ := json.Marshal(dat)
  1282. var res ResultTwo
  1283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1284. utils.ErrorLog("解析失败:%v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. res.ErrMsg = errMsgLog
  1289. if res.Infcode == 0 {
  1290. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1291. if err == gorm.ErrRecordNotFound {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1293. return
  1294. } else if err != nil {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1296. return
  1297. } else {
  1298. fmt.Println(res)
  1299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1301. infoStr := string(Iinfos)
  1302. idetinfoStr := string(Idetinfos)
  1303. psn := &models.HisPsn{
  1304. PsnNo: res.Output.Baseinfo.PsnNo,
  1305. Age: res.Output.Baseinfo.Age,
  1306. PatientId: patient.ID,
  1307. Certno: res.Output.Baseinfo.Certno,
  1308. Brdy: res.Output.Baseinfo.Brdy,
  1309. Gend: res.Output.Baseinfo.Gend,
  1310. Naty: res.Output.Baseinfo.Naty,
  1311. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1312. PsnName: res.Output.Baseinfo.PsnName,
  1313. Idetinfo: idetinfoStr,
  1314. Insuinfo: infoStr,
  1315. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1316. CardInfo: basStr,
  1317. VerifyNumber: "",
  1318. }
  1319. service.CreateHisPsn(psn)
  1320. var rf []*ResultFive
  1321. json.Unmarshal([]byte(infoStr), &rf)
  1322. var insutypes []*ResultFive
  1323. var insutype string
  1324. var is390 int = 0
  1325. var is310 int = 0
  1326. for _, item := range rf {
  1327. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1328. insutypes = append(insutypes, item)
  1329. }
  1330. }
  1331. if len(insutypes) == 1 {
  1332. insutype = insutypes[0].Insutype
  1333. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1334. } else {
  1335. for _, i := range insutypes {
  1336. if i.Insutype == "390" {
  1337. is390 = 1
  1338. }
  1339. if i.Insutype == "310" {
  1340. is310 = 1
  1341. }
  1342. }
  1343. }
  1344. if is390 == 1 {
  1345. insutype = "390"
  1346. }
  1347. if is310 == 1 {
  1348. insutype = "310"
  1349. }
  1350. if len(insutypes) == 0 {
  1351. insutype = "310"
  1352. }
  1353. c.ServeSuccessJSON(map[string]interface{}{
  1354. "patient": patient,
  1355. "number": cardnum,
  1356. "insutype": insutype,
  1357. })
  1358. }
  1359. } else {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1361. return
  1362. }
  1363. } else {
  1364. if initFlag == 0 {
  1365. c.TestGetBasBaseInit()
  1366. }
  1367. basStr := c.GetBasBaseInfo()
  1368. if len(basStr) == 0 {
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1370. return
  1371. }
  1372. fmt.Println(basStr)
  1373. bas := strings.Split(basStr, "|")
  1374. basNumber := bas[1]
  1375. fmt.Println(basNumber)
  1376. card_sn := bas[3]
  1377. fmt.Println(card_sn)
  1378. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1379. var dat map[string]interface{}
  1380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1381. fmt.Println(dat)
  1382. } else {
  1383. fmt.Println(err)
  1384. }
  1385. userJSONBytes, _ := json.Marshal(dat)
  1386. var res ResultTwo
  1387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1388. utils.ErrorLog("解析失败:%v", err)
  1389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. return
  1391. }
  1392. if res.Infcode == 0 {
  1393. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1394. if err == gorm.ErrRecordNotFound {
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1396. return
  1397. } else if err != nil {
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1399. return
  1400. } else {
  1401. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1402. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1403. infoStr := string(Iinfos)
  1404. idetinfoStr := string(Idetinfos)
  1405. psn := &models.HisPsn{
  1406. PsnNo: res.Output.Baseinfo.PsnNo,
  1407. Age: res.Output.Baseinfo.Age,
  1408. PatientId: patient.ID,
  1409. Certno: res.Output.Baseinfo.Certno,
  1410. Brdy: res.Output.Baseinfo.Brdy,
  1411. Gend: res.Output.Baseinfo.Gend,
  1412. Naty: res.Output.Baseinfo.Naty,
  1413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1414. PsnName: res.Output.Baseinfo.PsnName,
  1415. Idetinfo: idetinfoStr,
  1416. Insuinfo: infoStr,
  1417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1418. CardInfo: basStr,
  1419. VerifyNumber: "",
  1420. }
  1421. service.CreateHisPsn(psn)
  1422. c.ServeSuccessJSON(map[string]interface{}{
  1423. "patient": patient,
  1424. "number": basNumber,
  1425. })
  1426. }
  1427. } else {
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1429. return
  1430. }
  1431. break
  1432. }
  1433. case 2:
  1434. SFZStr := c.GetSFZBaseInfo()
  1435. id_card_str := strings.Split(SFZStr, "^")
  1436. id_card_number := id_card_str[0]
  1437. card_sn := ""
  1438. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1439. var dat map[string]interface{}
  1440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1441. fmt.Println(dat)
  1442. } else {
  1443. fmt.Println(err)
  1444. }
  1445. userJSONBytes, _ := json.Marshal(dat)
  1446. var res ResultTwo
  1447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1448. utils.ErrorLog("解析失败:%v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. if res.Infcode == 0 {
  1453. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1454. if err == gorm.ErrRecordNotFound {
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1456. return
  1457. } else if err != nil {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1459. return
  1460. } else {
  1461. c.ServeSuccessJSON(map[string]interface{}{
  1462. "patient": patient,
  1463. "number": id_card_number,
  1464. })
  1465. }
  1466. } else {
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1468. return
  1469. }
  1470. break
  1471. case 3:
  1472. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1473. var api string
  1474. if miConfig.MdtrtareaAdmvs == "320921" {
  1475. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1476. "&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
  1477. fmt.Println(api)
  1478. } else {
  1479. 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 +
  1480. "&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)
  1481. }
  1482. resp, requestErr := http.Get(api)
  1483. if requestErr != nil {
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1485. return
  1486. }
  1487. body, ioErr := ioutil.ReadAll(resp.Body)
  1488. if ioErr != nil {
  1489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. return
  1492. }
  1493. var respJSON map[string]interface{}
  1494. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. var status string
  1500. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1501. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1502. var token string
  1503. var res ResultTwo //1101结果
  1504. var res10265 ResultTwo10265 //1101结果
  1505. var card_info string //卡信息
  1506. var busi_card_info string
  1507. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1508. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1509. if status == "0" { //读卡成功
  1510. if card_type == "1" {
  1511. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1512. result, _ := json.Marshal(respJSON)
  1513. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1514. utils.ErrorLog("解析失败:%v", err)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. res.ErrMsg = res10265.ErrMsg
  1519. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1520. res.Infcode = infocode
  1521. res.Output = res10265.Output
  1522. res.InfRefmsgid = res10265.InfRefmsgid
  1523. } else {
  1524. //var card_info string //卡信息
  1525. //var busi_card_info string
  1526. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1527. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1528. //fmt.Println(card_info)
  1529. //fmt.Println(busi_card_info)
  1530. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1531. result, _ := json.Marshal(respJSON)
  1532. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1533. utils.ErrorLog("解析失败:%v", err)
  1534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1535. return
  1536. }
  1537. res.ErrMsg = res10265.ErrMsg
  1538. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1539. res.Infcode = infocode
  1540. res.Output = res10265.Output
  1541. res.InfRefmsgid = res10265.InfRefmsgid
  1542. }
  1543. if res.Infcode == 0 {
  1544. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1545. if err == gorm.ErrRecordNotFound {
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1547. return
  1548. } else if err != nil {
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1550. return
  1551. } else {
  1552. if card_type == "1" {
  1553. bas := strings.Split(card_info, "|")
  1554. basNumber := bas[2]
  1555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1557. infoStr := string(Iinfos)
  1558. idetinfoStr := string(Idetinfos)
  1559. psn := &models.HisPsn{
  1560. PsnNo: res.Output.Baseinfo.PsnNo,
  1561. Age: res.Output.Baseinfo.Age,
  1562. PatientId: patient.ID,
  1563. Certno: res.Output.Baseinfo.Certno,
  1564. Brdy: res.Output.Baseinfo.Brdy,
  1565. Gend: res.Output.Baseinfo.Gend,
  1566. Naty: res.Output.Baseinfo.Naty,
  1567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1568. PsnName: res.Output.Baseinfo.PsnName,
  1569. Idetinfo: idetinfoStr,
  1570. Insuinfo: infoStr,
  1571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1572. CardInfo: card_info,
  1573. VerifyNumber: busi_card_info,
  1574. }
  1575. service.CreateHisPsn(psn)
  1576. c.ServeSuccessJSON(map[string]interface{}{
  1577. "patient": patient,
  1578. "number": basNumber,
  1579. })
  1580. } else {
  1581. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1582. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1583. infoStr := string(Iinfos)
  1584. idetinfoStr := string(Idetinfos)
  1585. psn := &models.HisPsn{
  1586. PsnNo: res.Output.Baseinfo.PsnNo,
  1587. Age: res.Output.Baseinfo.Age,
  1588. PatientId: patient.ID,
  1589. Certno: res.Output.Baseinfo.Certno,
  1590. Brdy: res.Output.Baseinfo.Brdy,
  1591. Gend: res.Output.Baseinfo.Gend,
  1592. Naty: res.Output.Baseinfo.Naty,
  1593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1594. PsnName: res.Output.Baseinfo.PsnName,
  1595. Idetinfo: idetinfoStr,
  1596. Insuinfo: infoStr,
  1597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1598. CardInfo: card_info,
  1599. VerifyNumber: token,
  1600. }
  1601. service.CreateHisPsn(psn)
  1602. var rf []*ResultFive
  1603. json.Unmarshal([]byte(infoStr), &rf)
  1604. var insutypes []*ResultFive
  1605. var insutype string
  1606. var is390 int = 0
  1607. var is310 int = 0
  1608. for _, item := range rf {
  1609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1610. insutypes = append(insutypes, item)
  1611. }
  1612. }
  1613. if len(insutypes) == 1 {
  1614. insutype = insutypes[0].Insutype
  1615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1616. } else {
  1617. for _, i := range insutypes {
  1618. if i.Insutype == "390" {
  1619. is390 = 1
  1620. }
  1621. if i.Insutype == "310" {
  1622. is310 = 1
  1623. }
  1624. }
  1625. }
  1626. if is390 == 1 {
  1627. insutype = "390"
  1628. }
  1629. if is310 == 1 {
  1630. insutype = "310"
  1631. }
  1632. if len(insutypes) == 0 {
  1633. insutype = "310"
  1634. }
  1635. c.ServeSuccessJSON(map[string]interface{}{
  1636. "patient": patient,
  1637. "number": token,
  1638. "insutype": insutype,
  1639. })
  1640. }
  1641. }
  1642. } else {
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1644. return
  1645. }
  1646. } else { //读卡失败
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1648. return
  1649. }
  1650. }
  1651. break
  1652. case 4:
  1653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1654. var api string
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1657. "&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
  1658. fmt.Println(api)
  1659. } else {
  1660. 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 +
  1661. "&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)
  1662. }
  1663. resp, requestErr := http.Get(api)
  1664. if requestErr != nil {
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. body, ioErr := ioutil.ReadAll(resp.Body)
  1669. if ioErr != nil {
  1670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. return
  1673. }
  1674. var respJSON map[string]interface{}
  1675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1678. return
  1679. }
  1680. var status string
  1681. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1682. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1683. var token string
  1684. var res ResultTwo //1101结果
  1685. var res10265 ResultTwo10265 //1101结果
  1686. if status == "0" { //读卡成功
  1687. var card_info string //卡信息
  1688. var busi_card_info string
  1689. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1690. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1691. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1692. fmt.Println(card_info)
  1693. fmt.Println(busi_card_info)
  1694. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1695. result, _ := json.Marshal(respJSON)
  1696. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1697. utils.ErrorLog("解析失败:%v", err)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. return
  1700. }
  1701. res.ErrMsg = res10265.ErrMsg
  1702. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1703. res.Infcode = infocode
  1704. res.Output = res10265.Output
  1705. res.InfRefmsgid = res10265.InfRefmsgid
  1706. if res.Infcode == 0 {
  1707. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1708. if err == gorm.ErrRecordNotFound {
  1709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1710. return
  1711. } else if err != nil {
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1713. return
  1714. } else {
  1715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1717. infoStr := string(Iinfos)
  1718. idetinfoStr := string(Idetinfos)
  1719. psn := &models.HisPsn{
  1720. PsnNo: res.Output.Baseinfo.PsnNo,
  1721. Age: res.Output.Baseinfo.Age,
  1722. PatientId: patient.ID,
  1723. Certno: res.Output.Baseinfo.Certno,
  1724. Brdy: res.Output.Baseinfo.Brdy,
  1725. Gend: res.Output.Baseinfo.Gend,
  1726. Naty: res.Output.Baseinfo.Naty,
  1727. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1728. PsnName: res.Output.Baseinfo.PsnName,
  1729. Idetinfo: idetinfoStr,
  1730. Insuinfo: infoStr,
  1731. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1732. CardInfo: card_info,
  1733. VerifyNumber: token,
  1734. }
  1735. service.CreateHisPsn(psn)
  1736. c.ServeSuccessJSON(map[string]interface{}{
  1737. "patient": patient,
  1738. "number": token,
  1739. })
  1740. }
  1741. } else {
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1743. return
  1744. }
  1745. } else { //读卡失败
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1747. return
  1748. }
  1749. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1750. }
  1751. break
  1752. }
  1753. }
  1754. var initFlag int64 = 0
  1755. func (c *HisApiController) TestGetBasBaseInit() {
  1756. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1757. Iinit := DllDef.MustFindProc("Init")
  1758. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1759. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1760. if ret != 0 {
  1761. fmt.Println("SSCard的报错原因:", err)
  1762. fmt.Println("SSCard的运算结果为:", ret)
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1764. return
  1765. }
  1766. result := int(ret)
  1767. fmt.Println("SSCard的运算结果为1:", result)
  1768. initFlag = 1
  1769. return
  1770. }
  1771. func (c *HisApiController) GetSFZBaseInfo() string {
  1772. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1773. readCard := DllDef.MustFindProc("ReadSFZ")
  1774. if readCard == nil {
  1775. fmt.Println("readcard is nil")
  1776. readCard = DllDef.MustFindProc("ReadSFZ")
  1777. }
  1778. str := make([]byte, 256)
  1779. str1 := make([]byte, 256)
  1780. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1781. fmt.Println(r)
  1782. return string(str)
  1783. }
  1784. func (c *HisApiController) GetBasBaseInfo() string {
  1785. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1786. readCard := DllDef.MustFindProc("ReadCardBas")
  1787. if readCard == nil {
  1788. fmt.Println("readcard is nil")
  1789. readCard = DllDef.MustFindProc("ReadCardBas")
  1790. }
  1791. str := make([]byte, 1024)
  1792. str1 := make([]byte, 1024)
  1793. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1794. fmt.Println(string(str1))
  1795. fmt.Println(string(str))
  1796. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1797. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1798. if ret2 != 0 {
  1799. return ""
  1800. }
  1801. return string(str)
  1802. }
  1803. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1804. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1805. readCard := DllDef.MustFindProc("read_cardinfo")
  1806. if readCard == nil {
  1807. fmt.Println("readcard is nil")
  1808. readCard = DllDef.MustFindProc("read_cardinfo")
  1809. }
  1810. str := make([]byte, 1024) //卡号
  1811. str1 := make([]byte, 1024) //卡识别码
  1812. str2 := make([]byte, 1024) //身份证号
  1813. str3 := make([]byte, 1024) //姓名
  1814. str4 := make([]byte, 1024) //错误信息
  1815. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1816. fmt.Println(string(str1))
  1817. fmt.Println(string(str))
  1818. fmt.Println(string(str2))
  1819. fmt.Println(string(str3))
  1820. fmt.Println(string(str4))
  1821. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1822. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1823. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1824. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1825. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1826. if ret2 != 0 {
  1827. return "", "", "", "", ""
  1828. }
  1829. return string(str), string(str1), string(str2), string(str3), string(str4)
  1830. }
  1831. type CustomFundPay struct {
  1832. FundPayType string `json:"fund_pay_type"`
  1833. FundPayamt float64 `json:"fund_payamt"`
  1834. }
  1835. func (c *HisApiController) GetSettleList() {
  1836. order_id, _ := c.GetInt64("order_id")
  1837. admin_user_id, _ := c.GetInt64("admin_user_id")
  1838. order, _ := service.GetHisOrderByIDTwo(order_id)
  1839. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1840. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1841. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1842. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1843. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1845. if order.ID == 0 {
  1846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1847. return
  1848. }
  1849. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1850. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1851. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1852. fmt.Println(count)
  1853. var zero string
  1854. number := count + 1
  1855. if number >= 1000 {
  1856. zero = "0000" + strconv.FormatInt(number, 10)
  1857. } else if number >= 10000 {
  1858. zero = "000" + strconv.FormatInt(number, 10)
  1859. } else if number >= 100000 {
  1860. zero = "00" + strconv.FormatInt(number, 10)
  1861. } else if number >= 1000000 {
  1862. zero = "0" + strconv.FormatInt(number, 10)
  1863. } else {
  1864. zero = strconv.FormatInt(number, 10)
  1865. }
  1866. fmt.Println(zero)
  1867. struct4101 := service.Struct4101{
  1868. PsnNo: order.PsnNo,
  1869. MdtrtId: order.MdtrtId,
  1870. SetlId: order.SetlId,
  1871. PsnName: order.PsnName,
  1872. Gend: order.Gend,
  1873. Brdy: his.Brdy,
  1874. Age: his.Age,
  1875. Naty: order.Naty,
  1876. PatnCertType: "01",
  1877. Certno: order.Certno,
  1878. Prfs: "90",
  1879. ConerName: roles[0].UserName,
  1880. PatnRlts: "99",
  1881. ConerAddr: miConfig.OrgName,
  1882. ConerTel: admin.Mobile,
  1883. HiType: order.Insutype,
  1884. Insuplc: miConfig.InsuplcAdmdvs,
  1885. MaindiagFlag: "1",
  1886. BillCode: last_order.FaPiaoCode,
  1887. BillNo: zero,
  1888. BizSn: order.Number,
  1889. PsnSelfPay: order.PsnPartAmt,
  1890. PsnOwnPay: order.PsnPartAmt,
  1891. AcctPay: order.AcctPay,
  1892. PsnCashpay: order.PsnCashPay,
  1893. HiPaymtd: "1",
  1894. Hsorg: miConfig.InsuplcAdmdvs,
  1895. HsorgOpter: miConfig.InsuplcAdmdvs,
  1896. MedinsFillPsn: curRoles.UserName,
  1897. MedinsFillDept: depart.Name,
  1898. IptMedType: "2",
  1899. }
  1900. struct4101.SetlBegnDate = order.SetlTime
  1901. struct4101.SetlEndDate = order.SetlTime
  1902. time_arr := strings.Split(order.SetlTime, " ")
  1903. struct4101.AdmTime = time_arr[0]
  1904. struct4101.AdmEndTime = time_arr[0]
  1905. var rf []CustomFundPay
  1906. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1907. var tempFunPays []service.CustomStruct
  1908. for _, item := range rf {
  1909. var tempFunPay service.CustomStruct
  1910. tempFunPay.FundPayamt = item.FundPayamt
  1911. tempFunPay.FundPayType = item.FundPayType
  1912. tempFunPays = append(tempFunPays, tempFunPay)
  1913. }
  1914. struct4101.CustomStruct = tempFunPays
  1915. var tempDiaginfos []service.DiaginfoStructTwo
  1916. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1917. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1918. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1919. var config []*models.HisXtDiagnoseConfig
  1920. for _, item := range diagnosis_ids {
  1921. id, _ := strconv.ParseInt(item, 10, 64)
  1922. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1923. config = append(config, &diagnosisConfig)
  1924. }
  1925. for index, item := range config {
  1926. if index == 0 {
  1927. var tempDiaginfo service.DiaginfoStructTwo
  1928. tempDiaginfo.DiagCode = item.CountryCode
  1929. tempDiaginfo.DiagName = item.CountryContentName
  1930. tempDiaginfo.DiagType = "1"
  1931. tempDiaginfo.MaindiagFlag = "1"
  1932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1933. } else {
  1934. var tempDiaginfo service.DiaginfoStructTwo
  1935. tempDiaginfo.DiagCode = item.CountryCode
  1936. tempDiaginfo.DiagName = item.CountryContentName
  1937. tempDiaginfo.DiagType = "2"
  1938. tempDiaginfo.MaindiagFlag = "0"
  1939. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1940. }
  1941. }
  1942. struct4101.Diseinfo = tempDiaginfos
  1943. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1944. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1945. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1946. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1947. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1948. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1949. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1950. var iteminfo service.IteminfoStruct
  1951. var bedCostTotal float64 = 0 //床位总费
  1952. var bedCostSelfTotal float64 = 0 //床位自费
  1953. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1954. var operationCostTotal float64 = 0 //手术费
  1955. var operationCostSelfTotal float64 = 0 //手术费
  1956. var operationCostPartSelfTotal float64 = 0 //手术费
  1957. var otherCostTotal float64 = 0 //其他费用
  1958. var otherCostSelfTotal float64 = 0 //其他费用
  1959. var otherCostPartSelfTotal float64 = 0 //其他费用
  1960. var materialCostTotal float64 = 0 //材料费
  1961. var materialCostSelfTotal float64 = 0 //材料费
  1962. var materialCostPartSelfTotal float64 = 0 //材料费
  1963. var westernMedicineCostTotal float64 = 0 //西药费
  1964. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1965. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1966. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1967. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1968. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1969. var checkCostTotal float64 = 0 //检查费
  1970. var checkCostSelfTotal float64 = 0 //检查费
  1971. var checkCostPartSelfTotal float64 = 0 //检查费
  1972. var laboratoryCostTotal float64 = 0 //化验费
  1973. var laboratoryCostSelfTotal float64 = 0 //化验费
  1974. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1975. var treatCostTotal float64 = 0 //治疗费用
  1976. var treatCostSelfTotal float64 = 0 //治疗费用
  1977. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1978. decimal.DivisionPrecision = 2
  1979. var bed_fulamt_ownpay_amt float64 = 0
  1980. var operation_fulamt_ownpay_amt float64 = 0
  1981. var other_fulamt_ownpay_amt float64 = 0
  1982. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1983. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1984. var check_fulamt_ownpay_amt float64 = 0
  1985. var material_fulamt_ownpay_amt float64 = 0
  1986. var laboratory_fulamt_ownpay_amt float64 = 0
  1987. var treat_fulamt_ownpay_amt float64 = 0
  1988. var bed_claa_sunmfee float64 = 0
  1989. var bed_clab_amt float64 = 0
  1990. var bed_other_amt float64 = 0
  1991. var operation_claa_sunmfee float64 = 0
  1992. var operation_clab_amt float64 = 0
  1993. var operation_other_amt float64 = 0
  1994. var other_claa_sunmfee float64 = 0
  1995. var other_clab_amt float64 = 0
  1996. var other_other_amt float64 = 0
  1997. var westernMedicine_claa_sunmfee float64 = 0
  1998. var westernMedicine_clab_amt float64 = 0
  1999. var westernMedicine_other_amt float64 = 0
  2000. var chineseTraditional_claa_sunmfee float64 = 0
  2001. var chineseTraditional_clab_amt float64 = 0
  2002. var chineseTraditional_other_amt float64 = 0
  2003. var check_claa_sunmfee float64 = 0
  2004. var check_clab_amt float64 = 0
  2005. var check_other_amt float64 = 0
  2006. var material_claa_sunmfee float64 = 0
  2007. var material_clab_amt float64 = 0
  2008. var material_other_amt float64 = 0
  2009. var laboratory_claa_sunmfee float64 = 0
  2010. var laboratory_clab_amt float64 = 0
  2011. var laboratory_other_amt float64 = 0
  2012. var treat_claa_sunmfee float64 = 0
  2013. var treat_clab_amt float64 = 0
  2014. var treat_other_amt float64 = 0
  2015. for _, item := range order.HisOrderInfo {
  2016. if item.MedChrgitmType == "01" { //床位费
  2017. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2018. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2019. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2020. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2021. if item.ChrgitmLv == "1" {
  2022. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2023. }
  2024. if item.ChrgitmLv == "2" {
  2025. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2026. }
  2027. if item.ChrgitmLv == "3" {
  2028. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2029. }
  2030. }
  2031. if item.MedChrgitmType == "03" { //检查费
  2032. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2033. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2034. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2035. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2036. if item.ChrgitmLv == "1" {
  2037. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2038. }
  2039. if item.ChrgitmLv == "2" {
  2040. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2041. }
  2042. if item.ChrgitmLv == "3" {
  2043. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2044. }
  2045. }
  2046. if item.MedChrgitmType == "04" { //化验费
  2047. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2048. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2049. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2050. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2051. if item.ChrgitmLv == "1" {
  2052. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2053. }
  2054. if item.ChrgitmLv == "2" {
  2055. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2056. }
  2057. if item.ChrgitmLv == "3" {
  2058. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2059. }
  2060. }
  2061. if item.MedChrgitmType == "05" { //治疗费
  2062. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2063. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2064. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2065. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2066. if item.ChrgitmLv == "1" {
  2067. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2068. }
  2069. if item.ChrgitmLv == "2" {
  2070. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2071. }
  2072. if item.ChrgitmLv == "3" {
  2073. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2074. }
  2075. }
  2076. if item.MedChrgitmType == "06" { //手术费
  2077. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2078. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2079. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2080. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2081. if item.ChrgitmLv == "1" {
  2082. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2083. }
  2084. if item.ChrgitmLv == "2" {
  2085. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2086. }
  2087. if item.ChrgitmLv == "3" {
  2088. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2089. }
  2090. }
  2091. if item.MedChrgitmType == "08" { //材料费
  2092. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2093. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2094. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2095. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2096. if item.ChrgitmLv == "1" {
  2097. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2098. }
  2099. if item.ChrgitmLv == "2" {
  2100. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2101. }
  2102. if item.ChrgitmLv == "3" {
  2103. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2104. }
  2105. }
  2106. if item.MedChrgitmType == "09" { //西药费
  2107. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2108. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2109. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2110. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2111. if item.ChrgitmLv == "1" {
  2112. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2113. }
  2114. if item.ChrgitmLv == "2" {
  2115. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2116. }
  2117. if item.ChrgitmLv == "3" {
  2118. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2119. }
  2120. }
  2121. if item.MedChrgitmType == "11" { //中成费
  2122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2126. if item.ChrgitmLv == "1" {
  2127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2128. }
  2129. if item.ChrgitmLv == "2" {
  2130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2131. }
  2132. if item.ChrgitmLv == "3" {
  2133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2134. }
  2135. }
  2136. if item.MedChrgitmType == "14" { //其他费
  2137. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2138. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2139. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2141. if item.ChrgitmLv == "1" {
  2142. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2143. }
  2144. if item.ChrgitmLv == "2" {
  2145. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2146. }
  2147. if item.ChrgitmLv == "3" {
  2148. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2149. }
  2150. }
  2151. }
  2152. var iteminfoStructs []service.IteminfoStruct
  2153. if bedCostTotal != 0 {
  2154. iteminfo.MedChrgitm = "01"
  2155. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2156. iteminfo.Amt = bedCostTotal
  2157. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2158. iteminfo.ClabAmt = bed_clab_amt
  2159. iteminfo.OthAmt = bed_other_amt
  2160. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2161. }
  2162. if checkCostTotal != 0 {
  2163. iteminfo.MedChrgitm = "03"
  2164. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2165. iteminfo.Amt = checkCostTotal
  2166. iteminfo.ClaaSumfee = check_claa_sunmfee
  2167. iteminfo.ClabAmt = check_clab_amt
  2168. iteminfo.OthAmt = check_other_amt
  2169. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2170. }
  2171. if laboratoryCostTotal != 0 {
  2172. iteminfo.MedChrgitm = "04"
  2173. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2174. iteminfo.Amt = laboratoryCostTotal
  2175. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2176. iteminfo.ClabAmt = laboratory_clab_amt
  2177. iteminfo.OthAmt = laboratory_other_amt
  2178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2180. }
  2181. if treatCostTotal != 0 {
  2182. iteminfo.MedChrgitm = "05"
  2183. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2184. iteminfo.Amt = treatCostTotal
  2185. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2186. iteminfo.ClabAmt = treat_clab_amt
  2187. iteminfo.OthAmt = treat_other_amt
  2188. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2189. //(struct4101.IteminfoStruct, iteminfo)
  2190. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2191. }
  2192. if operationCostTotal != 0 {
  2193. iteminfo.MedChrgitm = "06"
  2194. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2195. iteminfo.Amt = operationCostTotal
  2196. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2197. iteminfo.ClabAmt = operation_clab_amt
  2198. iteminfo.OthAmt = operation_other_amt
  2199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2201. }
  2202. if materialCostTotal != 0 {
  2203. iteminfo.MedChrgitm = "08"
  2204. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2205. iteminfo.Amt = materialCostTotal
  2206. iteminfo.ClaaSumfee = material_claa_sunmfee
  2207. iteminfo.ClabAmt = material_clab_amt
  2208. iteminfo.OthAmt = material_other_amt
  2209. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2211. }
  2212. if westernMedicineCostTotal != 0 {
  2213. iteminfo.MedChrgitm = "09"
  2214. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2215. iteminfo.Amt = westernMedicineCostTotal
  2216. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2217. iteminfo.ClabAmt = westernMedicine_clab_amt
  2218. iteminfo.OthAmt = westernMedicine_other_amt
  2219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2221. }
  2222. if chineseTraditionalMedicineCostTotal != 0 {
  2223. iteminfo.MedChrgitm = "11"
  2224. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2225. iteminfo.Amt = westernMedicineCostTotal
  2226. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2227. iteminfo.ClabAmt = westernMedicine_clab_amt
  2228. iteminfo.OthAmt = westernMedicine_other_amt
  2229. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2230. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2231. }
  2232. if otherCostTotal != 0 {
  2233. iteminfo.MedChrgitm = "14"
  2234. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2235. iteminfo.Amt = otherCostTotal
  2236. iteminfo.ClaaSumfee = other_claa_sunmfee
  2237. iteminfo.ClabAmt = other_clab_amt
  2238. iteminfo.OthAmt = other_other_amt
  2239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2241. }
  2242. struct4101.IteminfoStruct = iteminfoStructs
  2243. struct4101.Ntly = "中国"
  2244. struct4101.AdmCaty = "A03.06"
  2245. var res ResultSeventeen
  2246. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2247. var resOther ResultSeventeenOther
  2248. var pp models.PublicParams
  2249. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2251. pp.FixmedinsName = miConfig.OrgName
  2252. pp.FixmedinsCode = miConfig.Code
  2253. pp.RequestUrl = miConfig.Url
  2254. pp.Cainfo = miConfig.Cainfo
  2255. pp.SecretKey = miConfig.SecretKey
  2256. pp.AccessKey = miConfig.AccessKey
  2257. pp.OpterName = curRoles.UserName
  2258. client := &http.Client{}
  2259. var req *http.Request
  2260. data := make(map[string]interface{})
  2261. data["struct4101"] = struct4101
  2262. data["pp"] = pp
  2263. bytesData, _ := json.Marshal(data)
  2264. if miConfig.MdtrtareaAdmvs == "320921" {
  2265. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2266. } else {
  2267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2268. }
  2269. resp, _ := client.Do(req)
  2270. defer resp.Body.Close()
  2271. body, ioErr := ioutil.ReadAll(resp.Body)
  2272. if ioErr != nil {
  2273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. var respJSON map[string]interface{}
  2278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. return
  2282. }
  2283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2284. userJSONBytes, _ := json.Marshal(respJSON)
  2285. fmt.Println("log")
  2286. fmt.Println(string(userJSONBytes))
  2287. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2288. utils.ErrorLog("解析失败:%v", err)
  2289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. return
  2291. }
  2292. res.InfRefmsgid = resOther.InfRefmsgid
  2293. res.Output = resOther.Output
  2294. res.ErrMsg = resOther.ErrMsg
  2295. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2296. res.Infcode = infocode
  2297. } else {
  2298. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2299. var dat map[string]interface{}
  2300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2301. fmt.Println(dat)
  2302. } else {
  2303. fmt.Println(err)
  2304. }
  2305. userJSONBytes, _ := json.Marshal(dat)
  2306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2307. utils.ErrorLog("解析失败:%v", err)
  2308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2309. return
  2310. }
  2311. }
  2312. if res.Infcode != 0 {
  2313. c.ServeSuccessJSON(map[string]interface{}{
  2314. "failed_code": -10,
  2315. "msg": res.ErrMsg,
  2316. })
  2317. return
  2318. } else {
  2319. order.FaPiaoNumber = zero
  2320. order.FaPiaoCode = last_order.FaPiaoCode
  2321. service.UpdateOrder(order)
  2322. hisFundSettleListResult := &models.HisFundSettleListResult{
  2323. Number: res.Output.SetlListId,
  2324. Status: 1,
  2325. Ctime: time.Now().Unix(),
  2326. Mtime: time.Now().Unix(),
  2327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2328. IsUpload: 1,
  2329. OrderId: order_id,
  2330. }
  2331. service.CreateUploadRecord(hisFundSettleListResult)
  2332. c.ServeSuccessJSON(map[string]interface{}{
  2333. "msg": "上传成功",
  2334. "result": hisFundSettleListResult,
  2335. })
  2336. return
  2337. }
  2338. }
  2339. func (c *HisApiController) GetSettleListHospital() {
  2340. order_id, _ := c.GetInt64("order_id")
  2341. admin_user_id, _ := c.GetInt64("admin_user_id")
  2342. order, _ := service.GetHisOrderByIDTwo(order_id)
  2343. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2344. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2345. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2346. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2347. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2348. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2349. if order.ID == 0 {
  2350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2351. return
  2352. }
  2353. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2354. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2355. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2356. fmt.Println(count)
  2357. var zero string
  2358. number := count + 1
  2359. if number >= 1000 {
  2360. zero = "0000" + strconv.FormatInt(number, 10)
  2361. } else if number >= 10000 {
  2362. zero = "000" + strconv.FormatInt(number, 10)
  2363. } else if number >= 100000 {
  2364. zero = "00" + strconv.FormatInt(number, 10)
  2365. } else if number >= 1000000 {
  2366. zero = "0" + strconv.FormatInt(number, 10)
  2367. } else {
  2368. zero = strconv.FormatInt(number, 10)
  2369. }
  2370. fmt.Println(zero)
  2371. struct4101 := service.Struct4101{
  2372. PsnNo: order.PsnNo,
  2373. MdtrtId: order.MdtrtId,
  2374. SetlId: order.SetlId,
  2375. PsnName: order.PsnName,
  2376. Gend: order.Gend,
  2377. Brdy: his.Brdy,
  2378. Age: int64(order.Age),
  2379. Naty: order.Naty,
  2380. PatnCertType: "01",
  2381. Certno: order.Certno,
  2382. Prfs: "90",
  2383. ConerName: roles[0].UserName,
  2384. PatnRlts: "99",
  2385. ConerAddr: miConfig.OrgName,
  2386. ConerTel: admin.Mobile,
  2387. HiType: order.Insutype,
  2388. Insuplc: miConfig.InsuplcAdmdvs,
  2389. MaindiagFlag: "1",
  2390. BillCode: last_order.FaPiaoCode,
  2391. BillNo: zero,
  2392. BizSn: order.Number,
  2393. PsnSelfPay: order.PsnPartAmt,
  2394. PsnOwnPay: order.PsnPartAmt,
  2395. AcctPay: order.AcctPay,
  2396. PsnCashpay: order.PsnCashPay,
  2397. HiPaymtd: "1",
  2398. Hsorg: miConfig.InsuplcAdmdvs,
  2399. HsorgOpter: miConfig.InsuplcAdmdvs,
  2400. MedinsFillPsn: curRoles.UserName,
  2401. MedinsFillDept: depart.Name,
  2402. IptMedType: "2",
  2403. AdmTime: his.InHosptialTime,
  2404. AdmEndTime: his.OutHosptialTime,
  2405. }
  2406. struct4101.SetlBegnDate = order.SetlTime
  2407. struct4101.SetlEndDate = order.SetlTime
  2408. var rf []CustomFundPay
  2409. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2410. var tempFunPays []service.CustomStruct
  2411. for _, item := range rf {
  2412. var tempFunPay service.CustomStruct
  2413. tempFunPay.FundPayamt = item.FundPayamt
  2414. tempFunPay.FundPayType = item.FundPayType
  2415. tempFunPays = append(tempFunPays, tempFunPay)
  2416. }
  2417. struct4101.CustomStruct = tempFunPays
  2418. var tempDiaginfos []service.DiaginfoStructTwo
  2419. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2420. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2421. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2422. var config []*models.HisXtDiagnoseConfig
  2423. for _, item := range diagnosis_ids {
  2424. id, _ := strconv.ParseInt(item, 10, 64)
  2425. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2426. config = append(config, &diagnosisConfig)
  2427. }
  2428. for index, item := range config {
  2429. if index == 0 {
  2430. var tempDiaginfo service.DiaginfoStructTwo
  2431. tempDiaginfo.DiagCode = item.CountryCode
  2432. tempDiaginfo.DiagName = item.CountryContentName
  2433. tempDiaginfo.DiagType = "1"
  2434. tempDiaginfo.MaindiagFlag = "1"
  2435. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2436. } else {
  2437. var tempDiaginfo service.DiaginfoStructTwo
  2438. tempDiaginfo.DiagCode = item.CountryCode
  2439. tempDiaginfo.DiagName = item.CountryContentName
  2440. tempDiaginfo.DiagType = "2"
  2441. tempDiaginfo.MaindiagFlag = "0"
  2442. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2443. }
  2444. }
  2445. struct4101.Diseinfo = tempDiaginfos
  2446. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2447. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2448. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2449. tempOpspdiseinfo2.OprnOprtCode = ""
  2450. tempOpspdiseinfo2.OprnOprtName = ""
  2451. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2452. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2453. var iteminfo service.IteminfoStruct
  2454. var bedCostTotal float64 = 0 //床位总费
  2455. var bedCostSelfTotal float64 = 0 //床位自费
  2456. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2457. var operationCostTotal float64 = 0 //手术费
  2458. var operationCostSelfTotal float64 = 0 //手术费
  2459. var operationCostPartSelfTotal float64 = 0 //手术费
  2460. var otherCostTotal float64 = 0 //其他费用
  2461. var otherCostSelfTotal float64 = 0 //其他费用
  2462. var otherCostPartSelfTotal float64 = 0 //其他费用
  2463. var materialCostTotal float64 = 0 //材料费
  2464. var materialCostSelfTotal float64 = 0 //材料费
  2465. var materialCostPartSelfTotal float64 = 0 //材料费
  2466. var westernMedicineCostTotal float64 = 0 //西药费
  2467. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2468. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2469. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2470. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2471. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2472. var checkCostTotal float64 = 0 //检查费
  2473. var checkCostSelfTotal float64 = 0 //检查费
  2474. var checkCostPartSelfTotal float64 = 0 //检查费
  2475. var laboratoryCostTotal float64 = 0 //化验费
  2476. var laboratoryCostSelfTotal float64 = 0 //化验费
  2477. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2478. var treatCostTotal float64 = 0 //治疗费用
  2479. var treatCostSelfTotal float64 = 0 //治疗费用
  2480. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2481. decimal.DivisionPrecision = 2
  2482. var bed_fulamt_ownpay_amt float64 = 0
  2483. var operation_fulamt_ownpay_amt float64 = 0
  2484. var other_fulamt_ownpay_amt float64 = 0
  2485. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2486. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2487. var check_fulamt_ownpay_amt float64 = 0
  2488. var material_fulamt_ownpay_amt float64 = 0
  2489. var laboratory_fulamt_ownpay_amt float64 = 0
  2490. var treat_fulamt_ownpay_amt float64 = 0
  2491. var bed_claa_sunmfee float64 = 0
  2492. var bed_clab_amt float64 = 0
  2493. var bed_other_amt float64 = 0
  2494. var operation_claa_sunmfee float64 = 0
  2495. var operation_clab_amt float64 = 0
  2496. var operation_other_amt float64 = 0
  2497. var other_claa_sunmfee float64 = 0
  2498. var other_clab_amt float64 = 0
  2499. var other_other_amt float64 = 0
  2500. var westernMedicine_claa_sunmfee float64 = 0
  2501. var westernMedicine_clab_amt float64 = 0
  2502. var westernMedicine_other_amt float64 = 0
  2503. var chineseTraditional_claa_sunmfee float64 = 0
  2504. var chineseTraditional_clab_amt float64 = 0
  2505. var chineseTraditional_other_amt float64 = 0
  2506. var check_claa_sunmfee float64 = 0
  2507. var check_clab_amt float64 = 0
  2508. var check_other_amt float64 = 0
  2509. var material_claa_sunmfee float64 = 0
  2510. var material_clab_amt float64 = 0
  2511. var material_other_amt float64 = 0
  2512. var laboratory_claa_sunmfee float64 = 0
  2513. var laboratory_clab_amt float64 = 0
  2514. var laboratory_other_amt float64 = 0
  2515. var treat_claa_sunmfee float64 = 0
  2516. var treat_clab_amt float64 = 0
  2517. var treat_other_amt float64 = 0
  2518. for _, item := range order.HisOrderInfo {
  2519. if item.MedChrgitmType == "01" { //床位费
  2520. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2521. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2522. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2523. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2524. if item.ChrgitmLv == "1" {
  2525. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2526. }
  2527. if item.ChrgitmLv == "2" {
  2528. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2529. }
  2530. if item.ChrgitmLv == "3" {
  2531. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2532. }
  2533. }
  2534. if item.MedChrgitmType == "03" { //检查费
  2535. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2536. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2537. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2538. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2539. if item.ChrgitmLv == "1" {
  2540. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2541. }
  2542. if item.ChrgitmLv == "2" {
  2543. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2544. }
  2545. if item.ChrgitmLv == "3" {
  2546. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2547. }
  2548. }
  2549. if item.MedChrgitmType == "04" { //化验费
  2550. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2551. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2552. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2553. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2554. if item.ChrgitmLv == "1" {
  2555. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2556. }
  2557. if item.ChrgitmLv == "2" {
  2558. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2559. }
  2560. if item.ChrgitmLv == "3" {
  2561. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2562. }
  2563. }
  2564. if item.MedChrgitmType == "05" { //治疗费
  2565. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2566. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2567. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2568. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2569. if item.ChrgitmLv == "1" {
  2570. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2571. }
  2572. if item.ChrgitmLv == "2" {
  2573. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2574. }
  2575. if item.ChrgitmLv == "3" {
  2576. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2577. }
  2578. }
  2579. if item.MedChrgitmType == "06" { //手术费
  2580. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2581. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2582. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2583. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2584. if item.ChrgitmLv == "1" {
  2585. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2586. }
  2587. if item.ChrgitmLv == "2" {
  2588. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2589. }
  2590. if item.ChrgitmLv == "3" {
  2591. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2592. }
  2593. }
  2594. if item.MedChrgitmType == "08" { //材料费
  2595. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2596. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2597. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2598. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2599. if item.ChrgitmLv == "1" {
  2600. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2601. }
  2602. if item.ChrgitmLv == "2" {
  2603. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2604. }
  2605. if item.ChrgitmLv == "3" {
  2606. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2607. }
  2608. }
  2609. if item.MedChrgitmType == "09" { //西药费
  2610. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2611. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2612. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2613. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2614. if item.ChrgitmLv == "1" {
  2615. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2616. }
  2617. if item.ChrgitmLv == "2" {
  2618. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2619. }
  2620. if item.ChrgitmLv == "3" {
  2621. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2622. }
  2623. }
  2624. if item.MedChrgitmType == "11" { //中成费
  2625. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2626. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2627. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2628. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2629. if item.ChrgitmLv == "1" {
  2630. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2631. }
  2632. if item.ChrgitmLv == "2" {
  2633. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2634. }
  2635. if item.ChrgitmLv == "3" {
  2636. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2637. }
  2638. }
  2639. if item.MedChrgitmType == "14" { //其他费
  2640. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2641. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2642. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2644. if item.ChrgitmLv == "1" {
  2645. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2646. }
  2647. if item.ChrgitmLv == "2" {
  2648. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2649. }
  2650. if item.ChrgitmLv == "3" {
  2651. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2652. }
  2653. }
  2654. }
  2655. var iteminfoStructs []service.IteminfoStruct
  2656. if bedCostTotal != 0 {
  2657. iteminfo.MedChrgitm = "01"
  2658. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2659. iteminfo.Amt = bedCostTotal
  2660. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2661. iteminfo.ClabAmt = bed_clab_amt
  2662. iteminfo.OthAmt = bed_other_amt
  2663. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2664. }
  2665. if checkCostTotal != 0 {
  2666. iteminfo.MedChrgitm = "03"
  2667. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2668. iteminfo.Amt = checkCostTotal
  2669. iteminfo.ClaaSumfee = check_claa_sunmfee
  2670. iteminfo.ClabAmt = check_clab_amt
  2671. iteminfo.OthAmt = check_other_amt
  2672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2673. }
  2674. if laboratoryCostTotal != 0 {
  2675. iteminfo.MedChrgitm = "04"
  2676. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2677. iteminfo.Amt = laboratoryCostTotal
  2678. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2679. iteminfo.ClabAmt = laboratory_clab_amt
  2680. iteminfo.OthAmt = laboratory_other_amt
  2681. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2682. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2683. }
  2684. if treatCostTotal != 0 {
  2685. iteminfo.MedChrgitm = "05"
  2686. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2687. iteminfo.Amt = treatCostTotal
  2688. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2689. iteminfo.ClabAmt = treat_clab_amt
  2690. iteminfo.OthAmt = treat_other_amt
  2691. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2692. //(struct4101.IteminfoStruct, iteminfo)
  2693. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2694. }
  2695. if operationCostTotal != 0 {
  2696. iteminfo.MedChrgitm = "06"
  2697. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2698. iteminfo.Amt = operationCostTotal
  2699. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2700. iteminfo.ClabAmt = operation_clab_amt
  2701. iteminfo.OthAmt = operation_other_amt
  2702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2704. }
  2705. if materialCostTotal != 0 {
  2706. iteminfo.MedChrgitm = "08"
  2707. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2708. iteminfo.Amt = materialCostTotal
  2709. iteminfo.ClaaSumfee = material_claa_sunmfee
  2710. iteminfo.ClabAmt = material_clab_amt
  2711. iteminfo.OthAmt = material_other_amt
  2712. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2714. }
  2715. if westernMedicineCostTotal != 0 {
  2716. iteminfo.MedChrgitm = "09"
  2717. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2718. iteminfo.Amt = westernMedicineCostTotal
  2719. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2720. iteminfo.ClabAmt = westernMedicine_clab_amt
  2721. iteminfo.OthAmt = westernMedicine_other_amt
  2722. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2724. }
  2725. if chineseTraditionalMedicineCostTotal != 0 {
  2726. iteminfo.MedChrgitm = "11"
  2727. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2728. iteminfo.Amt = westernMedicineCostTotal
  2729. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2730. iteminfo.ClabAmt = westernMedicine_clab_amt
  2731. iteminfo.OthAmt = westernMedicine_other_amt
  2732. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2734. }
  2735. if otherCostTotal != 0 {
  2736. iteminfo.MedChrgitm = "14"
  2737. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2738. iteminfo.Amt = otherCostTotal
  2739. iteminfo.ClaaSumfee = other_claa_sunmfee
  2740. iteminfo.ClabAmt = other_clab_amt
  2741. iteminfo.OthAmt = other_other_amt
  2742. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2744. }
  2745. struct4101.IteminfoStruct = iteminfoStructs
  2746. struct4101.Ntly = "中国"
  2747. struct4101.AdmCaty = "A03.06"
  2748. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2749. fmt.Println(result)
  2750. var dat map[string]interface{}
  2751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2752. fmt.Println(dat)
  2753. } else {
  2754. fmt.Println(err)
  2755. }
  2756. userJSONBytes, _ := json.Marshal(dat)
  2757. var res ResultSeventeen
  2758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2759. utils.ErrorLog("解析失败:%v", err)
  2760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2761. return
  2762. }
  2763. if res.Infcode != 0 {
  2764. c.ServeSuccessJSON(map[string]interface{}{
  2765. "failed_code": -10,
  2766. "msg": res.ErrMsg,
  2767. })
  2768. return
  2769. } else {
  2770. order.FaPiaoNumber = zero
  2771. order.FaPiaoCode = last_order.FaPiaoCode
  2772. service.UpdateOrder(order)
  2773. hisFundSettleListResult := &models.HisFundSettleListResult{
  2774. Number: res.Output.SetlListId,
  2775. Status: 1,
  2776. Ctime: time.Now().Unix(),
  2777. Mtime: time.Now().Unix(),
  2778. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2779. IsUpload: 1,
  2780. OrderId: order_id,
  2781. }
  2782. service.CreateUploadRecord(hisFundSettleListResult)
  2783. c.ServeSuccessJSON(map[string]interface{}{
  2784. "msg": "上传成功",
  2785. "result": hisFundSettleListResult,
  2786. })
  2787. return
  2788. }
  2789. }
  2790. func (c *HisApiController) GetBatchSettleList() {
  2791. orders, _ := service.GetAllHisOrder(10106)
  2792. for _, item := range orders {
  2793. order_id := item.ID
  2794. order, _ := service.GetHisOrderByIDTwo(order_id)
  2795. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2796. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2797. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2798. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2799. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2800. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2801. if order.ID == 0 {
  2802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2803. return
  2804. }
  2805. if his.BalanceAccountsType == 2 {
  2806. continue
  2807. }
  2808. struct4101 := service.Struct4101{
  2809. PsnNo: order.PsnNo,
  2810. MdtrtId: order.MdtrtId,
  2811. SetlId: order.SetlId,
  2812. PsnName: order.PsnName,
  2813. Gend: order.Gend,
  2814. Brdy: his.Brdy,
  2815. Age: his.Age,
  2816. Naty: order.Naty,
  2817. PatnCertType: "01",
  2818. Certno: order.Certno,
  2819. Prfs: "90",
  2820. ConerName: roles[0].UserName,
  2821. PatnRlts: "99",
  2822. ConerAddr: miConfig.OrgName,
  2823. ConerTel: admin.Mobile,
  2824. HiType: order.Insutype,
  2825. Insuplc: his.InsuplcAdmdvs,
  2826. MaindiagFlag: "1",
  2827. BillCode: order.FaPiaoCode,
  2828. BillNo: order.FaPiaoNumber,
  2829. BizSn: order.Number,
  2830. PsnSelfPay: order.PsnPartAmt,
  2831. PsnOwnPay: order.PsnPartAmt,
  2832. AcctPay: order.AcctPay,
  2833. PsnCashpay: order.PsnCashPay,
  2834. HiPaymtd: "1",
  2835. Hsorg: his.InsuplcAdmdvs,
  2836. HsorgOpter: his.InsuplcAdmdvs,
  2837. MedinsFillPsn: curRoles.UserName,
  2838. MedinsFillDept: depart.Name,
  2839. IptMedType: "2",
  2840. }
  2841. struct4101.SetlBegnDate = order.SetlTime
  2842. struct4101.SetlEndDate = order.SetlTime
  2843. //if order.SettleType == 1 {
  2844. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2845. // dateStr := t.Format("2006-01-02")
  2846. // struct4101.SetlBegnDate = dateStr
  2847. // struct4101.SetlEndDate = dateStr
  2848. //} else {
  2849. // t := time.Unix(int64(order.SettleStartTime), 0)
  2850. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2851. // dateStartStr := t.Format("2006-01-02")
  2852. // dateEndStr := t2.Format("2006-01-02")
  2853. // struct4101.SetlBegnDate = dateStartStr
  2854. // struct4101.SetlEndDate = dateEndStr
  2855. //}
  2856. var rf []CustomFundPay
  2857. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2858. var tempFunPays []service.CustomStruct
  2859. var tempFunPay610100 service.CustomStruct
  2860. for _, item := range rf {
  2861. if item.FundPayType == "610100" {
  2862. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2863. tempFunPay610100.FundPayType = item.FundPayType
  2864. } else {
  2865. var tempFunPay service.CustomStruct
  2866. tempFunPay.FundPayamt = item.FundPayamt
  2867. tempFunPay.FundPayType = item.FundPayType
  2868. tempFunPays = append(tempFunPays, tempFunPay)
  2869. }
  2870. }
  2871. tempFunPays = append(tempFunPays, tempFunPay610100)
  2872. struct4101.CustomStruct = tempFunPays
  2873. var tempDiaginfos []service.DiaginfoStructTwo
  2874. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2875. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2876. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2877. var config []*models.HisXtDiagnoseConfig
  2878. for _, item := range diagnosis_ids {
  2879. id, _ := strconv.ParseInt(item, 10, 64)
  2880. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2881. config = append(config, &diagnosisConfig)
  2882. }
  2883. for index, item := range config {
  2884. if index == 0 {
  2885. var tempDiaginfo service.DiaginfoStructTwo
  2886. tempDiaginfo.DiagCode = item.CountryCode
  2887. tempDiaginfo.DiagName = item.CountryContentName
  2888. tempDiaginfo.DiagType = "1"
  2889. tempDiaginfo.MaindiagFlag = "1"
  2890. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2891. } else {
  2892. var tempDiaginfo service.DiaginfoStructTwo
  2893. tempDiaginfo.DiagCode = item.CountryCode
  2894. tempDiaginfo.DiagName = item.CountryContentName
  2895. tempDiaginfo.DiagType = "2"
  2896. tempDiaginfo.MaindiagFlag = "0"
  2897. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2898. }
  2899. }
  2900. struct4101.Diseinfo = tempDiaginfos
  2901. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2902. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2903. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2904. tempOpspdiseinfo2.OprnOprtCode = ""
  2905. tempOpspdiseinfo2.OprnOprtName = ""
  2906. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2907. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2908. var iteminfo service.IteminfoStruct
  2909. var bedCostTotal float64 = 0 //床位总费
  2910. var bedCostSelfTotal float64 = 0 //床位自费
  2911. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2912. var examineCostTotal float64 = 0 //诊查总费
  2913. var examineCostSelfTotal float64 = 0 //诊查自费
  2914. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2915. var nursingCostTotal float64 = 0 //护理总费
  2916. var nursingCostSelfTotal float64 = 0 //护理自费
  2917. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2918. var chineseMedicineCostTotal float64 = 0 //中成药
  2919. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2920. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2921. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2922. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2923. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2924. var registerCostTotal float64 = 0 //一般诊疗费
  2925. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2926. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2927. var operationCostTotal float64 = 0 //手术费
  2928. var operationCostSelfTotal float64 = 0 //手术费
  2929. var operationCostPartSelfTotal float64 = 0 //手术费
  2930. var otherCostTotal float64 = 0 //其他费用
  2931. var otherCostSelfTotal float64 = 0 //其他费用
  2932. var otherCostPartSelfTotal float64 = 0 //其他费用
  2933. var materialCostTotal float64 = 0 //材料费
  2934. var materialCostSelfTotal float64 = 0 //材料费
  2935. var materialCostPartSelfTotal float64 = 0 //材料费
  2936. var westernMedicineCostTotal float64 = 0 //西药费
  2937. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2938. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2939. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2940. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2941. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2942. var checkCostTotal float64 = 0 //检查费
  2943. var checkCostSelfTotal float64 = 0 //检查费
  2944. var checkCostPartSelfTotal float64 = 0 //检查费
  2945. var laboratoryCostTotal float64 = 0 //化验费
  2946. var laboratoryCostSelfTotal float64 = 0 //化验费
  2947. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2948. var treatCostTotal float64 = 0 //治疗费用
  2949. var treatCostSelfTotal float64 = 0 //治疗费用
  2950. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2951. decimal.DivisionPrecision = 2
  2952. var bed_fulamt_ownpay_amt float64 = 0
  2953. var examine_fulamt_ownpay_amt float64 = 0
  2954. var nursing_fulamt_ownpay_amt float64 = 0
  2955. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2956. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2957. var register_fulamt_ownpay_amt float64 = 0
  2958. var operation_fulamt_ownpay_amt float64 = 0
  2959. var other_fulamt_ownpay_amt float64 = 0
  2960. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2961. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2962. var check_fulamt_ownpay_amt float64 = 0
  2963. var material_fulamt_ownpay_amt float64 = 0
  2964. var laboratory_fulamt_ownpay_amt float64 = 0
  2965. var treat_fulamt_ownpay_amt float64 = 0
  2966. var bed_claa_sunmfee float64 = 0
  2967. var bed_clab_amt float64 = 0
  2968. var bed_other_amt float64 = 0
  2969. var examine_claa_sunmfee float64 = 0
  2970. var examine_clab_amt float64 = 0
  2971. var examine_other_amt float64 = 0
  2972. var nursing_claa_sunmfee float64 = 0
  2973. var nursing_clab_amt float64 = 0
  2974. var nursing_other_amt float64 = 0
  2975. var chinese_medicine_claa_sunmfee float64 = 0
  2976. var chinese_medicine_clab_amt float64 = 0
  2977. var chinese_medicine_other_amt float64 = 0
  2978. var commonly_treatment_claa_sunmfee float64 = 0
  2979. var commonly_treatment_clab_amt float64 = 0
  2980. var commonly_treatment_other_amt float64 = 0
  2981. var operation_claa_sunmfee float64 = 0
  2982. var operation_clab_amt float64 = 0
  2983. var operation_other_amt float64 = 0
  2984. var other_claa_sunmfee float64 = 0
  2985. var other_clab_amt float64 = 0
  2986. var other_other_amt float64 = 0
  2987. var westernMedicine_claa_sunmfee float64 = 0
  2988. var westernMedicine_clab_amt float64 = 0
  2989. var westernMedicine_other_amt float64 = 0
  2990. var chineseTraditional_claa_sunmfee float64 = 0
  2991. var chineseTraditional_clab_amt float64 = 0
  2992. var chineseTraditional_other_amt float64 = 0
  2993. var check_claa_sunmfee float64 = 0
  2994. var check_clab_amt float64 = 0
  2995. var check_other_amt float64 = 0
  2996. var material_claa_sunmfee float64 = 0
  2997. var material_clab_amt float64 = 0
  2998. var material_other_amt float64 = 0
  2999. var laboratory_claa_sunmfee float64 = 0
  3000. var laboratory_clab_amt float64 = 0
  3001. var laboratory_other_amt float64 = 0
  3002. var treat_claa_sunmfee float64 = 0
  3003. var treat_clab_amt float64 = 0
  3004. var treat_other_amt float64 = 0
  3005. var register_claa_sunmfee float64 = 0
  3006. var register_clab_amt float64 = 0
  3007. var register_other_amt float64 = 0
  3008. for _, item := range order.HisOrderInfo {
  3009. if item.MedChrgitmType == "01" { //床位费
  3010. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3011. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3012. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3013. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3014. if item.ChrgitmLv == "1" {
  3015. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3016. }
  3017. if item.ChrgitmLv == "2" {
  3018. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3019. }
  3020. if item.ChrgitmLv == "3" {
  3021. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3022. }
  3023. }
  3024. if item.MedChrgitmType == "02" { //诊查
  3025. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3026. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3027. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3028. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3029. if item.ChrgitmLv == "1" {
  3030. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3031. }
  3032. if item.ChrgitmLv == "2" {
  3033. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3034. }
  3035. if item.ChrgitmLv == "3" {
  3036. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3037. }
  3038. }
  3039. if item.MedChrgitmType == "03" { //检查费
  3040. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3041. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3042. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3043. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3044. if item.ChrgitmLv == "1" {
  3045. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3046. }
  3047. if item.ChrgitmLv == "2" {
  3048. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3049. }
  3050. if item.ChrgitmLv == "3" {
  3051. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3052. }
  3053. }
  3054. if item.MedChrgitmType == "04" { //化验费
  3055. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3056. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3057. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3058. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3059. if item.ChrgitmLv == "1" {
  3060. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3061. }
  3062. if item.ChrgitmLv == "2" {
  3063. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3064. }
  3065. if item.ChrgitmLv == "3" {
  3066. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3067. }
  3068. }
  3069. if item.MedChrgitmType == "05" { //治疗费
  3070. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3071. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3072. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3073. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3074. if item.ChrgitmLv == "1" {
  3075. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3076. }
  3077. if item.ChrgitmLv == "2" {
  3078. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3079. }
  3080. if item.ChrgitmLv == "3" {
  3081. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3082. }
  3083. }
  3084. if item.MedChrgitmType == "06" { //手术费
  3085. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3086. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3087. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3088. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3089. if item.ChrgitmLv == "1" {
  3090. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3091. }
  3092. if item.ChrgitmLv == "2" {
  3093. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3094. }
  3095. if item.ChrgitmLv == "3" {
  3096. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3097. }
  3098. }
  3099. if item.MedChrgitmType == "07" { //手术费
  3100. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3101. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3102. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3103. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3104. if item.ChrgitmLv == "1" {
  3105. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3106. }
  3107. if item.ChrgitmLv == "2" {
  3108. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3109. }
  3110. if item.ChrgitmLv == "3" {
  3111. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3112. }
  3113. }
  3114. if item.MedChrgitmType == "08" { //材料费
  3115. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3116. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3117. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3118. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3119. if item.ChrgitmLv == "1" {
  3120. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3121. }
  3122. if item.ChrgitmLv == "2" {
  3123. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3124. }
  3125. if item.ChrgitmLv == "3" {
  3126. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3127. }
  3128. }
  3129. if item.MedChrgitmType == "09" { //西药费
  3130. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3131. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3132. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3134. if item.ChrgitmLv == "1" {
  3135. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3136. }
  3137. if item.ChrgitmLv == "2" {
  3138. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3139. }
  3140. if item.ChrgitmLv == "3" {
  3141. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3142. }
  3143. }
  3144. if item.MedChrgitmType == "10" { //中药饮片
  3145. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3146. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3147. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3149. if item.ChrgitmLv == "1" {
  3150. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3151. }
  3152. if item.ChrgitmLv == "2" {
  3153. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3154. }
  3155. if item.ChrgitmLv == "3" {
  3156. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3157. }
  3158. }
  3159. if item.MedChrgitmType == "11" { //中成费
  3160. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3161. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3162. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3164. if item.ChrgitmLv == "1" {
  3165. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3166. }
  3167. if item.ChrgitmLv == "2" {
  3168. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3169. }
  3170. if item.ChrgitmLv == "3" {
  3171. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3172. }
  3173. }
  3174. if item.MedChrgitmType == "12" { //中成费
  3175. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3176. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3177. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3179. if item.ChrgitmLv == "1" {
  3180. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3181. }
  3182. if item.ChrgitmLv == "2" {
  3183. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3184. }
  3185. if item.ChrgitmLv == "3" {
  3186. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3187. }
  3188. }
  3189. if item.MedChrgitmType == "13" { //中成费
  3190. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3191. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3192. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3194. if item.ChrgitmLv == "1" {
  3195. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3196. }
  3197. if item.ChrgitmLv == "2" {
  3198. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3199. }
  3200. if item.ChrgitmLv == "3" {
  3201. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3202. }
  3203. }
  3204. if item.MedChrgitmType == "14" { //其他费
  3205. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3206. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3207. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3209. if item.ChrgitmLv == "1" {
  3210. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3211. }
  3212. if item.ChrgitmLv == "2" {
  3213. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3214. }
  3215. if item.ChrgitmLv == "3" {
  3216. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3217. }
  3218. }
  3219. }
  3220. var iteminfoStructs []service.IteminfoStruct
  3221. if bedCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "01"
  3223. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3224. iteminfo.Amt = bedCostTotal
  3225. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3226. iteminfo.ClabAmt = bed_clab_amt
  3227. iteminfo.OthAmt = bed_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. }
  3230. if examineCostTotal != 0 {
  3231. iteminfo.MedChrgitm = "02"
  3232. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3233. iteminfo.Amt = examineCostTotal
  3234. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3235. iteminfo.ClabAmt = examine_clab_amt
  3236. iteminfo.OthAmt = examine_other_amt
  3237. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3238. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3239. }
  3240. if checkCostTotal != 0 {
  3241. iteminfo.MedChrgitm = "03"
  3242. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3243. iteminfo.Amt = checkCostTotal
  3244. iteminfo.ClaaSumfee = check_claa_sunmfee
  3245. iteminfo.ClabAmt = check_clab_amt
  3246. iteminfo.OthAmt = check_other_amt
  3247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3248. }
  3249. if laboratoryCostTotal != 0 {
  3250. iteminfo.MedChrgitm = "04"
  3251. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3252. iteminfo.Amt = laboratoryCostTotal
  3253. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3254. iteminfo.ClabAmt = laboratory_clab_amt
  3255. iteminfo.OthAmt = laboratory_other_amt
  3256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3257. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3258. }
  3259. if treatCostTotal != 0 {
  3260. iteminfo.MedChrgitm = "05"
  3261. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3262. iteminfo.Amt = treatCostTotal
  3263. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3264. iteminfo.ClabAmt = treat_clab_amt
  3265. iteminfo.OthAmt = treat_other_amt
  3266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3267. //(struct4101.IteminfoStruct, iteminfo)
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. }
  3270. if operationCostTotal != 0 {
  3271. iteminfo.MedChrgitm = "06"
  3272. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3273. iteminfo.Amt = operationCostTotal
  3274. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3275. iteminfo.ClabAmt = operation_clab_amt
  3276. iteminfo.OthAmt = operation_other_amt
  3277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3278. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3279. }
  3280. if nursingCostTotal != 0 {
  3281. iteminfo.MedChrgitm = "07"
  3282. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3283. iteminfo.Amt = nursingCostTotal
  3284. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3285. iteminfo.ClabAmt = nursing_clab_amt
  3286. iteminfo.OthAmt = nursing_other_amt
  3287. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3288. }
  3289. if materialCostTotal != 0 {
  3290. iteminfo.MedChrgitm = "08"
  3291. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3292. iteminfo.Amt = materialCostTotal
  3293. iteminfo.ClaaSumfee = material_claa_sunmfee
  3294. iteminfo.ClabAmt = material_clab_amt
  3295. iteminfo.OthAmt = material_other_amt
  3296. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3298. }
  3299. if westernMedicineCostTotal != 0 {
  3300. iteminfo.MedChrgitm = "09"
  3301. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3302. iteminfo.Amt = westernMedicineCostTotal
  3303. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3304. iteminfo.ClabAmt = westernMedicine_clab_amt
  3305. iteminfo.OthAmt = westernMedicine_other_amt
  3306. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3307. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3308. }
  3309. if chineseMedicineCostTotal != 0 {
  3310. iteminfo.MedChrgitm = "10"
  3311. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3312. iteminfo.Amt = chineseMedicineCostTotal
  3313. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3314. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3315. iteminfo.OthAmt = chinese_medicine_other_amt
  3316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3318. }
  3319. if chineseTraditionalMedicineCostTotal != 0 {
  3320. iteminfo.MedChrgitm = "11"
  3321. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3322. iteminfo.Amt = westernMedicineCostTotal
  3323. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3324. iteminfo.ClabAmt = westernMedicine_clab_amt
  3325. iteminfo.OthAmt = westernMedicine_other_amt
  3326. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3328. }
  3329. if commonlyTreatmentCostTotal != 0 {
  3330. iteminfo.MedChrgitm = "12"
  3331. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3332. iteminfo.Amt = commonlyTreatmentCostTotal
  3333. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3334. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3335. iteminfo.OthAmt = commonly_treatment_other_amt
  3336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3338. }
  3339. if registerCostTotal != 0 {
  3340. iteminfo.MedChrgitm = "13"
  3341. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3342. iteminfo.Amt = registerCostTotal
  3343. iteminfo.ClaaSumfee = register_claa_sunmfee
  3344. iteminfo.ClabAmt = register_clab_amt
  3345. iteminfo.OthAmt = register_other_amt
  3346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3348. }
  3349. if otherCostTotal != 0 {
  3350. iteminfo.MedChrgitm = "14"
  3351. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3352. iteminfo.Amt = otherCostTotal
  3353. iteminfo.ClaaSumfee = other_claa_sunmfee
  3354. iteminfo.ClabAmt = other_clab_amt
  3355. iteminfo.OthAmt = other_other_amt
  3356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3358. }
  3359. struct4101.IteminfoStruct = iteminfoStructs
  3360. struct4101.Ntly = "中国"
  3361. struct4101.AdmCaty = "A03.06"
  3362. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3363. fmt.Println(result)
  3364. var dat map[string]interface{}
  3365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3366. fmt.Println(dat)
  3367. } else {
  3368. fmt.Println(err)
  3369. }
  3370. userJSONBytes, _ := json.Marshal(dat)
  3371. var res ResultSeventeen
  3372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3373. utils.ErrorLog("解析失败:%v", err)
  3374. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3375. adminUser := c.GetAdminUserInfo()
  3376. errlog := &models.HisOrderError{
  3377. UserOrgId: adminUser.CurrentOrgId,
  3378. Ctime: time.Now().Unix(),
  3379. Mtime: time.Now().Unix(),
  3380. ErrMsg: res.ErrMsg + "解析失败",
  3381. Status: 1,
  3382. PatientId: order_id,
  3383. Stage: 10106,
  3384. }
  3385. service.CreateErrMsgLog(errlog)
  3386. continue
  3387. }
  3388. if res.Infcode != 0 {
  3389. adminUser := c.GetAdminUserInfo()
  3390. errlog := &models.HisOrderError{
  3391. UserOrgId: adminUser.CurrentOrgId,
  3392. Ctime: time.Now().Unix(),
  3393. Mtime: time.Now().Unix(),
  3394. ErrMsg: res.ErrMsg,
  3395. Status: 1,
  3396. PatientId: order_id,
  3397. Stage: 10106,
  3398. }
  3399. service.CreateErrMsgLog(errlog)
  3400. continue
  3401. } else {
  3402. hisFundSettleListResult := &models.HisFundSettleListResult{
  3403. Number: res.Output.SetlListId,
  3404. Status: 1,
  3405. Ctime: time.Now().Unix(),
  3406. Mtime: time.Now().Unix(),
  3407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3408. IsUpload: 1,
  3409. OrderId: order_id,
  3410. }
  3411. service.CreateUploadRecord(hisFundSettleListResult)
  3412. continue
  3413. }
  3414. }
  3415. }
  3416. func (c *HisApiController) GetOrgInfo() {
  3417. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3418. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3419. }
  3420. func (c *HisApiController) GetHisPatientInfo() {
  3421. medical_insurance_card := c.GetString("medical_insurance_card")
  3422. id_card_type, _ := c.GetInt64("id_card_type")
  3423. id_card := c.GetString("id_card")
  3424. adminInfo := c.GetAdminUserInfo()
  3425. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3426. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3427. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3428. IdCardNo := ""
  3429. if id_card_type == 1 {
  3430. IdCardNo = medical_insurance_card
  3431. } else if id_card_type == 2 {
  3432. IdCardNo = id_card
  3433. }
  3434. if config.IsOpen == 1 {
  3435. 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
  3436. resp, requestErr := http.Get(api)
  3437. if requestErr != nil {
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. defer resp.Body.Close()
  3442. body, ioErr := ioutil.ReadAll(resp.Body)
  3443. if ioErr != nil {
  3444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3446. return
  3447. }
  3448. var respJSON map[string]interface{}
  3449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3452. return
  3453. }
  3454. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3455. userJSONBytes, _ := json.Marshal(userJSON)
  3456. var res ResultTwo
  3457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3464. infoStr := string(Iinfos)
  3465. idetinfoStr := string(Idetinfos)
  3466. if res.Infcode == 0 {
  3467. his := models.VMHisPatient{
  3468. Status: 1,
  3469. Ctime: time.Now().Unix(),
  3470. Mtime: time.Now().Unix(),
  3471. PsnNo: res.Output.Baseinfo.PsnNo,
  3472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3473. Certno: res.Output.Baseinfo.Certno,
  3474. PsnName: res.Output.Baseinfo.PsnName,
  3475. Gend: res.Output.Baseinfo.Gend,
  3476. Naty: res.Output.Baseinfo.Naty,
  3477. Brdy: res.Output.Baseinfo.Brdy,
  3478. Age: res.Output.Baseinfo.Age,
  3479. Iinfo: infoStr,
  3480. Idetinfo: idetinfoStr,
  3481. UserOrgId: adminInfo.CurrentOrgId,
  3482. IsReturn: 1,
  3483. IdCardType: id_card_type,
  3484. }
  3485. c.ServeSuccessJSON(map[string]interface{}{
  3486. "info": his,
  3487. })
  3488. } else {
  3489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3490. return
  3491. }
  3492. }
  3493. }
  3494. //func GetBasBaseInfo() (jsonStr string, err error) {
  3495. //
  3496. // handle := syscall.NewLazyDLL("SSCard.dll")
  3497. // add := handle.NewProc("ReadCardBas")
  3498. // str := make([]byte, 1024)
  3499. // str1 := make([]byte, 1024)
  3500. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3501. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3502. //
  3503. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3504. //
  3505. // fmt.Println("> Add(4,5)的结果为:", ret)
  3506. // handle.Release()
  3507. //
  3508. // return "", nil
  3509. //
  3510. //}
  3511. //func GetQRBaseInfo() (jsonStr string, err error) {
  3512. // handle := syscall.LoadDLL("SSCard.dll")
  3513. // ReadCardBas := handle.FindProc("GetQRBase")
  3514. //
  3515. // str := make([]byte, 256)
  3516. // str1 := make([]byte, 256)
  3517. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3518. //
  3519. // fmt.Println(string(str))
  3520. // fmt.Println(r)
  3521. // return string(str), nil
  3522. //}
  3523. //func CardInit() int {
  3524. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3525. // add := DllTestDef.MustFindProc("Init")
  3526. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3527. // if err != nil {
  3528. // fmt.Println("SSCard的运算结果为:", ret)
  3529. // }
  3530. // result := int(ret)
  3531. // return result
  3532. //}
  3533. //func CardInit() int {
  3534. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3535. // if err != nil {
  3536. // fmt.Println("SSCard的运算结果为:", ret)
  3537. // }
  3538. // fmt.Println(err)
  3539. // result := int(ret)
  3540. // return result
  3541. //}
  3542. func IntPtr(n int) uintptr {
  3543. return uintptr(n)
  3544. }
  3545. func StrPtr(s string) uintptr {
  3546. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3547. }
  3548. type Result2001 struct {
  3549. Cainfo interface{} `json:"cainfo"`
  3550. ErrMsg string `json:"err_msg"`
  3551. InfRefmsgid string `json:"inf_refmsgid"`
  3552. Infcode int64 `json:"infcode"`
  3553. Output struct {
  3554. Trtinfo struct {
  3555. PsnNo string `json:"psn_no"`
  3556. TrtChkType string `json:"trt_chk_type"`
  3557. FundPayType string `json:"fund_pay_type"`
  3558. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3559. Begndate string `json:"begndate"`
  3560. Enddate string `json:"enddate"`
  3561. TrtChkRslt string `json:"trt_chk_rslt"`
  3562. } `json:"trtinfo"`
  3563. } `json:"output"`
  3564. RefmsgTime string `json:"refmsg_time"`
  3565. RespondTime string `json:"respond_time"`
  3566. Signtype interface{} `json:"signtype"`
  3567. WarnMsg interface{} `json:"warn_msg"`
  3568. }
  3569. type Result2001Org10265 struct {
  3570. Cainfo interface{} `json:"cainfo"`
  3571. ErrMsg string `json:"err_msg"`
  3572. InfRefmsgid string `json:"inf_refmsgid"`
  3573. Infcode string `json:"infcode"`
  3574. Output struct {
  3575. Trtinfo struct {
  3576. PsnNo string `json:"psn_no"`
  3577. TrtChkType string `json:"trt_chk_type"`
  3578. FundPayType string `json:"fund_pay_type"`
  3579. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3580. Begndate string `json:"begndate"`
  3581. Enddate string `json:"enddate"`
  3582. TrtChkRslt string `json:"trt_chk_rslt"`
  3583. } `json:"trtinfo"`
  3584. } `json:"output"`
  3585. RefmsgTime string `json:"refmsg_time"`
  3586. RespondTime string `json:"respond_time"`
  3587. Signtype interface{} `json:"signtype"`
  3588. WarnMsg interface{} `json:"warn_msg"`
  3589. }
  3590. type ResultTwo struct {
  3591. ErrMsg string `json:"err_msg"`
  3592. InfRefmsgid string `json:"inf_refmsgid"`
  3593. Infcode int64 `json:"infcode"`
  3594. Output struct {
  3595. Baseinfo struct {
  3596. Age float64 `json:"age"`
  3597. Brdy string `json:"brdy"`
  3598. Certno string `json:"certno"`
  3599. Gend string `json:"gend"`
  3600. Naty string `json:"naty"`
  3601. PsnCertType string `json:"psn_cert_type"`
  3602. PsnName string `json:"psn_name"`
  3603. PsnNo string `json:"psn_no"`
  3604. } `json:"baseinfo"`
  3605. Idetinfo []interface{} `json:"idetinfo"`
  3606. Iinfo []struct {
  3607. Balc float64 `json:"balc"`
  3608. CvlservFlag string `json:"cvlserv_flag"`
  3609. EmpName string `json:"emp_name"`
  3610. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3611. Insutype string `json:"insutype"`
  3612. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3613. PausInsuDate string `json:"paus_insu_date"`
  3614. PsnInsuDate string `json:"psn_insu_date"`
  3615. PsnInsuStas string `json:"psn_insu_stas"`
  3616. PsnType string `json:"psn_type"`
  3617. } `json:"insuinfo"`
  3618. } `json:"output"`
  3619. RefmsgTime string `json:"refmsg_time"`
  3620. RespondTime string `json:"respond_time"`
  3621. Signtype interface{} `json:"signtype"`
  3622. WarnInfo interface{} `json:"warn_info"`
  3623. }
  3624. type ResultTwo10265 struct {
  3625. ErrMsg string `json:"err_msg"`
  3626. InfRefmsgid string `json:"inf_refmsgid"`
  3627. Infcode string `json:"infcode"`
  3628. Output struct {
  3629. Baseinfo struct {
  3630. Age float64 `json:"age"`
  3631. Brdy string `json:"brdy"`
  3632. Certno string `json:"certno"`
  3633. Gend string `json:"gend"`
  3634. Naty string `json:"naty"`
  3635. PsnCertType string `json:"psn_cert_type"`
  3636. PsnName string `json:"psn_name"`
  3637. PsnNo string `json:"psn_no"`
  3638. } `json:"baseinfo"`
  3639. Idetinfo []interface{} `json:"idetinfo"`
  3640. Iinfo []struct {
  3641. Balc float64 `json:"balc"`
  3642. CvlservFlag string `json:"cvlserv_flag"`
  3643. EmpName string `json:"emp_name"`
  3644. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3645. Insutype string `json:"insutype"`
  3646. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3647. PausInsuDate string `json:"paus_insu_date"`
  3648. PsnInsuDate string `json:"psn_insu_date"`
  3649. PsnInsuStas string `json:"psn_insu_stas"`
  3650. PsnType string `json:"psn_type"`
  3651. } `json:"insuinfo"`
  3652. } `json:"output"`
  3653. RefmsgTime string `json:"refmsg_time"`
  3654. RespondTime string `json:"respond_time"`
  3655. Signtype interface{} `json:"signtype"`
  3656. WarnInfo interface{} `json:"warn_info"`
  3657. }
  3658. type ResultThree struct {
  3659. Cainfo interface{} `json:"cainfo"`
  3660. ErrMsg string `json:"err_msg"`
  3661. InfRefmsgid string `json:"inf_refmsgid"`
  3662. Infcode int64 `json:"infcode"`
  3663. Output struct {
  3664. Data struct {
  3665. IptOtpNo string `json:"ipt_otp_no"`
  3666. MdtrtID string `json:"mdtrt_id"`
  3667. PsnNo string `json:"psn_no"`
  3668. } `json:"data"`
  3669. } `json:"output"`
  3670. RefmsgTime string `json:"refmsg_time"`
  3671. RespondTime string `json:"respond_time"`
  3672. Signtype interface{} `json:"signtype"`
  3673. WarnMsg interface{} `json:"warn_msg"`
  3674. }
  3675. type ResultThree10265 struct {
  3676. Cainfo interface{} `json:"cainfo"`
  3677. ErrMsg string `json:"err_msg"`
  3678. InfRefmsgid string `json:"inf_refmsgid"`
  3679. Infcode string `json:"infcode"`
  3680. Output struct {
  3681. Data struct {
  3682. IptOtpNo string `json:"ipt_otp_no"`
  3683. MdtrtID string `json:"mdtrt_id"`
  3684. PsnNo string `json:"psn_no"`
  3685. } `json:"data"`
  3686. } `json:"output"`
  3687. RefmsgTime string `json:"refmsg_time"`
  3688. RespondTime string `json:"respond_time"`
  3689. Signtype interface{} `json:"signtype"`
  3690. WarnMsg interface{} `json:"warn_msg"`
  3691. }
  3692. type ResultFour struct {
  3693. Cainfo string `json:"cainfo"`
  3694. ErrMsg string `json:"err_msg"`
  3695. InfRefmsgid string `json:"inf_refmsgid"`
  3696. Infcode int64 `json:"infcode"`
  3697. Output struct {
  3698. Result []struct {
  3699. BasMednFlag string `json:"bas_medn_flag"`
  3700. ChldMedcFlag string `json:"chld_medc_flag"`
  3701. ChrgitmLv string `json:"chrgitm_lv"`
  3702. Cnt float64 `json:"cnt"`
  3703. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3704. DrtReimFlag string `json:"drt_reim_flag"`
  3705. FeedetlSn string `json:"feedetl_sn"`
  3706. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3707. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3708. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3709. ListSpItemFlag string `json:"list_sp_item_flag"`
  3710. LmtUsedFlag string `json:"lmt_used_flag"`
  3711. MedChrgitmType string `json:"med_chrgitm_type"`
  3712. Memo string `json:"memo"`
  3713. OverlmtAmt float64 `json:"overlmt_amt"`
  3714. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3715. Pric float64 `json:"pric"`
  3716. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3717. SelfpayProp float64 `json:"selfpay_prop"`
  3718. } `json:"result"`
  3719. } `json:"output"`
  3720. RefmsgTime string `json:"refmsg_time"`
  3721. RespondTime string `json:"respond_time"`
  3722. Signtype string `json:"signtype"`
  3723. WarnMsg string `json:"warn_msg"`
  3724. }
  3725. type ResultFour10265 struct {
  3726. Cainfo string `json:"cainfo"`
  3727. ErrMsg string `json:"err_msg"`
  3728. InfRefmsgid string `json:"inf_refmsgid"`
  3729. Infcode string `json:"infcode"`
  3730. Output struct {
  3731. Result []struct {
  3732. BasMednFlag string `json:"bas_medn_flag"`
  3733. ChldMedcFlag string `json:"chld_medc_flag"`
  3734. ChrgitmLv string `json:"chrgitm_lv"`
  3735. Cnt float64 `json:"cnt"`
  3736. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3737. DrtReimFlag string `json:"drt_reim_flag"`
  3738. FeedetlSn string `json:"feedetl_sn"`
  3739. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3740. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3741. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3742. ListSpItemFlag string `json:"list_sp_item_flag"`
  3743. LmtUsedFlag string `json:"lmt_used_flag"`
  3744. MedChrgitmType string `json:"med_chrgitm_type"`
  3745. Memo string `json:"memo"`
  3746. OverlmtAmt float64 `json:"overlmt_amt"`
  3747. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3748. Pric float64 `json:"pric"`
  3749. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3750. SelfpayProp float64 `json:"selfpay_prop"`
  3751. } `json:"result"`
  3752. } `json:"output"`
  3753. RefmsgTime string `json:"refmsg_time"`
  3754. RespondTime string `json:"respond_time"`
  3755. Signtype string `json:"signtype"`
  3756. WarnMsg string `json:"warn_msg"`
  3757. }
  3758. type ResultFive struct {
  3759. Balc float64 `json:"balc"`
  3760. CvlservFlag string `json:"cvlserv_flag"`
  3761. EmpName string `json:"emp_name"`
  3762. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3763. Insutype string `json:"insutype"`
  3764. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3765. PausInsuDate string `json:"paus_insu_date"`
  3766. PsnInsuDate string `json:"psn_insu_date"`
  3767. PsnInsuStas string `json:"psn_insu_stas"`
  3768. PsnType string `json:"psn_type"`
  3769. }
  3770. type ResultSix struct {
  3771. Cainfo interface{} `json:"cainfo"`
  3772. ErrMsg string `json:"err_msg"`
  3773. InfRefmsgid string `json:"inf_refmsgid"`
  3774. Infcode int64 `json:"infcode"`
  3775. Output struct {
  3776. } `json:"output"`
  3777. RefmsgTime string `json:"refmsg_time"`
  3778. RespondTime string `json:"respond_time"`
  3779. Signtype interface{} `json:"signtype"`
  3780. WarnMsg interface{} `json:"warn_msg"`
  3781. }
  3782. type ResultSix10265 struct {
  3783. Cainfo interface{} `json:"cainfo"`
  3784. ErrMsg string `json:"err_msg"`
  3785. InfRefmsgid string `json:"inf_refmsgid"`
  3786. Infcode string `json:"infcode"`
  3787. Output struct {
  3788. } `json:"output"`
  3789. RefmsgTime string `json:"refmsg_time"`
  3790. RespondTime string `json:"respond_time"`
  3791. Signtype interface{} `json:"signtype"`
  3792. WarnMsg interface{} `json:"warn_msg"`
  3793. }
  3794. type ResultSeven struct {
  3795. Cainfo string `json:"cainfo"`
  3796. ErrMsg string `json:"err_msg"`
  3797. InfRefmsgid string `json:"inf_refmsgid"`
  3798. Infcode int64 `json:"infcode"`
  3799. Output struct {
  3800. Setldetail []interface{} `json:"setldetail"`
  3801. Setlinfo struct {
  3802. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3803. AcctPay float64 `json:"acct_pay"`
  3804. ActPayDedc float64 `json:"act_pay_dedc"`
  3805. Age float64 `json:"age"`
  3806. Balc float64 `json:"balc"`
  3807. Brdy string `json:"brdy"`
  3808. Certno string `json:"certno"`
  3809. ClrOptins string `json:"clr_optins"`
  3810. ClrType string `json:"clr_type"`
  3811. ClrWay string `json:"clr_way"`
  3812. CvlservFlag string `json:"cvlserv_flag"`
  3813. CvlservPay float64 `json:"cvlserv_pay"`
  3814. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3815. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3816. Gend string `json:"gend"`
  3817. HifesPay float64 `json:"hifes_pay"`
  3818. HifmiPay float64 `json:"hifmi_pay"`
  3819. HifpPay float64 `json:"hifp_pay"`
  3820. HospPartAmt float64 `json:"hosp_part_amt"`
  3821. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3822. Insutype string `json:"insutype"`
  3823. MafPay float64 `json:"maf_pay"`
  3824. MdtrtCertType string `json:"mdtrt_cert_type"`
  3825. HifobPay float64 `json:"hifob_pay"`
  3826. MdtrtID string `json:"mdtrt_id"`
  3827. MedType string `json:"med_type"`
  3828. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3829. MedinsSetlID string `json:"medins_setl_id"`
  3830. Naty string `json:"naty"`
  3831. OthPay float64 `json:"oth_pay"`
  3832. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3833. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3834. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3835. PsnCashPay float64 `json:"psn_cash_pay"`
  3836. PsnCertType string `json:"psn_cert_type"`
  3837. PsnName string `json:"psn_name"`
  3838. PsnNo string `json:"psn_no"`
  3839. PsnPartAmt float64 `json:"psn_part_amt"`
  3840. PsnType string `json:"psn_type"`
  3841. SetlID string `json:"setl_id"`
  3842. SetlTime string `json:"setl_time"`
  3843. } `json:"setlinfo"`
  3844. } `json:"output"`
  3845. RefmsgTime string `json:"refmsg_time"`
  3846. RespondTime string `json:"respond_time"`
  3847. Signtype interface{} `json:"signtype"`
  3848. WarnMsg interface{} `json:"warn_msg"`
  3849. }
  3850. type ResultSeven10265 struct {
  3851. Cainfo string `json:"cainfo"`
  3852. ErrMsg string `json:"err_msg"`
  3853. InfRefmsgid string `json:"inf_refmsgid"`
  3854. Infcode string `json:"infcode"`
  3855. Output struct {
  3856. Setldetail []interface{} `json:"setldetail"`
  3857. Setlinfo struct {
  3858. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3859. AcctPay float64 `json:"acct_pay"`
  3860. ActPayDedc float64 `json:"act_pay_dedc"`
  3861. Age float64 `json:"age"`
  3862. Balc float64 `json:"balc"`
  3863. Brdy string `json:"brdy"`
  3864. Certno string `json:"certno"`
  3865. ClrOptins string `json:"clr_optins"`
  3866. ClrType string `json:"clr_type"`
  3867. ClrWay string `json:"clr_way"`
  3868. CvlservFlag string `json:"cvlserv_flag"`
  3869. CvlservPay float64 `json:"cvlserv_pay"`
  3870. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3871. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3872. Gend string `json:"gend"`
  3873. HifesPay float64 `json:"hifes_pay"`
  3874. HifmiPay float64 `json:"hifmi_pay"`
  3875. HifpPay float64 `json:"hifp_pay"`
  3876. HospPartAmt float64 `json:"hosp_part_amt"`
  3877. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3878. Insutype string `json:"insutype"`
  3879. MafPay float64 `json:"maf_pay"`
  3880. MdtrtCertType string `json:"mdtrt_cert_type"`
  3881. HifobPay float64 `json:"hifob_pay"`
  3882. MdtrtID string `json:"mdtrt_id"`
  3883. MedType string `json:"med_type"`
  3884. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3885. MedinsSetlID string `json:"medins_setl_id"`
  3886. Naty string `json:"naty"`
  3887. OthPay float64 `json:"oth_pay"`
  3888. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3889. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3890. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3891. PsnCashPay float64 `json:"psn_cash_pay"`
  3892. PsnCertType string `json:"psn_cert_type"`
  3893. PsnName string `json:"psn_name"`
  3894. PsnNo string `json:"psn_no"`
  3895. PsnPartAmt float64 `json:"psn_part_amt"`
  3896. PsnType string `json:"psn_type"`
  3897. SetlID string `json:"setl_id"`
  3898. SetlTime string `json:"setl_time"`
  3899. } `json:"setlinfo"`
  3900. } `json:"output"`
  3901. RefmsgTime string `json:"refmsg_time"`
  3902. RespondTime string `json:"respond_time"`
  3903. Signtype interface{} `json:"signtype"`
  3904. WarnMsg interface{} `json:"warn_msg"`
  3905. }
  3906. type ResultEight struct {
  3907. Cainfo string `json:"cainfo"`
  3908. ErrMsg string `json:"err_msg"`
  3909. InfRefmsgid string `json:"inf_refmsgid"`
  3910. Infcode int64 `json:"infcode"`
  3911. Output struct {
  3912. Stmtinfo struct {
  3913. SetlOptins string `json:"setl_optins"`
  3914. StmtRslt string `json:"stmt_rslt"`
  3915. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3916. } `json:"stmtinfo"`
  3917. } `json:"output"`
  3918. RefmsgTime string `json:"refmsg_time"`
  3919. RespondTime string `json:"respond_time"`
  3920. Signtype interface{} `json:"signtype"`
  3921. WarnMsg interface{} `json:"warn_msg"`
  3922. }
  3923. type ResultEightFor10188 struct {
  3924. Cainfo string `json:"cainfo"`
  3925. ErrMsg string `json:"err_msg"`
  3926. InfRefmsgid string `json:"inf_refmsgid"`
  3927. Infcode string `json:"infcode"`
  3928. Output struct {
  3929. Stmtinfo struct {
  3930. SetlOptins string `json:"setl_optins"`
  3931. StmtRslt string `json:"stmt_rslt"`
  3932. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3933. } `json:"stmtinfo"`
  3934. } `json:"output"`
  3935. RefmsgTime string `json:"refmsg_time"`
  3936. RespondTime string `json:"respond_time"`
  3937. Signtype interface{} `json:"signtype"`
  3938. WarnMsg interface{} `json:"warn_msg"`
  3939. }
  3940. type ResultNine struct {
  3941. Cainfo string `json:"cainfo"`
  3942. ErrMsg string `json:"err_msg"`
  3943. InfRefmsgid string `json:"inf_refmsgid"`
  3944. Infcode int64 `json:"infcode"`
  3945. Output struct {
  3946. FileQuryNo string `json:"file_qury_no"`
  3947. } `json:"output"`
  3948. RefmsgTime string `json:"refmsg_time"`
  3949. RespondTime string `json:"respond_time"`
  3950. Signtype interface{} `json:"signtype"`
  3951. WarnMsg interface{} `json:"warn_msg"`
  3952. }
  3953. type ResultTen struct {
  3954. Cainfo string `json:"cainfo"`
  3955. ErrMsg string `json:"err_msg"`
  3956. InfRefmsgid string `json:"inf_refmsgid"`
  3957. Infcode int64 `json:"infcode"`
  3958. Output struct {
  3959. DldEndtime string `json:"dld_endtime"`
  3960. FileQuryNo string `json:"file_qury_no"`
  3961. Filename string `json:"filename"`
  3962. } `json:"output"`
  3963. RefmsgTime string `json:"refmsg_time"`
  3964. RespondTime string `json:"respond_time"`
  3965. Signtype interface{} `json:"signtype"`
  3966. WarnMsg interface{} `json:"warn_msg"`
  3967. }
  3968. //type Autogenerated struct {
  3969. // Output struct {
  3970. // Setlinfo struct {
  3971. // SetlTime string `json:"setl_time"`
  3972. // CvlservPay float64 `json:"cvlserv_pay"`
  3973. // Year string `json:"year"`
  3974. // MedType string `json:"med_type"`
  3975. // PsnPay float64 `json:"psn_pay"`
  3976. // OpterID string `json:"opter_id"`
  3977. // Begndate string `json:"begndate"`
  3978. // FlxempeFlag string `json:"flxempe_flag"`
  3979. // HifmiPay float64 `json:"hifmi_pay"`
  3980. // PsnNo string `json:"psn_no"`
  3981. // ActPayDedc float64 `json:"act_pay_dedc"`
  3982. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3983. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3984. // ClrWay string `json:"clr_way"`
  3985. // OthPay float64 `json:"oth_pay"`
  3986. // Gend string `json:"gend"`
  3987. // MdtrtID string `json:"mdtrt_id"`
  3988. // AcctPay float64 `json:"acct_pay"`
  3989. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3990. // Insutype string `json:"insutype"`
  3991. // Invono interface{} `json:"invono"`
  3992. // Enddate string `json:"enddate"`
  3993. // CashPayamt float64 `json:"cash_payamt"`
  3994. // PsnType string `json:"psn_type"`
  3995. // FixmedinsName string `json:"fixmedins_name"`
  3996. // HifpPay float64 `json:"hifp_pay"`
  3997. // NewFlag interface{} `json:"new_flag"`
  3998. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3999. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4000. // PayLoc string `json:"pay_loc"`
  4001. // ClrType string `json:"clr_type"`
  4002. // RefdSetlFlag string `json:"refd_setl_flag"`
  4003. // CvlservFlag string `json:"cvlserv_flag"`
  4004. // EmpName string `json:"emp_name"`
  4005. // Brdy string `json:"brdy"`
  4006. // Naty string `json:"naty"`
  4007. // Certno string `json:"certno"`
  4008. // DiseCode string `json:"dise_code"`
  4009. // FixmedinsCode string `json:"fixmedins_code"`
  4010. // DedcHospLv string `json:"dedc_hosp_lv"`
  4011. // OpterName string `json:"opter_name"`
  4012. // Balc float64 `json:"balc"`
  4013. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4014. // PsnCertType string `json:"psn_cert_type"`
  4015. // HifobPay float64 `json:"hifob_pay"`
  4016. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4017. // HifesPay float64 `json:"hifes_pay"`
  4018. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4019. // OptTime string `json:"opt_time"`
  4020. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4021. // SetlID string `json:"setl_id"`
  4022. // MafPay float64 `json:"maf_pay"`
  4023. // PsnName string `json:"psn_name"`
  4024. // InsuOptins interface{} `json:"insu_optins"`
  4025. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4026. // ClrOptins string `json:"clr_optins"`
  4027. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4028. // DiseName string `json:"dise_name"`
  4029. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4030. // Age float64 `json:"age"`
  4031. // DtrtCertType string `json:"dtrt_cert_type"`
  4032. // HospLv string `json:"hosp_lv"`
  4033. // } `json:"setlinfo"`
  4034. // Setldetail []struct {
  4035. // FundPayType string `json:"fund_pay_type"`
  4036. // FundPayamt float64 `json:"fund_payamt"`
  4037. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4038. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4039. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4040. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4041. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4042. // } `json:"setldetail"`
  4043. // } `json:"output"`
  4044. // Infcode int `json:"infcode"`
  4045. // WarnMsg interface{} `json:"warn_msg"`
  4046. // Cainfo interface{} `json:"cainfo"`
  4047. // ErrMsg interface{} `json:"err_msg"`
  4048. // RefmsgTime string `json:"refmsg_time"`
  4049. // Signtype interface{} `json:"signtype"`
  4050. // RespondTime string `json:"respond_time"`
  4051. // InfRefmsgid string `json:"inf_refmsgid"`
  4052. //}
  4053. type ResultEleven struct {
  4054. Cainfo string `json:"cainfo"`
  4055. ErrMsg string `json:"err_msg"`
  4056. InfRefmsgid string `json:"inf_refmsgid"`
  4057. Infcode int64 `json:"infcode"`
  4058. Output struct {
  4059. Setlinfo struct {
  4060. SetlTime string `json:"setl_time"`
  4061. CvlservPay float64 `json:"cvlserv_pay"`
  4062. Year string `json:"year"`
  4063. MedType string `json:"med_type"`
  4064. PsnPay float64 `json:"psn_pay"`
  4065. OpterID string `json:"opter_id"`
  4066. Begndate string `json:"begndate"`
  4067. FlxempeFlag string `json:"flxempe_flag"`
  4068. HifmiPay float64 `json:"hifmi_pay"`
  4069. PsnNo string `json:"psn_no"`
  4070. ActPayDedc float64 `json:"act_pay_dedc"`
  4071. MedinsSetlID interface{} `json:"medins_setl_id"`
  4072. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4073. ClrWay string `json:"clr_way"`
  4074. OthPay float64 `json:"oth_pay"`
  4075. Gend string `json:"gend"`
  4076. MdtrtID string `json:"mdtrt_id"`
  4077. AcctPay float64 `json:"acct_pay"`
  4078. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4079. Insutype string `json:"insutype"`
  4080. Invono interface{} `json:"invono"`
  4081. Enddate string `json:"enddate"`
  4082. CashPayamt float64 `json:"cash_payamt"`
  4083. PsnType string `json:"psn_type"`
  4084. FixmedinsName string `json:"fixmedins_name"`
  4085. HifpPay float64 `json:"hifp_pay"`
  4086. NewFlag interface{} `json:"new_flag"`
  4087. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4088. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4089. PayLoc string `json:"pay_loc"`
  4090. ClrType string `json:"clr_type"`
  4091. RefdSetlFlag string `json:"refd_setl_flag"`
  4092. CvlservFlag string `json:"cvlserv_flag"`
  4093. EmpName string `json:"emp_name"`
  4094. Brdy string `json:"brdy"`
  4095. Naty string `json:"naty"`
  4096. Certno string `json:"certno"`
  4097. DiseCode string `json:"dise_code"`
  4098. FixmedinsCode string `json:"fixmedins_code"`
  4099. DedcHospLv string `json:"dedc_hosp_lv"`
  4100. OpterName string `json:"opter_name"`
  4101. Balc float64 `json:"balc"`
  4102. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4103. PsnCertType string `json:"psn_cert_type"`
  4104. HifobPay float64 `json:"hifob_pay"`
  4105. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4106. HifesPay float64 `json:"hifes_pay"`
  4107. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4108. OptTime string `json:"opt_time"`
  4109. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4110. SetlID string `json:"setl_id"`
  4111. MafPay float64 `json:"maf_pay"`
  4112. PsnName string `json:"psn_name"`
  4113. InsuOptins interface{} `json:"insu_optins"`
  4114. PrefFundPay interface{} `json:"pref_fund_pay"`
  4115. ClrOptins string `json:"clr_optins"`
  4116. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4117. DiseName string `json:"dise_name"`
  4118. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4119. Age float64 `json:"age"`
  4120. DtrtCertType string `json:"dtrt_cert_type"`
  4121. HospLv string `json:"hosp_lv"`
  4122. } `json:"setlinfo"`
  4123. } `json:"output"`
  4124. RefmsgTime string `json:"refmsg_time"`
  4125. RespondTime string `json:"respond_time"`
  4126. Signtype interface{} `json:"signtype"`
  4127. WarnMsg interface{} `json:"warn_msg"`
  4128. }
  4129. type ResultEleven10265 struct {
  4130. Cainfo string `json:"cainfo"`
  4131. ErrMsg string `json:"err_msg"`
  4132. InfRefmsgid string `json:"inf_refmsgid"`
  4133. Infcode string `json:"infcode"`
  4134. Output struct {
  4135. Setlinfo struct {
  4136. SetlTime string `json:"setl_time"`
  4137. CvlservPay float64 `json:"cvlserv_pay"`
  4138. Year string `json:"year"`
  4139. MedType string `json:"med_type"`
  4140. PsnPay float64 `json:"psn_pay"`
  4141. OpterID string `json:"opter_id"`
  4142. Begndate string `json:"begndate"`
  4143. FlxempeFlag string `json:"flxempe_flag"`
  4144. HifmiPay float64 `json:"hifmi_pay"`
  4145. PsnNo string `json:"psn_no"`
  4146. ActPayDedc float64 `json:"act_pay_dedc"`
  4147. MedinsSetlID interface{} `json:"medins_setl_id"`
  4148. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4149. ClrWay string `json:"clr_way"`
  4150. OthPay float64 `json:"oth_pay"`
  4151. Gend string `json:"gend"`
  4152. MdtrtID string `json:"mdtrt_id"`
  4153. AcctPay float64 `json:"acct_pay"`
  4154. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4155. Insutype string `json:"insutype"`
  4156. Invono interface{} `json:"invono"`
  4157. Enddate string `json:"enddate"`
  4158. CashPayamt float64 `json:"cash_payamt"`
  4159. PsnType string `json:"psn_type"`
  4160. FixmedinsName string `json:"fixmedins_name"`
  4161. HifpPay float64 `json:"hifp_pay"`
  4162. NewFlag interface{} `json:"new_flag"`
  4163. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4164. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4165. PayLoc string `json:"pay_loc"`
  4166. ClrType string `json:"clr_type"`
  4167. RefdSetlFlag string `json:"refd_setl_flag"`
  4168. CvlservFlag string `json:"cvlserv_flag"`
  4169. EmpName string `json:"emp_name"`
  4170. Brdy string `json:"brdy"`
  4171. Naty string `json:"naty"`
  4172. Certno string `json:"certno"`
  4173. DiseCode string `json:"dise_code"`
  4174. FixmedinsCode string `json:"fixmedins_code"`
  4175. DedcHospLv string `json:"dedc_hosp_lv"`
  4176. OpterName string `json:"opter_name"`
  4177. Balc float64 `json:"balc"`
  4178. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4179. PsnCertType string `json:"psn_cert_type"`
  4180. HifobPay float64 `json:"hifob_pay"`
  4181. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4182. HifesPay float64 `json:"hifes_pay"`
  4183. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4184. OptTime string `json:"opt_time"`
  4185. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4186. SetlID string `json:"setl_id"`
  4187. MafPay float64 `json:"maf_pay"`
  4188. PsnName string `json:"psn_name"`
  4189. InsuOptins interface{} `json:"insu_optins"`
  4190. PrefFundPay interface{} `json:"pref_fund_pay"`
  4191. ClrOptins string `json:"clr_optins"`
  4192. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4193. DiseName string `json:"dise_name"`
  4194. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4195. Age float64 `json:"age"`
  4196. DtrtCertType string `json:"dtrt_cert_type"`
  4197. HospLv string `json:"hosp_lv"`
  4198. } `json:"setlinfo"`
  4199. } `json:"output"`
  4200. RefmsgTime string `json:"refmsg_time"`
  4201. RespondTime string `json:"respond_time"`
  4202. Signtype interface{} `json:"signtype"`
  4203. WarnMsg interface{} `json:"warn_msg"`
  4204. }
  4205. type ResultTwelve struct {
  4206. Cainfo string `json:"cainfo"`
  4207. ErrMsg string `json:"err_msg"`
  4208. InfRefmsgid string `json:"inf_refmsgid"`
  4209. Infcode int64 `json:"infcode"`
  4210. Output struct {
  4211. MdtrtId string `json:"mdtrt_id"`
  4212. ChrgBchno string `json:"chrg_bchno"`
  4213. PsnNo string `json:"psn_no"`
  4214. } `json:"output"`
  4215. RefmsgTime string `json:"refmsg_time"`
  4216. RespondTime string `json:"respond_time"`
  4217. Signtype interface{} `json:"signtype"`
  4218. WarnMsg interface{} `json:"warn_msg"`
  4219. }
  4220. type ResultThirteen struct {
  4221. ErrMsg string `json:"err_msg"`
  4222. InfRefmsgid string `json:"inf_refmsgid"`
  4223. Infcode int64 `json:"infcode"`
  4224. Output struct {
  4225. Result struct {
  4226. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4227. } `json:"result"`
  4228. } `json:"output"`
  4229. RefmsgTime string `json:"refmsg_time"`
  4230. RespondTime string `json:"respond_time"`
  4231. Signtype interface{} `json:"signtype"`
  4232. WarnInfo interface{} `json:"warn_info"`
  4233. }
  4234. type ResultThirteen10265 struct {
  4235. ErrMsg string `json:"err_msg"`
  4236. InfRefmsgid string `json:"inf_refmsgid"`
  4237. Infcode string `json:"infcode"`
  4238. Output struct {
  4239. Result struct {
  4240. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4241. } `json:"result"`
  4242. } `json:"output"`
  4243. RefmsgTime string `json:"refmsg_time"`
  4244. RespondTime string `json:"respond_time"`
  4245. Signtype interface{} `json:"signtype"`
  4246. WarnInfo interface{} `json:"warn_info"`
  4247. }
  4248. type ResultFourteen struct {
  4249. ErrMsg string `json:"err_msg"`
  4250. InfRefmsgid string `json:"inf_refmsgid"`
  4251. Infcode int64 `json:"infcode"`
  4252. Output struct {
  4253. } `json:"output"`
  4254. RefmsgTime string `json:"refmsg_time"`
  4255. RespondTime string `json:"respond_time"`
  4256. Signtype interface{} `json:"signtype"`
  4257. WarnInfo interface{} `json:"warn_info"`
  4258. }
  4259. type ResultFourteen10265 struct {
  4260. ErrMsg string `json:"err_msg"`
  4261. InfRefmsgid string `json:"inf_refmsgid"`
  4262. Infcode string `json:"infcode"`
  4263. Output struct {
  4264. } `json:"output"`
  4265. RefmsgTime string `json:"refmsg_time"`
  4266. RespondTime string `json:"respond_time"`
  4267. Signtype interface{} `json:"signtype"`
  4268. WarnInfo interface{} `json:"warn_info"`
  4269. }
  4270. type ResultSixteen struct {
  4271. Cainfo string `json:"cainfo"`
  4272. ErrMsg string `json:"err_msg"`
  4273. InfRefmsgid string `json:"inf_refmsgid"`
  4274. Infcode int64 `json:"infcode"`
  4275. Output struct {
  4276. Setldetail []interface{} `json:"setldetail"`
  4277. Setlinfo struct {
  4278. MdtrtID string `json:"mdtrt_id"`
  4279. SetlID string `json:"setl_id"`
  4280. ClrOptins string `json:"clr_optins"`
  4281. SetlTime string `json:"setl_time"`
  4282. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4283. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4284. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4285. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4286. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4287. ActPayDedc float64 `json:"act_pay_dedc"`
  4288. HifpPay float64 `json:"hifp_pay"`
  4289. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4290. Lfpay float64 `json:"selfpay"`
  4291. CvlservPay float64 `json:"cvlserv_pay"`
  4292. HifesPay float64 `json:"hifes_pay"`
  4293. HifmiPay float64 `json:"hifmi_pay"`
  4294. HifobPay float64 `json:"hifob_pay"`
  4295. MafPay float64 `json:"maf_pay"`
  4296. OthPay float64 `json:"oth_pay"`
  4297. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4298. PsnPartAmt float64 `json:"psn_part_amt"`
  4299. AcctPay float64 `json:"acct_pay"`
  4300. Balc float64 `json:"balc"`
  4301. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4302. HospPartAmt float64 `json:"hosp_part_amt"`
  4303. MedinsSetlID string `json:"medins_setl_id"`
  4304. PdnCashPay string `json:"pdn_cash_pay"`
  4305. } `json:"setlinfo"`
  4306. } `json:"output"`
  4307. RefmsgTime string `json:"refmsg_time"`
  4308. RespondTime string `json:"respond_time"`
  4309. Signtype interface{} `json:"signtype"`
  4310. WarnMsg interface{} `json:"warn_msg"`
  4311. }
  4312. type ResultSixteen10265 struct {
  4313. Cainfo string `json:"cainfo"`
  4314. ErrMsg string `json:"err_msg"`
  4315. InfRefmsgid string `json:"inf_refmsgid"`
  4316. Infcode string `json:"infcode"`
  4317. Output struct {
  4318. Setldetail []interface{} `json:"setldetail"`
  4319. Setlinfo struct {
  4320. MdtrtID string `json:"mdtrt_id"`
  4321. SetlID string `json:"setl_id"`
  4322. ClrOptins string `json:"clr_optins"`
  4323. SetlTime string `json:"setl_time"`
  4324. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4325. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4326. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4327. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4328. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4329. ActPayDedc float64 `json:"act_pay_dedc"`
  4330. HifpPay float64 `json:"hifp_pay"`
  4331. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4332. Lfpay float64 `json:"selfpay"`
  4333. CvlservPay float64 `json:"cvlserv_pay"`
  4334. HifesPay float64 `json:"hifes_pay"`
  4335. HifmiPay float64 `json:"hifmi_pay"`
  4336. HifobPay float64 `json:"hifob_pay"`
  4337. MafPay float64 `json:"maf_pay"`
  4338. OthPay float64 `json:"oth_pay"`
  4339. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4340. PsnPartAmt float64 `json:"psn_part_amt"`
  4341. AcctPay float64 `json:"acct_pay"`
  4342. Balc float64 `json:"balc"`
  4343. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4344. HospPartAmt float64 `json:"hosp_part_amt"`
  4345. MedinsSetlID string `json:"medins_setl_id"`
  4346. PdnCashPay string `json:"pdn_cash_pay"`
  4347. } `json:"setlinfo"`
  4348. } `json:"output"`
  4349. RefmsgTime string `json:"refmsg_time"`
  4350. RespondTime string `json:"respond_time"`
  4351. Signtype interface{} `json:"signtype"`
  4352. WarnMsg interface{} `json:"warn_msg"`
  4353. }
  4354. type ResultSeventeen struct {
  4355. ErrMsg string `json:"err_msg"`
  4356. InfRefmsgid string `json:"inf_refmsgid"`
  4357. Infcode int64 `json:"infcode"`
  4358. Output struct {
  4359. SetlListId string `json:"setl_list_id"`
  4360. } `json:"output"`
  4361. RefmsgTime string `json:"refmsg_time"`
  4362. RespondTime string `json:"respond_time"`
  4363. Signtype string `json:"signtype"`
  4364. WarnInfo string `json:"warn_info"`
  4365. }
  4366. type ResultSeventeenOther struct {
  4367. ErrMsg string `json:"err_msg"`
  4368. InfRefmsgid string `json:"inf_refmsgid"`
  4369. Infcode string `json:"infcode"`
  4370. Output struct {
  4371. SetlListId string `json:"setl_list_id"`
  4372. } `json:"output"`
  4373. RefmsgTime string `json:"refmsg_time"`
  4374. RespondTime string `json:"respond_time"`
  4375. Signtype string `json:"signtype"`
  4376. WarnInfo string `json:"warn_info"`
  4377. }
  4378. type Result90991 struct {
  4379. ErrMsg string `json:"err_msg"`
  4380. InfRefmsgid string `json:"inf_refmsgid"`
  4381. Infcode int64 `json:"infcode"`
  4382. Output struct {
  4383. Result struct {
  4384. PsnNo string `json:"psn_no"`
  4385. CardStat string `json:"card_stat"`
  4386. Certno string `json:"certno"`
  4387. PsnName string `json:"psn_name"`
  4388. CheckStat string `json:"check_stat"`
  4389. SscnoCheckStat string `json:"sscno_check_stat"`
  4390. } `json:"result"`
  4391. } `json:"output"`
  4392. RefmsgTime string `json:"refmsg_time"`
  4393. RespondTime string `json:"respond_time"`
  4394. Signtype interface{} `json:"signtype"`
  4395. WarnInfo interface{} `json:"warn_info"`
  4396. }
  4397. type Result90100 struct {
  4398. ErrMsg string `json:"err_msg"`
  4399. InfRefmsgid string `json:"inf_refmsgid"`
  4400. Infcode int64 `json:"infcode"`
  4401. Output struct {
  4402. PoolareaNo string `json:"poolarea_no"`
  4403. PoolareaNoName string `json:"poolarea_no_name"`
  4404. Insutype string `json:"insutype"`
  4405. InsutypeName string `json:"insutype_name"`
  4406. ClctType string `json:"clct_type"`
  4407. ClctTypeName string `json:"clct_type_name"`
  4408. ClctFlag string `json:"clct_flag"`
  4409. ClctFlagName string `json:"clct_flag_name"`
  4410. AccrymBegn string `json:"accrym_begn"`
  4411. AccrymEnd string `json:"accrym_end"`
  4412. ClctTime string `json:"clct_time"`
  4413. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4414. } `json:"output"`
  4415. RefmsgTime string `json:"refmsg_time"`
  4416. RespondTime string `json:"respond_time"`
  4417. Signtype interface{} `json:"signtype"`
  4418. WarnInfo interface{} `json:"warn_info"`
  4419. }
  4420. type Custom struct {
  4421. DetItemFeeSumamt string
  4422. Cut string
  4423. FeedetlSn string
  4424. Price string
  4425. MedListCodg string
  4426. Type int64
  4427. AdviceId int64
  4428. ProjectId int64
  4429. ItemId int64
  4430. }
  4431. type Result5301 struct {
  4432. ErrMsg string `json:"err_msg"`
  4433. InfRefmsgid string `json:"inf_refmsgid"`
  4434. Infcode int64 `json:"infcode"`
  4435. Output struct {
  4436. Result []struct {
  4437. OpspDiseCode string `json:"opsp_dise_code"`
  4438. OpspDiseName string `json:"opsp_dise_name"`
  4439. Begndate string `json:"begndate"`
  4440. Enddate string `json:"enddate"`
  4441. } `json:"feedetail"`
  4442. } `json:"output"`
  4443. RefmsgTime string `json:"refmsg_time"`
  4444. RespondTime string `json:"respond_time"`
  4445. Signtype interface{} `json:"signtype"`
  4446. WarnInfo interface{} `json:"warn_info"`
  4447. }
  4448. type Result5301For10265 struct {
  4449. ErrMsg string `json:"err_msg"`
  4450. InfRefmsgid string `json:"inf_refmsgid"`
  4451. Infcode string `json:"infcode"`
  4452. Output struct {
  4453. Result []struct {
  4454. OpspDiseCode string `json:"opsp_dise_code"`
  4455. OpspDiseName string `json:"opsp_dise_name"`
  4456. Begndate string `json:"begndate"`
  4457. Enddate string `json:"enddate"`
  4458. } `json:"feedetail"`
  4459. } `json:"output"`
  4460. RefmsgTime string `json:"refmsg_time"`
  4461. RespondTime string `json:"respond_time"`
  4462. Signtype interface{} `json:"signtype"`
  4463. WarnInfo interface{} `json:"warn_info"`
  4464. }
  4465. //获取个人信息----挂号-----上传就诊信息
  4466. func (c *HisApiController) GetRegisterInfo() {
  4467. id, _ := c.GetInt64("id")
  4468. record_time := c.GetString("record_time")
  4469. settlementValue, _ := c.GetInt64("settlement_value")
  4470. medical_insurance_card := c.GetString("medical_insurance_card")
  4471. name := c.GetString("name")
  4472. id_card_type, _ := c.GetInt64("id_card_type")
  4473. certificates, _ := c.GetInt64("certificates")
  4474. medical_care, _ := c.GetInt64("medical_care")
  4475. birthday := c.GetString("birthday")
  4476. id_card := c.GetString("id_card")
  4477. register_type, _ := c.GetInt64("register")
  4478. doctor, _ := c.GetInt64("doctor")
  4479. department, _ := c.GetInt64("department")
  4480. gender, _ := c.GetInt64("sex")
  4481. registration_fee, _ := c.GetFloat("registration_fee")
  4482. medical_expenses, _ := c.GetFloat("medical_expenses")
  4483. social_type, _ := c.GetInt64("social_type")
  4484. med_type := c.GetString("social_type")
  4485. admin_user_id, _ := c.GetInt64("admin_user_id")
  4486. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4487. timeLayout := "2006-01-02"
  4488. loc, _ := time.LoadLocation("Local")
  4489. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4490. birthUnix := birthdays.Unix()
  4491. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4492. if err != nil {
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4494. return
  4495. }
  4496. recordDateTime := theTime.Unix()
  4497. adminInfo := c.GetAdminUserInfo()
  4498. var patient service.Patients
  4499. if id == 0 {
  4500. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4501. } else {
  4502. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4503. }
  4504. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4505. if patientPrescription.ID == 0 {
  4506. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4507. }
  4508. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4509. if patient.ID == 0 {
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4511. return
  4512. }
  4513. if len(patient.IdCardNo) == 0 {
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4515. return
  4516. }
  4517. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4518. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4519. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4520. //就诊结算未完成,不能进行二次挂号
  4521. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4522. if len(his) >= 1 {
  4523. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4524. if len(his) >= 1 && order.ID == 0 {
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4526. return
  4527. }
  4528. }
  4529. //var register_log string
  4530. if config.IsOpen == 1 {
  4531. var res ResultTwo
  4532. var res10265 ResultTwo10265
  4533. var PsnNo string
  4534. var PsnCertType string
  4535. var Certno string
  4536. var PsnName string
  4537. var Gend string
  4538. var Naty string
  4539. var Brdy string
  4540. var Age float64
  4541. var infoStr string
  4542. var idetinfoStr string
  4543. var infocode int64
  4544. var verify_number string
  4545. fmt.Println(verify_number)
  4546. if miConfig.MdtrtareaAdmvs == "421300" {
  4547. psn_info, _ := service.GetPsnByPatientId(id)
  4548. PsnNo = psn_info.PsnNo
  4549. PsnCertType = psn_info.PsnCertType
  4550. Certno = psn_info.Certno
  4551. PsnName = psn_info.PsnName
  4552. Gend = psn_info.Gend
  4553. Naty = psn_info.Naty
  4554. Brdy = psn_info.Brdy
  4555. Age = psn_info.Age
  4556. infoStr = psn_info.Insuinfo
  4557. idetinfoStr = psn_info.Idetinfo
  4558. infocode = 0
  4559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4560. psn_info, _ := service.GetPsnByPatientId(id)
  4561. PsnNo = psn_info.PsnNo
  4562. PsnCertType = psn_info.PsnCertType
  4563. Certno = psn_info.Certno
  4564. PsnName = psn_info.PsnName
  4565. Gend = psn_info.Gend
  4566. Naty = psn_info.Naty
  4567. Brdy = psn_info.Brdy
  4568. Age = psn_info.Age
  4569. infoStr = psn_info.Insuinfo
  4570. idetinfoStr = psn_info.Idetinfo
  4571. infocode = 0
  4572. verify_number = psn_info.VerifyNumber
  4573. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4574. if id_card_type == 1 {
  4575. psn_info, _ := service.GetPsnByPatientId(id)
  4576. PsnNo = psn_info.PsnNo
  4577. PsnCertType = psn_info.PsnCertType
  4578. Certno = psn_info.Certno
  4579. PsnName = psn_info.PsnName
  4580. Gend = psn_info.Gend
  4581. Naty = psn_info.Naty
  4582. Brdy = psn_info.Brdy
  4583. Age = psn_info.Age
  4584. infoStr = psn_info.Insuinfo
  4585. idetinfoStr = psn_info.Idetinfo
  4586. infocode = 0
  4587. verify_number = psn_info.VerifyNumber
  4588. } else if id_card_type == 2 {
  4589. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  4590. fmt.Println(errMsgLog)
  4591. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4592. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4593. utils.ErrorLog("解析失败:%v", err)
  4594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4595. return
  4596. }
  4597. PsnNo = res.Output.Baseinfo.PsnNo
  4598. PsnCertType = res.Output.Baseinfo.PsnCertType
  4599. Certno = res.Output.Baseinfo.Certno
  4600. PsnName = res.Output.Baseinfo.PsnName
  4601. Gend = res.Output.Baseinfo.Gend
  4602. Naty = res.Output.Baseinfo.Naty
  4603. Brdy = res.Output.Baseinfo.Brdy
  4604. Age = res.Output.Baseinfo.Age
  4605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4607. infoStr = string(Iinfos)
  4608. idetinfoStr = string(Idetinfos)
  4609. infocode = res.Infcode
  4610. }
  4611. } else {
  4612. var result string
  4613. var requestLog string
  4614. if miConfig.UserOrgId == 10138 {
  4615. 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)
  4616. } else {
  4617. 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)
  4618. }
  4619. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4620. if miConfig.Code == "H15049901371" {
  4621. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4622. utils.ErrorLog("解析失败:%v", err)
  4623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4624. return
  4625. }
  4626. res.ErrMsg = res10265.ErrMsg
  4627. res.Output = res10265.Output
  4628. res.InfRefmsgid = res10265.InfRefmsgid
  4629. } else {
  4630. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4631. utils.ErrorLog("解析失败:%v", err)
  4632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4633. return
  4634. }
  4635. }
  4636. PsnNo = res.Output.Baseinfo.PsnNo
  4637. PsnCertType = res.Output.Baseinfo.PsnCertType
  4638. Certno = res.Output.Baseinfo.Certno
  4639. PsnName = res.Output.Baseinfo.PsnName
  4640. Gend = res.Output.Baseinfo.Gend
  4641. Naty = res.Output.Baseinfo.Naty
  4642. Brdy = res.Output.Baseinfo.Brdy
  4643. Age = res.Output.Baseinfo.Age
  4644. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4645. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4646. infoStr = string(Iinfos)
  4647. idetinfoStr = string(Idetinfos)
  4648. if miConfig.Code == "H15049901371" {
  4649. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4650. } else {
  4651. infocode = res.Infcode
  4652. }
  4653. }
  4654. if infocode == 0 {
  4655. his := models.VMHisPatient{
  4656. Name: name,
  4657. Gender: gender,
  4658. Birthday: birthUnix,
  4659. MedicalTreatmentType: medical_care,
  4660. IdType: certificates,
  4661. IdCardNo: id_card,
  4662. BalanceAccountsType: settlementValue,
  4663. SocialType: social_type,
  4664. MedicalInsuranceNumber: medical_insurance_card,
  4665. RegisterType: register_type,
  4666. RegisterCost: registration_fee,
  4667. TreatmentCost: medical_expenses,
  4668. Status: 1,
  4669. Ctime: time.Now().Unix(),
  4670. Mtime: time.Now().Unix(),
  4671. PsnNo: PsnNo,
  4672. PsnCertType: PsnCertType,
  4673. Certno: Certno,
  4674. PsnName: PsnName,
  4675. Gend: Gend,
  4676. Naty: Naty,
  4677. Brdy: Brdy,
  4678. Age: Age,
  4679. Iinfo: infoStr,
  4680. Idetinfo: idetinfoStr,
  4681. PatientId: patient.ID,
  4682. RecordDate: theTime.Unix(),
  4683. UserOrgId: adminInfo.CurrentOrgId,
  4684. AdminUserId: admin_user_id,
  4685. IsReturn: 1,
  4686. IdCardType: id_card_type,
  4687. Doctor: doctor,
  4688. Departments: department,
  4689. }
  4690. timestamp := time.Now().Unix()
  4691. tempTime := time.Unix(timestamp, 0)
  4692. timeFormat := tempTime.Format("20060102150405")
  4693. chrgBchno := rand.Intn(100000) + 10000
  4694. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4695. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4696. department, _ := service.GetDepartMentDetail(department)
  4697. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4698. IdCardNo := ""
  4699. if id_card_type == 1 {
  4700. // IdCardNo = medical_insurance_card
  4701. IdCardNo = patient.IdCardNo
  4702. } else {
  4703. IdCardNo = patient.IdCardNo
  4704. }
  4705. var rf []*ResultFive
  4706. json.Unmarshal([]byte(his.Iinfo), &rf)
  4707. var insutypes []*ResultFive
  4708. var insutype string
  4709. var insuplc_admdvs_temp string
  4710. var is390 int = 0
  4711. var is310 int = 0
  4712. for _, item := range rf {
  4713. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4714. insutypes = append(insutypes, item)
  4715. }
  4716. }
  4717. if len(insutypes) == 1 {
  4718. insutype = insutypes[0].Insutype
  4719. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4720. } else {
  4721. for _, i := range insutypes {
  4722. if i.Insutype == "390" {
  4723. is390 = 1
  4724. }
  4725. if i.Insutype == "310" {
  4726. is310 = 1
  4727. }
  4728. }
  4729. }
  4730. if is390 == 1 {
  4731. insutype = "390"
  4732. }
  4733. if is310 == 1 {
  4734. insutype = "310"
  4735. }
  4736. if len(insutypes) == 0 {
  4737. insutype = "310"
  4738. }
  4739. if len(insutypes) == 2 {
  4740. insutype = med_type
  4741. }
  4742. if len(med_type) > 0 {
  4743. insutype = med_type
  4744. }
  4745. //for _, item := range rf {
  4746. // if item.Insutype == insutype {
  4747. // insuplc_admdvs = item.InsuplcAdmdvs
  4748. // }
  4749. //}
  4750. var infocode int64
  4751. var resThree ResultThree
  4752. var resThree10265 ResultThree10265
  4753. if len(insuplc_admdvs) == 0 {
  4754. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4755. } else {
  4756. insuplc_admdvs_temp = insuplc_admdvs
  4757. }
  4758. if miConfig.MdtrtareaAdmvs == "421300" {
  4759. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4760. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4761. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4762. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4763. resp, requestErr := http.Get(api)
  4764. if requestErr != nil {
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. body, ioErr := ioutil.ReadAll(resp.Body)
  4769. if ioErr != nil {
  4770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. var respJSON map[string]interface{}
  4775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4778. return
  4779. }
  4780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4781. result, _ := json.Marshal(respJSON)
  4782. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4783. utils.ErrorLog("解析失败:%v", err)
  4784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4785. return
  4786. }
  4787. infocode = resThree.Infcode
  4788. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4789. psn_info, _ := service.GetPsnByPatientId(id)
  4790. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4791. var cert_no string
  4792. if id_card_type == 3 {
  4793. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4794. cert_no = IdCardNo
  4795. } else if id_card_type == 4 {
  4796. cert_no = IdCardNo
  4797. psn_info.VerifyNumber = psn_info.VerifyNumber
  4798. } else {
  4799. bas := strings.Split(psn_info.CardInfo, "|")
  4800. cert_no = bas[2]
  4801. }
  4802. var api string
  4803. if miConfig.MdtrtareaAdmvs == "320921" {
  4804. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4805. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4806. "&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
  4807. } else {
  4808. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4809. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4810. "&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
  4811. }
  4812. resp, requestErr := http.Get(api)
  4813. if requestErr != nil {
  4814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4815. return
  4816. }
  4817. body, ioErr := ioutil.ReadAll(resp.Body)
  4818. if ioErr != nil {
  4819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4821. return
  4822. }
  4823. var respJSON map[string]interface{}
  4824. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4827. return
  4828. }
  4829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4830. result, _ := json.Marshal(respJSON)
  4831. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4832. utils.ErrorLog("解析失败:%v", err)
  4833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4834. return
  4835. }
  4836. resThree.ErrMsg = resThree10265.ErrMsg
  4837. resThree.Output = resThree10265.Output
  4838. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4839. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4840. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4841. psn_info, _ := service.GetPsnByPatientId(id)
  4842. var cert_no string
  4843. if id_card_type == 1 {
  4844. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4845. } else {
  4846. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  4847. }
  4848. fmt.Println(cert_no)
  4849. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  4850. saveLog(result, requestLog, "2201", "挂号")
  4851. if miConfig.Code == "H15049901371" {
  4852. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4853. utils.ErrorLog("解析失败:%v", err)
  4854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4855. return
  4856. }
  4857. resThree.ErrMsg = resThree10265.ErrMsg
  4858. resThree.Output = resThree10265.Output
  4859. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4860. } else {
  4861. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4862. utils.ErrorLog("解析失败:%v", err)
  4863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4864. return
  4865. }
  4866. }
  4867. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4868. } else {
  4869. 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)
  4870. saveLog(result, requestLog, "2201A", "挂号")
  4871. if miConfig.Code == "H15049901371" {
  4872. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4875. return
  4876. }
  4877. resThree.ErrMsg = resThree10265.ErrMsg
  4878. resThree.Output = resThree10265.Output
  4879. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4880. } else {
  4881. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4882. utils.ErrorLog("解析失败:%v", err)
  4883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4884. return
  4885. }
  4886. }
  4887. if miConfig.Code == "H15049901371" {
  4888. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4889. } else {
  4890. infocode = resThree.Infcode
  4891. }
  4892. }
  4893. if infocode != 0 {
  4894. adminUser := c.GetAdminUserInfo()
  4895. errlog := &models.HisOrderError{
  4896. UserOrgId: adminUser.CurrentOrgId,
  4897. Ctime: time.Now().Unix(),
  4898. Mtime: time.Now().Unix(),
  4899. ErrMsg: resThree.ErrMsg,
  4900. Status: 1,
  4901. PatientId: id,
  4902. RecordTime: recordDateTime,
  4903. Stage: 2,
  4904. }
  4905. service.CreateErrMsgLog(errlog)
  4906. c.ServeSuccessJSON(map[string]interface{}{
  4907. "failed_code": -10,
  4908. "msg": resThree.ErrMsg,
  4909. })
  4910. return
  4911. }
  4912. his.Number = resThree.Output.Data.MdtrtID
  4913. his.PsnNo = resThree.Output.Data.PsnNo
  4914. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4915. his.IdCardNo = patient.IdCardNo
  4916. his.PhoneNumber = patient.Phone
  4917. his.UserOrgId = adminInfo.CurrentOrgId
  4918. his.Insutype = insutype
  4919. his.Ctime = time.Now().Unix()
  4920. his.Mtime = time.Now().Unix()
  4921. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4922. his.Status = 1
  4923. service.UpdateHisPatientStatus(&his)
  4924. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4925. c.ServeSuccessJSON(map[string]interface{}{
  4926. "his_info": his,
  4927. })
  4928. } else {
  4929. adminUser := c.GetAdminUserInfo()
  4930. errlog := &models.HisOrderError{
  4931. UserOrgId: adminUser.CurrentOrgId,
  4932. Ctime: time.Now().Unix(),
  4933. Mtime: time.Now().Unix(),
  4934. ErrMsg: res.ErrMsg,
  4935. Status: 1,
  4936. PatientId: id,
  4937. RecordTime: recordDateTime,
  4938. Stage: 1,
  4939. }
  4940. service.CreateErrMsgLog(errlog)
  4941. c.ServeSuccessJSON(map[string]interface{}{
  4942. "failed_code": -10,
  4943. "msg": res.ErrMsg,
  4944. })
  4945. return
  4946. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4947. }
  4948. }
  4949. }
  4950. //上传明细----预结算----确认订单
  4951. func (c *HisApiController) GetUploadInfo() {
  4952. id, _ := c.GetInt64("id")
  4953. record_time := c.GetString("record_time")
  4954. his_patient_id, _ := c.GetInt64("his_patient_id")
  4955. order_id, _ := c.GetInt64("order_id")
  4956. pay_way, _ := c.GetInt64("pay_way")
  4957. pay_price, _ := c.GetFloat("pay_price")
  4958. pay_card_no := c.GetString("pay_card_no")
  4959. token := c.GetString("token")
  4960. discount_price, _ := c.GetFloat("discount_price")
  4961. preferential_price, _ := c.GetFloat("preferential_price")
  4962. reality_price, _ := c.GetFloat("reality_price")
  4963. found_price, _ := c.GetFloat("found_price")
  4964. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4965. private_price, _ := c.GetFloat("private_price")
  4966. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4967. admin_user_id, _ := c.GetInt64("admin_user_id")
  4968. fapiao_code := c.GetString("fapiao_code")
  4969. fapiao_number := c.GetString("fapiao_number")
  4970. diagnosis_id := c.GetString("diagnosis")
  4971. sick_type, _ := c.GetInt64("sick_type")
  4972. reg_type, _ := c.GetInt64("p_type")
  4973. begin_time := c.GetString("begin_time")
  4974. id_str := c.GetString("ids")
  4975. ids_arr := strings.Split(id_str, ",")
  4976. timeLayout := "2006-01-02"
  4977. loc, _ := time.LoadLocation("Local")
  4978. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4979. if err != nil {
  4980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4981. return
  4982. }
  4983. recordDateTime := theTime.Unix()
  4984. adminUser := c.GetAdminUserInfo()
  4985. var tempOrder models.HisOrder
  4986. tempOrder, _ = service.GetHisOrderByID(order_id)
  4987. var prescriptions []*models.HisPrescription
  4988. var start_time int64
  4989. var end_time int64
  4990. //押金模块
  4991. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4992. tmp_decimal := c.GetString("tmp_decimal")
  4993. var decimal float64 //本次使用的押金
  4994. var errmsg error
  4995. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4996. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4997. return
  4998. }
  4999. if len(tmp_decimal) > 0 {
  5000. if tmp_decimal[0] == 45 {
  5001. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5002. return
  5003. }
  5004. }
  5005. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5006. fmt.Println(errs)
  5007. decimal = tt
  5008. //if adminUser.CurrentOrgId == 10106{
  5009. // if len(fapiao_code) == 0{
  5010. // fapiao_code = "144072080589"
  5011. // }
  5012. // if len(fapiao_number) == 0{
  5013. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5014. // if order.ID == 0{
  5015. // fapiao_number = "00001520"
  5016. // }else{
  5017. // //fapiao_code = "00001520"
  5018. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5019. // var zero string
  5020. // if fpNumber >= 1000{
  5021. // zero = "0000" + strconv.Itoa(fpNumber)
  5022. // }else if fpNumber >= 10000{
  5023. // zero = "000" + strconv.Itoa(fpNumber)
  5024. // } else if fpNumber >= 100000{
  5025. // zero = "00" + strconv.Itoa(fpNumber)
  5026. // } else if fpNumber >= 1000000{
  5027. // zero = "0" + strconv.Itoa(fpNumber)
  5028. // }else {
  5029. // zero = strconv.Itoa(fpNumber)
  5030. // }
  5031. // fapiao_number = zero
  5032. // }
  5033. // }
  5034. //}
  5035. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5036. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5037. var patientPrescription models.HisPrescriptionInfo
  5038. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5039. if patientPrescription.ID == 0 {
  5040. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5041. }
  5042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5043. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5044. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5045. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5046. var config []*models.HisXtDiagnoseConfig
  5047. for _, item := range diagnosis_ids {
  5048. id, _ := strconv.ParseInt(item, 10, 64)
  5049. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5050. config = append(config, &diagnosisConfig)
  5051. }
  5052. sickConfig, _ := service.FindSickById(sick_type)
  5053. //if tempOrder.ID == 0 {
  5054. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5055. //}
  5056. if tempOrder.ID == 0 {
  5057. var result string
  5058. var requestLog string
  5059. var res2 ResultSix
  5060. var ressix10265 ResultSix10265
  5061. if miConfig.MdtrtareaAdmvs == "421300" {
  5062. data := make(map[string]interface{})
  5063. client := &http.Client{}
  5064. data["psn_no"] = his.PsnNo
  5065. data["mdtrt_id"] = his.Number
  5066. data["opter"] = roles.UserName
  5067. data["org_name"] = miConfig.OrgName
  5068. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5069. data["doctor_id"] = doctor_info.DoctorNumber
  5070. data["doctor_name"] = doctor_info.UserName
  5071. data["department"] = department.Name
  5072. data["fixmedins_code"] = miConfig.Code
  5073. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5074. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5075. data["secret_key"] = miConfig.SecretKey
  5076. data["sick_code"] = sickConfig.CountryCode
  5077. data["sick_name"] = sickConfig.ClassName
  5078. data["dept"] = strconv.FormatInt(department.ID, 10)
  5079. data["config"] = config
  5080. data["begin_time"] = begin_time
  5081. bytesData, _ := json.Marshal(data)
  5082. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5083. resp, _ := client.Do(req)
  5084. defer resp.Body.Close()
  5085. body, ioErr := ioutil.ReadAll(resp.Body)
  5086. if ioErr != nil {
  5087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5089. return
  5090. }
  5091. var respJSON map[string]interface{}
  5092. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5095. return
  5096. }
  5097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5098. userJSONBytes, _ := json.Marshal(respJSON)
  5099. fmt.Println("log")
  5100. fmt.Println(string(userJSONBytes))
  5101. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5102. utils.ErrorLog("解析失败:%v", err)
  5103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5104. return
  5105. }
  5106. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5107. //江苏地区国家医保医疗类别
  5108. //职工透析:医疗类别选特殊情况门诊9933
  5109. //居民血透门慢: 医疗类别选门诊慢病1402
  5110. //var med_type string
  5111. //if his.Insutype == "310" {
  5112. // if reg_type == 14 {
  5113. // med_type = "9933"
  5114. // } else if reg_type == 11 {
  5115. // med_type = "11"
  5116. //
  5117. // }
  5118. //} else if his.Insutype == "390" {
  5119. // if reg_type == 14 {
  5120. // med_type = "1402"
  5121. // } else if reg_type == 11 {
  5122. // med_type = "11"
  5123. // }
  5124. //}
  5125. data := make(map[string]interface{})
  5126. client := &http.Client{}
  5127. data["psn_no"] = his.PsnNo
  5128. data["mdtrt_id"] = his.Number
  5129. data["doctor"] = roles.UserName
  5130. data["department"] = department.Name
  5131. data["org_name"] = miConfig.OrgName
  5132. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5133. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5134. data["fixmedins_code"] = miConfig.Code
  5135. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5136. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5137. data["secret_key"] = miConfig.SecretKey
  5138. data["sick_code"] = sickConfig.CountryCode
  5139. data["sick_name"] = sickConfig.ClassName
  5140. data["url"] = miConfig.Url
  5141. data["ak"] = miConfig.AccessKey
  5142. data["begin_time"] = begin_time
  5143. data["cainfo"] = miConfig.Cainfo
  5144. data["dept"] = strconv.FormatInt(department.ID, 10)
  5145. data["config"] = config
  5146. bytesData, _ := json.Marshal(data)
  5147. var req *http.Request
  5148. if miConfig.MdtrtareaAdmvs == "320921" {
  5149. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5150. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5151. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5152. } else {
  5153. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5154. }
  5155. resp, _ := client.Do(req)
  5156. defer resp.Body.Close()
  5157. body, ioErr := ioutil.ReadAll(resp.Body)
  5158. if ioErr != nil {
  5159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. return
  5162. }
  5163. var respJSON map[string]interface{}
  5164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5167. return
  5168. }
  5169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5170. userJSONBytes, _ := json.Marshal(respJSON)
  5171. fmt.Println("log")
  5172. fmt.Println(string(userJSONBytes))
  5173. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5174. utils.ErrorLog("解析失败:%v", err)
  5175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5176. return
  5177. }
  5178. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5179. res2.Output = ressix10265.Output
  5180. res2.ErrMsg = ressix10265.ErrMsg
  5181. res2.Cainfo = ressix10265.Cainfo
  5182. res2.WarnMsg = ressix10265.WarnMsg
  5183. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5184. res2.Infcode = infocode
  5185. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5186. result, requestLog, _ = service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5187. saveLog(result, requestLog, "2203", "上传就诊信息")
  5188. var respJSON2 map[string]interface{}
  5189. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. return
  5193. }
  5194. userJSONBytes2, _ := json.Marshal(respJSON2)
  5195. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5196. utils.ErrorLog("解析失败:%v", err)
  5197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5198. return
  5199. }
  5200. } else {
  5201. if miConfig.MdtrtareaAdmvs == "440781" { //
  5202. 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)
  5203. } else {
  5204. if miConfig.Code == "H15049901371" {
  5205. //赤峰地区国家医保医疗类别
  5206. //职工透析:医疗类别选特殊情况门诊990502
  5207. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5208. var med_type string
  5209. if his.Insutype == "390" {
  5210. if reg_type == 14 {
  5211. med_type = "9933"
  5212. } else if reg_type == 11 {
  5213. med_type = "11"
  5214. }
  5215. } else if his.Insutype == "310" {
  5216. if reg_type == 14 {
  5217. med_type = "990502"
  5218. } else if reg_type == 11 {
  5219. med_type = "11"
  5220. }
  5221. }
  5222. 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)
  5223. } else {
  5224. 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)
  5225. }
  5226. }
  5227. saveLog(result, requestLog, "2203", "上传就诊信息")
  5228. var respJSON2 map[string]interface{}
  5229. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5232. return
  5233. }
  5234. userJSONBytes2, _ := json.Marshal(respJSON2)
  5235. if miConfig.Code == "H15049901371" {
  5236. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5237. utils.ErrorLog("解析失败:%v", err)
  5238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5239. return
  5240. }
  5241. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5242. res2.Output = ressix10265.Output
  5243. res2.ErrMsg = ressix10265.ErrMsg
  5244. res2.Cainfo = ressix10265.Cainfo
  5245. res2.WarnMsg = ressix10265.WarnMsg
  5246. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5247. res2.Infcode = infocode
  5248. } else {
  5249. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5250. utils.ErrorLog("解析失败:%v", err)
  5251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5252. return
  5253. }
  5254. }
  5255. }
  5256. if res2.Infcode != 0 {
  5257. adminUser := c.GetAdminUserInfo()
  5258. errlog := &models.HisOrderError{
  5259. UserOrgId: adminUser.CurrentOrgId,
  5260. Ctime: time.Now().Unix(),
  5261. Mtime: time.Now().Unix(),
  5262. ErrMsg: res2.ErrMsg,
  5263. Status: 1,
  5264. PatientId: id,
  5265. RecordTime: recordDateTime,
  5266. Stage: 3,
  5267. }
  5268. service.CreateErrMsgLog(errlog)
  5269. c.ServeSuccessJSON(map[string]interface{}{
  5270. "failed_code": -10,
  5271. "msg": res2.ErrMsg,
  5272. })
  5273. return
  5274. } else {
  5275. his.Diagnosis = diagnosis_id
  5276. his.SickType = sickConfig.ID
  5277. //var p_type int64
  5278. //if reg_type == 1111 || reg_type == 1112 {
  5279. // p_type = 11
  5280. //
  5281. //}
  5282. his.PType = fmt.Sprintf("%d", reg_type)
  5283. service.UpdateHisPatientThree(&his)
  5284. data := make(map[string]interface{})
  5285. if settle_accounts_type == 1 { //日结
  5286. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5287. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5288. } else {
  5289. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5290. }
  5291. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5292. data["pre"] = prescriptions
  5293. } else { //月结
  5294. start_time_str := c.GetString("start_time")
  5295. end_time_str := c.GetString("end_time")
  5296. timeLayout := "2006-01-02"
  5297. loc, _ := time.LoadLocation("Local")
  5298. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5299. if err != nil {
  5300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5301. return
  5302. }
  5303. recordStartTime := theStartTime.Unix()
  5304. start_time = recordStartTime
  5305. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5306. if err != nil {
  5307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5308. return
  5309. }
  5310. recordEndTime := theEndTime.Unix()
  5311. end_time = recordEndTime
  5312. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5313. data["pre"] = prescriptions
  5314. }
  5315. timestamp := time.Now().Unix()
  5316. tempTime := time.Unix(timestamp, 0)
  5317. timeFormat := tempTime.Format("20060102150405")
  5318. chrgBchno := rand.Intn(100000) + 10000
  5319. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5320. strconv.FormatInt(his.PatientId, 10)
  5321. client := &http.Client{}
  5322. data["psn_no"] = his.PsnNo
  5323. data["mdtrt_id"] = his.Number
  5324. data["chrg_bchno"] = chrg_bchno
  5325. data["org_name"] = miConfig.OrgName
  5326. data["doctor"] = doctor_info.UserName
  5327. data["doctor_id"] = doctor_info.DoctorNumber
  5328. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5329. data["fixmedins_code"] = miConfig.Code
  5330. data["opter"] = roles.UserName
  5331. data["dept_code"] = department.Number
  5332. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5333. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5334. data["secret_key"] = miConfig.SecretKey
  5335. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5336. data["url"] = miConfig.Url
  5337. data["ak"] = miConfig.AccessKey
  5338. data["new_doctor_name"] = patientPrescription.Doctor
  5339. data["diag_code"] = sickConfig.CountryCode
  5340. data["cainfo"] = miConfig.Cainfo
  5341. var ids []int64
  5342. for _, item := range prescriptions {
  5343. ids = append(ids, item.ID)
  5344. }
  5345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5346. if config.IsOpen == 1 { //对接了医保,走医保流程
  5347. var res ResultFour
  5348. var resFour10265 ResultFour10265
  5349. if miConfig.MdtrtareaAdmvs == "421300" {
  5350. bytesData, _ := json.Marshal(data)
  5351. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5352. resp, _ := client.Do(req)
  5353. defer resp.Body.Close()
  5354. body, ioErr := ioutil.ReadAll(resp.Body)
  5355. if ioErr != nil {
  5356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5358. return
  5359. }
  5360. var respJSON map[string]interface{}
  5361. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5364. return
  5365. }
  5366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5367. userJSONBytes, _ := json.Marshal(respJSON)
  5368. fmt.Println("log")
  5369. fmt.Println(string(userJSONBytes))
  5370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5371. utils.ErrorLog("解析失败:%v", err)
  5372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5373. return
  5374. }
  5375. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5376. bytesData, _ := json.Marshal(data)
  5377. var req *http.Request
  5378. if miConfig.MdtrtareaAdmvs == "320921" {
  5379. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5380. } else {
  5381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5382. }
  5383. resp, _ := client.Do(req)
  5384. defer resp.Body.Close()
  5385. body, ioErr := ioutil.ReadAll(resp.Body)
  5386. if ioErr != nil {
  5387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5389. return
  5390. }
  5391. var respJSON map[string]interface{}
  5392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5395. return
  5396. }
  5397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5398. userJSONBytes, _ := json.Marshal(respJSON)
  5399. fmt.Println("log")
  5400. fmt.Println(string(userJSONBytes))
  5401. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5402. utils.ErrorLog("解析失败:%v", err)
  5403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5404. return
  5405. }
  5406. res.InfRefmsgid = resFour10265.InfRefmsgid
  5407. res.Output = resFour10265.Output
  5408. res.ErrMsg = resFour10265.ErrMsg
  5409. res.Cainfo = resFour10265.Cainfo
  5410. res.WarnMsg = resFour10265.WarnMsg
  5411. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5412. res.Infcode = infocode
  5413. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5414. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5415. var dat map[string]interface{}
  5416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5417. fmt.Println(dat)
  5418. } else {
  5419. fmt.Println(err)
  5420. }
  5421. saveLog(result, request_log, "2204", "上传费用明细")
  5422. userJSONBytes, _ := json.Marshal(dat)
  5423. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5424. utils.ErrorLog("解析失败:%v", err)
  5425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5426. return
  5427. }
  5428. res.InfRefmsgid = resFour10265.InfRefmsgid
  5429. res.Output = resFour10265.Output
  5430. res.ErrMsg = resFour10265.ErrMsg
  5431. res.Cainfo = resFour10265.Cainfo
  5432. res.WarnMsg = resFour10265.WarnMsg
  5433. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5434. res.Infcode = infocode
  5435. } else {
  5436. if miConfig.Code == "H15049901371" {
  5437. 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)
  5438. var dat map[string]interface{}
  5439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5440. fmt.Println(dat)
  5441. } else {
  5442. fmt.Println(err)
  5443. }
  5444. saveLog(result, request_log, "2204", "上传费用明细")
  5445. userJSONBytes, _ := json.Marshal(dat)
  5446. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5447. utils.ErrorLog("解析失败:%v", err)
  5448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5449. return
  5450. }
  5451. res.InfRefmsgid = resFour10265.InfRefmsgid
  5452. res.Output = resFour10265.Output
  5453. res.ErrMsg = resFour10265.ErrMsg
  5454. res.Cainfo = resFour10265.Cainfo
  5455. res.WarnMsg = resFour10265.WarnMsg
  5456. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5457. res.Infcode = infocode
  5458. } else {
  5459. 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)
  5460. var dat map[string]interface{}
  5461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5462. fmt.Println(dat)
  5463. } else {
  5464. fmt.Println(err)
  5465. }
  5466. saveLog(result, request_log, "2204", "上传费用明细")
  5467. userJSONBytes, _ := json.Marshal(dat)
  5468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5469. utils.ErrorLog("解析失败:%v", err)
  5470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5471. return
  5472. }
  5473. }
  5474. }
  5475. if res.Infcode == 0 {
  5476. order := &models.HisOrder{
  5477. UserOrgId: adminUser.CurrentOrgId,
  5478. HisPatientId: his.ID,
  5479. PatientId: his.PatientId,
  5480. SettleAccountsDate: recordDateTime,
  5481. MdtrtId: his.Number,
  5482. PsnNo: his.PsnNo,
  5483. MedType: strconv.FormatInt(reg_type, 10),
  5484. Ctime: time.Now().Unix(),
  5485. Mtime: time.Now().Unix(),
  5486. Status: 1,
  5487. Number: chrg_bchno,
  5488. Infcode: res.Infcode,
  5489. WarnMsg: res.WarnMsg,
  5490. Cainfo: res.Cainfo,
  5491. ErrMsg: res.ErrMsg,
  5492. RespondTime: res.RefmsgTime,
  5493. InfRefmsgid: res.InfRefmsgid,
  5494. OrderStatus: 1,
  5495. PayWay: pay_way,
  5496. PayPrice: pay_price,
  5497. PayCardNo: pay_card_no,
  5498. DiscountPrice: discount_price,
  5499. PreferentialPrice: preferential_price,
  5500. RealityPrice: reality_price,
  5501. FoundPrice: found_price,
  5502. MedicalInsurancePrice: medical_insurance_price,
  5503. PrivatePrice: private_price,
  5504. IsMedicineInsurance: 1,
  5505. SettleType: settle_accounts_type,
  5506. SettleStartTime: start_time,
  5507. SettleEndTime: end_time,
  5508. Creator: roles.AdminUserId,
  5509. Modify: roles.AdminUserId,
  5510. FaPiaoNumber: fapiao_number,
  5511. FaPiaoCode: fapiao_code,
  5512. PType: 2,
  5513. Diagnosis: diagnosis_id,
  5514. }
  5515. err = service.CreateOrder(order)
  5516. if err != nil {
  5517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5518. return
  5519. }
  5520. for _, item := range res.Output.Result {
  5521. temp := strings.Split(item.FeedetlSn, "-")
  5522. var advice_id int64 = 0
  5523. var project_id int64 = 0
  5524. var types int64 = 0
  5525. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5526. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5527. if temp[1] == "1" {
  5528. advice_id = id
  5529. project_id = 0
  5530. } else if temp[1] == "2" {
  5531. advice_id = 0
  5532. project_id = id
  5533. }
  5534. info := &models.HisOrderInfo{
  5535. OrderNumber: order.Number,
  5536. FeedetlSn: item.FeedetlSn,
  5537. UploadDate: time.Now().Unix(),
  5538. AdviceId: advice_id,
  5539. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5540. Cnt: item.Cnt,
  5541. Pric: float64(item.Pric),
  5542. PatientId: his.PatientId,
  5543. PricUplmtAmt: item.PricUplmtAmt,
  5544. SelfpayProp: item.SelfpayProp,
  5545. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5546. OverlmtAmt: item.OverlmtAmt,
  5547. PreselfpayAmt: item.PreselfpayAmt,
  5548. BasMednFlag: item.BasMednFlag,
  5549. MedChrgitmType: item.MedChrgitmType,
  5550. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5551. Status: 1,
  5552. Memo: item.Memo,
  5553. Mtime: time.Now().Unix(),
  5554. InscpScpAmt: item.InscpScpAmt,
  5555. DrtReimFlag: item.DrtReimFlag,
  5556. Ctime: time.Now().Unix(),
  5557. ListSpItemFlag: item.ListSpItemFlag,
  5558. ChldMedcFlag: item.ChldMedcFlag,
  5559. LmtUsedFlag: item.LmtUsedFlag,
  5560. ChrgitmLv: item.ChrgitmLv,
  5561. UserOrgId: adminUser.CurrentOrgId,
  5562. HisPatientId: his.ID,
  5563. OrderId: order.ID,
  5564. ProjectId: project_id,
  5565. Type: types,
  5566. }
  5567. service.CreateOrderInfo(info)
  5568. }
  5569. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5570. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5571. var total float64
  5572. for _, item := range prescriptions {
  5573. if item.Type == 1 { //药品
  5574. for _, subItem := range item.HisDoctorAdviceInfo {
  5575. total = total + (subItem.Price * subItem.PrescribingNumber)
  5576. }
  5577. }
  5578. if item.Type == 2 { //项目
  5579. for _, subItem := range item.HisPrescriptionProject {
  5580. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5581. total = total + (subItem.Price * cnt)
  5582. }
  5583. }
  5584. }
  5585. for _, item := range prescriptions {
  5586. for _, subItem := range item.HisAdditionalCharge {
  5587. total = total + (subItem.Price * float64(subItem.Count))
  5588. }
  5589. }
  5590. var allTotal string
  5591. if adminUser.CurrentOrgId == 9919 {
  5592. allTotal = fmt.Sprintf("%.4f", total)
  5593. } else {
  5594. allTotal = fmt.Sprintf("%.4f", total)
  5595. }
  5596. if res.Infcode == 0 {
  5597. var rf []*ResultFive
  5598. json.Unmarshal([]byte(his.Iinfo), &rf)
  5599. chrg_bchno := chrg_bchno
  5600. cert_no := his.Certno
  5601. var insutypes []string
  5602. var insutype string
  5603. var is390 int = 0
  5604. var is310 int = 0
  5605. for _, item := range rf {
  5606. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5607. insutypes = append(insutypes, item.Insutype)
  5608. }
  5609. }
  5610. if len(insutypes) == 1 {
  5611. insutype = insutypes[0]
  5612. } else {
  5613. for _, i := range insutypes {
  5614. if i == "390" {
  5615. is390 = 1
  5616. }
  5617. if i == "310" {
  5618. is310 = 1
  5619. }
  5620. }
  5621. }
  5622. if is390 == 1 {
  5623. insutype = "390"
  5624. }
  5625. if is310 == 1 {
  5626. insutype = "310"
  5627. }
  5628. if len(insutypes) == 0 {
  5629. insutype = "310"
  5630. }
  5631. if len(insutypes) == 2 {
  5632. insutype = strconv.FormatInt(his.SocialType, 10)
  5633. }
  5634. insutype = strconv.FormatInt(his.SocialType, 10)
  5635. //insutype = "390"
  5636. if his.IdCardType == 1 {
  5637. // cert_no = his.MedicalInsuranceNumber
  5638. cert_no = his.Certno
  5639. } else {
  5640. cert_no = his.Certno
  5641. }
  5642. var res ResultSeven
  5643. var resSeven10265 ResultSeven10265
  5644. var src_resquest string
  5645. var result2 string
  5646. var acct_used_flag string
  5647. fmt.Println("pay_way")
  5648. fmt.Println(pay_way)
  5649. fmt.Println("pay_way")
  5650. if pay_way == 4 {
  5651. acct_used_flag = "1"
  5652. } else {
  5653. acct_used_flag = "0"
  5654. }
  5655. if miConfig.MdtrtareaAdmvs == "421300" {
  5656. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5657. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5658. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5660. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5661. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5662. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5663. resp, requestErr := http.Get(api)
  5664. if requestErr != nil {
  5665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5666. return
  5667. }
  5668. body, ioErr := ioutil.ReadAll(resp.Body)
  5669. if ioErr != nil {
  5670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5672. return
  5673. }
  5674. var respJSON map[string]interface{}
  5675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5678. return
  5679. }
  5680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5681. result, _ := json.Marshal(respJSON)
  5682. if miConfig.Code == "H15049901371" {
  5683. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5684. utils.ErrorLog("解析失败:%v", err)
  5685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5686. return
  5687. }
  5688. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5689. res.Output = resSeven10265.Output
  5690. res.ErrMsg = resSeven10265.ErrMsg
  5691. res.Cainfo = resSeven10265.Cainfo
  5692. res.WarnMsg = resSeven10265.WarnMsg
  5693. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5694. res.Infcode = infocode
  5695. } else {
  5696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5697. utils.ErrorLog("解析失败:%v", err)
  5698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5699. return
  5700. }
  5701. }
  5702. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5703. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5704. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5705. bas := strings.Split(psn_info.CardInfo, "|")
  5706. if his.IdCardType == 1 {
  5707. cert_no = bas[2]
  5708. } else if his.IdCardType == 3 {
  5709. cert_no = his.Certno
  5710. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5711. } else if his.IdCardType == 4 {
  5712. cert_no = his.Certno
  5713. psn_info.VerifyNumber = token
  5714. }
  5715. var api string
  5716. if miConfig.MdtrtareaAdmvs == "320921" {
  5717. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5718. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5719. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5720. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5721. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5722. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5723. "&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
  5724. } else {
  5725. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5726. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5727. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5728. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5729. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5730. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5731. "&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
  5732. }
  5733. resp, requestErr := http.Get(api)
  5734. if requestErr != nil {
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5736. return
  5737. }
  5738. body, ioErr := ioutil.ReadAll(resp.Body)
  5739. if ioErr != nil {
  5740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5742. return
  5743. }
  5744. var respJSON map[string]interface{}
  5745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5748. return
  5749. }
  5750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5751. result, _ := json.Marshal(respJSON)
  5752. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5753. utils.ErrorLog("解析失败:%v", err)
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5755. return
  5756. }
  5757. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5758. res.Output = resSeven10265.Output
  5759. res.ErrMsg = resSeven10265.ErrMsg
  5760. res.Cainfo = resSeven10265.Cainfo
  5761. res.WarnMsg = resSeven10265.WarnMsg
  5762. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5763. res.Infcode = infocode
  5764. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5765. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5766. var cert_no string
  5767. if his.IdCardType == 1 {
  5768. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5769. }
  5770. fmt.Println(cert_no)
  5771. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5772. //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)
  5773. var dat map[string]interface{}
  5774. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5775. fmt.Println(dat)
  5776. } else {
  5777. fmt.Println(err)
  5778. }
  5779. saveLog(result2, src_resquest, "2207", "结算")
  5780. userJSONBytes, _ := json.Marshal(dat)
  5781. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5782. utils.ErrorLog("解析失败:%v", err)
  5783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5784. return
  5785. }
  5786. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5787. res.Output = resSeven10265.Output
  5788. res.ErrMsg = resSeven10265.ErrMsg
  5789. res.Cainfo = resSeven10265.Cainfo
  5790. res.WarnMsg = resSeven10265.WarnMsg
  5791. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5792. res.Infcode = infocode
  5793. } else {
  5794. if miConfig.Code == "H15049901371" {
  5795. //赤峰地区国家医保医疗类别
  5796. //职工透析:医疗类别选特殊情况门诊990502
  5797. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5798. var med_type string
  5799. if his.Insutype == "390" {
  5800. if reg_type == 14 {
  5801. med_type = "9933"
  5802. } else if reg_type == 11 {
  5803. med_type = "11"
  5804. }
  5805. } else if his.Insutype == "310" {
  5806. if reg_type == 14 {
  5807. med_type = "990502"
  5808. } else if reg_type == 11 {
  5809. med_type = "11"
  5810. }
  5811. }
  5812. 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)
  5813. } else {
  5814. 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)
  5815. }
  5816. //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)
  5817. var dat map[string]interface{}
  5818. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5819. fmt.Println(dat)
  5820. } else {
  5821. fmt.Println(err)
  5822. }
  5823. saveLog(result2, src_resquest, "2207", "结算")
  5824. userJSONBytes, _ := json.Marshal(dat)
  5825. if miConfig.Code == "H15049901371" {
  5826. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5827. utils.ErrorLog("解析失败:%v", err)
  5828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5829. return
  5830. }
  5831. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5832. res.Output = resSeven10265.Output
  5833. res.ErrMsg = resSeven10265.ErrMsg
  5834. res.Cainfo = resSeven10265.Cainfo
  5835. res.WarnMsg = resSeven10265.WarnMsg
  5836. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5837. res.Infcode = infocode
  5838. } else {
  5839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5840. utils.ErrorLog("解析失败:%v", err)
  5841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5842. return
  5843. }
  5844. }
  5845. }
  5846. if res.Infcode != 0 {
  5847. errlog := &models.HisOrderError{
  5848. UserOrgId: adminUser.CurrentOrgId,
  5849. Ctime: time.Now().Unix(),
  5850. Mtime: time.Now().Unix(),
  5851. Number: chrg_bchno,
  5852. ErrMsg: res.ErrMsg,
  5853. Status: 1,
  5854. PatientId: id,
  5855. RecordTime: recordDateTime,
  5856. Stage: 6,
  5857. }
  5858. service.CreateErrMsgLog(errlog)
  5859. c.ServeSuccessJSON(map[string]interface{}{
  5860. "failed_code": -10,
  5861. "msg": res.ErrMsg,
  5862. })
  5863. return
  5864. } else {
  5865. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5866. order.OrderStatus = 2
  5867. order.Status = 1
  5868. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5869. order.SetlId = res.Output.Setlinfo.SetlID
  5870. order.PsnNo = res.Output.Setlinfo.PsnNo
  5871. order.PsnName = res.Output.Setlinfo.PsnName
  5872. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5873. order.Certno = res.Output.Setlinfo.Certno
  5874. order.Gend = res.Output.Setlinfo.Gend
  5875. order.Naty = res.Output.Setlinfo.Naty
  5876. order.Age = res.Output.Setlinfo.Age
  5877. order.Insutype = res.Output.Setlinfo.Insutype
  5878. order.PsnType = res.Output.Setlinfo.PsnType
  5879. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5880. order.SetlTime = res.Output.Setlinfo.SetlTime
  5881. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5882. if res.Output.Setlinfo.MedType == "140101" {
  5883. order.MedType = "14"
  5884. } else {
  5885. order.MedType = res.Output.Setlinfo.MedType
  5886. }
  5887. if reg_type == 1112 {
  5888. order.MedType = "1112"
  5889. }
  5890. if reg_type == 1111 {
  5891. order.MedType = "1111"
  5892. }
  5893. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5894. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5895. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5896. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5897. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5898. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5899. order.HifpPay = res.Output.Setlinfo.HifpPay
  5900. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5901. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5902. order.HifesPay = res.Output.Setlinfo.HifesPay
  5903. order.HifobPay = res.Output.Setlinfo.HifobPay
  5904. order.MafPay = res.Output.Setlinfo.MafPay
  5905. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5906. order.OthPay = res.Output.Setlinfo.OthPay
  5907. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5908. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5909. order.AcctPay = res.Output.Setlinfo.AcctPay
  5910. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5911. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5912. order.Balc = res.Output.Setlinfo.Balc
  5913. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5914. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5915. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5916. order.ClrType = res.Output.Setlinfo.ClrType
  5917. order.ClrWay = res.Output.Setlinfo.ClrWay
  5918. order.Creator = order.Creator
  5919. order.Modify = roles.AdminUserId
  5920. order.RequestLog = src_resquest
  5921. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5922. detailStr := string(setlDetail)
  5923. order.SetlDetail = detailStr
  5924. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5925. err = service.UpDateOrder(order)
  5926. if err == nil {
  5927. //判断是否使用了押金
  5928. if dec_way == "true" {
  5929. tmpstring := strconv.FormatInt(order.ID, 10)
  5930. order.Decimal = decimal
  5931. service.UpDateOrder(order)
  5932. //扣押金
  5933. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5934. if errmsg != nil {
  5935. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5936. return
  5937. }
  5938. }
  5939. c.ServeSuccessJSON(map[string]interface{}{
  5940. "msg": "结算成功",
  5941. })
  5942. } else {
  5943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5944. return
  5945. }
  5946. }
  5947. } else {
  5948. adminUser := c.GetAdminUserInfo()
  5949. errlog := &models.HisOrderError{
  5950. UserOrgId: adminUser.CurrentOrgId,
  5951. Ctime: time.Now().Unix(),
  5952. Mtime: time.Now().Unix(),
  5953. ErrMsg: res.ErrMsg,
  5954. Status: 1,
  5955. PatientId: id,
  5956. RecordTime: recordDateTime,
  5957. Stage: 4,
  5958. }
  5959. service.CreateErrMsgLog(errlog)
  5960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5961. return
  5962. }
  5963. } else {
  5964. adminUser := c.GetAdminUserInfo()
  5965. errlog := &models.HisOrderError{
  5966. UserOrgId: adminUser.CurrentOrgId,
  5967. Ctime: time.Now().Unix(),
  5968. Mtime: time.Now().Unix(),
  5969. ErrMsg: res.ErrMsg,
  5970. Status: 1,
  5971. PatientId: id,
  5972. RecordTime: recordDateTime,
  5973. Stage: 4,
  5974. }
  5975. service.CreateErrMsgLog(errlog)
  5976. c.ServeSuccessJSON(map[string]interface{}{
  5977. "failed_code": -10,
  5978. "msg": res.ErrMsg,
  5979. })
  5980. return
  5981. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5982. //return
  5983. }
  5984. }
  5985. }
  5986. } else if tempOrder.ID > 0 {
  5987. if tempOrder.IsPre == 1 {
  5988. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5989. var rf []*ResultFive
  5990. json.Unmarshal([]byte(his.Iinfo), &rf)
  5991. chrg_bchno := tempOrder.Number
  5992. cert_no := his.Certno
  5993. var insutypes []string
  5994. var insutype string
  5995. var is390 int = 0
  5996. var is310 int = 0
  5997. for _, item := range rf {
  5998. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5999. insutypes = append(insutypes, item.Insutype)
  6000. }
  6001. }
  6002. if len(insutypes) == 1 {
  6003. insutype = insutypes[0]
  6004. } else {
  6005. for _, i := range insutypes {
  6006. if i == "390" {
  6007. is390 = 1
  6008. }
  6009. if i == "310" {
  6010. is310 = 1
  6011. }
  6012. }
  6013. }
  6014. if is390 == 1 {
  6015. insutype = "390"
  6016. }
  6017. if is310 == 1 {
  6018. insutype = "310"
  6019. }
  6020. if len(insutypes) == 0 {
  6021. insutype = "310"
  6022. }
  6023. if len(insutypes) == 2 {
  6024. insutype = strconv.FormatInt(his.SocialType, 64)
  6025. }
  6026. //insutype = "390"
  6027. if his.IdCardType == 1 {
  6028. // cert_no = his.MedicalInsuranceNumber
  6029. cert_no = his.Certno
  6030. } else {
  6031. cert_no = his.Certno
  6032. }
  6033. var res ResultSeven
  6034. var resSeven10265 ResultSeven10265
  6035. var src_resquest string
  6036. var result2 string
  6037. var acct_used_flag string
  6038. fmt.Println("pay_way")
  6039. fmt.Println(pay_way)
  6040. fmt.Println("pay_way")
  6041. if pay_way == 4 {
  6042. acct_used_flag = "1"
  6043. } else {
  6044. acct_used_flag = "0"
  6045. }
  6046. if miConfig.MdtrtareaAdmvs == "421300" {
  6047. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6048. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6049. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6051. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6052. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6053. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6054. resp, requestErr := http.Get(api)
  6055. if requestErr != nil {
  6056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. return
  6058. }
  6059. body, ioErr := ioutil.ReadAll(resp.Body)
  6060. if ioErr != nil {
  6061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. var respJSON map[string]interface{}
  6066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6069. return
  6070. }
  6071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6072. result, _ := json.Marshal(respJSON)
  6073. fmt.Println("log")
  6074. fmt.Println(string(result))
  6075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6076. utils.ErrorLog("解析失败:%v", err)
  6077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6078. return
  6079. }
  6080. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6081. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6082. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6083. //psn_info, _ := service.GetPsnByPatientId(id)
  6084. bas := strings.Split(psn_info.CardInfo, "|")
  6085. if his.IdCardType == 1 {
  6086. cert_no = bas[2]
  6087. } else {
  6088. cert_no = bas[1]
  6089. }
  6090. //江苏地区国家医保医疗类别
  6091. //职工透析:医疗类别选特殊情况门诊9933
  6092. //居民血透门慢: 医疗类别选门诊慢病1402
  6093. //var med_type string
  6094. //if his.Insutype == "310" {
  6095. // if reg_type == 14 {
  6096. // med_type = "9933"
  6097. // } else if reg_type == 11 {
  6098. // med_type = "11"
  6099. //
  6100. // }
  6101. //} else if his.Insutype == "390" {
  6102. // if reg_type == 14 {
  6103. // med_type = "1402"
  6104. // } else if reg_type == 11 {
  6105. // med_type = "11"
  6106. // }
  6107. //}
  6108. var api string
  6109. if miConfig.MdtrtareaAdmvs == "320921" {
  6110. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6111. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6112. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6113. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6114. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6115. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6116. "&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
  6117. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6118. } else {
  6119. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6120. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6121. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6122. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6124. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6125. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6126. "&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
  6127. }
  6128. resp, requestErr := http.Get(api)
  6129. if requestErr != nil {
  6130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6131. return
  6132. }
  6133. body, ioErr := ioutil.ReadAll(resp.Body)
  6134. if ioErr != nil {
  6135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6137. return
  6138. }
  6139. var respJSON map[string]interface{}
  6140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6143. return
  6144. }
  6145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6146. result, _ := json.Marshal(respJSON)
  6147. fmt.Println("log")
  6148. fmt.Println(string(result))
  6149. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6150. utils.ErrorLog("解析失败:%v", err)
  6151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6152. return
  6153. }
  6154. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6155. res.Output = resSeven10265.Output
  6156. res.ErrMsg = resSeven10265.ErrMsg
  6157. res.Cainfo = resSeven10265.Cainfo
  6158. res.WarnMsg = resSeven10265.WarnMsg
  6159. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6160. res.Infcode = infocode
  6161. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6162. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6163. var cert_no string
  6164. if his.IdCardType == 1 {
  6165. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6166. }
  6167. fmt.Println(cert_no)
  6168. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6169. var dat map[string]interface{}
  6170. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6171. fmt.Println(dat)
  6172. } else {
  6173. fmt.Println(err)
  6174. }
  6175. saveLog(result2, src_resquest, "2207", "结算")
  6176. userJSONBytes, _ := json.Marshal(dat)
  6177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6178. utils.ErrorLog("解析失败:%v", err)
  6179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6180. return
  6181. }
  6182. } else {
  6183. var src_resquest string
  6184. if miConfig.Code == "H15049901371" {
  6185. //赤峰地区国家医保医疗类别
  6186. //职工透析:医疗类别选特殊情况门诊990502
  6187. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6188. var med_type string
  6189. if his.Insutype == "390" {
  6190. if reg_type == 14 {
  6191. med_type = "9933"
  6192. } else if reg_type == 11 {
  6193. med_type = "11"
  6194. }
  6195. } else if his.Insutype == "310" {
  6196. if reg_type == 14 {
  6197. med_type = "990502"
  6198. } else if reg_type == 11 {
  6199. med_type = "11"
  6200. }
  6201. }
  6202. 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)
  6203. } else {
  6204. 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)
  6205. }
  6206. var dat map[string]interface{}
  6207. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6208. fmt.Println(dat)
  6209. } else {
  6210. fmt.Println(err)
  6211. }
  6212. saveLog(result2, src_resquest, "2207", "结算")
  6213. userJSONBytes, _ := json.Marshal(dat)
  6214. if miConfig.Code == "H15049901371" {
  6215. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6216. utils.ErrorLog("解析失败:%v", err)
  6217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6218. return
  6219. }
  6220. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6221. res.Output = resSeven10265.Output
  6222. res.ErrMsg = resSeven10265.ErrMsg
  6223. res.Cainfo = resSeven10265.Cainfo
  6224. res.WarnMsg = resSeven10265.WarnMsg
  6225. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6226. res.Infcode = infocode
  6227. } else {
  6228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6229. utils.ErrorLog("解析失败:%v", err)
  6230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6231. return
  6232. }
  6233. }
  6234. }
  6235. if res.Infcode != 0 {
  6236. errlog := &models.HisOrderError{
  6237. UserOrgId: adminUser.CurrentOrgId,
  6238. Ctime: time.Now().Unix(),
  6239. Mtime: time.Now().Unix(),
  6240. Number: chrg_bchno,
  6241. ErrMsg: res.ErrMsg,
  6242. Status: 1,
  6243. PatientId: id,
  6244. RecordTime: recordDateTime,
  6245. Stage: 6,
  6246. }
  6247. service.CreateErrMsgLog(errlog)
  6248. c.ServeSuccessJSON(map[string]interface{}{
  6249. "failed_code": -10,
  6250. "msg": res.ErrMsg,
  6251. })
  6252. return
  6253. } else {
  6254. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6255. order.OrderStatus = 2
  6256. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6257. order.SetlId = res.Output.Setlinfo.SetlID
  6258. order.PsnNo = res.Output.Setlinfo.PsnNo
  6259. order.PsnName = res.Output.Setlinfo.PsnName
  6260. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6261. order.Certno = res.Output.Setlinfo.Certno
  6262. order.Gend = res.Output.Setlinfo.Gend
  6263. order.Naty = res.Output.Setlinfo.Naty
  6264. order.Age = res.Output.Setlinfo.Age
  6265. order.Insutype = res.Output.Setlinfo.Insutype
  6266. order.PsnType = res.Output.Setlinfo.PsnType
  6267. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6268. order.SetlTime = res.Output.Setlinfo.SetlTime
  6269. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6270. //order.MedType = res.Output.Setlinfo.MedType
  6271. if reg_type == 1112 {
  6272. order.MedType = "1112"
  6273. }
  6274. if reg_type == 1111 {
  6275. order.MedType = "1111"
  6276. }
  6277. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6278. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6279. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6280. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6281. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6282. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6283. order.HifpPay = res.Output.Setlinfo.HifpPay
  6284. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6285. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6286. order.HifesPay = res.Output.Setlinfo.HifesPay
  6287. order.HifobPay = res.Output.Setlinfo.HifobPay
  6288. order.MafPay = res.Output.Setlinfo.MafPay
  6289. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6290. order.OthPay = res.Output.Setlinfo.OthPay
  6291. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6292. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6293. order.AcctPay = res.Output.Setlinfo.AcctPay
  6294. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6295. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6296. order.Balc = res.Output.Setlinfo.Balc
  6297. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6298. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6299. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6300. order.ClrWay = res.Output.Setlinfo.ClrWay
  6301. order.Creator = order.Creator
  6302. order.Modify = roles.AdminUserId
  6303. order.RequestLog = src_resquest
  6304. order.Diagnosis = diagnosis_id
  6305. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6306. detailStr := string(setlDetail)
  6307. order.SetlDetail = detailStr
  6308. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6309. err = service.UpDateOrder(order)
  6310. if err == nil {
  6311. //判断是否使用了押金
  6312. if dec_way == "true" {
  6313. tmpstring := strconv.FormatInt(order.ID, 10)
  6314. //扣押金
  6315. order.Decimal = decimal
  6316. service.UpDateOrder(order)
  6317. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6318. if errmsg != nil {
  6319. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6320. return
  6321. }
  6322. }
  6323. c.ServeSuccessJSON(map[string]interface{}{
  6324. "msg": "结算成功",
  6325. })
  6326. } else {
  6327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6328. return
  6329. }
  6330. }
  6331. }
  6332. }
  6333. }
  6334. //func (c *HisApiController) GetPreUploadInfo() {
  6335. // id, _ := c.GetInt64("id")
  6336. // record_time := c.GetString("record_time")
  6337. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6338. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6339. //
  6340. // timeLayout := "2006-01-02"
  6341. // loc, _ := time.LoadLocation("Local")
  6342. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6343. // if err != nil {
  6344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6345. // return
  6346. // }
  6347. // recordDateTime := theTime.Unix()
  6348. // adminUser := c.GetAdminUserInfo()
  6349. //
  6350. // var prescriptions []*models.HisPrescription
  6351. //
  6352. // var start_time int64
  6353. // var end_time int64
  6354. //
  6355. // data := make(map[string]interface{})
  6356. // if settle_accounts_type == 1 { //日结
  6357. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6358. // data["pre"] = prescriptions
  6359. //
  6360. // } else { //月结
  6361. // start_time_str := c.GetString("start_time")
  6362. // end_time_str := c.GetString("end_time")
  6363. // timeLayout := "2006-01-02"
  6364. // loc, _ := time.LoadLocation("Local")
  6365. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6366. // if err != nil {
  6367. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6368. // return
  6369. // }
  6370. // recordStartTime := theStartTime.Unix()
  6371. // start_time = recordStartTime
  6372. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6373. // if err != nil {
  6374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6375. // return
  6376. // }
  6377. // recordEndTime := theEndTime.Unix()
  6378. // end_time = recordEndTime
  6379. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6380. // data["pre"] = prescriptions
  6381. //
  6382. // }
  6383. //
  6384. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6385. //
  6386. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6387. // timestamp := time.Now().Unix()
  6388. // tempTime := time.Unix(timestamp, 0)
  6389. // timeFormat := tempTime.Format("20060102150405")
  6390. // chrgBchno := rand.Intn(100000) + 10000
  6391. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6392. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6393. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6394. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6395. // strconv.FormatInt(his.PatientId, 10)
  6396. // client := &http.Client{}
  6397. // data["psn_no"] = his.PsnNo
  6398. // data["mdtrt_id"] = his.Number
  6399. // data["chrg_bchno"] = chrg_bchno
  6400. // data["org_name"] = miConfig.OrgName
  6401. // data["doctor"] = roles.UserName
  6402. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6403. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6404. // data["fixmedins_code"] = miConfig.Code
  6405. // data["dept_code"] = department.Number
  6406. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6407. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6408. // data["secret_key"] = miConfig.SecretKey
  6409. // var ids []int64
  6410. //
  6411. // for _, item := range prescriptions {
  6412. // ids = append(ids, item.ID)
  6413. // }
  6414. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6415. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6416. // bytesData, _ := json.Marshal(data)
  6417. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6418. // resp, _ := client.Do(req)
  6419. // defer resp.Body.Close()
  6420. // body, ioErr := ioutil.ReadAll(resp.Body)
  6421. // if ioErr != nil {
  6422. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6424. // return
  6425. // }
  6426. // var respJSON map[string]interface{}
  6427. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6428. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6430. // return
  6431. // }
  6432. //
  6433. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6434. // userJSONBytes, _ := json.Marshal(respJSON)
  6435. // var res ResultFour
  6436. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6437. // utils.ErrorLog("解析失败:%v", err)
  6438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6439. // return
  6440. // }
  6441. //
  6442. // if res.Infcode == 0 {
  6443. // order := &models.HisOrder{
  6444. // UserOrgId: adminUser.CurrentOrgId,
  6445. // HisPatientId: his.ID,
  6446. // PatientId: his.PatientId,
  6447. // SettleAccountsDate: recordDateTime,
  6448. // Ctime: time.Now().Unix(),
  6449. // Mtime: time.Now().Unix(),
  6450. // Status: 1,
  6451. // Number: chrg_bchno,
  6452. // Infcode: res.Infcode,
  6453. // WarnMsg: res.WarnMsg,
  6454. // Cainfo: res.Cainfo,
  6455. // ErrMsg: res.ErrMsg,
  6456. // RespondTime: res.RefmsgTime,
  6457. // InfRefmsgid: res.InfRefmsgid,
  6458. // OrderStatus: 1,
  6459. // IsMedicineInsurance: 1,
  6460. // SettleType: settle_accounts_type,
  6461. // SettleStartTime: start_time,
  6462. // SettleEndTime: end_time,
  6463. // Creator: roles.ID,
  6464. // Modify: roles.ID,
  6465. // PType: 2,
  6466. // }
  6467. // err = service.CreateOrder(order)
  6468. // if err != nil {
  6469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6470. // return
  6471. // }
  6472. //
  6473. // for _, item := range res.Output.Result {
  6474. // temp := strings.Split(item.FeedetlSn, "-")
  6475. // var advice_id int64 = 0
  6476. // var project_id int64 = 0
  6477. // var types int64 = 0
  6478. //
  6479. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6480. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6481. //
  6482. // if temp[1] == "1" {
  6483. // advice_id = id
  6484. // project_id = 0
  6485. // } else if temp[1] == "2" {
  6486. // advice_id = 0
  6487. // project_id = id
  6488. // }
  6489. //
  6490. // info := &models.HisOrderInfo{
  6491. // OrderNumber: order.Number,
  6492. // FeedetlSn: item.FeedetlSn,
  6493. // UploadDate: time.Now().Unix(),
  6494. // AdviceId: advice_id,
  6495. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6496. // Cnt: item.Cnt,
  6497. // Pric: float64(item.Pric),
  6498. // PatientId: his.PatientId,
  6499. // PricUplmtAmt: item.PricUplmtAmt,
  6500. // SelfpayProp: item.SelfpayProp,
  6501. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6502. // OverlmtAmt: item.OverlmtAmt,
  6503. // PreselfpayAmt: item.PreselfpayAmt,
  6504. // BasMednFlag: item.BasMednFlag,
  6505. // MedChrgitmType: item.MedChrgitmType,
  6506. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6507. // Status: 1,
  6508. // Memo: item.Memo,
  6509. // Mtime: time.Now().Unix(),
  6510. // InscpScpAmt: item.InscpScpAmt,
  6511. // DrtReimFlag: item.DrtReimFlag,
  6512. // Ctime: time.Now().Unix(),
  6513. // ListSpItemFlag: item.ListSpItemFlag,
  6514. // ChldMedcFlag: item.ChldMedcFlag,
  6515. // LmtUsedFlag: item.LmtUsedFlag,
  6516. // ChrgitmLv: item.ChrgitmLv,
  6517. // UserOrgId: adminUser.CurrentOrgId,
  6518. // HisPatientId: his.ID,
  6519. // OrderId: order.ID,
  6520. // ProjectId: project_id,
  6521. // Type: types,
  6522. // }
  6523. // service.CreateOrderInfo(info)
  6524. //
  6525. // }
  6526. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6527. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6528. //
  6529. // var total float64
  6530. // for _, item := range prescriptions {
  6531. // if item.Type == 1 { //药品
  6532. // for _, subItem := range item.HisDoctorAdviceInfo {
  6533. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6534. // }
  6535. // }
  6536. // if item.Type == 2 { //项目
  6537. // for _, subItem := range item.HisPrescriptionProject {
  6538. // total = total + (subItem.Price * float64(subItem.Count))
  6539. // }
  6540. // }
  6541. // }
  6542. //
  6543. // for _, item := range prescriptions {
  6544. // for _, subItem := range item.HisAdditionalCharge {
  6545. // total = total + (subItem.Price * float64(subItem.Count))
  6546. // }
  6547. // }
  6548. //
  6549. // allTotal := fmt.Sprintf("%.2f", total)
  6550. // if res.Infcode == 0 {
  6551. // var rf []*ResultFive
  6552. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6553. // psn_no := his.PsnNo
  6554. // mdtrt_id := his.Number
  6555. // chrg_bchno := chrg_bchno
  6556. // cert_no := his.Certno
  6557. // insutype := rf[0].Insutype
  6558. //
  6559. // if his.IdCardType == 1 {
  6560. // cert_no = his.MedicalInsuranceNumber
  6561. //
  6562. // } else {
  6563. //
  6564. // cert_no = his.Certno
  6565. //
  6566. // }
  6567. //
  6568. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6569. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6570. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6571. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6572. // resp, requestErr := http.Get(api)
  6573. // if requestErr != nil {
  6574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6575. // return
  6576. // }
  6577. // defer resp.Body.Close()
  6578. // body, ioErr := ioutil.ReadAll(resp.Body)
  6579. // if ioErr != nil {
  6580. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6582. // return
  6583. // }
  6584. // var respJSON map[string]interface{}
  6585. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6586. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6588. // return
  6589. // }
  6590. // fmt.Println(respJSON)
  6591. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6592. // userJSONBytes, _ := json.Marshal(respJSON)
  6593. // var res ResultSeven
  6594. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6595. // utils.ErrorLog("解析失败:%v", err)
  6596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6597. // return
  6598. // }
  6599. // if res.Infcode != 0 {
  6600. // errlog := &models.HisOrderError{
  6601. // UserOrgId: adminUser.CurrentOrgId,
  6602. // Ctime: time.Now().Unix(),
  6603. // Mtime: time.Now().Unix(),
  6604. // Number: chrg_bchno,
  6605. // ErrMsg: res.ErrMsg,
  6606. // Status: 1,
  6607. // PatientId: id,
  6608. // RecordTime: recordDateTime,
  6609. // Stage: 7,
  6610. // }
  6611. // service.CreateErrMsgLog(errlog)
  6612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6613. // return
  6614. // } else {
  6615. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6616. // order.OrderStatus = 1
  6617. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6618. // order.SetlId = res.Output.Setlinfo.SetlID
  6619. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6620. // order.PsnName = res.Output.Setlinfo.PsnName
  6621. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6622. // order.Certno = res.Output.Setlinfo.Certno
  6623. // order.Gend = res.Output.Setlinfo.Gend
  6624. // order.Naty = res.Output.Setlinfo.Naty
  6625. // order.Age = res.Output.Setlinfo.Age
  6626. // order.Insutype = res.Output.Setlinfo.Insutype
  6627. // order.PsnType = res.Output.Setlinfo.PsnType
  6628. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6629. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6630. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6631. // order.MedType = res.Output.Setlinfo.MedType
  6632. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6633. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6634. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6635. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6636. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6637. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6638. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6639. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6640. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6641. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6642. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6643. // order.MafPay = res.Output.Setlinfo.MafPay
  6644. // order.OthPay = res.Output.Setlinfo.OthPay
  6645. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6646. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6647. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6648. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6649. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6650. // order.Balc = res.Output.Setlinfo.Balc
  6651. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6652. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6653. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6654. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6655. // order.Creator = order.Creator
  6656. // order.Modify = roles.ID
  6657. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6658. // detailStr := string(setlDetail)
  6659. // order.SetlDetail = detailStr
  6660. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6661. // err = service.UpDateOrder(order)
  6662. // if err == nil {
  6663. // c.ServeSuccessJSON(map[string]interface{}{
  6664. // "msg": "预结算成功",
  6665. // })
  6666. // } else {
  6667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6668. // return
  6669. // }
  6670. // }
  6671. // } else {
  6672. // adminUser := c.GetAdminUserInfo()
  6673. // errlog := &models.HisOrderError{
  6674. // UserOrgId: adminUser.CurrentOrgId,
  6675. // Ctime: time.Now().Unix(),
  6676. // Mtime: time.Now().Unix(),
  6677. // ErrMsg: res.ErrMsg,
  6678. // Status: 1,
  6679. // PatientId: id,
  6680. // RecordTime: recordDateTime,
  6681. // Stage: 4,
  6682. // }
  6683. // service.CreateErrMsgLog(errlog)
  6684. //
  6685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6686. // return
  6687. // }
  6688. // } else {
  6689. // adminUser := c.GetAdminUserInfo()
  6690. // errlog := &models.HisOrderError{
  6691. // UserOrgId: adminUser.CurrentOrgId,
  6692. // Ctime: time.Now().Unix(),
  6693. // Mtime: time.Now().Unix(),
  6694. // ErrMsg: res.ErrMsg,
  6695. // Status: 1,
  6696. // PatientId: id,
  6697. // RecordTime: recordDateTime,
  6698. // Stage: 4,
  6699. // }
  6700. // service.CreateErrMsgLog(errlog)
  6701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6702. // return
  6703. // }
  6704. //
  6705. // } else {
  6706. // var total float64
  6707. // for _, item := range prescriptions {
  6708. // if item.Type == 1 { //药品
  6709. // for _, subItem := range item.HisDoctorAdviceInfo {
  6710. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6711. // }
  6712. // }
  6713. // if item.Type == 2 { //项目
  6714. // for _, subItem := range item.HisPrescriptionProject {
  6715. // total = total + (subItem.Price * float64(subItem.Count))
  6716. // }
  6717. // }
  6718. //
  6719. // for _, subItem := range item.HisAdditionalCharge {
  6720. // total = total + (subItem.Price * float64(subItem.Count))
  6721. // }
  6722. // }
  6723. //
  6724. // allTotal := fmt.Sprintf("%.2f", total)
  6725. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6726. // order := &models.HisOrder{
  6727. // UserOrgId: adminUser.CurrentOrgId,
  6728. // HisPatientId: his.ID,
  6729. // PatientId: id,
  6730. // SettleAccountsDate: recordDateTime,
  6731. // Ctime: time.Now().Unix(),
  6732. // Mtime: time.Now().Unix(),
  6733. // Status: 1,
  6734. // OrderStatus: 2,
  6735. // Number: chrg_bchno,
  6736. // MedfeeSumamt: totals,
  6737. // }
  6738. // err = service.CreateOrder(order)
  6739. // if err != nil {
  6740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6741. // return
  6742. // }
  6743. //
  6744. // var customs []*Custom
  6745. // for _, item := range prescriptions {
  6746. //
  6747. // if item.Type == 1 { //药品
  6748. // for _, subItem := range item.HisDoctorAdviceInfo {
  6749. // cus := &Custom{
  6750. // AdviceId: subItem.ID,
  6751. // ProjectId: 0,
  6752. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6753. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6754. // FeedetlSn: subItem.FeedetlSn,
  6755. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6756. // MedListCodg: subItem.MedListCodg,
  6757. // Type: 1,
  6758. // }
  6759. // customs = append(customs, cus)
  6760. // }
  6761. // }
  6762. //
  6763. // if item.Type == 2 { //项目
  6764. // for _, subItem := range item.HisPrescriptionProject {
  6765. //
  6766. // cus := &Custom{
  6767. // AdviceId: 0,
  6768. // ProjectId: subItem.ID,
  6769. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6770. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6771. // FeedetlSn: subItem.FeedetlSn,
  6772. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6773. // MedListCodg: subItem.MedListCodg,
  6774. // Type: 2,
  6775. // }
  6776. //
  6777. // customs = append(customs, cus)
  6778. // }
  6779. // }
  6780. //
  6781. // for _, item := range item.HisAdditionalCharge {
  6782. // cus := &Custom{
  6783. // ItemId: item.ID,
  6784. // AdviceId: 0,
  6785. // ProjectId: 0,
  6786. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6787. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6788. // FeedetlSn: item.FeedetlSn,
  6789. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6790. // MedListCodg: item.XtHisAddtionConfig.Code,
  6791. // Type: 3,
  6792. // }
  6793. //
  6794. // customs = append(customs, cus)
  6795. // }
  6796. //
  6797. // }
  6798. //
  6799. // for _, item := range customs {
  6800. // var advice_id int64 = 0
  6801. // var project_id int64 = 0
  6802. // var item_id int64 = 0
  6803. //
  6804. // var types int64 = 0
  6805. //
  6806. // if item.Type == 1 {
  6807. // advice_id = item.AdviceId
  6808. // project_id = 0
  6809. // item_id = 0
  6810. // } else if item.Type == 2 {
  6811. // advice_id = 0
  6812. // item_id = 0
  6813. //
  6814. // project_id = item.ProjectId
  6815. // } else if item.Type == 3 {
  6816. // advice_id = 0
  6817. // item_id = item.ItemId
  6818. // project_id = 0
  6819. // }
  6820. //
  6821. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6822. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6823. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6824. //
  6825. // info := &models.HisOrderInfo{
  6826. // OrderNumber: order.Number,
  6827. // UploadDate: time.Now().Unix(),
  6828. // AdviceId: advice_id,
  6829. // DetItemFeeSumamt: detItemFeeSumamt,
  6830. // Cnt: cut,
  6831. // Pric: pric,
  6832. // PatientId: id,
  6833. // Status: 1,
  6834. // Mtime: time.Now().Unix(),
  6835. // Ctime: time.Now().Unix(),
  6836. // UserOrgId: adminUser.CurrentOrgId,
  6837. // HisPatientId: his.ID,
  6838. // OrderId: order.ID,
  6839. // ProjectId: project_id,
  6840. // Type: types,
  6841. // ItemId: item_id,
  6842. // }
  6843. // service.CreateOrderInfo(info)
  6844. // }
  6845. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6846. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6847. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6848. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6849. // if err == nil {
  6850. // c.ServeSuccessJSON(map[string]interface{}{
  6851. // "msg": "结算成功",
  6852. // })
  6853. // } else {
  6854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6855. // return
  6856. // }
  6857. // }
  6858. //}
  6859. //上传明细-预结算-
  6860. func (c *HisApiController) GetPreUploadInfo() {
  6861. id, _ := c.GetInt64("id")
  6862. record_time := c.GetString("record_time")
  6863. his_patient_id, _ := c.GetInt64("his_patient_id")
  6864. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6865. admin_user_id, _ := c.GetInt64("admin_user_id")
  6866. diagnosis_id := c.GetString("diagnosis")
  6867. sick_type, _ := c.GetInt64("sick_type")
  6868. reg_type, _ := c.GetInt64("p_type")
  6869. begin_time := c.GetString("begin_time")
  6870. id_str := c.GetString("ids")
  6871. ids_arr := strings.Split(id_str, ",")
  6872. timeLayout := "2006-01-02"
  6873. loc, _ := time.LoadLocation("Local")
  6874. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6875. if err != nil {
  6876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6877. return
  6878. }
  6879. recordDateTime := theTime.Unix()
  6880. adminUser := c.GetAdminUserInfo()
  6881. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6882. var config []*models.HisXtDiagnoseConfig
  6883. for _, item := range diagnosis_ids {
  6884. id, _ := strconv.ParseInt(item, 10, 64)
  6885. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6886. config = append(config, &diagnosisConfig)
  6887. }
  6888. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6889. sickConfig, _ := service.FindSickById(sick_type)
  6890. var prescriptions []*models.HisPrescription
  6891. var start_time int64
  6892. var end_time int64
  6893. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6894. fmt.Println(his_patient_id)
  6895. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6896. timestamp := time.Now().Unix()
  6897. tempTime := time.Unix(timestamp, 0)
  6898. timeFormat := tempTime.Format("20060102150405")
  6899. chrgBchno := rand.Intn(100000) + 10000
  6900. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6901. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6902. var patientPrescription models.HisPrescriptionInfo
  6903. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6904. if patientPrescription.ID == 0 {
  6905. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6906. }
  6907. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6908. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6909. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6910. strconv.FormatInt(his.PatientId, 10)
  6911. var res2 ResultSix
  6912. var resSix10265 ResultSix10265
  6913. var time_stamp string
  6914. if miConfig.MdtrtareaAdmvs == "421300" {
  6915. data := make(map[string]interface{})
  6916. client := &http.Client{}
  6917. data["psn_no"] = his.PsnNo
  6918. data["mdtrt_id"] = his.Number
  6919. data["department"] = department.Name
  6920. data["org_name"] = miConfig.OrgName
  6921. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6922. data["doctor_id"] = doctor_info.DoctorNumber
  6923. data["doctor_name"] = roles.UserName
  6924. data["fixmedins_code"] = miConfig.Code
  6925. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6926. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6927. data["secret_key"] = miConfig.SecretKey
  6928. data["sick_code"] = sickConfig.CountryCode
  6929. data["sick_name"] = sickConfig.ClassName
  6930. data["begin_time"] = begin_time
  6931. data["dept"] = strconv.FormatInt(department.ID, 10)
  6932. data["config"] = config
  6933. data["opter"] = roles.UserName
  6934. fmt.Println(data)
  6935. bytesData, _ := json.Marshal(data)
  6936. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6937. resp, _ := client.Do(req)
  6938. defer resp.Body.Close()
  6939. body, ioErr := ioutil.ReadAll(resp.Body)
  6940. if ioErr != nil {
  6941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. return
  6944. }
  6945. var respJSON map[string]interface{}
  6946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6952. userJSONBytes, _ := json.Marshal(respJSON)
  6953. fmt.Println("log")
  6954. fmt.Println(string(userJSONBytes))
  6955. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6956. utils.ErrorLog("解析失败:%v", err)
  6957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6958. return
  6959. }
  6960. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6961. data := make(map[string]interface{})
  6962. client := &http.Client{}
  6963. data["psn_no"] = his.PsnNo
  6964. data["mdtrt_id"] = his.Number
  6965. data["doctor"] = roles.UserName
  6966. data["department"] = department.Name
  6967. data["org_name"] = miConfig.OrgName
  6968. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6969. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6970. data["fixmedins_code"] = miConfig.Code
  6971. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6972. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6973. data["secret_key"] = miConfig.SecretKey
  6974. data["sick_code"] = sickConfig.CountryCode
  6975. data["sick_name"] = sickConfig.ClassName
  6976. data["begin_time"] = begin_time
  6977. data["dept"] = strconv.FormatInt(department.ID, 10)
  6978. data["config"] = config
  6979. data["url"] = miConfig.Url
  6980. data["ak"] = miConfig.AccessKey
  6981. data["cainfo"] = miConfig.Cainfo
  6982. bytesData, _ := json.Marshal(data)
  6983. var req *http.Request
  6984. if miConfig.MdtrtareaAdmvs == "320921" {
  6985. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6986. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6987. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6988. } else {
  6989. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6990. }
  6991. resp, _ := client.Do(req)
  6992. defer resp.Body.Close()
  6993. body, ioErr := ioutil.ReadAll(resp.Body)
  6994. if ioErr != nil {
  6995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6997. return
  6998. }
  6999. var respJSON map[string]interface{}
  7000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. return
  7004. }
  7005. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7006. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7007. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7009. userJSONBytes, _ := json.Marshal(respJSON)
  7010. fmt.Println("log")
  7011. fmt.Println(string(userJSONBytes))
  7012. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7013. utils.ErrorLog("解析失败:%v", err)
  7014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7015. return
  7016. }
  7017. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7018. res2.Output = resSix10265.Output
  7019. res2.ErrMsg = resSix10265.ErrMsg
  7020. res2.Cainfo = resSix10265.Cainfo
  7021. res2.WarnMsg = resSix10265.WarnMsg
  7022. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7023. res2.Infcode = infocode
  7024. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7025. result, requestLog, _ := service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7026. saveLog(result, requestLog, "2203", "上传就诊信息")
  7027. var respJSON2 map[string]interface{}
  7028. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. return
  7032. }
  7033. userJSONBytes2, _ := json.Marshal(respJSON2)
  7034. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7035. utils.ErrorLog("解析失败:%v", err)
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. return
  7038. }
  7039. } else {
  7040. var result string
  7041. var requestLog string
  7042. if miConfig.MdtrtareaAdmvs == "440781" { //
  7043. 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)
  7044. } else {
  7045. if miConfig.Code == "H15049901371" {
  7046. //赤峰地区国家医保医疗类别
  7047. //职工透析:医疗类别选特殊情况门诊990502
  7048. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7049. var med_type string
  7050. if his.Insutype == "390" {
  7051. if reg_type == 14 {
  7052. med_type = "9933"
  7053. } else if reg_type == 11 {
  7054. med_type = "11"
  7055. }
  7056. } else if his.Insutype == "310" {
  7057. if reg_type == 14 {
  7058. med_type = "990502"
  7059. } else if reg_type == 11 {
  7060. med_type = "11"
  7061. }
  7062. }
  7063. 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)
  7064. } else {
  7065. 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)
  7066. }
  7067. saveLog(result, requestLog, "2203", "上传就诊信息")
  7068. var respJSON2 map[string]interface{}
  7069. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7072. return
  7073. }
  7074. userJSONBytes2, _ := json.Marshal(respJSON2)
  7075. if miConfig.Code == "H15049901371" {
  7076. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7077. utils.ErrorLog("解析失败:%v", err)
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. return
  7080. }
  7081. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7082. res2.Output = resSix10265.Output
  7083. res2.ErrMsg = resSix10265.ErrMsg
  7084. res2.Cainfo = resSix10265.Cainfo
  7085. res2.WarnMsg = resSix10265.WarnMsg
  7086. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7087. res2.Infcode = infocode
  7088. } else {
  7089. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7090. utils.ErrorLog("解析失败:%v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. }
  7095. }
  7096. }
  7097. if res2.Infcode != 0 {
  7098. adminUser := c.GetAdminUserInfo()
  7099. errlog := &models.HisOrderError{
  7100. UserOrgId: adminUser.CurrentOrgId,
  7101. Ctime: time.Now().Unix(),
  7102. Mtime: time.Now().Unix(),
  7103. ErrMsg: res2.ErrMsg,
  7104. Status: 1,
  7105. PatientId: id,
  7106. RecordTime: recordDateTime,
  7107. Stage: 3,
  7108. }
  7109. service.CreateErrMsgLog(errlog)
  7110. c.ServeSuccessJSON(map[string]interface{}{
  7111. "failed_code": -10,
  7112. "msg": res2.ErrMsg,
  7113. })
  7114. return
  7115. } else {
  7116. his.Diagnosis = diagnosis_id
  7117. his.SickType = sickConfig.ID
  7118. his.PType = fmt.Sprintf("%d", reg_type)
  7119. service.UpdateHisPatientThree(&his)
  7120. data := make(map[string]interface{})
  7121. if settle_accounts_type == 1 { //日结
  7122. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7123. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7124. } else {
  7125. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7126. }
  7127. data["pre"] = prescriptions
  7128. } else { //月结
  7129. start_time_str := c.GetString("start_time")
  7130. end_time_str := c.GetString("end_time")
  7131. timeLayout := "2006-01-02"
  7132. loc, _ := time.LoadLocation("Local")
  7133. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7134. if err != nil {
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7136. return
  7137. }
  7138. recordStartTime := theStartTime.Unix()
  7139. start_time = recordStartTime
  7140. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7141. if err != nil {
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7143. return
  7144. }
  7145. recordEndTime := theEndTime.Unix()
  7146. end_time = recordEndTime
  7147. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7148. data["pre"] = prescriptions
  7149. }
  7150. client := &http.Client{}
  7151. data["psn_no"] = his.PsnNo
  7152. data["mdtrt_id"] = his.Number
  7153. data["chrg_bchno"] = chrg_bchno
  7154. data["org_name"] = miConfig.OrgName
  7155. data["doctor"] = roles.UserName
  7156. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7157. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7158. data["fixmedins_code"] = miConfig.Code
  7159. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7160. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7161. data["dept_code"] = "15"
  7162. } else {
  7163. data["dept_code"] = department.Number
  7164. }
  7165. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7166. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7167. data["secret_key"] = miConfig.SecretKey
  7168. data["url"] = miConfig.Url
  7169. data["ak"] = miConfig.AccessKey
  7170. data["new_doctor_name"] = patientPrescription.Doctor
  7171. data["diag_code"] = sickConfig.CountryCode
  7172. data["time_stamp"] = time_stamp
  7173. data["cainfo"] = miConfig.Cainfo
  7174. var ids []int64
  7175. for _, item := range prescriptions {
  7176. ids = append(ids, item.ID)
  7177. }
  7178. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7179. if config.IsOpen == 1 { //对接了医保,走医保流程
  7180. var res ResultFour
  7181. var resFour10265 ResultFour10265
  7182. if miConfig.MdtrtareaAdmvs == "421300" {
  7183. bytesData, _ := json.Marshal(data)
  7184. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7185. resp, _ := client.Do(req)
  7186. defer resp.Body.Close()
  7187. body, ioErr := ioutil.ReadAll(resp.Body)
  7188. if ioErr != nil {
  7189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. var respJSON map[string]interface{}
  7194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7200. userJSONBytes, _ := json.Marshal(respJSON)
  7201. fmt.Println("log")
  7202. fmt.Println(string(userJSONBytes))
  7203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7204. utils.ErrorLog("解析失败:%v", err)
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7209. bytesData, _ := json.Marshal(data)
  7210. var req *http.Request
  7211. if miConfig.MdtrtareaAdmvs == "320921" {
  7212. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7213. } else {
  7214. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7215. }
  7216. resp, _ := client.Do(req)
  7217. defer resp.Body.Close()
  7218. body, ioErr := ioutil.ReadAll(resp.Body)
  7219. if ioErr != nil {
  7220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7222. return
  7223. }
  7224. var respJSON map[string]interface{}
  7225. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7228. return
  7229. }
  7230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7231. userJSONBytes, _ := json.Marshal(respJSON)
  7232. fmt.Println("log")
  7233. fmt.Println(string(userJSONBytes))
  7234. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7235. utils.ErrorLog("解析失败:%v", err)
  7236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7237. return
  7238. }
  7239. res.InfRefmsgid = resFour10265.InfRefmsgid
  7240. res.Output = resFour10265.Output
  7241. res.ErrMsg = resFour10265.ErrMsg
  7242. res.Cainfo = resFour10265.Cainfo
  7243. res.WarnMsg = resFour10265.WarnMsg
  7244. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7245. res.Infcode = infocode
  7246. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7247. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7248. var dat map[string]interface{}
  7249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7250. fmt.Println(dat)
  7251. } else {
  7252. fmt.Println(err)
  7253. }
  7254. saveLog(result, request_log, "2204", "上传费用明细")
  7255. userJSONBytes, _ := json.Marshal(dat)
  7256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7257. utils.ErrorLog("解析失败:%v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. } else {
  7262. if miConfig.Code == "H15049901371" {
  7263. 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)
  7264. var dat map[string]interface{}
  7265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7266. fmt.Println(dat)
  7267. } else {
  7268. fmt.Println(err)
  7269. }
  7270. saveLog(result, request_log, "2204", "上传费用明细")
  7271. userJSONBytes, _ := json.Marshal(dat)
  7272. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7273. utils.ErrorLog("解析失败:%v", err)
  7274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7275. return
  7276. }
  7277. res.InfRefmsgid = resFour10265.InfRefmsgid
  7278. res.Output = resFour10265.Output
  7279. res.ErrMsg = resFour10265.ErrMsg
  7280. res.Cainfo = resFour10265.Cainfo
  7281. res.WarnMsg = resFour10265.WarnMsg
  7282. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7283. res.Infcode = infocode
  7284. } else {
  7285. 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)
  7286. var dat map[string]interface{}
  7287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7288. fmt.Println(dat)
  7289. } else {
  7290. fmt.Println(err)
  7291. }
  7292. saveLog(result, request_log, "2204", "上传费用明细")
  7293. userJSONBytes, _ := json.Marshal(dat)
  7294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7295. utils.ErrorLog("解析失败:%v", err)
  7296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7297. return
  7298. }
  7299. }
  7300. }
  7301. if res.Infcode == 0 {
  7302. order := &models.HisOrder{
  7303. UserOrgId: adminUser.CurrentOrgId,
  7304. HisPatientId: his.ID,
  7305. PatientId: his.PatientId,
  7306. SettleAccountsDate: recordDateTime,
  7307. Ctime: time.Now().Unix(),
  7308. Mtime: time.Now().Unix(),
  7309. MdtrtId: his.Number,
  7310. PsnNo: his.PsnNo,
  7311. MedType: strconv.FormatInt(reg_type, 10),
  7312. Status: 1,
  7313. Number: chrg_bchno,
  7314. Infcode: res.Infcode,
  7315. WarnMsg: res.WarnMsg,
  7316. Cainfo: res.Cainfo,
  7317. ErrMsg: res.ErrMsg,
  7318. RespondTime: res.RefmsgTime,
  7319. InfRefmsgid: res.InfRefmsgid,
  7320. OrderStatus: 1,
  7321. IsMedicineInsurance: 1,
  7322. SettleType: settle_accounts_type,
  7323. SettleStartTime: start_time,
  7324. SettleEndTime: end_time,
  7325. Creator: roles.AdminUserId,
  7326. Modify: roles.AdminUserId,
  7327. PType: 2,
  7328. Diagnosis: diagnosis_id,
  7329. }
  7330. err = service.CreateOrder(order)
  7331. if err != nil {
  7332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7333. return
  7334. }
  7335. for _, item := range res.Output.Result {
  7336. temp := strings.Split(item.FeedetlSn, "-")
  7337. var advice_id int64 = 0
  7338. var project_id int64 = 0
  7339. var types int64 = 0
  7340. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7341. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7342. if temp[1] == "1" {
  7343. advice_id = id
  7344. project_id = 0
  7345. } else if temp[1] == "2" {
  7346. advice_id = 0
  7347. project_id = id
  7348. }
  7349. info := &models.HisOrderInfo{
  7350. OrderNumber: order.Number,
  7351. FeedetlSn: item.FeedetlSn,
  7352. UploadDate: time.Now().Unix(),
  7353. AdviceId: advice_id,
  7354. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7355. Cnt: item.Cnt,
  7356. Pric: float64(item.Pric),
  7357. PatientId: his.PatientId,
  7358. PricUplmtAmt: item.PricUplmtAmt,
  7359. SelfpayProp: item.SelfpayProp,
  7360. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7361. OverlmtAmt: item.OverlmtAmt,
  7362. PreselfpayAmt: item.PreselfpayAmt,
  7363. BasMednFlag: item.BasMednFlag,
  7364. MedChrgitmType: item.MedChrgitmType,
  7365. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7366. Status: 1,
  7367. Memo: item.Memo,
  7368. Mtime: time.Now().Unix(),
  7369. InscpScpAmt: item.InscpScpAmt,
  7370. DrtReimFlag: item.DrtReimFlag,
  7371. Ctime: time.Now().Unix(),
  7372. ListSpItemFlag: item.ListSpItemFlag,
  7373. ChldMedcFlag: item.ChldMedcFlag,
  7374. LmtUsedFlag: item.LmtUsedFlag,
  7375. ChrgitmLv: item.ChrgitmLv,
  7376. UserOrgId: adminUser.CurrentOrgId,
  7377. HisPatientId: his.ID,
  7378. OrderId: order.ID,
  7379. ProjectId: project_id,
  7380. Type: types,
  7381. }
  7382. service.CreateOrderInfo(info)
  7383. }
  7384. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7385. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7386. var total float64
  7387. for _, item := range prescriptions {
  7388. if item.Type == 1 { //药品
  7389. for _, subItem := range item.HisDoctorAdviceInfo {
  7390. total = total + (subItem.Price * subItem.PrescribingNumber)
  7391. }
  7392. }
  7393. if item.Type == 2 { //项目
  7394. for _, subItem := range item.HisPrescriptionProject {
  7395. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7396. total = total + (subItem.Price * cnt)
  7397. }
  7398. }
  7399. }
  7400. for _, item := range prescriptions {
  7401. for _, subItem := range item.HisAdditionalCharge {
  7402. total = total + (subItem.Price * float64(subItem.Count))
  7403. }
  7404. }
  7405. allTotal := fmt.Sprintf("%.4f", total)
  7406. if res.Infcode == 0 {
  7407. var rf []*ResultFive
  7408. json.Unmarshal([]byte(his.Iinfo), &rf)
  7409. chrg_bchno := chrg_bchno
  7410. cert_no := his.Certno
  7411. var insutypes []string
  7412. var insutype string
  7413. var is390 int = 0
  7414. var is310 int = 0
  7415. for _, item := range rf {
  7416. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7417. insutypes = append(insutypes, item.Insutype)
  7418. }
  7419. }
  7420. if len(insutypes) == 1 {
  7421. insutype = insutypes[0]
  7422. } else {
  7423. for _, i := range insutypes {
  7424. if i == "390" {
  7425. is390 = 1
  7426. }
  7427. if i == "310" {
  7428. is310 = 1
  7429. }
  7430. }
  7431. }
  7432. if is390 == 1 {
  7433. insutype = "390"
  7434. }
  7435. if is310 == 1 {
  7436. insutype = "310"
  7437. }
  7438. if len(insutypes) == 0 {
  7439. insutype = "310"
  7440. }
  7441. if len(insutypes) == 2 {
  7442. insutype = strconv.FormatInt(his.SocialType, 64)
  7443. }
  7444. //insutype = "390"
  7445. if his.IdCardType == 1 {
  7446. cert_no = his.MedicalInsuranceNumber
  7447. } else {
  7448. cert_no = his.Certno
  7449. }
  7450. var res ResultSeven
  7451. var resSeven10265 ResultSeven10265
  7452. if miConfig.MdtrtareaAdmvs == "421300" {
  7453. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7454. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7455. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7456. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7457. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7458. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7459. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7460. resp, requestErr := http.Get(api)
  7461. if requestErr != nil {
  7462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7463. return
  7464. }
  7465. body, ioErr := ioutil.ReadAll(resp.Body)
  7466. if ioErr != nil {
  7467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. var respJSON map[string]interface{}
  7472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7478. result, _ := json.Marshal(respJSON)
  7479. fmt.Println("log")
  7480. fmt.Println(string(result))
  7481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7482. utils.ErrorLog("解析失败:%v", err)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7487. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7488. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7489. bas := strings.Split(psn_info.CardInfo, "|")
  7490. if his.IdCardType == 1 {
  7491. cert_no = bas[2]
  7492. } else {
  7493. cert_no = bas[1]
  7494. }
  7495. //江苏地区国家医保医疗类别
  7496. //职工透析:医疗类别选特殊情况门诊9933
  7497. //居民血透门慢: 医疗类别选门诊慢病1402
  7498. //var med_type string
  7499. //if his.Insutype == "310" {
  7500. // if reg_type == 14 {
  7501. // med_type = "9933"
  7502. // } else if reg_type == 11 {
  7503. // med_type = "11"
  7504. //
  7505. // }
  7506. //} else if his.Insutype == "390" {
  7507. // if reg_type == 14 {
  7508. // med_type = "1402"
  7509. // } else if reg_type == 11 {
  7510. // med_type = "11"
  7511. // }
  7512. //}
  7513. var api string
  7514. if miConfig.MdtrtareaAdmvs == "320921" {
  7515. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7516. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7517. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7518. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7519. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7520. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7521. "&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
  7522. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7523. } else {
  7524. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7525. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7526. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7527. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7528. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7529. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7530. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7531. "&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
  7532. }
  7533. resp, requestErr := http.Get(api)
  7534. if requestErr != nil {
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. return
  7537. }
  7538. body, ioErr := ioutil.ReadAll(resp.Body)
  7539. if ioErr != nil {
  7540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. var respJSON map[string]interface{}
  7545. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7548. return
  7549. }
  7550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7551. result, _ := json.Marshal(respJSON)
  7552. fmt.Println("log")
  7553. fmt.Println(string(result))
  7554. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7555. utils.ErrorLog("解析失败:%v", err)
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. return
  7558. }
  7559. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7560. res.Output = resSeven10265.Output
  7561. res.ErrMsg = resSeven10265.ErrMsg
  7562. res.Cainfo = resSeven10265.Cainfo
  7563. res.WarnMsg = resSeven10265.WarnMsg
  7564. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7565. res.Infcode = infocode
  7566. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7567. result, request_log, _ := service.FJyb2206(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7568. var dat map[string]interface{}
  7569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7570. fmt.Println(dat)
  7571. } else {
  7572. fmt.Println(err)
  7573. }
  7574. saveLog(result, request_log, "2206", "预结算")
  7575. userJSONBytes, _ := json.Marshal(dat)
  7576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7577. utils.ErrorLog("解析失败:%v", err)
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7579. return
  7580. }
  7581. } else {
  7582. var result string
  7583. var request_log string
  7584. if miConfig.Code == "H15049901371" {
  7585. //赤峰地区国家医保医疗类别
  7586. //职工透析:医疗类别选特殊情况门诊990502
  7587. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7588. var med_type string
  7589. if his.Insutype == "390" {
  7590. if reg_type == 14 {
  7591. med_type = "9933"
  7592. } else if reg_type == 11 {
  7593. med_type = "11"
  7594. }
  7595. } else if his.Insutype == "310" {
  7596. if reg_type == 14 {
  7597. med_type = "990502"
  7598. } else if reg_type == 11 {
  7599. med_type = "11"
  7600. }
  7601. }
  7602. 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)
  7603. } else {
  7604. 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)
  7605. }
  7606. var dat map[string]interface{}
  7607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7608. fmt.Println(dat)
  7609. } else {
  7610. fmt.Println(err)
  7611. }
  7612. saveLog(result, request_log, "2206", "预结算")
  7613. //userJSONBytes, _ := json.Marshal(dat)
  7614. //
  7615. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7616. // utils.ErrorLog("解析失败:%v", err)
  7617. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7618. // return
  7619. //}
  7620. userJSONBytes, _ := json.Marshal(dat)
  7621. if miConfig.Code == "H15049901371" {
  7622. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7623. utils.ErrorLog("解析失败:%v", err)
  7624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7625. return
  7626. }
  7627. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7628. res.Output = resSeven10265.Output
  7629. res.ErrMsg = resSeven10265.ErrMsg
  7630. res.Cainfo = resSeven10265.Cainfo
  7631. res.WarnMsg = resSeven10265.WarnMsg
  7632. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7633. res.Infcode = infocode
  7634. } else {
  7635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7636. utils.ErrorLog("解析失败:%v", err)
  7637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7638. return
  7639. }
  7640. }
  7641. }
  7642. if res.Infcode != 0 {
  7643. errlog := &models.HisOrderError{
  7644. UserOrgId: adminUser.CurrentOrgId,
  7645. Ctime: time.Now().Unix(),
  7646. Mtime: time.Now().Unix(),
  7647. Number: chrg_bchno,
  7648. ErrMsg: res.ErrMsg,
  7649. Status: 1,
  7650. PatientId: id,
  7651. RecordTime: recordDateTime,
  7652. Stage: 20,
  7653. }
  7654. service.CreateErrMsgLog(errlog)
  7655. c.ServeSuccessJSON(map[string]interface{}{
  7656. "failed_code": -10,
  7657. "msg": res.ErrMsg,
  7658. })
  7659. return
  7660. } else {
  7661. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7662. order.OrderStatus = 1
  7663. order.IsPre = 1
  7664. order.Status = 1
  7665. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7666. order.SetlId = res.Output.Setlinfo.SetlID
  7667. order.PsnNo = res.Output.Setlinfo.PsnNo
  7668. order.PsnName = res.Output.Setlinfo.PsnName
  7669. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7670. order.Certno = res.Output.Setlinfo.Certno
  7671. order.Gend = res.Output.Setlinfo.Gend
  7672. order.Naty = res.Output.Setlinfo.Naty
  7673. order.Age = res.Output.Setlinfo.Age
  7674. order.Insutype = res.Output.Setlinfo.Insutype
  7675. order.PsnType = res.Output.Setlinfo.PsnType
  7676. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7677. order.SetlTime = res.Output.Setlinfo.SetlTime
  7678. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7679. if res.Output.Setlinfo.MedType == "140101" {
  7680. order.MedType = "14"
  7681. } else {
  7682. order.MedType = res.Output.Setlinfo.MedType
  7683. }
  7684. if reg_type == 1112 {
  7685. order.MedType = "1112"
  7686. }
  7687. if reg_type == 1111 {
  7688. order.MedType = "1111"
  7689. }
  7690. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7691. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7692. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7693. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7694. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7695. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7696. order.HifpPay = res.Output.Setlinfo.HifpPay
  7697. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7698. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7699. order.HifesPay = res.Output.Setlinfo.HifesPay
  7700. order.HifobPay = res.Output.Setlinfo.HifobPay
  7701. order.MafPay = res.Output.Setlinfo.MafPay
  7702. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7703. order.OthPay = res.Output.Setlinfo.OthPay
  7704. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7705. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7706. order.AcctPay = res.Output.Setlinfo.AcctPay
  7707. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7708. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7709. order.Balc = res.Output.Setlinfo.Balc
  7710. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7711. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7712. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7713. order.ClrWay = res.Output.Setlinfo.ClrWay
  7714. order.Creator = order.Creator
  7715. order.Modify = roles.AdminUserId
  7716. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7717. detailStr := string(setlDetail)
  7718. order.SetlDetail = detailStr
  7719. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7720. err = service.UpDateOrder(order)
  7721. if err == nil {
  7722. c.ServeSuccessJSON(map[string]interface{}{
  7723. "msg": "预结算成功",
  7724. })
  7725. } else {
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7727. return
  7728. }
  7729. }
  7730. } else {
  7731. adminUser := c.GetAdminUserInfo()
  7732. errlog := &models.HisOrderError{
  7733. UserOrgId: adminUser.CurrentOrgId,
  7734. Ctime: time.Now().Unix(),
  7735. Mtime: time.Now().Unix(),
  7736. ErrMsg: res.ErrMsg,
  7737. Status: 1,
  7738. PatientId: id,
  7739. RecordTime: recordDateTime,
  7740. Stage: 4,
  7741. }
  7742. service.CreateErrMsgLog(errlog)
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7744. return
  7745. }
  7746. } else {
  7747. adminUser := c.GetAdminUserInfo()
  7748. errlog := &models.HisOrderError{
  7749. UserOrgId: adminUser.CurrentOrgId,
  7750. Ctime: time.Now().Unix(),
  7751. Mtime: time.Now().Unix(),
  7752. ErrMsg: res.ErrMsg,
  7753. Status: 1,
  7754. PatientId: id,
  7755. RecordTime: recordDateTime,
  7756. Stage: 4,
  7757. }
  7758. service.CreateErrMsgLog(errlog)
  7759. c.ServeSuccessJSON(map[string]interface{}{
  7760. "failed_code": -10,
  7761. "msg": res.ErrMsg,
  7762. })
  7763. return
  7764. }
  7765. }
  7766. }
  7767. }
  7768. //退款
  7769. func (c *HisApiController) Refund() {
  7770. order_id, _ := c.GetInt64("order_id")
  7771. admin_user_id, _ := c.GetInt64("admin_user_id")
  7772. adminUser := c.GetAdminUserInfo()
  7773. var order models.HisOrder
  7774. order, _ = service.GetHisOrderByID(order_id)
  7775. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7776. if order.ID == 0 {
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7778. return
  7779. }
  7780. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7782. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7783. if config.IsOpen == 1 { //对接了医保,走医保流程
  7784. var res ResultSixteen
  7785. var resSixteen10265 ResultSixteen10265
  7786. var src_resquest string
  7787. var result string
  7788. if miConfig.MdtrtareaAdmvs == "421300" {
  7789. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7790. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7791. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7792. resp3, requestErr3 := http.Get(api3)
  7793. if requestErr3 != nil {
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7795. return
  7796. }
  7797. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7798. if ioErr3 != nil {
  7799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. var respJSON3 map[string]interface{}
  7804. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7810. userJSONBytes3, _ := json.Marshal(respJSON3)
  7811. fmt.Println("log")
  7812. fmt.Println(string(userJSONBytes3))
  7813. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7814. utils.ErrorLog("解析失败:%v", err)
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. return
  7817. }
  7818. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7819. var api3 string
  7820. if miConfig.MdtrtareaAdmvs == "320921" {
  7821. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7822. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7823. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7824. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7825. } else {
  7826. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7827. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7828. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7829. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7830. }
  7831. resp3, requestErr3 := http.Get(api3)
  7832. if requestErr3 != nil {
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7837. if ioErr3 != nil {
  7838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7840. return
  7841. }
  7842. var respJSON3 map[string]interface{}
  7843. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7846. return
  7847. }
  7848. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7849. userJSONBytes3, _ := json.Marshal(respJSON3)
  7850. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7851. utils.ErrorLog("解析失败:%v", err)
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7853. return
  7854. }
  7855. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7856. res.Output = resSixteen10265.Output
  7857. res.ErrMsg = resSixteen10265.ErrMsg
  7858. res.Cainfo = resSixteen10265.Cainfo
  7859. res.WarnMsg = resSixteen10265.WarnMsg
  7860. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7861. res.Infcode = infocode
  7862. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7863. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7864. var dat map[string]interface{}
  7865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7866. fmt.Println(dat)
  7867. } else {
  7868. fmt.Println(err)
  7869. }
  7870. saveLog(result, src_resquest, "2208", "退费")
  7871. userJSONBytes, _ := json.Marshal(dat)
  7872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7873. utils.ErrorLog("解析失败:%v", err)
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. return
  7876. }
  7877. } else {
  7878. if miConfig.Code == "H15049901371" {
  7879. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7880. var dat map[string]interface{}
  7881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7882. fmt.Println(dat)
  7883. } else {
  7884. fmt.Println(err)
  7885. }
  7886. saveLog(result, src_resquest, "2208", "退费")
  7887. userJSONBytes, _ := json.Marshal(dat)
  7888. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7889. utils.ErrorLog("解析失败:%v", err)
  7890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7891. return
  7892. }
  7893. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7894. res.Output = resSixteen10265.Output
  7895. res.ErrMsg = resSixteen10265.ErrMsg
  7896. res.Cainfo = resSixteen10265.Cainfo
  7897. res.WarnMsg = resSixteen10265.WarnMsg
  7898. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7899. res.Infcode = infocode
  7900. } else {
  7901. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7902. var dat map[string]interface{}
  7903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7904. fmt.Println(dat)
  7905. } else {
  7906. fmt.Println(err)
  7907. }
  7908. saveLog(result, src_resquest, "2208", "退费")
  7909. userJSONBytes, _ := json.Marshal(dat)
  7910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7911. utils.ErrorLog("解析失败:%v", err)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. }
  7916. }
  7917. if res.Infcode == 0 {
  7918. var res2 ResultSix
  7919. var resSix10265 ResultSix10265
  7920. if miConfig.MdtrtareaAdmvs == "421300" {
  7921. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7922. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7923. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7924. resp3, requestErr3 := http.Get(api3)
  7925. if requestErr3 != nil {
  7926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7927. return
  7928. }
  7929. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7930. if ioErr3 != nil {
  7931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7933. return
  7934. }
  7935. var respJSON3 map[string]interface{}
  7936. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7939. return
  7940. }
  7941. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7942. userJSONBytes3, _ := json.Marshal(respJSON3)
  7943. fmt.Println("log")
  7944. fmt.Println(string(userJSONBytes3))
  7945. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7946. utils.ErrorLog("解析失败:%v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7951. var api3 string
  7952. if miConfig.MdtrtareaAdmvs == "320921" {
  7953. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7954. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7956. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7957. } else {
  7958. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7959. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7960. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7962. }
  7963. resp3, requestErr3 := http.Get(api3)
  7964. if requestErr3 != nil {
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. return
  7967. }
  7968. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7969. if ioErr3 != nil {
  7970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. var respJSON3 map[string]interface{}
  7975. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7981. userJSONBytes3, _ := json.Marshal(respJSON3)
  7982. fmt.Println("log")
  7983. fmt.Println(string(userJSONBytes3))
  7984. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7985. utils.ErrorLog("解析失败:%v", err)
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7990. res2.Output = resSix10265.Output
  7991. res2.ErrMsg = resSix10265.ErrMsg
  7992. res2.Cainfo = resSix10265.Cainfo
  7993. res2.WarnMsg = resSix10265.WarnMsg
  7994. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7995. res2.Infcode = infocode
  7996. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7997. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7998. var dat map[string]interface{}
  7999. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8000. fmt.Println(dat)
  8001. } else {
  8002. fmt.Println(err)
  8003. }
  8004. saveLog(result2, src_request, "2205", "撤销明细")
  8005. userJSONBytes, _ := json.Marshal(dat)
  8006. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8007. utils.ErrorLog("解析失败:%v", err)
  8008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8009. return
  8010. }
  8011. } else {
  8012. if miConfig.Code == "H15049901371" {
  8013. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8014. var dat map[string]interface{}
  8015. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8016. fmt.Println(dat)
  8017. } else {
  8018. fmt.Println(err)
  8019. }
  8020. saveLog(result2, src_request, "2205", "撤销明细")
  8021. userJSONBytes, _ := json.Marshal(dat)
  8022. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8023. utils.ErrorLog("解析失败:%v", err)
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8028. res2.Output = resSix10265.Output
  8029. res2.ErrMsg = resSix10265.ErrMsg
  8030. res2.Cainfo = resSix10265.Cainfo
  8031. res2.WarnMsg = resSix10265.WarnMsg
  8032. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8033. res2.Infcode = infocode
  8034. } else {
  8035. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8036. var dat map[string]interface{}
  8037. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8038. fmt.Println(dat)
  8039. } else {
  8040. fmt.Println(err)
  8041. }
  8042. saveLog(result2, src_request, "2205", "撤销明细")
  8043. userJSONBytes, _ := json.Marshal(dat)
  8044. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8045. utils.ErrorLog("解析失败:%v", err)
  8046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8047. return
  8048. }
  8049. }
  8050. }
  8051. if res2.Infcode == 0 {
  8052. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8053. if err == nil {
  8054. //当押金不为零时产生退费记录
  8055. if order.Decimal != 0 {
  8056. tmp := strconv.FormatInt(order.ID, 10)
  8057. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8058. if err != nil {
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8060. return
  8061. }
  8062. }
  8063. c.ServeSuccessJSON(map[string]interface{}{
  8064. "msg": "退费成功",
  8065. })
  8066. } else {
  8067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8068. return
  8069. }
  8070. } else {
  8071. c.ServeSuccessJSON(map[string]interface{}{
  8072. "code": -10,
  8073. "msg": res2.ErrMsg,
  8074. })
  8075. }
  8076. } else {
  8077. c.ServeSuccessJSON(map[string]interface{}{
  8078. "code": -10,
  8079. "msg": res.ErrMsg,
  8080. })
  8081. }
  8082. }
  8083. }
  8084. func (c *HisApiController) RefundNumber() {
  8085. record_time := c.GetString("record_time")
  8086. //patient_id, _ := c.GetInt64("patient_id")
  8087. admin_user_id, _ := c.GetInt64("admin_user_id")
  8088. his_patient_id, _ := c.GetInt64("id")
  8089. timeLayout := "2006-01-02"
  8090. loc, _ := time.LoadLocation("Local")
  8091. adminUser := c.GetAdminUserInfo()
  8092. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8093. fmt.Println(err)
  8094. if err != nil {
  8095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8096. return
  8097. }
  8098. recordDateTime := theTime.Unix()
  8099. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8100. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8101. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8102. //order, _ := service.GetHisOrderByID(order_id)
  8103. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8104. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8106. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8107. if count > 0 {
  8108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8109. return
  8110. }
  8111. if config.IsOpen == 1 { //对接了医保,走医保流程
  8112. var res2 ResultSix
  8113. var resSix10265 ResultSix10265
  8114. if miConfig.MdtrtareaAdmvs == "421300" {
  8115. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8116. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8117. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8118. resp3, requestErr3 := http.Get(api3)
  8119. if requestErr3 != nil {
  8120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. return
  8122. }
  8123. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8124. if ioErr3 != nil {
  8125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8127. return
  8128. }
  8129. var respJSON3 map[string]interface{}
  8130. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8136. userJSONBytes3, _ := json.Marshal(respJSON3)
  8137. fmt.Println("log")
  8138. fmt.Println(string(userJSONBytes3))
  8139. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8140. utils.ErrorLog("解析失败:%v", err)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8145. var api3 string
  8146. if miConfig.MdtrtareaAdmvs == "320921" {
  8147. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8148. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8149. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8150. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8151. } else {
  8152. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8153. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8154. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8156. }
  8157. resp3, requestErr3 := http.Get(api3)
  8158. if requestErr3 != nil {
  8159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8160. return
  8161. }
  8162. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8163. if ioErr3 != nil {
  8164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8166. return
  8167. }
  8168. var respJSON3 map[string]interface{}
  8169. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8172. return
  8173. }
  8174. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8175. userJSONBytes3, _ := json.Marshal(respJSON3)
  8176. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8177. utils.ErrorLog("解析失败:%v", err)
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8179. return
  8180. }
  8181. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8182. res2.Output = resSix10265.Output
  8183. res2.ErrMsg = resSix10265.ErrMsg
  8184. res2.Cainfo = resSix10265.Cainfo
  8185. res2.WarnMsg = resSix10265.WarnMsg
  8186. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8187. res2.Infcode = infocode
  8188. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8189. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8190. var dat map[string]interface{}
  8191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8192. fmt.Println(dat)
  8193. } else {
  8194. fmt.Println(err)
  8195. }
  8196. saveLog(result, request, "2202", "退号")
  8197. userJSONBytes, _ := json.Marshal(dat)
  8198. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8199. utils.ErrorLog("解析失败:%v", err)
  8200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8201. return
  8202. }
  8203. } else {
  8204. var api3 string
  8205. if miConfig.Code == "H15049901371" {
  8206. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8207. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8209. } else {
  8210. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8211. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8213. }
  8214. resp3, requestErr3 := http.Get(api3)
  8215. if requestErr3 != nil {
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8220. if ioErr3 != nil {
  8221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8223. return
  8224. }
  8225. var respJSON3 map[string]interface{}
  8226. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8229. return
  8230. }
  8231. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8232. userJSONBytes3, _ := json.Marshal(respJSON3)
  8233. if miConfig.Code == "H15049901371" {
  8234. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8235. utils.ErrorLog("解析失败:%v", err)
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8237. return
  8238. }
  8239. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8240. res2.Output = resSix10265.Output
  8241. res2.ErrMsg = resSix10265.ErrMsg
  8242. res2.Cainfo = resSix10265.Cainfo
  8243. res2.WarnMsg = resSix10265.WarnMsg
  8244. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8245. res2.Infcode = infocode
  8246. } else {
  8247. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8248. utils.ErrorLog("解析失败:%v", err)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. }
  8253. }
  8254. if res2.Infcode == 0 {
  8255. if err == nil {
  8256. c.ServeSuccessJSON(map[string]interface{}{
  8257. "msg": "退号成功",
  8258. })
  8259. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8260. } else {
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. return
  8263. }
  8264. } else {
  8265. c.ServeSuccessJSON(map[string]interface{}{
  8266. "code": -10,
  8267. "msg": res2.ErrMsg,
  8268. })
  8269. }
  8270. } else {
  8271. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8272. //if err == nil {
  8273. // c.ServeSuccessJSON(map[string]interface{}{
  8274. // "msg": "退费成功",
  8275. // })
  8276. //} else {
  8277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. // return
  8279. //}
  8280. }
  8281. }
  8282. func (c *HisApiController) RefundDetail() {
  8283. order_id, _ := c.GetInt64("order_id")
  8284. admin_user_id, _ := c.GetInt64("admin_user_id")
  8285. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8286. number := c.GetString("number")
  8287. record_time := c.GetString("record_time")
  8288. patient_id, _ := c.GetInt64("patient_id")
  8289. //med_type, _ := c.GetInt64("med_type")
  8290. timeLayout := "2006-01-02"
  8291. loc, _ := time.LoadLocation("Local")
  8292. adminUser := c.GetAdminUserInfo()
  8293. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8294. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8295. fmt.Println(err)
  8296. if err != nil {
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8298. return
  8299. }
  8300. recordDateTime := theTime.Unix()
  8301. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8302. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8303. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8304. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8305. var order models.HisOrder
  8306. order, _ = service.GetHisOrderByID(order_id)
  8307. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8308. if config.IsOpen == 1 { //对接了医保,走医保流程
  8309. var res2 ResultSix
  8310. if miConfig.MdtrtareaAdmvs == "421300" {
  8311. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8312. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8313. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8314. resp3, requestErr3 := http.Get(api3)
  8315. if requestErr3 != nil {
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8317. return
  8318. }
  8319. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8320. if ioErr3 != nil {
  8321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. return
  8324. }
  8325. var respJSON3 map[string]interface{}
  8326. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8329. return
  8330. }
  8331. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8332. userJSONBytes3, _ := json.Marshal(respJSON3)
  8333. fmt.Println("log")
  8334. fmt.Println(string(userJSONBytes3))
  8335. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8336. utils.ErrorLog("解析失败:%v", err)
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8341. if err == nil {
  8342. c.ServeSuccessJSON(map[string]interface{}{
  8343. "msg": "撤销明细成功",
  8344. })
  8345. return
  8346. } else {
  8347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8348. return
  8349. }
  8350. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8351. var resSix10265 ResultSix10265
  8352. var api3 string
  8353. if miConfig.MdtrtareaAdmvs == "320921" {
  8354. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8355. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8356. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8357. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8358. } else {
  8359. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8360. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8361. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8362. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8363. }
  8364. resp3, requestErr3 := http.Get(api3)
  8365. if requestErr3 != nil {
  8366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8367. return
  8368. }
  8369. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8370. if ioErr3 != nil {
  8371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. var respJSON3 map[string]interface{}
  8376. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8382. userJSONBytes3, _ := json.Marshal(respJSON3)
  8383. fmt.Println("log")
  8384. fmt.Println(string(userJSONBytes3))
  8385. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8386. utils.ErrorLog("解析失败:%v", err)
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. return
  8389. }
  8390. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8391. res2.Output = resSix10265.Output
  8392. res2.ErrMsg = resSix10265.ErrMsg
  8393. res2.Cainfo = resSix10265.Cainfo
  8394. res2.WarnMsg = resSix10265.WarnMsg
  8395. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8396. res2.Infcode = infocode
  8397. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8398. if err == nil {
  8399. c.ServeSuccessJSON(map[string]interface{}{
  8400. "msg": "撤销明细成功",
  8401. })
  8402. return
  8403. } else {
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8408. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8409. var dat map[string]interface{}
  8410. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8411. fmt.Println(dat)
  8412. } else {
  8413. fmt.Println(err)
  8414. }
  8415. saveLog(result2, src_request, "2205", "撤销明细")
  8416. userJSONBytes, _ := json.Marshal(dat)
  8417. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8418. utils.ErrorLog("解析失败:%v", err)
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8420. return
  8421. }
  8422. if res2.Infcode == 0 {
  8423. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8424. if err == nil {
  8425. c.ServeSuccessJSON(map[string]interface{}{
  8426. "msg": "撤销明细成功",
  8427. })
  8428. return
  8429. } else {
  8430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8431. return
  8432. }
  8433. } else {
  8434. c.ServeSuccessJSON(map[string]interface{}{
  8435. "code": -10,
  8436. "msg": res2.ErrMsg,
  8437. })
  8438. }
  8439. } else {
  8440. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8441. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8443. resp2, requestErr2 := http.Get(api2)
  8444. if requestErr2 != nil {
  8445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8446. return
  8447. }
  8448. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8449. if ioErr2 != nil {
  8450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8452. return
  8453. }
  8454. var respJSON2 map[string]interface{}
  8455. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8458. return
  8459. }
  8460. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8461. if err == nil {
  8462. c.ServeSuccessJSON(map[string]interface{}{
  8463. "msg": "撤销明细成功",
  8464. })
  8465. return
  8466. } else {
  8467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8468. return
  8469. }
  8470. }
  8471. } else {
  8472. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8473. if err == nil {
  8474. c.ServeSuccessJSON(map[string]interface{}{
  8475. "msg": "退费成功",
  8476. })
  8477. } else {
  8478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8479. return
  8480. }
  8481. }
  8482. }
  8483. //对账
  8484. func (c *HisApiController) GetCheckAccount() {
  8485. start_time := c.GetString("start_time")
  8486. end_time := c.GetString("end_time")
  8487. insutype := c.GetString("insutype")
  8488. clr_type := c.GetString("clr_type")
  8489. clr_org := c.GetString("clr_optins")
  8490. admin_user_id, _ := c.GetInt64("admin_user_id")
  8491. adminUser := c.GetAdminUserInfo()
  8492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8494. if len(clr_org) == 0 {
  8495. clr_org = miConfig.MdtrtareaAdmvs
  8496. }
  8497. timeLayout := "2006-01-02"
  8498. loc, _ := time.LoadLocation("Local")
  8499. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8500. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8501. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8502. fixmedins_setl_cnt := int64(len(orders))
  8503. var medfee_sumamt float64
  8504. var acct_pay float64
  8505. var fund_pay_sumamt float64
  8506. for _, item := range orders {
  8507. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8508. acct_pay = acct_pay + item.AcctPay
  8509. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8510. }
  8511. var user_name string
  8512. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8513. if role.ID == 0 {
  8514. user_name = "xxx"
  8515. } else {
  8516. user_name = role.UserName
  8517. }
  8518. var res ResultEight
  8519. var res10188 ResultEightFor10188
  8520. if config.IsOpen == 1 {
  8521. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8522. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8523. "insutype=" + insutype +
  8524. "&clr_type=" + clr_type +
  8525. "&setl_optins=" + clr_org +
  8526. "&stmt_begndate=" + start_time +
  8527. "&stm_enddate=" + end_time +
  8528. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8529. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8530. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8531. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8532. "&fixmedins_code=" + miConfig.Code +
  8533. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8534. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8535. "&secret_key=" + miConfig.SecretKey +
  8536. "&org_name=" + miConfig.OrgName +
  8537. "&doctor=" + user_name +
  8538. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8539. fmt.Println(api)
  8540. resp, requestErr := http.Get(api)
  8541. if requestErr != nil {
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. body, ioErr := ioutil.ReadAll(resp.Body)
  8546. fmt.Println(body)
  8547. if ioErr != nil {
  8548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8550. return
  8551. }
  8552. var respJSON map[string]interface{}
  8553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8556. return
  8557. }
  8558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8559. userJSONBytes, _ := json.Marshal(respJSON)
  8560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8561. utils.ErrorLog("解析失败:%v", err)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. res.InfRefmsgid = res10188.InfRefmsgid
  8566. res.Output = res10188.Output
  8567. res.ErrMsg = res10188.ErrMsg
  8568. res.Cainfo = res10188.Cainfo
  8569. res.WarnMsg = res10188.WarnMsg
  8570. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8571. res.Infcode = infocode
  8572. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8573. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8574. "insutype=" + insutype +
  8575. "&clr_type=" + clr_type +
  8576. "&setl_optins=" + clr_org +
  8577. "&stmt_begndate=" + start_time +
  8578. "&stm_enddate=" + end_time +
  8579. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8580. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8581. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8582. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8583. "&fixmedins_code=" + miConfig.Code +
  8584. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8585. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8586. "&secret_key=" + miConfig.SecretKey +
  8587. "&org_name=" + miConfig.OrgName +
  8588. "&doctor=" + user_name
  8589. resp, requestErr := http.Get(api)
  8590. if requestErr != nil {
  8591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8592. return
  8593. }
  8594. body, ioErr := ioutil.ReadAll(resp.Body)
  8595. if ioErr != nil {
  8596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8598. return
  8599. }
  8600. var respJSON map[string]interface{}
  8601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8604. return
  8605. }
  8606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8607. result, _ := json.Marshal(respJSON)
  8608. fmt.Println("log")
  8609. fmt.Println(string(result))
  8610. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8611. utils.ErrorLog("解析失败:%v", err)
  8612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8613. return
  8614. }
  8615. res.InfRefmsgid = res10188.InfRefmsgid
  8616. res.Output = res10188.Output
  8617. res.ErrMsg = res10188.ErrMsg
  8618. res.Cainfo = res10188.Cainfo
  8619. res.WarnMsg = res10188.WarnMsg
  8620. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8621. res.Infcode = infocode
  8622. } else {
  8623. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8624. "insutype=" + insutype +
  8625. "&clr_type=" + clr_type +
  8626. "&setl_optins=" + clr_org +
  8627. "&stmt_begndate=" + start_time +
  8628. "&stm_enddate=" + end_time +
  8629. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8630. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8631. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8632. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8633. "&fixmedins_code=" + miConfig.Code +
  8634. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8635. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8636. "&secret_key=" + miConfig.SecretKey +
  8637. "&org_name=" + miConfig.OrgName +
  8638. "&doctor=" + user_name
  8639. fmt.Println(api)
  8640. resp, requestErr := http.Get(api)
  8641. if requestErr != nil {
  8642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8643. return
  8644. }
  8645. body, ioErr := ioutil.ReadAll(resp.Body)
  8646. fmt.Println(body)
  8647. if ioErr != nil {
  8648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8650. return
  8651. }
  8652. var respJSON map[string]interface{}
  8653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8656. return
  8657. }
  8658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8659. userJSONBytes, _ := json.Marshal(respJSON)
  8660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8661. utils.ErrorLog("解析失败:%v", err)
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. }
  8666. if res.Infcode == 0 {
  8667. if res.Output.Stmtinfo.StmtRslt == "0" {
  8668. micc := &models.MedicalInsuranceCostCompare{
  8669. StartTime: startime.Unix(),
  8670. EndTime: endtime.Unix(),
  8671. Insutype: insutype,
  8672. CheckType: 1,
  8673. Num: fixmedins_setl_cnt,
  8674. Mtime: time.Now().Unix(),
  8675. Status: 1,
  8676. UserOrgId: adminUser.CurrentOrgId,
  8677. CostTotal: medfee_sumamt,
  8678. FuncTotal: fund_pay_sumamt,
  8679. PsnPay: acct_pay,
  8680. Creator: admin_user_id,
  8681. Ctime: time.Now().Unix(),
  8682. ClrType: clr_type,
  8683. }
  8684. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8685. if err == nil {
  8686. c.ServeSuccessJSON(map[string]interface{}{
  8687. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8688. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8689. })
  8690. } else {
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. }
  8693. } else {
  8694. c.ServeSuccessJSON(map[string]interface{}{
  8695. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8696. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8697. })
  8698. }
  8699. } else {
  8700. c.ServeSuccessJSON(map[string]interface{}{
  8701. "code": -10,
  8702. "msg": res.ErrMsg,
  8703. })
  8704. }
  8705. }
  8706. }
  8707. func (c *HisApiController) Check310() {
  8708. adminUser := c.GetAdminUserInfo()
  8709. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8710. var user_name string
  8711. user_name = "高慧裕"
  8712. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8713. "insutype=" + "310" +
  8714. "&clr_type=" + "" +
  8715. "&setl_optins=" + "441202" +
  8716. "&stmt_begndate=" + "2022-03-01" +
  8717. "&stm_enddate=" + "2022-03-31" +
  8718. "&medfee_sumamt=" + "194930.12" +
  8719. "&fund_pay_sumamt=" + "188741.46" +
  8720. "&acct_pay=" + "0" +
  8721. "&fixmedins_setl_cnt=" + "452" +
  8722. "&fixmedins_code=" + miConfig.Code +
  8723. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8724. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8725. "&secret_key=" + miConfig.SecretKey +
  8726. "&org_name=" + miConfig.OrgName +
  8727. "&doctor=" + user_name
  8728. fmt.Println(api)
  8729. resp, requestErr := http.Get(api)
  8730. if requestErr != nil {
  8731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8732. return
  8733. }
  8734. body, ioErr := ioutil.ReadAll(resp.Body)
  8735. fmt.Println(body)
  8736. if ioErr != nil {
  8737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8739. return
  8740. }
  8741. var respJSON map[string]interface{}
  8742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8745. return
  8746. }
  8747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8748. userJSONBytes, _ := json.Marshal(respJSON)
  8749. var res ResultEight
  8750. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8751. utils.ErrorLog("解析失败:%v", err)
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. }
  8756. func (c *HisApiController) Check390() {
  8757. adminUser := c.GetAdminUserInfo()
  8758. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8759. var user_name string
  8760. user_name = "高慧裕"
  8761. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8762. "insutype=" + "390" +
  8763. "&clr_type=" + "" +
  8764. "&setl_optins=" + "441202" +
  8765. "&stmt_begndate=" + "2022-03-01" +
  8766. "&stm_enddate=" + "2022-03-31" +
  8767. "&medfee_sumamt=" + "1068448.89" +
  8768. "&fund_pay_sumamt=" + "1014677.62" +
  8769. "&acct_pay=" + "0" +
  8770. "&fixmedins_setl_cnt=" + "1950" +
  8771. "&fixmedins_code=" + miConfig.Code +
  8772. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8773. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8774. "&secret_key=" + miConfig.SecretKey +
  8775. "&org_name=" + miConfig.OrgName +
  8776. "&doctor=" + user_name
  8777. fmt.Println(api)
  8778. resp, requestErr := http.Get(api)
  8779. if requestErr != nil {
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8781. return
  8782. }
  8783. body, ioErr := ioutil.ReadAll(resp.Body)
  8784. fmt.Println(body)
  8785. if ioErr != nil {
  8786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8788. return
  8789. }
  8790. var respJSON map[string]interface{}
  8791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8794. return
  8795. }
  8796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8797. userJSONBytes, _ := json.Marshal(respJSON)
  8798. var res ResultEight
  8799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8800. utils.ErrorLog("解析失败:%v", err)
  8801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8802. return
  8803. }
  8804. }
  8805. //对账明细
  8806. func (c *HisApiController) GetCheckDetailAccount() {
  8807. start_time := c.GetString("start_time")
  8808. end_time := c.GetString("end_time")
  8809. admin_user_id, _ := c.GetInt64("admin_user_id")
  8810. adminUser := c.GetAdminUserInfo()
  8811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8813. timeLayout := "2006-01-02"
  8814. loc, _ := time.LoadLocation("Local")
  8815. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8816. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8817. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8818. rand.Seed(time.Now().UnixNano())
  8819. num := rand.Intn(30000)
  8820. Mkdir(miConfig.OrgName)
  8821. file := strconv.FormatInt(int64(num), 10)
  8822. file_name := file + ".txt"
  8823. zip_name := file + ".zip"
  8824. zip_path := miConfig.OrgName + "/" + zip_name
  8825. file_path := miConfig.OrgName + "/" + file_name
  8826. decimal.DivisionPrecision = 2
  8827. var medfee_sumamt float64
  8828. var psn_cash_pay float64
  8829. var fund_pay_sumamt float64
  8830. fixmedins_setl_cnt := int64(len(orders))
  8831. for _, item := range orders {
  8832. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8833. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8834. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8835. }
  8836. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8837. defer f.Close()
  8838. if err != nil {
  8839. fmt.Println(err.Error())
  8840. } else {
  8841. for _, item := range orders {
  8842. var refd_setl_flag string
  8843. if item.OrderStatus == 2 {
  8844. refd_setl_flag = "0"
  8845. var str string
  8846. str = item.SetlId + " " +
  8847. item.MdtrtId + " " +
  8848. item.PsnNo + " " +
  8849. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8850. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8851. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8852. _, err = f.Write([]byte(str))
  8853. }
  8854. if item.OrderStatus == 3 {
  8855. var str string
  8856. str = item.SetlId + " " +
  8857. item.MdtrtId + " " +
  8858. item.PsnNo + " " +
  8859. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8860. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8861. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8862. _, err = f.Write([]byte(str))
  8863. var str2 string
  8864. str2 = item.SetlId + " " +
  8865. item.MdtrtId + " " +
  8866. item.PsnNo + " " +
  8867. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8868. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8869. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8870. _, err = f.Write([]byte(str2))
  8871. }
  8872. }
  8873. }
  8874. Zip(file_path, zip_path)
  8875. fmt.Println(ReadFile(zip_path))
  8876. fmt.Println(string(ReadFile(zip_path)))
  8877. if config.IsOpen == 1 {
  8878. var user_name string
  8879. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8880. if role.ID == 0 {
  8881. user_name = "管理员"
  8882. } else {
  8883. user_name = role.UserName
  8884. }
  8885. baseParams := models.BaseParams{
  8886. SecretKey: miConfig.SecretKey,
  8887. FixmedinsCode: miConfig.Code,
  8888. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8889. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8890. OrgName: miConfig.OrgName,
  8891. Doctor: user_name,
  8892. }
  8893. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8894. var dat map[string]interface{}
  8895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8896. fmt.Println(dat)
  8897. } else {
  8898. fmt.Println(err)
  8899. }
  8900. userJSONBytes, _ := json.Marshal(dat)
  8901. var res ResultNine
  8902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8903. utils.ErrorLog("解析失败:%v", err)
  8904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8905. return
  8906. }
  8907. if res.Infcode == 0 {
  8908. fileNo := res.Output.FileQuryNo
  8909. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8910. "file_qury_no=" + fileNo +
  8911. "&setl_optins=" + "定点医保中心" +
  8912. "&stmt_begndate=" + start_time +
  8913. "&stm_enddate=" + end_time +
  8914. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8915. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8916. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8917. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8918. "&fixmedins_code=" + miConfig.Code +
  8919. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8920. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8921. "&secret_key=" + miConfig.SecretKey +
  8922. "&org_name=" + miConfig.OrgName +
  8923. "&doctor=" + user_name
  8924. resp, requestErr := http.Get(api)
  8925. if requestErr != nil {
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8927. return
  8928. }
  8929. body, ioErr := ioutil.ReadAll(resp.Body)
  8930. if ioErr != nil {
  8931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8933. return
  8934. }
  8935. var respJSON map[string]interface{}
  8936. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8939. return
  8940. }
  8941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8942. userJSONBytes, _ := json.Marshal(respJSON)
  8943. var res ResultTen
  8944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8945. utils.ErrorLog("解析失败:%v", err)
  8946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8947. return
  8948. }
  8949. if res.Infcode == 0 {
  8950. service.Gdyb9102(baseParams, zip_name, fileNo)
  8951. micc := &models.MedicalInsuranceCostCompare{
  8952. StartTime: startime.Unix(),
  8953. EndTime: endtime.Unix(),
  8954. Insutype: "0",
  8955. CheckType: 2,
  8956. Num: fixmedins_setl_cnt,
  8957. Mtime: time.Now().Unix(),
  8958. Status: 1,
  8959. UserOrgId: adminUser.CurrentOrgId,
  8960. CostTotal: medfee_sumamt,
  8961. FuncTotal: fund_pay_sumamt,
  8962. PsnPay: psn_cash_pay,
  8963. Creator: admin_user_id,
  8964. Ctime: time.Now().Unix(),
  8965. }
  8966. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8967. c.ServeSuccessJSON(map[string]interface{}{
  8968. "msg": "明细对账成功",
  8969. })
  8970. }
  8971. } else {
  8972. }
  8973. }
  8974. }
  8975. type CustomOrderInfo struct {
  8976. Name string
  8977. Spec string
  8978. Unit string
  8979. Count float64
  8980. Price float64
  8981. Total float64
  8982. }
  8983. func (c *HisApiController) GetSettleAccounts() {
  8984. //id, _ := c.GetInt64("id")
  8985. //record_time := c.GetString("record_time")
  8986. order_id, _ := c.GetInt64("order_id")
  8987. admin_user_id, _ := c.GetInt64("admin_user_id")
  8988. //timeLayout := "2006-01-02"
  8989. //loc, _ := time.LoadLocation("Local")
  8990. //
  8991. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8992. //if err != nil {
  8993. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8994. // return
  8995. //}
  8996. //recordDateTime := theTime.Unix()
  8997. adminUser := c.GetAdminUserInfo()
  8998. order, _ := service.GetHisOrderByID(order_id)
  8999. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9000. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9001. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9002. orderInfos = append(orderInfos, orderInfos_two...)
  9003. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9004. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9005. var diagnosis_ids []string
  9006. if his.ID > 0 {
  9007. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9008. } else {
  9009. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9010. }
  9011. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9012. var dia_config []*models.HisXtDiagnoseConfig
  9013. var name string
  9014. for _, item := range diagnosis_ids {
  9015. id, _ := strconv.ParseInt(item, 10, 64)
  9016. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9017. dia_config = append(dia_config, &diagnosisConfig)
  9018. if len(name) == 0 {
  9019. name = diagnosisConfig.ClassName
  9020. } else {
  9021. name = name + "," + diagnosisConfig.ClassName
  9022. }
  9023. }
  9024. var bedCostTotal float64 = 0 //床位总费
  9025. var bedCostSelfTotal float64 = 0 //床位自费
  9026. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9027. var operationCostTotal float64 = 0 //手术费
  9028. var operationCostSelfTotal float64 = 0 //手术费
  9029. var operationCostPartSelfTotal float64 = 0 //手术费
  9030. var otherCostTotal float64 = 0 //其他费用
  9031. var otherCostSelfTotal float64 = 0 //其他费用
  9032. var otherCostPartSelfTotal float64 = 0 //其他费用
  9033. var materialCostTotal float64 = 0 //材料费
  9034. var materialCostSelfTotal float64 = 0 //材料费
  9035. var materialCostPartSelfTotal float64 = 0 //材料费
  9036. var westernMedicineCostTotal float64 = 0 //西药费
  9037. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9038. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9039. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9040. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9041. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9042. var checkCostTotal float64 = 0 //检查费
  9043. var checkCostSelfTotal float64 = 0 //检查费
  9044. var checkCostPartSelfTotal float64 = 0 //检查费
  9045. var laboratoryCostTotal float64 = 0 //化验费
  9046. var laboratoryCostSelfTotal float64 = 0 //化验费
  9047. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9048. var treatCostTotal float64 = 0 //治疗费用
  9049. var treatCostSelfTotal float64 = 0 //治疗费用
  9050. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9051. decimal.DivisionPrecision = 2
  9052. for _, item := range orderInfos {
  9053. if item.MedChrgitmType == "01" { //床位费
  9054. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9055. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9056. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9057. }
  9058. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9059. if item.MedChrgitmType == "03" { //检查费
  9060. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9061. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9062. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9063. }
  9064. } else {
  9065. if item.MedChrgitmType == "03" { //检查费
  9066. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9067. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9068. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9069. }
  9070. }
  9071. if item.MedChrgitmType == "04" { //化验费
  9072. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9073. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9074. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9075. }
  9076. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9077. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9078. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9079. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9080. }
  9081. if item.MedChrgitmType == "06" { //手术费
  9082. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9083. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9084. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9085. }
  9086. if item.MedChrgitmType == "08" { //材料费
  9087. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9088. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9089. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9090. }
  9091. if item.MedChrgitmType == "09" { //西药费
  9092. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9093. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9094. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9095. }
  9096. if item.MedChrgitmType == "11" { //中成费
  9097. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9098. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9099. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9100. }
  9101. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9102. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9103. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9104. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9105. }
  9106. }
  9107. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9108. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9109. var user_name string
  9110. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9111. if role.ID == 0 {
  9112. user_name = "管理员"
  9113. } else {
  9114. user_name = role.UserName
  9115. }
  9116. baseParams := models.BaseParams{
  9117. SecretKey: miConfig.SecretKey,
  9118. FixmedinsCode: miConfig.Code,
  9119. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9120. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9121. OrgName: miConfig.OrgName,
  9122. Doctor: user_name,
  9123. }
  9124. businessParams := models.BusinessParams{
  9125. PsnNo: order.PsnNo,
  9126. MdtrtId: order.MdtrtId,
  9127. SetlId: order.SetlId,
  9128. }
  9129. var res ResultEleven
  9130. var resEleven10265 ResultEleven10265
  9131. if config.IsOpen == 1 {
  9132. if miConfig.MdtrtareaAdmvs == "421300" {
  9133. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9134. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9136. resp, requestErr := http.Get(api)
  9137. if requestErr != nil {
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9139. return
  9140. }
  9141. body, ioErr := ioutil.ReadAll(resp.Body)
  9142. if ioErr != nil {
  9143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9145. return
  9146. }
  9147. var respJSON map[string]interface{}
  9148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9151. return
  9152. }
  9153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9154. result, _ := json.Marshal(respJSON)
  9155. fmt.Println("log")
  9156. fmt.Println(string(result))
  9157. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9158. utils.ErrorLog("解析失败:%v", err)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9163. var api string
  9164. if miConfig.MdtrtareaAdmvs == "320921" {
  9165. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9166. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9167. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9168. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9169. } else {
  9170. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9171. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9172. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9173. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9174. }
  9175. resp, requestErr := http.Get(api)
  9176. if requestErr != nil {
  9177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9178. return
  9179. }
  9180. body, ioErr := ioutil.ReadAll(resp.Body)
  9181. if ioErr != nil {
  9182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9184. return
  9185. }
  9186. var respJSON map[string]interface{}
  9187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9190. return
  9191. }
  9192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9193. result, _ := json.Marshal(respJSON)
  9194. fmt.Println("log")
  9195. fmt.Println(string(result))
  9196. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9197. utils.ErrorLog("解析失败:%v", err)
  9198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9199. return
  9200. }
  9201. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9202. res.Output = resEleven10265.Output
  9203. res.ErrMsg = resEleven10265.ErrMsg
  9204. res.Cainfo = resEleven10265.Cainfo
  9205. res.WarnMsg = resEleven10265.WarnMsg
  9206. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9207. res.Infcode = infocode
  9208. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9209. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9210. saveLog(result, requestLog, "5203", "结算单")
  9211. var dat map[string]interface{}
  9212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9213. fmt.Println(dat)
  9214. } else {
  9215. fmt.Println(err)
  9216. }
  9217. userJSONBytes, _ := json.Marshal(dat)
  9218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9219. utils.ErrorLog("解析失败:%v", err)
  9220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9221. return
  9222. }
  9223. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9224. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9225. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9226. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9227. resp, requestErr := http.Get(api)
  9228. if requestErr != nil {
  9229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9230. return
  9231. }
  9232. body, ioErr := ioutil.ReadAll(resp.Body)
  9233. if ioErr != nil {
  9234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9236. return
  9237. }
  9238. var respJSON map[string]interface{}
  9239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9242. return
  9243. }
  9244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9245. result, _ := json.Marshal(respJSON)
  9246. fmt.Println("log")
  9247. fmt.Println(string(result))
  9248. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9249. utils.ErrorLog("解析失败:%v", err)
  9250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9251. return
  9252. }
  9253. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9254. res.Output = resEleven10265.Output
  9255. res.ErrMsg = resEleven10265.ErrMsg
  9256. res.Cainfo = resEleven10265.Cainfo
  9257. res.WarnMsg = resEleven10265.WarnMsg
  9258. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9259. res.Infcode = infocode
  9260. } else {
  9261. result := service.Gdyb5203(baseParams, businessParams)
  9262. //service.Gdyb5204(baseParams, businessParams)
  9263. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9264. var dat map[string]interface{}
  9265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9266. fmt.Println(dat)
  9267. } else {
  9268. fmt.Println(err)
  9269. }
  9270. userJSONBytes, _ := json.Marshal(dat)
  9271. if miConfig.Code == "H15049901371" {
  9272. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9273. utils.ErrorLog("解析失败:%v", err)
  9274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9275. return
  9276. }
  9277. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9278. res.Output = resEleven10265.Output
  9279. res.ErrMsg = resEleven10265.ErrMsg
  9280. res.Cainfo = resEleven10265.Cainfo
  9281. res.WarnMsg = resEleven10265.WarnMsg
  9282. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9283. res.Infcode = infocode
  9284. } else {
  9285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9286. utils.ErrorLog("解析失败:%v", err)
  9287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9288. return
  9289. }
  9290. }
  9291. }
  9292. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9293. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9294. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9295. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9296. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9297. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9298. var doctor_name string
  9299. if roles.ID == 0 {
  9300. doctor_name = "管理员"
  9301. } else {
  9302. doctor_name = roles.UserName
  9303. }
  9304. yiliao_leibie := ""
  9305. switch order.MedType {
  9306. case "11":
  9307. yiliao_leibie = "普通门诊"
  9308. break
  9309. case "12":
  9310. yiliao_leibie = "门诊挂号"
  9311. break
  9312. case "13":
  9313. yiliao_leibie = "急诊"
  9314. break
  9315. case "14":
  9316. yiliao_leibie = "门诊特殊病"
  9317. break
  9318. case "15":
  9319. yiliao_leibie = "门诊统筹"
  9320. break
  9321. case "16":
  9322. yiliao_leibie = "门诊慢性病"
  9323. break
  9324. case "21":
  9325. yiliao_leibie = "普通住院"
  9326. break
  9327. }
  9328. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9329. if res.Infcode == 0 {
  9330. c.ServeSuccessJSON(map[string]interface{}{
  9331. "diagnosis": name,
  9332. "order_infos": orderInfos,
  9333. "number": order.MdtrtId,
  9334. "date": order.SettleAccountsDate,
  9335. "charge_admin": charge_admin,
  9336. "printor_admin": printor_admin,
  9337. "info": res.Output.Setlinfo,
  9338. "order": order,
  9339. "bedCostTotal": bedCostTotal,
  9340. "bedCostSelfTotal": bedCostSelfTotal,
  9341. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9342. "operationCostTotal": operationCostTotal,
  9343. "operationCostSelfTotal": operationCostSelfTotal,
  9344. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9345. "otherCostTotal": otherCostTotal,
  9346. "otherCostSelfTotal": otherCostSelfTotal,
  9347. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9348. "materialCostTotal": materialCostTotal,
  9349. "materialCostSelfTotal": materialCostSelfTotal,
  9350. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9351. "westernMedicineCostTotal": westernMedicineCostTotal,
  9352. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9353. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9354. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9355. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9356. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9357. "checkCostTotal": checkCostTotal,
  9358. "checkCostSelfTotal": checkCostSelfTotal,
  9359. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9360. "laboratoryCostTotal": laboratoryCostTotal,
  9361. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9362. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9363. "treatCostTotal": treatCostTotal,
  9364. "treatCostSelfTotal": treatCostSelfTotal,
  9365. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9366. "doctor_info": doctor_info,
  9367. "doctor_code": adminRole_two.DoctorCode,
  9368. "doctor_name": doctor_name,
  9369. "health_card_no": order.PsnNo,
  9370. "department": departments.Name,
  9371. "yiliao_leibie": yiliao_leibie,
  9372. "after_money": order.AccountPrice,
  9373. "patient": patient,
  9374. "org_name": miConfig.OrgName,
  9375. "org_code": miConfig.Code,
  9376. "order_number": order.Number,
  9377. "his_hospital": his_hospital,
  9378. "his": his,
  9379. "dia_config": dia_config,
  9380. //"check_order_info": cus_slice,
  9381. })
  9382. }
  9383. }
  9384. }
  9385. func (c *HisApiController) CheckTreatment() {
  9386. patient_id, _ := c.GetInt64("patient_id")
  9387. id_card_no := c.GetString("id_card_no")
  9388. insutype := c.GetString("insutype")
  9389. med_type := c.GetString("med_type")
  9390. admin_user_id, _ := c.GetInt64("admin_user_id")
  9391. adminUser := c.GetAdminUserInfo()
  9392. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9394. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9395. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9396. if miConfig.MdtrtareaAdmvs == "421300" {
  9397. var res ResultTwo
  9398. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9399. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9400. "&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)
  9401. resp, requestErr := http.Get(api)
  9402. if requestErr != nil {
  9403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9404. return
  9405. }
  9406. body, ioErr := ioutil.ReadAll(resp.Body)
  9407. if ioErr != nil {
  9408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9410. return
  9411. }
  9412. var respJSON map[string]interface{}
  9413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9416. return
  9417. }
  9418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9419. result, _ := json.Marshal(respJSON)
  9420. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9421. utils.ErrorLog("解析失败:%v", err)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. if res.Infcode == 0 {
  9426. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9427. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9428. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9429. resp, requestErr := http.Get(api)
  9430. if requestErr != nil {
  9431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9432. return
  9433. }
  9434. body, ioErr := ioutil.ReadAll(resp.Body)
  9435. if ioErr != nil {
  9436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9438. return
  9439. }
  9440. var respJSON map[string]interface{}
  9441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9444. return
  9445. }
  9446. var res Result2001
  9447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9448. result2, _ := json.Marshal(respJSON)
  9449. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9450. utils.ErrorLog("解析失败:%v", err)
  9451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9452. return
  9453. }
  9454. if res.Infcode == 0 {
  9455. c.ServeSuccessJSON(map[string]interface{}{
  9456. "msg": res.Output.Trtinfo,
  9457. })
  9458. }
  9459. } else {
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9461. return
  9462. }
  9463. } else {
  9464. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9465. var dat map[string]interface{}
  9466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9467. fmt.Println(dat)
  9468. } else {
  9469. fmt.Println(err)
  9470. }
  9471. userJSONBytes, _ := json.Marshal(dat)
  9472. var res ResultTwo
  9473. var res10265 ResultTwo10265
  9474. if miConfig.Code == "H15049901371" {
  9475. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9476. utils.ErrorLog("解析失败:%v", err)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. res.ErrMsg = res10265.ErrMsg
  9481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9482. res.Infcode = infocode
  9483. res.Output = res10265.Output
  9484. res.InfRefmsgid = res10265.InfRefmsgid
  9485. } else {
  9486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9487. utils.ErrorLog("解析失败:%v", err)
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9489. return
  9490. }
  9491. }
  9492. var user_name string
  9493. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9494. if role.ID == 0 {
  9495. user_name = "xxx"
  9496. } else {
  9497. user_name = role.UserName
  9498. }
  9499. baseParams := models.BaseParams{
  9500. SecretKey: miConfig.SecretKey,
  9501. FixmedinsCode: miConfig.Code,
  9502. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9503. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9504. OrgName: miConfig.OrgName,
  9505. Doctor: user_name,
  9506. }
  9507. if config.IsOpen == 1 {
  9508. if miConfig.Code == "H15049901371" {
  9509. if med_type == "14" {
  9510. if insutype == "390" {
  9511. med_type = "9933"
  9512. } else if insutype == "310" {
  9513. med_type = "990502"
  9514. }
  9515. } else if med_type == "11" {
  9516. med_type = "11"
  9517. }
  9518. }
  9519. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9520. var dat map[string]interface{}
  9521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9522. fmt.Println(dat)
  9523. } else {
  9524. fmt.Println(err)
  9525. }
  9526. var res Result2001
  9527. var res10265 Result2001Org10265
  9528. if miConfig.Code == "H15049901371" {
  9529. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9530. utils.ErrorLog("解析失败:%v", err)
  9531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9532. return
  9533. }
  9534. res.ErrMsg = res10265.ErrMsg
  9535. res.Output = res10265.Output
  9536. res.InfRefmsgid = res10265.InfRefmsgid
  9537. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9538. res.Infcode = infocode
  9539. } else {
  9540. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9541. utils.ErrorLog("解析失败:%v", err)
  9542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9543. return
  9544. }
  9545. }
  9546. if res.Infcode == 0 {
  9547. c.ServeSuccessJSON(map[string]interface{}{
  9548. "msg": res.Output.Trtinfo,
  9549. })
  9550. }
  9551. }
  9552. }
  9553. }
  9554. //func (c *HisApiController) PutRecord() {
  9555. // id, _ := c.GetInt64("id")
  9556. // record_time := c.GetString("record_time")
  9557. // timeLayout := "2006-01-02"
  9558. // loc, _ := time.LoadLocation("Local")
  9559. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9560. // if err != nil {
  9561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9562. // return
  9563. // }
  9564. // recordDateTime := theTime.Unix()
  9565. //
  9566. // adminInfo := c.GetAdminUserInfo()
  9567. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9568. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9569. //
  9570. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9571. //
  9572. // fmt.Println(miConfig.SecretKey)
  9573. //
  9574. // if patient == nil {
  9575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9576. // return
  9577. // }
  9578. // if len(patient.IdCardNo) == 0 {
  9579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9580. // return
  9581. // }
  9582. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9583. // if config.IsOpen == 1 {
  9584. // 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
  9585. // resp, requestErr := http.Get(api)
  9586. // if requestErr != nil {
  9587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9588. // return
  9589. // }
  9590. // defer resp.Body.Close()
  9591. // body, ioErr := ioutil.ReadAll(resp.Body)
  9592. // if ioErr != nil {
  9593. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9595. // return
  9596. // }
  9597. // var respJSON map[string]interface{}
  9598. //
  9599. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9600. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9602. // return
  9603. // }
  9604. //
  9605. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9606. // userJSONBytes, _ := json.Marshal(userJSON)
  9607. // var res ResultTwo
  9608. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9609. // utils.ErrorLog("解析失败:%v", err)
  9610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9611. // return
  9612. // }
  9613. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9614. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9615. // infoStr := string(Iinfos)
  9616. // idetinfoStr := string(Idetinfos)
  9617. //
  9618. // if res.Infcode == 0 {
  9619. // his := models.VMHisPatient{
  9620. // Status: 1,
  9621. // Ctime: time.Now().Unix(),
  9622. // Mtime: time.Now().Unix(),
  9623. // PsnNo: res.Output.Baseinfo.PsnNo,
  9624. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9625. // Certno: res.Output.Baseinfo.Certno,
  9626. // PsnName: res.Output.Baseinfo.PsnName,
  9627. // Gend: res.Output.Baseinfo.Gend,
  9628. // Naty: res.Output.Baseinfo.Naty,
  9629. // Brdy: res.Output.Baseinfo.Brdy,
  9630. // Age: res.Output.Baseinfo.Age,
  9631. // Iinfo: infoStr,
  9632. // Idetinfo: idetinfoStr,
  9633. // PatientId: patient.ID,
  9634. // RecordDate: theTime.Unix(),
  9635. // UserOrgId: adminInfo.CurrentOrgId,
  9636. // AdminUserId: adminInfo.AdminUser.Id,
  9637. // IsReturn: 1,
  9638. // }
  9639. //
  9640. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9641. // //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")
  9642. // //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")
  9643. //
  9644. // //var dat map[string]interface{}
  9645. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9646. // // fmt.Println(dat)
  9647. // //} else {
  9648. // // fmt.Println(err)
  9649. // //}
  9650. //
  9651. // var dat2 map[string]interface{}
  9652. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9653. // fmt.Println(dat2)
  9654. // } else {
  9655. // fmt.Println(err)
  9656. // }
  9657. //
  9658. // } else {
  9659. // adminUser := c.GetAdminUserInfo()
  9660. // errlog := &models.HisOrderError{
  9661. // UserOrgId: adminUser.CurrentOrgId,
  9662. // Ctime: time.Now().Unix(),
  9663. // Mtime: time.Now().Unix(),
  9664. // ErrMsg: res.ErrMsg,
  9665. // Status: 1,
  9666. // PatientId: id,
  9667. // RecordTime: recordDateTime,
  9668. // Stage: 1,
  9669. // }
  9670. // service.CreateErrMsgLog(errlog)
  9671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9672. // return
  9673. // }
  9674. // }
  9675. //
  9676. //}
  9677. //func (c *HisApiController) GetUploadDiag() {
  9678. // id, _ := c.GetInt64("id")
  9679. // record_time := c.GetString("record_time")
  9680. //
  9681. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9682. // sick_type, _ := c.GetInt64("sick_type")
  9683. // reg_type, _ := c.GetInt64("reg_type")
  9684. //
  9685. // timeLayout := "2006-01-02"
  9686. // loc, _ := time.LoadLocation("Local")
  9687. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9688. // if err != nil {
  9689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9690. // return
  9691. // }
  9692. //
  9693. // var patientPrescription models.HisPrescriptionInfo
  9694. // recordDateTime := theTime.Unix()
  9695. // adminInfo := c.GetAdminUserInfo()
  9696. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9697. //
  9698. // if patientPrescription.ID == 0 {
  9699. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9700. // }
  9701. //
  9702. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9703. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9704. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9705. // sickConfig, _ := service.FindSickById(sick_type)
  9706. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9707. //
  9708. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9709. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9710. // "&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 +
  9711. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9712. // resp2, requestErr2 := http.Get(api2)
  9713. // if requestErr2 != nil {
  9714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9715. // return
  9716. // }
  9717. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9718. // if ioErr2 != nil {
  9719. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9721. // return
  9722. // }
  9723. // var respJSON2 map[string]interface{}
  9724. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9725. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9727. // return
  9728. // }
  9729. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9730. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9731. //
  9732. // var res2 ResultSix
  9733. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9734. // utils.ErrorLog("解析失败:%v", err)
  9735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9736. // return
  9737. // }
  9738. // if res2.Infcode != 0 {
  9739. // adminUser := c.GetAdminUserInfo()
  9740. // errlog := &models.HisOrderError{
  9741. // UserOrgId: adminUser.CurrentOrgId,
  9742. // Ctime: time.Now().Unix(),
  9743. // Mtime: time.Now().Unix(),
  9744. // ErrMsg: res2.ErrMsg,
  9745. // Status: 1,
  9746. // PatientId: id,
  9747. // RecordTime: recordDateTime,
  9748. // Stage: 3,
  9749. // }
  9750. // service.CreateErrMsgLog(errlog)
  9751. //
  9752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9753. // return
  9754. // }
  9755. //
  9756. // c.ServeSuccessJSON(map[string]interface{}{
  9757. // "msg": "上传成功",
  9758. // })
  9759. //
  9760. //}
  9761. type QueryResult struct {
  9762. ID int64
  9763. Name string
  9764. Code string
  9765. List_type_code string
  9766. }
  9767. func (c *HisApiController) GetCheckCode() {
  9768. ids_str := c.GetString("ids")
  9769. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9770. ids_arr := strings.Split(ids_str, ",")
  9771. var queryResult []QueryResult
  9772. ids := make([]int64, 0)
  9773. for _, item := range ids_arr {
  9774. id, _ := strconv.ParseInt(item, 10, 64)
  9775. ids = append(ids, id)
  9776. }
  9777. if record_type == 1 {
  9778. drugs, _ := service.GetBatchDrugList(ids)
  9779. for _, item := range drugs {
  9780. result := QueryResult{
  9781. ID: item.ID,
  9782. Name: item.DrugName,
  9783. Code: item.MedicalInsuranceNumber,
  9784. List_type_code: "101",
  9785. }
  9786. queryResult = append(queryResult, result)
  9787. }
  9788. } else if record_type == 2 {
  9789. goods, _ := service.GetBatchGoodInformationList(ids)
  9790. for _, item := range goods {
  9791. result := QueryResult{
  9792. ID: item.ID,
  9793. Name: item.GoodName,
  9794. Code: item.MedicalInsuranceNumber,
  9795. List_type_code: "301",
  9796. }
  9797. queryResult = append(queryResult, result)
  9798. }
  9799. } else if record_type == 3 {
  9800. projects, _ := service.GetBathchMyPorjecgList(ids)
  9801. for _, item := range projects {
  9802. result := QueryResult{
  9803. ID: item.ID,
  9804. Name: item.ProjectName,
  9805. Code: item.MedicalCode,
  9806. List_type_code: "201",
  9807. }
  9808. queryResult = append(queryResult, result)
  9809. }
  9810. }
  9811. admin_user_id, _ := c.GetInt64("admin_user_id")
  9812. adminUser := c.GetAdminUserInfo()
  9813. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9814. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9815. var user_name string
  9816. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9817. if role.ID == 0 {
  9818. user_name = "xxx"
  9819. } else {
  9820. user_name = role.UserName
  9821. }
  9822. baseParams := &models.BaseParams{
  9823. SecretKey: miConfig.SecretKey,
  9824. FixmedinsCode: miConfig.Code,
  9825. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9826. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9827. OrgName: miConfig.OrgName,
  9828. Doctor: user_name,
  9829. }
  9830. if config.IsOpen == 1 {
  9831. for _, item := range queryResult {
  9832. var result string
  9833. if record_type == 1 {
  9834. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9835. } else if record_type == 2 {
  9836. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9837. } else if record_type == 3 {
  9838. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9839. }
  9840. var dat map[string]interface{}
  9841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9842. fmt.Println(dat)
  9843. } else {
  9844. fmt.Println(err)
  9845. }
  9846. userJSONBytes, _ := json.Marshal(dat)
  9847. var res ResultSix
  9848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9849. utils.ErrorLog("解析失败:%v", err)
  9850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9851. return
  9852. }
  9853. if res.Infcode == 0 {
  9854. if record_type == 1 {
  9855. service.UpdateBaseDrugById(item.ID)
  9856. } else if record_type == 2 {
  9857. service.UpdateGoodInformaitonByDetail(item.ID)
  9858. } else if record_type == 3 {
  9859. service.UpdateProjectById(item.ID)
  9860. }
  9861. c.ServeSuccessJSON(map[string]interface{}{
  9862. "failed_code": 0,
  9863. "msg": "目录对照成功",
  9864. })
  9865. } else {
  9866. c.ServeSuccessJSON(map[string]interface{}{
  9867. "failed_code": -10,
  9868. "msg": res.ErrMsg,
  9869. })
  9870. }
  9871. }
  9872. }
  9873. }
  9874. func (c *HisApiController) UnCheckCode() {
  9875. ids_str := c.GetString("ids")
  9876. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9877. admin_user_id, _ := c.GetInt64("admin_user_id")
  9878. ids_arr := strings.Split(ids_str, ",")
  9879. var queryResult []QueryResult
  9880. ids := make([]int64, 0)
  9881. for _, item := range ids_arr {
  9882. id, _ := strconv.ParseInt(item, 10, 64)
  9883. ids = append(ids, id)
  9884. }
  9885. if record_type == 1 {
  9886. drugs, _ := service.GetBatchDrugList(ids)
  9887. for _, item := range drugs {
  9888. result := QueryResult{
  9889. ID: item.ID,
  9890. Name: item.DrugName,
  9891. Code: item.MedicalInsuranceNumber,
  9892. List_type_code: "101",
  9893. }
  9894. queryResult = append(queryResult, result)
  9895. }
  9896. } else if record_type == 2 {
  9897. goods, _ := service.GetBatchGoodInformationList(ids)
  9898. for _, item := range goods {
  9899. result := QueryResult{
  9900. ID: item.ID,
  9901. Name: item.GoodName,
  9902. Code: item.MedicalInsuranceNumber,
  9903. List_type_code: "301",
  9904. }
  9905. queryResult = append(queryResult, result)
  9906. }
  9907. } else if record_type == 3 {
  9908. projects, _ := service.GetBathchMyPorjecgList(ids)
  9909. for _, item := range projects {
  9910. result := QueryResult{
  9911. ID: item.ID,
  9912. Name: item.ProjectName,
  9913. Code: item.MedicalCode,
  9914. List_type_code: "201",
  9915. }
  9916. queryResult = append(queryResult, result)
  9917. }
  9918. }
  9919. adminUser := c.GetAdminUserInfo()
  9920. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9921. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9922. var user_name string
  9923. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9924. if role.ID == 0 {
  9925. user_name = "xxx"
  9926. } else {
  9927. user_name = role.UserName
  9928. }
  9929. baseParams := &models.BaseParams{
  9930. SecretKey: miConfig.SecretKey,
  9931. FixmedinsCode: miConfig.Code,
  9932. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9933. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9934. OrgName: miConfig.OrgName,
  9935. Doctor: user_name,
  9936. }
  9937. if config.IsOpen == 1 {
  9938. for _, item := range queryResult {
  9939. var result string
  9940. if record_type == 1 {
  9941. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9942. } else if record_type == 2 {
  9943. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9944. } else if record_type == 3 {
  9945. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9946. }
  9947. var dat2 map[string]interface{}
  9948. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9949. fmt.Println(dat2)
  9950. } else {
  9951. fmt.Println(err)
  9952. }
  9953. userJSONBytes, _ := json.Marshal(dat2)
  9954. var res ResultSix
  9955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9956. utils.ErrorLog("解析失败:%v", err)
  9957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9958. return
  9959. }
  9960. if res.Infcode == 0 {
  9961. if record_type == 1 {
  9962. service.UpdateDrugByIdDetail(item.ID)
  9963. } else if record_type == 2 {
  9964. service.UpdateGoodInfoById(item.ID)
  9965. } else if record_type == 3 {
  9966. service.UpdateMyProjectById(item.ID)
  9967. }
  9968. c.ServeSuccessJSON(map[string]interface{}{
  9969. "failed_code": 0,
  9970. "msg": "撤销目录对照成功",
  9971. })
  9972. } else {
  9973. c.ServeSuccessJSON(map[string]interface{}{
  9974. "failed_code": -10,
  9975. "msg": res.ErrMsg,
  9976. })
  9977. }
  9978. }
  9979. }
  9980. }
  9981. func (c *HisApiController) GetPatientInfo() {
  9982. id_card_no := c.GetString("id_card_no")
  9983. admin_user_id, _ := c.GetInt64("admin_user_id")
  9984. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9985. if patient.ID == 0 {
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9987. return
  9988. }
  9989. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9991. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9992. if config.IsOpen == 1 {
  9993. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9994. var dat map[string]interface{}
  9995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9996. fmt.Println(dat)
  9997. } else {
  9998. fmt.Println(err)
  9999. }
  10000. userJSONBytes, _ := json.Marshal(dat)
  10001. var res ResultTwo
  10002. var res10265 ResultTwo10265
  10003. if miConfig.Code == "H15049901371" {
  10004. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10005. utils.ErrorLog("解析失败:%v", err)
  10006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. return
  10008. }
  10009. res.ErrMsg = res10265.ErrMsg
  10010. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10011. res.Infcode = infocode
  10012. res.Output = res10265.Output
  10013. res.InfRefmsgid = res10265.InfRefmsgid
  10014. } else {
  10015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10016. utils.ErrorLog("解析失败:%v", err)
  10017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10018. return
  10019. }
  10020. }
  10021. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10022. // utils.ErrorLog("解析失败:%v", err)
  10023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10024. // return
  10025. //}
  10026. if res.Infcode != 0 {
  10027. c.ServeSuccessJSON(map[string]interface{}{
  10028. "failed_code": -10,
  10029. "msg": res.ErrMsg,
  10030. })
  10031. } else {
  10032. c.ServeSuccessJSON(map[string]interface{}{
  10033. "failed_code": 0,
  10034. "info": res,
  10035. })
  10036. }
  10037. }
  10038. }
  10039. func (c *HisApiController) PsnPutOnRecord() {
  10040. record_type, _ := c.GetInt64("type")
  10041. patient_id, _ := c.GetInt64("patient_id")
  10042. admin_user_id, _ := c.GetInt64("admin_user_id")
  10043. start_time := c.GetString("start_time")
  10044. end_time := c.GetString("end_time")
  10045. adminUser := c.GetAdminUserInfo()
  10046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10047. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10048. var patients []*models.Patients
  10049. if record_type == 1 { //全部备案
  10050. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10051. patients = append(patients, patient...)
  10052. } else { //单个备案
  10053. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10054. patients = append(patients, patient)
  10055. }
  10056. var user_name string
  10057. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10058. if role.ID == 0 {
  10059. user_name = "xxx"
  10060. } else {
  10061. user_name = role.UserName
  10062. }
  10063. if config.IsOpen == 1 {
  10064. for _, item := range patients {
  10065. 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
  10066. resp, requestErr := http.Get(api)
  10067. if requestErr != nil {
  10068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10069. return
  10070. }
  10071. defer resp.Body.Close()
  10072. body, ioErr := ioutil.ReadAll(resp.Body)
  10073. if ioErr != nil {
  10074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10076. return
  10077. }
  10078. var respJSON map[string]interface{}
  10079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10082. return
  10083. }
  10084. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10085. userJSONBytes, _ := json.Marshal(userJSON)
  10086. var res ResultTwo
  10087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10088. utils.ErrorLog("解析失败:%v", err)
  10089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10090. return
  10091. }
  10092. if res.Infcode == 0 {
  10093. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10094. var dat map[string]interface{}
  10095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10096. fmt.Println(dat)
  10097. } else {
  10098. fmt.Println(err)
  10099. }
  10100. userJSONBytes, _ := json.Marshal(dat)
  10101. var res2 ResultThirteen
  10102. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10103. utils.ErrorLog("解析失败:%v", err)
  10104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10105. return
  10106. }
  10107. if res2.Infcode == 0 {
  10108. psnResult := &models.GdybPsnRecord{
  10109. UserOrgId: adminUser.CurrentOrgId,
  10110. PatientId: item.ID,
  10111. PsnNo: res.Output.Baseinfo.PsnNo,
  10112. Ctime: time.Now().Unix(),
  10113. Mtime: time.Now().Unix(),
  10114. Status: 1,
  10115. IsCancel: 1,
  10116. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10117. }
  10118. service.CreatePsnRecord(psnResult)
  10119. } else {
  10120. c.ServeSuccessJSON(map[string]interface{}{
  10121. "failed_code": -10,
  10122. "msg": res2.ErrMsg,
  10123. })
  10124. return
  10125. }
  10126. }
  10127. }
  10128. }
  10129. }
  10130. func (c *HisApiController) PsnUnPutOnRecord() {
  10131. id, _ := c.GetInt64("id")
  10132. //record_type, _ := c.GetInt64("type")
  10133. admin_user_id, _ := c.GetInt64("admin_user_id")
  10134. adminUser := c.GetAdminUserInfo()
  10135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10136. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10137. var user_name string
  10138. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10139. if role.ID == 0 {
  10140. user_name = "xxx"
  10141. } else {
  10142. user_name = role.UserName
  10143. }
  10144. psn_record, _ := service.GetPsnRecordById(id)
  10145. if psn_record.ID == 0 {
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10147. return
  10148. }
  10149. if config.IsOpen == 1 {
  10150. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  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 ResultFourteen
  10159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. if res.Infcode == 0 {
  10165. psn_record.IsCancel = 2
  10166. service.CreatePsnRecord(&psn_record)
  10167. } else {
  10168. c.ServeSuccessJSON(map[string]interface{}{
  10169. "failed_code": -10,
  10170. "msg": res.ErrMsg,
  10171. })
  10172. return
  10173. }
  10174. }
  10175. }
  10176. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10177. patient_id, _ := c.GetInt64("patient_id")
  10178. insutype_two := c.GetString("insutype")
  10179. psn_no := c.GetString("psn_no")
  10180. doctor_id, _ := c.GetInt64("doctor_id")
  10181. sick_id, _ := c.GetInt64("sick_id")
  10182. department_id, _ := c.GetInt64("department_id")
  10183. start_time := c.GetString("start_time")
  10184. end_time := c.GetString("end_time")
  10185. check_time := c.GetString("check_time")
  10186. adminUser := c.GetAdminUserInfo()
  10187. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10188. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10189. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10190. sick, _ := service.FindSickById(sick_id)
  10191. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10192. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10193. var res ResultTwo
  10194. var res10265 ResultTwo10265
  10195. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10196. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10197. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10198. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10199. "&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
  10200. resp, requestErr := http.Get(api)
  10201. if requestErr != nil {
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10203. return
  10204. }
  10205. body, ioErr := ioutil.ReadAll(resp.Body)
  10206. if ioErr != nil {
  10207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10209. return
  10210. }
  10211. var respJSON map[string]interface{}
  10212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10215. return
  10216. }
  10217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10218. result, _ := json.Marshal(respJSON)
  10219. fmt.Println("log")
  10220. fmt.Println(string(result))
  10221. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10222. utils.ErrorLog("解析失败:%v", err)
  10223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10224. return
  10225. }
  10226. res.ErrMsg = res10265.ErrMsg
  10227. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10228. res.Infcode = infocode
  10229. res.Output = res10265.Output
  10230. res.InfRefmsgid = res10265.InfRefmsgid
  10231. } else {
  10232. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10233. if miConfig.Code == "H15049901371" {
  10234. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10235. utils.ErrorLog("解析失败:%v", err)
  10236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10237. return
  10238. }
  10239. res.ErrMsg = res10265.ErrMsg
  10240. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10241. res.Infcode = infocode
  10242. res.Output = res10265.Output
  10243. res.InfRefmsgid = res10265.InfRefmsgid
  10244. } else {
  10245. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10246. utils.ErrorLog("解析失败:%v", err)
  10247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10248. return
  10249. }
  10250. }
  10251. }
  10252. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10253. infoStr := string(Iinfos)
  10254. var rf []*ResultFive
  10255. json.Unmarshal([]byte(infoStr), &rf)
  10256. var insuplc_admdvs string
  10257. var insutype string
  10258. var is390 int = 0
  10259. var is310 int = 0
  10260. var insutypes []*ResultFive
  10261. for _, item := range rf {
  10262. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10263. insutypes = append(insutypes, item)
  10264. }
  10265. }
  10266. if len(insutypes) == 1 {
  10267. insutype = insutypes[0].Insutype
  10268. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10269. } else {
  10270. for _, i := range insutypes {
  10271. if i.Insutype == "390" {
  10272. is390 = 1
  10273. }
  10274. if i.Insutype == "310" {
  10275. is310 = 1
  10276. }
  10277. }
  10278. }
  10279. if is390 == 1 {
  10280. insutype = "390"
  10281. }
  10282. if is310 == 1 {
  10283. insutype = "310"
  10284. }
  10285. if len(insutypes) == 2 {
  10286. insutype = insutype_two
  10287. }
  10288. if len(insutypes) == 0 {
  10289. insutype = "310"
  10290. }
  10291. insutype = insutype_two
  10292. fmt.Println(insutype)
  10293. for _, item := range rf {
  10294. fmt.Println(item.Insutype)
  10295. fmt.Println(insutype)
  10296. if item.Insutype == insutype {
  10297. fmt.Println(item.Insutype)
  10298. fmt.Println(insutype)
  10299. insuplc_admdvs = item.InsuplcAdmdvs
  10300. }
  10301. }
  10302. fmt.Println(insuplc_admdvs)
  10303. var res2 ResultThirteen
  10304. var res10265_2 ResultThirteen10265
  10305. if config.IsOpen == 1 {
  10306. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10307. } else {
  10308. 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)
  10309. var dat map[string]interface{}
  10310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10311. fmt.Println(dat)
  10312. } else {
  10313. fmt.Println(err)
  10314. }
  10315. userJSONBytes, _ := json.Marshal(dat)
  10316. if miConfig.Code == "H15049901371" {
  10317. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10318. utils.ErrorLog("解析失败:%v", err)
  10319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10320. return
  10321. }
  10322. res2.ErrMsg = res10265_2.ErrMsg
  10323. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10324. res2.Infcode = infocode
  10325. res2.Output = res10265_2.Output
  10326. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10327. } else {
  10328. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10329. utils.ErrorLog("解析失败:%v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. }
  10334. }
  10335. if res2.Infcode == 0 {
  10336. psnResult := &models.GdybPsnNcdsRecord{
  10337. UserOrgId: adminUser.CurrentOrgId,
  10338. PatientId: patient.ID,
  10339. PsnNo: psn_no,
  10340. DoctorId: doctor.AdminUserId,
  10341. DepartmentId: department_id,
  10342. SickType: sick_id,
  10343. Insutype: insutype,
  10344. Ctime: time.Now().Unix(),
  10345. Mtime: time.Now().Unix(),
  10346. Status: 1,
  10347. IsCancel: 1,
  10348. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10349. }
  10350. service.CreatePsnNCDSRecord(psnResult)
  10351. c.ServeSuccessJSON(map[string]interface{}{
  10352. "failed_code": 0,
  10353. "msg": "备案成功",
  10354. "result": psnResult,
  10355. })
  10356. } else {
  10357. c.ServeSuccessJSON(map[string]interface{}{
  10358. "failed_code": -10,
  10359. "msg": res2.ErrMsg,
  10360. })
  10361. return
  10362. }
  10363. }
  10364. }
  10365. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10366. id, _ := c.GetInt64("id")
  10367. admin_user_id, _ := c.GetInt64("admin_user_id")
  10368. adminUser := c.GetAdminUserInfo()
  10369. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10370. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10371. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10372. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10373. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10374. //var user_name string
  10375. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10376. //if role.ID == 0 {
  10377. // user_name = "xxx"
  10378. //} else {
  10379. // user_name = role.UserName
  10380. //}
  10381. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10382. if psn_record.ID == 0 {
  10383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10384. return
  10385. }
  10386. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10387. var res ResultTwo
  10388. var res10265 ResultTwo10265
  10389. if miConfig.Code == "H15049901371" {
  10390. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10391. utils.ErrorLog("解析失败:%v", err)
  10392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10393. return
  10394. }
  10395. res.ErrMsg = res10265.ErrMsg
  10396. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10397. res.Infcode = infocode
  10398. res.Output = res10265.Output
  10399. res.InfRefmsgid = res10265.InfRefmsgid
  10400. } else {
  10401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10402. utils.ErrorLog("解析失败:%v", err)
  10403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10404. return
  10405. }
  10406. }
  10407. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10408. infoStr := string(Iinfos)
  10409. var rf []*ResultFive
  10410. json.Unmarshal([]byte(infoStr), &rf)
  10411. var insuplc_admdvs string
  10412. var insutype string
  10413. var is390 int = 0
  10414. var is310 int = 0
  10415. var insutypes []*ResultFive
  10416. for _, item := range rf {
  10417. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10418. insutypes = append(insutypes, item)
  10419. }
  10420. }
  10421. if len(insutypes) == 1 {
  10422. insutype = insutypes[0].Insutype
  10423. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10424. } else {
  10425. for _, i := range insutypes {
  10426. if i.Insutype == "390" {
  10427. is390 = 1
  10428. }
  10429. if i.Insutype == "310" {
  10430. is310 = 1
  10431. }
  10432. }
  10433. }
  10434. if is390 == 1 {
  10435. insutype = "390"
  10436. }
  10437. if is310 == 1 {
  10438. insutype = "310"
  10439. }
  10440. if len(insutypes) == 0 {
  10441. insutype = "310"
  10442. }
  10443. insutype = psn_record.Insutype
  10444. for _, item := range rf {
  10445. if item.Insutype == insutype {
  10446. insuplc_admdvs = item.InsuplcAdmdvs
  10447. }
  10448. }
  10449. if config.IsOpen == 1 {
  10450. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10451. var dat map[string]interface{}
  10452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10453. fmt.Println(dat)
  10454. } else {
  10455. fmt.Println(err)
  10456. }
  10457. userJSONBytes, _ := json.Marshal(dat)
  10458. var res ResultFourteen
  10459. var res10265 ResultFourteen10265
  10460. if miConfig.Code == "H15049901371" {
  10461. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10462. utils.ErrorLog("解析失败:%v", err)
  10463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10464. return
  10465. }
  10466. res.ErrMsg = res10265.ErrMsg
  10467. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10468. res.Infcode = infocode
  10469. res.Output = res10265.Output
  10470. res.InfRefmsgid = res10265.InfRefmsgid
  10471. } else {
  10472. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10473. utils.ErrorLog("解析失败:%v", err)
  10474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10475. return
  10476. }
  10477. }
  10478. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10479. // utils.ErrorLog("解析失败:%v", err)
  10480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10481. // return
  10482. //}
  10483. if res.Infcode == 0 {
  10484. psn_record.IsCancel = 2
  10485. service.CreatePsnNCDSRecord(&psn_record)
  10486. c.ServeSuccessJSON(map[string]interface{}{
  10487. "failed_code": 0,
  10488. "msg": "撤销备案成功",
  10489. })
  10490. } else {
  10491. c.ServeSuccessJSON(map[string]interface{}{
  10492. "failed_code": -10,
  10493. "msg": res.ErrMsg,
  10494. })
  10495. return
  10496. }
  10497. }
  10498. }
  10499. func (c *HisApiController) TestTest() {
  10500. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10501. fmt.Println(patient.Iinfo)
  10502. }
  10503. type CustomData struct {
  10504. MsgId string
  10505. PsnNo string
  10506. Info string
  10507. }
  10508. func (c *HisApiController) ReversalData() {
  10509. var customData []*CustomData
  10510. custom := &CustomData{
  10511. MsgId: "H44022900158202103301714472004",
  10512. PsnNo: "44020000001101329945",
  10513. Info: "2207",
  10514. }
  10515. customData = append(customData, custom)
  10516. custom1 := &CustomData{
  10517. MsgId: "H4402290015820210330172057803",
  10518. PsnNo: "44020000001101161813",
  10519. Info: "2207",
  10520. }
  10521. customData = append(customData, custom1)
  10522. custom2 := &CustomData{
  10523. MsgId: "H44022900158202103301705198813",
  10524. PsnNo: "44190000133097375417",
  10525. Info: "2207",
  10526. }
  10527. customData = append(customData, custom2)
  10528. custom3 := &CustomData{
  10529. MsgId: "H44022900158202103301715524756",
  10530. PsnNo: "44020000001100187221",
  10531. Info: "2207",
  10532. }
  10533. customData = append(customData, custom3)
  10534. custom4 := &CustomData{
  10535. MsgId: "H44022900158202103301730376224",
  10536. PsnNo: "44020000001101959155",
  10537. Info: "2207",
  10538. }
  10539. customData = append(customData, custom4)
  10540. custom5 := &CustomData{
  10541. MsgId: "H44022900158202103301748008725",
  10542. PsnNo: "44020000001104246641",
  10543. Info: "2207",
  10544. }
  10545. customData = append(customData, custom5)
  10546. custom6 := &CustomData{
  10547. MsgId: "H44022900158202103301718096755",
  10548. PsnNo: "44020000001102211860",
  10549. Info: "2207",
  10550. }
  10551. customData = append(customData, custom6)
  10552. custom7 := &CustomData{
  10553. MsgId: "H44022900158202103301736551640",
  10554. PsnNo: "44020000001102687718",
  10555. Info: "2207",
  10556. }
  10557. customData = append(customData, custom7)
  10558. custom8 := &CustomData{
  10559. MsgId: "H44022900158202103301743097676",
  10560. PsnNo: "44020000001102127785",
  10561. Info: "2207",
  10562. }
  10563. customData = append(customData, custom8)
  10564. custom9 := &CustomData{
  10565. MsgId: "H44022900158202103301712304203",
  10566. PsnNo: "44020000001101518097",
  10567. Info: "2207",
  10568. }
  10569. customData = append(customData, custom9)
  10570. custom10 := &CustomData{
  10571. MsgId: "H44022900158202103301738448785",
  10572. PsnNo: "44020000001100500813",
  10573. Info: "2207",
  10574. }
  10575. customData = append(customData, custom10)
  10576. custom11 := &CustomData{
  10577. MsgId: "H44022900158202103301732455843",
  10578. PsnNo: "44020000001102690557",
  10579. Info: "2207",
  10580. }
  10581. customData = append(customData, custom11)
  10582. custom12 := &CustomData{
  10583. MsgId: "H44022900158202103301745421708",
  10584. PsnNo: "44020000001102211928",
  10585. Info: "2207",
  10586. }
  10587. customData = append(customData, custom12)
  10588. custom1212 := &CustomData{
  10589. MsgId: "H440229001582021033017351627",
  10590. PsnNo: "44020000001102481733",
  10591. Info: "2207",
  10592. }
  10593. customData = append(customData, custom1212)
  10594. custom13 := &CustomData{
  10595. MsgId: "H44022900158202103301740327951",
  10596. PsnNo: "44020000001103174866",
  10597. Info: "2207",
  10598. }
  10599. customData = append(customData, custom13)
  10600. custom14 := &CustomData{
  10601. MsgId: "H4402290015820210330174922668",
  10602. PsnNo: "44020000001102927272",
  10603. Info: "2207",
  10604. }
  10605. customData = append(customData, custom14)
  10606. custom15 := &CustomData{
  10607. MsgId: "H44022900158202103301752362273",
  10608. PsnNo: "44020000001102942890",
  10609. Info: "2207",
  10610. }
  10611. customData = append(customData, custom15)
  10612. custom16 := &CustomData{
  10613. MsgId: "H44022900158202103301751082917",
  10614. PsnNo: "44020000001101662162",
  10615. Info: "2207",
  10616. }
  10617. customData = append(customData, custom16)
  10618. custom17 := &CustomData{
  10619. MsgId: "H44022900158202103301754147728",
  10620. PsnNo: "44020000000229014511",
  10621. Info: "2207",
  10622. }
  10623. customData = append(customData, custom17)
  10624. adminUser := c.GetAdminUserInfo()
  10625. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10626. for _, item := range customData {
  10627. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10628. fmt.Println(result)
  10629. }
  10630. }
  10631. //func (c *HisApiController) GetAllopatry() {
  10632. // year := c.GetString("year")
  10633. // month := c.GetString("month")
  10634. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10635. // adminUser := c.GetAdminUserInfo()
  10636. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10637. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10638. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10639. //
  10640. // var dat map[string]interface{}
  10641. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10642. // fmt.Println(dat)
  10643. // } else {
  10644. // fmt.Println(err)
  10645. // }
  10646. // userJSONBytes, _ := json.Marshal(dat)
  10647. // var res models.Result9001
  10648. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10649. // utils.ErrorLog("解析失败:%v", err)
  10650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10651. // return
  10652. // }
  10653. //
  10654. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10655. // var dat2 map[string]interface{}
  10656. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10657. // fmt.Println(dat)
  10658. // } else {
  10659. // fmt.Println(err)
  10660. // }
  10661. // userJSONBytes2, _ := json.Marshal(dat2)
  10662. // var res2 models.Result3260
  10663. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10664. // utils.ErrorLog("解析失败:%v", err)
  10665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10666. // return
  10667. // }
  10668. // if res2.Infcode == 0 {
  10669. // c.ServeSuccessJSON(map[string]interface{}{
  10670. // "list": res2.Output.Data,
  10671. // })
  10672. // return
  10673. // } else {
  10674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10675. // return
  10676. // }
  10677. //
  10678. //}
  10679. //func (c *HisApiController) ComfirmAllopatry() {
  10680. // year := c.GetString("year")
  10681. // month := c.GetString("month")
  10682. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10683. // adminUser := c.GetAdminUserInfo()
  10684. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10685. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10686. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10687. // var dat map[string]interface{}
  10688. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10689. // fmt.Println(dat)
  10690. // } else {
  10691. // fmt.Println(err)
  10692. // }
  10693. // userJSONBytes, _ := json.Marshal(dat)
  10694. // var res models.Result9001
  10695. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10696. // utils.ErrorLog("解析失败:%v", err)
  10697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10698. // return
  10699. // }
  10700. //
  10701. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10702. // var dat2 map[string]interface{}
  10703. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10704. // fmt.Println(dat)
  10705. // } else {
  10706. // fmt.Println(err)
  10707. // }
  10708. // userJSONBytes2, _ := json.Marshal(dat2)
  10709. // var res2 models.Result3260
  10710. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10711. // utils.ErrorLog("解析失败:%v", err)
  10712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10713. // return
  10714. // }
  10715. //
  10716. // if res2.Infcode == 0 {
  10717. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10718. // var dat map[string]interface{}
  10719. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10720. // fmt.Println(dat)
  10721. // } else {
  10722. // fmt.Println(err)
  10723. // }
  10724. // userJSONBytes, _ := json.Marshal(dat)
  10725. // var res3 models.Result3261
  10726. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10727. // utils.ErrorLog("解析失败:%v", err)
  10728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10729. // return
  10730. // }
  10731. //
  10732. // if res3.Infcode == 0 {
  10733. // record := &models.HisYidiClearRecord{
  10734. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10735. // Ctime: time.Now().Unix(),
  10736. // Mtime: time.Now().Unix(),
  10737. // Status: 1,
  10738. // MsgId: msgId,
  10739. // }
  10740. // service.SaveClearRecord(record)
  10741. // c.ServeSuccessJSON(map[string]interface{}{
  10742. // "msg": "提取成功",
  10743. // })
  10744. // }
  10745. // }
  10746. //}
  10747. func (c *HisApiController) RefundAllopatry() {
  10748. year := c.GetString("year")
  10749. month := c.GetString("month")
  10750. id, _ := c.GetInt64("id")
  10751. admin_user_id, _ := c.GetInt64("admin_user_id")
  10752. adminUser := c.GetAdminUserInfo()
  10753. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10754. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10755. record, _ := service.GetClearRecordById(id)
  10756. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10757. var dat map[string]interface{}
  10758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10759. fmt.Println(dat)
  10760. } else {
  10761. fmt.Println(err)
  10762. }
  10763. userJSONBytes, _ := json.Marshal(dat)
  10764. var empty ResultFourteen
  10765. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10766. utils.ErrorLog("解析失败:%v", err)
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. return
  10769. }
  10770. if empty.Infcode == 0 {
  10771. c.ServeSuccessJSON(map[string]interface{}{
  10772. "msg": "撤销成功",
  10773. })
  10774. return
  10775. }
  10776. }
  10777. func (c *HisApiController) ReversalOtherData() {
  10778. var customData []*CustomData
  10779. custom := &CustomData{
  10780. MsgId: "H44022900158202103301714472004",
  10781. PsnNo: "44020000001101329945",
  10782. Info: "2208",
  10783. }
  10784. customData = append(customData, custom)
  10785. custom1 := &CustomData{
  10786. MsgId: "H4402290015820210330172057803",
  10787. PsnNo: "44020000001101161813",
  10788. Info: "2208",
  10789. }
  10790. customData = append(customData, custom1)
  10791. custom2 := &CustomData{
  10792. MsgId: "H44022900158202103301705198813",
  10793. PsnNo: "44190000133097375417",
  10794. Info: "2208",
  10795. }
  10796. customData = append(customData, custom2)
  10797. custom3 := &CustomData{
  10798. MsgId: "H44022900158202103301715524756",
  10799. PsnNo: "44020000001100187221",
  10800. Info: "2208",
  10801. }
  10802. customData = append(customData, custom3)
  10803. custom4 := &CustomData{
  10804. MsgId: "H44022900158202103301730376224",
  10805. PsnNo: "44020000001101959155",
  10806. Info: "2208",
  10807. }
  10808. customData = append(customData, custom4)
  10809. custom5 := &CustomData{
  10810. MsgId: "H44022900158202103301748008725",
  10811. PsnNo: "44020000001104246641",
  10812. Info: "2208",
  10813. }
  10814. customData = append(customData, custom5)
  10815. custom6 := &CustomData{
  10816. MsgId: "H44022900158202103301718096755",
  10817. PsnNo: "44020000001102211860",
  10818. Info: "2208",
  10819. }
  10820. customData = append(customData, custom6)
  10821. custom7 := &CustomData{
  10822. MsgId: "H44022900158202103301736551640",
  10823. PsnNo: "44020000001102687718",
  10824. Info: "2208",
  10825. }
  10826. customData = append(customData, custom7)
  10827. custom8 := &CustomData{
  10828. MsgId: "H44022900158202103301743097676",
  10829. PsnNo: "44020000001102127785",
  10830. Info: "2208",
  10831. }
  10832. customData = append(customData, custom8)
  10833. custom9 := &CustomData{
  10834. MsgId: "H44022900158202103301712304203",
  10835. PsnNo: "44020000001101518097",
  10836. Info: "2208",
  10837. }
  10838. customData = append(customData, custom9)
  10839. custom10 := &CustomData{
  10840. MsgId: "H44022900158202103301738448785",
  10841. PsnNo: "44020000001100500813",
  10842. Info: "2208",
  10843. }
  10844. customData = append(customData, custom10)
  10845. custom11 := &CustomData{
  10846. MsgId: "H44022900158202103301732455843",
  10847. PsnNo: "44020000001102690557",
  10848. Info: "2208",
  10849. }
  10850. customData = append(customData, custom11)
  10851. custom12 := &CustomData{
  10852. MsgId: "H44022900158202103301745421708",
  10853. PsnNo: "44020000001102211928",
  10854. Info: "2208",
  10855. }
  10856. customData = append(customData, custom12)
  10857. custom1212 := &CustomData{
  10858. MsgId: "H440229001582021033017351627",
  10859. PsnNo: "44020000001102481733",
  10860. Info: "2208",
  10861. }
  10862. customData = append(customData, custom1212)
  10863. custom13 := &CustomData{
  10864. MsgId: "H44022900158202103301740327951",
  10865. PsnNo: "44020000001103174866",
  10866. Info: "2208",
  10867. }
  10868. customData = append(customData, custom13)
  10869. custom14 := &CustomData{
  10870. MsgId: "H4402290015820210330174922668",
  10871. PsnNo: "44020000001102927272",
  10872. Info: "2208",
  10873. }
  10874. customData = append(customData, custom14)
  10875. custom15 := &CustomData{
  10876. MsgId: "H44022900158202103301752362273",
  10877. PsnNo: "44020000001102942890",
  10878. Info: "2208",
  10879. }
  10880. customData = append(customData, custom15)
  10881. custom16 := &CustomData{
  10882. MsgId: "H44022900158202103301751082917",
  10883. PsnNo: "44020000001101662162",
  10884. Info: "2208",
  10885. }
  10886. customData = append(customData, custom16)
  10887. custom17 := &CustomData{
  10888. MsgId: "H44022900158202103301754147728",
  10889. PsnNo: "44020000000229014511",
  10890. Info: "2208",
  10891. }
  10892. customData = append(customData, custom17)
  10893. adminUser := c.GetAdminUserInfo()
  10894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10895. for _, item := range customData {
  10896. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10897. fmt.Println(result)
  10898. }
  10899. }
  10900. func PathExists(path string) (bool, error) {
  10901. _, err := os.Stat(path)
  10902. if err == nil {
  10903. return true, nil
  10904. }
  10905. if os.IsNotExist(err) {
  10906. return false, nil
  10907. }
  10908. return false, err
  10909. }
  10910. //创建文件夹
  10911. func Mkdir(dir string) {
  10912. // 创建文件夹
  10913. exist, err := PathExists(dir)
  10914. if err != nil {
  10915. fmt.Println(err.Error())
  10916. } else {
  10917. if exist {
  10918. fmt.Println(dir + "文件夹已存在!")
  10919. } else {
  10920. // 文件夹名称,权限
  10921. err := os.Mkdir(dir, os.ModePerm)
  10922. if err != nil {
  10923. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10924. } else {
  10925. fmt.Println(dir + "文件夹创建成功!")
  10926. }
  10927. }
  10928. }
  10929. }
  10930. //压缩文件
  10931. func Zip(srcFile string, destZip string) error {
  10932. zipfile, err := os.Create(destZip)
  10933. if err != nil {
  10934. return err
  10935. }
  10936. defer zipfile.Close()
  10937. archive := zip.NewWriter(zipfile)
  10938. defer archive.Close()
  10939. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10940. if err != nil {
  10941. return err
  10942. }
  10943. header, err := zip.FileInfoHeader(info)
  10944. if err != nil {
  10945. return err
  10946. }
  10947. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10948. // header.Name = path
  10949. if info.IsDir() {
  10950. header.Name += "/"
  10951. } else {
  10952. header.Method = zip.Deflate
  10953. }
  10954. writer, err := archive.CreateHeader(header)
  10955. if err != nil {
  10956. return err
  10957. }
  10958. if !info.IsDir() {
  10959. file, err := os.Open(path)
  10960. if err != nil {
  10961. return err
  10962. }
  10963. defer file.Close()
  10964. _, err = io.Copy(writer, file)
  10965. }
  10966. return err
  10967. })
  10968. return err
  10969. }
  10970. func ReadFile(filePath string) []byte {
  10971. f, err := os.Open(filePath)
  10972. if err != nil {
  10973. fmt.Println("read file fail", err)
  10974. return nil
  10975. }
  10976. defer f.Close()
  10977. fd, err := ioutil.ReadAll(f)
  10978. if err != nil {
  10979. fmt.Println("read to fd fail", err)
  10980. return nil
  10981. }
  10982. return fd
  10983. }
  10984. func saveLog(result string, request string, infno string, desc string) {
  10985. org_id, _ := beego.AppConfig.Int64("org_id")
  10986. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10987. dir := miConfig.OrgName + "日志"
  10988. utils.Mkdir(dir)
  10989. month := time.Unix(1557042972, 0).Format("1")
  10990. year := time.Now().Format("2006")
  10991. month = time.Now().Format("01")
  10992. day := time.Now().Format("02")
  10993. hour := time.Now().Format("15")
  10994. min := time.Now().Format("04")
  10995. sec := time.Now().Format("05")
  10996. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10997. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10998. file_name := file + ".txt"
  10999. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11000. exist, _ := utils.PathExists(file_path)
  11001. if exist { //存在
  11002. fmt.Println("存在")
  11003. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11004. if err != nil {
  11005. fmt.Println("read fail")
  11006. }
  11007. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11008. n, _ := f.Seek(0, 2)
  11009. _, err = f.WriteAt([]byte(content), n)
  11010. } else { //不存在
  11011. fmt.Println("文件不存在,创建文件")
  11012. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11013. defer f.Close()
  11014. if err != nil {
  11015. } else {
  11016. _, err = f.Write([]byte("记录日志"))
  11017. }
  11018. }
  11019. }
  11020. type Charset string
  11021. const (
  11022. UTF8 = Charset("UTF-8")
  11023. GB18030 = Charset("GB18030")
  11024. )
  11025. func ConvertToString(src string, srcCode string, tagCode string) string {
  11026. srcCoder := mahonia.NewDecoder(srcCode)
  11027. srcResult := srcCoder.ConvertString(src)
  11028. tagCoder := mahonia.NewDecoder(tagCode)
  11029. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11030. result := string(cdata)
  11031. return result
  11032. }
  11033. func (c *HisApiController) ReadEleCard() {
  11034. id_card_type, _ := c.GetInt64("id_card_type")
  11035. admin_user_id, _ := c.GetInt64("admin_user_id")
  11036. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11037. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11039. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11040. var api string
  11041. if miConfig.MdtrtareaAdmvs == "320921" {
  11042. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11043. "&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
  11044. fmt.Println(api)
  11045. } else {
  11046. 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 +
  11047. "&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)
  11048. }
  11049. resp, requestErr := http.Get(api)
  11050. if requestErr != nil {
  11051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11052. return
  11053. }
  11054. body, ioErr := ioutil.ReadAll(resp.Body)
  11055. if ioErr != nil {
  11056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11058. return
  11059. }
  11060. var respJSON map[string]interface{}
  11061. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11064. return
  11065. }
  11066. var status string
  11067. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11068. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11069. var token string
  11070. var res ResultTwo //1101结果
  11071. var res10265 ResultTwo10265 //1101结果
  11072. if status == "0" { //读卡成功
  11073. var card_info string //卡信息
  11074. var busi_card_info string
  11075. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11076. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11077. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11078. fmt.Println(card_info)
  11079. fmt.Println(busi_card_info)
  11080. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11081. result, _ := json.Marshal(respJSON)
  11082. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11083. utils.ErrorLog("解析失败:%v", err)
  11084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11085. return
  11086. }
  11087. res.ErrMsg = res10265.ErrMsg
  11088. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11089. res.Infcode = infocode
  11090. res.Output = res10265.Output
  11091. res.InfRefmsgid = res10265.InfRefmsgid
  11092. if res.Infcode == 0 {
  11093. c.ServeSuccessJSON(map[string]interface{}{
  11094. "number": token,
  11095. })
  11096. }
  11097. } else {
  11098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11099. return
  11100. }
  11101. } else { //读卡失败
  11102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11103. return
  11104. }
  11105. }
  11106. func DeleteExtraSpaceTwo(s string) string {
  11107. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11108. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11109. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11110. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11111. s2 := make([]byte, len(s1)) //定义字符数组切片
  11112. copy(s2, s1) //将字符串复制到切片
  11113. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11114. for len(spc_index) > 0 { //找到适配项
  11115. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11116. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11117. }
  11118. return string(s2)
  11119. }
  11120. func Remove0000(s string) string {
  11121. str := make([]rune, 0, len(s))
  11122. for _, v := range []rune(s) {
  11123. if v == 0 {
  11124. continue
  11125. }
  11126. str = append(str, v)
  11127. }
  11128. return string(str)
  11129. }
  11130. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11131. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11132. readCard := DllDef.MustFindProc("EcQuery")
  11133. pCardInfo := make([]byte, 8192)
  11134. pBusiCardInfo := make([]byte, 8192)
  11135. data := make(map[string]interface{})
  11136. //pData := make(map[string]interface{})
  11137. inputData := make(map[string]interface{})
  11138. inputData["orgId"] = code
  11139. inputData["businessType"] = "01101"
  11140. inputData["operatorId"] = operator_id
  11141. inputData["operatorName"] = operator_name
  11142. inputData["officeId"] = "001"
  11143. inputData["officeName"] = "血透室"
  11144. //
  11145. data["data"] = inputData
  11146. data["transType"] = "ec.query"
  11147. data["orgId"] = code
  11148. bytesData, _ := json.Marshal(data)
  11149. pCardInfo = bytesData
  11150. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11151. fmt.Println(ret2)
  11152. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11153. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11154. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11155. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11156. if ret2 != 0 {
  11157. return "", ""
  11158. }
  11159. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11160. }
  11161. func DeleteExtraSpace(s string) string {
  11162. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11163. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11164. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11165. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11166. s2 := make([]byte, len(s1)) //定义字符数组切片
  11167. copy(s2, s1) //将字符串复制到切片
  11168. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11169. for len(spc_index) > 0 { //找到适配项
  11170. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11171. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11172. }
  11173. return string(s2)
  11174. }