his_api_controller.go 202KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817
  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/jinzhu/gorm"
  14. "github.com/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func HisManagerApiRegistRouters() {
  31. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  32. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  33. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  34. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  35. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  36. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  37. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  38. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  39. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  40. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  41. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  42. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  43. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  44. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  45. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  46. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  47. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  48. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  49. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  50. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  51. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  52. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  53. //备案撤销相关接口
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  65. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  66. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  67. }
  68. func (c *HisApiController) ReadCard() {
  69. id_card_type, _ := c.GetInt64("id_card_type")
  70. admin_user_id, _ := c.GetInt64("admin_user_id")
  71. certificates, _ := c.GetInt64("certificates")
  72. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  73. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  74. if initFlag == 0 {
  75. c.TestGetBasBaseInit()
  76. }
  77. switch id_card_type {
  78. case 1:
  79. basStr := c.GetBasBaseInfo()
  80. fmt.Println(basStr)
  81. bas := strings.Split(basStr, "|")
  82. basNumber := bas[3]
  83. fmt.Println(basNumber)
  84. card_sn := bas[4]
  85. fmt.Println(card_sn)
  86. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  87. var dat map[string]interface{}
  88. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  89. fmt.Println(dat)
  90. } else {
  91. fmt.Println(err)
  92. }
  93. userJSONBytes, _ := json.Marshal(dat)
  94. var res ResultTwo
  95. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  96. utils.ErrorLog("解析失败:%v", err)
  97. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  98. return
  99. }
  100. if res.Infcode == 0 {
  101. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  102. if err == gorm.ErrRecordNotFound {
  103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  104. return
  105. } else if err != nil {
  106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  107. return
  108. } else {
  109. c.ServeSuccessJSON(map[string]interface{}{
  110. "patient": patient,
  111. "number": basNumber,
  112. })
  113. }
  114. } else {
  115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  116. return
  117. }
  118. break
  119. case 2:
  120. SFZStr := c.GetSFZBaseInfo()
  121. id_card_str := strings.Split(SFZStr, "^")
  122. id_card_number := id_card_str[0]
  123. card_sn := ""
  124. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  125. var dat map[string]interface{}
  126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  127. fmt.Println(dat)
  128. } else {
  129. fmt.Println(err)
  130. }
  131. userJSONBytes, _ := json.Marshal(dat)
  132. var res ResultTwo
  133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  134. utils.ErrorLog("解析失败:%v", err)
  135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  136. return
  137. }
  138. if res.Infcode == 0 {
  139. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  140. if err == gorm.ErrRecordNotFound {
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  142. return
  143. } else if err != nil {
  144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  145. return
  146. } else {
  147. c.ServeSuccessJSON(map[string]interface{}{
  148. "patient": patient,
  149. "number": id_card_number,
  150. })
  151. }
  152. } else {
  153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  154. return
  155. }
  156. break
  157. case 3:
  158. break
  159. }
  160. }
  161. var initFlag int64 = 0
  162. func (c *HisApiController) TestGetBasBaseInit() {
  163. DllDef := syscall.MustLoadDLL("SSCard.dll")
  164. Iinit := DllDef.MustFindProc("Init")
  165. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  166. if ret != 0 {
  167. fmt.Println("SSCard的报错原因:", err)
  168. fmt.Println("SSCard的运算结果为:", ret)
  169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  170. return
  171. }
  172. result := int(ret)
  173. fmt.Println("SSCard的运算结果为1:", result)
  174. initFlag = 1
  175. return
  176. }
  177. func (c *HisApiController) GetSFZBaseInfo() string {
  178. DllDef := syscall.MustLoadDLL("SSCard.dll")
  179. readCard := DllDef.MustFindProc("ReadSFZ")
  180. if readCard == nil {
  181. fmt.Println("readcard is nil")
  182. readCard = DllDef.MustFindProc("ReadSFZ")
  183. }
  184. str := make([]byte, 256)
  185. str1 := make([]byte, 256)
  186. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  187. fmt.Println(r)
  188. return string(str)
  189. }
  190. func (c *HisApiController) GetBasBaseInfo() string {
  191. DllDef := syscall.MustLoadDLL("SSCard.dll")
  192. readCard := DllDef.MustFindProc("ReadCardBas")
  193. if readCard == nil {
  194. fmt.Println("readcard is nil")
  195. readCard = DllDef.MustFindProc("ReadCardBas")
  196. }
  197. str := make([]byte, 1024)
  198. str1 := make([]byte, 1024)
  199. ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  200. if err2 != nil {
  201. fmt.Println("SSCard的运算结果为:", ret2)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  203. return ""
  204. }
  205. return string(str1)
  206. }
  207. func prttostr(vcode uintptr) string {
  208. var vbyte []byte
  209. for i := 0; i < 10; i++ {
  210. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  211. if sbyte == 0 {
  212. break
  213. }
  214. vbyte = append(vbyte, sbyte)
  215. vcode += 1
  216. }
  217. return string(vbyte)
  218. }
  219. type CustomFundPay struct {
  220. FundPayType string `json:"fund_pay_type"`
  221. FundPayamt float64 `json:"fund_payamt"`
  222. }
  223. func (c *HisApiController) GetSettleList() {
  224. order_id, _ := c.GetInt64("order_id")
  225. admin_user_id, _ := c.GetInt64("admin_user_id")
  226. order, _ := service.GetHisOrderByIDTwo(order_id)
  227. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  228. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  229. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  230. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  231. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  232. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  233. if order.ID == 0 {
  234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  235. return
  236. }
  237. struct4101 := service.Struct4101{
  238. PsnNo: order.PsnNo,
  239. MdtrtId: order.MdtrtId,
  240. SetlId: order.SetlId,
  241. PsnName: order.PsnName,
  242. Gend: order.Gend,
  243. Brdy: his.Brdy,
  244. Age: his.Age,
  245. Naty: order.Naty,
  246. PatnCertType: "01",
  247. Certno: order.Certno,
  248. Prfs: "90",
  249. ConerName: roles[0].UserName,
  250. PatnRlts: "99",
  251. ConerAddr: miConfig.OrgName,
  252. ConerTel: admin.Mobile,
  253. HiType: order.Insutype,
  254. Insuplc: miConfig.InsuplcAdmdvs,
  255. MaindiagFlag: "1",
  256. BillCode: order.FaPiaoCode,
  257. BillNo: order.FaPiaoNumber,
  258. BizSn: order.Number,
  259. PsnSelfPay: order.PsnPartAmt,
  260. PsnOwnPay: order.PsnPartAmt,
  261. AcctPay: order.AcctPay,
  262. PsnCashpay: order.PsnCashPay,
  263. HiPaymtd: "1",
  264. Hsorg: miConfig.InsuplcAdmdvs,
  265. HsorgOpter: miConfig.InsuplcAdmdvs,
  266. MedinsFillPsn: curRoles.UserName,
  267. MedinsFillDept: depart.Name,
  268. IptMedType: "2",
  269. }
  270. if order.SettleType == 1 {
  271. t := time.Unix(int64(order.SettleAccountsDate), 0)
  272. dateStr := t.Format("2006-01-02")
  273. struct4101.SetlBegnDate = dateStr
  274. struct4101.SetlEndDate = dateStr
  275. } else {
  276. t := time.Unix(int64(order.SettleStartTime), 0)
  277. t2 := time.Unix(int64(order.SettleEndTime), 0)
  278. dateStartStr := t.Format("2006-01-02")
  279. dateEndStr := t2.Format("2006-01-02")
  280. struct4101.SetlBegnDate = dateStartStr
  281. struct4101.SetlEndDate = dateEndStr
  282. }
  283. var rf []CustomFundPay
  284. json.Unmarshal([]byte(order.SetlDetail), &rf)
  285. var tempFunPays []service.CustomStruct
  286. for _, item := range rf {
  287. var tempFunPay service.CustomStruct
  288. tempFunPay.FundPayamt = item.FundPayamt
  289. tempFunPay.FundPayType = item.FundPayType
  290. tempFunPays = append(tempFunPays, tempFunPay)
  291. }
  292. struct4101.CustomStruct = tempFunPays
  293. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  294. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  295. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  296. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  297. var config []*models.HisXtDiagnoseConfig
  298. for _, item := range diagnosis_ids {
  299. id, _ := strconv.ParseInt(item, 10, 64)
  300. diagnosisConfig, _ := service.FindDiagnoseById(id)
  301. config = append(config, diagnosisConfig)
  302. }
  303. for _, item := range config {
  304. var tempOpspdiseinfo service.OpspdiseinfoStruct
  305. tempOpspdiseinfo.DiagCode = item.CountryCode
  306. tempOpspdiseinfo.DiagName = item.CountryContentName
  307. tempOpspdiseinfo.MaindiagFlag = "1"
  308. tempOpspdiseinfo.OprnOprtCode = ""
  309. tempOpspdiseinfo.OprnOprtName = ""
  310. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  311. }
  312. sickConfigTwo, _ := service.FindSickById(his.SickType)
  313. tempOpspdiseinfo2.DiagCode = sickConfigTwo.CountryCode
  314. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  315. tempOpspdiseinfo2.MaindiagFlag = "2"
  316. tempOpspdiseinfo2.OprnOprtCode = ""
  317. tempOpspdiseinfo2.OprnOprtName = ""
  318. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  319. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  320. var iteminfo service.IteminfoStruct
  321. var bedCostTotal float64 = 0 //床位总费
  322. var bedCostSelfTotal float64 = 0 //床位自费
  323. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  324. var operationCostTotal float64 = 0 //手术费
  325. var operationCostSelfTotal float64 = 0 //手术费
  326. var operationCostPartSelfTotal float64 = 0 //手术费
  327. var otherCostTotal float64 = 0 //其他费用
  328. var otherCostSelfTotal float64 = 0 //其他费用
  329. var otherCostPartSelfTotal float64 = 0 //其他费用
  330. var materialCostTotal float64 = 0 //材料费
  331. var materialCostSelfTotal float64 = 0 //材料费
  332. var materialCostPartSelfTotal float64 = 0 //材料费
  333. var westernMedicineCostTotal float64 = 0 //西药费
  334. var westernMedicineCostSelfTotal float64 = 0 //西药费
  335. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  336. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  337. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  338. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  339. var checkCostTotal float64 = 0 //检查费
  340. var checkCostSelfTotal float64 = 0 //检查费
  341. var checkCostPartSelfTotal float64 = 0 //检查费
  342. var laboratoryCostTotal float64 = 0 //化验费
  343. var laboratoryCostSelfTotal float64 = 0 //化验费
  344. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  345. var treatCostTotal float64 = 0 //治疗费用
  346. var treatCostSelfTotal float64 = 0 //治疗费用
  347. var treatCostPartSelfTotal float64 = 0 //治疗费用
  348. decimal.DivisionPrecision = 2
  349. var bed_fulamt_ownpay_amt float64 = 0
  350. var operation_fulamt_ownpay_amt float64 = 0
  351. var other_fulamt_ownpay_amt float64 = 0
  352. var westernMedicine_fulamt_ownpay_amt float64 = 0
  353. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  354. var check_fulamt_ownpay_amt float64 = 0
  355. var material_fulamt_ownpay_amt float64 = 0
  356. var laboratory_fulamt_ownpay_amt float64 = 0
  357. var treat_fulamt_ownpay_amt float64 = 0
  358. var bed_claa_sunmfee float64 = 0
  359. var bed_clab_amt float64 = 0
  360. var bed_other_amt float64 = 0
  361. var operation_claa_sunmfee float64 = 0
  362. var operation_clab_amt float64 = 0
  363. var operation_other_amt float64 = 0
  364. var other_claa_sunmfee float64 = 0
  365. var other_clab_amt float64 = 0
  366. var other_other_amt float64 = 0
  367. var westernMedicine_claa_sunmfee float64 = 0
  368. var westernMedicine_clab_amt float64 = 0
  369. var westernMedicine_other_amt float64 = 0
  370. var chineseTraditional_claa_sunmfee float64 = 0
  371. var chineseTraditional_clab_amt float64 = 0
  372. var chineseTraditional_other_amt float64 = 0
  373. var check_claa_sunmfee float64 = 0
  374. var check_clab_amt float64 = 0
  375. var check_other_amt float64 = 0
  376. var material_claa_sunmfee float64 = 0
  377. var material_clab_amt float64 = 0
  378. var material_other_amt float64 = 0
  379. var laboratory_claa_sunmfee float64 = 0
  380. var laboratory_clab_amt float64 = 0
  381. var laboratory_other_amt float64 = 0
  382. var treat_claa_sunmfee float64 = 0
  383. var treat_clab_amt float64 = 0
  384. var treat_other_amt float64 = 0
  385. for _, item := range order.HisOrderInfo {
  386. if item.MedChrgitmType == "01" { //床位费
  387. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  388. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  389. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  390. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  391. if item.ChrgitmLv == "1" {
  392. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  393. }
  394. if item.ChrgitmLv == "2" {
  395. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  396. }
  397. if item.ChrgitmLv == "3" {
  398. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  399. }
  400. }
  401. if item.MedChrgitmType == "03" { //检查费
  402. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  403. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  404. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  405. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  406. if item.ChrgitmLv == "1" {
  407. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  408. }
  409. if item.ChrgitmLv == "2" {
  410. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  411. }
  412. if item.ChrgitmLv == "3" {
  413. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  414. }
  415. }
  416. if item.MedChrgitmType == "04" { //化验费
  417. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  418. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  419. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  420. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  421. if item.ChrgitmLv == "1" {
  422. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  423. }
  424. if item.ChrgitmLv == "2" {
  425. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  426. }
  427. if item.ChrgitmLv == "3" {
  428. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  429. }
  430. }
  431. if item.MedChrgitmType == "05" { //治疗费
  432. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  433. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  434. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  435. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  436. if item.ChrgitmLv == "1" {
  437. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  438. }
  439. if item.ChrgitmLv == "2" {
  440. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  441. }
  442. if item.ChrgitmLv == "3" {
  443. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  444. }
  445. }
  446. if item.MedChrgitmType == "06" { //手术费
  447. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  448. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  449. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  450. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  451. if item.ChrgitmLv == "1" {
  452. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  453. }
  454. if item.ChrgitmLv == "2" {
  455. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  456. }
  457. if item.ChrgitmLv == "3" {
  458. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  459. }
  460. }
  461. if item.MedChrgitmType == "08" { //材料费
  462. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  463. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  464. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  465. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  466. if item.ChrgitmLv == "1" {
  467. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  468. }
  469. if item.ChrgitmLv == "2" {
  470. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  471. }
  472. if item.ChrgitmLv == "3" {
  473. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  474. }
  475. }
  476. if item.MedChrgitmType == "09" { //西药费
  477. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  478. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  479. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  480. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  481. if item.ChrgitmLv == "1" {
  482. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  483. }
  484. if item.ChrgitmLv == "2" {
  485. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  486. }
  487. if item.ChrgitmLv == "3" {
  488. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  489. }
  490. }
  491. if item.MedChrgitmType == "11" { //中成费
  492. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  493. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  494. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  495. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  496. if item.ChrgitmLv == "1" {
  497. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  498. }
  499. if item.ChrgitmLv == "2" {
  500. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  501. }
  502. if item.ChrgitmLv == "3" {
  503. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  504. }
  505. }
  506. if item.MedChrgitmType == "14" { //其他费
  507. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  508. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  509. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  510. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  511. if item.ChrgitmLv == "1" {
  512. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  513. }
  514. if item.ChrgitmLv == "2" {
  515. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  516. }
  517. if item.ChrgitmLv == "3" {
  518. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  519. }
  520. }
  521. }
  522. var iteminfoStructs []service.IteminfoStruct
  523. if bedCostTotal != 0 {
  524. iteminfo.MedChrgitm = "01"
  525. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  526. iteminfo.Amt = bedCostTotal
  527. iteminfo.ClaaSumfee = bed_claa_sunmfee
  528. iteminfo.ClabAmt = bed_clab_amt
  529. iteminfo.OthAmt = bed_other_amt
  530. iteminfoStructs = append(iteminfoStructs, iteminfo)
  531. }
  532. if checkCostTotal != 0 {
  533. iteminfo.MedChrgitm = "03"
  534. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  535. iteminfo.Amt = checkCostTotal
  536. iteminfo.ClaaSumfee = check_claa_sunmfee
  537. iteminfo.ClabAmt = check_clab_amt
  538. iteminfo.OthAmt = check_other_amt
  539. iteminfoStructs = append(iteminfoStructs, iteminfo)
  540. }
  541. if laboratoryCostTotal != 0 {
  542. iteminfo.MedChrgitm = "04"
  543. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  544. iteminfo.Amt = laboratoryCostTotal
  545. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  546. iteminfo.ClabAmt = laboratory_clab_amt
  547. iteminfo.OthAmt = laboratory_other_amt
  548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  549. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  550. }
  551. if treatCostTotal != 0 {
  552. iteminfo.MedChrgitm = "05"
  553. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  554. iteminfo.Amt = treatCostTotal
  555. iteminfo.ClaaSumfee = treat_claa_sunmfee
  556. iteminfo.ClabAmt = treat_clab_amt
  557. iteminfo.OthAmt = treat_other_amt
  558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  559. // (struct4101.IteminfoStruct, iteminfo)
  560. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  561. }
  562. if operationCostTotal != 0 {
  563. iteminfo.MedChrgitm = "06"
  564. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  565. iteminfo.Amt = operationCostTotal
  566. iteminfo.ClaaSumfee = operation_claa_sunmfee
  567. iteminfo.ClabAmt = operation_clab_amt
  568. iteminfo.OthAmt = operation_other_amt
  569. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  571. }
  572. if materialCostTotal != 0 {
  573. iteminfo.MedChrgitm = "08"
  574. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  575. iteminfo.Amt = materialCostTotal
  576. iteminfo.ClaaSumfee = material_claa_sunmfee
  577. iteminfo.ClabAmt = material_clab_amt
  578. iteminfo.OthAmt = material_other_amt
  579. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  580. iteminfoStructs = append(iteminfoStructs, iteminfo)
  581. }
  582. if westernMedicineCostTotal != 0 {
  583. iteminfo.MedChrgitm = "09"
  584. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  585. iteminfo.Amt = westernMedicineCostTotal
  586. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  587. iteminfo.ClabAmt = westernMedicine_clab_amt
  588. iteminfo.OthAmt = westernMedicine_other_amt
  589. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  590. iteminfoStructs = append(iteminfoStructs, iteminfo)
  591. }
  592. if chineseTraditionalMedicineCostTotal != 0 {
  593. iteminfo.MedChrgitm = "11"
  594. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  595. iteminfo.Amt = westernMedicineCostTotal
  596. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  597. iteminfo.ClabAmt = westernMedicine_clab_amt
  598. iteminfo.OthAmt = westernMedicine_other_amt
  599. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  600. iteminfoStructs = append(iteminfoStructs, iteminfo)
  601. }
  602. if otherCostTotal != 0 {
  603. iteminfo.MedChrgitm = "14"
  604. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  605. iteminfo.Amt = otherCostTotal
  606. iteminfo.ClaaSumfee = other_claa_sunmfee
  607. iteminfo.ClabAmt = other_clab_amt
  608. iteminfo.OthAmt = other_other_amt
  609. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  610. iteminfoStructs = append(iteminfoStructs, iteminfo)
  611. }
  612. struct4101.IteminfoStruct = iteminfoStructs
  613. struct4101.Ntly = "中国"
  614. struct4101.AdmCaty = "A03.06"
  615. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  616. fmt.Println(result)
  617. var dat map[string]interface{}
  618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  619. fmt.Println(dat)
  620. } else {
  621. fmt.Println(err)
  622. }
  623. userJSONBytes, _ := json.Marshal(dat)
  624. var res ResultSeventeen
  625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  626. utils.ErrorLog("解析失败:%v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. if res.Infcode != 0 {
  631. c.ServeSuccessJSON(map[string]interface{}{
  632. "failed_code": -10,
  633. "msg": res.ErrMsg,
  634. })
  635. return
  636. } else {
  637. hisFundSettleListResult := &models.HisFundSettleListResult{
  638. Number: res.Output.SetlListId,
  639. Status: 1,
  640. Ctime: time.Now().Unix(),
  641. Mtime: time.Now().Unix(),
  642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  643. IsUpload: 1,
  644. OrderId: order_id,
  645. }
  646. service.CreateUploadRecord(hisFundSettleListResult)
  647. c.ServeSuccessJSON(map[string]interface{}{
  648. "msg": "上传成功",
  649. "result": hisFundSettleListResult,
  650. })
  651. return
  652. }
  653. }
  654. //func (c *HisApiController) TestPay() {
  655. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  656. // readCards := DllDef2.MustFindProc("BankTrans")
  657. // inputData := make(map[string]interface{})
  658. // inputData["transId"] = "05"
  659. // inputData["amount"] = "0.01"
  660. // inputData["traceNo"] = "20210227093601325405377"
  661. // inputData["cardNo"] = "F36084348"
  662. // inputData["id"] = "44022919620927046X"
  663. // //jsonStr := `
  664. // // {
  665. // // "transId": "05",
  666. // // "amount":"1.00",
  667. // // "traceNo":"20210227093601325405377",
  668. // // "cardNo":"F36084348",
  669. // // "id":"44022919620927046X"
  670. // //
  671. // // }
  672. // //`
  673. //
  674. // bytes_arr, _ := json.Marshal(inputData)
  675. // str3 := make([]byte, 256)
  676. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  677. // fmt.Println(":", string(str3))
  678. //
  679. // if err4 != nil {
  680. // fmt.Println("SSCard的运算结果为:", ret4)
  681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  682. // return
  683. // }
  684. //
  685. //}
  686. //func (c *HisApiController) TestGetBasBaseInfo() {
  687. //
  688. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  689. // //fmt.Println(result)
  690. // //cs1 := C.CString("")
  691. // //cs2 := C.CString("")
  692. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  693. // //fmt.Println(cs1)
  694. // //fmt.Println(cs2)
  695. // //C.free(unsafe.Pointer(cs1))
  696. // //C.free(unsafe.Pointer(cs2))
  697. //
  698. // //
  699. //
  700. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  701. // Iinit := DllDef.MustFindProc("Init")
  702. // readCard := DllDef.MustFindProc("ReadCardBas")
  703. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  704. // if ret != 0 {
  705. // fmt.Println("SSCard的报错原因:", err)
  706. // fmt.Println("SSCard的运算结果为:", ret)
  707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  708. // return
  709. // }
  710. //
  711. // result := int(ret)
  712. // fmt.Println("SSCard的运算结果为1:", result)
  713. //
  714. // //path := ""
  715. // //bytePath := []byte( "\x00")
  716. // //bytePath2 := []byte( "\x00")
  717. // //ssss
  718. //
  719. // str := make([]byte, 256)
  720. // str1 := make([]byte, 256)
  721. // s2 := []byte(string(str))
  722. // s3 := []byte(string(str1))
  723. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  724. // fmt.Println(" Add(4,5)的结果为:", ret2)
  725. // fmt.Println(" str:", s2)
  726. // fmt.Println(" str1:", s3)
  727. // if err2 != nil {
  728. // fmt.Println("SSCard的运算结果为:", ret2)
  729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  730. // return
  731. // }
  732. //
  733. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  734. //
  735. //}
  736. func (c *HisApiController) GetOrgInfo() {
  737. miConfig, _ := service.FindMedicalInsuranceInfo(9919)
  738. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  739. }
  740. func (c *HisApiController) GetHisPatientInfo() {
  741. medical_insurance_card := c.GetString("medical_insurance_card")
  742. id_card_type, _ := c.GetInt64("id_card_type")
  743. id_card := c.GetString("id_card")
  744. adminInfo := c.GetAdminUserInfo()
  745. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  746. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  747. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  748. IdCardNo := ""
  749. if id_card_type == 1 {
  750. IdCardNo = medical_insurance_card
  751. } else if id_card_type == 2 {
  752. IdCardNo = id_card
  753. }
  754. if config.IsOpen == 1 {
  755. 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
  756. resp, requestErr := http.Get(api)
  757. if requestErr != nil {
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. defer resp.Body.Close()
  762. body, ioErr := ioutil.ReadAll(resp.Body)
  763. if ioErr != nil {
  764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. var respJSON map[string]interface{}
  769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  775. userJSONBytes, _ := json.Marshal(userJSON)
  776. var res ResultTwo
  777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  778. utils.ErrorLog("解析失败:%v", err)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. return
  781. }
  782. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  783. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  784. infoStr := string(Iinfos)
  785. idetinfoStr := string(Idetinfos)
  786. if res.Infcode == 0 {
  787. his := models.VMHisPatient{
  788. Status: 1,
  789. Ctime: time.Now().Unix(),
  790. Mtime: time.Now().Unix(),
  791. PsnNo: res.Output.Baseinfo.PsnNo,
  792. PsnCertType: res.Output.Baseinfo.PsnCertType,
  793. Certno: res.Output.Baseinfo.Certno,
  794. PsnName: res.Output.Baseinfo.PsnName,
  795. Gend: res.Output.Baseinfo.Gend,
  796. Naty: res.Output.Baseinfo.Naty,
  797. Brdy: res.Output.Baseinfo.Brdy,
  798. Age: res.Output.Baseinfo.Age,
  799. Iinfo: infoStr,
  800. Idetinfo: idetinfoStr,
  801. UserOrgId: adminInfo.CurrentOrgId,
  802. IsReturn: 1,
  803. IdCardType: id_card_type,
  804. }
  805. c.ServeSuccessJSON(map[string]interface{}{
  806. "info": his,
  807. })
  808. } else {
  809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  810. return
  811. }
  812. }
  813. }
  814. //func GetBasBaseInfo() (jsonStr string, err error) {
  815. //
  816. // handle := syscall.NewLazyDLL("SSCard.dll")
  817. // add := handle.NewProc("ReadCardBas")
  818. // str := make([]byte, 1024)
  819. // str1 := make([]byte, 1024)
  820. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  821. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  822. //
  823. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  824. //
  825. // fmt.Println("> Add(4,5)的结果为:", ret)
  826. // handle.Release()
  827. //
  828. // return "", nil
  829. //
  830. //}
  831. //func GetQRBaseInfo() (jsonStr string, err error) {
  832. // handle := syscall.LoadDLL("SSCard.dll")
  833. // ReadCardBas := handle.FindProc("GetQRBase")
  834. //
  835. // str := make([]byte, 256)
  836. // str1 := make([]byte, 256)
  837. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  838. //
  839. // fmt.Println(string(str))
  840. // fmt.Println(r)
  841. // return string(str), nil
  842. //}
  843. func CardInit() int {
  844. DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  845. add := DllTestDef.MustFindProc("Init")
  846. ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  847. if err != nil {
  848. fmt.Println("SSCard的运算结果为:", ret)
  849. }
  850. result := int(ret)
  851. return result
  852. }
  853. //func CardInit() int {
  854. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  855. // if err != nil {
  856. // fmt.Println("SSCard的运算结果为:", ret)
  857. // }
  858. // fmt.Println(err)
  859. // result := int(ret)
  860. // return result
  861. //}
  862. func IntPtr(n int) uintptr {
  863. return uintptr(n)
  864. }
  865. func StrPtr(s string) uintptr {
  866. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  867. }
  868. type ResultTwo struct {
  869. ErrMsg string `json:"err_msg"`
  870. InfRefmsgid string `json:"inf_refmsgid"`
  871. Infcode int64 `json:"infcode"`
  872. Output struct {
  873. Baseinfo struct {
  874. Age float64 `json:"age"`
  875. Brdy string `json:"brdy"`
  876. Certno string `json:"certno"`
  877. Gend string `json:"gend"`
  878. Naty string `json:"naty"`
  879. PsnCertType string `json:"psn_cert_type"`
  880. PsnName string `json:"psn_name"`
  881. PsnNo string `json:"psn_no"`
  882. } `json:"baseinfo"`
  883. Idetinfo []interface{} `json:"idetinfo"`
  884. Iinfo []struct {
  885. Balc float64 `json:"balc"`
  886. CvlservFlag string `json:"cvlserv_flag"`
  887. EmpName string `json:"emp_name"`
  888. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  889. Insutype string `json:"insutype"`
  890. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  891. PausInsuDate string `json:"paus_insu_date"`
  892. PsnInsuDate string `json:"psn_insu_date"`
  893. PsnInsuStas string `json:"psn_insu_stas"`
  894. PsnType string `json:"psn_type"`
  895. } `json:"insuinfo"`
  896. } `json:"output"`
  897. RefmsgTime string `json:"refmsg_time"`
  898. RespondTime string `json:"respond_time"`
  899. Signtype interface{} `json:"signtype"`
  900. WarnInfo interface{} `json:"warn_info"`
  901. }
  902. type ResultThree struct {
  903. Cainfo interface{} `json:"cainfo"`
  904. ErrMsg string `json:"err_msg"`
  905. InfRefmsgid string `json:"inf_refmsgid"`
  906. Infcode int64 `json:"infcode"`
  907. Output struct {
  908. Data struct {
  909. IptOtpNo string `json:"ipt_otp_no"`
  910. MdtrtID string `json:"mdtrt_id"`
  911. PsnNo string `json:"psn_no"`
  912. } `json:"data"`
  913. } `json:"output"`
  914. RefmsgTime string `json:"refmsg_time"`
  915. RespondTime string `json:"respond_time"`
  916. Signtype interface{} `json:"signtype"`
  917. WarnMsg interface{} `json:"warn_msg"`
  918. }
  919. type ResultFour struct {
  920. Cainfo string `json:"cainfo"`
  921. ErrMsg string `json:"err_msg"`
  922. InfRefmsgid string `json:"inf_refmsgid"`
  923. Infcode int64 `json:"infcode"`
  924. Output struct {
  925. Result []struct {
  926. BasMednFlag string `json:"bas_medn_flag"`
  927. ChldMedcFlag string `json:"chld_medc_flag"`
  928. ChrgitmLv string `json:"chrgitm_lv"`
  929. Cnt float64 `json:"cnt"`
  930. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  931. DrtReimFlag string `json:"drt_reim_flag"`
  932. FeedetlSn string `json:"feedetl_sn"`
  933. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  934. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  935. InscpScpAmt float64 `json:"inscp_scp_amt"`
  936. ListSpItemFlag string `json:"list_sp_item_flag"`
  937. LmtUsedFlag string `json:"lmt_used_flag"`
  938. MedChrgitmType string `json:"med_chrgitm_type"`
  939. Memo string `json:"memo"`
  940. OverlmtAmt float64 `json:"overlmt_amt"`
  941. PreselfpayAmt float64 `json:"preselfpay_amt"`
  942. Pric float64 `json:"pric"`
  943. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  944. SelfpayProp float64 `json:"selfpay_prop"`
  945. } `json:"result"`
  946. } `json:"output"`
  947. RefmsgTime string `json:"refmsg_time"`
  948. RespondTime string `json:"respond_time"`
  949. Signtype string `json:"signtype"`
  950. WarnMsg string `json:"warn_msg"`
  951. }
  952. type ResultFive struct {
  953. Balc float64 `json:"balc"`
  954. CvlservFlag string `json:"cvlserv_flag"`
  955. EmpName string `json:"emp_name"`
  956. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  957. Insutype string `json:"insutype"`
  958. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  959. PausInsuDate string `json:"paus_insu_date"`
  960. PsnInsuDate string `json:"psn_insu_date"`
  961. PsnInsuStas string `json:"psn_insu_stas"`
  962. PsnType string `json:"psn_type"`
  963. }
  964. type ResultSix struct {
  965. Cainfo interface{} `json:"cainfo"`
  966. ErrMsg string `json:"err_msg"`
  967. InfRefmsgid string `json:"inf_refmsgid"`
  968. Infcode int64 `json:"infcode"`
  969. Output struct {
  970. } `json:"output"`
  971. RefmsgTime string `json:"refmsg_time"`
  972. RespondTime string `json:"respond_time"`
  973. Signtype interface{} `json:"signtype"`
  974. WarnMsg interface{} `json:"warn_msg"`
  975. }
  976. type ResultSeven struct {
  977. Cainfo string `json:"cainfo"`
  978. ErrMsg string `json:"err_msg"`
  979. InfRefmsgid string `json:"inf_refmsgid"`
  980. Infcode int64 `json:"infcode"`
  981. Output struct {
  982. Setldetail []interface{} `json:"setldetail"`
  983. Setlinfo struct {
  984. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  985. AcctPay float64 `json:"acct_pay"`
  986. ActPayDedc float64 `json:"act_pay_dedc"`
  987. Age float64 `json:"age"`
  988. Balc float64 `json:"balc"`
  989. Brdy string `json:"brdy"`
  990. Certno string `json:"certno"`
  991. ClrOptins string `json:"clr_optins"`
  992. ClrType string `json:"clr_type"`
  993. ClrWay string `json:"clr_way"`
  994. CvlservFlag string `json:"cvlserv_flag"`
  995. CvlservPay float64 `json:"cvlserv_pay"`
  996. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  997. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  998. Gend string `json:"gend"`
  999. HifesPay float64 `json:"hifes_pay"`
  1000. HifmiPay float64 `json:"hifmi_pay"`
  1001. HifpPay float64 `json:"hifp_pay"`
  1002. HospPartAmt float64 `json:"hosp_part_amt"`
  1003. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1004. Insutype string `json:"insutype"`
  1005. MafPay float64 `json:"maf_pay"`
  1006. MdtrtCertType string `json:"mdtrt_cert_type"`
  1007. HifobPay float64 `json:"hifob_pay"`
  1008. MdtrtID string `json:"mdtrt_id"`
  1009. MedType string `json:"med_type"`
  1010. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1011. MedinsSetlID string `json:"medins_setl_id"`
  1012. Naty string `json:"naty"`
  1013. OthPay float64 `json:"oth_pay"`
  1014. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1015. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1016. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1017. PsnCashPay float64 `json:"psn_cash_pay"`
  1018. PsnCertType string `json:"psn_cert_type"`
  1019. PsnName string `json:"psn_name"`
  1020. PsnNo string `json:"psn_no"`
  1021. PsnPartAmt float64 `json:"psn_part_amt"`
  1022. PsnType string `json:"psn_type"`
  1023. SetlID string `json:"setl_id"`
  1024. SetlTime string `json:"setl_time"`
  1025. } `json:"setlinfo"`
  1026. } `json:"output"`
  1027. RefmsgTime string `json:"refmsg_time"`
  1028. RespondTime string `json:"respond_time"`
  1029. Signtype interface{} `json:"signtype"`
  1030. WarnMsg interface{} `json:"warn_msg"`
  1031. }
  1032. type ResultEight struct {
  1033. Cainfo string `json:"cainfo"`
  1034. ErrMsg string `json:"err_msg"`
  1035. InfRefmsgid string `json:"inf_refmsgid"`
  1036. Infcode int64 `json:"infcode"`
  1037. Output struct {
  1038. Stmtinfo struct {
  1039. SetlOptins string `json:"setl_optins"`
  1040. StmtRslt string `json:"stmt_rslt"`
  1041. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1042. } `json:"stmtinfo"`
  1043. } `json:"output"`
  1044. RefmsgTime string `json:"refmsg_time"`
  1045. RespondTime string `json:"respond_time"`
  1046. Signtype interface{} `json:"signtype"`
  1047. WarnMsg interface{} `json:"warn_msg"`
  1048. }
  1049. type ResultNine struct {
  1050. Cainfo string `json:"cainfo"`
  1051. ErrMsg string `json:"err_msg"`
  1052. InfRefmsgid string `json:"inf_refmsgid"`
  1053. Infcode int64 `json:"infcode"`
  1054. Output struct {
  1055. FileQuryNo string `json:"file_qury_no"`
  1056. } `json:"output"`
  1057. RefmsgTime string `json:"refmsg_time"`
  1058. RespondTime string `json:"respond_time"`
  1059. Signtype interface{} `json:"signtype"`
  1060. WarnMsg interface{} `json:"warn_msg"`
  1061. }
  1062. type ResultTen struct {
  1063. Cainfo string `json:"cainfo"`
  1064. ErrMsg string `json:"err_msg"`
  1065. InfRefmsgid string `json:"inf_refmsgid"`
  1066. Infcode int64 `json:"infcode"`
  1067. Output struct {
  1068. DldEndtime string `json:"dld_endtime"`
  1069. FileQuryNo string `json:"file_qury_no"`
  1070. Filename string `json:"filename"`
  1071. } `json:"output"`
  1072. RefmsgTime string `json:"refmsg_time"`
  1073. RespondTime string `json:"respond_time"`
  1074. Signtype interface{} `json:"signtype"`
  1075. WarnMsg interface{} `json:"warn_msg"`
  1076. }
  1077. //type Autogenerated struct {
  1078. // Output struct {
  1079. // Setlinfo struct {
  1080. // SetlTime string `json:"setl_time"`
  1081. // CvlservPay float64 `json:"cvlserv_pay"`
  1082. // Year string `json:"year"`
  1083. // MedType string `json:"med_type"`
  1084. // PsnPay float64 `json:"psn_pay"`
  1085. // OpterID string `json:"opter_id"`
  1086. // Begndate string `json:"begndate"`
  1087. // FlxempeFlag string `json:"flxempe_flag"`
  1088. // HifmiPay float64 `json:"hifmi_pay"`
  1089. // PsnNo string `json:"psn_no"`
  1090. // ActPayDedc float64 `json:"act_pay_dedc"`
  1091. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1092. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1093. // ClrWay string `json:"clr_way"`
  1094. // OthPay float64 `json:"oth_pay"`
  1095. // Gend string `json:"gend"`
  1096. // MdtrtID string `json:"mdtrt_id"`
  1097. // AcctPay float64 `json:"acct_pay"`
  1098. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1099. // Insutype string `json:"insutype"`
  1100. // Invono interface{} `json:"invono"`
  1101. // Enddate string `json:"enddate"`
  1102. // CashPayamt float64 `json:"cash_payamt"`
  1103. // PsnType string `json:"psn_type"`
  1104. // FixmedinsName string `json:"fixmedins_name"`
  1105. // HifpPay float64 `json:"hifp_pay"`
  1106. // NewFlag interface{} `json:"new_flag"`
  1107. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1108. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1109. // PayLoc string `json:"pay_loc"`
  1110. // ClrType string `json:"clr_type"`
  1111. // RefdSetlFlag string `json:"refd_setl_flag"`
  1112. // CvlservFlag string `json:"cvlserv_flag"`
  1113. // EmpName string `json:"emp_name"`
  1114. // Brdy string `json:"brdy"`
  1115. // Naty string `json:"naty"`
  1116. // Certno string `json:"certno"`
  1117. // DiseCode string `json:"dise_code"`
  1118. // FixmedinsCode string `json:"fixmedins_code"`
  1119. // DedcHospLv string `json:"dedc_hosp_lv"`
  1120. // OpterName string `json:"opter_name"`
  1121. // Balc float64 `json:"balc"`
  1122. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1123. // PsnCertType string `json:"psn_cert_type"`
  1124. // HifobPay float64 `json:"hifob_pay"`
  1125. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1126. // HifesPay float64 `json:"hifes_pay"`
  1127. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1128. // OptTime string `json:"opt_time"`
  1129. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1130. // SetlID string `json:"setl_id"`
  1131. // MafPay float64 `json:"maf_pay"`
  1132. // PsnName string `json:"psn_name"`
  1133. // InsuOptins interface{} `json:"insu_optins"`
  1134. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1135. // ClrOptins string `json:"clr_optins"`
  1136. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1137. // DiseName string `json:"dise_name"`
  1138. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1139. // Age float64 `json:"age"`
  1140. // DtrtCertType string `json:"dtrt_cert_type"`
  1141. // HospLv string `json:"hosp_lv"`
  1142. // } `json:"setlinfo"`
  1143. // Setldetail []struct {
  1144. // FundPayType string `json:"fund_pay_type"`
  1145. // FundPayamt float64 `json:"fund_payamt"`
  1146. // SetlProcInfo interface{} `json:"setl_proc_info"`
  1147. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  1148. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  1149. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  1150. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1151. // } `json:"setldetail"`
  1152. // } `json:"output"`
  1153. // Infcode int `json:"infcode"`
  1154. // WarnMsg interface{} `json:"warn_msg"`
  1155. // Cainfo interface{} `json:"cainfo"`
  1156. // ErrMsg interface{} `json:"err_msg"`
  1157. // RefmsgTime string `json:"refmsg_time"`
  1158. // Signtype interface{} `json:"signtype"`
  1159. // RespondTime string `json:"respond_time"`
  1160. // InfRefmsgid string `json:"inf_refmsgid"`
  1161. //}
  1162. type ResultEleven struct {
  1163. Cainfo string `json:"cainfo"`
  1164. ErrMsg string `json:"err_msg"`
  1165. InfRefmsgid string `json:"inf_refmsgid"`
  1166. Infcode int64 `json:"infcode"`
  1167. Output struct {
  1168. Setlinfo struct {
  1169. SetlTime string `json:"setl_time"`
  1170. CvlservPay float64 `json:"cvlserv_pay"`
  1171. Year string `json:"year"`
  1172. MedType string `json:"med_type"`
  1173. PsnPay float64 `json:"psn_pay"`
  1174. OpterID string `json:"opter_id"`
  1175. Begndate string `json:"begndate"`
  1176. FlxempeFlag string `json:"flxempe_flag"`
  1177. HifmiPay float64 `json:"hifmi_pay"`
  1178. PsnNo string `json:"psn_no"`
  1179. ActPayDedc float64 `json:"act_pay_dedc"`
  1180. MedinsSetlID interface{} `json:"medins_setl_id"`
  1181. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1182. ClrWay string `json:"clr_way"`
  1183. OthPay float64 `json:"oth_pay"`
  1184. Gend string `json:"gend"`
  1185. MdtrtID string `json:"mdtrt_id"`
  1186. AcctPay float64 `json:"acct_pay"`
  1187. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1188. Insutype string `json:"insutype"`
  1189. Invono interface{} `json:"invono"`
  1190. Enddate string `json:"enddate"`
  1191. CashPayamt float64 `json:"cash_payamt"`
  1192. PsnType string `json:"psn_type"`
  1193. FixmedinsName string `json:"fixmedins_name"`
  1194. HifpPay float64 `json:"hifp_pay"`
  1195. NewFlag interface{} `json:"new_flag"`
  1196. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1198. PayLoc string `json:"pay_loc"`
  1199. ClrType string `json:"clr_type"`
  1200. RefdSetlFlag string `json:"refd_setl_flag"`
  1201. CvlservFlag string `json:"cvlserv_flag"`
  1202. EmpName string `json:"emp_name"`
  1203. Brdy string `json:"brdy"`
  1204. Naty string `json:"naty"`
  1205. Certno string `json:"certno"`
  1206. DiseCode string `json:"dise_code"`
  1207. FixmedinsCode string `json:"fixmedins_code"`
  1208. DedcHospLv string `json:"dedc_hosp_lv"`
  1209. OpterName string `json:"opter_name"`
  1210. Balc float64 `json:"balc"`
  1211. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1212. PsnCertType string `json:"psn_cert_type"`
  1213. HifobPay float64 `json:"hifob_pay"`
  1214. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1215. HifesPay float64 `json:"hifes_pay"`
  1216. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1217. OptTime string `json:"opt_time"`
  1218. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1219. SetlID string `json:"setl_id"`
  1220. MafPay float64 `json:"maf_pay"`
  1221. PsnName string `json:"psn_name"`
  1222. InsuOptins interface{} `json:"insu_optins"`
  1223. PrefFundPay interface{} `json:"pref_fund_pay"`
  1224. ClrOptins string `json:"clr_optins"`
  1225. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1226. DiseName string `json:"dise_name"`
  1227. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1228. Age float64 `json:"age"`
  1229. DtrtCertType string `json:"dtrt_cert_type"`
  1230. HospLv string `json:"hosp_lv"`
  1231. } `json:"setlinfo"`
  1232. } `json:"output"`
  1233. RefmsgTime string `json:"refmsg_time"`
  1234. RespondTime string `json:"respond_time"`
  1235. Signtype interface{} `json:"signtype"`
  1236. WarnMsg interface{} `json:"warn_msg"`
  1237. }
  1238. type ResultTwelve struct {
  1239. Cainfo string `json:"cainfo"`
  1240. ErrMsg string `json:"err_msg"`
  1241. InfRefmsgid string `json:"inf_refmsgid"`
  1242. Infcode int64 `json:"infcode"`
  1243. Output struct {
  1244. MdtrtId string `json:"mdtrt_id"`
  1245. ChrgBchno string `json:"chrg_bchno"`
  1246. PsnNo string `json:"psn_no"`
  1247. } `json:"output"`
  1248. RefmsgTime string `json:"refmsg_time"`
  1249. RespondTime string `json:"respond_time"`
  1250. Signtype interface{} `json:"signtype"`
  1251. WarnMsg interface{} `json:"warn_msg"`
  1252. }
  1253. type ResultThirteen struct {
  1254. ErrMsg string `json:"err_msg"`
  1255. InfRefmsgid string `json:"inf_refmsgid"`
  1256. Infcode int64 `json:"infcode"`
  1257. Output struct {
  1258. Result struct {
  1259. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  1260. } `json:"result"`
  1261. } `json:"output"`
  1262. RefmsgTime string `json:"refmsg_time"`
  1263. RespondTime string `json:"respond_time"`
  1264. Signtype interface{} `json:"signtype"`
  1265. WarnInfo interface{} `json:"warn_info"`
  1266. }
  1267. type ResultFourteen struct {
  1268. ErrMsg string `json:"err_msg"`
  1269. InfRefmsgid string `json:"inf_refmsgid"`
  1270. Infcode int64 `json:"infcode"`
  1271. Output struct {
  1272. } `json:"output"`
  1273. RefmsgTime string `json:"refmsg_time"`
  1274. RespondTime string `json:"respond_time"`
  1275. Signtype interface{} `json:"signtype"`
  1276. WarnInfo interface{} `json:"warn_info"`
  1277. }
  1278. type ResultSixteen struct {
  1279. Cainfo string `json:"cainfo"`
  1280. ErrMsg string `json:"err_msg"`
  1281. InfRefmsgid string `json:"inf_refmsgid"`
  1282. Infcode int64 `json:"infcode"`
  1283. Output struct {
  1284. Setldetail []interface{} `json:"setldetail"`
  1285. Setlinfo struct {
  1286. MdtrtID string `json:"mdtrt_id"`
  1287. SetlID string `json:"setl_id"`
  1288. ClrOptins string `json:"clr_optins"`
  1289. SetlTime string `json:"setl_time"`
  1290. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1291. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1292. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1293. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1294. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1295. ActPayDedc float64 `json:"act_pay_dedc"`
  1296. HifpPay float64 `json:"hifp_pay"`
  1297. PoolPropSe float64 `json:"pool_prop_selfpay"`
  1298. Lfpay float64 `json:"selfpay"`
  1299. CvlservPay float64 `json:"cvlserv_pay"`
  1300. HifesPay float64 `json:"hifes_pay"`
  1301. HifmiPay float64 `json:"hifmi_pay"`
  1302. HifobPay float64 `json:"hifob_pay"`
  1303. MafPay float64 `json:"maf_pay"`
  1304. OthPay float64 `json:"oth_pay"`
  1305. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1306. PsnPartAmt float64 `json:"psn_part_amt"`
  1307. AcctPay float64 `json:"acct_pay"`
  1308. Balc float64 `json:"balc"`
  1309. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1310. HospPartAmt float64 `json:"hosp_part_amt"`
  1311. MedinsSetlID string `json:"medins_setl_id"`
  1312. PdnCashPay string `json:"pdn_cash_pay"`
  1313. } `json:"setlinfo"`
  1314. } `json:"output"`
  1315. RefmsgTime string `json:"refmsg_time"`
  1316. RespondTime string `json:"respond_time"`
  1317. Signtype interface{} `json:"signtype"`
  1318. WarnMsg interface{} `json:"warn_msg"`
  1319. }
  1320. type ResultSeventeen struct {
  1321. ErrMsg string `json:"err_msg"`
  1322. InfRefmsgid string `json:"inf_refmsgid"`
  1323. Infcode int64 `json:"infcode"`
  1324. Output struct {
  1325. SetlListId string `json:"setl_list_id"`
  1326. } `json:"output"`
  1327. RefmsgTime string `json:"refmsg_time"`
  1328. RespondTime string `json:"respond_time"`
  1329. Signtype string `json:"signtype"`
  1330. WarnInfo string `json:"warn_info"`
  1331. }
  1332. type Custom struct {
  1333. DetItemFeeSumamt string
  1334. Cut string
  1335. FeedetlSn string
  1336. Price string
  1337. MedListCodg string
  1338. Type int64
  1339. AdviceId int64
  1340. ProjectId int64
  1341. ItemId int64
  1342. }
  1343. //获取个人信息----挂号-----上传就诊信息
  1344. func (c *HisApiController) GetRegisterInfo() {
  1345. id, _ := c.GetInt64("id")
  1346. record_time := c.GetString("record_time")
  1347. settlementValue, _ := c.GetInt64("settlement_value")
  1348. medical_insurance_card := c.GetString("medical_insurance_card")
  1349. name := c.GetString("name")
  1350. id_card_type, _ := c.GetInt64("id_card_type")
  1351. certificates, _ := c.GetInt64("certificates")
  1352. medical_care, _ := c.GetInt64("medical_care")
  1353. birthday := c.GetString("birthday")
  1354. //age, _ := c.GetInt64("age")
  1355. id_card := c.GetString("id_card")
  1356. register_type, _ := c.GetInt64("register")
  1357. doctor, _ := c.GetInt64("doctor")
  1358. department, _ := c.GetInt64("department")
  1359. gender, _ := c.GetInt64("sex")
  1360. //phone := c.GetString("phone")
  1361. registration_fee, _ := c.GetFloat("registration_fee")
  1362. medical_expenses, _ := c.GetFloat("medical_expenses")
  1363. social_type, _ := c.GetInt64("social_type")
  1364. admin_user_id, _ := c.GetInt64("admin_user_id")
  1365. timeLayout := "2006-01-02"
  1366. loc, _ := time.LoadLocation("Local")
  1367. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1368. birthUnix := birthdays.Unix()
  1369. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1370. if err != nil {
  1371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1372. return
  1373. }
  1374. recordDateTime := theTime.Unix()
  1375. adminInfo := c.GetAdminUserInfo()
  1376. var patient service.Patients
  1377. if id == 0 {
  1378. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1379. } else {
  1380. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1381. }
  1382. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1383. if patientPrescription.ID == 0 {
  1384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1385. }
  1386. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  1387. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  1388. //sickConfig, _ := service.FindSickById(sick_type)
  1389. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1390. if patient.ID == 0 {
  1391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1392. return
  1393. }
  1394. if len(patient.IdCardNo) == 0 {
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1396. return
  1397. }
  1398. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1399. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1400. //就诊结算未完成,不能进行二次挂号
  1401. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1402. if len(his) >= 1 {
  1403. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  1404. if len(his) >= 1 && order.ID == 0 {
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  1406. return
  1407. }
  1408. }
  1409. if config.IsOpen == 1 {
  1410. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
  1411. resp, requestErr := http.Get(api)
  1412. if requestErr != nil {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. return
  1415. }
  1416. defer resp.Body.Close()
  1417. body, ioErr := ioutil.ReadAll(resp.Body)
  1418. if ioErr != nil {
  1419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1421. return
  1422. }
  1423. var respJSON map[string]interface{}
  1424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1427. return
  1428. }
  1429. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1430. userJSONBytes, _ := json.Marshal(userJSON)
  1431. var res ResultTwo
  1432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1433. utils.ErrorLog("解析失败:%v", err)
  1434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1435. return
  1436. }
  1437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1439. infoStr := string(Iinfos)
  1440. idetinfoStr := string(Idetinfos)
  1441. if res.Infcode == 0 {
  1442. his := models.VMHisPatient{
  1443. Name: name,
  1444. Gender: gender,
  1445. Birthday: birthUnix,
  1446. MedicalTreatmentType: medical_care,
  1447. IdType: certificates,
  1448. IdCardNo: id_card,
  1449. BalanceAccountsType: settlementValue,
  1450. SocialType: social_type,
  1451. MedicalInsuranceNumber: medical_insurance_card,
  1452. RegisterType: register_type,
  1453. RegisterCost: registration_fee,
  1454. TreatmentCost: medical_expenses,
  1455. Status: 1,
  1456. Ctime: time.Now().Unix(),
  1457. Mtime: time.Now().Unix(),
  1458. PsnNo: res.Output.Baseinfo.PsnNo,
  1459. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1460. Certno: res.Output.Baseinfo.Certno,
  1461. PsnName: res.Output.Baseinfo.PsnName,
  1462. Gend: res.Output.Baseinfo.Gend,
  1463. Naty: res.Output.Baseinfo.Naty,
  1464. Brdy: res.Output.Baseinfo.Brdy,
  1465. Age: res.Output.Baseinfo.Age,
  1466. Iinfo: infoStr,
  1467. Idetinfo: idetinfoStr,
  1468. PatientId: patient.ID,
  1469. RecordDate: theTime.Unix(),
  1470. UserOrgId: adminInfo.CurrentOrgId,
  1471. AdminUserId: admin_user_id,
  1472. IsReturn: 1,
  1473. IdCardType: id_card_type,
  1474. Doctor: doctor,
  1475. Departments: department,
  1476. }
  1477. timestamp := time.Now().Unix()
  1478. tempTime := time.Unix(timestamp, 0)
  1479. timeFormat := tempTime.Format("20060102150405")
  1480. chrgBchno := rand.Intn(100000) + 10000
  1481. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1482. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1483. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1484. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1485. IdCardNo := ""
  1486. if id_card_type == 1 {
  1487. IdCardNo = medical_insurance_card
  1488. } else {
  1489. IdCardNo = patient.IdCardNo
  1490. }
  1491. var insutypes []string
  1492. var insutype string
  1493. var is390 int = 0
  1494. var is310 int = 0
  1495. for _, item := range res.Output.Iinfo {
  1496. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1497. insutypes = append(insutypes, item.Insutype)
  1498. }
  1499. }
  1500. if len(insutypes) == 1 {
  1501. insutype = insutypes[0]
  1502. } else {
  1503. for _, i := range insutypes {
  1504. if i == "390" {
  1505. is390 = 1
  1506. }
  1507. if i == "310" {
  1508. is310 = 1
  1509. }
  1510. }
  1511. }
  1512. if is390 == 1 {
  1513. insutype = "390"
  1514. }
  1515. if is310 == 1 {
  1516. insutype = "310"
  1517. }
  1518. if len(insutypes) == 0 {
  1519. insutype = "310"
  1520. }
  1521. //insutype = "390"
  1522. //if count == 1 {
  1523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1524. // return
  1525. //}
  1526. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1527. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1528. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1529. "&dept=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  1530. resp, requestErr := http.Get(api)
  1531. if requestErr != nil {
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. return
  1534. }
  1535. defer resp.Body.Close()
  1536. body, ioErr := ioutil.ReadAll(resp.Body)
  1537. if ioErr != nil {
  1538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1540. return
  1541. }
  1542. var respJSON map[string]interface{}
  1543. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1546. return
  1547. }
  1548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1549. userJSONBytes, _ := json.Marshal(respJSON)
  1550. var res ResultThree
  1551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. if res.Infcode != 0 {
  1557. adminUser := c.GetAdminUserInfo()
  1558. errlog := &models.HisOrderError{
  1559. UserOrgId: adminUser.CurrentOrgId,
  1560. Ctime: time.Now().Unix(),
  1561. Mtime: time.Now().Unix(),
  1562. ErrMsg: res.ErrMsg,
  1563. Status: 1,
  1564. PatientId: id,
  1565. RecordTime: recordDateTime,
  1566. Stage: 2,
  1567. }
  1568. service.CreateErrMsgLog(errlog)
  1569. c.ServeSuccessJSON(map[string]interface{}{
  1570. "failed_code": -10,
  1571. "msg": res.ErrMsg,
  1572. })
  1573. return
  1574. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1575. //return
  1576. }
  1577. his.Number = res.Output.Data.MdtrtID
  1578. his.PsnNo = res.Output.Data.PsnNo
  1579. his.IptOtpNo = res.Output.Data.IptOtpNo
  1580. his.IdCardNo = patient.IdCardNo
  1581. his.PhoneNumber = patient.Phone
  1582. his.UserOrgId = adminInfo.CurrentOrgId
  1583. his.Ctime = time.Now().Unix()
  1584. his.Mtime = time.Now().Unix()
  1585. his.Status = 1
  1586. service.UpdateHisPatientStatus(&his)
  1587. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1588. if len(lists) == 1 {
  1589. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1590. }
  1591. c.ServeSuccessJSON(map[string]interface{}{
  1592. "his_info": his,
  1593. })
  1594. } else {
  1595. adminUser := c.GetAdminUserInfo()
  1596. errlog := &models.HisOrderError{
  1597. UserOrgId: adminUser.CurrentOrgId,
  1598. Ctime: time.Now().Unix(),
  1599. Mtime: time.Now().Unix(),
  1600. ErrMsg: res.ErrMsg,
  1601. Status: 1,
  1602. PatientId: id,
  1603. RecordTime: recordDateTime,
  1604. Stage: 1,
  1605. }
  1606. service.CreateErrMsgLog(errlog)
  1607. c.ServeSuccessJSON(map[string]interface{}{
  1608. "failed_code": -10,
  1609. "msg": res.ErrMsg,
  1610. })
  1611. return
  1612. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1613. }
  1614. }
  1615. }
  1616. //上传明细----预结算----确认订单
  1617. func (c *HisApiController) GetUploadInfo() {
  1618. id, _ := c.GetInt64("id")
  1619. record_time := c.GetString("record_time")
  1620. his_patient_id, _ := c.GetInt64("his_patient_id")
  1621. order_id, _ := c.GetInt64("order_id")
  1622. pay_way, _ := c.GetInt64("pay_way")
  1623. pay_price, _ := c.GetFloat("pay_price")
  1624. pay_card_no := c.GetString("pay_card_no")
  1625. discount_price, _ := c.GetFloat("discount_price")
  1626. preferential_price, _ := c.GetFloat("preferential_price")
  1627. reality_price, _ := c.GetFloat("reality_price")
  1628. found_price, _ := c.GetFloat("found_price")
  1629. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1630. private_price, _ := c.GetFloat("private_price")
  1631. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1632. admin_user_id, _ := c.GetInt64("admin_user_id")
  1633. fapiao_code := c.GetString("fapiao_code")
  1634. fapiao_number := c.GetString("fapiao_number")
  1635. diagnosis_id := c.GetString("diagnosis")
  1636. sick_type, _ := c.GetInt64("sick_type")
  1637. reg_type, _ := c.GetInt64("p_type")
  1638. timeLayout := "2006-01-02"
  1639. loc, _ := time.LoadLocation("Local")
  1640. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1641. if err != nil {
  1642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1643. return
  1644. }
  1645. recordDateTime := theTime.Unix()
  1646. adminUser := c.GetAdminUserInfo()
  1647. tempOrder, _ := service.GetHisOrderByID(order_id)
  1648. var prescriptions []*models.HisPrescription
  1649. var start_time int64
  1650. var end_time int64
  1651. //if adminUser.CurrentOrgId == 10106{
  1652. // if len(fapiao_code) == 0{
  1653. // fapiao_code = "144072080589"
  1654. // }
  1655. // if len(fapiao_number) == 0{
  1656. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1657. // if order.ID == 0{
  1658. // fapiao_number = "00001520"
  1659. // }else{
  1660. // //fapiao_code = "00001520"
  1661. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1662. // var zero string
  1663. // if fpNumber >= 1000{
  1664. // zero = "0000" + strconv.Itoa(fpNumber)
  1665. // }else if fpNumber >= 10000{
  1666. // zero = "000" + strconv.Itoa(fpNumber)
  1667. // } else if fpNumber >= 100000{
  1668. // zero = "00" + strconv.Itoa(fpNumber)
  1669. // } else if fpNumber >= 1000000{
  1670. // zero = "0" + strconv.Itoa(fpNumber)
  1671. // }else {
  1672. // zero = strconv.Itoa(fpNumber)
  1673. // }
  1674. // fapiao_number = zero
  1675. // }
  1676. // }
  1677. //}
  1678. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1679. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1680. patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1681. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1682. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1683. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1684. var config []*models.HisXtDiagnoseConfig
  1685. for _, item := range diagnosis_ids {
  1686. id, _ := strconv.ParseInt(item, 10, 64)
  1687. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1688. config = append(config, diagnosisConfig)
  1689. }
  1690. sickConfig, _ := service.FindSickById(sick_type)
  1691. if tempOrder.ID == 0 {
  1692. var result string
  1693. if miConfig.InsuplcAdmdvs == "440781" { //
  1694. result = service.Gdyb2203A(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1695. } else {
  1696. result = service.Gdyb2203(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1697. }
  1698. var respJSON2 map[string]interface{}
  1699. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1702. return
  1703. }
  1704. userJSONBytes2, _ := json.Marshal(respJSON2)
  1705. var res2 ResultSix
  1706. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1707. utils.ErrorLog("解析失败:%v", err)
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1709. return
  1710. }
  1711. if res2.Infcode != 0 {
  1712. adminUser := c.GetAdminUserInfo()
  1713. errlog := &models.HisOrderError{
  1714. UserOrgId: adminUser.CurrentOrgId,
  1715. Ctime: time.Now().Unix(),
  1716. Mtime: time.Now().Unix(),
  1717. ErrMsg: res2.ErrMsg,
  1718. Status: 1,
  1719. PatientId: id,
  1720. RecordTime: recordDateTime,
  1721. Stage: 3,
  1722. }
  1723. service.CreateErrMsgLog(errlog)
  1724. c.ServeSuccessJSON(map[string]interface{}{
  1725. "failed_code": -10,
  1726. "msg": res2.ErrMsg,
  1727. })
  1728. return
  1729. } else {
  1730. his.Diagnosis = diagnosis_id
  1731. his.SickType = sickConfig.ID
  1732. his.PType = fmt.Sprintf("%d", reg_type)
  1733. service.UpdateHisPatientThree(&his)
  1734. data := make(map[string]interface{})
  1735. if settle_accounts_type == 1 { //日结
  1736. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  1737. data["pre"] = prescriptions
  1738. } else { //月结
  1739. start_time_str := c.GetString("start_time")
  1740. end_time_str := c.GetString("end_time")
  1741. timeLayout := "2006-01-02"
  1742. loc, _ := time.LoadLocation("Local")
  1743. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1744. if err != nil {
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1746. return
  1747. }
  1748. recordStartTime := theStartTime.Unix()
  1749. start_time = recordStartTime
  1750. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1751. if err != nil {
  1752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1753. return
  1754. }
  1755. recordEndTime := theEndTime.Unix()
  1756. end_time = recordEndTime
  1757. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  1758. data["pre"] = prescriptions
  1759. }
  1760. timestamp := time.Now().Unix()
  1761. tempTime := time.Unix(timestamp, 0)
  1762. timeFormat := tempTime.Format("20060102150405")
  1763. chrgBchno := rand.Intn(100000) + 10000
  1764. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1765. strconv.FormatInt(his.PatientId, 10)
  1766. client := &http.Client{}
  1767. data["psn_no"] = his.PsnNo
  1768. data["mdtrt_id"] = his.Number
  1769. data["chrg_bchno"] = chrg_bchno
  1770. data["org_name"] = miConfig.OrgName
  1771. data["doctor"] = roles.UserName
  1772. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1773. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1774. data["fixmedins_code"] = miConfig.Code
  1775. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1776. data["dept_code"] = "15"
  1777. } else {
  1778. data["dept_code"] = department.Number
  1779. }
  1780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1782. data["secret_key"] = miConfig.SecretKey
  1783. var ids []int64
  1784. for _, item := range prescriptions {
  1785. ids = append(ids, item.ID)
  1786. }
  1787. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1788. if config.IsOpen == 1 { //对接了医保,走医保流程
  1789. bytesData, _ := json.Marshal(data)
  1790. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1791. resp, _ := client.Do(req)
  1792. defer resp.Body.Close()
  1793. body, ioErr := ioutil.ReadAll(resp.Body)
  1794. if ioErr != nil {
  1795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1797. return
  1798. }
  1799. var respJSON map[string]interface{}
  1800. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1803. return
  1804. }
  1805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1806. userJSONBytes, _ := json.Marshal(respJSON)
  1807. var res ResultFour
  1808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1809. utils.ErrorLog("解析失败:%v", err)
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. return
  1812. }
  1813. if res.Infcode == 0 {
  1814. order := &models.HisOrder{
  1815. UserOrgId: adminUser.CurrentOrgId,
  1816. HisPatientId: his.ID,
  1817. PatientId: his.PatientId,
  1818. SettleAccountsDate: recordDateTime,
  1819. Ctime: time.Now().Unix(),
  1820. Mtime: time.Now().Unix(),
  1821. Status: 1,
  1822. Number: chrg_bchno,
  1823. Infcode: res.Infcode,
  1824. WarnMsg: res.WarnMsg,
  1825. Cainfo: res.Cainfo,
  1826. ErrMsg: res.ErrMsg,
  1827. RespondTime: res.RefmsgTime,
  1828. InfRefmsgid: res.InfRefmsgid,
  1829. OrderStatus: 1,
  1830. PayWay: pay_way,
  1831. PayPrice: pay_price,
  1832. PayCardNo: pay_card_no,
  1833. DiscountPrice: discount_price,
  1834. PreferentialPrice: preferential_price,
  1835. RealityPrice: reality_price,
  1836. FoundPrice: found_price,
  1837. MedicalInsurancePrice: medical_insurance_price,
  1838. PrivatePrice: private_price,
  1839. IsMedicineInsurance: 1,
  1840. SettleType: settle_accounts_type,
  1841. SettleStartTime: start_time,
  1842. SettleEndTime: end_time,
  1843. Creator: roles.AdminUserId,
  1844. Modify: roles.AdminUserId,
  1845. FaPiaoNumber: fapiao_number,
  1846. FaPiaoCode: fapiao_code,
  1847. PType: 2,
  1848. Diagnosis: diagnosis_id,
  1849. }
  1850. err = service.CreateOrder(order)
  1851. if err != nil {
  1852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1853. return
  1854. }
  1855. for _, item := range res.Output.Result {
  1856. temp := strings.Split(item.FeedetlSn, "-")
  1857. var advice_id int64 = 0
  1858. var project_id int64 = 0
  1859. var types int64 = 0
  1860. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1861. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1862. if temp[1] == "1" {
  1863. advice_id = id
  1864. project_id = 0
  1865. } else if temp[1] == "2" {
  1866. advice_id = 0
  1867. project_id = id
  1868. }
  1869. info := &models.HisOrderInfo{
  1870. OrderNumber: order.Number,
  1871. FeedetlSn: item.FeedetlSn,
  1872. UploadDate: time.Now().Unix(),
  1873. AdviceId: advice_id,
  1874. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1875. Cnt: item.Cnt,
  1876. Pric: float64(item.Pric),
  1877. PatientId: his.PatientId,
  1878. PricUplmtAmt: item.PricUplmtAmt,
  1879. SelfpayProp: item.SelfpayProp,
  1880. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1881. OverlmtAmt: item.OverlmtAmt,
  1882. PreselfpayAmt: item.PreselfpayAmt,
  1883. BasMednFlag: item.BasMednFlag,
  1884. MedChrgitmType: item.MedChrgitmType,
  1885. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1886. Status: 1,
  1887. Memo: item.Memo,
  1888. Mtime: time.Now().Unix(),
  1889. InscpScpAmt: item.InscpScpAmt,
  1890. DrtReimFlag: item.DrtReimFlag,
  1891. Ctime: time.Now().Unix(),
  1892. ListSpItemFlag: item.ListSpItemFlag,
  1893. ChldMedcFlag: item.ChldMedcFlag,
  1894. LmtUsedFlag: item.LmtUsedFlag,
  1895. ChrgitmLv: item.ChrgitmLv,
  1896. UserOrgId: adminUser.CurrentOrgId,
  1897. HisPatientId: his.ID,
  1898. OrderId: order.ID,
  1899. ProjectId: project_id,
  1900. Type: types,
  1901. }
  1902. service.CreateOrderInfo(info)
  1903. }
  1904. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1905. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  1906. var total float64
  1907. for _, item := range prescriptions {
  1908. if item.Type == 1 { //药品
  1909. for _, subItem := range item.HisDoctorAdviceInfo {
  1910. total = total + (subItem.Price * subItem.PrescribingNumber)
  1911. }
  1912. }
  1913. if item.Type == 2 { //项目
  1914. for _, subItem := range item.HisPrescriptionProject {
  1915. total = total + (subItem.Price * float64(subItem.Count))
  1916. }
  1917. }
  1918. }
  1919. for _, item := range prescriptions {
  1920. for _, subItem := range item.HisAdditionalCharge {
  1921. total = total + (subItem.Price * float64(subItem.Count))
  1922. }
  1923. }
  1924. allTotal := fmt.Sprintf("%.2f", total)
  1925. if res.Infcode == 0 {
  1926. var rf []*ResultFive
  1927. json.Unmarshal([]byte(his.Iinfo), &rf)
  1928. chrg_bchno := chrg_bchno
  1929. cert_no := his.Certno
  1930. var insutypes []string
  1931. var insutype string
  1932. var is390 int = 0
  1933. var is310 int = 0
  1934. for _, item := range rf {
  1935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1936. insutypes = append(insutypes, item.Insutype)
  1937. }
  1938. }
  1939. if len(insutypes) == 1 {
  1940. insutype = insutypes[0]
  1941. } else {
  1942. for _, i := range insutypes {
  1943. if i == "390" {
  1944. is390 = 1
  1945. }
  1946. if i == "310" {
  1947. is310 = 1
  1948. }
  1949. }
  1950. }
  1951. if is390 == 1 {
  1952. insutype = "390"
  1953. }
  1954. if is310 == 1 {
  1955. insutype = "310"
  1956. }
  1957. if len(insutypes) == 0 {
  1958. insutype = "310"
  1959. }
  1960. //insutype = "390"
  1961. if his.IdCardType == 1 {
  1962. cert_no = his.MedicalInsuranceNumber
  1963. } else {
  1964. cert_no = his.Certno
  1965. }
  1966. result, 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)
  1967. var dat map[string]interface{}
  1968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1969. fmt.Println(dat)
  1970. } else {
  1971. fmt.Println(err)
  1972. }
  1973. userJSONBytes, _ := json.Marshal(dat)
  1974. var res ResultSeven
  1975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1976. utils.ErrorLog("解析失败:%v", err)
  1977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1978. return
  1979. }
  1980. if res.Infcode != 0 {
  1981. errlog := &models.HisOrderError{
  1982. UserOrgId: adminUser.CurrentOrgId,
  1983. Ctime: time.Now().Unix(),
  1984. Mtime: time.Now().Unix(),
  1985. Number: chrg_bchno,
  1986. ErrMsg: res.ErrMsg,
  1987. Status: 1,
  1988. PatientId: id,
  1989. RecordTime: recordDateTime,
  1990. Stage: 6,
  1991. }
  1992. service.CreateErrMsgLog(errlog)
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "failed_code": -10,
  1995. "msg": res.ErrMsg,
  1996. })
  1997. return
  1998. } else {
  1999. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2000. order.OrderStatus = 2
  2001. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2002. order.SetlId = res.Output.Setlinfo.SetlID
  2003. order.PsnNo = res.Output.Setlinfo.PsnNo
  2004. order.PsnName = res.Output.Setlinfo.PsnName
  2005. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2006. order.Certno = res.Output.Setlinfo.Certno
  2007. order.Gend = res.Output.Setlinfo.Gend
  2008. order.Naty = res.Output.Setlinfo.Naty
  2009. order.Age = res.Output.Setlinfo.Age
  2010. order.Insutype = res.Output.Setlinfo.Insutype
  2011. order.PsnType = res.Output.Setlinfo.PsnType
  2012. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2013. order.SetlTime = res.Output.Setlinfo.SetlTime
  2014. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2015. order.MedType = res.Output.Setlinfo.MedType
  2016. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2017. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2018. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2019. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2020. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2021. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2022. order.HifpPay = res.Output.Setlinfo.HifpPay
  2023. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2024. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2025. order.HifesPay = res.Output.Setlinfo.HifesPay
  2026. order.HifobPay = res.Output.Setlinfo.HifobPay
  2027. order.MafPay = res.Output.Setlinfo.MafPay
  2028. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2029. order.OthPay = res.Output.Setlinfo.OthPay
  2030. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2031. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2032. order.AcctPay = res.Output.Setlinfo.AcctPay
  2033. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2034. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2035. order.Balc = res.Output.Setlinfo.Balc
  2036. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2037. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2038. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2039. order.ClrWay = res.Output.Setlinfo.ClrWay
  2040. order.Creator = order.Creator
  2041. order.Modify = roles.AdminUserId
  2042. order.RequestLog = src_resquest
  2043. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2044. detailStr := string(setlDetail)
  2045. order.SetlDetail = detailStr
  2046. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2047. err = service.UpDateOrder(order)
  2048. if err == nil {
  2049. c.ServeSuccessJSON(map[string]interface{}{
  2050. "msg": "结算成功",
  2051. })
  2052. } else {
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2054. return
  2055. }
  2056. }
  2057. } else {
  2058. adminUser := c.GetAdminUserInfo()
  2059. errlog := &models.HisOrderError{
  2060. UserOrgId: adminUser.CurrentOrgId,
  2061. Ctime: time.Now().Unix(),
  2062. Mtime: time.Now().Unix(),
  2063. ErrMsg: res.ErrMsg,
  2064. Status: 1,
  2065. PatientId: id,
  2066. RecordTime: recordDateTime,
  2067. Stage: 4,
  2068. }
  2069. service.CreateErrMsgLog(errlog)
  2070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2071. return
  2072. }
  2073. } else {
  2074. adminUser := c.GetAdminUserInfo()
  2075. errlog := &models.HisOrderError{
  2076. UserOrgId: adminUser.CurrentOrgId,
  2077. Ctime: time.Now().Unix(),
  2078. Mtime: time.Now().Unix(),
  2079. ErrMsg: res.ErrMsg,
  2080. Status: 1,
  2081. PatientId: id,
  2082. RecordTime: recordDateTime,
  2083. Stage: 4,
  2084. }
  2085. service.CreateErrMsgLog(errlog)
  2086. c.ServeSuccessJSON(map[string]interface{}{
  2087. "failed_code": -10,
  2088. "msg": res.ErrMsg,
  2089. })
  2090. return
  2091. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2092. //return
  2093. }
  2094. }
  2095. }
  2096. } else if tempOrder.ID > 0 {
  2097. if tempOrder.IsPre == 1 {
  2098. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  2099. var rf []*ResultFive
  2100. json.Unmarshal([]byte(his.Iinfo), &rf)
  2101. chrg_bchno := tempOrder.Number
  2102. cert_no := his.Certno
  2103. var insutypes []string
  2104. var insutype string
  2105. var is390 int = 0
  2106. var is310 int = 0
  2107. for _, item := range rf {
  2108. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2109. insutypes = append(insutypes, item.Insutype)
  2110. }
  2111. }
  2112. if len(insutypes) == 1 {
  2113. insutype = insutypes[0]
  2114. } else {
  2115. for _, i := range insutypes {
  2116. if i == "390" {
  2117. is390 = 1
  2118. }
  2119. if i == "310" {
  2120. is310 = 1
  2121. }
  2122. }
  2123. }
  2124. if is390 == 1 {
  2125. insutype = "390"
  2126. }
  2127. if is310 == 1 {
  2128. insutype = "310"
  2129. }
  2130. if len(insutypes) == 0 {
  2131. insutype = "310"
  2132. }
  2133. //insutype = "390"
  2134. if his.IdCardType == 1 {
  2135. cert_no = his.MedicalInsuranceNumber
  2136. } else {
  2137. cert_no = his.Certno
  2138. }
  2139. result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
  2140. var dat map[string]interface{}
  2141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2142. fmt.Println(dat)
  2143. } else {
  2144. fmt.Println(err)
  2145. }
  2146. userJSONBytes, _ := json.Marshal(dat)
  2147. var res ResultSeven
  2148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2149. utils.ErrorLog("解析失败:%v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. return
  2152. }
  2153. if res.Infcode != 0 {
  2154. errlog := &models.HisOrderError{
  2155. UserOrgId: adminUser.CurrentOrgId,
  2156. Ctime: time.Now().Unix(),
  2157. Mtime: time.Now().Unix(),
  2158. Number: chrg_bchno,
  2159. ErrMsg: res.ErrMsg,
  2160. Status: 1,
  2161. PatientId: id,
  2162. RecordTime: recordDateTime,
  2163. Stage: 6,
  2164. }
  2165. service.CreateErrMsgLog(errlog)
  2166. c.ServeSuccessJSON(map[string]interface{}{
  2167. "failed_code": -10,
  2168. "msg": res.ErrMsg,
  2169. })
  2170. return
  2171. } else {
  2172. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2173. order.OrderStatus = 2
  2174. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2175. order.SetlId = res.Output.Setlinfo.SetlID
  2176. order.PsnNo = res.Output.Setlinfo.PsnNo
  2177. order.PsnName = res.Output.Setlinfo.PsnName
  2178. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2179. order.Certno = res.Output.Setlinfo.Certno
  2180. order.Gend = res.Output.Setlinfo.Gend
  2181. order.Naty = res.Output.Setlinfo.Naty
  2182. order.Age = res.Output.Setlinfo.Age
  2183. order.Insutype = res.Output.Setlinfo.Insutype
  2184. order.PsnType = res.Output.Setlinfo.PsnType
  2185. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2186. order.SetlTime = res.Output.Setlinfo.SetlTime
  2187. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2188. order.MedType = res.Output.Setlinfo.MedType
  2189. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2190. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2191. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2192. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2193. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2194. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2195. order.HifpPay = res.Output.Setlinfo.HifpPay
  2196. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2197. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2198. order.HifesPay = res.Output.Setlinfo.HifesPay
  2199. order.HifobPay = res.Output.Setlinfo.HifobPay
  2200. order.MafPay = res.Output.Setlinfo.MafPay
  2201. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2202. order.OthPay = res.Output.Setlinfo.OthPay
  2203. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2204. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2205. order.AcctPay = res.Output.Setlinfo.AcctPay
  2206. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2207. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2208. order.Balc = res.Output.Setlinfo.Balc
  2209. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2210. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2211. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2212. order.ClrWay = res.Output.Setlinfo.ClrWay
  2213. order.Creator = order.Creator
  2214. order.Modify = roles.AdminUserId
  2215. order.RequestLog = src_resquest
  2216. order.Diagnosis = diagnosis_id
  2217. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2218. detailStr := string(setlDetail)
  2219. order.SetlDetail = detailStr
  2220. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2221. err = service.UpDateOrder(order)
  2222. if err == nil {
  2223. c.ServeSuccessJSON(map[string]interface{}{
  2224. "msg": "结算成功",
  2225. })
  2226. } else {
  2227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2228. return
  2229. }
  2230. }
  2231. }
  2232. }
  2233. }
  2234. //func (c *HisApiController) GetPreUploadInfo() {
  2235. // id, _ := c.GetInt64("id")
  2236. // record_time := c.GetString("record_time")
  2237. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2238. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2239. //
  2240. // timeLayout := "2006-01-02"
  2241. // loc, _ := time.LoadLocation("Local")
  2242. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2243. // if err != nil {
  2244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2245. // return
  2246. // }
  2247. // recordDateTime := theTime.Unix()
  2248. // adminUser := c.GetAdminUserInfo()
  2249. //
  2250. // var prescriptions []*models.HisPrescription
  2251. //
  2252. // var start_time int64
  2253. // var end_time int64
  2254. //
  2255. // data := make(map[string]interface{})
  2256. // if settle_accounts_type == 1 { //日结
  2257. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2258. // data["pre"] = prescriptions
  2259. //
  2260. // } else { //月结
  2261. // start_time_str := c.GetString("start_time")
  2262. // end_time_str := c.GetString("end_time")
  2263. // timeLayout := "2006-01-02"
  2264. // loc, _ := time.LoadLocation("Local")
  2265. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2266. // if err != nil {
  2267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2268. // return
  2269. // }
  2270. // recordStartTime := theStartTime.Unix()
  2271. // start_time = recordStartTime
  2272. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2273. // if err != nil {
  2274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2275. // return
  2276. // }
  2277. // recordEndTime := theEndTime.Unix()
  2278. // end_time = recordEndTime
  2279. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2280. // data["pre"] = prescriptions
  2281. //
  2282. // }
  2283. //
  2284. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2285. //
  2286. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2287. // timestamp := time.Now().Unix()
  2288. // tempTime := time.Unix(timestamp, 0)
  2289. // timeFormat := tempTime.Format("20060102150405")
  2290. // chrgBchno := rand.Intn(100000) + 10000
  2291. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2292. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2293. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2294. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2295. // strconv.FormatInt(his.PatientId, 10)
  2296. // client := &http.Client{}
  2297. // data["psn_no"] = his.PsnNo
  2298. // data["mdtrt_id"] = his.Number
  2299. // data["chrg_bchno"] = chrg_bchno
  2300. // data["org_name"] = miConfig.OrgName
  2301. // data["doctor"] = roles.UserName
  2302. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2303. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2304. // data["fixmedins_code"] = miConfig.Code
  2305. // data["dept_code"] = department.Number
  2306. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2307. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2308. // data["secret_key"] = miConfig.SecretKey
  2309. // var ids []int64
  2310. //
  2311. // for _, item := range prescriptions {
  2312. // ids = append(ids, item.ID)
  2313. // }
  2314. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2315. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2316. // bytesData, _ := json.Marshal(data)
  2317. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2318. // resp, _ := client.Do(req)
  2319. // defer resp.Body.Close()
  2320. // body, ioErr := ioutil.ReadAll(resp.Body)
  2321. // if ioErr != nil {
  2322. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2324. // return
  2325. // }
  2326. // var respJSON map[string]interface{}
  2327. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2328. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2330. // return
  2331. // }
  2332. //
  2333. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2334. // userJSONBytes, _ := json.Marshal(respJSON)
  2335. // var res ResultFour
  2336. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2337. // utils.ErrorLog("解析失败:%v", err)
  2338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2339. // return
  2340. // }
  2341. //
  2342. // if res.Infcode == 0 {
  2343. // order := &models.HisOrder{
  2344. // UserOrgId: adminUser.CurrentOrgId,
  2345. // HisPatientId: his.ID,
  2346. // PatientId: his.PatientId,
  2347. // SettleAccountsDate: recordDateTime,
  2348. // Ctime: time.Now().Unix(),
  2349. // Mtime: time.Now().Unix(),
  2350. // Status: 1,
  2351. // Number: chrg_bchno,
  2352. // Infcode: res.Infcode,
  2353. // WarnMsg: res.WarnMsg,
  2354. // Cainfo: res.Cainfo,
  2355. // ErrMsg: res.ErrMsg,
  2356. // RespondTime: res.RefmsgTime,
  2357. // InfRefmsgid: res.InfRefmsgid,
  2358. // OrderStatus: 1,
  2359. // IsMedicineInsurance: 1,
  2360. // SettleType: settle_accounts_type,
  2361. // SettleStartTime: start_time,
  2362. // SettleEndTime: end_time,
  2363. // Creator: roles.ID,
  2364. // Modify: roles.ID,
  2365. // PType: 2,
  2366. // }
  2367. // err = service.CreateOrder(order)
  2368. // if err != nil {
  2369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2370. // return
  2371. // }
  2372. //
  2373. // for _, item := range res.Output.Result {
  2374. // temp := strings.Split(item.FeedetlSn, "-")
  2375. // var advice_id int64 = 0
  2376. // var project_id int64 = 0
  2377. // var types int64 = 0
  2378. //
  2379. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2380. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2381. //
  2382. // if temp[1] == "1" {
  2383. // advice_id = id
  2384. // project_id = 0
  2385. // } else if temp[1] == "2" {
  2386. // advice_id = 0
  2387. // project_id = id
  2388. // }
  2389. //
  2390. // info := &models.HisOrderInfo{
  2391. // OrderNumber: order.Number,
  2392. // FeedetlSn: item.FeedetlSn,
  2393. // UploadDate: time.Now().Unix(),
  2394. // AdviceId: advice_id,
  2395. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  2396. // Cnt: item.Cnt,
  2397. // Pric: float64(item.Pric),
  2398. // PatientId: his.PatientId,
  2399. // PricUplmtAmt: item.PricUplmtAmt,
  2400. // SelfpayProp: item.SelfpayProp,
  2401. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2402. // OverlmtAmt: item.OverlmtAmt,
  2403. // PreselfpayAmt: item.PreselfpayAmt,
  2404. // BasMednFlag: item.BasMednFlag,
  2405. // MedChrgitmType: item.MedChrgitmType,
  2406. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  2407. // Status: 1,
  2408. // Memo: item.Memo,
  2409. // Mtime: time.Now().Unix(),
  2410. // InscpScpAmt: item.InscpScpAmt,
  2411. // DrtReimFlag: item.DrtReimFlag,
  2412. // Ctime: time.Now().Unix(),
  2413. // ListSpItemFlag: item.ListSpItemFlag,
  2414. // ChldMedcFlag: item.ChldMedcFlag,
  2415. // LmtUsedFlag: item.LmtUsedFlag,
  2416. // ChrgitmLv: item.ChrgitmLv,
  2417. // UserOrgId: adminUser.CurrentOrgId,
  2418. // HisPatientId: his.ID,
  2419. // OrderId: order.ID,
  2420. // ProjectId: project_id,
  2421. // Type: types,
  2422. // }
  2423. // service.CreateOrderInfo(info)
  2424. //
  2425. // }
  2426. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2427. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2428. //
  2429. // var total float64
  2430. // for _, item := range prescriptions {
  2431. // if item.Type == 1 { //药品
  2432. // for _, subItem := range item.HisDoctorAdviceInfo {
  2433. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2434. // }
  2435. // }
  2436. // if item.Type == 2 { //项目
  2437. // for _, subItem := range item.HisPrescriptionProject {
  2438. // total = total + (subItem.Price * float64(subItem.Count))
  2439. // }
  2440. // }
  2441. // }
  2442. //
  2443. // for _, item := range prescriptions {
  2444. // for _, subItem := range item.HisAdditionalCharge {
  2445. // total = total + (subItem.Price * float64(subItem.Count))
  2446. // }
  2447. // }
  2448. //
  2449. // allTotal := fmt.Sprintf("%.2f", total)
  2450. // if res.Infcode == 0 {
  2451. // var rf []*ResultFive
  2452. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2453. // psn_no := his.PsnNo
  2454. // mdtrt_id := his.Number
  2455. // chrg_bchno := chrg_bchno
  2456. // cert_no := his.Certno
  2457. // insutype := rf[0].Insutype
  2458. //
  2459. // if his.IdCardType == 1 {
  2460. // cert_no = his.MedicalInsuranceNumber
  2461. //
  2462. // } else {
  2463. //
  2464. // cert_no = his.Certno
  2465. //
  2466. // }
  2467. //
  2468. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2469. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2470. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2471. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2472. // resp, requestErr := http.Get(api)
  2473. // if requestErr != nil {
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // defer resp.Body.Close()
  2478. // body, ioErr := ioutil.ReadAll(resp.Body)
  2479. // if ioErr != nil {
  2480. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2482. // return
  2483. // }
  2484. // var respJSON map[string]interface{}
  2485. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2486. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2488. // return
  2489. // }
  2490. // fmt.Println(respJSON)
  2491. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2492. // userJSONBytes, _ := json.Marshal(respJSON)
  2493. // var res ResultSeven
  2494. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2495. // utils.ErrorLog("解析失败:%v", err)
  2496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2497. // return
  2498. // }
  2499. // if res.Infcode != 0 {
  2500. // errlog := &models.HisOrderError{
  2501. // UserOrgId: adminUser.CurrentOrgId,
  2502. // Ctime: time.Now().Unix(),
  2503. // Mtime: time.Now().Unix(),
  2504. // Number: chrg_bchno,
  2505. // ErrMsg: res.ErrMsg,
  2506. // Status: 1,
  2507. // PatientId: id,
  2508. // RecordTime: recordDateTime,
  2509. // Stage: 7,
  2510. // }
  2511. // service.CreateErrMsgLog(errlog)
  2512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2513. // return
  2514. // } else {
  2515. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2516. // order.OrderStatus = 1
  2517. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2518. // order.SetlId = res.Output.Setlinfo.SetlID
  2519. // order.PsnNo = res.Output.Setlinfo.PsnNo
  2520. // order.PsnName = res.Output.Setlinfo.PsnName
  2521. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2522. // order.Certno = res.Output.Setlinfo.Certno
  2523. // order.Gend = res.Output.Setlinfo.Gend
  2524. // order.Naty = res.Output.Setlinfo.Naty
  2525. // order.Age = res.Output.Setlinfo.Age
  2526. // order.Insutype = res.Output.Setlinfo.Insutype
  2527. // order.PsnType = res.Output.Setlinfo.PsnType
  2528. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2529. // order.SetlTime = res.Output.Setlinfo.SetlTime
  2530. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2531. // order.MedType = res.Output.Setlinfo.MedType
  2532. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2533. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2534. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2535. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2536. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2537. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2538. // order.HifpPay = res.Output.Setlinfo.HifpPay
  2539. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2540. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2541. // order.HifesPay = res.Output.Setlinfo.HifesPay
  2542. // order.HifobPay = res.Output.Setlinfo.HifobPay
  2543. // order.MafPay = res.Output.Setlinfo.MafPay
  2544. // order.OthPay = res.Output.Setlinfo.OthPay
  2545. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2546. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2547. // order.AcctPay = res.Output.Setlinfo.AcctPay
  2548. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2549. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2550. // order.Balc = res.Output.Setlinfo.Balc
  2551. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2552. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2553. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2554. // order.ClrWay = res.Output.Setlinfo.ClrWay
  2555. // order.Creator = order.Creator
  2556. // order.Modify = roles.ID
  2557. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2558. // detailStr := string(setlDetail)
  2559. // order.SetlDetail = detailStr
  2560. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2561. // err = service.UpDateOrder(order)
  2562. // if err == nil {
  2563. // c.ServeSuccessJSON(map[string]interface{}{
  2564. // "msg": "预结算成功",
  2565. // })
  2566. // } else {
  2567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2568. // return
  2569. // }
  2570. // }
  2571. // } else {
  2572. // adminUser := c.GetAdminUserInfo()
  2573. // errlog := &models.HisOrderError{
  2574. // UserOrgId: adminUser.CurrentOrgId,
  2575. // Ctime: time.Now().Unix(),
  2576. // Mtime: time.Now().Unix(),
  2577. // ErrMsg: res.ErrMsg,
  2578. // Status: 1,
  2579. // PatientId: id,
  2580. // RecordTime: recordDateTime,
  2581. // Stage: 4,
  2582. // }
  2583. // service.CreateErrMsgLog(errlog)
  2584. //
  2585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2586. // return
  2587. // }
  2588. // } else {
  2589. // adminUser := c.GetAdminUserInfo()
  2590. // errlog := &models.HisOrderError{
  2591. // UserOrgId: adminUser.CurrentOrgId,
  2592. // Ctime: time.Now().Unix(),
  2593. // Mtime: time.Now().Unix(),
  2594. // ErrMsg: res.ErrMsg,
  2595. // Status: 1,
  2596. // PatientId: id,
  2597. // RecordTime: recordDateTime,
  2598. // Stage: 4,
  2599. // }
  2600. // service.CreateErrMsgLog(errlog)
  2601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2602. // return
  2603. // }
  2604. //
  2605. // } else {
  2606. // var total float64
  2607. // for _, item := range prescriptions {
  2608. // if item.Type == 1 { //药品
  2609. // for _, subItem := range item.HisDoctorAdviceInfo {
  2610. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2611. // }
  2612. // }
  2613. // if item.Type == 2 { //项目
  2614. // for _, subItem := range item.HisPrescriptionProject {
  2615. // total = total + (subItem.Price * float64(subItem.Count))
  2616. // }
  2617. // }
  2618. //
  2619. // for _, subItem := range item.HisAdditionalCharge {
  2620. // total = total + (subItem.Price * float64(subItem.Count))
  2621. // }
  2622. // }
  2623. //
  2624. // allTotal := fmt.Sprintf("%.2f", total)
  2625. // totals, _ := strconv.ParseFloat(allTotal, 64)
  2626. // order := &models.HisOrder{
  2627. // UserOrgId: adminUser.CurrentOrgId,
  2628. // HisPatientId: his.ID,
  2629. // PatientId: id,
  2630. // SettleAccountsDate: recordDateTime,
  2631. // Ctime: time.Now().Unix(),
  2632. // Mtime: time.Now().Unix(),
  2633. // Status: 1,
  2634. // OrderStatus: 2,
  2635. // Number: chrg_bchno,
  2636. // MedfeeSumamt: totals,
  2637. // }
  2638. // err = service.CreateOrder(order)
  2639. // if err != nil {
  2640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2641. // return
  2642. // }
  2643. //
  2644. // var customs []*Custom
  2645. // for _, item := range prescriptions {
  2646. //
  2647. // if item.Type == 1 { //药品
  2648. // for _, subItem := range item.HisDoctorAdviceInfo {
  2649. // cus := &Custom{
  2650. // AdviceId: subItem.ID,
  2651. // ProjectId: 0,
  2652. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2653. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2654. // FeedetlSn: subItem.FeedetlSn,
  2655. // Price: fmt.Sprintf("%.2f", subItem.Price),
  2656. // MedListCodg: subItem.MedListCodg,
  2657. // Type: 1,
  2658. // }
  2659. // customs = append(customs, cus)
  2660. // }
  2661. // }
  2662. //
  2663. // if item.Type == 2 { //项目
  2664. // for _, subItem := range item.HisPrescriptionProject {
  2665. //
  2666. // cus := &Custom{
  2667. // AdviceId: 0,
  2668. // ProjectId: subItem.ID,
  2669. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2670. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2671. // FeedetlSn: subItem.FeedetlSn,
  2672. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2673. // MedListCodg: subItem.MedListCodg,
  2674. // Type: 2,
  2675. // }
  2676. //
  2677. // customs = append(customs, cus)
  2678. // }
  2679. // }
  2680. //
  2681. // for _, item := range item.HisAdditionalCharge {
  2682. // cus := &Custom{
  2683. // ItemId: item.ID,
  2684. // AdviceId: 0,
  2685. // ProjectId: 0,
  2686. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2687. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2688. // FeedetlSn: item.FeedetlSn,
  2689. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2690. // MedListCodg: item.XtHisAddtionConfig.Code,
  2691. // Type: 3,
  2692. // }
  2693. //
  2694. // customs = append(customs, cus)
  2695. // }
  2696. //
  2697. // }
  2698. //
  2699. // for _, item := range customs {
  2700. // var advice_id int64 = 0
  2701. // var project_id int64 = 0
  2702. // var item_id int64 = 0
  2703. //
  2704. // var types int64 = 0
  2705. //
  2706. // if item.Type == 1 {
  2707. // advice_id = item.AdviceId
  2708. // project_id = 0
  2709. // item_id = 0
  2710. // } else if item.Type == 2 {
  2711. // advice_id = 0
  2712. // item_id = 0
  2713. //
  2714. // project_id = item.ProjectId
  2715. // } else if item.Type == 3 {
  2716. // advice_id = 0
  2717. // item_id = item.ItemId
  2718. // project_id = 0
  2719. // }
  2720. //
  2721. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2722. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  2723. // pric, _ := strconv.ParseFloat(item.Price, 32)
  2724. //
  2725. // info := &models.HisOrderInfo{
  2726. // OrderNumber: order.Number,
  2727. // UploadDate: time.Now().Unix(),
  2728. // AdviceId: advice_id,
  2729. // DetItemFeeSumamt: detItemFeeSumamt,
  2730. // Cnt: cut,
  2731. // Pric: pric,
  2732. // PatientId: id,
  2733. // Status: 1,
  2734. // Mtime: time.Now().Unix(),
  2735. // Ctime: time.Now().Unix(),
  2736. // UserOrgId: adminUser.CurrentOrgId,
  2737. // HisPatientId: his.ID,
  2738. // OrderId: order.ID,
  2739. // ProjectId: project_id,
  2740. // Type: types,
  2741. // ItemId: item_id,
  2742. // }
  2743. // service.CreateOrderInfo(info)
  2744. // }
  2745. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2746. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2747. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2748. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2749. // if err == nil {
  2750. // c.ServeSuccessJSON(map[string]interface{}{
  2751. // "msg": "结算成功",
  2752. // })
  2753. // } else {
  2754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2755. // return
  2756. // }
  2757. // }
  2758. //}
  2759. //上传明细-预结算-
  2760. func (c *HisApiController) GetPreUploadInfo() {
  2761. id, _ := c.GetInt64("id")
  2762. record_time := c.GetString("record_time")
  2763. his_patient_id, _ := c.GetInt64("his_patient_id")
  2764. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2765. admin_user_id, _ := c.GetInt64("admin_user_id")
  2766. diagnosis_id := c.GetString("diagnosis")
  2767. sick_type, _ := c.GetInt64("sick_type")
  2768. reg_type, _ := c.GetInt64("p_type")
  2769. timeLayout := "2006-01-02"
  2770. loc, _ := time.LoadLocation("Local")
  2771. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2772. if err != nil {
  2773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2774. return
  2775. }
  2776. recordDateTime := theTime.Unix()
  2777. adminUser := c.GetAdminUserInfo()
  2778. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2779. var config []*models.HisXtDiagnoseConfig
  2780. for _, item := range diagnosis_ids {
  2781. id, _ := strconv.ParseInt(item, 10, 64)
  2782. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2783. config = append(config, diagnosisConfig)
  2784. }
  2785. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2786. sickConfig, _ := service.FindSickById(sick_type)
  2787. var prescriptions []*models.HisPrescription
  2788. var start_time int64
  2789. var end_time int64
  2790. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2791. fmt.Println(his_patient_id)
  2792. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2793. timestamp := time.Now().Unix()
  2794. tempTime := time.Unix(timestamp, 0)
  2795. timeFormat := tempTime.Format("20060102150405")
  2796. chrgBchno := rand.Intn(100000) + 10000
  2797. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2798. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2799. patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2800. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2801. strconv.FormatInt(his.PatientId, 10)
  2802. var result string
  2803. if miConfig.InsuplcAdmdvs == "440781" { //
  2804. result = service.Gdyb2203A(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2805. } else {
  2806. result = service.Gdyb2203(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2807. }
  2808. var respJSON2 map[string]interface{}
  2809. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2812. return
  2813. }
  2814. userJSONBytes2, _ := json.Marshal(respJSON2)
  2815. var res2 ResultSix
  2816. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2817. utils.ErrorLog("解析失败:%v", err)
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. return
  2820. }
  2821. if res2.Infcode != 0 {
  2822. adminUser := c.GetAdminUserInfo()
  2823. errlog := &models.HisOrderError{
  2824. UserOrgId: adminUser.CurrentOrgId,
  2825. Ctime: time.Now().Unix(),
  2826. Mtime: time.Now().Unix(),
  2827. ErrMsg: res2.ErrMsg,
  2828. Status: 1,
  2829. PatientId: id,
  2830. RecordTime: recordDateTime,
  2831. Stage: 3,
  2832. }
  2833. service.CreateErrMsgLog(errlog)
  2834. c.ServeSuccessJSON(map[string]interface{}{
  2835. "failed_code": -10,
  2836. "msg": res2.ErrMsg,
  2837. })
  2838. return
  2839. } else {
  2840. his.Diagnosis = diagnosis_id
  2841. his.SickType = sickConfig.ID
  2842. his.PType = fmt.Sprintf("%d", reg_type)
  2843. service.UpdateHisPatientThree(&his)
  2844. data := make(map[string]interface{})
  2845. if settle_accounts_type == 1 { //日结
  2846. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  2847. data["pre"] = prescriptions
  2848. } else { //月结
  2849. start_time_str := c.GetString("start_time")
  2850. end_time_str := c.GetString("end_time")
  2851. timeLayout := "2006-01-02"
  2852. loc, _ := time.LoadLocation("Local")
  2853. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2854. if err != nil {
  2855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2856. return
  2857. }
  2858. recordStartTime := theStartTime.Unix()
  2859. start_time = recordStartTime
  2860. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2861. if err != nil {
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2863. return
  2864. }
  2865. recordEndTime := theEndTime.Unix()
  2866. end_time = recordEndTime
  2867. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  2868. data["pre"] = prescriptions
  2869. }
  2870. client := &http.Client{}
  2871. data["psn_no"] = his.PsnNo
  2872. data["mdtrt_id"] = his.Number
  2873. data["chrg_bchno"] = chrg_bchno
  2874. data["org_name"] = miConfig.OrgName
  2875. data["doctor"] = roles.UserName
  2876. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2877. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2878. data["fixmedins_code"] = miConfig.Code
  2879. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  2880. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  2881. data["dept_code"] = "15"
  2882. } else {
  2883. data["dept_code"] = department.Number
  2884. }
  2885. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2886. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2887. data["secret_key"] = miConfig.SecretKey
  2888. var ids []int64
  2889. for _, item := range prescriptions {
  2890. ids = append(ids, item.ID)
  2891. }
  2892. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2893. if config.IsOpen == 1 { //对接了医保,走医保流程
  2894. bytesData, _ := json.Marshal(data)
  2895. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2896. resp, _ := client.Do(req)
  2897. defer resp.Body.Close()
  2898. body, ioErr := ioutil.ReadAll(resp.Body)
  2899. if ioErr != nil {
  2900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. var respJSON map[string]interface{}
  2905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2908. return
  2909. }
  2910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2911. userJSONBytes, _ := json.Marshal(respJSON)
  2912. var res ResultFour
  2913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res.Infcode == 0 {
  2919. order := &models.HisOrder{
  2920. UserOrgId: adminUser.CurrentOrgId,
  2921. HisPatientId: his.ID,
  2922. PatientId: his.PatientId,
  2923. SettleAccountsDate: recordDateTime,
  2924. Ctime: time.Now().Unix(),
  2925. Mtime: time.Now().Unix(),
  2926. Status: 1,
  2927. Number: chrg_bchno,
  2928. Infcode: res.Infcode,
  2929. WarnMsg: res.WarnMsg,
  2930. Cainfo: res.Cainfo,
  2931. ErrMsg: res.ErrMsg,
  2932. RespondTime: res.RefmsgTime,
  2933. InfRefmsgid: res.InfRefmsgid,
  2934. OrderStatus: 1,
  2935. IsMedicineInsurance: 1,
  2936. SettleType: settle_accounts_type,
  2937. SettleStartTime: start_time,
  2938. SettleEndTime: end_time,
  2939. Creator: roles.AdminUserId,
  2940. Modify: roles.AdminUserId,
  2941. PType: 2,
  2942. Diagnosis: diagnosis_id,
  2943. }
  2944. err = service.CreateOrder(order)
  2945. if err != nil {
  2946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2947. return
  2948. }
  2949. for _, item := range res.Output.Result {
  2950. temp := strings.Split(item.FeedetlSn, "-")
  2951. var advice_id int64 = 0
  2952. var project_id int64 = 0
  2953. var types int64 = 0
  2954. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2955. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2956. if temp[1] == "1" {
  2957. advice_id = id
  2958. project_id = 0
  2959. } else if temp[1] == "2" {
  2960. advice_id = 0
  2961. project_id = id
  2962. }
  2963. info := &models.HisOrderInfo{
  2964. OrderNumber: order.Number,
  2965. FeedetlSn: item.FeedetlSn,
  2966. UploadDate: time.Now().Unix(),
  2967. AdviceId: advice_id,
  2968. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2969. Cnt: item.Cnt,
  2970. Pric: float64(item.Pric),
  2971. PatientId: his.PatientId,
  2972. PricUplmtAmt: item.PricUplmtAmt,
  2973. SelfpayProp: item.SelfpayProp,
  2974. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2975. OverlmtAmt: item.OverlmtAmt,
  2976. PreselfpayAmt: item.PreselfpayAmt,
  2977. BasMednFlag: item.BasMednFlag,
  2978. MedChrgitmType: item.MedChrgitmType,
  2979. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2980. Status: 1,
  2981. Memo: item.Memo,
  2982. Mtime: time.Now().Unix(),
  2983. InscpScpAmt: item.InscpScpAmt,
  2984. DrtReimFlag: item.DrtReimFlag,
  2985. Ctime: time.Now().Unix(),
  2986. ListSpItemFlag: item.ListSpItemFlag,
  2987. ChldMedcFlag: item.ChldMedcFlag,
  2988. LmtUsedFlag: item.LmtUsedFlag,
  2989. ChrgitmLv: item.ChrgitmLv,
  2990. UserOrgId: adminUser.CurrentOrgId,
  2991. HisPatientId: his.ID,
  2992. OrderId: order.ID,
  2993. ProjectId: project_id,
  2994. Type: types,
  2995. }
  2996. service.CreateOrderInfo(info)
  2997. }
  2998. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2999. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3000. var total float64
  3001. for _, item := range prescriptions {
  3002. if item.Type == 1 { //药品
  3003. for _, subItem := range item.HisDoctorAdviceInfo {
  3004. total = total + (subItem.Price * subItem.PrescribingNumber)
  3005. }
  3006. }
  3007. if item.Type == 2 { //项目
  3008. for _, subItem := range item.HisPrescriptionProject {
  3009. total = total + (subItem.Price * float64(subItem.Count))
  3010. }
  3011. }
  3012. }
  3013. for _, item := range prescriptions {
  3014. for _, subItem := range item.HisAdditionalCharge {
  3015. total = total + (subItem.Price * float64(subItem.Count))
  3016. }
  3017. }
  3018. allTotal := fmt.Sprintf("%.2f", total)
  3019. if res.Infcode == 0 {
  3020. var rf []*ResultFive
  3021. json.Unmarshal([]byte(his.Iinfo), &rf)
  3022. chrg_bchno := chrg_bchno
  3023. cert_no := his.Certno
  3024. var insutypes []string
  3025. var insutype string
  3026. var is390 int = 0
  3027. var is310 int = 0
  3028. for _, item := range rf {
  3029. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3030. insutypes = append(insutypes, item.Insutype)
  3031. }
  3032. }
  3033. if len(insutypes) == 1 {
  3034. insutype = insutypes[0]
  3035. } else {
  3036. for _, i := range insutypes {
  3037. if i == "390" {
  3038. is390 = 1
  3039. }
  3040. if i == "310" {
  3041. is310 = 1
  3042. }
  3043. }
  3044. }
  3045. if is390 == 1 {
  3046. insutype = "390"
  3047. }
  3048. if is310 == 1 {
  3049. insutype = "310"
  3050. }
  3051. if len(insutypes) == 0 {
  3052. insutype = "310"
  3053. }
  3054. //insutype = "390"
  3055. if his.IdCardType == 1 {
  3056. cert_no = his.MedicalInsuranceNumber
  3057. } else {
  3058. cert_no = his.Certno
  3059. }
  3060. result := service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  3061. var dat map[string]interface{}
  3062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3063. fmt.Println(dat)
  3064. } else {
  3065. fmt.Println(err)
  3066. }
  3067. userJSONBytes, _ := json.Marshal(dat)
  3068. var res ResultSeven
  3069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3070. utils.ErrorLog("解析失败:%v", err)
  3071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3072. return
  3073. }
  3074. if res.Infcode != 0 {
  3075. errlog := &models.HisOrderError{
  3076. UserOrgId: adminUser.CurrentOrgId,
  3077. Ctime: time.Now().Unix(),
  3078. Mtime: time.Now().Unix(),
  3079. Number: chrg_bchno,
  3080. ErrMsg: res.ErrMsg,
  3081. Status: 1,
  3082. PatientId: id,
  3083. RecordTime: recordDateTime,
  3084. Stage: 20,
  3085. }
  3086. service.CreateErrMsgLog(errlog)
  3087. c.ServeSuccessJSON(map[string]interface{}{
  3088. "failed_code": -10,
  3089. "msg": res.ErrMsg,
  3090. })
  3091. return
  3092. } else {
  3093. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3094. order.OrderStatus = 1
  3095. order.IsPre = 1
  3096. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3097. order.SetlId = res.Output.Setlinfo.SetlID
  3098. order.PsnNo = res.Output.Setlinfo.PsnNo
  3099. order.PsnName = res.Output.Setlinfo.PsnName
  3100. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3101. order.Certno = res.Output.Setlinfo.Certno
  3102. order.Gend = res.Output.Setlinfo.Gend
  3103. order.Naty = res.Output.Setlinfo.Naty
  3104. order.Age = res.Output.Setlinfo.Age
  3105. order.Insutype = res.Output.Setlinfo.Insutype
  3106. order.PsnType = res.Output.Setlinfo.PsnType
  3107. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3108. order.SetlTime = res.Output.Setlinfo.SetlTime
  3109. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3110. order.MedType = res.Output.Setlinfo.MedType
  3111. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3112. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3113. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3114. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3115. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3116. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3117. order.HifpPay = res.Output.Setlinfo.HifpPay
  3118. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3119. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3120. order.HifesPay = res.Output.Setlinfo.HifesPay
  3121. order.HifobPay = res.Output.Setlinfo.HifobPay
  3122. order.MafPay = res.Output.Setlinfo.MafPay
  3123. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3124. order.OthPay = res.Output.Setlinfo.OthPay
  3125. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3126. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3127. order.AcctPay = res.Output.Setlinfo.AcctPay
  3128. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3129. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3130. order.Balc = res.Output.Setlinfo.Balc
  3131. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3132. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3133. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3134. order.ClrWay = res.Output.Setlinfo.ClrWay
  3135. order.Creator = order.Creator
  3136. order.Modify = roles.AdminUserId
  3137. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3138. detailStr := string(setlDetail)
  3139. order.SetlDetail = detailStr
  3140. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3141. err = service.UpDateOrder(order)
  3142. if err == nil {
  3143. c.ServeSuccessJSON(map[string]interface{}{
  3144. "msg": "预结算成功",
  3145. })
  3146. } else {
  3147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3148. return
  3149. }
  3150. }
  3151. } else {
  3152. adminUser := c.GetAdminUserInfo()
  3153. errlog := &models.HisOrderError{
  3154. UserOrgId: adminUser.CurrentOrgId,
  3155. Ctime: time.Now().Unix(),
  3156. Mtime: time.Now().Unix(),
  3157. ErrMsg: res.ErrMsg,
  3158. Status: 1,
  3159. PatientId: id,
  3160. RecordTime: recordDateTime,
  3161. Stage: 4,
  3162. }
  3163. service.CreateErrMsgLog(errlog)
  3164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3165. return
  3166. }
  3167. } else {
  3168. adminUser := c.GetAdminUserInfo()
  3169. errlog := &models.HisOrderError{
  3170. UserOrgId: adminUser.CurrentOrgId,
  3171. Ctime: time.Now().Unix(),
  3172. Mtime: time.Now().Unix(),
  3173. ErrMsg: res.ErrMsg,
  3174. Status: 1,
  3175. PatientId: id,
  3176. RecordTime: recordDateTime,
  3177. Stage: 4,
  3178. }
  3179. service.CreateErrMsgLog(errlog)
  3180. c.ServeSuccessJSON(map[string]interface{}{
  3181. "failed_code": -10,
  3182. "msg": res.ErrMsg,
  3183. })
  3184. return
  3185. }
  3186. }
  3187. }
  3188. }
  3189. //func (c *HisApiController) GetSettleInfo() {
  3190. // id, _ := c.GetInt64("id")
  3191. // order_id, _ := c.GetInt64("order_id")
  3192. //
  3193. // record_time := c.GetString("record_time")
  3194. // pay_way, _ := c.GetInt64("pay_way")
  3195. // pay_price, _ := c.GetFloat("pay_price")
  3196. // pay_card_no := c.GetString("pay_card_no")
  3197. // discount_price, _ := c.GetFloat("discount_price")
  3198. // preferential_price, _ := c.GetFloat("preferential_price")
  3199. // reality_price, _ := c.GetFloat("reality_price")
  3200. // found_price, _ := c.GetFloat("found_price")
  3201. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3202. // private_price, _ := c.GetFloat("private_price")
  3203. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3204. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3205. //
  3206. // timeLayout := "2006-01-02"
  3207. // loc, _ := time.LoadLocation("Local")
  3208. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3209. // if err != nil {
  3210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3211. // return
  3212. // }
  3213. // recordDateTime := theTime.Unix()
  3214. // adminUser := c.GetAdminUserInfo()
  3215. //
  3216. // var prescriptions []*models.HisPrescription
  3217. //
  3218. // data := make(map[string]interface{})
  3219. // if settle_accounts_type == 1 { //日结
  3220. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3221. // data["pre"] = prescriptions
  3222. //
  3223. // } else { //月结
  3224. // start_time_str := c.GetString("start_time")
  3225. // end_time_str := c.GetString("end_time")
  3226. // timeLayout := "2006-01-02"
  3227. // loc, _ := time.LoadLocation("Local")
  3228. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3229. // if err != nil {
  3230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3231. // return
  3232. // }
  3233. // recordStartTime := theStartTime.Unix()
  3234. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3235. // if err != nil {
  3236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3237. // return
  3238. // }
  3239. // recordEndTime := theEndTime.Unix()
  3240. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3241. // data["pre"] = prescriptions
  3242. //
  3243. // }
  3244. //
  3245. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3246. //
  3247. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3248. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3249. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3250. // strconv.FormatInt(his.PatientId, 10)
  3251. //
  3252. // order_src, _ := service.GetHisOrderByID(order_id)
  3253. //
  3254. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3255. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3256. //
  3257. // var total float64
  3258. // for _, item := range prescriptions {
  3259. // if item.Type == 1 { //药品
  3260. // for _, subItem := range item.HisDoctorAdviceInfo {
  3261. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3262. // }
  3263. // }
  3264. // if item.Type == 2 { //项目
  3265. // for _, subItem := range item.HisPrescriptionProject {
  3266. // total = total + (subItem.Price * float64(subItem.Count))
  3267. // }
  3268. // }
  3269. // }
  3270. //
  3271. // for _, item := range prescriptions {
  3272. // for _, subItem := range item.HisAdditionalCharge {
  3273. // total = total + (subItem.Price * float64(subItem.Count))
  3274. // }
  3275. // }
  3276. //
  3277. // allTotal := fmt.Sprintf("%.2f", total)
  3278. // var rf []*ResultFive
  3279. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3280. // psn_no := order_src.PsnNo
  3281. // mdtrt_id := order_src.MdtrtId
  3282. // chrg_bchno := order_src.Number
  3283. // cert_no := order_src.Certno
  3284. // insutype := rf[0].Insutype
  3285. //
  3286. // if his.IdCardType == 1 {
  3287. // cert_no = his.MedicalInsuranceNumber
  3288. // } else {
  3289. // cert_no = his.Certno
  3290. // }
  3291. //
  3292. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  3293. // var dat map[string]interface{}
  3294. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3295. // fmt.Println(dat)
  3296. // } else {
  3297. // fmt.Println(err)
  3298. // }
  3299. //
  3300. // userJSONBytes, _ := json.Marshal(dat)
  3301. //
  3302. //
  3303. //
  3304. // var res ResultSeven
  3305. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3306. // utils.ErrorLog("解析失败:%v", err)
  3307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. // return
  3309. // }
  3310. // if res.Infcode == -1 {
  3311. // errlog := &models.HisOrderError{
  3312. // UserOrgId: adminUser.CurrentOrgId,
  3313. // Ctime: time.Now().Unix(),
  3314. // Mtime: time.Now().Unix(),
  3315. // Number: chrg_bchno,
  3316. // ErrMsg: res.ErrMsg,
  3317. // Status: 1,
  3318. // PatientId: id,
  3319. // RecordTime: recordDateTime,
  3320. // Stage: 6,
  3321. // }
  3322. // service.CreateErrMsgLog(errlog)
  3323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3324. // return
  3325. // } else {
  3326. // order_src.OrderStatus = 2
  3327. // order_src.PayWay = pay_way
  3328. // order_src.PayPrice = pay_price
  3329. // order_src.PayCardNo = pay_card_no
  3330. // order_src.DiscountPrice = discount_price
  3331. // order_src.PreferentialPrice = preferential_price
  3332. // order_src.RealityPrice = reality_price
  3333. // order_src.FoundPrice = found_price
  3334. // order_src.MedicalInsurancePrice = medical_insurance_price
  3335. // order_src.PrivatePrice = private_price
  3336. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  3337. // order_src.SetlId = res.Output.Setlinfo.SetlID
  3338. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  3339. // order_src.PsnName = res.Output.Setlinfo.PsnName
  3340. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  3341. // order_src.Certno = res.Output.Setlinfo.Certno
  3342. // order_src.Gend = res.Output.Setlinfo.Gend
  3343. // order_src.Naty = res.Output.Setlinfo.Naty
  3344. // order_src.Age = res.Output.Setlinfo.Age
  3345. // order_src.Insutype = res.Output.Setlinfo.Insutype
  3346. // order_src.PsnType = res.Output.Setlinfo.PsnType
  3347. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3348. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  3349. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3350. // order_src.MedType = res.Output.Setlinfo.MedType
  3351. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3352. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3353. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3354. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3355. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3356. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3357. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  3358. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  3359. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3360. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  3361. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  3362. // order_src.MafPay = res.Output.Setlinfo.MafPay
  3363. // order_src.OthPay = res.Output.Setlinfo.OthPay
  3364. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3365. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3366. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  3367. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3368. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3369. // order_src.Balc = res.Output.Setlinfo.Balc
  3370. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3371. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3372. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  3373. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  3374. // order_src.Creator = order_src.Creator
  3375. // order_src.Modify = roles.ID
  3376. // order_src.RequestLog = src_resquest
  3377. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3378. // detailStr := string(setlDetail)
  3379. // order_src.SetlDetail = detailStr
  3380. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3381. // err = service.UpDateOrder(order_src)
  3382. //
  3383. // if err == nil {
  3384. // c.ServeSuccessJSON(map[string]interface{}{
  3385. // "msg": "结算成功",
  3386. // })
  3387. // } else {
  3388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3389. // return
  3390. // }
  3391. // }
  3392. // }
  3393. //}
  3394. //退款
  3395. func (c *HisApiController) Refund() {
  3396. order_id, _ := c.GetInt64("order_id")
  3397. admin_user_id, _ := c.GetInt64("admin_user_id")
  3398. //record_time := c.GetString("record_time")
  3399. //patient_id, _ := c.GetInt64("patient_id")
  3400. //timeLayout := "2006-01-02"
  3401. //loc, _ := time.LoadLocation("Local")
  3402. adminUser := c.GetAdminUserInfo()
  3403. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3404. //if err != nil {
  3405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3406. // return
  3407. //}
  3408. //recordDateTime := theTime.Unix()
  3409. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3410. var order models.HisOrder
  3411. order, _ = service.GetHisOrderByID(order_id)
  3412. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3413. if order.ID == 0 {
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3415. return
  3416. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3417. }
  3418. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3419. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3420. if config.IsOpen == 1 { //对接了医保,走医保流程
  3421. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3422. var dat map[string]interface{}
  3423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3424. fmt.Println(dat)
  3425. } else {
  3426. fmt.Println(err)
  3427. }
  3428. userJSONBytes, _ := json.Marshal(dat)
  3429. var res ResultSixteen
  3430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3431. utils.ErrorLog("解析失败:%v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. if res.Infcode == 0 {
  3436. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  3437. var dat map[string]interface{}
  3438. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3439. fmt.Println(dat)
  3440. } else {
  3441. fmt.Println(err)
  3442. }
  3443. userJSONBytes, _ := json.Marshal(dat)
  3444. var res2 ResultSix
  3445. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3446. utils.ErrorLog("解析失败:%v", err)
  3447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3448. return
  3449. }
  3450. if res2.Infcode == 0 {
  3451. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  3452. if err == nil {
  3453. c.ServeSuccessJSON(map[string]interface{}{
  3454. "msg": "退费成功",
  3455. })
  3456. } else {
  3457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3458. return
  3459. }
  3460. } else {
  3461. c.ServeSuccessJSON(map[string]interface{}{
  3462. "code": -10,
  3463. "msg": res2.ErrMsg,
  3464. })
  3465. }
  3466. } else {
  3467. c.ServeSuccessJSON(map[string]interface{}{
  3468. "code": -10,
  3469. "msg": res.ErrMsg,
  3470. })
  3471. }
  3472. }
  3473. }
  3474. func (c *HisApiController) RefundNumber() {
  3475. record_time := c.GetString("record_time")
  3476. //patient_id, _ := c.GetInt64("patient_id")
  3477. admin_user_id, _ := c.GetInt64("admin_user_id")
  3478. his_patient_id, _ := c.GetInt64("id")
  3479. timeLayout := "2006-01-02"
  3480. loc, _ := time.LoadLocation("Local")
  3481. adminUser := c.GetAdminUserInfo()
  3482. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3483. fmt.Println(err)
  3484. if err != nil {
  3485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3486. return
  3487. }
  3488. recordDateTime := theTime.Unix()
  3489. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3490. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  3491. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3492. //order, _ := service.GetHisOrderByID(order_id)
  3493. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3494. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3495. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3496. if config.IsOpen == 1 { //对接了医保,走医保流程
  3497. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  3498. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3499. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3500. resp3, requestErr3 := http.Get(api3)
  3501. if requestErr3 != nil {
  3502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3503. return
  3504. }
  3505. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  3506. if ioErr3 != nil {
  3507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  3508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3509. return
  3510. }
  3511. var respJSON3 map[string]interface{}
  3512. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  3513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3515. return
  3516. }
  3517. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3518. userJSONBytes3, _ := json.Marshal(respJSON3)
  3519. var res2 ResultSix
  3520. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3521. utils.ErrorLog("解析失败:%v", err)
  3522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3523. return
  3524. }
  3525. if res2.Infcode == 0 {
  3526. if err == nil {
  3527. c.ServeSuccessJSON(map[string]interface{}{
  3528. "msg": "退号成功",
  3529. })
  3530. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  3531. } else {
  3532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3533. return
  3534. }
  3535. } else {
  3536. c.ServeSuccessJSON(map[string]interface{}{
  3537. "code": -10,
  3538. "msg": res2.ErrMsg,
  3539. })
  3540. }
  3541. } else {
  3542. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3543. //if err == nil {
  3544. // c.ServeSuccessJSON(map[string]interface{}{
  3545. // "msg": "退费成功",
  3546. // })
  3547. //} else {
  3548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3549. // return
  3550. //}
  3551. }
  3552. }
  3553. func (c *HisApiController) RefundDetail() {
  3554. order_id, _ := c.GetInt64("order_id")
  3555. his_patient_id, _ := c.GetInt64("his_patient_id")
  3556. number := c.GetString("number")
  3557. record_time := c.GetString("record_time")
  3558. patient_id, _ := c.GetInt64("patient_id")
  3559. timeLayout := "2006-01-02"
  3560. loc, _ := time.LoadLocation("Local")
  3561. adminUser := c.GetAdminUserInfo()
  3562. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3563. fmt.Println(err)
  3564. if err != nil {
  3565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3566. return
  3567. }
  3568. recordDateTime := theTime.Unix()
  3569. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3570. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3571. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3572. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3573. var order models.HisOrder
  3574. order, _ = service.GetHisOrderByID(order_id)
  3575. if order.ID == 0 {
  3576. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3577. }
  3578. if config.IsOpen == 1 { //对接了医保,走医保流程
  3579. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3580. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3581. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3582. resp2, requestErr2 := http.Get(api2)
  3583. if requestErr2 != nil {
  3584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3585. return
  3586. }
  3587. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3588. if ioErr2 != nil {
  3589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3591. return
  3592. }
  3593. var respJSON2 map[string]interface{}
  3594. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3597. return
  3598. }
  3599. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3600. if err == nil {
  3601. c.ServeSuccessJSON(map[string]interface{}{
  3602. "msg": "退费成功",
  3603. })
  3604. } else {
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. } else {
  3609. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3610. if err == nil {
  3611. c.ServeSuccessJSON(map[string]interface{}{
  3612. "msg": "退费成功",
  3613. })
  3614. } else {
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. }
  3619. }
  3620. //对账
  3621. func (c *HisApiController) GetCheckAccount() {
  3622. start_time := c.GetString("start_time")
  3623. end_time := c.GetString("end_time")
  3624. insutype := c.GetString("insutype")
  3625. clr_type := c.GetString("clr_type")
  3626. admin_user_id, _ := c.GetInt64("admin_user_id")
  3627. adminUser := c.GetAdminUserInfo()
  3628. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3629. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3630. timeLayout := "2006-01-02"
  3631. loc, _ := time.LoadLocation("Local")
  3632. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3633. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3634. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3635. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3636. fixmedins_setl_cnt := int64(len(orders))
  3637. //
  3638. ////撤销的算2条数据为一笔
  3639. //for _, item := range orders_two {
  3640. // if item.OrderStatus == 3 {
  3641. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3642. // }
  3643. //}
  3644. var medfee_sumamt float64
  3645. var acct_pay float64
  3646. var fund_pay_sumamt float64
  3647. for _, item := range orders {
  3648. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3649. acct_pay = acct_pay + item.AcctPay
  3650. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3651. }
  3652. var user_name string
  3653. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3654. if role.ID == 0 {
  3655. user_name = "xxx"
  3656. } else {
  3657. user_name = role.UserName
  3658. }
  3659. if config.IsOpen == 1 {
  3660. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3661. "insutype=" + insutype +
  3662. "&clr_type=" + clr_type +
  3663. "&setl_optins=" + "定点医保中心" +
  3664. "&stmt_begndate=" + start_time +
  3665. "&stm_enddate=" + end_time +
  3666. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3667. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3668. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3669. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3670. "&fixmedins_code=" + miConfig.Code +
  3671. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3672. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3673. "&secret_key=" + miConfig.SecretKey +
  3674. "&org_name=" + miConfig.OrgName +
  3675. "&doctor=" + user_name
  3676. fmt.Println(api)
  3677. resp, requestErr := http.Get(api)
  3678. if requestErr != nil {
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. body, ioErr := ioutil.ReadAll(resp.Body)
  3683. fmt.Println(body)
  3684. if ioErr != nil {
  3685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3687. return
  3688. }
  3689. var respJSON map[string]interface{}
  3690. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3693. return
  3694. }
  3695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3696. userJSONBytes, _ := json.Marshal(respJSON)
  3697. var res ResultEight
  3698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3699. utils.ErrorLog("解析失败:%v", err)
  3700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3701. return
  3702. }
  3703. if res.Infcode == 0 {
  3704. if res.Output.Stmtinfo.StmtRslt == "0" {
  3705. micc := &models.MedicalInsuranceCostCompare{
  3706. StartTime: startime.Unix(),
  3707. EndTime: endtime.Unix(),
  3708. Insutype: insutype,
  3709. CheckType: 1,
  3710. Num: fixmedins_setl_cnt,
  3711. Mtime: time.Now().Unix(),
  3712. Status: 1,
  3713. UserOrgId: adminUser.CurrentOrgId,
  3714. CostTotal: medfee_sumamt,
  3715. FuncTotal: fund_pay_sumamt,
  3716. PsnPay: acct_pay,
  3717. Creator: admin_user_id,
  3718. Ctime: time.Now().Unix(),
  3719. }
  3720. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3721. if err == nil {
  3722. c.ServeSuccessJSON(map[string]interface{}{
  3723. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3724. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3725. })
  3726. } else {
  3727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3728. }
  3729. } else {
  3730. c.ServeSuccessJSON(map[string]interface{}{
  3731. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3732. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3733. })
  3734. }
  3735. } else {
  3736. c.ServeSuccessJSON(map[string]interface{}{
  3737. "code": -10,
  3738. "msg": res.ErrMsg,
  3739. })
  3740. }
  3741. }
  3742. }
  3743. func (c *HisApiController) Check310() {
  3744. adminUser := c.GetAdminUserInfo()
  3745. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3746. var user_name string
  3747. user_name = "xxx"
  3748. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3749. "insutype=" + "310" +
  3750. "&clr_type=" + "11" +
  3751. "&setl_optins=" + "定点医保中心" +
  3752. "&stmt_begndate=" + "2021-03-01" +
  3753. "&stm_enddate=" + "2021-03-31" +
  3754. "&medfee_sumamt=" + "11521" +
  3755. "&fund_pay_sumamt=" + "10166.66" +
  3756. "&acct_pay=" + "0" +
  3757. "&fixmedins_setl_cnt=" + "7" +
  3758. "&fixmedins_code=" + miConfig.Code +
  3759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3760. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3761. "&secret_key=" + miConfig.SecretKey +
  3762. "&org_name=" + miConfig.OrgName +
  3763. "&doctor=" + user_name
  3764. fmt.Println(api)
  3765. resp, requestErr := http.Get(api)
  3766. if requestErr != nil {
  3767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3768. return
  3769. }
  3770. body, ioErr := ioutil.ReadAll(resp.Body)
  3771. fmt.Println(body)
  3772. if ioErr != nil {
  3773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3775. return
  3776. }
  3777. var respJSON map[string]interface{}
  3778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3781. return
  3782. }
  3783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3784. userJSONBytes, _ := json.Marshal(respJSON)
  3785. var res ResultEight
  3786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3787. utils.ErrorLog("解析失败:%v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. }
  3792. func (c *HisApiController) Check390() {
  3793. adminUser := c.GetAdminUserInfo()
  3794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3795. var user_name string
  3796. user_name = "张俊杰"
  3797. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3798. "insutype=" + "390" +
  3799. "&clr_type=" + "11" +
  3800. "&setl_optins=" + "定点医保中心" +
  3801. "&stmt_begndate=" + "2021-03-01" +
  3802. "&stm_enddate=" + "2021-03-31" +
  3803. "&medfee_sumamt=" + "209318.43" +
  3804. "&fund_pay_sumamt=" + "188029.12" +
  3805. "&acct_pay=" + "0" +
  3806. "&fixmedins_setl_cnt=" + "48" +
  3807. "&fixmedins_code=" + miConfig.Code +
  3808. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3809. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3810. "&secret_key=" + miConfig.SecretKey +
  3811. "&org_name=" + miConfig.OrgName +
  3812. "&doctor=" + user_name
  3813. fmt.Println(api)
  3814. resp, requestErr := http.Get(api)
  3815. if requestErr != nil {
  3816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3817. return
  3818. }
  3819. body, ioErr := ioutil.ReadAll(resp.Body)
  3820. fmt.Println(body)
  3821. if ioErr != nil {
  3822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3824. return
  3825. }
  3826. var respJSON map[string]interface{}
  3827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3830. return
  3831. }
  3832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3833. userJSONBytes, _ := json.Marshal(respJSON)
  3834. var res ResultEight
  3835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3836. utils.ErrorLog("解析失败:%v", err)
  3837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3838. return
  3839. }
  3840. }
  3841. //对账明细
  3842. func (c *HisApiController) GetCheckDetailAccount() {
  3843. start_time := c.GetString("start_time")
  3844. end_time := c.GetString("end_time")
  3845. admin_user_id, _ := c.GetInt64("admin_user_id")
  3846. adminUser := c.GetAdminUserInfo()
  3847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3848. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3849. timeLayout := "2006-01-02"
  3850. loc, _ := time.LoadLocation("Local")
  3851. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3852. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3853. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  3854. Mkdir(miConfig.OrgName)
  3855. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  3856. file_name := file + ".txt"
  3857. zip_name := file + ".zip"
  3858. zip_path := miConfig.OrgName + "/" + zip_name
  3859. file_path := miConfig.OrgName + "/" + file_name
  3860. decimal.DivisionPrecision = 2
  3861. var medfee_sumamt float64
  3862. var psn_cash_pay float64
  3863. var fund_pay_sumamt float64
  3864. fixmedins_setl_cnt := int64(len(orders))
  3865. for _, item := range orders {
  3866. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3867. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  3868. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3869. }
  3870. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  3871. defer f.Close()
  3872. if err != nil {
  3873. fmt.Println(err.Error())
  3874. } else {
  3875. for _, item := range orders {
  3876. var refd_setl_flag string
  3877. if item.OrderStatus == 2 {
  3878. refd_setl_flag = "0"
  3879. var str string
  3880. str = item.SetlId + " " +
  3881. item.MdtrtId + " " +
  3882. item.PsnNo + " " +
  3883. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3884. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3885. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  3886. _, err = f.Write([]byte(str))
  3887. }
  3888. if item.OrderStatus == 3 {
  3889. var str string
  3890. str = item.SetlId + " " +
  3891. item.MdtrtId + " " +
  3892. item.PsnNo + " " +
  3893. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3894. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3895. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  3896. _, err = f.Write([]byte(str))
  3897. var str2 string
  3898. str2 = item.SetlId + " " +
  3899. item.MdtrtId + " " +
  3900. item.PsnNo + " " +
  3901. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  3902. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  3903. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  3904. _, err = f.Write([]byte(str2))
  3905. }
  3906. }
  3907. }
  3908. Zip(file_path, zip_path)
  3909. fmt.Println(ReadFile(zip_path))
  3910. fmt.Println(string(ReadFile(zip_path)))
  3911. if config.IsOpen == 1 {
  3912. var user_name string
  3913. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3914. if role.ID == 0 {
  3915. user_name = "管理员"
  3916. } else {
  3917. user_name = role.UserName
  3918. }
  3919. baseParams := models.BaseParams{
  3920. SecretKey: miConfig.SecretKey,
  3921. FixmedinsCode: miConfig.Code,
  3922. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3923. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3924. OrgName: miConfig.OrgName,
  3925. Doctor: user_name,
  3926. }
  3927. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  3928. var dat map[string]interface{}
  3929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3930. fmt.Println(dat)
  3931. } else {
  3932. fmt.Println(err)
  3933. }
  3934. userJSONBytes, _ := json.Marshal(dat)
  3935. var res ResultNine
  3936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3937. utils.ErrorLog("解析失败:%v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. if res.Infcode == 0 {
  3942. fileNo := res.Output.FileQuryNo
  3943. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  3944. "file_qury_no=" + fileNo +
  3945. "&setl_optins=" + "定点医保中心" +
  3946. "&stmt_begndate=" + start_time +
  3947. "&stm_enddate=" + end_time +
  3948. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3949. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3950. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  3951. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3952. "&fixmedins_code=" + miConfig.Code +
  3953. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3954. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3955. "&secret_key=" + miConfig.SecretKey +
  3956. "&org_name=" + miConfig.OrgName +
  3957. "&doctor=" + user_name
  3958. resp, requestErr := http.Get(api)
  3959. if requestErr != nil {
  3960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. return
  3962. }
  3963. body, ioErr := ioutil.ReadAll(resp.Body)
  3964. if ioErr != nil {
  3965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3967. return
  3968. }
  3969. var respJSON map[string]interface{}
  3970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3973. return
  3974. }
  3975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3976. userJSONBytes, _ := json.Marshal(respJSON)
  3977. var res ResultTen
  3978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3979. utils.ErrorLog("解析失败:%v", err)
  3980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3981. return
  3982. }
  3983. if res.Infcode == 0 {
  3984. service.Gdyb9102(baseParams, zip_name, fileNo)
  3985. micc := &models.MedicalInsuranceCostCompare{
  3986. StartTime: startime.Unix(),
  3987. EndTime: endtime.Unix(),
  3988. Insutype: "0",
  3989. CheckType: 2,
  3990. Num: fixmedins_setl_cnt,
  3991. Mtime: time.Now().Unix(),
  3992. Status: 1,
  3993. UserOrgId: adminUser.CurrentOrgId,
  3994. CostTotal: medfee_sumamt,
  3995. FuncTotal: fund_pay_sumamt,
  3996. PsnPay: psn_cash_pay,
  3997. Creator: admin_user_id,
  3998. Ctime: time.Now().Unix(),
  3999. }
  4000. service.CreateMedicalInsuranceCostCompareRecord(micc)
  4001. c.ServeSuccessJSON(map[string]interface{}{
  4002. "msg": "明细对账成功",
  4003. })
  4004. }
  4005. } else {
  4006. }
  4007. }
  4008. }
  4009. func (c *HisApiController) GetSettleAccounts() {
  4010. //id, _ := c.GetInt64("id")
  4011. //record_time := c.GetString("record_time")
  4012. order_id, _ := c.GetInt64("order_id")
  4013. admin_user_id, _ := c.GetInt64("admin_user_id")
  4014. //timeLayout := "2006-01-02"
  4015. //loc, _ := time.LoadLocation("Local")
  4016. //
  4017. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4018. //if err != nil {
  4019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4020. // return
  4021. //}
  4022. //recordDateTime := theTime.Unix()
  4023. adminUser := c.GetAdminUserInfo()
  4024. order, _ := service.GetHisOrderByID(order_id)
  4025. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4026. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  4027. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4028. orderInfos = append(orderInfos, orderInfos_two...)
  4029. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  4030. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4031. //var config []*models.HisXtDiagnoseConfig
  4032. var name string
  4033. for _, item := range diagnosis_ids {
  4034. id, _ := strconv.ParseInt(item, 10, 64)
  4035. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4036. if len(name) == 0 {
  4037. name = diagnosisConfig.ClassName
  4038. } else {
  4039. name = name + "," + diagnosisConfig.ClassName
  4040. }
  4041. }
  4042. var bedCostTotal float64 = 0 //床位总费
  4043. var bedCostSelfTotal float64 = 0 //床位自费
  4044. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4045. var operationCostTotal float64 = 0 //手术费
  4046. var operationCostSelfTotal float64 = 0 //手术费
  4047. var operationCostPartSelfTotal float64 = 0 //手术费
  4048. var otherCostTotal float64 = 0 //其他费用
  4049. var otherCostSelfTotal float64 = 0 //其他费用
  4050. var otherCostPartSelfTotal float64 = 0 //其他费用
  4051. var materialCostTotal float64 = 0 //材料费
  4052. var materialCostSelfTotal float64 = 0 //材料费
  4053. var materialCostPartSelfTotal float64 = 0 //材料费
  4054. var westernMedicineCostTotal float64 = 0 //西药费
  4055. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4056. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4057. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4058. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4059. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4060. var checkCostTotal float64 = 0 //检查费
  4061. var checkCostSelfTotal float64 = 0 //检查费
  4062. var checkCostPartSelfTotal float64 = 0 //检查费
  4063. var laboratoryCostTotal float64 = 0 //化验费
  4064. var laboratoryCostSelfTotal float64 = 0 //化验费
  4065. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4066. var treatCostTotal float64 = 0 //治疗费用
  4067. var treatCostSelfTotal float64 = 0 //治疗费用
  4068. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4069. decimal.DivisionPrecision = 2
  4070. for _, item := range orderInfos {
  4071. if item.MedChrgitmType == "01" { //床位费
  4072. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4073. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4074. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4075. }
  4076. if item.MedChrgitmType == "03" { //检查费
  4077. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4078. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4079. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4080. }
  4081. if item.MedChrgitmType == "04" { //化验费
  4082. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4083. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4084. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4085. }
  4086. if item.MedChrgitmType == "05" { //治疗费
  4087. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4088. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4089. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4090. }
  4091. if item.MedChrgitmType == "06" { //手术费
  4092. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4093. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4094. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4095. }
  4096. if item.MedChrgitmType == "08" { //材料费
  4097. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4098. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4099. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4100. }
  4101. if item.MedChrgitmType == "09" { //西药费
  4102. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4103. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4104. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4105. }
  4106. if item.MedChrgitmType == "11" { //中成费
  4107. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4108. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4109. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4110. }
  4111. if item.MedChrgitmType == "14" { //其他费
  4112. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4113. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4114. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4115. }
  4116. }
  4117. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4118. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4119. var user_name string
  4120. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4121. if role.ID == 0 {
  4122. user_name = "管理员"
  4123. } else {
  4124. user_name = role.UserName
  4125. }
  4126. baseParams := models.BaseParams{
  4127. SecretKey: miConfig.SecretKey,
  4128. FixmedinsCode: miConfig.Code,
  4129. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4130. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4131. OrgName: miConfig.OrgName,
  4132. Doctor: user_name,
  4133. }
  4134. businessParams := models.BusinessParams{
  4135. PsnNo: order.PsnNo,
  4136. MdtrtId: order.MdtrtId,
  4137. SetlId: order.SetlId,
  4138. }
  4139. if config.IsOpen == 1 {
  4140. result := service.Gdyb5203(baseParams, businessParams)
  4141. var dat map[string]interface{}
  4142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4143. fmt.Println(dat)
  4144. } else {
  4145. fmt.Println(err)
  4146. }
  4147. userJSONBytes, _ := json.Marshal(dat)
  4148. var res ResultEleven
  4149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4155. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  4156. if res.Infcode == 0 {
  4157. c.ServeSuccessJSON(map[string]interface{}{
  4158. "diagnosis": name,
  4159. "order_infos": orderInfos,
  4160. "number": order.MdtrtId,
  4161. "date": order.SettleAccountsDate,
  4162. "charge_admin": charge_admin,
  4163. "printor_admin": printor_admin,
  4164. "info": res.Output.Setlinfo,
  4165. "bedCostTotal": bedCostTotal,
  4166. "bedCostSelfTotal": bedCostSelfTotal,
  4167. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  4168. "operationCostTotal": operationCostTotal,
  4169. "operationCostSelfTotal": operationCostSelfTotal,
  4170. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  4171. "otherCostTotal": otherCostTotal,
  4172. "otherCostSelfTotal": otherCostSelfTotal,
  4173. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  4174. "materialCostTotal": materialCostTotal,
  4175. "materialCostSelfTotal": materialCostSelfTotal,
  4176. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  4177. "westernMedicineCostTotal": westernMedicineCostTotal,
  4178. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  4179. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  4180. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  4181. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  4182. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  4183. "checkCostTotal": checkCostTotal,
  4184. "checkCostSelfTotal": checkCostSelfTotal,
  4185. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  4186. "laboratoryCostTotal": laboratoryCostTotal,
  4187. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  4188. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  4189. "treatCostTotal": treatCostTotal,
  4190. "treatCostSelfTotal": treatCostSelfTotal,
  4191. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  4192. })
  4193. }
  4194. }
  4195. }
  4196. func (c *HisApiController) CheckTreatment() {
  4197. patient_id, _ := c.GetInt64("patient_id", 0)
  4198. record_time := c.GetString("record_time")
  4199. insutype := c.GetString("insutype")
  4200. timeLayout := "2006-01-02"
  4201. loc, _ := time.LoadLocation("Local")
  4202. adminUser := c.GetAdminUserInfo()
  4203. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4204. fmt.Println(err)
  4205. if err != nil {
  4206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4207. return
  4208. }
  4209. recordDateTime := theTime.Unix()
  4210. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4211. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4212. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4213. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4214. var user_name string
  4215. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  4216. if role.ID == 0 {
  4217. user_name = "xxx"
  4218. } else {
  4219. user_name = role.UserName
  4220. }
  4221. baseParams := models.BaseParams{
  4222. SecretKey: miConfig.SecretKey,
  4223. FixmedinsCode: miConfig.Code,
  4224. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4225. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4226. OrgName: miConfig.OrgName,
  4227. Doctor: user_name,
  4228. }
  4229. if config.IsOpen == 1 {
  4230. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  4231. var dat map[string]interface{}
  4232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4233. fmt.Println(dat)
  4234. } else {
  4235. fmt.Println(err)
  4236. }
  4237. }
  4238. }
  4239. func (c *HisApiController) PutRecord() {
  4240. id, _ := c.GetInt64("id")
  4241. record_time := c.GetString("record_time")
  4242. timeLayout := "2006-01-02"
  4243. loc, _ := time.LoadLocation("Local")
  4244. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4245. if err != nil {
  4246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4247. return
  4248. }
  4249. recordDateTime := theTime.Unix()
  4250. adminInfo := c.GetAdminUserInfo()
  4251. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  4252. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4253. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4254. fmt.Println(miConfig.SecretKey)
  4255. if patient == nil {
  4256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4257. return
  4258. }
  4259. if len(patient.IdCardNo) == 0 {
  4260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4261. return
  4262. }
  4263. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4264. if config.IsOpen == 1 {
  4265. 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
  4266. resp, requestErr := http.Get(api)
  4267. if requestErr != nil {
  4268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4269. return
  4270. }
  4271. defer resp.Body.Close()
  4272. body, ioErr := ioutil.ReadAll(resp.Body)
  4273. if ioErr != nil {
  4274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. var respJSON map[string]interface{}
  4279. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4282. return
  4283. }
  4284. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4285. userJSONBytes, _ := json.Marshal(userJSON)
  4286. var res ResultTwo
  4287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4288. utils.ErrorLog("解析失败:%v", err)
  4289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4290. return
  4291. }
  4292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4293. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4294. infoStr := string(Iinfos)
  4295. idetinfoStr := string(Idetinfos)
  4296. if res.Infcode == 0 {
  4297. his := models.VMHisPatient{
  4298. Status: 1,
  4299. Ctime: time.Now().Unix(),
  4300. Mtime: time.Now().Unix(),
  4301. PsnNo: res.Output.Baseinfo.PsnNo,
  4302. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4303. Certno: res.Output.Baseinfo.Certno,
  4304. PsnName: res.Output.Baseinfo.PsnName,
  4305. Gend: res.Output.Baseinfo.Gend,
  4306. Naty: res.Output.Baseinfo.Naty,
  4307. Brdy: res.Output.Baseinfo.Brdy,
  4308. Age: res.Output.Baseinfo.Age,
  4309. Iinfo: infoStr,
  4310. Idetinfo: idetinfoStr,
  4311. PatientId: patient.ID,
  4312. RecordDate: theTime.Unix(),
  4313. UserOrgId: adminInfo.CurrentOrgId,
  4314. AdminUserId: adminInfo.AdminUser.Id,
  4315. IsReturn: 1,
  4316. }
  4317. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4318. 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")
  4319. 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")
  4320. var dat map[string]interface{}
  4321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4322. fmt.Println(dat)
  4323. } else {
  4324. fmt.Println(err)
  4325. }
  4326. var dat2 map[string]interface{}
  4327. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  4328. fmt.Println(dat2)
  4329. } else {
  4330. fmt.Println(err)
  4331. }
  4332. } else {
  4333. adminUser := c.GetAdminUserInfo()
  4334. errlog := &models.HisOrderError{
  4335. UserOrgId: adminUser.CurrentOrgId,
  4336. Ctime: time.Now().Unix(),
  4337. Mtime: time.Now().Unix(),
  4338. ErrMsg: res.ErrMsg,
  4339. Status: 1,
  4340. PatientId: id,
  4341. RecordTime: recordDateTime,
  4342. Stage: 1,
  4343. }
  4344. service.CreateErrMsgLog(errlog)
  4345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4346. return
  4347. }
  4348. }
  4349. }
  4350. func (c *HisApiController) GetUploadDiag() {
  4351. id, _ := c.GetInt64("id")
  4352. record_time := c.GetString("record_time")
  4353. diagnosis_id, _ := c.GetInt64("diagnosis")
  4354. sick_type, _ := c.GetInt64("sick_type")
  4355. reg_type, _ := c.GetInt64("reg_type")
  4356. timeLayout := "2006-01-02"
  4357. loc, _ := time.LoadLocation("Local")
  4358. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4359. if err != nil {
  4360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4361. return
  4362. }
  4363. var patientPrescription models.HisPrescriptionInfo
  4364. recordDateTime := theTime.Unix()
  4365. adminInfo := c.GetAdminUserInfo()
  4366. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4367. if patientPrescription.ID == 0 {
  4368. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4369. }
  4370. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4371. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4372. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4373. sickConfig, _ := service.FindSickById(sick_type)
  4374. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4375. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  4376. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  4377. "&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 +
  4378. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  4379. resp2, requestErr2 := http.Get(api2)
  4380. if requestErr2 != nil {
  4381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4382. return
  4383. }
  4384. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4385. if ioErr2 != nil {
  4386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. var respJSON2 map[string]interface{}
  4391. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. return
  4395. }
  4396. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4397. userJSONBytes2, _ := json.Marshal(respJSON2)
  4398. var res2 ResultSix
  4399. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4400. utils.ErrorLog("解析失败:%v", err)
  4401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4402. return
  4403. }
  4404. if res2.Infcode != 0 {
  4405. adminUser := c.GetAdminUserInfo()
  4406. errlog := &models.HisOrderError{
  4407. UserOrgId: adminUser.CurrentOrgId,
  4408. Ctime: time.Now().Unix(),
  4409. Mtime: time.Now().Unix(),
  4410. ErrMsg: res2.ErrMsg,
  4411. Status: 1,
  4412. PatientId: id,
  4413. RecordTime: recordDateTime,
  4414. Stage: 3,
  4415. }
  4416. service.CreateErrMsgLog(errlog)
  4417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  4418. return
  4419. }
  4420. c.ServeSuccessJSON(map[string]interface{}{
  4421. "msg": "上传成功",
  4422. })
  4423. }
  4424. type QueryResult struct {
  4425. ID int64
  4426. Name string
  4427. Code string
  4428. List_type_code string
  4429. }
  4430. func (c *HisApiController) GetCheckCode() {
  4431. ids_str := c.GetString("ids")
  4432. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4433. ids_arr := strings.Split(ids_str, ",")
  4434. var queryResult []QueryResult
  4435. ids := make([]int64, 0)
  4436. for _, item := range ids_arr {
  4437. id, _ := strconv.ParseInt(item, 10, 64)
  4438. ids = append(ids, id)
  4439. }
  4440. if record_type == 1 {
  4441. drugs, _ := service.GetBatchDrugList(ids)
  4442. for _, item := range drugs {
  4443. result := QueryResult{
  4444. ID: item.ID,
  4445. Name: item.DrugName,
  4446. Code: item.MedicalInsuranceNumber,
  4447. List_type_code: "101",
  4448. }
  4449. queryResult = append(queryResult, result)
  4450. }
  4451. } else if record_type == 2 {
  4452. goods, _ := service.GetBatchGoodInformationList(ids)
  4453. for _, item := range goods {
  4454. result := QueryResult{
  4455. ID: item.ID,
  4456. Name: item.GoodName,
  4457. Code: item.MedicalInsuranceNumber,
  4458. List_type_code: "301",
  4459. }
  4460. queryResult = append(queryResult, result)
  4461. }
  4462. } else if record_type == 3 {
  4463. projects, _ := service.GetBathchMyPorjecgList(ids)
  4464. for _, item := range projects {
  4465. result := QueryResult{
  4466. ID: item.ID,
  4467. Name: item.ProjectName,
  4468. Code: item.MedicalCode,
  4469. List_type_code: "201",
  4470. }
  4471. queryResult = append(queryResult, result)
  4472. }
  4473. }
  4474. admin_user_id, _ := c.GetInt64("admin_user_id")
  4475. adminUser := c.GetAdminUserInfo()
  4476. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4477. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4478. var user_name string
  4479. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4480. if role.ID == 0 {
  4481. user_name = "xxx"
  4482. } else {
  4483. user_name = role.UserName
  4484. }
  4485. baseParams := &models.BaseParams{
  4486. SecretKey: miConfig.SecretKey,
  4487. FixmedinsCode: miConfig.Code,
  4488. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4489. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4490. OrgName: miConfig.OrgName,
  4491. Doctor: user_name,
  4492. }
  4493. if config.IsOpen == 1 {
  4494. for _, item := range queryResult {
  4495. var result string
  4496. if record_type == 1 {
  4497. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4498. } else if record_type == 2 {
  4499. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4500. } else if record_type == 3 {
  4501. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4502. }
  4503. var dat map[string]interface{}
  4504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4505. fmt.Println(dat)
  4506. } else {
  4507. fmt.Println(err)
  4508. }
  4509. userJSONBytes, _ := json.Marshal(dat)
  4510. var res ResultSix
  4511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. if res.Infcode == 0 {
  4517. if record_type == 1 {
  4518. service.UpdateBaseDrugById(item.ID)
  4519. } else if record_type == 2 {
  4520. service.UpdateGoodInformaitonByDetail(item.ID)
  4521. } else if record_type == 3 {
  4522. service.UpdateProjectById(item.ID)
  4523. }
  4524. c.ServeSuccessJSON(map[string]interface{}{
  4525. "failed_code": 0,
  4526. "msg": "目录对照成功",
  4527. })
  4528. } else {
  4529. c.ServeSuccessJSON(map[string]interface{}{
  4530. "failed_code": -10,
  4531. "msg": res.ErrMsg,
  4532. })
  4533. }
  4534. }
  4535. }
  4536. }
  4537. func (c *HisApiController) UnCheckCode() {
  4538. ids_str := c.GetString("ids")
  4539. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4540. admin_user_id, _ := c.GetInt64("admin_user_id")
  4541. ids_arr := strings.Split(ids_str, ",")
  4542. var queryResult []QueryResult
  4543. ids := make([]int64, 0)
  4544. for _, item := range ids_arr {
  4545. id, _ := strconv.ParseInt(item, 10, 64)
  4546. ids = append(ids, id)
  4547. }
  4548. if record_type == 1 {
  4549. drugs, _ := service.GetBatchDrugList(ids)
  4550. for _, item := range drugs {
  4551. result := QueryResult{
  4552. ID: item.ID,
  4553. Name: item.DrugName,
  4554. Code: item.MedicalInsuranceNumber,
  4555. List_type_code: "101",
  4556. }
  4557. queryResult = append(queryResult, result)
  4558. }
  4559. } else if record_type == 2 {
  4560. goods, _ := service.GetBatchGoodInformationList(ids)
  4561. for _, item := range goods {
  4562. result := QueryResult{
  4563. ID: item.ID,
  4564. Name: item.GoodName,
  4565. Code: item.MedicalInsuranceNumber,
  4566. List_type_code: "301",
  4567. }
  4568. queryResult = append(queryResult, result)
  4569. }
  4570. } else if record_type == 3 {
  4571. projects, _ := service.GetBathchMyPorjecgList(ids)
  4572. for _, item := range projects {
  4573. result := QueryResult{
  4574. ID: item.ID,
  4575. Name: item.ProjectName,
  4576. Code: item.MedicalCode,
  4577. List_type_code: "201",
  4578. }
  4579. queryResult = append(queryResult, result)
  4580. }
  4581. }
  4582. adminUser := c.GetAdminUserInfo()
  4583. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4584. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4585. var user_name string
  4586. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4587. if role.ID == 0 {
  4588. user_name = "xxx"
  4589. } else {
  4590. user_name = role.UserName
  4591. }
  4592. baseParams := &models.BaseParams{
  4593. SecretKey: miConfig.SecretKey,
  4594. FixmedinsCode: miConfig.Code,
  4595. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4596. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4597. OrgName: miConfig.OrgName,
  4598. Doctor: user_name,
  4599. }
  4600. if config.IsOpen == 1 {
  4601. for _, item := range queryResult {
  4602. var result string
  4603. if record_type == 1 {
  4604. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4605. } else if record_type == 2 {
  4606. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4607. } else if record_type == 3 {
  4608. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4609. }
  4610. var dat2 map[string]interface{}
  4611. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4612. fmt.Println(dat2)
  4613. } else {
  4614. fmt.Println(err)
  4615. }
  4616. userJSONBytes, _ := json.Marshal(dat2)
  4617. var res ResultSix
  4618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4619. utils.ErrorLog("解析失败:%v", err)
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. return
  4622. }
  4623. if res.Infcode == 0 {
  4624. if record_type == 1 {
  4625. service.UpdateDrugByIdDetail(item.ID)
  4626. } else if record_type == 2 {
  4627. service.UpdateGoodInfoById(item.ID)
  4628. } else if record_type == 3 {
  4629. service.UpdateMyProjectById(item.ID)
  4630. }
  4631. c.ServeSuccessJSON(map[string]interface{}{
  4632. "failed_code": 0,
  4633. "msg": "撤销目录对照成功",
  4634. })
  4635. } else {
  4636. c.ServeSuccessJSON(map[string]interface{}{
  4637. "failed_code": -10,
  4638. "msg": res.ErrMsg,
  4639. })
  4640. }
  4641. }
  4642. }
  4643. }
  4644. func (c *HisApiController) GetPatientInfo() {
  4645. id_card_no := c.GetString("id_card_no")
  4646. admin_user_id, _ := c.GetInt64("admin_user_id")
  4647. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4648. if patient.ID == 0 {
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4650. return
  4651. }
  4652. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4653. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4654. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4655. if config.IsOpen == 1 {
  4656. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4657. var dat map[string]interface{}
  4658. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4659. fmt.Println(dat)
  4660. } else {
  4661. fmt.Println(err)
  4662. }
  4663. userJSONBytes, _ := json.Marshal(dat)
  4664. var res ResultTwo
  4665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4666. utils.ErrorLog("解析失败:%v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. if res.Infcode != 0 {
  4671. c.ServeSuccessJSON(map[string]interface{}{
  4672. "failed_code": -10,
  4673. "msg": res.ErrMsg,
  4674. })
  4675. } else {
  4676. c.ServeSuccessJSON(map[string]interface{}{
  4677. "failed_code": 0,
  4678. "info": res,
  4679. })
  4680. }
  4681. }
  4682. }
  4683. func (c *HisApiController) PsnPutOnRecord() {
  4684. record_type, _ := c.GetInt64("type")
  4685. patient_id, _ := c.GetInt64("patient_id")
  4686. admin_user_id, _ := c.GetInt64("admin_user_id")
  4687. start_time := c.GetString("start_time")
  4688. end_time := c.GetString("end_time")
  4689. adminUser := c.GetAdminUserInfo()
  4690. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4691. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4692. var patients []*models.Patients
  4693. if record_type == 1 { //全部备案
  4694. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4695. patients = append(patients, patient...)
  4696. } else { //单个备案
  4697. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4698. patients = append(patients, patient)
  4699. }
  4700. var user_name string
  4701. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4702. if role.ID == 0 {
  4703. user_name = "xxx"
  4704. } else {
  4705. user_name = role.UserName
  4706. }
  4707. if config.IsOpen == 1 {
  4708. for _, item := range patients {
  4709. 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
  4710. resp, requestErr := http.Get(api)
  4711. if requestErr != nil {
  4712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4713. return
  4714. }
  4715. defer resp.Body.Close()
  4716. body, ioErr := ioutil.ReadAll(resp.Body)
  4717. if ioErr != nil {
  4718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4720. return
  4721. }
  4722. var respJSON map[string]interface{}
  4723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4726. return
  4727. }
  4728. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4729. userJSONBytes, _ := json.Marshal(userJSON)
  4730. var res ResultTwo
  4731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4732. utils.ErrorLog("解析失败:%v", err)
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4734. return
  4735. }
  4736. if res.Infcode == 0 {
  4737. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4738. var dat map[string]interface{}
  4739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4740. fmt.Println(dat)
  4741. } else {
  4742. fmt.Println(err)
  4743. }
  4744. userJSONBytes, _ := json.Marshal(dat)
  4745. var res2 ResultThirteen
  4746. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4747. utils.ErrorLog("解析失败:%v", err)
  4748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4749. return
  4750. }
  4751. if res2.Infcode == 0 {
  4752. psnResult := &models.GdybPsnRecord{
  4753. UserOrgId: adminUser.CurrentOrgId,
  4754. PatientId: item.ID,
  4755. PsnNo: res.Output.Baseinfo.PsnNo,
  4756. Ctime: time.Now().Unix(),
  4757. Mtime: time.Now().Unix(),
  4758. Status: 1,
  4759. IsCancel: 1,
  4760. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4761. }
  4762. service.CreatePsnRecord(psnResult)
  4763. } else {
  4764. c.ServeSuccessJSON(map[string]interface{}{
  4765. "failed_code": -10,
  4766. "msg": res2.ErrMsg,
  4767. })
  4768. return
  4769. }
  4770. }
  4771. }
  4772. }
  4773. }
  4774. func (c *HisApiController) PsnUnPutOnRecord() {
  4775. id, _ := c.GetInt64("id")
  4776. //record_type, _ := c.GetInt64("type")
  4777. admin_user_id, _ := c.GetInt64("admin_user_id")
  4778. adminUser := c.GetAdminUserInfo()
  4779. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4780. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4781. var user_name string
  4782. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4783. if role.ID == 0 {
  4784. user_name = "xxx"
  4785. } else {
  4786. user_name = role.UserName
  4787. }
  4788. psn_record, _ := service.GetPsnRecordById(id)
  4789. if psn_record.ID == 0 {
  4790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4791. return
  4792. }
  4793. if config.IsOpen == 1 {
  4794. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4795. var dat map[string]interface{}
  4796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4797. fmt.Println(dat)
  4798. } else {
  4799. fmt.Println(err)
  4800. }
  4801. userJSONBytes, _ := json.Marshal(dat)
  4802. var res ResultFourteen
  4803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4804. utils.ErrorLog("解析失败:%v", err)
  4805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4806. return
  4807. }
  4808. if res.Infcode == 0 {
  4809. psn_record.IsCancel = 2
  4810. service.CreatePsnRecord(&psn_record)
  4811. } else {
  4812. c.ServeSuccessJSON(map[string]interface{}{
  4813. "failed_code": -10,
  4814. "msg": res.ErrMsg,
  4815. })
  4816. return
  4817. }
  4818. }
  4819. }
  4820. func (c *HisApiController) PsnPutNCDSOnRecord() {
  4821. patient_id, _ := c.GetInt64("patient_id")
  4822. insutype := c.GetString("insutype")
  4823. psn_no := c.GetString("psn_no")
  4824. doctor_id, _ := c.GetInt64("doctor_id")
  4825. sick_id, _ := c.GetInt64("sick_id")
  4826. department_id, _ := c.GetInt64("department_id")
  4827. adminUser := c.GetAdminUserInfo()
  4828. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4830. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4831. sick, _ := service.FindSickById(sick_id)
  4832. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  4833. if config.IsOpen == 1 {
  4834. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.CountryCode)
  4835. var dat map[string]interface{}
  4836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4837. fmt.Println(dat)
  4838. } else {
  4839. fmt.Println(err)
  4840. }
  4841. userJSONBytes, _ := json.Marshal(dat)
  4842. var res2 ResultThirteen
  4843. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. if res2.Infcode == 0 {
  4849. psnResult := &models.GdybPsnNcdsRecord{
  4850. UserOrgId: adminUser.CurrentOrgId,
  4851. PatientId: patient.ID,
  4852. PsnNo: psn_no,
  4853. DoctorId: doctor.AdminUserId,
  4854. DepartmentId: department_id,
  4855. SickType: sick_id,
  4856. Insutype: insutype,
  4857. Ctime: time.Now().Unix(),
  4858. Mtime: time.Now().Unix(),
  4859. Status: 1,
  4860. IsCancel: 1,
  4861. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4862. }
  4863. service.CreatePsnNCDSRecord(psnResult)
  4864. c.ServeSuccessJSON(map[string]interface{}{
  4865. "failed_code": 0,
  4866. "msg": "备案成功",
  4867. "result": psnResult,
  4868. })
  4869. } else {
  4870. c.ServeSuccessJSON(map[string]interface{}{
  4871. "failed_code": -10,
  4872. "msg": res2.ErrMsg,
  4873. })
  4874. return
  4875. }
  4876. }
  4877. }
  4878. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  4879. id, _ := c.GetInt64("id")
  4880. admin_user_id, _ := c.GetInt64("admin_user_id")
  4881. adminUser := c.GetAdminUserInfo()
  4882. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4884. var user_name string
  4885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4886. if role.ID == 0 {
  4887. user_name = "xxx"
  4888. } else {
  4889. user_name = role.UserName
  4890. }
  4891. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4892. if psn_record.ID == 0 {
  4893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4894. return
  4895. }
  4896. if config.IsOpen == 1 {
  4897. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4898. var dat map[string]interface{}
  4899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4900. fmt.Println(dat)
  4901. } else {
  4902. fmt.Println(err)
  4903. }
  4904. userJSONBytes, _ := json.Marshal(dat)
  4905. var res ResultFourteen
  4906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4907. utils.ErrorLog("解析失败:%v", err)
  4908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. return
  4910. }
  4911. if res.Infcode == 0 {
  4912. psn_record.IsCancel = 2
  4913. service.CreatePsnNCDSRecord(&psn_record)
  4914. c.ServeSuccessJSON(map[string]interface{}{
  4915. "failed_code": 0,
  4916. "msg": "撤销备案成功",
  4917. })
  4918. } else {
  4919. c.ServeSuccessJSON(map[string]interface{}{
  4920. "failed_code": -10,
  4921. "msg": res.ErrMsg,
  4922. })
  4923. return
  4924. }
  4925. }
  4926. }
  4927. func (c *HisApiController) TestTest() {
  4928. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  4929. fmt.Println(patient.Iinfo)
  4930. }
  4931. type CustomData struct {
  4932. MsgId string
  4933. PsnNo string
  4934. Info string
  4935. }
  4936. func (c *HisApiController) ReversalData() {
  4937. var customData []*CustomData
  4938. custom := &CustomData{
  4939. MsgId: "H44022900158202103301714472004",
  4940. PsnNo: "44020000001101329945",
  4941. Info: "2207",
  4942. }
  4943. customData = append(customData, custom)
  4944. custom1 := &CustomData{
  4945. MsgId: "H4402290015820210330172057803",
  4946. PsnNo: "44020000001101161813",
  4947. Info: "2207",
  4948. }
  4949. customData = append(customData, custom1)
  4950. custom2 := &CustomData{
  4951. MsgId: "H44022900158202103301705198813",
  4952. PsnNo: "44190000133097375417",
  4953. Info: "2207",
  4954. }
  4955. customData = append(customData, custom2)
  4956. custom3 := &CustomData{
  4957. MsgId: "H44022900158202103301715524756",
  4958. PsnNo: "44020000001100187221",
  4959. Info: "2207",
  4960. }
  4961. customData = append(customData, custom3)
  4962. custom4 := &CustomData{
  4963. MsgId: "H44022900158202103301730376224",
  4964. PsnNo: "44020000001101959155",
  4965. Info: "2207",
  4966. }
  4967. customData = append(customData, custom4)
  4968. custom5 := &CustomData{
  4969. MsgId: "H44022900158202103301748008725",
  4970. PsnNo: "44020000001104246641",
  4971. Info: "2207",
  4972. }
  4973. customData = append(customData, custom5)
  4974. custom6 := &CustomData{
  4975. MsgId: "H44022900158202103301718096755",
  4976. PsnNo: "44020000001102211860",
  4977. Info: "2207",
  4978. }
  4979. customData = append(customData, custom6)
  4980. custom7 := &CustomData{
  4981. MsgId: "H44022900158202103301736551640",
  4982. PsnNo: "44020000001102687718",
  4983. Info: "2207",
  4984. }
  4985. customData = append(customData, custom7)
  4986. custom8 := &CustomData{
  4987. MsgId: "H44022900158202103301743097676",
  4988. PsnNo: "44020000001102127785",
  4989. Info: "2207",
  4990. }
  4991. customData = append(customData, custom8)
  4992. custom9 := &CustomData{
  4993. MsgId: "H44022900158202103301712304203",
  4994. PsnNo: "44020000001101518097",
  4995. Info: "2207",
  4996. }
  4997. customData = append(customData, custom9)
  4998. custom10 := &CustomData{
  4999. MsgId: "H44022900158202103301738448785",
  5000. PsnNo: "44020000001100500813",
  5001. Info: "2207",
  5002. }
  5003. customData = append(customData, custom10)
  5004. custom11 := &CustomData{
  5005. MsgId: "H44022900158202103301732455843",
  5006. PsnNo: "44020000001102690557",
  5007. Info: "2207",
  5008. }
  5009. customData = append(customData, custom11)
  5010. custom12 := &CustomData{
  5011. MsgId: "H44022900158202103301745421708",
  5012. PsnNo: "44020000001102211928",
  5013. Info: "2207",
  5014. }
  5015. customData = append(customData, custom12)
  5016. custom1212 := &CustomData{
  5017. MsgId: "H440229001582021033017351627",
  5018. PsnNo: "44020000001102481733",
  5019. Info: "2207",
  5020. }
  5021. customData = append(customData, custom1212)
  5022. custom13 := &CustomData{
  5023. MsgId: "H44022900158202103301740327951",
  5024. PsnNo: "44020000001103174866",
  5025. Info: "2207",
  5026. }
  5027. customData = append(customData, custom13)
  5028. custom14 := &CustomData{
  5029. MsgId: "H4402290015820210330174922668",
  5030. PsnNo: "44020000001102927272",
  5031. Info: "2207",
  5032. }
  5033. customData = append(customData, custom14)
  5034. custom15 := &CustomData{
  5035. MsgId: "H44022900158202103301752362273",
  5036. PsnNo: "44020000001102942890",
  5037. Info: "2207",
  5038. }
  5039. customData = append(customData, custom15)
  5040. custom16 := &CustomData{
  5041. MsgId: "H44022900158202103301751082917",
  5042. PsnNo: "44020000001101662162",
  5043. Info: "2207",
  5044. }
  5045. customData = append(customData, custom16)
  5046. custom17 := &CustomData{
  5047. MsgId: "H44022900158202103301754147728",
  5048. PsnNo: "44020000000229014511",
  5049. Info: "2207",
  5050. }
  5051. customData = append(customData, custom17)
  5052. adminUser := c.GetAdminUserInfo()
  5053. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5054. for _, item := range customData {
  5055. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5056. fmt.Println(result)
  5057. }
  5058. }
  5059. func (c *HisApiController) ReversalOtherData() {
  5060. var customData []*CustomData
  5061. custom := &CustomData{
  5062. MsgId: "H44022900158202103301714472004",
  5063. PsnNo: "44020000001101329945",
  5064. Info: "2208",
  5065. }
  5066. customData = append(customData, custom)
  5067. custom1 := &CustomData{
  5068. MsgId: "H4402290015820210330172057803",
  5069. PsnNo: "44020000001101161813",
  5070. Info: "2208",
  5071. }
  5072. customData = append(customData, custom1)
  5073. custom2 := &CustomData{
  5074. MsgId: "H44022900158202103301705198813",
  5075. PsnNo: "44190000133097375417",
  5076. Info: "2208",
  5077. }
  5078. customData = append(customData, custom2)
  5079. custom3 := &CustomData{
  5080. MsgId: "H44022900158202103301715524756",
  5081. PsnNo: "44020000001100187221",
  5082. Info: "2208",
  5083. }
  5084. customData = append(customData, custom3)
  5085. custom4 := &CustomData{
  5086. MsgId: "H44022900158202103301730376224",
  5087. PsnNo: "44020000001101959155",
  5088. Info: "2208",
  5089. }
  5090. customData = append(customData, custom4)
  5091. custom5 := &CustomData{
  5092. MsgId: "H44022900158202103301748008725",
  5093. PsnNo: "44020000001104246641",
  5094. Info: "2208",
  5095. }
  5096. customData = append(customData, custom5)
  5097. custom6 := &CustomData{
  5098. MsgId: "H44022900158202103301718096755",
  5099. PsnNo: "44020000001102211860",
  5100. Info: "2208",
  5101. }
  5102. customData = append(customData, custom6)
  5103. custom7 := &CustomData{
  5104. MsgId: "H44022900158202103301736551640",
  5105. PsnNo: "44020000001102687718",
  5106. Info: "2208",
  5107. }
  5108. customData = append(customData, custom7)
  5109. custom8 := &CustomData{
  5110. MsgId: "H44022900158202103301743097676",
  5111. PsnNo: "44020000001102127785",
  5112. Info: "2208",
  5113. }
  5114. customData = append(customData, custom8)
  5115. custom9 := &CustomData{
  5116. MsgId: "H44022900158202103301712304203",
  5117. PsnNo: "44020000001101518097",
  5118. Info: "2208",
  5119. }
  5120. customData = append(customData, custom9)
  5121. custom10 := &CustomData{
  5122. MsgId: "H44022900158202103301738448785",
  5123. PsnNo: "44020000001100500813",
  5124. Info: "2208",
  5125. }
  5126. customData = append(customData, custom10)
  5127. custom11 := &CustomData{
  5128. MsgId: "H44022900158202103301732455843",
  5129. PsnNo: "44020000001102690557",
  5130. Info: "2208",
  5131. }
  5132. customData = append(customData, custom11)
  5133. custom12 := &CustomData{
  5134. MsgId: "H44022900158202103301745421708",
  5135. PsnNo: "44020000001102211928",
  5136. Info: "2208",
  5137. }
  5138. customData = append(customData, custom12)
  5139. custom1212 := &CustomData{
  5140. MsgId: "H440229001582021033017351627",
  5141. PsnNo: "44020000001102481733",
  5142. Info: "2208",
  5143. }
  5144. customData = append(customData, custom1212)
  5145. custom13 := &CustomData{
  5146. MsgId: "H44022900158202103301740327951",
  5147. PsnNo: "44020000001103174866",
  5148. Info: "2208",
  5149. }
  5150. customData = append(customData, custom13)
  5151. custom14 := &CustomData{
  5152. MsgId: "H4402290015820210330174922668",
  5153. PsnNo: "44020000001102927272",
  5154. Info: "2208",
  5155. }
  5156. customData = append(customData, custom14)
  5157. custom15 := &CustomData{
  5158. MsgId: "H44022900158202103301752362273",
  5159. PsnNo: "44020000001102942890",
  5160. Info: "2208",
  5161. }
  5162. customData = append(customData, custom15)
  5163. custom16 := &CustomData{
  5164. MsgId: "H44022900158202103301751082917",
  5165. PsnNo: "44020000001101662162",
  5166. Info: "2208",
  5167. }
  5168. customData = append(customData, custom16)
  5169. custom17 := &CustomData{
  5170. MsgId: "H44022900158202103301754147728",
  5171. PsnNo: "44020000000229014511",
  5172. Info: "2208",
  5173. }
  5174. customData = append(customData, custom17)
  5175. adminUser := c.GetAdminUserInfo()
  5176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5177. for _, item := range customData {
  5178. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5179. fmt.Println(result)
  5180. }
  5181. }
  5182. func PathExists(path string) (bool, error) {
  5183. _, err := os.Stat(path)
  5184. if err == nil {
  5185. return true, nil
  5186. }
  5187. if os.IsNotExist(err) {
  5188. return false, nil
  5189. }
  5190. return false, err
  5191. }
  5192. //创建文件夹
  5193. func Mkdir(dir string) {
  5194. // 创建文件夹
  5195. exist, err := PathExists(dir)
  5196. if err != nil {
  5197. fmt.Println(err.Error())
  5198. } else {
  5199. if exist {
  5200. fmt.Println(dir + "文件夹已存在!")
  5201. } else {
  5202. // 文件夹名称,权限
  5203. err := os.Mkdir(dir, os.ModePerm)
  5204. if err != nil {
  5205. fmt.Println(dir+"文件夹创建失败:", err.Error())
  5206. } else {
  5207. fmt.Println(dir + "文件夹创建成功!")
  5208. }
  5209. }
  5210. }
  5211. }
  5212. //压缩文件
  5213. func Zip(srcFile string, destZip string) error {
  5214. zipfile, err := os.Create(destZip)
  5215. if err != nil {
  5216. return err
  5217. }
  5218. defer zipfile.Close()
  5219. archive := zip.NewWriter(zipfile)
  5220. defer archive.Close()
  5221. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  5222. if err != nil {
  5223. return err
  5224. }
  5225. header, err := zip.FileInfoHeader(info)
  5226. if err != nil {
  5227. return err
  5228. }
  5229. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  5230. // header.Name = path
  5231. if info.IsDir() {
  5232. header.Name += "/"
  5233. } else {
  5234. header.Method = zip.Deflate
  5235. }
  5236. writer, err := archive.CreateHeader(header)
  5237. if err != nil {
  5238. return err
  5239. }
  5240. if !info.IsDir() {
  5241. file, err := os.Open(path)
  5242. if err != nil {
  5243. return err
  5244. }
  5245. defer file.Close()
  5246. _, err = io.Copy(writer, file)
  5247. }
  5248. return err
  5249. })
  5250. return err
  5251. }
  5252. func ReadFile(filePath string) []byte {
  5253. f, err := os.Open(filePath)
  5254. if err != nil {
  5255. fmt.Println("read file fail", err)
  5256. return nil
  5257. }
  5258. defer f.Close()
  5259. fd, err := ioutil.ReadAll(f)
  5260. if err != nil {
  5261. fmt.Println("read to fd fail", err)
  5262. return nil
  5263. }
  5264. return fd
  5265. }
  5266. func RemoveRepeatedCode(arr []string) (newArr []string) {
  5267. newArr = make([]string, 0)
  5268. for i := 0; i < len(arr); i++ {
  5269. repeat := false
  5270. for j := i + 1; j < len(arr); j++ {
  5271. if arr[i] == arr[j] {
  5272. repeat = true
  5273. break
  5274. }
  5275. }
  5276. if !repeat {
  5277. newArr = append(newArr, arr[i])
  5278. }
  5279. }
  5280. return
  5281. }