sz_his_api_controller.go 177KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064
  1. package sz
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "github.com/axgle/mahonia"
  12. "math/rand"
  13. //"github.com/axgle/mahonia"
  14. "math"
  15. //"math/rand"µ
  16. "strconv"
  17. "strings"
  18. //"strings"
  19. "syscall"
  20. "time"
  21. "unsafe"
  22. )
  23. type Result struct {
  24. Transtime string `json:"transTime"`
  25. Transtype string `json:"transType"`
  26. Transreturncode string `json:"transReturnCode"`
  27. Transreturnmessage string `json:"transReturnMessage"`
  28. Transversion string `json:"transVersion"`
  29. Serialnumber string `json:"serialNumber"`
  30. Cardarea string `json:"cardArea"`
  31. Hospitalcode string `json:"hospitalCode"`
  32. Operatorcode string `json:"operatorCode"`
  33. Operatorname string `json:"operatorName"`
  34. Operatorpass string `json:"operatorPass"`
  35. Transbody struct {
  36. Akc190 string `json:"akc190"`
  37. Listsize int `json:"listsize"`
  38. Outputlist []struct {
  39. Aae072 string `json:"aae072"`
  40. Bkc369 string `json:"bkc369"`
  41. Bkf500 string `json:"bkf500"`
  42. Aka111 string `json:"aka111"`
  43. Ake001 string `json:"ake001"`
  44. Ake002 string `json:"ake002"`
  45. Bkm017 string `json:"bkm017"`
  46. Ake005 string `json:"ake005"`
  47. Ake006 string `json:"ake006"`
  48. Akc225 float64 `json:"akc225"`
  49. Akc226 float64 `json:"akc226"`
  50. Akc264 float64 `json:"akc264"`
  51. Aka065 string `json:"aka065"`
  52. Cka319 float64 `json:"cka319"`
  53. Akc268 float64 `json:"akc268"`
  54. } `json:"outputlist"`
  55. } `json:"transBody"`
  56. Verifycode string `json:"verifyCode"`
  57. Extenddeviceid string `json:"extendDeviceId"`
  58. Transchannel string `json:"transChannel"`
  59. Extenduserid string `json:"extendUserId"`
  60. Extendserialnumber string `json:"extendSerialNumber"`
  61. Caz055 string `json:"caz055"`
  62. Aae501 string `json:"aae501"`
  63. }
  64. type ResultOne struct {
  65. Transtime string `json:"transTime"`
  66. Transtype string `json:"transType"`
  67. Transreturncode string `json:"transReturnCode"`
  68. Transreturnmessage string `json:"transReturnMessage"`
  69. Transversion string `json:"transVersion"`
  70. Serialnumber string `json:"serialNumber"`
  71. Cardarea string `json:"cardArea"`
  72. Hospitalcode string `json:"hospitalCode"`
  73. Operatorcode string `json:"operatorCode"`
  74. Operatorname string `json:"operatorName"`
  75. Operatorpass string `json:"operatorPass"`
  76. Transbody struct {
  77. Ckc618 string `json:"ckc618"`
  78. Akc264 float64 `json:"akc264"`
  79. Akb068 int `json:"akb068"`
  80. Akb066 float64 `json:"akb066"`
  81. Akb067 int `json:"akb067"`
  82. Aae240 float64 `json:"aae240"`
  83. Outputlist []struct {
  84. Aaa036 string `json:"aaa036"`
  85. Aae019 float64 `json:"aae019"`
  86. } `json:"outputlist"`
  87. Outputlist2 []interface{} `json:"outputlist2"`
  88. } `json:"transBody"`
  89. Verifycode string `json:"verifyCode"`
  90. Extenddeviceid string `json:"extendDeviceId"`
  91. Transchannel string `json:"transChannel"`
  92. Extenduserid string `json:"extendUserId"`
  93. Extendserialnumber string `json:"extendSerialNumber"`
  94. Caz055 string `json:"caz055"`
  95. Aae501 string `json:"aae501"`
  96. }
  97. type ResultTwo struct {
  98. Transtime string `json:"transTime"`
  99. Transtype string `json:"transType"`
  100. Transreturncode string `json:"transReturnCode"`
  101. Transreturnmessage string `json:"transReturnMessage"`
  102. Transversion string `json:"transVersion"`
  103. Serialnumber string `json:"serialNumber"`
  104. Cardarea string `json:"cardArea"`
  105. Hospitalcode string `json:"hospitalCode"`
  106. Operatorcode string `json:"operatorCode"`
  107. Operatorname string `json:"operatorName"`
  108. Operatorpass string `json:"operatorPass"`
  109. Transbody struct {
  110. Ckc618 string `json:"ckc618"`
  111. Akc264 float64 `json:"akc264"`
  112. Akb068 float64 `json:"akb068"`
  113. Akb066 float64 `json:"akb066"`
  114. Akb067 float64 `json:"akb067"`
  115. Aae240 float64 `json:"aae240"`
  116. Outputlist1 []struct {
  117. Aka111 string `json:"aka111"`
  118. Bka058 float64 `json:"bka058"`
  119. } `json:"outputlist1"`
  120. Outputlist2 []struct {
  121. Aaa036 string `json:"aaa036"`
  122. Aae019 float64 `json:"aae019"`
  123. } `json:"outputlist2"`
  124. Outputlist3 []interface{} `json:"outputlist3"`
  125. } `json:"transBody"`
  126. Verifycode string `json:"verifyCode"`
  127. Extenddeviceid string `json:"extendDeviceId"`
  128. Transchannel string `json:"transChannel"`
  129. Extenduserid string `json:"extendUserId"`
  130. Extendserialnumber string `json:"extendSerialNumber"`
  131. Caz055 string `json:"caz055"`
  132. Aae501 string `json:"aae501"`
  133. }
  134. type ResultThree struct {
  135. Transtime string `json:"transTime"`
  136. Transtype string `json:"transType"`
  137. Transreturncode string `json:"transReturnCode"`
  138. Transreturnmessage string `json:"transReturnMessage"`
  139. Transversion string `json:"transVersion"`
  140. Serialnumber string `json:"serialNumber"`
  141. Cardarea string `json:"cardArea"`
  142. Hospitalcode string `json:"hospitalCode"`
  143. Operatorcode string `json:"operatorCode"`
  144. Operatorname string `json:"operatorName"`
  145. Operatorpass string `json:"operatorPass"`
  146. Transbody struct {
  147. Baz700 string `json:"baz700"`
  148. Ckc618 string `json:"ckc618"`
  149. } `json:"transBody"`
  150. Verifycode string `json:"verifyCode"`
  151. Extenddeviceid string `json:"extendDeviceId"`
  152. Transchannel string `json:"transChannel"`
  153. Extenduserid string `json:"extendUserId"`
  154. Extendserialnumber string `json:"extendSerialNumber"`
  155. Caz055 string `json:"caz055"`
  156. Aae501 string `json:"aae501"`
  157. }
  158. type ResultFive struct {
  159. Transtime string `json:"transTime"`
  160. Transtype string `json:"transType"`
  161. Transreturncode string `json:"transReturnCode"`
  162. Transreturnmessage string `json:"transReturnMessage"`
  163. Transversion string `json:"transVersion"`
  164. Serialnumber string `json:"serialNumber"`
  165. Cardarea string `json:"cardArea"`
  166. Hospitalcode string `json:"hospitalCode"`
  167. Operatorcode string `json:"operatorCode"`
  168. Operatorname string `json:"operatorName"`
  169. Operatorpass string `json:"operatorPass"`
  170. Transbody struct {
  171. Akc190 string `json:"akc190"`
  172. Listsize int `json:"listsize"`
  173. Outputlist []struct {
  174. Aae072 string `json:"aae072"`
  175. Bkf500 string `json:"bkf500"`
  176. Baz700 string `json:"baz700"`
  177. Bce574 string `json:"bce574"`
  178. } `json:"outputlist"`
  179. } `json:"transBody"`
  180. Verifycode string `json:"verifyCode"`
  181. Extenddeviceid string `json:"extendDeviceId"`
  182. Transchannel string `json:"transChannel"`
  183. Extenduserid string `json:"extendUserId"`
  184. Extendserialnumber string `json:"extendSerialNumber"`
  185. Caz055 string `json:"caz055"`
  186. Aae501 string `json:"aae501"`
  187. }
  188. type ResultFour struct {
  189. Transtime string `json:"transTime"`
  190. Transtype string `json:"transType"`
  191. Transreturncode string `json:"transReturnCode"`
  192. Transreturnmessage string `json:"transReturnMessage"`
  193. Transversion string `json:"transVersion"`
  194. Serialnumber string `json:"serialNumber"`
  195. Cardarea string `json:"cardArea"`
  196. Hospitalcode string `json:"hospitalCode"`
  197. Operatorcode string `json:"operatorCode"`
  198. Operatorname string `json:"operatorName"`
  199. Operatorpass string `json:"operatorPass"`
  200. Transbody struct {
  201. Akc190 string `json:"akc190"`
  202. Akc194 int `json:"akc194"`
  203. Bae917 int64 `json:"bae917"`
  204. Aka018 string `json:"aka018"`
  205. Aka030 string `json:"aka030"`
  206. Ckc618 string `json:"ckc618"`
  207. Akc264 float64 `json:"akc264"`
  208. Akb068 float64 `json:"akb068"`
  209. Akb066 float64 `json:"akb066"`
  210. Akb067 float64 `json:"akb067"`
  211. Cke298 float64 `json:"cke298"`
  212. Aae240 float64 `json:"aae240"`
  213. Outputlist1 []struct {
  214. Aae072 string `json:"aae072"`
  215. Bkc369 string `json:"bkc369"`
  216. Bkf500 string `json:"bkf500"`
  217. Aka111 string `json:"aka111"`
  218. Ake001 string `json:"ake001"`
  219. Ake002 string `json:"ake002"`
  220. Bkm017 string `json:"bkm017"`
  221. Ake005 string `json:"ake005"`
  222. Ake006 string `json:"ake006"`
  223. Ala026 string `json:"ala026"`
  224. Aka070 string `json:"aka070"`
  225. Aka074 string `json:"aka074"`
  226. Akc226 float64 `json:"akc226"`
  227. Akc225 float64 `json:"akc225"`
  228. Akc264 float64 `json:"akc264"`
  229. Aka067 string `json:"aka067"`
  230. Akc271 int `json:"akc271"`
  231. Bkc320 string `json:"bkc320"`
  232. Cke400 string `json:"cke400"`
  233. Ckc618 string `json:"ckc618"`
  234. Bka069 int64 `json:"bka069"`
  235. Aka018 string `json:"aka018"`
  236. Aka030 string `json:"aka030"`
  237. Aka065 string `json:"aka065"`
  238. Cka319 float64 `json:"cka319"`
  239. Akc268 float64 `json:"akc268"`
  240. } `json:"outputlist1"`
  241. Outputlist2 []struct {
  242. Aka111 string `json:"aka111"`
  243. Bka058 float64 `json:"bka058"`
  244. } `json:"outputlist2"`
  245. Outputlist3 []struct {
  246. Aaa036 string `json:"aaa036"`
  247. Aae019 float64 `json:"aae019"`
  248. } `json:"outputlist3"`
  249. } `json:"transBody"`
  250. Verifycode string `json:"verifyCode"`
  251. Extenddeviceid string `json:"extendDeviceId"`
  252. Transchannel string `json:"transChannel"`
  253. Extenduserid string `json:"extendUserId"`
  254. Extendserialnumber string `json:"extendSerialNumber"`
  255. Caz055 string `json:"caz055"`
  256. Aae501 string `json:"aae501"`
  257. }
  258. type ResultMZ001 struct {
  259. Transtime string `json:"transTime"`
  260. Transtype string `json:"transType"`
  261. Transreturncode string `json:"transReturnCode"`
  262. Transreturnmessage string `json:"transReturnMessage"`
  263. Transversion string `json:"transVersion"`
  264. Serialnumber string `json:"serialNumber"`
  265. Cardarea string `json:"cardArea"`
  266. Hospitalcode string `json:"hospitalCode"`
  267. Operatorcode string `json:"operatorCode"`
  268. Operatorname string `json:"operatorName"`
  269. Operatorpass string `json:"operatorPass"`
  270. Transbody struct {
  271. Aaz515 string `json:"aaz515"`
  272. Aaz500 string `json:"aaz500"`
  273. Aac001 float64 `json:"aac001"`
  274. Aac999 string `json:"aac999"`
  275. Aac002 string `json:"aac002"`
  276. Aac058 string `json:"aac058"`
  277. Aac147 string `json:"aac147"`
  278. Aac003 string `json:"aac003"`
  279. Aac004 string `json:"aac004"`
  280. Aac006 float64 `json:"aac006"`
  281. Bae093 float64 `json:"bae093"`
  282. Cac215 string `json:"cac215"`
  283. Aac066 string `json:"aac066"`
  284. Aac008 string `json:"aac008"`
  285. Bke404 string `json:"bke404"`
  286. Aae240 float64 `json:"aae240"`
  287. Bkc346 string `json:"bkc346"`
  288. Ckc601 string `json:"ckc601"`
  289. Caz574 string `json:"caz574"`
  290. Caz654 string `json:"caz654"`
  291. Ckc403 string `json:"ckc403"`
  292. Ckc362 string `json:"ckc362"`
  293. Ckc363 string `json:"ckc363"`
  294. Outputlist1 []struct {
  295. Aab001 float64 `json:"aab001"`
  296. Aab999 string `json:"aab999"`
  297. Aab004 string `json:"aab004"`
  298. Aab019 string `json:"aab019"`
  299. Aae140 string `json:"aae140"`
  300. Aae030 float64 `json:"aae030"`
  301. Aae031 string `json:"aae031"`
  302. Bcc334 string `json:"bcc334"`
  303. Aac031 string `json:"aac031"`
  304. } `json:"outputlist1"`
  305. } `json:"transBody"`
  306. Verifycode string `json:"verifyCode"`
  307. Extenddeviceid string `json:"extendDeviceId"`
  308. Transchannel string `json:"transChannel"`
  309. Extenduserid string `json:"extendUserId"`
  310. Extendserialnumber string `json:"extendSerialNumber"`
  311. Caz055 string `json:"caz055"`
  312. Aae501 string `json:"aae501"`
  313. }
  314. type SZHisApiController struct {
  315. controllers.BaseAuthAPIController
  316. }
  317. func SZHisManagerApiRegistRouters() {
  318. //挂号
  319. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  320. //结算
  321. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  322. //退费
  323. beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
  324. beego.Router("/sz/api/readcard", &SZHisApiController{}, "get:ReadCard")
  325. beego.Router("sz/api/refundnumber/get", &SZHisApiController{}, "get:RefundNumber")
  326. beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
  327. //查询交易
  328. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  329. //beego.Router("/sz/api/detail/upload", &SZHisApiController{}, "get:GetUploadDetail")
  330. beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
  331. //
  332. ////机构药品目录备案
  333. beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
  334. ////协议机构诊疗项目
  335. beego.Router("/sz/api/treatment/get", &SZHisApiController{}, "get:GetTreatmentProject")
  336. ////协议机构目录备案撤销
  337. beego.Router("/sz/api/revocation/get", &SZHisApiController{}, "get:GetRevocation")
  338. //
  339. ////定点机构约定信息查询
  340. //beego.Router("/sz/api/information/query/get",&SZHisApiController{},"get:GetInformationQuery")
  341. ////-医药师信息登记
  342. beego.Router("/sz/api/doctor/get", &SZHisApiController{}, "get:GetDoctorList")
  343. ////医药师执业状态变更
  344. beego.Router("/sz/api/medical/get", &SZHisApiController{}, "get:GetMedicalList")
  345. ////医药师信息更新
  346. //beego.Router("/sz/api/update/medical/get", &SZHisApiController{}, "get:GetUpdateMedicalList")
  347. ////协议机构材料目录备案
  348. //
  349. beego.Router("/sz/api/goods/get", &SZHisApiController{}, "get:GetGoodsList")
  350. }
  351. func IntPtr(n int) uintptr {
  352. return uintptr(n)
  353. }
  354. func StrPtr(s string) uintptr {
  355. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  356. }
  357. type Custom struct {
  358. DetItemFeeSumamt string
  359. Cut string
  360. FeedetlSn string
  361. Price string
  362. MedListCodg string
  363. Type int64
  364. AdviceId int64
  365. ProjectId int64
  366. ItemId int64
  367. }
  368. func (c *SZHisApiController) ReadCard() {
  369. id_card_type, _ := c.GetInt64("id_card_type")
  370. adminInfo := c.GetAdminUserInfo()
  371. if id_card_type != 1 {
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorNoReadCardException)
  373. return
  374. }
  375. month := time.Unix(1557042972, 0).Format("1")
  376. year := time.Now().Format("2006")
  377. month = time.Now().Format("01")
  378. day := time.Now().Format("02")
  379. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  380. number := miConfig.Code + year + month + day +
  381. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  382. id_card_number, health_card_no, _, ret4 := ReadBasCard("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  383. if ret4 == 0 {
  384. patient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  385. if patient.ID == 0 {
  386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  387. return
  388. } else {
  389. c.ServeSuccessJSON(map[string]interface{}{
  390. "patient": patient,
  391. "health_card_no": health_card_no,
  392. })
  393. }
  394. } else {
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  396. return
  397. }
  398. }
  399. //获取读卡信息 -- 门诊挂号
  400. //func (c *SZHisApiController) GetRegisterInfo() {
  401. // adminInfo := c.GetAdminUserInfo()
  402. // admin_user_id, _ := c.GetInt64("admin_user_id")
  403. // patient_id, _ := c.GetInt64("id")
  404. // record_time := c.GetString("record_time")
  405. // settlementValue, _ := c.GetInt64("settlement_value")
  406. // medical_insurance_card := c.GetString("medical_insurance_card")
  407. // name := c.GetString("name")
  408. // id_card_type, _ := c.GetInt64("id_card_type")
  409. // certificates, _ := c.GetInt64("certificates")
  410. // medical_care, _ := c.GetInt64("medical_care")
  411. // birthday := c.GetString("birthday")
  412. // id_card := c.GetString("id_card")
  413. // register_type, _ := c.GetInt64("register")
  414. // doctor, _ := c.GetInt64("doctor")
  415. // department, _ := c.GetInt64("department")
  416. // gender, _ := c.GetInt64("sex")
  417. // registration_fee, _ := c.GetFloat("registration_fee")
  418. // medical_expenses, _ := c.GetFloat("medical_expenses")
  419. // social_type, _ := c.GetInt64("social_type")
  420. //
  421. // is_yidi, _ := c.GetInt64("is_yidi")
  422. //
  423. // timeLayout := "2006-01-02"
  424. // loc, _ := time.LoadLocation("Local")
  425. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  426. // birthUnix := birthdays.Unix()
  427. //
  428. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  429. // if err != nil {
  430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  431. // return
  432. // }
  433. //
  434. // var patient service.Patients
  435. // if patient_id == 0 {
  436. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  437. // } else {
  438. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  439. // }
  440. //
  441. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  442. // if patient.ID == 0 {
  443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  444. // return
  445. // }
  446. // if len(patient.IdCardNo) == 0 {
  447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  448. // return
  449. // }
  450. //
  451. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  452. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  453. //
  454. // var custom_code string
  455. // var custom_project_name string
  456. // var allPrice float64
  457. //
  458. // switch register_type {
  459. // case 1:
  460. // custom_code = "110100002"
  461. // custom_project_name = "普通门诊"
  462. // allPrice = 10
  463. // break
  464. // case 3:
  465. // custom_code = "110200002-2"
  466. // custom_project_name = "主任医师"
  467. // allPrice = 10
  468. //
  469. // break
  470. // case 2:
  471. // custom_code = "110200002-3"
  472. // custom_project_name = "副主任医师"
  473. // allPrice = 10
  474. //
  475. // break
  476. // case 4:
  477. // custom_code = "0"
  478. // custom_project_name = "免受诊金"
  479. // allPrice = 0
  480. // break
  481. // case 5:
  482. // custom_code = "110200002-1"
  483. // custom_project_name = "专家"
  484. // allPrice = 10
  485. //
  486. // break
  487. // }
  488. //
  489. // if his.ID == 0 {
  490. //
  491. // var doctor_name string
  492. // var doctor_code string
  493. // if adminRole.ID == 0 {
  494. //
  495. // doctor_name = ""
  496. // doctor_code = "1001"
  497. // doctor_name = ""
  498. // doctor_code = ""
  499. //
  500. // } else {
  501. // doctor_name = adminRole.UserName
  502. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  503. //
  504. // }
  505. // month := time.Unix(1557042972, 0).Format("1")
  506. // year := time.Now().Format("2006")
  507. // month = time.Now().Format("01")
  508. // day := time.Now().Format("02")
  509. //
  510. // //流水号
  511. // //
  512. // number := miConfig.Code + year + month + day +
  513. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  514. // mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  515. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  516. // //1.判断读卡类型
  517. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  518. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  519. // fmt.Println(yiliao_number)
  520. // fmt.Println(id_card_number)
  521. // fmt.Println(verifyCode)
  522. // fmt.Println(version_code)
  523. // fmt.Println(ret4)
  524. //
  525. // dept_code := "0305"
  526. // is_yidi = 1
  527. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  528. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  529. // if tempPatient.ID == patient_id {
  530. // if ret4 == 0 { //本地卡流程
  531. // if is_yidi == 1 {
  532. // //本地就医流程
  533. // //挂号
  534. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice,medical_care)
  535. // var dat map[string]interface{}
  536. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  537. // fmt.Println(dat)
  538. // } else {
  539. // fmt.Println(err)
  540. // }
  541. // userJSONBytes, _ := json.Marshal(dat)
  542. // var res ResultOne
  543. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  544. // utils.ErrorLog("解析失败:%v", err)
  545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  546. // return
  547. // }
  548. // if res.Transreturncode == "00000000" {
  549. // his := models.VMHisPatient{
  550. // Name: name,
  551. // Gender: gender,
  552. // Birthday: birthUnix,
  553. // MedicalTreatmentType: medical_care,
  554. // IdType: certificates,
  555. // IdCardNo: id_card,
  556. // BalanceAccountsType: settlementValue,
  557. // SocialType: social_type,
  558. // MedicalInsuranceNumber: medical_insurance_card,
  559. // RegisterType: register_type,
  560. // RegisterCost: registration_fee,
  561. // TreatmentCost: medical_expenses,
  562. // Status: 1,
  563. // Ctime: time.Now().Unix(),
  564. // Mtime: time.Now().Unix(),
  565. // Iinfo: resp_result,
  566. // PatientId: patient.ID,
  567. // RecordDate: theTime.Unix(),
  568. // UserOrgId: adminInfo.CurrentOrgId,
  569. // AdminUserId: admin_user_id,
  570. // IsReturn: 1,
  571. // IdCardType: id_card_type,
  572. // Doctor: doctor,
  573. // Departments: department,
  574. // YiliaoNumber: yiliao_number,
  575. // MzNumber: number,
  576. // Number: mz_number,
  577. // }
  578. // service.CreateHisPatientTwo(&his)
  579. // c.ServeSuccessJSON(map[string]interface{}{
  580. // "msg": "挂号成功",
  581. // })
  582. // } else {
  583. // c.ServeSuccessJSON(map[string]interface{}{
  584. // "failed_code": -10,
  585. // "msg": res.Transreturnmessage,
  586. // })
  587. // return
  588. // }
  589. //
  590. // } else {
  591. // //异地就医流程
  592. // //异地走鉴权流程
  593. // //authResult := CardAuth(number)
  594. // //fmt.Println(authResult)
  595. //
  596. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  597. // //if tempPatient.ID == patient_id {
  598. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  599. // var dat map[string]interface{}
  600. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  601. // fmt.Println(dat)
  602. // } else {
  603. // fmt.Println(err)
  604. // }
  605. //
  606. // userJSONBytes, _ := json.Marshal(dat)
  607. //
  608. // var res ResultOne
  609. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  610. // utils.ErrorLog("解析失败:%v", err)
  611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  612. // return
  613. // }
  614. // if res.Transreturncode == "00000000" {
  615. // his := models.VMHisPatient{
  616. // Name: name,
  617. // Gender: gender,
  618. // Birthday: birthUnix,
  619. // MedicalTreatmentType: medical_care,
  620. // IdType: certificates,
  621. // IdCardNo: id_card,
  622. // BalanceAccountsType: settlementValue,
  623. // SocialType: social_type,
  624. // MedicalInsuranceNumber: medical_insurance_card,
  625. // RegisterType: register_type,
  626. // RegisterCost: registration_fee,
  627. // TreatmentCost: medical_expenses,
  628. // Status: 1,
  629. // Ctime: time.Now().Unix(),
  630. // Mtime: time.Now().Unix(),
  631. // Iinfo: resp_result,
  632. // PatientId: patient.ID,
  633. // RecordDate: theTime.Unix(),
  634. // UserOrgId: adminInfo.CurrentOrgId,
  635. // AdminUserId: admin_user_id,
  636. // IsReturn: 1,
  637. // IdCardType: id_card_type,
  638. // Doctor: doctor,
  639. // Departments: department,
  640. // YiliaoNumber: yiliao_number,
  641. // MzNumber: number,
  642. // Number: mz_number,
  643. // }
  644. // service.CreateHisPatientTwo(&his)
  645. // c.ServeSuccessJSON(map[string]interface{}{
  646. // "msg": "挂号成功",
  647. // })
  648. // } else {
  649. // c.ServeSuccessJSON(map[string]interface{}{
  650. // "failed_code": -10,
  651. // "msg": res.Transreturnmessage,
  652. // })
  653. // return
  654. // }
  655. //
  656. // }
  657. //
  658. // } else { //异地卡流程
  659. // //readCardBasResult := ReadCardBasHSM(number)
  660. // //fmt.Println(readCardBasResult)
  661. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  662. // if is_yidi == 1 { //1本地就医
  663. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  664. // var dat map[string]interface{}
  665. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  666. // fmt.Println(dat)
  667. // } else {
  668. // fmt.Println(err)
  669. // }
  670. //
  671. // userJSONBytes, _ := json.Marshal(dat)
  672. //
  673. // var res ResultOne
  674. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  675. // utils.ErrorLog("解析失败:%v", err)
  676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  677. // return
  678. // }
  679. // if res.Transreturncode == "00000000" {
  680. // his := models.VMHisPatient{
  681. // Name: name,
  682. // Gender: gender,
  683. // Birthday: birthUnix,
  684. // MedicalTreatmentType: medical_care,
  685. // IdType: certificates,
  686. // IdCardNo: id_card,
  687. // BalanceAccountsType: settlementValue,
  688. // SocialType: social_type,
  689. // MedicalInsuranceNumber: medical_insurance_card,
  690. // RegisterType: register_type,
  691. // RegisterCost: registration_fee,
  692. // TreatmentCost: medical_expenses,
  693. // Status: 1,
  694. // Ctime: time.Now().Unix(),
  695. // Mtime: time.Now().Unix(),
  696. // Iinfo: resp_result,
  697. // PatientId: patient.ID,
  698. // RecordDate: theTime.Unix(),
  699. // UserOrgId: adminInfo.CurrentOrgId,
  700. // AdminUserId: admin_user_id,
  701. // IsReturn: 1,
  702. // IdCardType: id_card_type,
  703. // Doctor: doctor,
  704. // Departments: department,
  705. // YiliaoNumber: yiliao_number,
  706. // MzNumber: number,
  707. // Number: mz_number,
  708. // }
  709. // service.CreateHisPatientTwo(&his)
  710. // c.ServeSuccessJSON(map[string]interface{}{
  711. // "msg": "挂号成功",
  712. // })
  713. // } else {
  714. // c.ServeSuccessJSON(map[string]interface{}{
  715. // "failed_code": -10,
  716. // "msg": res.Transreturnmessage,
  717. // })
  718. // return
  719. // }
  720. //
  721. // } else { //异地就医需要走鉴权流程
  722. // //authResult := CardAuth(number)
  723. // //fmt.Println(authResult)
  724. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  725. // var dat map[string]interface{}
  726. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  727. // fmt.Println(dat)
  728. // } else {
  729. // fmt.Println(err)
  730. // }
  731. //
  732. // userJSONBytes, _ := json.Marshal(dat)
  733. //
  734. // var res ResultOne
  735. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  736. // utils.ErrorLog("解析失败:%v", err)
  737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. // return
  739. // }
  740. // if res.Transreturncode == "00000000" {
  741. // his := models.VMHisPatient{
  742. // Name: name,
  743. // Gender: gender,
  744. // Birthday: birthUnix,
  745. // MedicalTreatmentType: medical_care,
  746. // IdType: certificates,
  747. // IdCardNo: id_card,
  748. // BalanceAccountsType: settlementValue,
  749. // SocialType: social_type,
  750. // MedicalInsuranceNumber: medical_insurance_card,
  751. // RegisterType: register_type,
  752. // RegisterCost: registration_fee,
  753. // TreatmentCost: medical_expenses,
  754. // Status: 1,
  755. // Ctime: time.Now().Unix(),
  756. // Mtime: time.Now().Unix(),
  757. // Iinfo: resp_result,
  758. // PatientId: patient.ID,
  759. // RecordDate: theTime.Unix(),
  760. // UserOrgId: adminInfo.CurrentOrgId,
  761. // AdminUserId: admin_user_id,
  762. // IsReturn: 1,
  763. // IdCardType: id_card_type,
  764. // Doctor: doctor,
  765. // Departments: department,
  766. // YiliaoNumber: yiliao_number,
  767. // MzNumber: number,
  768. // Number: mz_number,
  769. // }
  770. // service.CreateHisPatientTwo(&his)
  771. // c.ServeSuccessJSON(map[string]interface{}{
  772. // "msg": "挂号成功",
  773. // })
  774. // } else {
  775. // c.ServeSuccessJSON(map[string]interface{}{
  776. // "failed_code": -10,
  777. // "msg": res.Transreturnmessage,
  778. // })
  779. // return
  780. // }
  781. //
  782. // }
  783. // }
  784. // } else {
  785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  786. // return
  787. // }
  788. // } else {
  789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  790. // return
  791. // }
  792. //}
  793. func (c *SZHisApiController) GetRegisterInfo() {
  794. adminInfo := c.GetAdminUserInfo()
  795. admin_user_id, _ := c.GetInt64("admin_user_id")
  796. patient_id, _ := c.GetInt64("id")
  797. record_time := c.GetString("record_time")
  798. settlementValue, _ := c.GetInt64("settlement_value")
  799. medical_insurance_card := c.GetString("medical_insurance_card")
  800. name := c.GetString("name")
  801. id_card_type, _ := c.GetInt64("id_card_type")
  802. certificates, _ := c.GetInt64("certificates")
  803. medical_care, _ := c.GetInt64("medical_care")
  804. birthday := c.GetString("birthday")
  805. id_card := c.GetString("id_card")
  806. register_type, _ := c.GetInt64("register")
  807. doctor, _ := c.GetInt64("doctor")
  808. department, _ := c.GetInt64("department")
  809. gender, _ := c.GetInt64("sex")
  810. registration_fee, _ := c.GetFloat("registration_fee")
  811. medical_expenses, _ := c.GetFloat("medical_expenses")
  812. social_type, _ := c.GetInt64("social_type")
  813. is_yidi, _ := c.GetInt64("is_yidi")
  814. timeLayout := "2006-01-02"
  815. loc, _ := time.LoadLocation("Local")
  816. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  817. birthUnix := birthdays.Unix()
  818. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  819. if err != nil {
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  821. return
  822. }
  823. var patient service.Patients
  824. if patient_id == 0 {
  825. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  826. } else {
  827. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  828. }
  829. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  830. if patient.ID == 0 {
  831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  832. return
  833. }
  834. if len(patient.IdCardNo) == 0 {
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  836. return
  837. }
  838. //doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  839. doctorDepartment, _ := service.GetDepartMentDetail(department)
  840. adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  841. //his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  842. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, theTime.Unix())
  843. if len(his) >= 1 {
  844. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, theTime.Unix())
  845. if len(his) >= 1 && order.ID == 0 {
  846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  847. return
  848. }
  849. }
  850. var custom_code string
  851. var custom_project_name string
  852. var allPrice float64
  853. switch register_type {
  854. case 1:
  855. custom_code = "110100002"
  856. custom_project_name = "普通门诊"
  857. allPrice = 10
  858. break
  859. case 3:
  860. custom_code = "110200002-2"
  861. custom_project_name = "主任医师"
  862. allPrice = 10
  863. break
  864. case 2:
  865. custom_code = "110200002-3"
  866. custom_project_name = "副主任医师"
  867. allPrice = 10
  868. break
  869. case 4:
  870. custom_code = "0"
  871. custom_project_name = "免受诊金"
  872. allPrice = 0
  873. break
  874. case 5:
  875. custom_code = "110200002-1"
  876. custom_project_name = "专家"
  877. allPrice = 10
  878. break
  879. }
  880. var opera_name string
  881. var opera_code string
  882. if adminRole.ID == 0 {
  883. opera_name = "管理员"
  884. opera_code = "01"
  885. } else {
  886. opera_name = adminRole.UserName
  887. opera_code = strconv.FormatInt(admin_user_id, 10)
  888. }
  889. month := time.Unix(1557042972, 0).Format("1")
  890. year := time.Now().Format("2006")
  891. month = time.Now().Format("01")
  892. day := time.Now().Format("02")
  893. //流水号
  894. number := miConfig.Code + year + month + day +
  895. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  896. mz_number := miConfig.Code + year + month + day +
  897. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  898. //1.判断读卡类型
  899. //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  900. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  901. fmt.Println(yiliao_number)
  902. fmt.Println(id_card_number)
  903. fmt.Println(verifyCode)
  904. fmt.Println(version_code)
  905. fmt.Println(ret4)
  906. dept_code := doctorDepartment.Number
  907. is_yidi = 1
  908. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  909. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  910. fmt.Println(tempPatient.ID)
  911. fmt.Println(patient_id)
  912. if tempPatient.ID == patient_id {
  913. temp_mz_number := miConfig.Code + year + month + day +
  914. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  915. tempVerifyCode, tempVersionCode := ReadCardGetCode("XX001" + "|" + temp_mz_number + "|" + miConfig.Code)
  916. yiliao_number = "%GALMAFXJGKUKZNKWAIUH?;07857319025346309758?"
  917. result001 := service.SzybXX001(opera_name, opera_code, miConfig.Code, yiliao_number, tempVerifyCode, temp_mz_number, tempVersionCode)
  918. if ret4 == 0 { //本地卡流程
  919. if is_yidi == 1 {
  920. //var dat2 map[string]interface{}
  921. //if err := json.Unmarshal([]byte(result001), &dat2); err == nil {
  922. // fmt.Println(dat2)
  923. //} else {
  924. // fmt.Println(err)
  925. //}
  926. //userJSONBytes2, _ := json.Marshal(dat2)
  927. //var res2 ResultMZ001
  928. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  929. // utils.ErrorLog("解析失败:%v", err)
  930. //}
  931. //本地就医流程
  932. //挂号
  933. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  934. var dat map[string]interface{}
  935. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  936. fmt.Println(dat)
  937. } else {
  938. fmt.Println(err)
  939. }
  940. userJSONBytes, _ := json.Marshal(dat)
  941. var res ResultOne
  942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  943. utils.ErrorLog("解析失败:%v", err)
  944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  945. return
  946. }
  947. if res.Transreturncode == "00000000" {
  948. his := models.VMHisPatient{
  949. Name: name,
  950. Gender: gender,
  951. Birthday: birthUnix,
  952. MedicalTreatmentType: medical_care,
  953. IdType: certificates,
  954. IdCardNo: id_card,
  955. BalanceAccountsType: settlementValue,
  956. SocialType: social_type,
  957. MedicalInsuranceNumber: medical_insurance_card,
  958. RegisterType: register_type,
  959. RegisterCost: registration_fee,
  960. TreatmentCost: medical_expenses,
  961. Status: 1,
  962. Ctime: time.Now().Unix(),
  963. Mtime: time.Now().Unix(),
  964. Iinfo: resp_result,
  965. PatientId: patient.ID,
  966. RecordDate: theTime.Unix(),
  967. UserOrgId: adminInfo.CurrentOrgId,
  968. AdminUserId: admin_user_id,
  969. IsReturn: 1,
  970. IdCardType: id_card_type,
  971. Doctor: doctor,
  972. Departments: department,
  973. YiliaoNumber: yiliao_number,
  974. MzNumber: number,
  975. Number: mz_number,
  976. PsnNo: health_card_no,
  977. PatientInfo: result001,
  978. }
  979. service.CreateHisPatientTwo(&his)
  980. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, theTime.Unix())
  981. if len(lists) == 1 {
  982. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, theTime.Unix(), adminInfo.CurrentOrgId)
  983. }
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "msg": "挂号成功",
  986. })
  987. } else {
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": res.Transreturnmessage,
  991. })
  992. return
  993. }
  994. } else {
  995. //异地就医流程
  996. //异地走鉴权流程
  997. //authResult := CardAuth(number)
  998. //fmt.Println(authResult)
  999. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1000. //if tempPatient.ID == patient_id {
  1001. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1002. var dat map[string]interface{}
  1003. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1004. fmt.Println(dat)
  1005. } else {
  1006. fmt.Println(err)
  1007. }
  1008. userJSONBytes, _ := json.Marshal(dat)
  1009. var res ResultOne
  1010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1011. utils.ErrorLog("解析失败:%v", err)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. if res.Transreturncode == "00000000" {
  1016. his := models.VMHisPatient{
  1017. Name: name,
  1018. Gender: gender,
  1019. Birthday: birthUnix,
  1020. MedicalTreatmentType: medical_care,
  1021. IdType: certificates,
  1022. IdCardNo: id_card,
  1023. BalanceAccountsType: settlementValue,
  1024. SocialType: social_type,
  1025. MedicalInsuranceNumber: medical_insurance_card,
  1026. RegisterType: register_type,
  1027. RegisterCost: registration_fee,
  1028. TreatmentCost: medical_expenses,
  1029. Status: 1,
  1030. Ctime: time.Now().Unix(),
  1031. Mtime: time.Now().Unix(),
  1032. Iinfo: resp_result,
  1033. PatientId: patient.ID,
  1034. RecordDate: theTime.Unix(),
  1035. UserOrgId: adminInfo.CurrentOrgId,
  1036. AdminUserId: admin_user_id,
  1037. IsReturn: 1,
  1038. IdCardType: id_card_type,
  1039. Doctor: doctor,
  1040. Departments: department,
  1041. YiliaoNumber: yiliao_number,
  1042. MzNumber: number,
  1043. Number: mz_number,
  1044. PsnNo: health_card_no,
  1045. PatientInfo: result001,
  1046. }
  1047. service.CreateHisPatientTwo(&his)
  1048. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, theTime.Unix())
  1049. if len(lists) == 1 {
  1050. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, theTime.Unix(), adminInfo.CurrentOrgId)
  1051. }
  1052. c.ServeSuccessJSON(map[string]interface{}{
  1053. "msg": "挂号成功",
  1054. })
  1055. } else {
  1056. c.ServeSuccessJSON(map[string]interface{}{
  1057. "failed_code": -10,
  1058. "msg": res.Transreturnmessage,
  1059. })
  1060. return
  1061. }
  1062. }
  1063. } else { //异地卡流程
  1064. //readCardBasResult := ReadCardBasHSM(number)
  1065. //fmt.Println(readCardBasResult)
  1066. //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1067. if is_yidi == 1 { //1本地就医
  1068. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1069. var dat map[string]interface{}
  1070. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1071. fmt.Println(dat)
  1072. } else {
  1073. fmt.Println(err)
  1074. }
  1075. userJSONBytes, _ := json.Marshal(dat)
  1076. var res ResultOne
  1077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1078. utils.ErrorLog("解析失败:%v", err)
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1080. return
  1081. }
  1082. if res.Transreturncode == "00000000" {
  1083. his := models.VMHisPatient{
  1084. Name: name,
  1085. Gender: gender,
  1086. Birthday: birthUnix,
  1087. MedicalTreatmentType: medical_care,
  1088. IdType: certificates,
  1089. IdCardNo: id_card,
  1090. BalanceAccountsType: settlementValue,
  1091. SocialType: social_type,
  1092. MedicalInsuranceNumber: medical_insurance_card,
  1093. RegisterType: register_type,
  1094. RegisterCost: registration_fee,
  1095. TreatmentCost: medical_expenses,
  1096. Status: 1,
  1097. Ctime: time.Now().Unix(),
  1098. Mtime: time.Now().Unix(),
  1099. Iinfo: resp_result,
  1100. PatientId: patient.ID,
  1101. RecordDate: theTime.Unix(),
  1102. UserOrgId: adminInfo.CurrentOrgId,
  1103. AdminUserId: admin_user_id,
  1104. IsReturn: 1,
  1105. IdCardType: id_card_type,
  1106. Doctor: doctor,
  1107. Departments: department,
  1108. YiliaoNumber: yiliao_number,
  1109. MzNumber: number,
  1110. Number: mz_number,
  1111. PsnNo: health_card_no,
  1112. PatientInfo: result001,
  1113. }
  1114. service.CreateHisPatientTwo(&his)
  1115. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, theTime.Unix())
  1116. if len(lists) == 1 {
  1117. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, theTime.Unix(), adminInfo.CurrentOrgId)
  1118. }
  1119. c.ServeSuccessJSON(map[string]interface{}{
  1120. "msg": "挂号成功",
  1121. })
  1122. } else {
  1123. c.ServeSuccessJSON(map[string]interface{}{
  1124. "failed_code": -10,
  1125. "msg": res.Transreturnmessage,
  1126. })
  1127. return
  1128. }
  1129. } else { //异地就医需要走鉴权流程
  1130. //authResult := CardAuth(number)
  1131. //fmt.Println(authResult)
  1132. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1133. var dat map[string]interface{}
  1134. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1135. fmt.Println(dat)
  1136. } else {
  1137. fmt.Println(err)
  1138. }
  1139. userJSONBytes, _ := json.Marshal(dat)
  1140. var res ResultOne
  1141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. if res.Transreturncode == "00000000" {
  1147. his := models.VMHisPatient{
  1148. Name: name,
  1149. Gender: gender,
  1150. Birthday: birthUnix,
  1151. MedicalTreatmentType: medical_care,
  1152. IdType: certificates,
  1153. IdCardNo: id_card,
  1154. BalanceAccountsType: settlementValue,
  1155. SocialType: social_type,
  1156. MedicalInsuranceNumber: medical_insurance_card,
  1157. RegisterType: register_type,
  1158. RegisterCost: registration_fee,
  1159. TreatmentCost: medical_expenses,
  1160. Status: 1,
  1161. Ctime: time.Now().Unix(),
  1162. Mtime: time.Now().Unix(),
  1163. Iinfo: resp_result,
  1164. PatientId: patient.ID,
  1165. RecordDate: theTime.Unix(),
  1166. UserOrgId: adminInfo.CurrentOrgId,
  1167. AdminUserId: admin_user_id,
  1168. IsReturn: 1,
  1169. IdCardType: id_card_type,
  1170. Doctor: doctor,
  1171. Departments: department,
  1172. YiliaoNumber: yiliao_number,
  1173. MzNumber: number,
  1174. Number: mz_number,
  1175. PsnNo: health_card_no,
  1176. PatientInfo: result001,
  1177. }
  1178. service.CreateHisPatientTwo(&his)
  1179. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, theTime.Unix())
  1180. if len(lists) == 1 {
  1181. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, theTime.Unix(), adminInfo.CurrentOrgId)
  1182. }
  1183. c.ServeSuccessJSON(map[string]interface{}{
  1184. "msg": "挂号成功",
  1185. })
  1186. } else {
  1187. c.ServeSuccessJSON(map[string]interface{}{
  1188. "failed_code": -10,
  1189. "msg": res.Transreturnmessage,
  1190. })
  1191. return
  1192. }
  1193. }
  1194. }
  1195. } else {
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1197. return
  1198. }
  1199. }
  1200. //func (c *SZHisApiController) GetInfo() {
  1201. //func (c *SZHisApiController) GetRegisterInfo() {
  1202. // adminInfo := c.GetAdminUserInfo()
  1203. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1204. // patient_id, _ := c.GetInt64("id")
  1205. // record_time := c.GetString("record_time")
  1206. // settlementValue, _ := c.GetInt64("settlement_value")
  1207. // medical_insurance_card := c.GetString("medical_insurance_card")
  1208. // name := c.GetString("name")
  1209. // id_card_type, _ := c.GetInt64("id_card_type")
  1210. // certificates, _ := c.GetInt64("certificates")
  1211. // medical_care, _ := c.GetInt64("medical_care")
  1212. // birthday := c.GetString("birthday")
  1213. // id_card := c.GetString("id_card")
  1214. // register_type, _ := c.GetInt64("register")
  1215. // doctor, _ := c.GetInt64("doctor")
  1216. // department, _ := c.GetInt64("department")
  1217. // gender, _ := c.GetInt64("sex")
  1218. // registration_fee, _ := c.GetFloat("registration_fee")
  1219. // medical_expenses, _ := c.GetFloat("medical_expenses")
  1220. // social_type, _ := c.GetInt64("social_type")
  1221. //
  1222. // is_yidi, _ := c.GetInt64("is_yidi")
  1223. //
  1224. // timeLayout := "2006-01-02"
  1225. // loc, _ := time.LoadLocation("Local")
  1226. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1227. // birthUnix := birthdays.Unix()
  1228. //
  1229. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1230. // if err != nil {
  1231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1232. // return
  1233. // }
  1234. //
  1235. // var patient service.Patients
  1236. // if patient_id == 0 {
  1237. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1238. // } else {
  1239. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  1240. // }
  1241. //
  1242. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1243. // if patient.ID == 0 {
  1244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1245. // return
  1246. // }
  1247. // if len(patient.IdCardNo) == 0 {
  1248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1249. // return
  1250. // }
  1251. //
  1252. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1253. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  1254. //
  1255. // var custom_code string
  1256. // var custom_project_name string
  1257. // var allPrice float64
  1258. //
  1259. // switch register_type {
  1260. // case 1:
  1261. // custom_code = "110100002"
  1262. // custom_project_name = "普通门诊"
  1263. // allPrice = 10
  1264. // break
  1265. // case 3:
  1266. // custom_code = "110200002-2"
  1267. // custom_project_name = "主任医师"
  1268. // allPrice = 10
  1269. //
  1270. // break
  1271. // case 2:
  1272. // custom_code = "110200002-3"
  1273. // custom_project_name = "副主任医师"
  1274. // allPrice = 10
  1275. //
  1276. // break
  1277. // case 4:
  1278. // custom_code = "0"
  1279. // custom_project_name = "免受诊金"
  1280. // allPrice = 0
  1281. // break
  1282. // case 5:
  1283. // custom_code = "110200002-1"
  1284. // custom_project_name = "专家"
  1285. // allPrice = 10
  1286. //
  1287. // break
  1288. // }
  1289. //
  1290. // if his.ID == 0 {
  1291. //
  1292. // var doctor_name string
  1293. // var doctor_code string
  1294. // if adminRole.ID == 0 {
  1295. //
  1296. // doctor_name = ""
  1297. // doctor_code = "1001"
  1298. // doctor_name = ""
  1299. // doctor_code = ""
  1300. //
  1301. // } else {
  1302. // doctor_name = adminRole.UserName
  1303. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1304. //
  1305. // }
  1306. // month := time.Unix(1557042972, 0).Format("1")
  1307. // year := time.Now().Format("2006")
  1308. // month = time.Now().Format("01")
  1309. // day := time.Now().Format("02")
  1310. //
  1311. // //流水号
  1312. // //
  1313. // number := miConfig.Code + year + month + day +
  1314. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1315. // mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  1316. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  1317. // //1.判断读卡类型
  1318. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1319. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  1320. // fmt.Println(yiliao_number)
  1321. // fmt.Println(id_card_number)
  1322. // fmt.Println(verifyCode)
  1323. // fmt.Println(version_code)
  1324. // fmt.Println(ret4)
  1325. //
  1326. // dept_code := "0305"
  1327. // is_yidi = 1
  1328. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1329. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1330. // if tempPatient.ID == patient_id {
  1331. // if ret4 == 0 { //本地卡流程
  1332. // if is_yidi == 1 {
  1333. // //本地就医流程
  1334. // //挂号
  1335. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1336. // var dat map[string]interface{}
  1337. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1338. // fmt.Println(dat)
  1339. // } else {
  1340. // fmt.Println(err)
  1341. // }
  1342. // userJSONBytes, _ := json.Marshal(dat)
  1343. // var res ResultOne
  1344. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1345. // utils.ErrorLog("解析失败:%v", err)
  1346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1347. // return
  1348. // }
  1349. // if res.Transreturncode == "00000000" {
  1350. // his := models.VMHisPatient{
  1351. // Name: name,
  1352. // Gender: gender,
  1353. // Birthday: birthUnix,
  1354. // MedicalTreatmentType: medical_care,
  1355. // IdType: certificates,
  1356. // IdCardNo: id_card,
  1357. // BalanceAccountsType: settlementValue,
  1358. // SocialType: social_type,
  1359. // MedicalInsuranceNumber: medical_insurance_card,
  1360. // RegisterType: register_type,
  1361. // RegisterCost: registration_fee,
  1362. // TreatmentCost: medical_expenses,
  1363. // Status: 1,
  1364. // Ctime: time.Now().Unix(),
  1365. // Mtime: time.Now().Unix(),
  1366. // Iinfo: resp_result,
  1367. // PatientId: patient.ID,
  1368. // RecordDate: theTime.Unix(),
  1369. // UserOrgId: adminInfo.CurrentOrgId,
  1370. // AdminUserId: admin_user_id,
  1371. // IsReturn: 1,
  1372. // IdCardType: id_card_type,
  1373. // Doctor: doctor,
  1374. // Departments: department,
  1375. // YiliaoNumber: yiliao_number,
  1376. // MzNumber: number,
  1377. // Number: mz_number,
  1378. // }
  1379. // service.CreateHisPatientTwo(&his)
  1380. // c.ServeSuccessJSON(map[string]interface{}{
  1381. // "msg": "挂号成功",
  1382. // })
  1383. // } else {
  1384. // c.ServeSuccessJSON(map[string]interface{}{
  1385. // "failed_code": -10,
  1386. // "msg": res.Transreturnmessage,
  1387. // })
  1388. // return
  1389. // }
  1390. //
  1391. // } else {
  1392. // //异地就医流程
  1393. // //异地走鉴权流程
  1394. // //authResult := CardAuth(number)
  1395. // //fmt.Println(authResult)
  1396. //
  1397. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1398. // //if tempPatient.ID == patient_id {
  1399. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  1400. // var dat map[string]interface{}
  1401. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1402. // fmt.Println(dat)
  1403. // } else {
  1404. // fmt.Println(err)
  1405. // }
  1406. //
  1407. // userJSONBytes, _ := json.Marshal(dat)
  1408. //
  1409. // var res ResultOne
  1410. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1411. // utils.ErrorLog("解析失败:%v", err)
  1412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1413. // return
  1414. // }
  1415. // if res.Transreturncode == "00000000" {
  1416. // his := models.VMHisPatient{
  1417. // Name: name,
  1418. // Gender: gender,
  1419. // Birthday: birthUnix,
  1420. // MedicalTreatmentType: medical_care,
  1421. // IdType: certificates,
  1422. // IdCardNo: id_card,
  1423. // BalanceAccountsType: settlementValue,
  1424. // SocialType: social_type,
  1425. // MedicalInsuranceNumber: medical_insurance_card,
  1426. // RegisterType: register_type,
  1427. // RegisterCost: registration_fee,
  1428. // TreatmentCost: medical_expenses,
  1429. // Status: 1,
  1430. // Ctime: time.Now().Unix(),
  1431. // Mtime: time.Now().Unix(),
  1432. // Iinfo: resp_result,
  1433. // PatientId: patient.ID,
  1434. // RecordDate: theTime.Unix(),
  1435. // UserOrgId: adminInfo.CurrentOrgId,
  1436. // AdminUserId: admin_user_id,
  1437. // IsReturn: 1,
  1438. // IdCardType: id_card_type,
  1439. // Doctor: doctor,
  1440. // Departments: department,
  1441. // YiliaoNumber: yiliao_number,
  1442. // MzNumber: number,
  1443. // Number: mz_number,
  1444. // }
  1445. // service.CreateHisPatientTwo(&his)
  1446. // c.ServeSuccessJSON(map[string]interface{}{
  1447. // "msg": "挂号成功",
  1448. // })
  1449. // } else {
  1450. // c.ServeSuccessJSON(map[string]interface{}{
  1451. // "failed_code": -10,
  1452. // "msg": res.Transreturnmessage,
  1453. // })
  1454. // return
  1455. // }
  1456. //
  1457. // }
  1458. //
  1459. // } else { //异地卡流程
  1460. // //readCardBasResult := ReadCardBasHSM(number)
  1461. // //fmt.Println(readCardBasResult)
  1462. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1463. // if is_yidi == 1 { //1本地就医
  1464. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  1465. // var dat map[string]interface{}
  1466. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1467. // fmt.Println(dat)
  1468. // } else {
  1469. // fmt.Println(err)
  1470. // }
  1471. //
  1472. // userJSONBytes, _ := json.Marshal(dat)
  1473. //
  1474. // var res ResultOne
  1475. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1476. // utils.ErrorLog("解析失败:%v", err)
  1477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. // return
  1479. // }
  1480. // if res.Transreturncode == "00000000" {
  1481. // his := models.VMHisPatient{
  1482. // Name: name,
  1483. // Gender: gender,
  1484. // Birthday: birthUnix,
  1485. // MedicalTreatmentType: medical_care,
  1486. // IdType: certificates,
  1487. // IdCardNo: id_card,
  1488. // BalanceAccountsType: settlementValue,
  1489. // SocialType: social_type,
  1490. // MedicalInsuranceNumber: medical_insurance_card,
  1491. // RegisterType: register_type,
  1492. // RegisterCost: registration_fee,
  1493. // TreatmentCost: medical_expenses,
  1494. // Status: 1,
  1495. // Ctime: time.Now().Unix(),
  1496. // Mtime: time.Now().Unix(),
  1497. // Iinfo: resp_result,
  1498. // PatientId: patient.ID,
  1499. // RecordDate: theTime.Unix(),
  1500. // UserOrgId: adminInfo.CurrentOrgId,
  1501. // AdminUserId: admin_user_id,
  1502. // IsReturn: 1,
  1503. // IdCardType: id_card_type,
  1504. // Doctor: doctor,
  1505. // Departments: department,
  1506. // YiliaoNumber: yiliao_number,
  1507. // MzNumber: number,
  1508. // Number: mz_number,
  1509. // }
  1510. // service.CreateHisPatientTwo(&his)
  1511. // c.ServeSuccessJSON(map[string]interface{}{
  1512. // "msg": "挂号成功",
  1513. // })
  1514. // } else {
  1515. // c.ServeSuccessJSON(map[string]interface{}{
  1516. // "failed_code": -10,
  1517. // "msg": res.Transreturnmessage,
  1518. // })
  1519. // return
  1520. // }
  1521. //
  1522. // } else { //异地就医需要走鉴权流程
  1523. // //authResult := CardAuth(number)
  1524. // //fmt.Println(authResult)
  1525. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  1526. // var dat map[string]interface{}
  1527. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1528. // fmt.Println(dat)
  1529. // } else {
  1530. // fmt.Println(err)
  1531. // }
  1532. //
  1533. // userJSONBytes, _ := json.Marshal(dat)
  1534. //
  1535. // var res ResultOne
  1536. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. // }
  1541. // if res.Transreturncode == "00000000" {
  1542. // his := models.VMHisPatient{
  1543. // Name: name,
  1544. // Gender: gender,
  1545. // Birthday: birthUnix,
  1546. // MedicalTreatmentType: medical_care,
  1547. // IdType: certificates,
  1548. // IdCardNo: id_card,
  1549. // BalanceAccountsType: settlementValue,
  1550. // SocialType: social_type,
  1551. // MedicalInsuranceNumber: medical_insurance_card,
  1552. // RegisterType: register_type,
  1553. // RegisterCost: registration_fee,
  1554. // TreatmentCost: medical_expenses,
  1555. // Status: 1,
  1556. // Ctime: time.Now().Unix(),
  1557. // Mtime: time.Now().Unix(),
  1558. // Iinfo: resp_result,
  1559. // PatientId: patient.ID,
  1560. // RecordDate: theTime.Unix(),
  1561. // UserOrgId: adminInfo.CurrentOrgId,
  1562. // AdminUserId: admin_user_id,
  1563. // IsReturn: 1,
  1564. // IdCardType: id_card_type,
  1565. // Doctor: doctor,
  1566. // Departments: department,
  1567. // YiliaoNumber: yiliao_number,
  1568. // MzNumber: number,
  1569. // Number: mz_number,
  1570. // }
  1571. // service.CreateHisPatientTwo(&his)
  1572. // c.ServeSuccessJSON(map[string]interface{}{
  1573. // "msg": "挂号成功",
  1574. // })
  1575. // } else {
  1576. // c.ServeSuccessJSON(map[string]interface{}{
  1577. // "failed_code": -10,
  1578. // "msg": res.Transreturnmessage,
  1579. // })
  1580. // return
  1581. // }
  1582. //
  1583. // }
  1584. // }
  1585. // } else {
  1586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1587. // return
  1588. // }
  1589. // } else {
  1590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1591. // return
  1592. // }
  1593. //}
  1594. //func (c *SZHisApiController) GetRegisterInfo() {
  1595. // adminInfo := c.GetAdminUserInfo()
  1596. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1597. // month := time.Unix(1557042972, 0).Format("1")
  1598. // year := time.Now().Format("2006")
  1599. // month = time.Now().Format("01")
  1600. // day := time.Now().Format("02")
  1601. // //流水号
  1602. // number := miConfig.Code + year + month + day +
  1603. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1604. // //1.判断读卡类型
  1605. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1606. // yiliao_number, _, verifyCode, version_code, _, _, _ := ReadBasCardGetNumber("XX001" + "|" + number + "|" + miConfig.Code + "|")
  1607. // fmt.Println(result)
  1608. //
  1609. //}
  1610. func (c *SZHisApiController) RefundNumber() {
  1611. record_time := c.GetString("record_time")
  1612. patient_id, _ := c.GetInt64("patient_id")
  1613. admin_user_id, _ := c.GetInt64("admin_user_id")
  1614. timeLayout := "2006-01-02"
  1615. loc, _ := time.LoadLocation("Local")
  1616. adminUser := c.GetAdminUserInfo()
  1617. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1618. fmt.Println(err)
  1619. if err != nil {
  1620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1621. return
  1622. }
  1623. recordDateTime := theTime.Unix()
  1624. fmt.Println(recordDateTime)
  1625. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  1626. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1628. //结算流程
  1629. var doctor_name string
  1630. var doctor_code string
  1631. if roles.ID == 0 {
  1632. doctor_name = "管理员"
  1633. doctor_code = "01"
  1634. } else {
  1635. doctor_name = roles.UserName
  1636. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1637. }
  1638. month := time.Unix(1557042972, 0).Format("1")
  1639. year := time.Now().Format("2006")
  1640. month = time.Now().Format("01")
  1641. day := time.Now().Format("02")
  1642. //number := miConfig.Code + year + month + day + "1367866"
  1643. number := miConfig.Code + year + month + day +
  1644. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1645. //number := miConfig.Code + year + month + day + "1590003"
  1646. //流水号
  1647. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1648. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  1649. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1650. if config.IsOpen == 1 { //对接了医保,走医保流程
  1651. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, his.MzNumber, his.Number, verifyCode, number, version_code)
  1652. var dat map[string]interface{}
  1653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1654. fmt.Println(dat)
  1655. } else {
  1656. fmt.Println(err)
  1657. }
  1658. userJSONBytes, _ := json.Marshal(dat)
  1659. var res ResultThree
  1660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1661. utils.ErrorLog("解析失败:%v", err)
  1662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1663. return
  1664. }
  1665. if res.Transreturncode == "00000000" {
  1666. service.UpdataHisStatusSZ(adminUser.CurrentOrgId, his.MzNumber, his.Number, result)
  1667. c.ServeSuccessJSON(map[string]interface{}{
  1668. "msg": "退号成功",
  1669. })
  1670. } else {
  1671. c.ServeSuccessJSON(map[string]interface{}{
  1672. "failed_code": -10,
  1673. "msg": res.Transreturnmessage,
  1674. })
  1675. }
  1676. }
  1677. }
  1678. //func (c *SZHisApiController) GetRegisterInfo() {
  1679. // adminInfo := c.GetAdminUserInfo()
  1680. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1681. // patient_id, _ := c.GetInt64("id")
  1682. // record_time := c.GetString("record_time")
  1683. // settlementValue, _ := c.GetInt64("settlement_value")
  1684. // medical_insurance_card := c.GetString("medical_insurance_card")
  1685. // name := c.GetString("name")
  1686. // id_card_type, _ := c.GetInt64("id_card_type")
  1687. // certificates, _ := c.GetInt64("certificates")
  1688. // medical_care, _ := c.GetInt64("medical_care")
  1689. // birthday := c.GetString("birthday")
  1690. // id_card := c.GetString("id_card")
  1691. // register_type, _ := c.GetInt64("register")
  1692. // doctor, _ := c.GetInt64("doctor")
  1693. // department, _ := c.GetInt64("department")
  1694. // gender, _ := c.GetInt64("sex")
  1695. // registration_fee, _ := c.GetFloat("registration_fee")
  1696. // medical_expenses, _ := c.GetFloat("medical_expenses")
  1697. // social_type, _ := c.GetInt64("social_type")
  1698. //
  1699. // is_yidi, _ := c.GetInt64("is_yidi")
  1700. //
  1701. // timeLayout := "2006-01-02"
  1702. // loc, _ := time.LoadLocation("Local")
  1703. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1704. // birthUnix := birthdays.Unix()
  1705. //
  1706. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1707. // if err != nil {
  1708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1709. // return
  1710. // }
  1711. //
  1712. // var patient service.Patients
  1713. // if patient_id == 0 {
  1714. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1715. // } else {
  1716. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  1717. // }
  1718. //
  1719. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1720. // if patient.ID == 0 {
  1721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1722. // return
  1723. // }
  1724. // if len(patient.IdCardNo) == 0 {
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1726. // return
  1727. // }
  1728. //
  1729. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1730. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  1731. //
  1732. // var custom_code string
  1733. // var custom_project_name string
  1734. // var allPrice float64
  1735. //
  1736. // switch register_type {
  1737. // case 1:
  1738. // custom_code = "110100002"
  1739. // custom_project_name = "普通门诊"
  1740. // allPrice = 10
  1741. // break
  1742. // case 3:
  1743. // custom_code = "110200002-2"
  1744. // custom_project_name = "主任医师"
  1745. // allPrice = 10
  1746. //
  1747. // break
  1748. // case 2:
  1749. // custom_code = "110200002-3"
  1750. // custom_project_name = "副主任医师"
  1751. // allPrice = 10
  1752. //
  1753. // break
  1754. // case 4:
  1755. // custom_code = "0"
  1756. // custom_project_name = "免受诊金"
  1757. // allPrice = 0
  1758. // break
  1759. // case 5:
  1760. // custom_code = "110200002-1"
  1761. // custom_project_name = "专家"
  1762. // allPrice = 10
  1763. //
  1764. // break
  1765. // }
  1766. //
  1767. // if his.ID == 0 {
  1768. //
  1769. // var doctor_name string
  1770. // var doctor_code string
  1771. // if adminRole.ID == 0 {
  1772. //
  1773. // doctor_name = "管理员"
  1774. // doctor_code = "01"
  1775. //
  1776. // } else {
  1777. // doctor_name = adminRole.UserName
  1778. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1779. //
  1780. // }
  1781. // month := time.Unix(1557042972, 0).Format("1")
  1782. // year := time.Now().Format("2006")
  1783. // month = time.Now().Format("01")
  1784. // day := time.Now().Format("02")
  1785. //
  1786. // //流水号
  1787. // //
  1788. // number := miConfig.Code + year + month + day +
  1789. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1790. // mz_number := miConfig.Code + year + month + day +
  1791. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  1792. // //1.判断读卡类型
  1793. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1794. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  1795. // fmt.Println(yiliao_number)
  1796. // fmt.Println(id_card_number)
  1797. // fmt.Println(verifyCode)
  1798. // fmt.Println(version_code)
  1799. // fmt.Println(ret4)
  1800. //
  1801. // dept_code := "0306"
  1802. // is_yidi = 1
  1803. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1804. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1805. // fmt.Println(tempPatient.ID)
  1806. // fmt.Println(patient_id)
  1807. //
  1808. // if tempPatient.ID == patient_id {
  1809. // if ret4 == 0 { //本地卡流程
  1810. // if is_yidi == 1 {
  1811. // //本地就医流程
  1812. // //挂号
  1813. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1814. // var dat map[string]interface{}
  1815. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1816. // fmt.Println(dat)
  1817. // } else {
  1818. // fmt.Println(err)
  1819. // }
  1820. // userJSONBytes, _ := json.Marshal(dat)
  1821. // var res ResultOne
  1822. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1823. // utils.ErrorLog("解析失败:%v", err)
  1824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. // return
  1826. // }
  1827. // if res.Transreturncode == "00000000" {
  1828. // his := models.VMHisPatient{
  1829. // Name: name,
  1830. // Gender: gender,
  1831. // Birthday: birthUnix,
  1832. // MedicalTreatmentType: medical_care,
  1833. // IdType: certificates,
  1834. // IdCardNo: id_card,
  1835. // BalanceAccountsType: settlementValue,
  1836. // SocialType: social_type,
  1837. // MedicalInsuranceNumber: medical_insurance_card,
  1838. // RegisterType: register_type,
  1839. // RegisterCost: registration_fee,
  1840. // TreatmentCost: medical_expenses,
  1841. // Status: 1,
  1842. // Ctime: time.Now().Unix(),
  1843. // Mtime: time.Now().Unix(),
  1844. // Iinfo: resp_result,
  1845. // PatientId: patient.ID,
  1846. // RecordDate: theTime.Unix(),
  1847. // UserOrgId: adminInfo.CurrentOrgId,
  1848. // AdminUserId: admin_user_id,
  1849. // IsReturn: 1,
  1850. // IdCardType: id_card_type,
  1851. // Doctor: doctor,
  1852. // Departments: department,
  1853. // YiliaoNumber: yiliao_number,
  1854. // MzNumber: number,
  1855. // Number: mz_number,
  1856. // }
  1857. // service.CreateHisPatientTwo(&his)
  1858. // c.ServeSuccessJSON(map[string]interface{}{
  1859. // "msg": "挂号成功",
  1860. // })
  1861. // } else {
  1862. // c.ServeSuccessJSON(map[string]interface{}{
  1863. // "failed_code": -10,
  1864. // "msg": res.Transreturnmessage,
  1865. // })
  1866. // return
  1867. // }
  1868. //
  1869. // } else {
  1870. // //异地就医流程
  1871. // //异地走鉴权流程
  1872. // //authResult := CardAuth(number)
  1873. // //fmt.Println(authResult)
  1874. //
  1875. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1876. // //if tempPatient.ID == patient_id {
  1877. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1878. // var dat map[string]interface{}
  1879. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1880. // fmt.Println(dat)
  1881. // } else {
  1882. // fmt.Println(err)
  1883. // }
  1884. //
  1885. // userJSONBytes, _ := json.Marshal(dat)
  1886. //
  1887. // var res ResultOne
  1888. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1889. // utils.ErrorLog("解析失败:%v", err)
  1890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1891. // return
  1892. // }
  1893. // if res.Transreturncode == "00000000" {
  1894. // his := models.VMHisPatient{
  1895. // Name: name,
  1896. // Gender: gender,
  1897. // Birthday: birthUnix,
  1898. // MedicalTreatmentType: medical_care,
  1899. // IdType: certificates,
  1900. // IdCardNo: id_card,
  1901. // BalanceAccountsType: settlementValue,
  1902. // SocialType: social_type,
  1903. // MedicalInsuranceNumber: medical_insurance_card,
  1904. // RegisterType: register_type,
  1905. // RegisterCost: registration_fee,
  1906. // TreatmentCost: medical_expenses,
  1907. // Status: 1,
  1908. // Ctime: time.Now().Unix(),
  1909. // Mtime: time.Now().Unix(),
  1910. // Iinfo: resp_result,
  1911. // PatientId: patient.ID,
  1912. // RecordDate: theTime.Unix(),
  1913. // UserOrgId: adminInfo.CurrentOrgId,
  1914. // AdminUserId: admin_user_id,
  1915. // IsReturn: 1,
  1916. // IdCardType: id_card_type,
  1917. // Doctor: doctor,
  1918. // Departments: department,
  1919. // YiliaoNumber: yiliao_number,
  1920. // MzNumber: number,
  1921. // Number: mz_number,
  1922. // }
  1923. // service.CreateHisPatientTwo(&his)
  1924. // c.ServeSuccessJSON(map[string]interface{}{
  1925. // "msg": "挂号成功",
  1926. // })
  1927. // } else {
  1928. // c.ServeSuccessJSON(map[string]interface{}{
  1929. // "failed_code": -10,
  1930. // "msg": res.Transreturnmessage,
  1931. // })
  1932. // return
  1933. // }
  1934. //
  1935. // }
  1936. //
  1937. // } else { //异地卡流程
  1938. // //readCardBasResult := ReadCardBasHSM(number)
  1939. // //fmt.Println(readCardBasResult)
  1940. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1941. // if is_yidi == 1 { //1本地就医
  1942. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1943. // var dat map[string]interface{}
  1944. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1945. // fmt.Println(dat)
  1946. // } else {
  1947. // fmt.Println(err)
  1948. // }
  1949. //
  1950. // userJSONBytes, _ := json.Marshal(dat)
  1951. //
  1952. // var res ResultOne
  1953. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1954. // utils.ErrorLog("解析失败:%v", err)
  1955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1956. // return
  1957. // }
  1958. // if res.Transreturncode == "00000000" {
  1959. // his := models.VMHisPatient{
  1960. // Name: name,
  1961. // Gender: gender,
  1962. // Birthday: birthUnix,
  1963. // MedicalTreatmentType: medical_care,
  1964. // IdType: certificates,
  1965. // IdCardNo: id_card,
  1966. // BalanceAccountsType: settlementValue,
  1967. // SocialType: social_type,
  1968. // MedicalInsuranceNumber: medical_insurance_card,
  1969. // RegisterType: register_type,
  1970. // RegisterCost: registration_fee,
  1971. // TreatmentCost: medical_expenses,
  1972. // Status: 1,
  1973. // Ctime: time.Now().Unix(),
  1974. // Mtime: time.Now().Unix(),
  1975. // Iinfo: resp_result,
  1976. // PatientId: patient.ID,
  1977. // RecordDate: theTime.Unix(),
  1978. // UserOrgId: adminInfo.CurrentOrgId,
  1979. // AdminUserId: admin_user_id,
  1980. // IsReturn: 1,
  1981. // IdCardType: id_card_type,
  1982. // Doctor: doctor,
  1983. // Departments: department,
  1984. // YiliaoNumber: yiliao_number,
  1985. // MzNumber: number,
  1986. // Number: mz_number,
  1987. // }
  1988. // service.CreateHisPatientTwo(&his)
  1989. // c.ServeSuccessJSON(map[string]interface{}{
  1990. // "msg": "挂号成功",
  1991. // })
  1992. // } else {
  1993. // c.ServeSuccessJSON(map[string]interface{}{
  1994. // "failed_code": -10,
  1995. // "msg": res.Transreturnmessage,
  1996. // })
  1997. // return
  1998. // }
  1999. //
  2000. // } else { //异地就医需要走鉴权流程
  2001. // //authResult := CardAuth(number)
  2002. // //fmt.Println(authResult)
  2003. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  2004. // var dat map[string]interface{}
  2005. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  2006. // fmt.Println(dat)
  2007. // } else {
  2008. // fmt.Println(err)
  2009. // }
  2010. //
  2011. // userJSONBytes, _ := json.Marshal(dat)
  2012. //
  2013. // var res ResultOne
  2014. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2015. // utils.ErrorLog("解析失败:%v", err)
  2016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2017. // return
  2018. // }
  2019. // if res.Transreturncode == "00000000" {
  2020. // his := models.VMHisPatient{
  2021. // Name: name,
  2022. // Gender: gender,
  2023. // Birthday: birthUnix,
  2024. // MedicalTreatmentType: medical_care,
  2025. // IdType: certificates,
  2026. // IdCardNo: id_card,
  2027. // BalanceAccountsType: settlementValue,
  2028. // SocialType: social_type,
  2029. // MedicalInsuranceNumber: medical_insurance_card,
  2030. // RegisterType: register_type,
  2031. // RegisterCost: registration_fee,
  2032. // TreatmentCost: medical_expenses,
  2033. // Status: 1,
  2034. // Ctime: time.Now().Unix(),
  2035. // Mtime: time.Now().Unix(),
  2036. // Iinfo: resp_result,
  2037. // PatientId: patient.ID,
  2038. // RecordDate: theTime.Unix(),
  2039. // UserOrgId: adminInfo.CurrentOrgId,
  2040. // AdminUserId: admin_user_id,
  2041. // IsReturn: 1,
  2042. // IdCardType: id_card_type,
  2043. // Doctor: doctor,
  2044. // Departments: department,
  2045. // YiliaoNumber: yiliao_number,
  2046. // MzNumber: number,
  2047. // Number: mz_number,
  2048. // }
  2049. // service.CreateHisPatientTwo(&his)
  2050. // c.ServeSuccessJSON(map[string]interface{}{
  2051. // "msg": "挂号成功",
  2052. // })
  2053. // } else {
  2054. // c.ServeSuccessJSON(map[string]interface{}{
  2055. // "failed_code": -10,
  2056. // "msg": res.Transreturnmessage,
  2057. // })
  2058. // return
  2059. // }
  2060. //
  2061. // }
  2062. // }
  2063. // } else {
  2064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2065. // return
  2066. // }
  2067. // } else {
  2068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2069. // return
  2070. // }
  2071. //}
  2072. //上传明细----结算----确认订单
  2073. func (c *SZHisApiController) GetSettleInfo() {
  2074. pay_way, _ := c.GetInt64("pay_way")
  2075. pay_price, _ := c.GetFloat("pay_price")
  2076. pay_card_no := c.GetString("pay_card_no")
  2077. discount_price, _ := c.GetFloat("discount_price")
  2078. preferential_price, _ := c.GetFloat("preferential_price")
  2079. reality_price, _ := c.GetFloat("reality_price")
  2080. found_price, _ := c.GetFloat("found_price")
  2081. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2082. private_price, _ := c.GetFloat("private_price")
  2083. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2084. patient_id, _ := c.GetInt64("id")
  2085. record_time := c.GetString("record_time")
  2086. admin_user_id, _ := c.GetInt64("admin_user_id")
  2087. his_patient_id, _ := c.GetInt64("his_patient_id")
  2088. timestamp := time.Now().Unix()
  2089. tempTime := time.Unix(timestamp, 0)
  2090. timeFormat := tempTime.Format("20060102150405")
  2091. chrgBchno := rand.Intn(10000) + 1000
  2092. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  2093. adminUser := c.GetAdminUserInfo()
  2094. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2095. month := time.Unix(1557042972, 0).Format("1")
  2096. year := time.Now().Format("2006")
  2097. month = time.Now().Format("01")
  2098. day := time.Now().Format("02")
  2099. timeLayout := "2006-01-02"
  2100. loc, _ := time.LoadLocation("Local")
  2101. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2102. fmt.Println(err)
  2103. if err != nil {
  2104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2105. return
  2106. }
  2107. recordDateTime := theTime.Unix()
  2108. var prescriptions []*models.HisPrescription
  2109. var start_time int64
  2110. var end_time int64
  2111. if settle_accounts_type == 1 { //日结
  2112. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2113. } else { //月结
  2114. start_time_str := c.GetString("start_time")
  2115. end_time_str := c.GetString("end_time")
  2116. timeLayout := "2006-01-02"
  2117. loc, _ := time.LoadLocation("Local")
  2118. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2119. if err != nil {
  2120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2121. return
  2122. }
  2123. recordStartTime := theStartTime.Unix()
  2124. start_time = recordStartTime
  2125. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2126. if err != nil {
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2128. return
  2129. }
  2130. recordEndTime := theEndTime.Unix()
  2131. end_time = recordEndTime
  2132. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2133. }
  2134. var ids []int64
  2135. for _, item := range prescriptions {
  2136. ids = append(ids, item.ID)
  2137. }
  2138. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2139. sick, _ := service.FindSickById(patientPrescription.SickType)
  2140. if sick.ID == 0 {
  2141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamSickTypeWrong)
  2142. return
  2143. }
  2144. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2145. adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2146. his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2147. mz_number := his.Number
  2148. number := miConfig.Code + year + month + day +
  2149. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2150. var doctor_name string
  2151. var doctor_code string
  2152. var drug_doctor_code string
  2153. drug_doctor_code = adminRole_two.DoctorCode
  2154. drug_doctor_name := adminRole_two.UserName
  2155. if adminRole.ID == 0 {
  2156. doctor_name = "管理员"
  2157. doctor_code = "01"
  2158. } else {
  2159. doctor_name = adminRole.UserName
  2160. doctor_code = strconv.FormatInt(admin_user_id, 10)
  2161. }
  2162. verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2163. //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2164. //version_code := "V0.3"
  2165. var customs []*models.CustomDetail
  2166. for _, item := range prescriptions {
  2167. if item.Type == 1 { //药品
  2168. for _, subItem := range item.HisDoctorAdviceInfo {
  2169. fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2170. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2171. _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2172. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2173. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2174. temp := strings.Split(subItem.FeedetlSn, "-")
  2175. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2176. cus := &models.CustomDetail{
  2177. PrescriptionNumber: chrg_bchno,
  2178. OrderType: "1",
  2179. ChargeSerialNumber: newFl,
  2180. Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2181. CodeName: subItem.BaseDrugLib.DrugName,
  2182. Flag: "1",
  2183. Price: price,
  2184. Count: subItem.PrescribingNumber,
  2185. ChargeOrderDate: year + month + day,
  2186. DoctorCode: doctor_code,
  2187. Total: detItemFeeSumamt,
  2188. DoseCode: dose_code,
  2189. Spec: subItem.BaseDrugLib.DrugSpec,
  2190. }
  2191. customs = append(customs, cus)
  2192. }
  2193. }
  2194. }
  2195. if item.Type == 2 { //项目
  2196. for _, subItem := range item.HisPrescriptionProject {
  2197. if len(subItem.HisProject.MedicalCode) > 0 {
  2198. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2199. //count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2200. count, _ := strconv.ParseFloat(strconv.FormatInt(subItem.Count, 10), 64)
  2201. temp := strings.Split(subItem.FeedetlSn, "-")
  2202. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2203. cus := &models.CustomDetail{
  2204. PrescriptionNumber: chrg_bchno,
  2205. OrderType: "1",
  2206. ChargeSerialNumber: newFl,
  2207. Code: subItem.HisProject.MedicalCode,
  2208. CodeName: subItem.HisProject.ProjectName,
  2209. Flag: "1",
  2210. Price: subItem.Price,
  2211. Count: count,
  2212. ChargeOrderDate: year + month + day,
  2213. DoctorCode: doctor_code,
  2214. Total: detItemFeeSumamt,
  2215. DoseCode: "",
  2216. Spec: "次",
  2217. }
  2218. customs = append(customs, cus)
  2219. }
  2220. }
  2221. }
  2222. //
  2223. //for _, subItem := range item.HisAdditionalCharge {
  2224. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2225. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2226. //
  2227. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2228. // cus := &models.CustomDetail{
  2229. // PrescriptionNumber: chrg_bchno,
  2230. // OrderType: "1",
  2231. // ChargeSerialNumber: subItem.FeedetlSn,
  2232. // Code: subItem.XtHisAddtionConfig.Code,
  2233. // CodeName: subItem.XtHisAddtionConfig.Name,
  2234. // Flag: "1",
  2235. // Price: subItem.Price,
  2236. // Count: count,
  2237. // ChargeOrderDate: year + month + day,
  2238. // DoctorCode: doctor_code,
  2239. // Total: detItemFeeSumamt,
  2240. // DoseCode: "",
  2241. // Spec: subItem.XtHisAddtionConfig.,
  2242. // }
  2243. // customs = append(customs, cus)
  2244. // }
  2245. //}
  2246. }
  2247. var pagesize int = 50
  2248. var start int = 1
  2249. var stop int
  2250. var pagecount int
  2251. var curpage int
  2252. var isSuccess bool = true
  2253. //总页数,向上取整,注意除之前要先转换类型为float64
  2254. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2255. var ress []*Result
  2256. for curpage = 1; curpage <= pagecount; curpage++ {
  2257. if curpage == 1 {
  2258. start = 1
  2259. } else {
  2260. start = (curpage-1)*pagesize + 1
  2261. }
  2262. stop = curpage * pagesize
  2263. if stop > len(customs) {
  2264. stop = len(customs)
  2265. }
  2266. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2267. fmt.Println(result)
  2268. var dat map[string]interface{}
  2269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2270. fmt.Println(dat)
  2271. } else {
  2272. fmt.Println(err)
  2273. }
  2274. userJSONBytes, _ := json.Marshal(dat)
  2275. var res Result
  2276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2277. utils.ErrorLog("解析失败:%v", err)
  2278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2279. return
  2280. }
  2281. if res.Transreturncode == "00000000" {
  2282. ress = append(ress, &res)
  2283. } else {
  2284. isSuccess = false
  2285. errlog := &models.HisOrderError{
  2286. UserOrgId: adminUser.CurrentOrgId,
  2287. Ctime: time.Now().Unix(),
  2288. Mtime: time.Now().Unix(),
  2289. Number: chrg_bchno,
  2290. ErrMsg: res.Transreturnmessage,
  2291. Status: 1,
  2292. PatientId: patient_id,
  2293. RecordTime: recordDateTime,
  2294. Stage: 4,
  2295. }
  2296. service.CreateErrMsgLog(errlog)
  2297. c.ServeSuccessJSON(map[string]interface{}{
  2298. "failed_code": -10,
  2299. "msg": res.Transreturnmessage,
  2300. })
  2301. return
  2302. }
  2303. //设置变量,根据变量的值来判断上传是否成功
  2304. }
  2305. if isSuccess == true {
  2306. order := &models.HisOrder{
  2307. UserOrgId: adminUser.CurrentOrgId,
  2308. HisPatientId: 0,
  2309. PatientId: patient_id,
  2310. SettleAccountsDate: recordDateTime,
  2311. Ctime: time.Now().Unix(),
  2312. Mtime: time.Now().Unix(),
  2313. Status: 0,
  2314. Number: chrg_bchno,
  2315. Infcode: 0,
  2316. WarnMsg: "",
  2317. Cainfo: "",
  2318. ErrMsg: "",
  2319. RespondTime: "",
  2320. InfRefmsgid: "",
  2321. OrderStatus: 1,
  2322. IsMedicineInsurance: 1,
  2323. SettleType: settle_accounts_type,
  2324. SettleStartTime: start_time,
  2325. SettleEndTime: end_time,
  2326. Creator: admin_user_id,
  2327. Modify: admin_user_id,
  2328. OrgSetlNumber: number,
  2329. MdtrtId: mz_number,
  2330. }
  2331. data, _ := json.Marshal(ress)
  2332. order.DetailLog = string(data)
  2333. err = service.CreateOrder(order)
  2334. if err != nil {
  2335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2336. return
  2337. }
  2338. for _, subItem := range ress {
  2339. for _, item := range subItem.Transbody.Outputlist {
  2340. temp := strings.Split(item.Bkf500, "-")
  2341. var advice_id int64 = 0
  2342. var project_id int64 = 0
  2343. var types int64 = 0
  2344. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2345. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2346. if temp[1] == "1" {
  2347. advice_id = id
  2348. project_id = 0
  2349. } else if temp[1] == "2" {
  2350. advice_id = 0
  2351. project_id = id
  2352. }
  2353. info := &models.HisOrderInfo{
  2354. OrderNumber: order.Number,
  2355. FeedetlSn: item.Bkf500,
  2356. UploadDate: time.Now().Unix(),
  2357. AdviceId: advice_id,
  2358. DetItemFeeSumamt: item.Akc264,
  2359. Cnt: item.Akc226,
  2360. Pric: float64(item.Akc225),
  2361. PatientId: patient_id,
  2362. Status: 1,
  2363. ChrgitmLv: item.Aka065,
  2364. Mtime: time.Now().Unix(),
  2365. Ctime: time.Now().Unix(),
  2366. UserOrgId: adminUser.CurrentOrgId,
  2367. OrderId: order.ID,
  2368. ProjectId: project_id,
  2369. Type: types,
  2370. OverPricPsnPay: item.Akc268,
  2371. AllowReimburse: item.Cka319,
  2372. }
  2373. service.CreateOrderInfo(info)
  2374. }
  2375. }
  2376. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2377. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2378. var total float64
  2379. for _, item := range prescriptions {
  2380. if item.Type == 1 { //药品
  2381. for _, subItem := range item.HisDoctorAdviceInfo {
  2382. total = total + (subItem.Price * subItem.PrescribingNumber)
  2383. }
  2384. }
  2385. if item.Type == 2 { //项目
  2386. for _, subItem := range item.HisPrescriptionProject {
  2387. total = total + (subItem.Price * float64(subItem.Count))
  2388. }
  2389. }
  2390. }
  2391. for _, item := range prescriptions {
  2392. for _, subItem := range item.HisAdditionalCharge {
  2393. total = total + (subItem.Price * float64(subItem.Count))
  2394. }
  2395. }
  2396. total, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
  2397. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2398. if ret4 == 0 {
  2399. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2400. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2401. if tempPatient.ID == patient_id {
  2402. result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType, sick.CountryCode)
  2403. var dat map[string]interface{}
  2404. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2405. fmt.Println(dat)
  2406. } else {
  2407. fmt.Println(err)
  2408. }
  2409. userJSONBytes, _ := json.Marshal(dat)
  2410. var res ResultTwo
  2411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2412. utils.ErrorLog("解析失败:%v", err)
  2413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2414. return
  2415. }
  2416. if res.Transreturncode == "00000000" {
  2417. order.OrderStatus = 2
  2418. order.Status = 1
  2419. order.PayWay = pay_way
  2420. order.PayPrice = pay_price
  2421. order.PayCardNo = pay_card_no
  2422. order.PsnNo = health_card_no
  2423. order.DiscountPrice = discount_price
  2424. order.PreferentialPrice = preferential_price
  2425. order.RealityPrice = reality_price
  2426. order.FoundPrice = found_price
  2427. order.MedicalInsurancePrice = medical_insurance_price
  2428. order.PrivatePrice = private_price
  2429. order.Modify = admin_user_id
  2430. order.MedfeeSumamt = res.Transbody.Akc264
  2431. order.SetlId = res.Transbody.Ckc618
  2432. order.FundPaySumamt = res.Transbody.Akb068
  2433. order.AcctPay = res.Transbody.Akb066
  2434. order.PsnCashPay = res.Transbody.Akb067
  2435. order.PsnPartAmt = res.Transbody.Akb067
  2436. order.AccountPrice = res.Transbody.Aae240
  2437. order.MzNumber = mz_number
  2438. order.YiliaoNumber = yiliao_number
  2439. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2440. detailStrOne := string(setlDetailOne)
  2441. order.SzChargeInfo = detailStrOne
  2442. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2443. detailStrTwo := string(setlDetailTwo)
  2444. order.SzProjectInfo = detailStrTwo
  2445. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2446. detailStrThree := string(setlDetailThree)
  2447. order.SzMedicineInsuranceInfo = detailStrThree
  2448. order.Cainfo = result_three
  2449. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2450. err = service.UpDateOrderTwo(order)
  2451. c.ServeSuccessJSON(map[string]interface{}{
  2452. "msg": "结算成功",
  2453. })
  2454. } else {
  2455. //结算报错
  2456. errlog := &models.HisOrderError{
  2457. UserOrgId: adminUser.CurrentOrgId,
  2458. Ctime: time.Now().Unix(),
  2459. Mtime: time.Now().Unix(),
  2460. Number: chrg_bchno,
  2461. ErrMsg: res.Transreturnmessage,
  2462. Status: 1,
  2463. PatientId: patient_id,
  2464. RecordTime: recordDateTime,
  2465. Stage: 6,
  2466. }
  2467. service.CreateErrMsgLog(errlog)
  2468. c.ServeSuccessJSON(map[string]interface{}{
  2469. "failed_code": -10,
  2470. "msg": res.Transreturnmessage,
  2471. })
  2472. }
  2473. } else {
  2474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2475. return
  2476. }
  2477. } else {
  2478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2479. return
  2480. }
  2481. } else {
  2482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2483. return
  2484. }
  2485. }
  2486. //func (c *SZHisApiController) GetSettleInfo() {
  2487. // pay_way, _ := c.GetInt64("pay_way")
  2488. // pay_price, _ := c.GetFloat("pay_price")
  2489. // pay_card_no := c.GetString("pay_card_no")
  2490. // discount_price, _ := c.GetFloat("discount_price")
  2491. // preferential_price, _ := c.GetFloat("preferential_price")
  2492. // reality_price, _ := c.GetFloat("reality_price")
  2493. // found_price, _ := c.GetFloat("found_price")
  2494. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2495. // private_price, _ := c.GetFloat("private_price")
  2496. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2497. // patient_id, _ := c.GetInt64("id")
  2498. // record_time := c.GetString("record_time")
  2499. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2500. // timestamp := time.Now().Unix()
  2501. // tempTime := time.Unix(timestamp, 0)
  2502. // timeFormat := tempTime.Format("20060102150405")
  2503. // chrgBchno := rand.Intn(10000) + 1000
  2504. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  2505. // adminUser := c.GetAdminUserInfo()
  2506. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2507. // month := time.Unix(1557042972, 0).Format("1")
  2508. // year := time.Now().Format("2006")
  2509. // month = time.Now().Format("01")
  2510. // day := time.Now().Format("02")
  2511. //
  2512. // timeLayout := "2006-01-02"
  2513. // loc, _ := time.LoadLocation("Local")
  2514. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2515. // fmt.Println(err)
  2516. // if err != nil {
  2517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2518. // return
  2519. // }
  2520. // recordDateTime := theTime.Unix()
  2521. //
  2522. // var prescriptions []*models.HisPrescription
  2523. //
  2524. // var start_time int64
  2525. // var end_time int64
  2526. //
  2527. // if settle_accounts_type == 1 { //日结
  2528. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2529. //
  2530. // } else { //月结
  2531. // start_time_str := c.GetString("start_time")
  2532. // end_time_str := c.GetString("end_time")
  2533. // timeLayout := "2006-01-02"
  2534. // loc, _ := time.LoadLocation("Local")
  2535. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2536. // if err != nil {
  2537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2538. // return
  2539. // }
  2540. // recordStartTime := theStartTime.Unix()
  2541. // start_time = recordStartTime
  2542. //
  2543. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2544. // if err != nil {
  2545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2546. // return
  2547. // }
  2548. // recordEndTime := theEndTime.Unix()
  2549. // end_time = recordEndTime
  2550. //
  2551. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2552. // }
  2553. //
  2554. // var ids []int64
  2555. // for _, item := range prescriptions {
  2556. // ids = append(ids, item.ID)
  2557. // }
  2558. //
  2559. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2560. //
  2561. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2562. //
  2563. // adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2564. // his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2565. // mz_number := his.Number
  2566. // number := miConfig.Code + year + month + day +
  2567. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2568. // var doctor_name string
  2569. // var doctor_code string
  2570. // var drug_doctor_code string
  2571. // drug_doctor_code = adminRole_two.DoctorCode
  2572. // drug_doctor_name := adminRole_two.UserName
  2573. //
  2574. // if adminRole.ID == 0 {
  2575. // doctor_name = "黄亦轩"
  2576. // doctor_code = "1"
  2577. // } else {
  2578. // doctor_name = adminRole.UserName
  2579. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  2580. // }
  2581. //
  2582. // verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2583. // //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2584. // //version_code := "V0.3"
  2585. // var customs []*models.CustomDetail
  2586. // for _, item := range prescriptions {
  2587. // if item.Type == 1 { //药品
  2588. // for _, subItem := range item.HisDoctorAdviceInfo {
  2589. // fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2590. //
  2591. // if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2592. // _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2593. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2594. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2595. // temp := strings.Split(subItem.FeedetlSn, "-")
  2596. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2597. //
  2598. // cus := &models.CustomDetail{
  2599. // PrescriptionNumber: chrg_bchno,
  2600. // OrderType: "1",
  2601. // ChargeSerialNumber: newFl,
  2602. // Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2603. // CodeName: subItem.BaseDrugLib.DrugName,
  2604. // Flag: "1",
  2605. // Price: price,
  2606. // Count: subItem.PrescribingNumber,
  2607. // ChargeOrderDate: year + month + day,
  2608. // DoctorCode: doctor_code,
  2609. // Total: detItemFeeSumamt,
  2610. // DoseCode: dose_code,
  2611. // Spec: subItem.BaseDrugLib.DrugSpec,
  2612. // }
  2613. // customs = append(customs, cus)
  2614. // }
  2615. // }
  2616. // }
  2617. //
  2618. // if item.Type == 2 { //项目
  2619. // for _, subItem := range item.HisPrescriptionProject {
  2620. // if len(subItem.HisProject.MedicalCode) > 0 {
  2621. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2622. //
  2623. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2624. // temp := strings.Split(subItem.FeedetlSn, "-")
  2625. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2626. //
  2627. // cus := &models.CustomDetail{
  2628. // PrescriptionNumber: chrg_bchno,
  2629. // OrderType: "1",
  2630. // ChargeSerialNumber: newFl,
  2631. // Code: subItem.HisProject.MedicalCode,
  2632. // CodeName: subItem.HisProject.ProjectName,
  2633. // Flag: "1",
  2634. // Price: subItem.Price,
  2635. // Count: count,
  2636. // ChargeOrderDate: year + month + day,
  2637. // DoctorCode: doctor_code,
  2638. // Total: detItemFeeSumamt,
  2639. // DoseCode: "",
  2640. // Spec: "次",
  2641. // }
  2642. // customs = append(customs, cus)
  2643. // }
  2644. // }
  2645. // }
  2646. // //
  2647. // //for _, subItem := range item.HisAdditionalCharge {
  2648. // // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2649. // // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2650. // //
  2651. // // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2652. // // cus := &models.CustomDetail{
  2653. // // PrescriptionNumber: chrg_bchno,
  2654. // // OrderType: "1",
  2655. // // ChargeSerialNumber: subItem.FeedetlSn,
  2656. // // Code: subItem.XtHisAddtionConfig.Code,
  2657. // // CodeName: subItem.XtHisAddtionConfig.Name,
  2658. // // Flag: "1",
  2659. // // Price: subItem.Price,
  2660. // // Count: count,
  2661. // // ChargeOrderDate: year + month + day,
  2662. // // DoctorCode: doctor_code,
  2663. // // Total: detItemFeeSumamt,
  2664. // // DoseCode: "",
  2665. // // Spec: subItem.XtHisAddtionConfig.,
  2666. // // }
  2667. // // customs = append(customs, cus)
  2668. // // }
  2669. // //}
  2670. // }
  2671. //
  2672. // var pagesize int = 50
  2673. // var start int = 1
  2674. // var stop int
  2675. // var pagecount int
  2676. // var curpage int
  2677. // var isSuccess bool = true
  2678. // //总页数,向上取整,注意除之前要先转换类型为float64
  2679. // pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2680. //
  2681. // var ress []*Result
  2682. // for curpage = 1; curpage <= pagecount; curpage++ {
  2683. // if curpage == 1 {
  2684. // start = 1
  2685. // } else {
  2686. // start = (curpage-1)*pagesize + 1
  2687. // }
  2688. // stop = curpage * pagesize
  2689. // if stop > len(customs) {
  2690. // stop = len(customs)
  2691. // }
  2692. // result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2693. // fmt.Println(result)
  2694. //
  2695. // var dat map[string]interface{}
  2696. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2697. // fmt.Println(dat)
  2698. // } else {
  2699. // fmt.Println(err)
  2700. // }
  2701. //
  2702. // userJSONBytes, _ := json.Marshal(dat)
  2703. //
  2704. // var res Result
  2705. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2706. // utils.ErrorLog("解析失败:%v", err)
  2707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2708. // return
  2709. // }
  2710. // if res.Transreturncode == "00000000" {
  2711. // ress = append(ress, &res)
  2712. // } else {
  2713. // isSuccess = false
  2714. // errlog := &models.HisOrderError{
  2715. // UserOrgId: adminUser.CurrentOrgId,
  2716. // Ctime: time.Now().Unix(),
  2717. // Mtime: time.Now().Unix(),
  2718. // Number: chrg_bchno,
  2719. // ErrMsg: res.Transreturnmessage,
  2720. // Status: 1,
  2721. // PatientId: patient_id,
  2722. // RecordTime: recordDateTime,
  2723. // Stage: 4,
  2724. // }
  2725. // service.CreateErrMsgLog(errlog)
  2726. // c.ServeSuccessJSON(map[string]interface{}{
  2727. // "failed_code": -10,
  2728. // "msg": res.Transreturnmessage,
  2729. // })
  2730. // return
  2731. // }
  2732. // //设置变量,根据变量的值来判断上传是否成功
  2733. // }
  2734. // if isSuccess == true {
  2735. // order := &models.HisOrder{
  2736. // UserOrgId: adminUser.CurrentOrgId,
  2737. // HisPatientId: 0,
  2738. // PatientId: patient_id,
  2739. // SettleAccountsDate: recordDateTime,
  2740. // Ctime: time.Now().Unix(),
  2741. // Mtime: time.Now().Unix(),
  2742. // Status: 1,
  2743. // Number: chrg_bchno,
  2744. // Infcode: 0,
  2745. // WarnMsg: "",
  2746. // Cainfo: "",
  2747. // ErrMsg: "",
  2748. // RespondTime: "",
  2749. // InfRefmsgid: "",
  2750. // OrderStatus: 1,
  2751. // IsMedicineInsurance: 1,
  2752. // SettleType: settle_accounts_type,
  2753. // SettleStartTime: start_time,
  2754. // SettleEndTime: end_time,
  2755. // Creator: admin_user_id,
  2756. // Modify: admin_user_id,
  2757. // OrgSetlNumber: number,
  2758. // }
  2759. // data, _ := json.Marshal(ress)
  2760. // order.DetailLog = string(data)
  2761. //
  2762. // err = service.CreateOrder(order)
  2763. // if err != nil {
  2764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2765. // return
  2766. // }
  2767. //
  2768. // for _, subItem := range ress {
  2769. // for _, item := range subItem.Transbody.Outputlist {
  2770. //
  2771. // temp := strings.Split(item.Bkf500, "-")
  2772. // var advice_id int64 = 0
  2773. // var project_id int64 = 0
  2774. // var types int64 = 0
  2775. //
  2776. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2777. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2778. //
  2779. // if temp[1] == "1" {
  2780. // advice_id = id
  2781. // project_id = 0
  2782. // } else if temp[1] == "2" {
  2783. // advice_id = 0
  2784. // project_id = id
  2785. // }
  2786. //
  2787. // info := &models.HisOrderInfo{
  2788. // OrderNumber: order.Number,
  2789. // FeedetlSn: item.Bkf500,
  2790. // UploadDate: time.Now().Unix(),
  2791. // AdviceId: advice_id,
  2792. // DetItemFeeSumamt: item.Akc264,
  2793. // Cnt: item.Akc226,
  2794. // Pric: float64(item.Akc225),
  2795. // PatientId: patient_id,
  2796. // Status: 1,
  2797. // ChrgitmLv: item.Aka065,
  2798. // Mtime: time.Now().Unix(),
  2799. // Ctime: time.Now().Unix(),
  2800. // UserOrgId: adminUser.CurrentOrgId,
  2801. // OrderId: order.ID,
  2802. // ProjectId: project_id,
  2803. // Type: types,
  2804. //
  2805. // OverPricPsnPay: item.Akc268,
  2806. // AllowReimburse: item.Cka319,
  2807. // }
  2808. // service.CreateOrderInfo(info)
  2809. //
  2810. // }
  2811. // }
  2812. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2813. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2814. // var total float64
  2815. // for _, item := range prescriptions {
  2816. // if item.Type == 1 { //药品
  2817. // for _, subItem := range item.HisDoctorAdviceInfo {
  2818. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2819. // }
  2820. // }
  2821. // if item.Type == 2 { //项目
  2822. // for _, subItem := range item.HisPrescriptionProject {
  2823. // total = total + (subItem.Price * float64(subItem.Count))
  2824. // }
  2825. // }
  2826. // }
  2827. // for _, item := range prescriptions {
  2828. // for _, subItem := range item.HisAdditionalCharge {
  2829. // total = total + (subItem.Price * float64(subItem.Count))
  2830. // }
  2831. // }
  2832. //
  2833. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2834. // if ret4 == 0 {
  2835. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2836. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2837. // if tempPatient.ID == patient_id {
  2838. //
  2839. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType)
  2840. // var dat map[string]interface{}
  2841. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2842. // fmt.Println(dat)
  2843. // } else {
  2844. // fmt.Println(err)
  2845. // }
  2846. // userJSONBytes, _ := json.Marshal(dat)
  2847. // var res ResultTwo
  2848. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2849. // utils.ErrorLog("解析失败:%v", err)
  2850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2851. // return
  2852. // }
  2853. //
  2854. // if res.Transreturncode == "00000000" {
  2855. // order.OrderStatus = 2
  2856. // order.PayWay = pay_way
  2857. // order.PayPrice = pay_price
  2858. // order.PayCardNo = pay_card_no
  2859. // order.DiscountPrice = discount_price
  2860. // order.PreferentialPrice = preferential_price
  2861. // order.RealityPrice = reality_price
  2862. // order.FoundPrice = found_price
  2863. // order.MedicalInsurancePrice = medical_insurance_price
  2864. // order.PrivatePrice = private_price
  2865. // order.Modify = admin_user_id
  2866. // order.MedfeeSumamt = res.Transbody.Akc264
  2867. // order.SetlId = res.Transbody.Ckc618
  2868. // order.FundPaySumamt = res.Transbody.Akb068
  2869. // order.AcctPay = res.Transbody.Akb066
  2870. // order.PsnCashPay = res.Transbody.Akb067
  2871. // order.PsnPartAmt = res.Transbody.Akb067
  2872. // order.AccountPrice = res.Transbody.Aae240
  2873. // order.MzNumber = mz_number
  2874. // order.YiliaoNumber = yiliao_number
  2875. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2876. // detailStrOne := string(setlDetailOne)
  2877. // order.SzChargeInfo = detailStrOne
  2878. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2879. // detailStrTwo := string(setlDetailTwo)
  2880. // order.SzProjectInfo = detailStrTwo
  2881. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2882. // detailStrThree := string(setlDetailThree)
  2883. // order.SzMedicineInsuranceInfo = detailStrThree
  2884. // order.Cainfo = result_three
  2885. // err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2886. // err = service.UpDateOrderTwo(order)
  2887. // c.ServeSuccessJSON(map[string]interface{}{
  2888. // "msg": "结算成功",
  2889. // })
  2890. // } else {
  2891. // //结算报错
  2892. // errlog := &models.HisOrderError{
  2893. // UserOrgId: adminUser.CurrentOrgId,
  2894. // Ctime: time.Now().Unix(),
  2895. // Mtime: time.Now().Unix(),
  2896. // Number: chrg_bchno,
  2897. // ErrMsg: res.Transreturnmessage,
  2898. // Status: 1,
  2899. // PatientId: patient_id,
  2900. // RecordTime: recordDateTime,
  2901. // Stage: 6,
  2902. // }
  2903. // service.CreateErrMsgLog(errlog)
  2904. // c.ServeSuccessJSON(map[string]interface{}{
  2905. // "failed_code": -10,
  2906. // "msg": res.Transreturnmessage,
  2907. // })
  2908. // }
  2909. // } else {
  2910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2911. // return
  2912. // }
  2913. // } else {
  2914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2915. // return
  2916. // }
  2917. // } else {
  2918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2919. // return
  2920. // }
  2921. //}
  2922. //结算
  2923. //func (c *SZHisApiController) GetSettleInfo() {
  2924. // patient_id, _ := c.GetInt64("id")
  2925. // order_id, _ := c.GetInt64("order_id")
  2926. // record_time := c.GetString("record_time")
  2927. // pay_way, _ := c.GetInt64("pay_way")
  2928. // pay_price, _ := c.GetFloat("pay_price")
  2929. // pay_card_no := c.GetString("pay_card_no")
  2930. // discount_price, _ := c.GetFloat("discount_price")
  2931. // preferential_price, _ := c.GetFloat("preferential_price")
  2932. // reality_price, _ := c.GetFloat("reality_price")
  2933. // found_price, _ := c.GetFloat("found_price")
  2934. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2935. // private_price, _ := c.GetFloat("private_price")
  2936. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2937. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2938. //
  2939. // timeLayout := "2006-01-02"
  2940. // loc, _ := time.LoadLocation("Local")
  2941. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2942. // if err != nil {
  2943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2944. // return
  2945. // }
  2946. // recordDateTime := theTime.Unix()
  2947. // adminUser := c.GetAdminUserInfo()
  2948. //
  2949. // var prescriptions []*models.HisPrescription
  2950. //
  2951. // data := make(map[string]interface{})
  2952. // if settle_accounts_type == 1 { //日结
  2953. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2954. // data["pre"] = prescriptions
  2955. //
  2956. // } else { //月结
  2957. // start_time_str := c.GetString("start_time")
  2958. // end_time_str := c.GetString("end_time")
  2959. // timeLayout := "2006-01-02"
  2960. // loc, _ := time.LoadLocation("Local")
  2961. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2962. // if err != nil {
  2963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2964. // return
  2965. // }
  2966. // recordStartTime := theStartTime.Unix()
  2967. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2968. // if err != nil {
  2969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2970. // return
  2971. // }
  2972. // recordEndTime := theEndTime.Unix()
  2973. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2974. // data["pre"] = prescriptions
  2975. //
  2976. // }
  2977. //
  2978. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2979. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2980. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2981. // strconv.FormatInt(his.PatientId, 10)
  2982. //
  2983. // order_src, _ := service.GetHisOrderByID(order_id)
  2984. //
  2985. // if order_src.ID == 0 {
  2986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2987. // return
  2988. // }
  2989. //
  2990. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2991. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2992. // if order_src.OrderStatus != 2 {
  2993. // var total float64
  2994. // for _, item := range prescriptions {
  2995. // if item.Type == 1 { //药品
  2996. // for _, subItem := range item.HisDoctorAdviceInfo {
  2997. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2998. // }
  2999. // }
  3000. // if item.Type == 2 { //项目
  3001. // for _, subItem := range item.HisPrescriptionProject {
  3002. // total = total + (subItem.Price * float64(subItem.Count))
  3003. // }
  3004. // }
  3005. // }
  3006. //
  3007. // for _, item := range prescriptions {
  3008. // for _, subItem := range item.HisAdditionalCharge {
  3009. // total = total + (subItem.Price * float64(subItem.Count))
  3010. // }
  3011. // }
  3012. //
  3013. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3014. //
  3015. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3016. //
  3017. // var drug_doctor string
  3018. // drug_doctor = adminRole_two.DoctorCode
  3019. // drug_doctor_name := adminRole_two.UserName
  3020. // //结算流程
  3021. // var doctor_name string
  3022. // var doctor_code string
  3023. // if roles.ID == 0 {
  3024. // doctor_name = "黄亦轩"
  3025. // doctor_code = "1010"
  3026. // } else {
  3027. // doctor_name = roles.UserName
  3028. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  3029. // }
  3030. // number := order_src.OrgSetlNumber
  3031. // mz_number := his.Number
  3032. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  3033. //
  3034. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  3035. // //version_code := "V0.3"
  3036. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  3037. // yiliao_number := his.YiliaoNumber
  3038. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  3039. // var dat map[string]interface{}
  3040. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  3041. // fmt.Println(dat)
  3042. // } else {
  3043. // fmt.Println(err)
  3044. // }
  3045. // userJSONBytes, _ := json.Marshal(dat)
  3046. // var res ResultTwo
  3047. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3048. // utils.ErrorLog("解析失败:%v", err)
  3049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3050. // return
  3051. // }
  3052. //
  3053. // if res.Transreturncode == "00000000" {
  3054. // order_src.OrderStatus = 2
  3055. // order_src.PayWay = pay_way
  3056. // order_src.PayPrice = pay_price
  3057. // order_src.PayCardNo = pay_card_no
  3058. // order_src.DiscountPrice = discount_price
  3059. // order_src.PreferentialPrice = preferential_price
  3060. // order_src.RealityPrice = reality_price
  3061. // order_src.FoundPrice = found_price
  3062. // order_src.MedicalInsurancePrice = medical_insurance_price
  3063. // order_src.PrivatePrice = private_price
  3064. // order_src.Creator = order_src.Creator
  3065. // order_src.Modify = roles.ID
  3066. // order_src.MedfeeSumamt = res.Transbody.Akc264
  3067. // order_src.SetlId = res.Transbody.Ckc618
  3068. // order_src.FundPaySumamt = res.Transbody.Akb068
  3069. // order_src.AcctPay = res.Transbody.Akb066
  3070. // order_src.PsnCashPay = res.Transbody.Akb067
  3071. // order_src.PsnPartAmt = res.Transbody.Akb067
  3072. // order_src.AccountPrice = res.Transbody.Aae240
  3073. // order_src.MzNumber = mz_number
  3074. // order_src.YiliaoNumber = yiliao_number
  3075. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  3076. // detailStrOne := string(setlDetailOne)
  3077. // order_src.SzChargeInfo = detailStrOne
  3078. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  3079. // detailStrTwo := string(setlDetailTwo)
  3080. // order_src.SzProjectInfo = detailStrTwo
  3081. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  3082. // detailStrThree := string(setlDetailThree)
  3083. // order_src.SzMedicineInsuranceInfo = detailStrThree
  3084. // order_src.Cainfo = result_three
  3085. //
  3086. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  3087. // err = service.UpDateOrder(order_src)
  3088. //
  3089. // c.ServeSuccessJSON(map[string]interface{}{
  3090. // "msg": "结算成功",
  3091. // })
  3092. // } else {
  3093. // //version_code := "0.03"
  3094. // c.ServeSuccessJSON(map[string]interface{}{
  3095. // "failed_code": -10,
  3096. // "msg": res.Transreturnmessage,
  3097. // })
  3098. //
  3099. // }
  3100. // } else {
  3101. //
  3102. // //错误提示
  3103. //
  3104. // }
  3105. // } else {
  3106. // //错误提示
  3107. //
  3108. // }
  3109. //}
  3110. //当月退费
  3111. func (c *SZHisApiController) Refund() {
  3112. order_id, _ := c.GetInt64("order_id")
  3113. record_time := c.GetString("record_time")
  3114. patient_id, _ := c.GetInt64("patient_id")
  3115. admin_user_id, _ := c.GetInt64("admin_user_id")
  3116. timeLayout := "2006-01-02"
  3117. loc, _ := time.LoadLocation("Local")
  3118. adminUser := c.GetAdminUserInfo()
  3119. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3120. fmt.Println(err)
  3121. if err != nil {
  3122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3123. return
  3124. }
  3125. recordDateTime := theTime.Unix()
  3126. fmt.Println(recordDateTime)
  3127. var order models.HisOrder
  3128. order, _ = service.GetHisOrderByID(order_id)
  3129. if order.ID == 0 {
  3130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3131. return
  3132. }
  3133. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  3134. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3136. //结算流程
  3137. var doctor_name string
  3138. var doctor_code string
  3139. if roles.ID == 0 {
  3140. doctor_name = "管理员"
  3141. doctor_code = "01"
  3142. } else {
  3143. doctor_name = roles.UserName
  3144. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3145. }
  3146. month := time.Unix(1557042972, 0).Format("1")
  3147. year := time.Now().Format("2006")
  3148. month = time.Now().Format("01")
  3149. day := time.Now().Format("02")
  3150. //number := miConfig.Code + year + month + day + "1367866"
  3151. number := miConfig.Code + year + month + day +
  3152. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  3153. //number := miConfig.Code + year + month + day + "1590003"
  3154. //流水号
  3155. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3156. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  3157. //version_code := "V0.3"
  3158. //
  3159. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  3160. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3161. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3162. var customs []*models.CustomDetail
  3163. for _, item := range order_infos {
  3164. cus := &models.CustomDetail{
  3165. PrescriptionNumber: item.OrderNumber,
  3166. ChargeSerialNumber: item.FeedetlSn,
  3167. }
  3168. customs = append(customs, cus)
  3169. }
  3170. if config.IsOpen == 1 { //对接了医保,走医保流程
  3171. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  3172. fmt.Println(result)
  3173. var dat map[string]interface{}
  3174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3175. fmt.Println(dat)
  3176. } else {
  3177. fmt.Println(err)
  3178. }
  3179. userJSONBytes, _ := json.Marshal(dat)
  3180. var res ResultThree
  3181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3182. utils.ErrorLog("解析失败:%v", err)
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. return
  3185. }
  3186. if res.Transreturncode == "00000000" {
  3187. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  3188. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  3189. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3190. c.ServeSuccessJSON(map[string]interface{}{
  3191. "msg": "退费成功",
  3192. })
  3193. } else {
  3194. c.ServeSuccessJSON(map[string]interface{}{
  3195. "failed_code": -10,
  3196. "msg": res.Transreturnmessage,
  3197. })
  3198. }
  3199. }
  3200. }
  3201. //跨月退费
  3202. func (c *SZHisApiController) MonthRefund() {
  3203. order_id, _ := c.GetInt64("order_id")
  3204. record_time := c.GetString("record_time")
  3205. patient_id, _ := c.GetInt64("patient_id")
  3206. admin_user_id, _ := c.GetInt64("admin_user_id")
  3207. timeLayout := "2006-01-02"
  3208. loc, _ := time.LoadLocation("Local")
  3209. adminUser := c.GetAdminUserInfo()
  3210. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3211. fmt.Println(err)
  3212. if err != nil {
  3213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3214. return
  3215. }
  3216. recordDateTime := theTime.Unix()
  3217. var order models.HisOrder
  3218. order, _ = service.GetHisOrderByID(order_id)
  3219. if order.ID == 0 {
  3220. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3221. }
  3222. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3223. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3224. //结算流程
  3225. var doctor_name string
  3226. var doctor_code string
  3227. if roles.ID == 0 {
  3228. doctor_name = "管理员"
  3229. doctor_code = "01"
  3230. } else {
  3231. doctor_name = roles.UserName
  3232. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3233. }
  3234. month := time.Unix(1557042972, 0).Format("1")
  3235. year := time.Now().Format("2006")
  3236. month = time.Now().Format("01")
  3237. day := time.Now().Format("02")
  3238. //流水号
  3239. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3240. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  3241. version_code := "0.03"
  3242. fmt.Println(number_two)
  3243. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  3244. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3245. if config.IsOpen == 1 { //对接了医保,走医保流程
  3246. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3247. fmt.Println(result)
  3248. var dat map[string]interface{}
  3249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3250. fmt.Println(dat)
  3251. } else {
  3252. fmt.Println(err)
  3253. }
  3254. userJSONBytes, _ := json.Marshal(dat)
  3255. var res ResultThree
  3256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3257. utils.ErrorLog("解析失败:%v", err)
  3258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3259. return
  3260. }
  3261. if res.Transreturncode == "00000000" {
  3262. c.ServeSuccessJSON(map[string]interface{}{
  3263. "msg": "退费成功",
  3264. })
  3265. } else {
  3266. }
  3267. }
  3268. }
  3269. //查询
  3270. func (c *SZHisApiController) GetSettleAccounts() {
  3271. order_id, _ := c.GetInt64("order_id")
  3272. record_time := c.GetString("record_time")
  3273. patient_id, _ := c.GetInt64("patient_id")
  3274. admin_user_id, _ := c.GetInt64("admin_user_id")
  3275. timeLayout := "2006-01-02"
  3276. loc, _ := time.LoadLocation("Local")
  3277. adminUser := c.GetAdminUserInfo()
  3278. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3279. fmt.Println(err)
  3280. if err != nil {
  3281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3282. return
  3283. }
  3284. recordDateTime := theTime.Unix()
  3285. fmt.Println(recordDateTime)
  3286. var order models.HisOrder
  3287. order, _ = service.GetHisOrderByID(order_id)
  3288. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  3289. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3290. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3291. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3292. yiliao_leibie := ""
  3293. switch his.MedicalTreatmentType {
  3294. case 11:
  3295. yiliao_leibie = "普通门诊"
  3296. break
  3297. case 12:
  3298. yiliao_leibie = "家庭通道"
  3299. break
  3300. case 13:
  3301. yiliao_leibie = "门诊大病"
  3302. break
  3303. case 14:
  3304. yiliao_leibie = "重疾特药"
  3305. break
  3306. case 15:
  3307. yiliao_leibie = "门诊慢病"
  3308. break
  3309. case 16:
  3310. yiliao_leibie = "门诊特检"
  3311. break
  3312. case 17:
  3313. yiliao_leibie = "健康体检"
  3314. break
  3315. case 18:
  3316. yiliao_leibie = "预防接种"
  3317. break
  3318. case 19:
  3319. yiliao_leibie = "门诊输血"
  3320. break
  3321. case 91:
  3322. yiliao_leibie = "新冠肺炎门诊"
  3323. break
  3324. }
  3325. //departments, _ := service.Get(patientPrescription.Departments)
  3326. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3327. if order.ID == 0 {
  3328. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3330. return
  3331. }
  3332. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3333. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3334. //结算流程
  3335. var doctor_name string
  3336. var doctor_code string
  3337. if roles.ID == 0 {
  3338. doctor_name = "管理员"
  3339. doctor_code = "01"
  3340. } else {
  3341. doctor_name = roles.UserName
  3342. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3343. }
  3344. //month := time.Unix(1557042972, 0).Format("1")
  3345. //year := time.Now().Format("2006")
  3346. //month = time.Now().Format("01")
  3347. //day := time.Now().Format("02")
  3348. //流水号
  3349. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3350. //fmt.Println(number_two)
  3351. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3352. //version_code := "V0.3"
  3353. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  3354. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3355. if config.IsOpen == 1 { //对接了医保,走医保流程
  3356. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3357. fmt.Println(result)
  3358. var dat map[string]interface{}
  3359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3360. fmt.Println(dat)
  3361. } else {
  3362. fmt.Println(err)
  3363. }
  3364. userJSONBytes, _ := json.Marshal(dat)
  3365. var res ResultFour
  3366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3367. utils.ErrorLog("解析失败:%v", err)
  3368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3369. return
  3370. }
  3371. if res.Transreturncode == "00000000" {
  3372. var dat2 map[string]interface{}
  3373. if err := json.Unmarshal([]byte(his.PatientInfo), &dat2); err == nil {
  3374. fmt.Println(dat2)
  3375. } else {
  3376. fmt.Println(err)
  3377. }
  3378. userJSONBytes2, _ := json.Marshal(dat2)
  3379. var res2 ResultMZ001
  3380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3381. utils.ErrorLog("解析失败:%v", err)
  3382. }
  3383. c.ServeSuccessJSON(map[string]interface{}{
  3384. "result": res,
  3385. "org_name": miConfig.OrgName,
  3386. "org_code": miConfig.Code,
  3387. "patient_name": patient.Name,
  3388. "doctor_code": adminRole_two.DoctorCode,
  3389. "doctor_name": doctor_name,
  3390. "health_card_no": order.PsnNo,
  3391. "health_card_no_two": res2.Transbody.Aaz500,
  3392. "order_number": order.Number,
  3393. "department": departments.Name,
  3394. "yiliao_leibie": yiliao_leibie,
  3395. "before_money": res2.Transbody.Aae240,
  3396. "after_money": order.AccountPrice,
  3397. })
  3398. } else {
  3399. c.ServeSuccessJSON(map[string]interface{}{
  3400. "failed_code": -10,
  3401. "msg": res.Transreturnmessage,
  3402. })
  3403. }
  3404. }
  3405. }
  3406. //费用录入取消
  3407. func (c *SZHisApiController) CancelOrderDetail() {
  3408. order_id, _ := c.GetInt64("order_id")
  3409. record_time := c.GetString("record_time")
  3410. patient_id, _ := c.GetInt64("patient_id")
  3411. admin_user_id, _ := c.GetInt64("admin_user_id")
  3412. timeLayout := "2006-01-02"
  3413. loc, _ := time.LoadLocation("Local")
  3414. adminUser := c.GetAdminUserInfo()
  3415. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3416. fmt.Println(err)
  3417. if err != nil {
  3418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3419. return
  3420. }
  3421. recordDateTime := theTime.Unix()
  3422. var order models.HisOrder
  3423. order, _ = service.GetHisOrderByID(order_id)
  3424. if order.ID == 0 {
  3425. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3426. }
  3427. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3428. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3430. //结算流程
  3431. var doctor_name string
  3432. var doctor_code string
  3433. if roles.ID == 0 {
  3434. doctor_name = "管理员"
  3435. doctor_code = "1001"
  3436. } else {
  3437. doctor_name = roles.UserName
  3438. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3439. }
  3440. var customs []*models.CustomDetail
  3441. for _, item := range order_infos {
  3442. cus := &models.CustomDetail{
  3443. PrescriptionNumber: item.OrderNumber,
  3444. ChargeSerialNumber: item.FeedetlSn,
  3445. }
  3446. customs = append(customs, cus)
  3447. }
  3448. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3449. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3450. var pagesize int = 50
  3451. var start int = 1
  3452. var stop int
  3453. var pagecount int
  3454. var curpage int
  3455. var isSuccess bool = true
  3456. var ress []*ResultFive
  3457. //总页数,向上取整,注意除之前要先转换类型为float64
  3458. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  3459. for curpage = 1; curpage <= pagecount; curpage++ {
  3460. if curpage == 1 {
  3461. start = 1
  3462. } else {
  3463. start = (curpage-1)*pagesize + 1
  3464. }
  3465. stop = curpage * pagesize
  3466. if stop > len(customs) {
  3467. stop = len(customs)
  3468. }
  3469. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  3470. fmt.Println(result)
  3471. var dat map[string]interface{}
  3472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3473. fmt.Println(dat)
  3474. } else {
  3475. fmt.Println(err)
  3476. }
  3477. userJSONBytes, _ := json.Marshal(dat)
  3478. var res ResultFive
  3479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3480. utils.ErrorLog("解析失败:%v", err)
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. return
  3483. }
  3484. if res.Transreturncode == "00000000" {
  3485. ress = append(ress, &res)
  3486. } else {
  3487. isSuccess = false
  3488. //预结算报错
  3489. errlog := &models.HisOrderError{
  3490. UserOrgId: adminUser.CurrentOrgId,
  3491. Ctime: time.Now().Unix(),
  3492. Mtime: time.Now().Unix(),
  3493. ErrMsg: res.Transreturnmessage,
  3494. Status: 1,
  3495. PatientId: patient_id,
  3496. RecordTime: recordDateTime,
  3497. Stage: 11,
  3498. }
  3499. service.CreateErrMsgLog(errlog)
  3500. c.ServeSuccessJSON(map[string]interface{}{
  3501. "faild_code": -10,
  3502. "msg": res.Transreturnmessage,
  3503. })
  3504. return
  3505. }
  3506. }
  3507. if isSuccess == true {
  3508. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3509. c.ServeSuccessJSON(map[string]interface{}{
  3510. "msg": "撤销成功",
  3511. })
  3512. }
  3513. }
  3514. //获取verifyCode
  3515. func ReadCardGetCode(request string) (string, string) {
  3516. request = request + "|"
  3517. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3518. readCards := DllDef2.MustFindProc("iVerifyCode")
  3519. str := request
  3520. str3 := make([]byte, 256)
  3521. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3522. fmt.Println(":", string(str3))
  3523. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3524. if ret4 == 0 {
  3525. result := string(str3)
  3526. fmt.Println(result)
  3527. result_arr := strings.Split(result, "|")
  3528. verifyCode := result_arr[0] + "|" + result_arr[1]
  3529. versionCode := result_arr[2]
  3530. return verifyCode, versionCode
  3531. }
  3532. return "", ""
  3533. }
  3534. ////获取卡信息
  3535. func ReadBasCardGetNumber(request string) (string, string, string, string, string, error, int64) {
  3536. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3537. readCards := DllDef2.MustFindProc("iReadCardBas")
  3538. str := request
  3539. str3 := make([]byte, 1024)
  3540. fmt.Println(":", request)
  3541. fmt.Println(":", StrPtr(str))
  3542. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3543. fmt.Println(":", string(str3))
  3544. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3545. if ret4 == 0 {
  3546. result := string(str3)
  3547. fmt.Println(result)
  3548. result_arr := strings.Split(result, "|")
  3549. //医疗证号
  3550. yiliao_number := result_arr[12]
  3551. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3552. id_card_number := result_arr[1]
  3553. verifyCode := result_arr[11] + "|" + result_arr[13]
  3554. versionCode := result_arr[14]
  3555. health_card_no := result_arr[2]
  3556. return yiliao_number, id_card_number, verifyCode, versionCode, health_card_no, err, 0
  3557. }
  3558. return "", "", "", "", "", err, -10
  3559. }
  3560. //读卡
  3561. func ReadBasCard(request string) (string, string, error, int64) {
  3562. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3563. readCards := DllDef2.MustFindProc("iReadCardBas")
  3564. str := request
  3565. str3 := make([]byte, 1024)
  3566. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3567. fmt.Println(":", string(str3))
  3568. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3569. if ret4 == 0 {
  3570. result := string(str3)
  3571. result_arr := strings.Split(result, "|")
  3572. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3573. id_card_number := result_arr[1]
  3574. health_card_no := result_arr[2]
  3575. return id_card_number, health_card_no, err, 0
  3576. }
  3577. return "", "", err, -10
  3578. }
  3579. //
  3580. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  3581. //func ReadCardBasHSM(number string) string {
  3582. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3583. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  3584. // str := make([]byte, 256)
  3585. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  3586. // fmt.Println(":", string(str))
  3587. //
  3588. // result_arr := strings.Split(string(str), "|")
  3589. //
  3590. // if ret == 0 {
  3591. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  3592. // str2 := make([]byte, 256)
  3593. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  3594. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  3595. // fmt.Println(":", string(str2))
  3596. //
  3597. // if ret2 == 0 {
  3598. // result_arr := strings.Split(string(str2), "|")
  3599. //
  3600. // if result_arr[2] == "0" {
  3601. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  3602. // str4 := result_arr[4] + "|" + result_arr[5]
  3603. // str5 := make([]byte, 256)
  3604. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  3605. //
  3606. // if ret3 == 0 {
  3607. // return string(str5)
  3608. //
  3609. // } else {
  3610. // return ""
  3611. // }
  3612. // } else {
  3613. // return ""
  3614. // }
  3615. // }
  3616. // return ""
  3617. // }
  3618. // return ""
  3619. //
  3620. //}
  3621. //
  3622. ////1904卡鉴权
  3623. //func CardAuth(request string) string {
  3624. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3625. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  3626. // str := request
  3627. // str3 := make([]byte, 256)
  3628. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3629. // fmt.Println(":", string(str3))
  3630. //
  3631. // if ret4 == 0 {
  3632. // return string(str3)
  3633. // }
  3634. // return ""
  3635. //}
  3636. func (c *SZHisApiController) GetDrugList() {
  3637. adminUserInfo := c.GetAdminUserInfo()
  3638. orgId := adminUserInfo.CurrentOrgId
  3639. admin_user_id, _ := c.GetInt64("admin_user_id")
  3640. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3641. ids := c.GetString("ids")
  3642. stringarr := strings.Split(ids, ",")
  3643. idss := make([]int64, 0)
  3644. for _, item := range stringarr {
  3645. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3646. id := int64(itemsss)
  3647. idss = append(idss, id)
  3648. }
  3649. //批量获取
  3650. list, _ := service.GetBatchDrugList(idss)
  3651. //获取药品剂型
  3652. drugs, _ := service.GetDrugDosageForm(orgId)
  3653. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3654. var doctor_name string
  3655. var doctor_code string
  3656. doctor_name = roles.UserName
  3657. doctor_code = "1001"
  3658. var isSuccess bool = true
  3659. timeLayout := "20060102"
  3660. //这里就可以查看开始和结束了
  3661. for _, item := range list {
  3662. recordDate := time.Unix(item.RecordDate, 0).Format(timeLayout)
  3663. detail := &models.DrugDetail{
  3664. MedicalInsuranceNumber: item.SocialSecurityDirectoryCode,
  3665. Code: item.Code,
  3666. DrugName: item.DrugName,
  3667. DrugSpec: item.DrugSpec,
  3668. DrugDosageName: item.DrugDosageName,
  3669. ManufacturerName: item.ManufacturerName,
  3670. MinUnit: item.MinUnit,
  3671. RetailPrice: item.RetailPrice,
  3672. LastPrice: item.LastPrice,
  3673. LimitRemark: item.LimitRemark,
  3674. PrescriptionMark: strconv.FormatInt(item.PrescriptionMark, 10),
  3675. RecordDate: recordDate,
  3676. }
  3677. for _, it := range drugs {
  3678. if item.DrugDosageForm == it.Value {
  3679. detail.DrugDosageName = it.Code
  3680. }
  3681. }
  3682. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3683. var dat map[string]interface{}
  3684. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3685. //fmt.Println(dat)
  3686. } else {
  3687. //fmt.Println(err)
  3688. }
  3689. userJSONBytes, _ := json.Marshal(dat)
  3690. var res Result
  3691. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3692. utils.ErrorLog("解析失败:%v", err)
  3693. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3694. c.ServeSuccessJSON(map[string]interface{}{
  3695. "failed_code": -10,
  3696. "msg": res.Transreturnmessage,
  3697. })
  3698. return
  3699. }
  3700. if res.Transreturncode == "00000000" {
  3701. //更新备案状态
  3702. _, err := service.UpdateBaseDrugById(item.ID)
  3703. fmt.Println("err", err)
  3704. c.ServeSuccessJSON(map[string]interface{}{
  3705. "failed_code": -10,
  3706. "msg": res.Transreturnmessage,
  3707. })
  3708. return
  3709. }
  3710. fmt.Println(isSuccess)
  3711. c.ServeSuccessJSON(map[string]interface{}{
  3712. "failed_code": -10,
  3713. "msg": res.Transreturnmessage,
  3714. })
  3715. return
  3716. }
  3717. }
  3718. func (c *SZHisApiController) GetTreatmentProject() {
  3719. adminUserInfo := c.GetAdminUserInfo()
  3720. orgId := adminUserInfo.CurrentOrgId
  3721. ids := c.GetString("ids")
  3722. stringarr := strings.Split(ids, ",")
  3723. idss := make([]int64, 0)
  3724. admin_user_id, _ := c.GetInt64("admin_user_id")
  3725. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3726. for _, item := range stringarr {
  3727. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3728. id := int64(itemsss)
  3729. idss = append(idss, id)
  3730. }
  3731. //获取项目库数据
  3732. list, _ := service.GetBathchMyPorjecgList(idss)
  3733. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3734. var doctor_name string
  3735. var doctor_code string
  3736. doctor_name = roles.UserName
  3737. doctor_code = "1001"
  3738. var isSuccess bool = true
  3739. for _, item := range list {
  3740. detail := &models.MyHisProject{
  3741. MedicalCode: item.MedicalCode, //社保目录
  3742. ProjectName: item.ProjectName,
  3743. Price: item.Price,
  3744. Category: item.Category,
  3745. Remark: item.Remark,
  3746. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  3747. SpecailProject: item.SpecailProject,
  3748. RecordDate: item.RecordDate,
  3749. }
  3750. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  3751. var dat map[string]interface{}
  3752. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3753. fmt.Println(dat)
  3754. } else {
  3755. fmt.Println(err)
  3756. }
  3757. userJSONBytes, _ := json.Marshal(dat)
  3758. var res Result
  3759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3760. utils.ErrorLog("解析失败:%v", err)
  3761. c.ServeSuccessJSON(map[string]interface{}{
  3762. "failed_code": -10,
  3763. "msg": res.Transreturnmessage,
  3764. })
  3765. return
  3766. }
  3767. if res.Transreturncode == "00000000" {
  3768. //备案成功返回状态值
  3769. _, err := service.UpdateProjectById(item.ID)
  3770. fmt.Println("err", err)
  3771. } else {
  3772. isSuccess = false
  3773. //失败
  3774. c.ServeSuccessJSON(map[string]interface{}{
  3775. "failed_code": -10,
  3776. "msg": res.Transreturnmessage,
  3777. })
  3778. return
  3779. }
  3780. fmt.Println(isSuccess)
  3781. c.ServeSuccessJSON(map[string]interface{}{
  3782. "failed_code": -10,
  3783. "msg": res.Transreturnmessage,
  3784. })
  3785. return
  3786. }
  3787. }
  3788. func (c *SZHisApiController) GetRevocation() {
  3789. adminUserInfo := c.GetAdminUserInfo()
  3790. orgId := adminUserInfo.CurrentOrgId
  3791. id, _ := c.GetInt64("id")
  3792. admin_user_id, _ := c.GetInt64("admin_user_id")
  3793. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3794. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  3795. is_mark, _ := c.GetInt64("is_mark")
  3796. type_id, _ := c.GetInt64("type_id")
  3797. if type_id == 1 {
  3798. //撤销
  3799. if is_mark == 1 {
  3800. //获取药品库数据
  3801. list, _ := service.GetDrugListByDetail(orgId, id)
  3802. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3803. var doctor_name string
  3804. var doctor_code string
  3805. doctor_name = roles.UserName
  3806. doctor_code = "1001"
  3807. var pagesize int = 50
  3808. var start int = 1
  3809. var stop int
  3810. var pagecount int
  3811. var curpage int
  3812. var isSuccess bool = true
  3813. //总页数,向上取整,注意除之前要先转换类型为float64
  3814. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3815. for curpage = 1; curpage <= pagecount; curpage++ {
  3816. if curpage == 1 {
  3817. start = 1
  3818. } else {
  3819. start = (curpage-1)*pagesize + 1
  3820. }
  3821. stop = curpage * pagesize
  3822. if stop > len(list) {
  3823. stop = len(list)
  3824. }
  3825. //这里就可以查看开始和结束了
  3826. fmt.Println(list[start-1 : stop])
  3827. var customs []*models.DrugDetail
  3828. for _, item := range list {
  3829. detail := &models.DrugDetail{
  3830. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber, //社保目录
  3831. Code: item.Code, //协议机构内部目录编码
  3832. DrugName: item.DrugName, //协议机构内部目录名称
  3833. DrugSpec: item.DrugSpec,
  3834. ManufacturerName: item.ManufacturerName,
  3835. MinUnit: item.MinUnit,
  3836. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  3837. LimitRemark: item.LimitRemark,
  3838. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  3839. }
  3840. customs = append(customs, detail)
  3841. }
  3842. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3843. fmt.Println("reuslt", result)
  3844. var dat map[string]interface{}
  3845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3846. fmt.Println(dat)
  3847. } else {
  3848. fmt.Println(err)
  3849. }
  3850. userJSONBytes, _ := json.Marshal(dat)
  3851. var res Result
  3852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3853. utils.ErrorLog("解析失败:%v", err)
  3854. c.ServeSuccessJSON(map[string]interface{}{
  3855. "failed_code": -10,
  3856. "msg": res.Transreturnmessage,
  3857. })
  3858. return
  3859. }
  3860. if res.Transreturncode == "00000000" {
  3861. //撤销成功
  3862. _, err := service.UpdateDrugByIdDetail(id)
  3863. fmt.Println("err", err)
  3864. } else {
  3865. isSuccess = false
  3866. //失败
  3867. c.ServeSuccessJSON(map[string]interface{}{
  3868. "failed_code": -10,
  3869. "msg": res.Transreturnmessage,
  3870. })
  3871. return
  3872. }
  3873. fmt.Println(isSuccess)
  3874. c.ServeSuccessJSON(map[string]interface{}{
  3875. "failed_code": -10,
  3876. "msg": res.Transreturnmessage,
  3877. })
  3878. return
  3879. }
  3880. }
  3881. // 备案
  3882. if is_mark == 0 {
  3883. adminUserInfo := c.GetAdminUserInfo()
  3884. orgId := adminUserInfo.CurrentOrgId
  3885. //获取药品库数据
  3886. list, _ := service.GetDrugListByDetail(orgId, id)
  3887. //获取药品剂型
  3888. drugs, _ := service.GetDrugDosageForm(orgId)
  3889. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3890. var doctor_name string
  3891. var doctor_code string
  3892. doctor_name = roles.UserName
  3893. doctor_code = "1001"
  3894. var isSuccess bool = true
  3895. //这里就可以查看开始和结束了
  3896. for _, item := range list {
  3897. detail := &models.DrugDetail{
  3898. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  3899. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber,
  3900. Code: item.Code,
  3901. DrugName: item.DrugName,
  3902. DrugSpec: item.DrugSpec,
  3903. DrugDosageName: item.DrugDosageName,
  3904. ManufacturerName: item.ManufacturerName,
  3905. MinUnit: item.MinUnit,
  3906. RetailPrice: item.RetailPrice,
  3907. LastPrice: item.LastPrice,
  3908. LimitRemark: item.LimitRemark,
  3909. }
  3910. for _, it := range drugs {
  3911. if item.DrugDosageForm == it.Value {
  3912. detail.DrugDosageName = it.Code
  3913. }
  3914. }
  3915. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3916. var dat map[string]interface{}
  3917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3918. //fmt.Println(dat)
  3919. } else {
  3920. //fmt.Println(err)
  3921. }
  3922. userJSONBytes, _ := json.Marshal(dat)
  3923. var res Result
  3924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3925. utils.ErrorLog("解析失败:%v", err)
  3926. c.ServeSuccessJSON(map[string]interface{}{
  3927. "failed_code": -10,
  3928. "msg": res.Transreturnmessage,
  3929. })
  3930. return
  3931. }
  3932. if res.Transreturncode == "00000000" {
  3933. //更新备案状态
  3934. _, err := service.UpdateBaseDrugById(item.ID)
  3935. fmt.Println("err", err)
  3936. }
  3937. fmt.Println(isSuccess)
  3938. c.ServeSuccessJSON(map[string]interface{}{
  3939. "failed_code": -10,
  3940. "msg": res.Transreturnmessage,
  3941. })
  3942. return
  3943. }
  3944. }
  3945. }
  3946. if type_id == 2 {
  3947. //撤销
  3948. if is_mark == 1 {
  3949. //获取药品库数据
  3950. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  3951. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3952. var doctor_name string
  3953. var doctor_code string
  3954. doctor_name = roles.UserName
  3955. doctor_code = "1001"
  3956. var pagesize int = 50
  3957. var start int = 1
  3958. var stop int
  3959. var pagecount int
  3960. var curpage int
  3961. var isSuccess bool = true
  3962. //总页数,向上取整,注意除之前要先转换类型为float64
  3963. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3964. for curpage = 1; curpage <= pagecount; curpage++ {
  3965. if curpage == 1 {
  3966. start = 1
  3967. } else {
  3968. start = (curpage-1)*pagesize + 1
  3969. }
  3970. stop = curpage * pagesize
  3971. if stop > len(list) {
  3972. stop = len(list)
  3973. }
  3974. //这里就可以查看开始和结束了
  3975. fmt.Println(list[start-1 : stop])
  3976. var customs []*models.DrugDetail
  3977. for _, item := range list {
  3978. detail := &models.DrugDetail{
  3979. SocialSecurityDirectoryCode: item.MedicalCode,
  3980. }
  3981. customs = append(customs, detail)
  3982. }
  3983. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3984. fmt.Println("reuslt", result)
  3985. var dat map[string]interface{}
  3986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3987. fmt.Println(dat)
  3988. } else {
  3989. fmt.Println(err)
  3990. }
  3991. userJSONBytes, _ := json.Marshal(dat)
  3992. var res Result
  3993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3994. utils.ErrorLog("解析失败:%v", err)
  3995. c.ServeSuccessJSON(map[string]interface{}{
  3996. "failed_code": -10,
  3997. "msg": res.Transreturnmessage,
  3998. })
  3999. return
  4000. }
  4001. if res.Transreturncode == "00000000" {
  4002. //核销成功返回状态码
  4003. _, err := service.UpdateMyProjectById(id)
  4004. fmt.Println("err", err)
  4005. } else {
  4006. isSuccess = false
  4007. //失败
  4008. c.ServeSuccessJSON(map[string]interface{}{
  4009. "failed_code": -10,
  4010. "msg": res.Transreturnmessage,
  4011. })
  4012. return
  4013. }
  4014. fmt.Println(isSuccess)
  4015. c.ServeSuccessJSON(map[string]interface{}{
  4016. "failed_code": -10,
  4017. "msg": res.Transreturnmessage,
  4018. })
  4019. return
  4020. }
  4021. }
  4022. //备案
  4023. if is_mark == 0 {
  4024. adminUserInfo := c.GetAdminUserInfo()
  4025. orgId := adminUserInfo.CurrentOrgId
  4026. //获取药品库数据
  4027. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  4028. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4029. var doctor_name string
  4030. var doctor_code string
  4031. doctor_name = roles.UserName
  4032. doctor_code = "1001"
  4033. var isSuccess bool = true
  4034. for _, item := range list {
  4035. detail := &models.MyHisProject{
  4036. MedicalCode: item.MedicalCode, //社保目录
  4037. ProjectName: item.ProjectName,
  4038. Price: item.Price,
  4039. Category: item.Category,
  4040. Remark: item.Remark,
  4041. }
  4042. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  4043. fmt.Println("reuslt", result)
  4044. var dat map[string]interface{}
  4045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4046. fmt.Println(dat)
  4047. } else {
  4048. fmt.Println(err)
  4049. }
  4050. userJSONBytes, _ := json.Marshal(dat)
  4051. var res Result
  4052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4053. utils.ErrorLog("解析失败:%v", err)
  4054. c.ServeSuccessJSON(map[string]interface{}{
  4055. "failed_code": -10,
  4056. "msg": res.Transreturnmessage,
  4057. })
  4058. return
  4059. }
  4060. if res.Transreturncode == "00000000" {
  4061. //备案成功返回状态值
  4062. _, err := service.UpdateProjectById(item.ID)
  4063. fmt.Println("err", err)
  4064. } else {
  4065. isSuccess = false
  4066. //失败
  4067. c.ServeSuccessJSON(map[string]interface{}{
  4068. "failed_code": -10,
  4069. "msg": res.Transreturnmessage,
  4070. })
  4071. return
  4072. }
  4073. fmt.Println(isSuccess)
  4074. c.ServeSuccessJSON(map[string]interface{}{
  4075. "failed_code": -10,
  4076. "msg": res.Transreturnmessage,
  4077. })
  4078. return
  4079. }
  4080. }
  4081. }
  4082. if type_id == 3 {
  4083. //撤销
  4084. if is_mark == 1 {
  4085. //获取药品库数据
  4086. list, _ := service.GetGoodListByDetail(orgId, id)
  4087. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4088. var doctor_name string
  4089. var doctor_code string
  4090. doctor_name = roles.UserName
  4091. doctor_code = "1001"
  4092. var pagesize int = 50
  4093. var start int = 1
  4094. var stop int
  4095. var pagecount int
  4096. var curpage int
  4097. var isSuccess bool = true
  4098. //总页数,向上取整,注意除之前要先转换类型为float64
  4099. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4100. for curpage = 1; curpage <= pagecount; curpage++ {
  4101. if curpage == 1 {
  4102. start = 1
  4103. } else {
  4104. start = (curpage-1)*pagesize + 1
  4105. }
  4106. stop = curpage * pagesize
  4107. if stop > len(list) {
  4108. stop = len(list)
  4109. }
  4110. //这里就可以查看开始和结束了
  4111. fmt.Println(list[start-1 : stop])
  4112. var customs []*models.DrugDetail
  4113. for _, item := range list {
  4114. fmt.Println("医疗机构编码", item.SocialSecurityDirectoryCode)
  4115. detail := &models.DrugDetail{
  4116. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4117. ManufacturerName: item.ManufacturerName,
  4118. }
  4119. customs = append(customs, detail)
  4120. }
  4121. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  4122. fmt.Println("reuslt", result)
  4123. var dat map[string]interface{}
  4124. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4125. fmt.Println(dat)
  4126. } else {
  4127. fmt.Println(err)
  4128. }
  4129. userJSONBytes, _ := json.Marshal(dat)
  4130. var res Result
  4131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4132. utils.ErrorLog("解析失败:%v", err)
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4134. return
  4135. }
  4136. if res.Transreturncode == "00000000" {
  4137. //撤销成功后改变状态
  4138. _, err := service.UpdateGoodInfoById(id)
  4139. fmt.Println("err", err)
  4140. } else {
  4141. isSuccess = false
  4142. //失败
  4143. c.ServeSuccessJSON(map[string]interface{}{
  4144. "failed_code": -10,
  4145. "msg": res.Transreturnmessage,
  4146. })
  4147. return
  4148. }
  4149. fmt.Println(isSuccess)
  4150. c.ServeSuccessJSON(map[string]interface{}{
  4151. "failed_code": -10,
  4152. "msg": res.Transreturnmessage,
  4153. })
  4154. return
  4155. }
  4156. }
  4157. //备案
  4158. if is_mark == 0 {
  4159. adminUserInfo := c.GetAdminUserInfo()
  4160. orgId := adminUserInfo.CurrentOrgId
  4161. //获取所有耗材信息
  4162. list, _ := service.GetGoodListByDetail(orgId, id)
  4163. //获取单位
  4164. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4165. var doctor_name string
  4166. var doctor_code string
  4167. doctor_name = roles.UserName
  4168. doctor_code = "1001"
  4169. var isSuccess bool = true
  4170. for _, item := range list {
  4171. detail := &models.XtGoodInformation{
  4172. GoodName: item.GoodName,
  4173. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4174. ManufacturerName: item.ManufacturerName,
  4175. ProductionType: item.ProductionType,
  4176. SpecialMedical: item.SpecialMedical,
  4177. BuyPrice: item.BuyPrice,
  4178. SellPrice: item.SellPrice,
  4179. Remark: item.Remark,
  4180. SpecificationName: item.SpecificationName,
  4181. }
  4182. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4183. fmt.Println("reuslt", result)
  4184. var dat map[string]interface{}
  4185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4186. fmt.Println(dat)
  4187. } else {
  4188. fmt.Println(err)
  4189. }
  4190. userJSONBytes, _ := json.Marshal(dat)
  4191. var res Result
  4192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4193. utils.ErrorLog("解析失败:%v", err)
  4194. c.ServeSuccessJSON(map[string]interface{}{
  4195. "failed_code": -10,
  4196. "msg": res.Transreturnmessage,
  4197. })
  4198. return
  4199. }
  4200. if res.Transreturncode == "00000000" {
  4201. //备案成功返回状态
  4202. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4203. fmt.Println("err", err)
  4204. } else {
  4205. isSuccess = false
  4206. //失败
  4207. c.ServeSuccessJSON(map[string]interface{}{
  4208. "failed_code": -10,
  4209. "msg": res.Transreturnmessage,
  4210. })
  4211. return
  4212. }
  4213. fmt.Println(isSuccess)
  4214. c.ServeSuccessJSON(map[string]interface{}{
  4215. "failed_code": -10,
  4216. "msg": res.Transreturnmessage,
  4217. })
  4218. return
  4219. }
  4220. }
  4221. }
  4222. }
  4223. func (c *SZHisApiController) GetDoctorList() {
  4224. adminUserInfo := c.GetAdminUserInfo()
  4225. orgid := adminUserInfo.CurrentOrgId
  4226. ids := c.GetString("ids")
  4227. admin_user_id, _ := c.GetInt64("admin_user_id")
  4228. roles, _ := service.GetAdminUserInfoByID(orgid, admin_user_id)
  4229. stringarr := strings.Split(ids, ",")
  4230. idss := make([]int64, 0)
  4231. for _, item := range stringarr {
  4232. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4233. id := int64(itemsss)
  4234. idss = append(idss, id)
  4235. }
  4236. //获取所有医生护士信息
  4237. //list, _ := service.GetDoctorList(orgid)
  4238. //批量查询
  4239. list, _ := service.GetBatchDoctorList(idss)
  4240. //获取所有角色名称
  4241. roleList, _ := service.GetRoleList(orgid)
  4242. miConfig, _ := service.FindMedicalInsuranceInfo(orgid)
  4243. for _, item := range list {
  4244. for _, it := range roleList {
  4245. if item.RoleId == it.ID {
  4246. item.Name = it.RoleName
  4247. }
  4248. }
  4249. }
  4250. var doctor_name string
  4251. var doctor_code string
  4252. doctor_name = roles.UserName
  4253. doctor_code = "1001"
  4254. var isSuccess bool = true
  4255. for _, item := range list {
  4256. depart, _ := service.GetDepartMentDetail(item.DepartmentId)
  4257. detail := &models.DocDetail{
  4258. UserName: item.UserName, //医护姓名
  4259. RoleId: item.Name, //医护人员类别
  4260. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4261. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4262. IdCard: item.IdCard, //证件号码
  4263. Phone: item.Mobile, //联系电话
  4264. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4265. Nation: "1", //民族
  4266. BirthDay: 20201022, // 出生日期
  4267. WorkTime: 20201022, //参加工作日期
  4268. Education: strconv.FormatInt(item.Education, 10), //学历
  4269. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4270. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4271. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4272. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4273. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4274. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4275. DoctorNumber: item.DoctorNumber, //医保医师编号
  4276. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4277. DoctorServiceStatus: "", //医师医保服务资格状态
  4278. MonitoringLevel: "", //监控等级
  4279. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4280. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4281. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4282. PharmacistType: "", //药师类别
  4283. PharmacistPracticeCategory: "", //药师执业类别
  4284. PharmacistsLicensing: "", //药师执业范围
  4285. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4286. OfficeCode: depart.Number, //科室编码
  4287. JobNumber: item.JobNumber, //工号
  4288. PostName: "", //职位名称
  4289. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4290. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4291. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4292. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4293. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4294. StartTime: 20201010, //开始日期
  4295. StaffCode: "", //医护人员编码
  4296. EndTime: 0, // 结束日期
  4297. }
  4298. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4299. fmt.Println("reuslt", result)
  4300. var dat map[string]interface{}
  4301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4302. fmt.Println(dat)
  4303. } else {
  4304. fmt.Println(err)
  4305. }
  4306. userJSONBytes, _ := json.Marshal(dat)
  4307. var res Result
  4308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4309. utils.ErrorLog("解析失败:%v", err)
  4310. c.ServeSuccessJSON(map[string]interface{}{
  4311. "failed_code": -10,
  4312. "msg": res.Transreturnmessage,
  4313. })
  4314. return
  4315. }
  4316. if res.Transreturncode == "00000000" {
  4317. //批量插入数据
  4318. _, err := service.UpdateAdminUserRoleById(item.AdminUserId, orgid)
  4319. fmt.Println("err", err)
  4320. } else {
  4321. isSuccess = false
  4322. //失败
  4323. c.ServeSuccessJSON(map[string]interface{}{
  4324. "failed_code": -10,
  4325. "msg": res.Transreturnmessage,
  4326. })
  4327. return
  4328. }
  4329. fmt.Println(isSuccess)
  4330. c.ServeSuccessJSON(map[string]interface{}{
  4331. "failed_code": -10,
  4332. "msg": res.Transreturnmessage,
  4333. })
  4334. return
  4335. }
  4336. }
  4337. func (c *SZHisApiController) GetMedicalList() {
  4338. adminUserInfo := c.GetAdminUserInfo()
  4339. orgId := adminUserInfo.CurrentOrgId
  4340. id, _ := c.GetInt64("id")
  4341. is_mark, _ := c.GetInt64("is_mark")
  4342. admin_user_id, _ := c.GetInt64("admin_user_id")
  4343. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4344. //去登记
  4345. if is_mark == 0 {
  4346. list, _ := service.GetDoctorListByDetail(orgId, id)
  4347. //获取所有角色名称
  4348. roleList, _ := service.GetRoleList(orgId)
  4349. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4350. for _, item := range list {
  4351. for _, it := range roleList {
  4352. if item.RoleId == it.ID {
  4353. item.Name = it.RoleName
  4354. }
  4355. }
  4356. }
  4357. var doctor_name string
  4358. var doctor_code string
  4359. doctor_name = roles.UserName
  4360. doctor_code = "1001"
  4361. var isSuccess bool = true
  4362. for _, item := range list {
  4363. detail := &models.DocDetail{
  4364. UserName: item.UserName, //医护姓名
  4365. RoleId: item.Name, //医护人员类别
  4366. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4367. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4368. IdCard: item.IdCard, //证件号码
  4369. Phone: item.Mobile, //联系电话
  4370. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4371. Nation: item.Nation, //民族
  4372. BirthDay: 20201022, // 出生日期
  4373. WorkTime: 20201022, //参加工作日期
  4374. Education: strconv.FormatInt(item.Education, 10), //学历
  4375. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4376. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4377. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4378. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4379. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4380. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4381. DoctorNumber: item.DoctorNumber, //医保医师编号
  4382. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4383. DoctorServiceStatus: "", //医师医保服务资格状态
  4384. MonitoringLevel: "", //监控等级
  4385. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4386. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4387. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4388. PharmacistType: "", //药师类别
  4389. PharmacistPracticeCategory: "", //药师执业类别
  4390. PharmacistsLicensing: "", //药师执业范围
  4391. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4392. OfficeCode: "", //科室编码
  4393. JobNumber: item.JobNumber, //工号
  4394. PostName: "", //职位名称
  4395. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4396. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4397. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4398. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4399. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4400. StartTime: 20201010, //开始日期
  4401. StaffCode: "", //医护人员编码
  4402. EndTime: 0, // 结束日期
  4403. }
  4404. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4405. var dat map[string]interface{}
  4406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4407. fmt.Println(dat)
  4408. } else {
  4409. fmt.Println(err)
  4410. }
  4411. userJSONBytes, _ := json.Marshal(dat)
  4412. var res Result
  4413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4414. utils.ErrorLog("解析失败:%v", err)
  4415. c.ServeSuccessJSON(map[string]interface{}{
  4416. "failed_code": -10,
  4417. "msg": res.Transreturnmessage,
  4418. })
  4419. return
  4420. }
  4421. if res.Transreturncode == "00000000" {
  4422. //登记成功
  4423. service.UpdateAdminUserRoleById(item.ID, orgId)
  4424. } else {
  4425. isSuccess = false
  4426. //失败
  4427. c.ServeSuccessJSON(map[string]interface{}{
  4428. "failed_code": -10,
  4429. "msg": res.Transreturnmessage,
  4430. })
  4431. return
  4432. }
  4433. fmt.Println(isSuccess)
  4434. c.ServeSuccessJSON(map[string]interface{}{
  4435. "failed_code": -10,
  4436. "msg": res.Transreturnmessage,
  4437. })
  4438. return
  4439. }
  4440. }
  4441. //去撤销
  4442. if is_mark == 1 {
  4443. //获取所有医生护士信息
  4444. list, _ := service.GetDoctorListByDetail(orgId, id)
  4445. //获取所有角色名称
  4446. roleList, _ := service.GetRoleList(orgId)
  4447. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4448. for _, item := range list {
  4449. for _, it := range roleList {
  4450. if item.RoleId == it.ID {
  4451. item.Name = it.RoleName
  4452. }
  4453. }
  4454. }
  4455. var doctor_name string
  4456. var doctor_code string
  4457. doctor_name = "黄亦轩"
  4458. doctor_code = "1001"
  4459. var isSuccess bool = true
  4460. for _, item := range list {
  4461. detail := &models.DocDetail{
  4462. UserName: item.UserName, //医护姓名
  4463. RoleId: item.Name, //医护人员类别
  4464. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4465. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4466. IdCard: item.IdCard, //证件号码
  4467. Phone: item.Mobile, //联系电话
  4468. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4469. Nation: item.Nation, //民族
  4470. BirthDay: 20201022, // 出生日期
  4471. WorkTime: 20201022, //参加工作日期
  4472. Education: strconv.FormatInt(item.Education, 10), //学历
  4473. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4474. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4475. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4476. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4477. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4478. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4479. DoctorNumber: item.DoctorNumber, //医保医师编号
  4480. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4481. DoctorServiceStatus: "", //医师医保服务资格状态
  4482. MonitoringLevel: "", //监控等级
  4483. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4484. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4485. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4486. PharmacistType: "", //药师类别
  4487. PharmacistPracticeCategory: "", //药师执业类别
  4488. PharmacistsLicensing: "", //药师执业范围
  4489. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4490. OfficeCode: "", //科室编码
  4491. JobNumber: item.JobNumber, //工号
  4492. PostName: "", //职位名称
  4493. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4494. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4495. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4496. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4497. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4498. StartTime: 20201010, //开始日期
  4499. StaffCode: "", //医护人员编码
  4500. EndTime: 0, // 结束日期
  4501. }
  4502. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
  4503. var dat map[string]interface{}
  4504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4505. fmt.Println(dat)
  4506. } else {
  4507. fmt.Println(err)
  4508. }
  4509. userJSONBytes, _ := json.Marshal(dat)
  4510. var res Result
  4511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeSuccessJSON(map[string]interface{}{
  4514. "failed_code": -10,
  4515. "msg": res.Transreturnmessage,
  4516. })
  4517. return
  4518. }
  4519. if res.Transreturncode == "00000000" {
  4520. //去撤销
  4521. service.UpdateAdminUserRoleById(item.ID, orgId)
  4522. } else {
  4523. isSuccess = false
  4524. //失败
  4525. c.ServeSuccessJSON(map[string]interface{}{
  4526. "failed_code": -10,
  4527. "msg": res.Transreturnmessage,
  4528. })
  4529. return
  4530. }
  4531. fmt.Println(isSuccess)
  4532. c.ServeSuccessJSON(map[string]interface{}{
  4533. "failed_code": -10,
  4534. "msg": res.Transreturnmessage,
  4535. })
  4536. return
  4537. }
  4538. }
  4539. }
  4540. func (c *SZHisApiController) GetUpdateMedicalList() {
  4541. adminUserInfo := c.GetAdminUserInfo()
  4542. orgId := adminUserInfo.CurrentOrgId
  4543. //获取所有医生护士信息
  4544. list, _ := service.GetDoctorList(orgId)
  4545. //获取所有角色名称
  4546. roleList, _ := service.GetRoleList(orgId)
  4547. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4548. for _, item := range list {
  4549. for _, it := range roleList {
  4550. if item.RoleId == it.ID {
  4551. item.Name = it.RoleName
  4552. }
  4553. }
  4554. }
  4555. var doctor_name string
  4556. var doctor_code string
  4557. doctor_name = "黄亦轩"
  4558. doctor_code = "1001"
  4559. var pagesize int = 50
  4560. var start int = 1
  4561. var stop int
  4562. var pagecount int
  4563. var curpage int
  4564. var isSuccess bool = true
  4565. //总页数,向上取整,注意除之前要先转换类型为float64
  4566. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4567. var ress []*Result
  4568. for curpage = 1; curpage <= pagecount; curpage++ {
  4569. if curpage == 1 {
  4570. start = 1
  4571. } else {
  4572. start = (curpage-1)*pagesize + 1
  4573. }
  4574. stop = curpage * pagesize
  4575. if stop > len(list) {
  4576. stop = len(list)
  4577. }
  4578. //这里就可以查看开始和结束了
  4579. fmt.Println(list[start-1 : stop])
  4580. var customs []*models.DocDetail
  4581. for _, item := range list {
  4582. detail := &models.DocDetail{
  4583. StaffCode: "", //医护人员编码
  4584. UserName: item.UserName, //医护人员姓名
  4585. RoleId: item.Name, //医护人员类别
  4586. Sex: "", //性别
  4587. CardType: "", //证件类型
  4588. IdCard: "", //证件号码
  4589. Phone: "", //联系电话
  4590. WorkMajorName: "", //现从事专业名称
  4591. Nation: "", //民族
  4592. BirthDay: 20201022, //出生日期
  4593. WorkTime: 20201022, //参加工作日期
  4594. Education: "", //学历
  4595. StudyMajorName: "", //所学的专业名称
  4596. CertificateCode: "", //证书编码
  4597. MedicalCode: "", //医师资格编码
  4598. MedicalRangeCode: "", //医师执业范围代码
  4599. MedicalLevel: "", //医生级别
  4600. TypeJob: "", //职业类别
  4601. DoctorNumber: "", //医师编号
  4602. Licensing: "", //职业标志
  4603. DoctorServiceStatus: "", //医师医保服务资格状态
  4604. MonitoringLevel: "", //监控等级
  4605. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4606. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4607. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4608. PharmacistType: "", //药师类别
  4609. PharmacistPracticeCategory: "", //药师执业类别
  4610. PharmacistsLicensing: "", //药师执业范围
  4611. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4612. OfficeCode: "", //科室编码
  4613. JobNumber: "", //工号
  4614. PostName: "", //职位名称
  4615. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4616. IsActive: "", //在职与否
  4617. PrescriptionQualificationIdentification: "", //处方资格标识
  4618. IdentificationOutpatients: "", //门诊大病医师标识
  4619. OutpatientIllnessCategory: "", //门诊大病类别
  4620. StartTime: 20201022, //开始日期
  4621. EndTime: 20201022,
  4622. }
  4623. customs = append(customs, detail)
  4624. }
  4625. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  4626. var dat map[string]interface{}
  4627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4628. fmt.Println(dat)
  4629. } else {
  4630. fmt.Println(err)
  4631. }
  4632. userJSONBytes, _ := json.Marshal(dat)
  4633. var res Result
  4634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4635. utils.ErrorLog("解析失败:%v", err)
  4636. c.ServeSuccessJSON(map[string]interface{}{
  4637. "failed_code": -10,
  4638. "msg": res.Transreturnmessage,
  4639. })
  4640. return
  4641. }
  4642. if res.Transreturncode == "00000000" {
  4643. ress = append(ress, &res)
  4644. } else {
  4645. isSuccess = false
  4646. //失败
  4647. c.ServeSuccessJSON(map[string]interface{}{
  4648. "failed_code": -10,
  4649. "msg": res.Transreturnmessage,
  4650. })
  4651. return
  4652. }
  4653. fmt.Println(isSuccess)
  4654. c.ServeSuccessJSON(map[string]interface{}{
  4655. "failed_code": -10,
  4656. "msg": res.Transreturnmessage,
  4657. })
  4658. return
  4659. }
  4660. }
  4661. func (c *SZHisApiController) GetGoodsList() {
  4662. adminUserInfo := c.GetAdminUserInfo()
  4663. orgId := adminUserInfo.CurrentOrgId
  4664. ids := c.GetString("ids")
  4665. admin_user_id, _ := c.GetInt64("admin_user_id")
  4666. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4667. stringarr := strings.Split(ids, ",")
  4668. idss := make([]int64, 0)
  4669. for _, item := range stringarr {
  4670. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4671. id := int64(itemsss)
  4672. idss = append(idss, id)
  4673. }
  4674. //批量获取所有耗材信息
  4675. list, _ := service.GetBatchGoodInformationList(idss)
  4676. //获取单位
  4677. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4678. var doctor_name string
  4679. var doctor_code string
  4680. doctor_name = roles.UserName
  4681. doctor_code = "1001"
  4682. var isSuccess bool = true
  4683. for _, item := range list {
  4684. detail := &models.XtGoodInformation{
  4685. GoodName: item.GoodName,
  4686. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4687. ManufacturerName: item.ManufacturerName,
  4688. ProductionType: item.ProductionType,
  4689. SpecialMedical: item.SpecialMedical,
  4690. BuyPrice: item.BuyPrice,
  4691. SellPrice: item.SellPrice,
  4692. Remark: item.Remark,
  4693. SpecificationName: item.SpecificationName,
  4694. }
  4695. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4696. fmt.Println("reuslt", result)
  4697. var dat map[string]interface{}
  4698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4699. fmt.Println(dat)
  4700. } else {
  4701. fmt.Println(err)
  4702. }
  4703. userJSONBytes, _ := json.Marshal(dat)
  4704. var res Result
  4705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. if res.Transreturncode == "00000000" {
  4711. //备案成功返回状态
  4712. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4713. fmt.Println("err", err)
  4714. } else {
  4715. isSuccess = false
  4716. //失败
  4717. c.ServeSuccessJSON(map[string]interface{}{
  4718. "failed_code": -10,
  4719. "msg": res.Transreturnmessage,
  4720. })
  4721. return
  4722. }
  4723. fmt.Println(isSuccess)
  4724. c.ServeSuccessJSON(map[string]interface{}{
  4725. "failed_code": -10,
  4726. "msg": res.Transreturnmessage,
  4727. })
  4728. return
  4729. }
  4730. }
  4731. type Charset string
  4732. const (
  4733. UTF8 = Charset("UTF-8")
  4734. GB18030 = Charset("GB18030")
  4735. )
  4736. func ConvertToString(src string, srcCode string, tagCode string) string {
  4737. srcCoder := mahonia.NewDecoder(srcCode)
  4738. srcResult := srcCoder.ConvertString(src)
  4739. tagCoder := mahonia.NewDecoder(tagCode)
  4740. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  4741. result := string(cdata)
  4742. return result
  4743. }