his_api_controller.go 202KB

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