his_api_controller.go 188KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445
  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. if config.IsOpen == 1 {
  1494. 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)
  1495. resp, requestErr := http.Get(api)
  1496. if requestErr != nil {
  1497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1498. return
  1499. }
  1500. defer resp.Body.Close()
  1501. body, ioErr := ioutil.ReadAll(resp.Body)
  1502. if ioErr != nil {
  1503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1505. return
  1506. }
  1507. var respJSON map[string]interface{}
  1508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1511. return
  1512. }
  1513. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1514. userJSONBytes, _ := json.Marshal(userJSON)
  1515. var res ResultTwo
  1516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1517. utils.ErrorLog("解析失败:%v", err)
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1519. return
  1520. }
  1521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1523. infoStr := string(Iinfos)
  1524. idetinfoStr := string(Idetinfos)
  1525. if res.Infcode == 0 {
  1526. his := models.VMHisPatient{
  1527. Name: name,
  1528. Gender: gender,
  1529. Birthday: birthUnix,
  1530. MedicalTreatmentType: medical_care,
  1531. IdType: certificates,
  1532. IdCardNo: id_card,
  1533. BalanceAccountsType: settlementValue,
  1534. SocialType: social_type,
  1535. MedicalInsuranceNumber: medical_insurance_card,
  1536. RegisterType: register_type,
  1537. RegisterCost: registration_fee,
  1538. TreatmentCost: medical_expenses,
  1539. Status: 1,
  1540. Ctime: time.Now().Unix(),
  1541. Mtime: time.Now().Unix(),
  1542. PsnNo: res.Output.Baseinfo.PsnNo,
  1543. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1544. Certno: res.Output.Baseinfo.Certno,
  1545. PsnName: res.Output.Baseinfo.PsnName,
  1546. Gend: res.Output.Baseinfo.Gend,
  1547. Naty: res.Output.Baseinfo.Naty,
  1548. Brdy: res.Output.Baseinfo.Brdy,
  1549. Age: res.Output.Baseinfo.Age,
  1550. Iinfo: infoStr,
  1551. Idetinfo: idetinfoStr,
  1552. PatientId: patient.ID,
  1553. RecordDate: theTime.Unix(),
  1554. UserOrgId: adminInfo.CurrentOrgId,
  1555. AdminUserId: admin_user_id,
  1556. IsReturn: 1,
  1557. IdCardType: id_card_type,
  1558. Doctor: doctor,
  1559. Departments: department,
  1560. SickType: sick_type,
  1561. Diagnosis: diagnosis_id,
  1562. PType: reg_type,
  1563. }
  1564. timestamp := time.Now().Unix()
  1565. tempTime := time.Unix(timestamp, 0)
  1566. timeFormat := tempTime.Format("20060102150405")
  1567. chrgBchno := rand.Intn(100000) + 10000
  1568. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1569. count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1570. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1571. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1572. IdCardNo := ""
  1573. if id_card_type == 1 {
  1574. IdCardNo = medical_insurance_card
  1575. } else {
  1576. IdCardNo = patient.IdCardNo
  1577. }
  1578. var insutypes []string
  1579. var insutype string
  1580. var is390 int = 0
  1581. var is310 int = 0
  1582. for _, item := range res.Output.Iinfo {
  1583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1584. insutypes = append(insutypes, item.Insutype)
  1585. }
  1586. }
  1587. if len(insutypes) == 1 {
  1588. insutype = insutypes[0]
  1589. } else {
  1590. for _, i := range insutypes {
  1591. if i == "390" {
  1592. is390 = 1
  1593. }
  1594. if i == "310" {
  1595. is310 = 1
  1596. }
  1597. }
  1598. }
  1599. if is390 == 1 {
  1600. insutype = "390"
  1601. }
  1602. if is310 == 1 {
  1603. insutype = "310"
  1604. }
  1605. if len(insutypes) == 0 {
  1606. insutype = "310"
  1607. }
  1608. if count == 1 {
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1610. return
  1611. }
  1612. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1613. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1614. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1615. "&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)
  1616. resp, requestErr := http.Get(api)
  1617. if requestErr != nil {
  1618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1619. return
  1620. }
  1621. defer resp.Body.Close()
  1622. body, ioErr := ioutil.ReadAll(resp.Body)
  1623. if ioErr != nil {
  1624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1626. return
  1627. }
  1628. var respJSON map[string]interface{}
  1629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1632. return
  1633. }
  1634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1635. userJSONBytes, _ := json.Marshal(respJSON)
  1636. var res ResultThree
  1637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1638. utils.ErrorLog("解析失败:%v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. if res.Infcode != 0 {
  1643. adminUser := c.GetAdminUserInfo()
  1644. errlog := &models.HisOrderError{
  1645. UserOrgId: adminUser.CurrentOrgId,
  1646. Ctime: time.Now().Unix(),
  1647. Mtime: time.Now().Unix(),
  1648. ErrMsg: res.ErrMsg,
  1649. Status: 1,
  1650. PatientId: id,
  1651. RecordTime: recordDateTime,
  1652. Stage: 2,
  1653. }
  1654. service.CreateErrMsgLog(errlog)
  1655. c.ServeSuccessJSON(map[string]interface{}{
  1656. "failed_code": -10,
  1657. "msg": res.ErrMsg,
  1658. })
  1659. return
  1660. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1661. //return
  1662. }
  1663. his.Number = res.Output.Data.MdtrtID
  1664. his.PsnNo = res.Output.Data.PsnNo
  1665. his.IptOtpNo = res.Output.Data.IptOtpNo
  1666. his.IdCardNo = patient.IdCardNo
  1667. his.PhoneNumber = patient.Phone
  1668. his.UserOrgId = adminInfo.CurrentOrgId
  1669. his.Ctime = time.Now().Unix()
  1670. his.Mtime = time.Now().Unix()
  1671. his.Status = 0
  1672. service.CreateHisPatientTwo(&his)
  1673. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1674. if len(lists) == 1 {
  1675. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1676. }
  1677. if err == nil {
  1678. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  1679. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  1680. "&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 +
  1681. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  1682. resp2, requestErr2 := http.Get(api2)
  1683. if requestErr2 != nil {
  1684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1685. return
  1686. }
  1687. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1688. if ioErr2 != nil {
  1689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1691. return
  1692. }
  1693. var respJSON2 map[string]interface{}
  1694. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  1695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1697. return
  1698. }
  1699. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1700. userJSONBytes2, _ := json.Marshal(respJSON2)
  1701. var res2 ResultSix
  1702. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1703. utils.ErrorLog("解析失败:%v", err)
  1704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1705. return
  1706. }
  1707. if res2.Infcode != 0 {
  1708. adminUser := c.GetAdminUserInfo()
  1709. errlog := &models.HisOrderError{
  1710. UserOrgId: adminUser.CurrentOrgId,
  1711. Ctime: time.Now().Unix(),
  1712. Mtime: time.Now().Unix(),
  1713. ErrMsg: res2.ErrMsg,
  1714. Status: 1,
  1715. PatientId: id,
  1716. RecordTime: recordDateTime,
  1717. Stage: 3,
  1718. }
  1719. service.CreateErrMsgLog(errlog)
  1720. c.ServeSuccessJSON(map[string]interface{}{
  1721. "failed_code": -10,
  1722. "msg": res2.ErrMsg,
  1723. })
  1724. return
  1725. } else {
  1726. his.Status = 1
  1727. service.UpdateHisPatientStatus(&his)
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "his_info": his,
  1730. })
  1731. }
  1732. } else {
  1733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1734. return
  1735. }
  1736. } else {
  1737. adminUser := c.GetAdminUserInfo()
  1738. errlog := &models.HisOrderError{
  1739. UserOrgId: adminUser.CurrentOrgId,
  1740. Ctime: time.Now().Unix(),
  1741. Mtime: time.Now().Unix(),
  1742. ErrMsg: res.ErrMsg,
  1743. Status: 1,
  1744. PatientId: id,
  1745. RecordTime: recordDateTime,
  1746. Stage: 1,
  1747. }
  1748. service.CreateErrMsgLog(errlog)
  1749. c.ServeSuccessJSON(map[string]interface{}{
  1750. "failed_code": -10,
  1751. "msg": res.ErrMsg,
  1752. })
  1753. return
  1754. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1755. }
  1756. } else {
  1757. timeStr := time.Now().Format("2006-01-02")
  1758. timeArr := strings.Split(timeStr, "-")
  1759. var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(patient.ID, 10)
  1760. his, err := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1761. var hisPatient models.XtHisPatient
  1762. if err == gorm.ErrRecordNotFound || his.ID == 0 {
  1763. hisPatient = models.XtHisPatient{
  1764. Name: name,
  1765. Age: age,
  1766. Gender: gender,
  1767. Birthday: birthUnix,
  1768. Phone: phone,
  1769. MedicalTreatmentType: medical_care,
  1770. IdType: certificates,
  1771. IdCardNo: id_card,
  1772. BalanceAccountsType: settlementValue,
  1773. SocialType: social_type,
  1774. MedicalInsuranceNumber: medical_insurance_card,
  1775. RegisterType: register_type,
  1776. RegisterCost: registration_fee,
  1777. TreatmentCost: medical_expenses,
  1778. AdminUserId: admin_user_id,
  1779. UserOrgId: adminInfo.CurrentOrgId,
  1780. Status: 1,
  1781. RecordDate: recordDateTime,
  1782. IsReturn: 1,
  1783. PatientId: patient.ID,
  1784. Ctime: time.Now().Unix(),
  1785. Mtime: time.Now().Unix(),
  1786. Number: str,
  1787. }
  1788. service.CreateHisPatient(&hisPatient)
  1789. }
  1790. c.ServeSuccessJSON(map[string]interface{}{
  1791. "his_info": hisPatient,
  1792. })
  1793. }
  1794. }
  1795. //上传明细----预结算----确认订单
  1796. func (c *HisApiController) GetUploadInfo() {
  1797. id, _ := c.GetInt64("id")
  1798. record_time := c.GetString("record_time")
  1799. his_patient_id, _ := c.GetInt64("his_patient_id")
  1800. pay_way, _ := c.GetInt64("pay_way")
  1801. pay_price, _ := c.GetFloat("pay_price")
  1802. pay_card_no := c.GetString("pay_card_no")
  1803. discount_price, _ := c.GetFloat("discount_price")
  1804. preferential_price, _ := c.GetFloat("preferential_price")
  1805. reality_price, _ := c.GetFloat("reality_price")
  1806. found_price, _ := c.GetFloat("found_price")
  1807. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1808. private_price, _ := c.GetFloat("private_price")
  1809. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1810. admin_user_id, _ := c.GetInt64("admin_user_id")
  1811. fapiao_code := c.GetString("fapiao_code")
  1812. fapiao_number := c.GetString("fapiao_number")
  1813. timeLayout := "2006-01-02"
  1814. loc, _ := time.LoadLocation("Local")
  1815. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1816. if err != nil {
  1817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1818. return
  1819. }
  1820. recordDateTime := theTime.Unix()
  1821. adminUser := c.GetAdminUserInfo()
  1822. var prescriptions []*models.HisPrescription
  1823. var start_time int64
  1824. var end_time int64
  1825. //if adminUser.CurrentOrgId == 10106{
  1826. // if len(fapiao_code) == 0{
  1827. // fapiao_code = "144072080589"
  1828. // }
  1829. // if len(fapiao_number) == 0{
  1830. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1831. // if order.ID == 0{
  1832. // fapiao_number = "00001520"
  1833. // }else{
  1834. // //fapiao_code = "00001520"
  1835. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1836. // var zero string
  1837. // if fpNumber >= 1000{
  1838. // zero = "0000" + strconv.Itoa(fpNumber)
  1839. // }else if fpNumber >= 10000{
  1840. // zero = "000" + strconv.Itoa(fpNumber)
  1841. // } else if fpNumber >= 100000{
  1842. // zero = "00" + strconv.Itoa(fpNumber)
  1843. // } else if fpNumber >= 1000000{
  1844. // zero = "0" + strconv.Itoa(fpNumber)
  1845. // }else {
  1846. // zero = strconv.Itoa(fpNumber)
  1847. // }
  1848. // fapiao_number = zero
  1849. // }
  1850. // }
  1851. //}
  1852. data := make(map[string]interface{})
  1853. if settle_accounts_type == 1 { //日结
  1854. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1855. data["pre"] = prescriptions
  1856. } else { //月结
  1857. start_time_str := c.GetString("start_time")
  1858. end_time_str := c.GetString("end_time")
  1859. timeLayout := "2006-01-02"
  1860. loc, _ := time.LoadLocation("Local")
  1861. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1862. if err != nil {
  1863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1864. return
  1865. }
  1866. recordStartTime := theStartTime.Unix()
  1867. start_time = recordStartTime
  1868. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1869. if err != nil {
  1870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1871. return
  1872. }
  1873. recordEndTime := theEndTime.Unix()
  1874. end_time = recordEndTime
  1875. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1876. data["pre"] = prescriptions
  1877. }
  1878. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1879. fmt.Println(his_patient_id)
  1880. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1881. timestamp := time.Now().Unix()
  1882. tempTime := time.Unix(timestamp, 0)
  1883. timeFormat := tempTime.Format("20060102150405")
  1884. chrgBchno := rand.Intn(100000) + 10000
  1885. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1886. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1887. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1888. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1889. strconv.FormatInt(his.PatientId, 10)
  1890. client := &http.Client{}
  1891. data["psn_no"] = his.PsnNo
  1892. data["mdtrt_id"] = his.Number
  1893. data["chrg_bchno"] = chrg_bchno
  1894. data["org_name"] = miConfig.OrgName
  1895. data["doctor"] = roles.UserName
  1896. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1897. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1898. data["fixmedins_code"] = miConfig.Code
  1899. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1900. data["dept_code"] = "15"
  1901. } else {
  1902. data["dept_code"] = department.Number
  1903. }
  1904. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1905. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1906. data["secret_key"] = miConfig.SecretKey
  1907. var ids []int64
  1908. for _, item := range prescriptions {
  1909. ids = append(ids, item.ID)
  1910. }
  1911. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1912. if config.IsOpen == 1 { //对接了医保,走医保流程
  1913. bytesData, _ := json.Marshal(data)
  1914. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1915. resp, _ := client.Do(req)
  1916. defer resp.Body.Close()
  1917. body, ioErr := ioutil.ReadAll(resp.Body)
  1918. if ioErr != nil {
  1919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. return
  1922. }
  1923. var respJSON map[string]interface{}
  1924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. return
  1928. }
  1929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1930. userJSONBytes, _ := json.Marshal(respJSON)
  1931. var res ResultFour
  1932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1933. utils.ErrorLog("解析失败:%v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. if res.Infcode == 0 {
  1938. order := &models.HisOrder{
  1939. UserOrgId: adminUser.CurrentOrgId,
  1940. HisPatientId: his.ID,
  1941. PatientId: his.PatientId,
  1942. SettleAccountsDate: recordDateTime,
  1943. Ctime: time.Now().Unix(),
  1944. Mtime: time.Now().Unix(),
  1945. Status: 1,
  1946. Number: chrg_bchno,
  1947. Infcode: res.Infcode,
  1948. WarnMsg: res.WarnMsg,
  1949. Cainfo: res.Cainfo,
  1950. ErrMsg: res.ErrMsg,
  1951. RespondTime: res.RefmsgTime,
  1952. InfRefmsgid: res.InfRefmsgid,
  1953. OrderStatus: 1,
  1954. PayWay: pay_way,
  1955. PayPrice: pay_price,
  1956. PayCardNo: pay_card_no,
  1957. DiscountPrice: discount_price,
  1958. PreferentialPrice: preferential_price,
  1959. RealityPrice: reality_price,
  1960. FoundPrice: found_price,
  1961. MedicalInsurancePrice: medical_insurance_price,
  1962. PrivatePrice: private_price,
  1963. IsMedicineInsurance: 1,
  1964. SettleType: settle_accounts_type,
  1965. SettleStartTime: start_time,
  1966. SettleEndTime: end_time,
  1967. Creator: roles.AdminUserId,
  1968. Modify: roles.AdminUserId,
  1969. FaPiaoNumber: fapiao_number,
  1970. FaPiaoCode: fapiao_code,
  1971. PType: 2,
  1972. }
  1973. err = service.CreateOrder(order)
  1974. if err != nil {
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1976. return
  1977. }
  1978. for _, item := range res.Output.Result {
  1979. temp := strings.Split(item.FeedetlSn, "-")
  1980. var advice_id int64 = 0
  1981. var project_id int64 = 0
  1982. var types int64 = 0
  1983. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1984. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1985. if temp[1] == "1" {
  1986. advice_id = id
  1987. project_id = 0
  1988. } else if temp[1] == "2" {
  1989. advice_id = 0
  1990. project_id = id
  1991. }
  1992. info := &models.HisOrderInfo{
  1993. OrderNumber: order.Number,
  1994. FeedetlSn: item.FeedetlSn,
  1995. UploadDate: time.Now().Unix(),
  1996. AdviceId: advice_id,
  1997. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1998. Cnt: item.Cnt,
  1999. Pric: float64(item.Pric),
  2000. PatientId: his.PatientId,
  2001. PricUplmtAmt: item.PricUplmtAmt,
  2002. SelfpayProp: item.SelfpayProp,
  2003. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2004. OverlmtAmt: item.OverlmtAmt,
  2005. PreselfpayAmt: item.PreselfpayAmt,
  2006. BasMednFlag: item.BasMednFlag,
  2007. MedChrgitmType: item.MedChrgitmType,
  2008. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2009. Status: 1,
  2010. Memo: item.Memo,
  2011. Mtime: time.Now().Unix(),
  2012. InscpScpAmt: item.InscpScpAmt,
  2013. DrtReimFlag: item.DrtReimFlag,
  2014. Ctime: time.Now().Unix(),
  2015. ListSpItemFlag: item.ListSpItemFlag,
  2016. ChldMedcFlag: item.ChldMedcFlag,
  2017. LmtUsedFlag: item.LmtUsedFlag,
  2018. ChrgitmLv: item.ChrgitmLv,
  2019. UserOrgId: adminUser.CurrentOrgId,
  2020. HisPatientId: his.ID,
  2021. OrderId: order.ID,
  2022. ProjectId: project_id,
  2023. Type: types,
  2024. }
  2025. service.CreateOrderInfo(info)
  2026. }
  2027. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2028. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2029. var total float64
  2030. for _, item := range prescriptions {
  2031. if item.Type == 1 { //药品
  2032. for _, subItem := range item.HisDoctorAdviceInfo {
  2033. total = total + (subItem.Price * subItem.PrescribingNumber)
  2034. }
  2035. }
  2036. if item.Type == 2 { //项目
  2037. for _, subItem := range item.HisPrescriptionProject {
  2038. total = total + (subItem.Price * float64(subItem.Count))
  2039. }
  2040. }
  2041. }
  2042. for _, item := range prescriptions {
  2043. for _, subItem := range item.HisAdditionalCharge {
  2044. total = total + (subItem.Price * float64(subItem.Count))
  2045. }
  2046. }
  2047. allTotal := fmt.Sprintf("%.2f", total)
  2048. if res.Infcode == 0 {
  2049. var rf []*ResultFive
  2050. json.Unmarshal([]byte(his.Iinfo), &rf)
  2051. chrg_bchno := chrg_bchno
  2052. cert_no := his.Certno
  2053. var insutypes []string
  2054. var insutype string
  2055. var is390 int = 0
  2056. var is310 int = 0
  2057. for _, item := range rf {
  2058. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2059. insutypes = append(insutypes, item.Insutype)
  2060. }
  2061. }
  2062. if len(insutypes) == 1 {
  2063. insutype = insutypes[0]
  2064. } else {
  2065. for _, i := range insutypes {
  2066. if i == "390" {
  2067. is390 = 1
  2068. }
  2069. if i == "310" {
  2070. is310 = 1
  2071. }
  2072. }
  2073. }
  2074. if is390 == 1 {
  2075. insutype = "390"
  2076. }
  2077. if is310 == 1 {
  2078. insutype = "310"
  2079. }
  2080. if len(insutypes) == 0 {
  2081. insutype = "310"
  2082. }
  2083. if his.IdCardType == 1 {
  2084. cert_no = his.MedicalInsuranceNumber
  2085. } else {
  2086. cert_no = his.Certno
  2087. }
  2088. 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)
  2089. var dat map[string]interface{}
  2090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2091. fmt.Println(dat)
  2092. } else {
  2093. fmt.Println(err)
  2094. }
  2095. userJSONBytes, _ := json.Marshal(dat)
  2096. var res ResultSeven
  2097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2098. utils.ErrorLog("解析失败:%v", err)
  2099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2100. return
  2101. }
  2102. if res.Infcode != 0 {
  2103. errlog := &models.HisOrderError{
  2104. UserOrgId: adminUser.CurrentOrgId,
  2105. Ctime: time.Now().Unix(),
  2106. Mtime: time.Now().Unix(),
  2107. Number: chrg_bchno,
  2108. ErrMsg: res.ErrMsg,
  2109. Status: 1,
  2110. PatientId: id,
  2111. RecordTime: recordDateTime,
  2112. Stage: 6,
  2113. }
  2114. service.CreateErrMsgLog(errlog)
  2115. c.ServeSuccessJSON(map[string]interface{}{
  2116. "failed_code": -10,
  2117. "msg": res.ErrMsg,
  2118. })
  2119. return
  2120. } else {
  2121. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2122. order.OrderStatus = 2
  2123. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2124. order.SetlId = res.Output.Setlinfo.SetlID
  2125. order.PsnNo = res.Output.Setlinfo.PsnNo
  2126. order.PsnName = res.Output.Setlinfo.PsnName
  2127. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2128. order.Certno = res.Output.Setlinfo.Certno
  2129. order.Gend = res.Output.Setlinfo.Gend
  2130. order.Naty = res.Output.Setlinfo.Naty
  2131. order.Age = res.Output.Setlinfo.Age
  2132. order.Insutype = res.Output.Setlinfo.Insutype
  2133. order.PsnType = res.Output.Setlinfo.PsnType
  2134. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2135. order.SetlTime = res.Output.Setlinfo.SetlTime
  2136. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2137. order.MedType = res.Output.Setlinfo.MedType
  2138. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2139. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2140. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2141. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2142. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2143. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2144. order.HifpPay = res.Output.Setlinfo.HifpPay
  2145. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2146. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2147. order.HifesPay = res.Output.Setlinfo.HifesPay
  2148. order.HifobPay = res.Output.Setlinfo.HifobPay
  2149. order.MafPay = res.Output.Setlinfo.MafPay
  2150. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2151. order.OthPay = res.Output.Setlinfo.OthPay
  2152. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2153. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2154. order.AcctPay = res.Output.Setlinfo.AcctPay
  2155. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2156. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2157. order.Balc = res.Output.Setlinfo.Balc
  2158. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2159. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2160. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2161. order.ClrWay = res.Output.Setlinfo.ClrWay
  2162. order.Creator = order.Creator
  2163. order.Modify = roles.AdminUserId
  2164. order.RequestLog = src_resquest
  2165. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2166. detailStr := string(setlDetail)
  2167. order.SetlDetail = detailStr
  2168. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2169. err = service.UpDateOrder(order)
  2170. if err == nil {
  2171. c.ServeSuccessJSON(map[string]interface{}{
  2172. "msg": "结算成功",
  2173. })
  2174. } else {
  2175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2176. return
  2177. }
  2178. }
  2179. } else {
  2180. adminUser := c.GetAdminUserInfo()
  2181. errlog := &models.HisOrderError{
  2182. UserOrgId: adminUser.CurrentOrgId,
  2183. Ctime: time.Now().Unix(),
  2184. Mtime: time.Now().Unix(),
  2185. ErrMsg: res.ErrMsg,
  2186. Status: 1,
  2187. PatientId: id,
  2188. RecordTime: recordDateTime,
  2189. Stage: 4,
  2190. }
  2191. service.CreateErrMsgLog(errlog)
  2192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2193. return
  2194. }
  2195. } else {
  2196. adminUser := c.GetAdminUserInfo()
  2197. errlog := &models.HisOrderError{
  2198. UserOrgId: adminUser.CurrentOrgId,
  2199. Ctime: time.Now().Unix(),
  2200. Mtime: time.Now().Unix(),
  2201. ErrMsg: res.ErrMsg,
  2202. Status: 1,
  2203. PatientId: id,
  2204. RecordTime: recordDateTime,
  2205. Stage: 4,
  2206. }
  2207. service.CreateErrMsgLog(errlog)
  2208. c.ServeSuccessJSON(map[string]interface{}{
  2209. "failed_code": -10,
  2210. "msg": res.ErrMsg,
  2211. })
  2212. return
  2213. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2214. //return
  2215. }
  2216. } else {
  2217. var total float64
  2218. for _, item := range prescriptions {
  2219. if item.Type == 1 { //药品
  2220. for _, subItem := range item.HisDoctorAdviceInfo {
  2221. total = total + (subItem.Price * subItem.PrescribingNumber)
  2222. }
  2223. }
  2224. if item.Type == 2 { //项目
  2225. for _, subItem := range item.HisPrescriptionProject {
  2226. total = total + (subItem.Price * float64(subItem.Count))
  2227. }
  2228. }
  2229. for _, subItem := range item.HisAdditionalCharge {
  2230. total = total + (subItem.Price * float64(subItem.Count))
  2231. }
  2232. }
  2233. allTotal := fmt.Sprintf("%.2f", total)
  2234. totals, _ := strconv.ParseFloat(allTotal, 64)
  2235. order := &models.HisOrder{
  2236. UserOrgId: adminUser.CurrentOrgId,
  2237. HisPatientId: his.ID,
  2238. PatientId: id,
  2239. SettleAccountsDate: recordDateTime,
  2240. Ctime: time.Now().Unix(),
  2241. Mtime: time.Now().Unix(),
  2242. Status: 1,
  2243. OrderStatus: 2,
  2244. Number: chrg_bchno,
  2245. MedfeeSumamt: totals,
  2246. PayWay: pay_way,
  2247. PayPrice: pay_price,
  2248. PayCardNo: pay_card_no,
  2249. DiscountPrice: discount_price,
  2250. PreferentialPrice: preferential_price,
  2251. RealityPrice: reality_price,
  2252. FoundPrice: found_price,
  2253. MedicalInsurancePrice: medical_insurance_price,
  2254. PrivatePrice: private_price,
  2255. }
  2256. err = service.CreateOrder(order)
  2257. if err != nil {
  2258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2259. return
  2260. }
  2261. var customs []*Custom
  2262. for _, item := range prescriptions {
  2263. if item.Type == 1 { //药品
  2264. for _, subItem := range item.HisDoctorAdviceInfo {
  2265. cus := &Custom{
  2266. AdviceId: subItem.ID,
  2267. ProjectId: 0,
  2268. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2269. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2270. FeedetlSn: subItem.FeedetlSn,
  2271. Price: fmt.Sprintf("%.2f", subItem.Price),
  2272. MedListCodg: subItem.MedListCodg,
  2273. Type: 1,
  2274. }
  2275. customs = append(customs, cus)
  2276. }
  2277. }
  2278. if item.Type == 2 { //项目
  2279. for _, subItem := range item.HisPrescriptionProject {
  2280. cus := &Custom{
  2281. AdviceId: 0,
  2282. ProjectId: subItem.ID,
  2283. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2284. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2285. FeedetlSn: subItem.FeedetlSn,
  2286. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2287. MedListCodg: subItem.MedListCodg,
  2288. Type: 2,
  2289. }
  2290. customs = append(customs, cus)
  2291. }
  2292. }
  2293. for _, item := range item.HisAdditionalCharge {
  2294. cus := &Custom{
  2295. ItemId: item.ID,
  2296. AdviceId: 0,
  2297. ProjectId: 0,
  2298. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2299. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2300. FeedetlSn: item.FeedetlSn,
  2301. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2302. MedListCodg: item.XtHisAddtionConfig.Code,
  2303. Type: 3,
  2304. }
  2305. customs = append(customs, cus)
  2306. }
  2307. }
  2308. for _, item := range customs {
  2309. var advice_id int64 = 0
  2310. var project_id int64 = 0
  2311. var item_id int64 = 0
  2312. var types int64 = 0
  2313. if item.Type == 1 {
  2314. advice_id = item.AdviceId
  2315. project_id = 0
  2316. item_id = 0
  2317. } else if item.Type == 2 {
  2318. advice_id = 0
  2319. item_id = 0
  2320. project_id = item.ProjectId
  2321. } else if item.Type == 3 {
  2322. advice_id = 0
  2323. item_id = item.ItemId
  2324. project_id = 0
  2325. }
  2326. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2327. cut, _ := strconv.ParseFloat(item.Cut, 32)
  2328. pric, _ := strconv.ParseFloat(item.Price, 32)
  2329. info := &models.HisOrderInfo{
  2330. OrderNumber: order.Number,
  2331. UploadDate: time.Now().Unix(),
  2332. AdviceId: advice_id,
  2333. DetItemFeeSumamt: detItemFeeSumamt,
  2334. Cnt: cut,
  2335. Pric: pric,
  2336. PatientId: id,
  2337. Status: 1,
  2338. Mtime: time.Now().Unix(),
  2339. Ctime: time.Now().Unix(),
  2340. UserOrgId: adminUser.CurrentOrgId,
  2341. HisPatientId: his.ID,
  2342. OrderId: order.ID,
  2343. ProjectId: project_id,
  2344. Type: types,
  2345. ItemId: item_id,
  2346. }
  2347. service.CreateOrderInfo(info)
  2348. }
  2349. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2350. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2351. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2352. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2353. if err == nil {
  2354. c.ServeSuccessJSON(map[string]interface{}{
  2355. "msg": "结算成功",
  2356. })
  2357. } else {
  2358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2359. return
  2360. }
  2361. }
  2362. }
  2363. func (c *HisApiController) GetPreUploadInfo() {
  2364. id, _ := c.GetInt64("id")
  2365. record_time := c.GetString("record_time")
  2366. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2367. admin_user_id, _ := c.GetInt64("admin_user_id")
  2368. timeLayout := "2006-01-02"
  2369. loc, _ := time.LoadLocation("Local")
  2370. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2371. if err != nil {
  2372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2373. return
  2374. }
  2375. recordDateTime := theTime.Unix()
  2376. adminUser := c.GetAdminUserInfo()
  2377. var prescriptions []*models.HisPrescription
  2378. var start_time int64
  2379. var end_time int64
  2380. data := make(map[string]interface{})
  2381. if settle_accounts_type == 1 { //日结
  2382. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2383. data["pre"] = prescriptions
  2384. } else { //月结
  2385. start_time_str := c.GetString("start_time")
  2386. end_time_str := c.GetString("end_time")
  2387. timeLayout := "2006-01-02"
  2388. loc, _ := time.LoadLocation("Local")
  2389. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2390. if err != nil {
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2392. return
  2393. }
  2394. recordStartTime := theStartTime.Unix()
  2395. start_time = recordStartTime
  2396. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2397. if err != nil {
  2398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2399. return
  2400. }
  2401. recordEndTime := theEndTime.Unix()
  2402. end_time = recordEndTime
  2403. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2404. data["pre"] = prescriptions
  2405. }
  2406. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2407. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2408. timestamp := time.Now().Unix()
  2409. tempTime := time.Unix(timestamp, 0)
  2410. timeFormat := tempTime.Format("20060102150405")
  2411. chrgBchno := rand.Intn(100000) + 10000
  2412. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2414. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2415. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2416. strconv.FormatInt(his.PatientId, 10)
  2417. client := &http.Client{}
  2418. data["psn_no"] = his.PsnNo
  2419. data["mdtrt_id"] = his.Number
  2420. data["chrg_bchno"] = chrg_bchno
  2421. data["org_name"] = miConfig.OrgName
  2422. data["doctor"] = roles.UserName
  2423. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2424. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2425. data["fixmedins_code"] = miConfig.Code
  2426. data["dept_code"] = department.Number
  2427. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2428. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2429. data["secret_key"] = miConfig.SecretKey
  2430. var ids []int64
  2431. for _, item := range prescriptions {
  2432. ids = append(ids, item.ID)
  2433. }
  2434. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2435. if config.IsOpen == 1 { //对接了医保,走医保流程
  2436. bytesData, _ := json.Marshal(data)
  2437. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2438. resp, _ := client.Do(req)
  2439. defer resp.Body.Close()
  2440. body, ioErr := ioutil.ReadAll(resp.Body)
  2441. if ioErr != nil {
  2442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. return
  2445. }
  2446. var respJSON map[string]interface{}
  2447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2450. return
  2451. }
  2452. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2453. userJSONBytes, _ := json.Marshal(respJSON)
  2454. var res ResultFour
  2455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2456. utils.ErrorLog("解析失败:%v", err)
  2457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2458. return
  2459. }
  2460. if res.Infcode == 0 {
  2461. order := &models.HisOrder{
  2462. UserOrgId: adminUser.CurrentOrgId,
  2463. HisPatientId: his.ID,
  2464. PatientId: his.PatientId,
  2465. SettleAccountsDate: recordDateTime,
  2466. Ctime: time.Now().Unix(),
  2467. Mtime: time.Now().Unix(),
  2468. Status: 1,
  2469. Number: chrg_bchno,
  2470. Infcode: res.Infcode,
  2471. WarnMsg: res.WarnMsg,
  2472. Cainfo: res.Cainfo,
  2473. ErrMsg: res.ErrMsg,
  2474. RespondTime: res.RefmsgTime,
  2475. InfRefmsgid: res.InfRefmsgid,
  2476. OrderStatus: 1,
  2477. IsMedicineInsurance: 1,
  2478. SettleType: settle_accounts_type,
  2479. SettleStartTime: start_time,
  2480. SettleEndTime: end_time,
  2481. Creator: roles.ID,
  2482. Modify: roles.ID,
  2483. }
  2484. err = service.CreateOrder(order)
  2485. if err != nil {
  2486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2487. return
  2488. }
  2489. for _, item := range res.Output.Result {
  2490. temp := strings.Split(item.FeedetlSn, "-")
  2491. var advice_id int64 = 0
  2492. var project_id int64 = 0
  2493. var types int64 = 0
  2494. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2495. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2496. if temp[1] == "1" {
  2497. advice_id = id
  2498. project_id = 0
  2499. } else if temp[1] == "2" {
  2500. advice_id = 0
  2501. project_id = id
  2502. }
  2503. info := &models.HisOrderInfo{
  2504. OrderNumber: order.Number,
  2505. FeedetlSn: item.FeedetlSn,
  2506. UploadDate: time.Now().Unix(),
  2507. AdviceId: advice_id,
  2508. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2509. Cnt: item.Cnt,
  2510. Pric: float64(item.Pric),
  2511. PatientId: his.PatientId,
  2512. PricUplmtAmt: item.PricUplmtAmt,
  2513. SelfpayProp: item.SelfpayProp,
  2514. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2515. OverlmtAmt: item.OverlmtAmt,
  2516. PreselfpayAmt: item.PreselfpayAmt,
  2517. BasMednFlag: item.BasMednFlag,
  2518. MedChrgitmType: item.MedChrgitmType,
  2519. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2520. Status: 1,
  2521. Memo: item.Memo,
  2522. Mtime: time.Now().Unix(),
  2523. InscpScpAmt: item.InscpScpAmt,
  2524. DrtReimFlag: item.DrtReimFlag,
  2525. Ctime: time.Now().Unix(),
  2526. ListSpItemFlag: item.ListSpItemFlag,
  2527. ChldMedcFlag: item.ChldMedcFlag,
  2528. LmtUsedFlag: item.LmtUsedFlag,
  2529. ChrgitmLv: item.ChrgitmLv,
  2530. UserOrgId: adminUser.CurrentOrgId,
  2531. HisPatientId: his.ID,
  2532. OrderId: order.ID,
  2533. ProjectId: project_id,
  2534. Type: types,
  2535. }
  2536. service.CreateOrderInfo(info)
  2537. }
  2538. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2539. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2540. var total float64
  2541. for _, item := range prescriptions {
  2542. if item.Type == 1 { //药品
  2543. for _, subItem := range item.HisDoctorAdviceInfo {
  2544. total = total + (subItem.Price * subItem.PrescribingNumber)
  2545. }
  2546. }
  2547. if item.Type == 2 { //项目
  2548. for _, subItem := range item.HisPrescriptionProject {
  2549. total = total + (subItem.Price * float64(subItem.Count))
  2550. }
  2551. }
  2552. }
  2553. for _, item := range prescriptions {
  2554. for _, subItem := range item.HisAdditionalCharge {
  2555. total = total + (subItem.Price * float64(subItem.Count))
  2556. }
  2557. }
  2558. allTotal := fmt.Sprintf("%.2f", total)
  2559. if res.Infcode == 0 {
  2560. var rf []*ResultFive
  2561. json.Unmarshal([]byte(his.Iinfo), &rf)
  2562. psn_no := his.PsnNo
  2563. mdtrt_id := his.Number
  2564. chrg_bchno := chrg_bchno
  2565. cert_no := his.Certno
  2566. insutype := rf[0].Insutype
  2567. if his.IdCardType == 1 {
  2568. cert_no = his.MedicalInsuranceNumber
  2569. } else {
  2570. cert_no = his.Certno
  2571. }
  2572. api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2573. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2574. "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2575. miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2576. resp, requestErr := http.Get(api)
  2577. if requestErr != nil {
  2578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2579. return
  2580. }
  2581. defer resp.Body.Close()
  2582. body, ioErr := ioutil.ReadAll(resp.Body)
  2583. if ioErr != nil {
  2584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2586. return
  2587. }
  2588. var respJSON map[string]interface{}
  2589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. return
  2593. }
  2594. fmt.Println(respJSON)
  2595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2596. userJSONBytes, _ := json.Marshal(respJSON)
  2597. var res ResultSeven
  2598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2599. utils.ErrorLog("解析失败:%v", err)
  2600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2601. return
  2602. }
  2603. if res.Infcode != 0 {
  2604. errlog := &models.HisOrderError{
  2605. UserOrgId: adminUser.CurrentOrgId,
  2606. Ctime: time.Now().Unix(),
  2607. Mtime: time.Now().Unix(),
  2608. Number: chrg_bchno,
  2609. ErrMsg: res.ErrMsg,
  2610. Status: 1,
  2611. PatientId: id,
  2612. RecordTime: recordDateTime,
  2613. Stage: 7,
  2614. }
  2615. service.CreateErrMsgLog(errlog)
  2616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2617. return
  2618. } else {
  2619. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2620. order.OrderStatus = 1
  2621. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2622. order.SetlId = res.Output.Setlinfo.SetlID
  2623. order.PsnNo = res.Output.Setlinfo.PsnNo
  2624. order.PsnName = res.Output.Setlinfo.PsnName
  2625. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2626. order.Certno = res.Output.Setlinfo.Certno
  2627. order.Gend = res.Output.Setlinfo.Gend
  2628. order.Naty = res.Output.Setlinfo.Naty
  2629. order.Age = res.Output.Setlinfo.Age
  2630. order.Insutype = res.Output.Setlinfo.Insutype
  2631. order.PsnType = res.Output.Setlinfo.PsnType
  2632. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2633. order.SetlTime = res.Output.Setlinfo.SetlTime
  2634. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2635. order.MedType = res.Output.Setlinfo.MedType
  2636. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2637. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2638. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2639. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2640. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2641. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2642. order.HifpPay = res.Output.Setlinfo.HifpPay
  2643. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2644. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2645. order.HifesPay = res.Output.Setlinfo.HifesPay
  2646. order.HifobPay = res.Output.Setlinfo.HifobPay
  2647. order.MafPay = res.Output.Setlinfo.MafPay
  2648. order.OthPay = res.Output.Setlinfo.OthPay
  2649. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2650. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2651. order.AcctPay = res.Output.Setlinfo.AcctPay
  2652. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2653. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2654. order.Balc = res.Output.Setlinfo.Balc
  2655. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2656. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2657. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2658. order.ClrWay = res.Output.Setlinfo.ClrWay
  2659. order.Creator = order.Creator
  2660. order.Modify = roles.ID
  2661. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2662. detailStr := string(setlDetail)
  2663. order.SetlDetail = detailStr
  2664. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2665. err = service.UpDateOrder(order)
  2666. if err == nil {
  2667. c.ServeSuccessJSON(map[string]interface{}{
  2668. "msg": "预结算成功",
  2669. })
  2670. } else {
  2671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2672. return
  2673. }
  2674. }
  2675. } else {
  2676. adminUser := c.GetAdminUserInfo()
  2677. errlog := &models.HisOrderError{
  2678. UserOrgId: adminUser.CurrentOrgId,
  2679. Ctime: time.Now().Unix(),
  2680. Mtime: time.Now().Unix(),
  2681. ErrMsg: res.ErrMsg,
  2682. Status: 1,
  2683. PatientId: id,
  2684. RecordTime: recordDateTime,
  2685. Stage: 4,
  2686. }
  2687. service.CreateErrMsgLog(errlog)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2689. return
  2690. }
  2691. } else {
  2692. adminUser := c.GetAdminUserInfo()
  2693. errlog := &models.HisOrderError{
  2694. UserOrgId: adminUser.CurrentOrgId,
  2695. Ctime: time.Now().Unix(),
  2696. Mtime: time.Now().Unix(),
  2697. ErrMsg: res.ErrMsg,
  2698. Status: 1,
  2699. PatientId: id,
  2700. RecordTime: recordDateTime,
  2701. Stage: 4,
  2702. }
  2703. service.CreateErrMsgLog(errlog)
  2704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2705. return
  2706. }
  2707. } else {
  2708. var total float64
  2709. for _, item := range prescriptions {
  2710. if item.Type == 1 { //药品
  2711. for _, subItem := range item.HisDoctorAdviceInfo {
  2712. total = total + (subItem.Price * subItem.PrescribingNumber)
  2713. }
  2714. }
  2715. if item.Type == 2 { //项目
  2716. for _, subItem := range item.HisPrescriptionProject {
  2717. total = total + (subItem.Price * float64(subItem.Count))
  2718. }
  2719. }
  2720. for _, subItem := range item.HisAdditionalCharge {
  2721. total = total + (subItem.Price * float64(subItem.Count))
  2722. }
  2723. }
  2724. allTotal := fmt.Sprintf("%.2f", total)
  2725. totals, _ := strconv.ParseFloat(allTotal, 64)
  2726. order := &models.HisOrder{
  2727. UserOrgId: adminUser.CurrentOrgId,
  2728. HisPatientId: his.ID,
  2729. PatientId: id,
  2730. SettleAccountsDate: recordDateTime,
  2731. Ctime: time.Now().Unix(),
  2732. Mtime: time.Now().Unix(),
  2733. Status: 1,
  2734. OrderStatus: 2,
  2735. Number: chrg_bchno,
  2736. MedfeeSumamt: totals,
  2737. }
  2738. err = service.CreateOrder(order)
  2739. if err != nil {
  2740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2741. return
  2742. }
  2743. var customs []*Custom
  2744. for _, item := range prescriptions {
  2745. if item.Type == 1 { //药品
  2746. for _, subItem := range item.HisDoctorAdviceInfo {
  2747. cus := &Custom{
  2748. AdviceId: subItem.ID,
  2749. ProjectId: 0,
  2750. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2751. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2752. FeedetlSn: subItem.FeedetlSn,
  2753. Price: fmt.Sprintf("%.2f", subItem.Price),
  2754. MedListCodg: subItem.MedListCodg,
  2755. Type: 1,
  2756. }
  2757. customs = append(customs, cus)
  2758. }
  2759. }
  2760. if item.Type == 2 { //项目
  2761. for _, subItem := range item.HisPrescriptionProject {
  2762. cus := &Custom{
  2763. AdviceId: 0,
  2764. ProjectId: subItem.ID,
  2765. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2766. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2767. FeedetlSn: subItem.FeedetlSn,
  2768. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2769. MedListCodg: subItem.MedListCodg,
  2770. Type: 2,
  2771. }
  2772. customs = append(customs, cus)
  2773. }
  2774. }
  2775. for _, item := range item.HisAdditionalCharge {
  2776. cus := &Custom{
  2777. ItemId: item.ID,
  2778. AdviceId: 0,
  2779. ProjectId: 0,
  2780. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2781. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2782. FeedetlSn: item.FeedetlSn,
  2783. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2784. MedListCodg: item.XtHisAddtionConfig.Code,
  2785. Type: 3,
  2786. }
  2787. customs = append(customs, cus)
  2788. }
  2789. }
  2790. for _, item := range customs {
  2791. var advice_id int64 = 0
  2792. var project_id int64 = 0
  2793. var item_id int64 = 0
  2794. var types int64 = 0
  2795. if item.Type == 1 {
  2796. advice_id = item.AdviceId
  2797. project_id = 0
  2798. item_id = 0
  2799. } else if item.Type == 2 {
  2800. advice_id = 0
  2801. item_id = 0
  2802. project_id = item.ProjectId
  2803. } else if item.Type == 3 {
  2804. advice_id = 0
  2805. item_id = item.ItemId
  2806. project_id = 0
  2807. }
  2808. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2809. cut, _ := strconv.ParseFloat(item.Cut, 32)
  2810. pric, _ := strconv.ParseFloat(item.Price, 32)
  2811. info := &models.HisOrderInfo{
  2812. OrderNumber: order.Number,
  2813. UploadDate: time.Now().Unix(),
  2814. AdviceId: advice_id,
  2815. DetItemFeeSumamt: detItemFeeSumamt,
  2816. Cnt: cut,
  2817. Pric: pric,
  2818. PatientId: id,
  2819. Status: 1,
  2820. Mtime: time.Now().Unix(),
  2821. Ctime: time.Now().Unix(),
  2822. UserOrgId: adminUser.CurrentOrgId,
  2823. HisPatientId: his.ID,
  2824. OrderId: order.ID,
  2825. ProjectId: project_id,
  2826. Type: types,
  2827. ItemId: item_id,
  2828. }
  2829. service.CreateOrderInfo(info)
  2830. }
  2831. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2832. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2833. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2834. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2835. if err == nil {
  2836. c.ServeSuccessJSON(map[string]interface{}{
  2837. "msg": "结算成功",
  2838. })
  2839. } else {
  2840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2841. return
  2842. }
  2843. }
  2844. }
  2845. //func (c *HisApiController) GetSettleInfo() {
  2846. // id, _ := c.GetInt64("id")
  2847. // order_id, _ := c.GetInt64("order_id")
  2848. //
  2849. // record_time := c.GetString("record_time")
  2850. // pay_way, _ := c.GetInt64("pay_way")
  2851. // pay_price, _ := c.GetFloat("pay_price")
  2852. // pay_card_no := c.GetString("pay_card_no")
  2853. // discount_price, _ := c.GetFloat("discount_price")
  2854. // preferential_price, _ := c.GetFloat("preferential_price")
  2855. // reality_price, _ := c.GetFloat("reality_price")
  2856. // found_price, _ := c.GetFloat("found_price")
  2857. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2858. // private_price, _ := c.GetFloat("private_price")
  2859. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2860. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2861. //
  2862. // timeLayout := "2006-01-02"
  2863. // loc, _ := time.LoadLocation("Local")
  2864. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2865. // if err != nil {
  2866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2867. // return
  2868. // }
  2869. // recordDateTime := theTime.Unix()
  2870. // adminUser := c.GetAdminUserInfo()
  2871. //
  2872. // var prescriptions []*models.HisPrescription
  2873. //
  2874. // data := make(map[string]interface{})
  2875. // if settle_accounts_type == 1 { //日结
  2876. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2877. // data["pre"] = prescriptions
  2878. //
  2879. // } else { //月结
  2880. // start_time_str := c.GetString("start_time")
  2881. // end_time_str := c.GetString("end_time")
  2882. // timeLayout := "2006-01-02"
  2883. // loc, _ := time.LoadLocation("Local")
  2884. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2885. // if err != nil {
  2886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2887. // return
  2888. // }
  2889. // recordStartTime := theStartTime.Unix()
  2890. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2891. // if err != nil {
  2892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2893. // return
  2894. // }
  2895. // recordEndTime := theEndTime.Unix()
  2896. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2897. // data["pre"] = prescriptions
  2898. //
  2899. // }
  2900. //
  2901. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2902. //
  2903. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2904. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2905. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2906. // strconv.FormatInt(his.PatientId, 10)
  2907. //
  2908. // order_src, _ := service.GetHisOrderByID(order_id)
  2909. //
  2910. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2911. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2912. //
  2913. // var total float64
  2914. // for _, item := range prescriptions {
  2915. // if item.Type == 1 { //药品
  2916. // for _, subItem := range item.HisDoctorAdviceInfo {
  2917. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2918. // }
  2919. // }
  2920. // if item.Type == 2 { //项目
  2921. // for _, subItem := range item.HisPrescriptionProject {
  2922. // total = total + (subItem.Price * float64(subItem.Count))
  2923. // }
  2924. // }
  2925. // }
  2926. //
  2927. // for _, item := range prescriptions {
  2928. // for _, subItem := range item.HisAdditionalCharge {
  2929. // total = total + (subItem.Price * float64(subItem.Count))
  2930. // }
  2931. // }
  2932. //
  2933. // allTotal := fmt.Sprintf("%.2f", total)
  2934. // var rf []*ResultFive
  2935. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2936. // psn_no := order_src.PsnNo
  2937. // mdtrt_id := order_src.MdtrtId
  2938. // chrg_bchno := order_src.Number
  2939. // cert_no := order_src.Certno
  2940. // insutype := rf[0].Insutype
  2941. //
  2942. // if his.IdCardType == 1 {
  2943. // cert_no = his.MedicalInsuranceNumber
  2944. // } else {
  2945. // cert_no = his.Certno
  2946. // }
  2947. //
  2948. // 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)
  2949. // var dat map[string]interface{}
  2950. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2951. // fmt.Println(dat)
  2952. // } else {
  2953. // fmt.Println(err)
  2954. // }
  2955. //
  2956. // userJSONBytes, _ := json.Marshal(dat)
  2957. //
  2958. //
  2959. //
  2960. // var res ResultSeven
  2961. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2962. // utils.ErrorLog("解析失败:%v", err)
  2963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. // return
  2965. // }
  2966. // if res.Infcode == -1 {
  2967. // errlog := &models.HisOrderError{
  2968. // UserOrgId: adminUser.CurrentOrgId,
  2969. // Ctime: time.Now().Unix(),
  2970. // Mtime: time.Now().Unix(),
  2971. // Number: chrg_bchno,
  2972. // ErrMsg: res.ErrMsg,
  2973. // Status: 1,
  2974. // PatientId: id,
  2975. // RecordTime: recordDateTime,
  2976. // Stage: 6,
  2977. // }
  2978. // service.CreateErrMsgLog(errlog)
  2979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2980. // return
  2981. // } else {
  2982. // order_src.OrderStatus = 2
  2983. // order_src.PayWay = pay_way
  2984. // order_src.PayPrice = pay_price
  2985. // order_src.PayCardNo = pay_card_no
  2986. // order_src.DiscountPrice = discount_price
  2987. // order_src.PreferentialPrice = preferential_price
  2988. // order_src.RealityPrice = reality_price
  2989. // order_src.FoundPrice = found_price
  2990. // order_src.MedicalInsurancePrice = medical_insurance_price
  2991. // order_src.PrivatePrice = private_price
  2992. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  2993. // order_src.SetlId = res.Output.Setlinfo.SetlID
  2994. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  2995. // order_src.PsnName = res.Output.Setlinfo.PsnName
  2996. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  2997. // order_src.Certno = res.Output.Setlinfo.Certno
  2998. // order_src.Gend = res.Output.Setlinfo.Gend
  2999. // order_src.Naty = res.Output.Setlinfo.Naty
  3000. // order_src.Age = res.Output.Setlinfo.Age
  3001. // order_src.Insutype = res.Output.Setlinfo.Insutype
  3002. // order_src.PsnType = res.Output.Setlinfo.PsnType
  3003. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3004. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  3005. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3006. // order_src.MedType = res.Output.Setlinfo.MedType
  3007. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3008. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3009. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3010. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3011. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3012. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3013. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  3014. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  3015. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3016. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  3017. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  3018. // order_src.MafPay = res.Output.Setlinfo.MafPay
  3019. // order_src.OthPay = res.Output.Setlinfo.OthPay
  3020. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3021. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3022. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  3023. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3024. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3025. // order_src.Balc = res.Output.Setlinfo.Balc
  3026. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3027. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3028. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  3029. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  3030. // order_src.Creator = order_src.Creator
  3031. // order_src.Modify = roles.ID
  3032. // order_src.RequestLog = src_resquest
  3033. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3034. // detailStr := string(setlDetail)
  3035. // order_src.SetlDetail = detailStr
  3036. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3037. // err = service.UpDateOrder(order_src)
  3038. //
  3039. // if err == nil {
  3040. // c.ServeSuccessJSON(map[string]interface{}{
  3041. // "msg": "结算成功",
  3042. // })
  3043. // } else {
  3044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3045. // return
  3046. // }
  3047. // }
  3048. // }
  3049. //}
  3050. //退款
  3051. func (c *HisApiController) Refund() {
  3052. order_id, _ := c.GetInt64("order_id")
  3053. admin_user_id, _ := c.GetInt64("admin_user_id")
  3054. record_time := c.GetString("record_time")
  3055. patient_id, _ := c.GetInt64("patient_id")
  3056. timeLayout := "2006-01-02"
  3057. loc, _ := time.LoadLocation("Local")
  3058. adminUser := c.GetAdminUserInfo()
  3059. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3060. if err != nil {
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3062. return
  3063. }
  3064. recordDateTime := theTime.Unix()
  3065. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3066. var order models.HisOrder
  3067. order, _ = service.GetHisOrderByID(order_id)
  3068. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3069. if order.ID == 0 {
  3070. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3071. }
  3072. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3073. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3074. if config.IsOpen == 1 { //对接了医保,走医保流程
  3075. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3076. var dat map[string]interface{}
  3077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3078. fmt.Println(dat)
  3079. } else {
  3080. fmt.Println(err)
  3081. }
  3082. userJSONBytes, _ := json.Marshal(dat)
  3083. var res ResultSixteen
  3084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3085. utils.ErrorLog("解析失败:%v", err)
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. return
  3088. }
  3089. if res.Infcode == 0 {
  3090. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  3091. var dat map[string]interface{}
  3092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3093. fmt.Println(dat)
  3094. } else {
  3095. fmt.Println(err)
  3096. }
  3097. userJSONBytes, _ := json.Marshal(dat)
  3098. var res2 ResultSix
  3099. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3100. utils.ErrorLog("解析失败:%v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. if res2.Infcode == 0 {
  3105. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  3106. if err == nil {
  3107. c.ServeSuccessJSON(map[string]interface{}{
  3108. "msg": "退费成功",
  3109. })
  3110. } else {
  3111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3112. return
  3113. }
  3114. } else {
  3115. c.ServeSuccessJSON(map[string]interface{}{
  3116. "code": -10,
  3117. "msg": res2.ErrMsg,
  3118. })
  3119. }
  3120. } else {
  3121. c.ServeSuccessJSON(map[string]interface{}{
  3122. "code": -10,
  3123. "msg": res.ErrMsg,
  3124. })
  3125. }
  3126. } else {
  3127. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  3128. if err == nil {
  3129. c.ServeSuccessJSON(map[string]interface{}{
  3130. "msg": "退费成功",
  3131. })
  3132. } else {
  3133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3134. return
  3135. }
  3136. }
  3137. }
  3138. func (c *HisApiController) RefundNumber() {
  3139. record_time := c.GetString("record_time")
  3140. patient_id, _ := c.GetInt64("patient_id")
  3141. admin_user_id, _ := c.GetInt64("admin_user_id")
  3142. //his_patient_id, _ := c.GetInt64("id")
  3143. timeLayout := "2006-01-02"
  3144. loc, _ := time.LoadLocation("Local")
  3145. adminUser := c.GetAdminUserInfo()
  3146. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3147. fmt.Println(err)
  3148. if err != nil {
  3149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3150. return
  3151. }
  3152. recordDateTime := theTime.Unix()
  3153. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3154. //his, _ := service.GetNewHisPatientRecord(adminUser.CurrentOrgId, patient_id)
  3155. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3156. //order, _ := service.GetHisOrderByID(order_id)
  3157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3158. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3159. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3160. if config.IsOpen == 1 { //对接了医保,走医保流程
  3161. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  3162. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3163. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3164. resp3, requestErr3 := http.Get(api3)
  3165. if requestErr3 != nil {
  3166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3167. return
  3168. }
  3169. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  3170. if ioErr3 != nil {
  3171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. return
  3174. }
  3175. var respJSON3 map[string]interface{}
  3176. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  3177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3179. return
  3180. }
  3181. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3182. userJSONBytes3, _ := json.Marshal(respJSON3)
  3183. var res2 ResultSix
  3184. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3185. utils.ErrorLog("解析失败:%v", err)
  3186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3187. return
  3188. }
  3189. if res2.Infcode == 0 {
  3190. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3191. service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  3192. //err := service.UpdataRegStatus2()
  3193. if err == nil {
  3194. c.ServeSuccessJSON(map[string]interface{}{
  3195. "msg": "退号成功",
  3196. })
  3197. } else {
  3198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3199. return
  3200. }
  3201. } else {
  3202. c.ServeSuccessJSON(map[string]interface{}{
  3203. "code": -10,
  3204. "msg": res2.ErrMsg,
  3205. })
  3206. }
  3207. } else {
  3208. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3209. //if err == nil {
  3210. // c.ServeSuccessJSON(map[string]interface{}{
  3211. // "msg": "退费成功",
  3212. // })
  3213. //} else {
  3214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. // return
  3216. //}
  3217. }
  3218. }
  3219. func (c *HisApiController) RefundDetail() {
  3220. order_id, _ := c.GetInt64("order_id")
  3221. his_patient_id, _ := c.GetInt64("his_patient_id")
  3222. number := c.GetString("number")
  3223. record_time := c.GetString("record_time")
  3224. patient_id, _ := c.GetInt64("patient_id")
  3225. timeLayout := "2006-01-02"
  3226. loc, _ := time.LoadLocation("Local")
  3227. adminUser := c.GetAdminUserInfo()
  3228. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3229. fmt.Println(err)
  3230. if err != nil {
  3231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3232. return
  3233. }
  3234. recordDateTime := theTime.Unix()
  3235. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3236. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3237. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3238. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3239. var order models.HisOrder
  3240. order, _ = service.GetHisOrderByID(order_id)
  3241. if order.ID == 0 {
  3242. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3243. }
  3244. if config.IsOpen == 1 { //对接了医保,走医保流程
  3245. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3246. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3247. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3248. resp2, requestErr2 := http.Get(api2)
  3249. if requestErr2 != nil {
  3250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3251. return
  3252. }
  3253. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3254. if ioErr2 != nil {
  3255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3257. return
  3258. }
  3259. var respJSON2 map[string]interface{}
  3260. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3263. return
  3264. }
  3265. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3266. if err == nil {
  3267. c.ServeSuccessJSON(map[string]interface{}{
  3268. "msg": "退费成功",
  3269. })
  3270. } else {
  3271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3272. return
  3273. }
  3274. } else {
  3275. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3276. if err == nil {
  3277. c.ServeSuccessJSON(map[string]interface{}{
  3278. "msg": "退费成功",
  3279. })
  3280. } else {
  3281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3282. return
  3283. }
  3284. }
  3285. }
  3286. //对账
  3287. func (c *HisApiController) GetCheckAccount() {
  3288. start_time := c.GetString("start_time")
  3289. end_time := c.GetString("end_time")
  3290. insutype := c.GetString("insutype")
  3291. clr_type := c.GetString("clr_type")
  3292. admin_user_id, _ := c.GetInt64("admin_user_id")
  3293. adminUser := c.GetAdminUserInfo()
  3294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3295. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3296. timeLayout := "2006-01-02"
  3297. loc, _ := time.LoadLocation("Local")
  3298. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3299. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3300. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3301. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3302. fixmedins_setl_cnt := int64(len(orders))
  3303. //
  3304. ////撤销的算2条数据为一笔
  3305. //for _, item := range orders_two {
  3306. // if item.OrderStatus == 3 {
  3307. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3308. // }
  3309. //}
  3310. var medfee_sumamt float64
  3311. var acct_pay float64
  3312. var fund_pay_sumamt float64
  3313. for _, item := range orders {
  3314. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3315. acct_pay = acct_pay + item.AcctPay
  3316. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3317. }
  3318. var user_name string
  3319. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3320. if role.ID == 0 {
  3321. user_name = "xxx"
  3322. } else {
  3323. user_name = role.UserName
  3324. }
  3325. if config.IsOpen == 1 {
  3326. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3327. "insutype=" + insutype +
  3328. "&clr_type=" + clr_type +
  3329. "&setl_optins=" + "定点医保中心" +
  3330. "&stmt_begndate=" + start_time +
  3331. "&stm_enddate=" + end_time +
  3332. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3333. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3334. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3335. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3336. "&fixmedins_code=" + miConfig.Code +
  3337. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3338. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3339. "&secret_key=" + miConfig.SecretKey +
  3340. "&org_name=" + miConfig.OrgName +
  3341. "&doctor=" + user_name
  3342. fmt.Println(api)
  3343. resp, requestErr := http.Get(api)
  3344. if requestErr != nil {
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3346. return
  3347. }
  3348. body, ioErr := ioutil.ReadAll(resp.Body)
  3349. fmt.Println(body)
  3350. if ioErr != nil {
  3351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3353. return
  3354. }
  3355. var respJSON map[string]interface{}
  3356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3359. return
  3360. }
  3361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3362. userJSONBytes, _ := json.Marshal(respJSON)
  3363. var res ResultEight
  3364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. if res.Infcode == 0 {
  3370. if res.Output.Stmtinfo.StmtRslt == "0" {
  3371. micc := &models.MedicalInsuranceCostCompare{
  3372. StartTime: startime.Unix(),
  3373. EndTime: endtime.Unix(),
  3374. Insutype: insutype,
  3375. CheckType: 1,
  3376. Num: fixmedins_setl_cnt,
  3377. Mtime: time.Now().Unix(),
  3378. Status: 1,
  3379. UserOrgId: adminUser.CurrentOrgId,
  3380. CostTotal: medfee_sumamt,
  3381. FuncTotal: fund_pay_sumamt,
  3382. PsnPay: acct_pay,
  3383. Creator: admin_user_id,
  3384. Ctime: time.Now().Unix(),
  3385. }
  3386. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3387. if err == nil {
  3388. c.ServeSuccessJSON(map[string]interface{}{
  3389. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3390. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3391. })
  3392. } else {
  3393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3394. }
  3395. } else {
  3396. c.ServeSuccessJSON(map[string]interface{}{
  3397. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3398. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3399. })
  3400. }
  3401. } else {
  3402. c.ServeSuccessJSON(map[string]interface{}{
  3403. "code": -10,
  3404. "msg": res.ErrMsg,
  3405. })
  3406. }
  3407. }
  3408. }
  3409. func (c *HisApiController) Check310() {
  3410. adminUser := c.GetAdminUserInfo()
  3411. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3412. var user_name string
  3413. user_name = "xxx"
  3414. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3415. "insutype=" + "310" +
  3416. "&clr_type=" + "11" +
  3417. "&setl_optins=" + "定点医保中心" +
  3418. "&stmt_begndate=" + "2021-03-01" +
  3419. "&stm_enddate=" + "2021-03-31" +
  3420. "&medfee_sumamt=" + "11521" +
  3421. "&fund_pay_sumamt=" + "10166.66" +
  3422. "&acct_pay=" + "0" +
  3423. "&fixmedins_setl_cnt=" + "7" +
  3424. "&fixmedins_code=" + miConfig.Code +
  3425. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3426. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3427. "&secret_key=" + miConfig.SecretKey +
  3428. "&org_name=" + miConfig.OrgName +
  3429. "&doctor=" + user_name
  3430. fmt.Println(api)
  3431. resp, requestErr := http.Get(api)
  3432. if requestErr != nil {
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. body, ioErr := ioutil.ReadAll(resp.Body)
  3437. fmt.Println(body)
  3438. if ioErr != nil {
  3439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3441. return
  3442. }
  3443. var respJSON map[string]interface{}
  3444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3447. return
  3448. }
  3449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3450. userJSONBytes, _ := json.Marshal(respJSON)
  3451. var res ResultEight
  3452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3453. utils.ErrorLog("解析失败:%v", err)
  3454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3455. return
  3456. }
  3457. }
  3458. func (c *HisApiController) Check390() {
  3459. adminUser := c.GetAdminUserInfo()
  3460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3461. var user_name string
  3462. user_name = "张俊杰"
  3463. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3464. "insutype=" + "390" +
  3465. "&clr_type=" + "11" +
  3466. "&setl_optins=" + "定点医保中心" +
  3467. "&stmt_begndate=" + "2021-03-01" +
  3468. "&stm_enddate=" + "2021-03-31" +
  3469. "&medfee_sumamt=" + "209318.43" +
  3470. "&fund_pay_sumamt=" + "188029.12" +
  3471. "&acct_pay=" + "0" +
  3472. "&fixmedins_setl_cnt=" + "48" +
  3473. "&fixmedins_code=" + miConfig.Code +
  3474. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3475. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3476. "&secret_key=" + miConfig.SecretKey +
  3477. "&org_name=" + miConfig.OrgName +
  3478. "&doctor=" + user_name
  3479. fmt.Println(api)
  3480. resp, requestErr := http.Get(api)
  3481. if requestErr != nil {
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. body, ioErr := ioutil.ReadAll(resp.Body)
  3486. fmt.Println(body)
  3487. if ioErr != nil {
  3488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3490. return
  3491. }
  3492. var respJSON map[string]interface{}
  3493. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3496. return
  3497. }
  3498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3499. userJSONBytes, _ := json.Marshal(respJSON)
  3500. var res ResultEight
  3501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3502. utils.ErrorLog("解析失败:%v", err)
  3503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3504. return
  3505. }
  3506. }
  3507. //对账明细
  3508. func (c *HisApiController) GetCheckDetailAccount() {
  3509. start_time := c.GetString("start_time")
  3510. end_time := c.GetString("end_time")
  3511. admin_user_id, _ := c.GetInt64("admin_user_id")
  3512. adminUser := c.GetAdminUserInfo()
  3513. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3514. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3515. timeLayout := "2006-01-02"
  3516. loc, _ := time.LoadLocation("Local")
  3517. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3518. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3519. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  3520. Mkdir(miConfig.OrgName)
  3521. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  3522. file_name := file + ".txt"
  3523. zip_name := file + ".zip"
  3524. zip_path := miConfig.OrgName + "/" + zip_name
  3525. file_path := miConfig.OrgName + "/" + file_name
  3526. decimal.DivisionPrecision = 2
  3527. var medfee_sumamt float64
  3528. var psn_cash_pay float64
  3529. var fund_pay_sumamt float64
  3530. fixmedins_setl_cnt := int64(len(orders))
  3531. for _, item := range orders {
  3532. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3533. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  3534. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3535. }
  3536. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  3537. defer f.Close()
  3538. if err != nil {
  3539. fmt.Println(err.Error())
  3540. } else {
  3541. for _, item := range orders {
  3542. var refd_setl_flag string
  3543. if item.OrderStatus == 2 {
  3544. refd_setl_flag = "0"
  3545. var str string
  3546. str = item.SetlId + " " +
  3547. item.MdtrtId + " " +
  3548. item.PsnNo + " " +
  3549. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3550. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3551. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  3552. _, err = f.Write([]byte(str))
  3553. }
  3554. if item.OrderStatus == 3 {
  3555. var str string
  3556. str = item.SetlId + " " +
  3557. item.MdtrtId + " " +
  3558. item.PsnNo + " " +
  3559. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3560. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3561. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  3562. _, err = f.Write([]byte(str))
  3563. var str2 string
  3564. str2 = item.SetlId + " " +
  3565. item.MdtrtId + " " +
  3566. item.PsnNo + " " +
  3567. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  3568. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  3569. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  3570. _, err = f.Write([]byte(str2))
  3571. }
  3572. }
  3573. }
  3574. Zip(file_path, zip_path)
  3575. fmt.Println(ReadFile(zip_path))
  3576. fmt.Println(string(ReadFile(zip_path)))
  3577. if config.IsOpen == 1 {
  3578. var user_name string
  3579. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3580. if role.ID == 0 {
  3581. user_name = "管理员"
  3582. } else {
  3583. user_name = role.UserName
  3584. }
  3585. baseParams := models.BaseParams{
  3586. SecretKey: miConfig.SecretKey,
  3587. FixmedinsCode: miConfig.Code,
  3588. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3589. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3590. OrgName: miConfig.OrgName,
  3591. Doctor: user_name,
  3592. }
  3593. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  3594. var dat map[string]interface{}
  3595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3596. fmt.Println(dat)
  3597. } else {
  3598. fmt.Println(err)
  3599. }
  3600. userJSONBytes, _ := json.Marshal(dat)
  3601. var res ResultNine
  3602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3603. utils.ErrorLog("解析失败:%v", err)
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. if res.Infcode == 0 {
  3608. fileNo := res.Output.FileQuryNo
  3609. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  3610. "file_qury_no=" + fileNo +
  3611. "&setl_optins=" + "定点医保中心" +
  3612. "&stmt_begndate=" + start_time +
  3613. "&stm_enddate=" + end_time +
  3614. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3615. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3616. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  3617. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3618. "&fixmedins_code=" + miConfig.Code +
  3619. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3620. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3621. "&secret_key=" + miConfig.SecretKey +
  3622. "&org_name=" + miConfig.OrgName +
  3623. "&doctor=" + user_name
  3624. resp, requestErr := http.Get(api)
  3625. if requestErr != nil {
  3626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3627. return
  3628. }
  3629. body, ioErr := ioutil.ReadAll(resp.Body)
  3630. if ioErr != nil {
  3631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3633. return
  3634. }
  3635. var respJSON map[string]interface{}
  3636. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3639. return
  3640. }
  3641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3642. userJSONBytes, _ := json.Marshal(respJSON)
  3643. var res ResultTen
  3644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3645. utils.ErrorLog("解析失败:%v", err)
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3647. return
  3648. }
  3649. if res.Infcode == 0 {
  3650. service.Gdyb9102(baseParams, zip_name, fileNo)
  3651. micc := &models.MedicalInsuranceCostCompare{
  3652. StartTime: startime.Unix(),
  3653. EndTime: endtime.Unix(),
  3654. Insutype: "0",
  3655. CheckType: 2,
  3656. Num: fixmedins_setl_cnt,
  3657. Mtime: time.Now().Unix(),
  3658. Status: 1,
  3659. UserOrgId: adminUser.CurrentOrgId,
  3660. CostTotal: medfee_sumamt,
  3661. FuncTotal: fund_pay_sumamt,
  3662. PsnPay: psn_cash_pay,
  3663. Creator: admin_user_id,
  3664. Ctime: time.Now().Unix(),
  3665. }
  3666. service.CreateMedicalInsuranceCostCompareRecord(micc)
  3667. c.ServeSuccessJSON(map[string]interface{}{
  3668. "msg": "明细对账成功",
  3669. })
  3670. }
  3671. } else {
  3672. }
  3673. }
  3674. }
  3675. func (c *HisApiController) GetSettleAccounts() {
  3676. //id, _ := c.GetInt64("id")
  3677. //record_time := c.GetString("record_time")
  3678. order_id, _ := c.GetInt64("order_id")
  3679. admin_user_id, _ := c.GetInt64("admin_user_id")
  3680. //timeLayout := "2006-01-02"
  3681. //loc, _ := time.LoadLocation("Local")
  3682. //
  3683. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3684. //if err != nil {
  3685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3686. // return
  3687. //}
  3688. //recordDateTime := theTime.Unix()
  3689. adminUser := c.GetAdminUserInfo()
  3690. order, _ := service.GetHisOrderByID(order_id)
  3691. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3692. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3693. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3694. orderInfos = append(orderInfos, orderInfos_two...)
  3695. diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  3696. var bedCostTotal float64 = 0 //床位总费
  3697. var bedCostSelfTotal float64 = 0 //床位自费
  3698. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3699. var operationCostTotal float64 = 0 //手术费
  3700. var operationCostSelfTotal float64 = 0 //手术费
  3701. var operationCostPartSelfTotal float64 = 0 //手术费
  3702. var otherCostTotal float64 = 0 //其他费用
  3703. var otherCostSelfTotal float64 = 0 //其他费用
  3704. var otherCostPartSelfTotal float64 = 0 //其他费用
  3705. var materialCostTotal float64 = 0 //材料费
  3706. var materialCostSelfTotal float64 = 0 //材料费
  3707. var materialCostPartSelfTotal float64 = 0 //材料费
  3708. var westernMedicineCostTotal float64 = 0 //西药费
  3709. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3710. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3711. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3712. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3713. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3714. var checkCostTotal float64 = 0 //检查费
  3715. var checkCostSelfTotal float64 = 0 //检查费
  3716. var checkCostPartSelfTotal float64 = 0 //检查费
  3717. var laboratoryCostTotal float64 = 0 //化验费
  3718. var laboratoryCostSelfTotal float64 = 0 //化验费
  3719. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3720. var treatCostTotal float64 = 0 //治疗费用
  3721. var treatCostSelfTotal float64 = 0 //治疗费用
  3722. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3723. decimal.DivisionPrecision = 2
  3724. for _, item := range orderInfos {
  3725. if item.MedChrgitmType == "01" { //床位费
  3726. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3727. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3728. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3729. }
  3730. if item.MedChrgitmType == "03" { //检查费
  3731. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3732. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3733. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3734. }
  3735. if item.MedChrgitmType == "04" { //化验费
  3736. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3737. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3738. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3739. }
  3740. if item.MedChrgitmType == "05" { //治疗费
  3741. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3742. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3743. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3744. }
  3745. if item.MedChrgitmType == "06" { //手术费
  3746. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3747. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3748. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3749. }
  3750. if item.MedChrgitmType == "08" { //材料费
  3751. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3752. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3753. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3754. }
  3755. if item.MedChrgitmType == "09" { //西药费
  3756. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3757. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3758. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3759. }
  3760. if item.MedChrgitmType == "11" { //中成费
  3761. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3762. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3763. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3764. }
  3765. if item.MedChrgitmType == "14" { //其他费
  3766. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3767. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3768. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3769. }
  3770. }
  3771. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3772. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3773. var user_name string
  3774. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3775. if role.ID == 0 {
  3776. user_name = "管理员"
  3777. } else {
  3778. user_name = role.UserName
  3779. }
  3780. baseParams := models.BaseParams{
  3781. SecretKey: miConfig.SecretKey,
  3782. FixmedinsCode: miConfig.Code,
  3783. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3784. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3785. OrgName: miConfig.OrgName,
  3786. Doctor: user_name,
  3787. }
  3788. businessParams := models.BusinessParams{
  3789. PsnNo: order.PsnNo,
  3790. MdtrtId: order.MdtrtId,
  3791. SetlId: order.SetlId,
  3792. }
  3793. if config.IsOpen == 1 {
  3794. result := service.Gdyb5203(baseParams, businessParams)
  3795. var dat map[string]interface{}
  3796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3797. fmt.Println(dat)
  3798. } else {
  3799. fmt.Println(err)
  3800. }
  3801. userJSONBytes, _ := json.Marshal(dat)
  3802. var res ResultEleven
  3803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3804. utils.ErrorLog("解析失败:%v", err)
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3806. return
  3807. }
  3808. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3809. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  3810. if res.Infcode == 0 {
  3811. c.ServeSuccessJSON(map[string]interface{}{
  3812. "diagnosis": diagnosisConfig.CountryContentName,
  3813. "order_infos": orderInfos,
  3814. "number": order.MdtrtId,
  3815. "date": order.SettleAccountsDate,
  3816. "charge_admin": charge_admin,
  3817. "printor_admin": printor_admin,
  3818. "info": res.Output.Setlinfo,
  3819. "bedCostTotal": bedCostTotal,
  3820. "bedCostSelfTotal": bedCostSelfTotal,
  3821. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  3822. "operationCostTotal": operationCostTotal,
  3823. "operationCostSelfTotal": operationCostSelfTotal,
  3824. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  3825. "otherCostTotal": otherCostTotal,
  3826. "otherCostSelfTotal": otherCostSelfTotal,
  3827. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  3828. "materialCostTotal": materialCostTotal,
  3829. "materialCostSelfTotal": materialCostSelfTotal,
  3830. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  3831. "westernMedicineCostTotal": westernMedicineCostTotal,
  3832. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  3833. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  3834. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  3835. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  3836. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  3837. "checkCostTotal": checkCostTotal,
  3838. "checkCostSelfTotal": checkCostSelfTotal,
  3839. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  3840. "laboratoryCostTotal": laboratoryCostTotal,
  3841. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  3842. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  3843. "treatCostTotal": treatCostTotal,
  3844. "treatCostSelfTotal": treatCostSelfTotal,
  3845. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  3846. })
  3847. }
  3848. }
  3849. }
  3850. func (c *HisApiController) CheckTreatment() {
  3851. patient_id, _ := c.GetInt64("patient_id", 0)
  3852. record_time := c.GetString("record_time")
  3853. insutype := c.GetString("insutype")
  3854. timeLayout := "2006-01-02"
  3855. loc, _ := time.LoadLocation("Local")
  3856. adminUser := c.GetAdminUserInfo()
  3857. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3858. fmt.Println(err)
  3859. if err != nil {
  3860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3861. return
  3862. }
  3863. recordDateTime := theTime.Unix()
  3864. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3865. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3866. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3867. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3868. var user_name string
  3869. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  3870. if role.ID == 0 {
  3871. user_name = "xxx"
  3872. } else {
  3873. user_name = role.UserName
  3874. }
  3875. baseParams := models.BaseParams{
  3876. SecretKey: miConfig.SecretKey,
  3877. FixmedinsCode: miConfig.Code,
  3878. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3879. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3880. OrgName: miConfig.OrgName,
  3881. Doctor: user_name,
  3882. }
  3883. if config.IsOpen == 1 {
  3884. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  3885. var dat map[string]interface{}
  3886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3887. fmt.Println(dat)
  3888. } else {
  3889. fmt.Println(err)
  3890. }
  3891. }
  3892. }
  3893. func (c *HisApiController) PutRecord() {
  3894. id, _ := c.GetInt64("id")
  3895. record_time := c.GetString("record_time")
  3896. timeLayout := "2006-01-02"
  3897. loc, _ := time.LoadLocation("Local")
  3898. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3899. if err != nil {
  3900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3901. return
  3902. }
  3903. recordDateTime := theTime.Unix()
  3904. adminInfo := c.GetAdminUserInfo()
  3905. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  3906. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3907. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3908. fmt.Println(miConfig.SecretKey)
  3909. if patient == nil {
  3910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3911. return
  3912. }
  3913. if len(patient.IdCardNo) == 0 {
  3914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3915. return
  3916. }
  3917. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3918. if config.IsOpen == 1 {
  3919. 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
  3920. resp, requestErr := http.Get(api)
  3921. if requestErr != nil {
  3922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3923. return
  3924. }
  3925. defer resp.Body.Close()
  3926. body, ioErr := ioutil.ReadAll(resp.Body)
  3927. if ioErr != nil {
  3928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3930. return
  3931. }
  3932. var respJSON map[string]interface{}
  3933. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. return
  3937. }
  3938. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3939. userJSONBytes, _ := json.Marshal(userJSON)
  3940. var res ResultTwo
  3941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3942. utils.ErrorLog("解析失败:%v", err)
  3943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3944. return
  3945. }
  3946. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3947. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3948. infoStr := string(Iinfos)
  3949. idetinfoStr := string(Idetinfos)
  3950. if res.Infcode == 0 {
  3951. his := models.VMHisPatient{
  3952. Status: 1,
  3953. Ctime: time.Now().Unix(),
  3954. Mtime: time.Now().Unix(),
  3955. PsnNo: res.Output.Baseinfo.PsnNo,
  3956. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3957. Certno: res.Output.Baseinfo.Certno,
  3958. PsnName: res.Output.Baseinfo.PsnName,
  3959. Gend: res.Output.Baseinfo.Gend,
  3960. Naty: res.Output.Baseinfo.Naty,
  3961. Brdy: res.Output.Baseinfo.Brdy,
  3962. Age: res.Output.Baseinfo.Age,
  3963. Iinfo: infoStr,
  3964. Idetinfo: idetinfoStr,
  3965. PatientId: patient.ID,
  3966. RecordDate: theTime.Unix(),
  3967. UserOrgId: adminInfo.CurrentOrgId,
  3968. AdminUserId: adminInfo.AdminUser.Id,
  3969. IsReturn: 1,
  3970. }
  3971. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3972. 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")
  3973. 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")
  3974. var dat map[string]interface{}
  3975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3976. fmt.Println(dat)
  3977. } else {
  3978. fmt.Println(err)
  3979. }
  3980. var dat2 map[string]interface{}
  3981. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  3982. fmt.Println(dat2)
  3983. } else {
  3984. fmt.Println(err)
  3985. }
  3986. } else {
  3987. adminUser := c.GetAdminUserInfo()
  3988. errlog := &models.HisOrderError{
  3989. UserOrgId: adminUser.CurrentOrgId,
  3990. Ctime: time.Now().Unix(),
  3991. Mtime: time.Now().Unix(),
  3992. ErrMsg: res.ErrMsg,
  3993. Status: 1,
  3994. PatientId: id,
  3995. RecordTime: recordDateTime,
  3996. Stage: 1,
  3997. }
  3998. service.CreateErrMsgLog(errlog)
  3999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4000. return
  4001. }
  4002. }
  4003. }
  4004. func (c *HisApiController) GetUploadDiag() {
  4005. id, _ := c.GetInt64("id")
  4006. record_time := c.GetString("record_time")
  4007. diagnosis_id, _ := c.GetInt64("diagnosis")
  4008. sick_type, _ := c.GetInt64("sick_type")
  4009. reg_type, _ := c.GetInt64("reg_type")
  4010. timeLayout := "2006-01-02"
  4011. loc, _ := time.LoadLocation("Local")
  4012. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4013. if err != nil {
  4014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4015. return
  4016. }
  4017. var patientPrescription models.HisPrescriptionInfo
  4018. recordDateTime := theTime.Unix()
  4019. adminInfo := c.GetAdminUserInfo()
  4020. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4021. if patientPrescription.ID == 0 {
  4022. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4023. }
  4024. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4025. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4026. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4027. sickConfig, _ := service.FindSickById(sick_type)
  4028. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4029. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  4030. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  4031. "&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 +
  4032. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  4033. resp2, requestErr2 := http.Get(api2)
  4034. if requestErr2 != nil {
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4036. return
  4037. }
  4038. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4039. if ioErr2 != nil {
  4040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4042. return
  4043. }
  4044. var respJSON2 map[string]interface{}
  4045. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4048. return
  4049. }
  4050. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4051. userJSONBytes2, _ := json.Marshal(respJSON2)
  4052. var res2 ResultSix
  4053. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4054. utils.ErrorLog("解析失败:%v", err)
  4055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4056. return
  4057. }
  4058. if res2.Infcode != 0 {
  4059. adminUser := c.GetAdminUserInfo()
  4060. errlog := &models.HisOrderError{
  4061. UserOrgId: adminUser.CurrentOrgId,
  4062. Ctime: time.Now().Unix(),
  4063. Mtime: time.Now().Unix(),
  4064. ErrMsg: res2.ErrMsg,
  4065. Status: 1,
  4066. PatientId: id,
  4067. RecordTime: recordDateTime,
  4068. Stage: 3,
  4069. }
  4070. service.CreateErrMsgLog(errlog)
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  4072. return
  4073. }
  4074. c.ServeSuccessJSON(map[string]interface{}{
  4075. "msg": "上传成功",
  4076. })
  4077. }
  4078. type QueryResult struct {
  4079. ID int64
  4080. Name string
  4081. Code string
  4082. List_type_code string
  4083. }
  4084. func (c *HisApiController) GetCheckCode() {
  4085. ids_str := c.GetString("ids")
  4086. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4087. ids_arr := strings.Split(ids_str, ",")
  4088. var queryResult []QueryResult
  4089. ids := make([]int64, 0)
  4090. for _, item := range ids_arr {
  4091. id, _ := strconv.ParseInt(item, 10, 64)
  4092. ids = append(ids, id)
  4093. }
  4094. if record_type == 1 {
  4095. drugs, _ := service.GetBatchDrugList(ids)
  4096. for _, item := range drugs {
  4097. result := QueryResult{
  4098. ID: item.ID,
  4099. Name: item.DrugName,
  4100. Code: item.MedicalInsuranceNumber,
  4101. List_type_code: "101",
  4102. }
  4103. queryResult = append(queryResult, result)
  4104. }
  4105. } else if record_type == 2 {
  4106. goods, _ := service.GetBatchGoodInformationList(ids)
  4107. for _, item := range goods {
  4108. result := QueryResult{
  4109. ID: item.ID,
  4110. Name: item.GoodName,
  4111. Code: item.MedicalInsuranceNumber,
  4112. List_type_code: "301",
  4113. }
  4114. queryResult = append(queryResult, result)
  4115. }
  4116. } else if record_type == 3 {
  4117. projects, _ := service.GetBathchMyPorjecgList(ids)
  4118. for _, item := range projects {
  4119. result := QueryResult{
  4120. ID: item.ID,
  4121. Name: item.ProjectName,
  4122. Code: item.MedicalCode,
  4123. List_type_code: "201",
  4124. }
  4125. queryResult = append(queryResult, result)
  4126. }
  4127. }
  4128. admin_user_id, _ := c.GetInt64("admin_user_id")
  4129. adminUser := c.GetAdminUserInfo()
  4130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4131. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4132. var user_name string
  4133. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4134. if role.ID == 0 {
  4135. user_name = "xxx"
  4136. } else {
  4137. user_name = role.UserName
  4138. }
  4139. baseParams := &models.BaseParams{
  4140. SecretKey: miConfig.SecretKey,
  4141. FixmedinsCode: miConfig.Code,
  4142. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4143. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4144. OrgName: miConfig.OrgName,
  4145. Doctor: user_name,
  4146. }
  4147. if config.IsOpen == 1 {
  4148. for _, item := range queryResult {
  4149. var result string
  4150. if record_type == 1 {
  4151. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4152. } else if record_type == 2 {
  4153. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4154. } else if record_type == 3 {
  4155. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4156. }
  4157. var dat map[string]interface{}
  4158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4159. fmt.Println(dat)
  4160. } else {
  4161. fmt.Println(err)
  4162. }
  4163. userJSONBytes, _ := json.Marshal(dat)
  4164. var res ResultSix
  4165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4166. utils.ErrorLog("解析失败:%v", err)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. if res.Infcode == 0 {
  4171. if record_type == 1 {
  4172. service.UpdateBaseDrugById(item.ID)
  4173. } else if record_type == 2 {
  4174. service.UpdateGoodInformaitonByDetail(item.ID)
  4175. } else if record_type == 3 {
  4176. service.UpdateProjectById(item.ID)
  4177. }
  4178. c.ServeSuccessJSON(map[string]interface{}{
  4179. "failed_code": 0,
  4180. "msg": "目录对照成功",
  4181. })
  4182. } else {
  4183. c.ServeSuccessJSON(map[string]interface{}{
  4184. "failed_code": -10,
  4185. "msg": res.ErrMsg,
  4186. })
  4187. }
  4188. }
  4189. }
  4190. }
  4191. func (c *HisApiController) UnCheckCode() {
  4192. ids_str := c.GetString("ids")
  4193. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4194. admin_user_id, _ := c.GetInt64("admin_user_id")
  4195. ids_arr := strings.Split(ids_str, ",")
  4196. var queryResult []QueryResult
  4197. ids := make([]int64, 0)
  4198. for _, item := range ids_arr {
  4199. id, _ := strconv.ParseInt(item, 10, 64)
  4200. ids = append(ids, id)
  4201. }
  4202. if record_type == 1 {
  4203. drugs, _ := service.GetBatchDrugList(ids)
  4204. for _, item := range drugs {
  4205. result := QueryResult{
  4206. ID: item.ID,
  4207. Name: item.DrugName,
  4208. Code: item.MedicalInsuranceNumber,
  4209. List_type_code: "101",
  4210. }
  4211. queryResult = append(queryResult, result)
  4212. }
  4213. } else if record_type == 2 {
  4214. goods, _ := service.GetBatchGoodInformationList(ids)
  4215. for _, item := range goods {
  4216. result := QueryResult{
  4217. ID: item.ID,
  4218. Name: item.GoodName,
  4219. Code: item.MedicalInsuranceNumber,
  4220. List_type_code: "301",
  4221. }
  4222. queryResult = append(queryResult, result)
  4223. }
  4224. } else if record_type == 3 {
  4225. projects, _ := service.GetBathchMyPorjecgList(ids)
  4226. for _, item := range projects {
  4227. result := QueryResult{
  4228. ID: item.ID,
  4229. Name: item.ProjectName,
  4230. Code: item.MedicalCode,
  4231. List_type_code: "201",
  4232. }
  4233. queryResult = append(queryResult, result)
  4234. }
  4235. }
  4236. adminUser := c.GetAdminUserInfo()
  4237. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4238. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4239. var user_name string
  4240. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4241. if role.ID == 0 {
  4242. user_name = "xxx"
  4243. } else {
  4244. user_name = role.UserName
  4245. }
  4246. baseParams := &models.BaseParams{
  4247. SecretKey: miConfig.SecretKey,
  4248. FixmedinsCode: miConfig.Code,
  4249. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4250. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4251. OrgName: miConfig.OrgName,
  4252. Doctor: user_name,
  4253. }
  4254. if config.IsOpen == 1 {
  4255. for _, item := range queryResult {
  4256. var result string
  4257. if record_type == 1 {
  4258. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4259. } else if record_type == 2 {
  4260. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4261. } else if record_type == 3 {
  4262. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4263. }
  4264. var dat2 map[string]interface{}
  4265. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4266. fmt.Println(dat2)
  4267. } else {
  4268. fmt.Println(err)
  4269. }
  4270. userJSONBytes, _ := json.Marshal(dat2)
  4271. var res ResultSix
  4272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4273. utils.ErrorLog("解析失败:%v", err)
  4274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. return
  4276. }
  4277. if res.Infcode == 0 {
  4278. if record_type == 1 {
  4279. service.UpdateDrugByIdDetail(item.ID)
  4280. } else if record_type == 2 {
  4281. service.UpdateGoodInfoById(item.ID)
  4282. } else if record_type == 3 {
  4283. service.UpdateMyProjectById(item.ID)
  4284. }
  4285. c.ServeSuccessJSON(map[string]interface{}{
  4286. "failed_code": 0,
  4287. "msg": "撤销目录对照成功",
  4288. })
  4289. } else {
  4290. c.ServeSuccessJSON(map[string]interface{}{
  4291. "failed_code": -10,
  4292. "msg": res.ErrMsg,
  4293. })
  4294. }
  4295. }
  4296. }
  4297. }
  4298. func (c *HisApiController) GetPatientInfo() {
  4299. id_card_no := c.GetString("id_card_no")
  4300. admin_user_id, _ := c.GetInt64("admin_user_id")
  4301. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4302. if patient.ID == 0 {
  4303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4304. return
  4305. }
  4306. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4308. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4309. if config.IsOpen == 1 {
  4310. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4311. var dat map[string]interface{}
  4312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4313. fmt.Println(dat)
  4314. } else {
  4315. fmt.Println(err)
  4316. }
  4317. userJSONBytes, _ := json.Marshal(dat)
  4318. var res ResultTwo
  4319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4320. utils.ErrorLog("解析失败:%v", err)
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. return
  4323. }
  4324. if res.Infcode != 0 {
  4325. c.ServeSuccessJSON(map[string]interface{}{
  4326. "failed_code": -10,
  4327. "msg": res.ErrMsg,
  4328. })
  4329. } else {
  4330. c.ServeSuccessJSON(map[string]interface{}{
  4331. "failed_code": 0,
  4332. "info": res,
  4333. })
  4334. }
  4335. }
  4336. }
  4337. func (c *HisApiController) PsnPutOnRecord() {
  4338. record_type, _ := c.GetInt64("type")
  4339. patient_id, _ := c.GetInt64("patient_id")
  4340. admin_user_id, _ := c.GetInt64("admin_user_id")
  4341. start_time := c.GetString("start_time")
  4342. end_time := c.GetString("end_time")
  4343. adminUser := c.GetAdminUserInfo()
  4344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4346. var patients []*models.Patients
  4347. if record_type == 1 { //全部备案
  4348. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4349. patients = append(patients, patient...)
  4350. } else { //单个备案
  4351. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4352. patients = append(patients, patient)
  4353. }
  4354. var user_name string
  4355. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4356. if role.ID == 0 {
  4357. user_name = "xxx"
  4358. } else {
  4359. user_name = role.UserName
  4360. }
  4361. if config.IsOpen == 1 {
  4362. for _, item := range patients {
  4363. 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
  4364. resp, requestErr := http.Get(api)
  4365. if requestErr != nil {
  4366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. return
  4368. }
  4369. defer resp.Body.Close()
  4370. body, ioErr := ioutil.ReadAll(resp.Body)
  4371. if ioErr != nil {
  4372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4374. return
  4375. }
  4376. var respJSON map[string]interface{}
  4377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4380. return
  4381. }
  4382. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4383. userJSONBytes, _ := json.Marshal(userJSON)
  4384. var res ResultTwo
  4385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4386. utils.ErrorLog("解析失败:%v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. if res.Infcode == 0 {
  4391. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4392. var dat map[string]interface{}
  4393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4394. fmt.Println(dat)
  4395. } else {
  4396. fmt.Println(err)
  4397. }
  4398. userJSONBytes, _ := json.Marshal(dat)
  4399. var res2 ResultThirteen
  4400. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4401. utils.ErrorLog("解析失败:%v", err)
  4402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4403. return
  4404. }
  4405. if res2.Infcode == 0 {
  4406. psnResult := &models.GdybPsnRecord{
  4407. UserOrgId: adminUser.CurrentOrgId,
  4408. PatientId: item.ID,
  4409. PsnNo: res.Output.Baseinfo.PsnNo,
  4410. Ctime: time.Now().Unix(),
  4411. Mtime: time.Now().Unix(),
  4412. Status: 1,
  4413. IsCancel: 1,
  4414. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4415. }
  4416. service.CreatePsnRecord(psnResult)
  4417. } else {
  4418. c.ServeSuccessJSON(map[string]interface{}{
  4419. "failed_code": -10,
  4420. "msg": res2.ErrMsg,
  4421. })
  4422. return
  4423. }
  4424. }
  4425. }
  4426. }
  4427. }
  4428. func (c *HisApiController) PsnUnPutOnRecord() {
  4429. id, _ := c.GetInt64("id")
  4430. //record_type, _ := c.GetInt64("type")
  4431. admin_user_id, _ := c.GetInt64("admin_user_id")
  4432. adminUser := c.GetAdminUserInfo()
  4433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4434. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4435. var user_name string
  4436. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4437. if role.ID == 0 {
  4438. user_name = "xxx"
  4439. } else {
  4440. user_name = role.UserName
  4441. }
  4442. psn_record, _ := service.GetPsnRecordById(id)
  4443. if psn_record.ID == 0 {
  4444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4445. return
  4446. }
  4447. if config.IsOpen == 1 {
  4448. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4449. var dat map[string]interface{}
  4450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4451. fmt.Println(dat)
  4452. } else {
  4453. fmt.Println(err)
  4454. }
  4455. userJSONBytes, _ := json.Marshal(dat)
  4456. var res ResultFourteen
  4457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4458. utils.ErrorLog("解析失败:%v", err)
  4459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4460. return
  4461. }
  4462. if res.Infcode == 0 {
  4463. psn_record.IsCancel = 2
  4464. service.CreatePsnRecord(&psn_record)
  4465. } else {
  4466. c.ServeSuccessJSON(map[string]interface{}{
  4467. "failed_code": -10,
  4468. "msg": res.ErrMsg,
  4469. })
  4470. return
  4471. }
  4472. }
  4473. }
  4474. func (c *HisApiController) PsnPutNCDSOnRecord() {
  4475. patient_id, _ := c.GetInt64("patient_id")
  4476. insutype := c.GetString("insutype")
  4477. psn_no := c.GetString("psn_no")
  4478. doctor_id, _ := c.GetInt64("doctor_id")
  4479. sick_id, _ := c.GetInt64("sick_id")
  4480. department_id, _ := c.GetInt64("department_id")
  4481. adminUser := c.GetAdminUserInfo()
  4482. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4483. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4484. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4485. sick, _ := service.FindSickById(sick_id)
  4486. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  4487. if config.IsOpen == 1 {
  4488. 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)
  4489. var dat map[string]interface{}
  4490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4491. fmt.Println(dat)
  4492. } else {
  4493. fmt.Println(err)
  4494. }
  4495. userJSONBytes, _ := json.Marshal(dat)
  4496. var res2 ResultThirteen
  4497. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4498. utils.ErrorLog("解析失败:%v", err)
  4499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4500. return
  4501. }
  4502. if res2.Infcode == 0 {
  4503. psnResult := &models.GdybPsnNcdsRecord{
  4504. UserOrgId: adminUser.CurrentOrgId,
  4505. PatientId: patient.ID,
  4506. PsnNo: psn_no,
  4507. DoctorId: doctor.AdminUserId,
  4508. DepartmentId: department_id,
  4509. SickType: sick_id,
  4510. Insutype: insutype,
  4511. Ctime: time.Now().Unix(),
  4512. Mtime: time.Now().Unix(),
  4513. Status: 1,
  4514. IsCancel: 1,
  4515. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4516. }
  4517. service.CreatePsnNCDSRecord(psnResult)
  4518. c.ServeSuccessJSON(map[string]interface{}{
  4519. "failed_code": 0,
  4520. "msg": "备案成功",
  4521. "result": psnResult,
  4522. })
  4523. } else {
  4524. c.ServeSuccessJSON(map[string]interface{}{
  4525. "failed_code": -10,
  4526. "msg": res2.ErrMsg,
  4527. })
  4528. return
  4529. }
  4530. }
  4531. }
  4532. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  4533. id, _ := c.GetInt64("id")
  4534. admin_user_id, _ := c.GetInt64("admin_user_id")
  4535. adminUser := c.GetAdminUserInfo()
  4536. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4537. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4538. var user_name string
  4539. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4540. if role.ID == 0 {
  4541. user_name = "xxx"
  4542. } else {
  4543. user_name = role.UserName
  4544. }
  4545. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4546. if psn_record.ID == 0 {
  4547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4548. return
  4549. }
  4550. if config.IsOpen == 1 {
  4551. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4552. var dat map[string]interface{}
  4553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4554. fmt.Println(dat)
  4555. } else {
  4556. fmt.Println(err)
  4557. }
  4558. userJSONBytes, _ := json.Marshal(dat)
  4559. var res ResultFourteen
  4560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4561. utils.ErrorLog("解析失败:%v", err)
  4562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4563. return
  4564. }
  4565. if res.Infcode == 0 {
  4566. psn_record.IsCancel = 2
  4567. service.CreatePsnNCDSRecord(&psn_record)
  4568. c.ServeSuccessJSON(map[string]interface{}{
  4569. "failed_code": 0,
  4570. "msg": "撤销备案成功",
  4571. })
  4572. } else {
  4573. c.ServeSuccessJSON(map[string]interface{}{
  4574. "failed_code": -10,
  4575. "msg": res.ErrMsg,
  4576. })
  4577. return
  4578. }
  4579. }
  4580. }
  4581. func (c *HisApiController) TestTest() {
  4582. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  4583. fmt.Println(patient.Iinfo)
  4584. }
  4585. type CustomData struct {
  4586. MsgId string
  4587. PsnNo string
  4588. Info string
  4589. }
  4590. func (c *HisApiController) ReversalData() {
  4591. var customData []*CustomData
  4592. custom := &CustomData{
  4593. MsgId: "H44022900158202103301714472004",
  4594. PsnNo: "44020000001101329945",
  4595. Info: "2207",
  4596. }
  4597. customData = append(customData, custom)
  4598. custom1 := &CustomData{
  4599. MsgId: "H4402290015820210330172057803",
  4600. PsnNo: "44020000001101161813",
  4601. Info: "2207",
  4602. }
  4603. customData = append(customData, custom1)
  4604. custom2 := &CustomData{
  4605. MsgId: "H44022900158202103301705198813",
  4606. PsnNo: "44190000133097375417",
  4607. Info: "2207",
  4608. }
  4609. customData = append(customData, custom2)
  4610. custom3 := &CustomData{
  4611. MsgId: "H44022900158202103301715524756",
  4612. PsnNo: "44020000001100187221",
  4613. Info: "2207",
  4614. }
  4615. customData = append(customData, custom3)
  4616. custom4 := &CustomData{
  4617. MsgId: "H44022900158202103301730376224",
  4618. PsnNo: "44020000001101959155",
  4619. Info: "2207",
  4620. }
  4621. customData = append(customData, custom4)
  4622. custom5 := &CustomData{
  4623. MsgId: "H44022900158202103301748008725",
  4624. PsnNo: "44020000001104246641",
  4625. Info: "2207",
  4626. }
  4627. customData = append(customData, custom5)
  4628. custom6 := &CustomData{
  4629. MsgId: "H44022900158202103301718096755",
  4630. PsnNo: "44020000001102211860",
  4631. Info: "2207",
  4632. }
  4633. customData = append(customData, custom6)
  4634. custom7 := &CustomData{
  4635. MsgId: "H44022900158202103301736551640",
  4636. PsnNo: "44020000001102687718",
  4637. Info: "2207",
  4638. }
  4639. customData = append(customData, custom7)
  4640. custom8 := &CustomData{
  4641. MsgId: "H44022900158202103301743097676",
  4642. PsnNo: "44020000001102127785",
  4643. Info: "2207",
  4644. }
  4645. customData = append(customData, custom8)
  4646. custom9 := &CustomData{
  4647. MsgId: "H44022900158202103301712304203",
  4648. PsnNo: "44020000001101518097",
  4649. Info: "2207",
  4650. }
  4651. customData = append(customData, custom9)
  4652. custom10 := &CustomData{
  4653. MsgId: "H44022900158202103301738448785",
  4654. PsnNo: "44020000001100500813",
  4655. Info: "2207",
  4656. }
  4657. customData = append(customData, custom10)
  4658. custom11 := &CustomData{
  4659. MsgId: "H44022900158202103301732455843",
  4660. PsnNo: "44020000001102690557",
  4661. Info: "2207",
  4662. }
  4663. customData = append(customData, custom11)
  4664. custom12 := &CustomData{
  4665. MsgId: "H44022900158202103301745421708",
  4666. PsnNo: "44020000001102211928",
  4667. Info: "2207",
  4668. }
  4669. customData = append(customData, custom12)
  4670. custom1212 := &CustomData{
  4671. MsgId: "H440229001582021033017351627",
  4672. PsnNo: "44020000001102481733",
  4673. Info: "2207",
  4674. }
  4675. customData = append(customData, custom1212)
  4676. custom13 := &CustomData{
  4677. MsgId: "H44022900158202103301740327951",
  4678. PsnNo: "44020000001103174866",
  4679. Info: "2207",
  4680. }
  4681. customData = append(customData, custom13)
  4682. custom14 := &CustomData{
  4683. MsgId: "H4402290015820210330174922668",
  4684. PsnNo: "44020000001102927272",
  4685. Info: "2207",
  4686. }
  4687. customData = append(customData, custom14)
  4688. custom15 := &CustomData{
  4689. MsgId: "H44022900158202103301752362273",
  4690. PsnNo: "44020000001102942890",
  4691. Info: "2207",
  4692. }
  4693. customData = append(customData, custom15)
  4694. custom16 := &CustomData{
  4695. MsgId: "H44022900158202103301751082917",
  4696. PsnNo: "44020000001101662162",
  4697. Info: "2207",
  4698. }
  4699. customData = append(customData, custom16)
  4700. custom17 := &CustomData{
  4701. MsgId: "H44022900158202103301754147728",
  4702. PsnNo: "44020000000229014511",
  4703. Info: "2207",
  4704. }
  4705. customData = append(customData, custom17)
  4706. adminUser := c.GetAdminUserInfo()
  4707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4708. for _, item := range customData {
  4709. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4710. fmt.Println(result)
  4711. }
  4712. }
  4713. func (c *HisApiController) ReversalOtherData() {
  4714. var customData []*CustomData
  4715. custom := &CustomData{
  4716. MsgId: "H44022900158202103301714472004",
  4717. PsnNo: "44020000001101329945",
  4718. Info: "2208",
  4719. }
  4720. customData = append(customData, custom)
  4721. custom1 := &CustomData{
  4722. MsgId: "H4402290015820210330172057803",
  4723. PsnNo: "44020000001101161813",
  4724. Info: "2208",
  4725. }
  4726. customData = append(customData, custom1)
  4727. custom2 := &CustomData{
  4728. MsgId: "H44022900158202103301705198813",
  4729. PsnNo: "44190000133097375417",
  4730. Info: "2208",
  4731. }
  4732. customData = append(customData, custom2)
  4733. custom3 := &CustomData{
  4734. MsgId: "H44022900158202103301715524756",
  4735. PsnNo: "44020000001100187221",
  4736. Info: "2208",
  4737. }
  4738. customData = append(customData, custom3)
  4739. custom4 := &CustomData{
  4740. MsgId: "H44022900158202103301730376224",
  4741. PsnNo: "44020000001101959155",
  4742. Info: "2208",
  4743. }
  4744. customData = append(customData, custom4)
  4745. custom5 := &CustomData{
  4746. MsgId: "H44022900158202103301748008725",
  4747. PsnNo: "44020000001104246641",
  4748. Info: "2208",
  4749. }
  4750. customData = append(customData, custom5)
  4751. custom6 := &CustomData{
  4752. MsgId: "H44022900158202103301718096755",
  4753. PsnNo: "44020000001102211860",
  4754. Info: "2208",
  4755. }
  4756. customData = append(customData, custom6)
  4757. custom7 := &CustomData{
  4758. MsgId: "H44022900158202103301736551640",
  4759. PsnNo: "44020000001102687718",
  4760. Info: "2208",
  4761. }
  4762. customData = append(customData, custom7)
  4763. custom8 := &CustomData{
  4764. MsgId: "H44022900158202103301743097676",
  4765. PsnNo: "44020000001102127785",
  4766. Info: "2208",
  4767. }
  4768. customData = append(customData, custom8)
  4769. custom9 := &CustomData{
  4770. MsgId: "H44022900158202103301712304203",
  4771. PsnNo: "44020000001101518097",
  4772. Info: "2208",
  4773. }
  4774. customData = append(customData, custom9)
  4775. custom10 := &CustomData{
  4776. MsgId: "H44022900158202103301738448785",
  4777. PsnNo: "44020000001100500813",
  4778. Info: "2208",
  4779. }
  4780. customData = append(customData, custom10)
  4781. custom11 := &CustomData{
  4782. MsgId: "H44022900158202103301732455843",
  4783. PsnNo: "44020000001102690557",
  4784. Info: "2208",
  4785. }
  4786. customData = append(customData, custom11)
  4787. custom12 := &CustomData{
  4788. MsgId: "H44022900158202103301745421708",
  4789. PsnNo: "44020000001102211928",
  4790. Info: "2208",
  4791. }
  4792. customData = append(customData, custom12)
  4793. custom1212 := &CustomData{
  4794. MsgId: "H440229001582021033017351627",
  4795. PsnNo: "44020000001102481733",
  4796. Info: "2208",
  4797. }
  4798. customData = append(customData, custom1212)
  4799. custom13 := &CustomData{
  4800. MsgId: "H44022900158202103301740327951",
  4801. PsnNo: "44020000001103174866",
  4802. Info: "2208",
  4803. }
  4804. customData = append(customData, custom13)
  4805. custom14 := &CustomData{
  4806. MsgId: "H4402290015820210330174922668",
  4807. PsnNo: "44020000001102927272",
  4808. Info: "2208",
  4809. }
  4810. customData = append(customData, custom14)
  4811. custom15 := &CustomData{
  4812. MsgId: "H44022900158202103301752362273",
  4813. PsnNo: "44020000001102942890",
  4814. Info: "2208",
  4815. }
  4816. customData = append(customData, custom15)
  4817. custom16 := &CustomData{
  4818. MsgId: "H44022900158202103301751082917",
  4819. PsnNo: "44020000001101662162",
  4820. Info: "2208",
  4821. }
  4822. customData = append(customData, custom16)
  4823. custom17 := &CustomData{
  4824. MsgId: "H44022900158202103301754147728",
  4825. PsnNo: "44020000000229014511",
  4826. Info: "2208",
  4827. }
  4828. customData = append(customData, custom17)
  4829. adminUser := c.GetAdminUserInfo()
  4830. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4831. for _, item := range customData {
  4832. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4833. fmt.Println(result)
  4834. }
  4835. }
  4836. func PathExists(path string) (bool, error) {
  4837. _, err := os.Stat(path)
  4838. if err == nil {
  4839. return true, nil
  4840. }
  4841. if os.IsNotExist(err) {
  4842. return false, nil
  4843. }
  4844. return false, err
  4845. }
  4846. //创建文件夹
  4847. func Mkdir(dir string) {
  4848. // 创建文件夹
  4849. exist, err := PathExists(dir)
  4850. if err != nil {
  4851. fmt.Println(err.Error())
  4852. } else {
  4853. if exist {
  4854. fmt.Println(dir + "文件夹已存在!")
  4855. } else {
  4856. // 文件夹名称,权限
  4857. err := os.Mkdir(dir, os.ModePerm)
  4858. if err != nil {
  4859. fmt.Println(dir+"文件夹创建失败:", err.Error())
  4860. } else {
  4861. fmt.Println(dir + "文件夹创建成功!")
  4862. }
  4863. }
  4864. }
  4865. }
  4866. //压缩文件
  4867. func Zip(srcFile string, destZip string) error {
  4868. zipfile, err := os.Create(destZip)
  4869. if err != nil {
  4870. return err
  4871. }
  4872. defer zipfile.Close()
  4873. archive := zip.NewWriter(zipfile)
  4874. defer archive.Close()
  4875. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  4876. if err != nil {
  4877. return err
  4878. }
  4879. header, err := zip.FileInfoHeader(info)
  4880. if err != nil {
  4881. return err
  4882. }
  4883. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  4884. // header.Name = path
  4885. if info.IsDir() {
  4886. header.Name += "/"
  4887. } else {
  4888. header.Method = zip.Deflate
  4889. }
  4890. writer, err := archive.CreateHeader(header)
  4891. if err != nil {
  4892. return err
  4893. }
  4894. if !info.IsDir() {
  4895. file, err := os.Open(path)
  4896. if err != nil {
  4897. return err
  4898. }
  4899. defer file.Close()
  4900. _, err = io.Copy(writer, file)
  4901. }
  4902. return err
  4903. })
  4904. return err
  4905. }
  4906. func ReadFile(filePath string) []byte {
  4907. f, err := os.Open(filePath)
  4908. if err != nil {
  4909. fmt.Println("read file fail", err)
  4910. return nil
  4911. }
  4912. defer f.Close()
  4913. fd, err := ioutil.ReadAll(f)
  4914. if err != nil {
  4915. fmt.Println("read to fd fail", err)
  4916. return nil
  4917. }
  4918. return fd
  4919. }
  4920. func RemoveRepeatedCode(arr []string) (newArr []string) {
  4921. newArr = make([]string, 0)
  4922. for i := 0; i < len(arr); i++ {
  4923. repeat := false
  4924. for j := i + 1; j < len(arr); j++ {
  4925. if arr[i] == arr[j] {
  4926. repeat = true
  4927. break
  4928. }
  4929. }
  4930. if !repeat {
  4931. newArr = append(newArr, arr[i])
  4932. }
  4933. }
  4934. return
  4935. }