sz_his_api_controller.go 177KB

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