sz_his_api_controller.go 180KB

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