his_api_controller.go 188KB

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