sz_his_api_controller.go 136KB

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