sz_his_api_controller.go 179KB

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