his_api_controller.go 182KB

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