sz_his_api_controller.go 165KB

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