sz_his_api_controller.go 161KB

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