sz_his_api_controller.go 154KB

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