sz_his_api_controller.go 182KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092
  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. if subItem.Type == 2 {
  2205. cus := &models.CustomDetail{
  2206. PrescriptionNumber: chrg_bchno,
  2207. OrderType: "1",
  2208. ChargeSerialNumber: newFl,
  2209. Code: subItem.HisProject.MedicalCode,
  2210. CodeName: subItem.HisProject.ProjectName,
  2211. Flag: "1",
  2212. Price: subItem.Price,
  2213. Count: count,
  2214. ChargeOrderDate: year + month + day,
  2215. DoctorCode: doctor_code,
  2216. Total: detItemFeeSumamt,
  2217. DoseCode: "",
  2218. Spec: "次",
  2219. }
  2220. customs = append(customs, cus)
  2221. } else if subItem.Type == 3 {
  2222. cus := &models.CustomDetail{
  2223. PrescriptionNumber: chrg_bchno,
  2224. OrderType: "1",
  2225. ChargeSerialNumber: newFl,
  2226. Code: subItem.GoodInfo.MedicalInsuranceNumber,
  2227. CodeName: subItem.GoodInfo.GoodName,
  2228. Flag: "1",
  2229. Price: subItem.Price,
  2230. Count: count,
  2231. ChargeOrderDate: year + month + day,
  2232. DoctorCode: doctor_code,
  2233. Total: detItemFeeSumamt,
  2234. DoseCode: "",
  2235. Spec: "次",
  2236. }
  2237. customs = append(customs, cus)
  2238. }
  2239. }
  2240. }
  2241. }
  2242. //
  2243. //for _, subItem := range item.HisAdditionalCharge {
  2244. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2245. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2246. //
  2247. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2248. // cus := &models.CustomDetail{
  2249. // PrescriptionNumber: chrg_bchno,
  2250. // OrderType: "1",
  2251. // ChargeSerialNumber: subItem.FeedetlSn,
  2252. // Code: subItem.XtHisAddtionConfig.Code,
  2253. // CodeName: subItem.XtHisAddtionConfig.Name,
  2254. // Flag: "1",
  2255. // Price: subItem.Price,
  2256. // Count: count,
  2257. // ChargeOrderDate: year + month + day,
  2258. // DoctorCode: doctor_code,
  2259. // Total: detItemFeeSumamt,
  2260. // DoseCode: "",
  2261. // Spec: subItem.XtHisAddtionConfig.,
  2262. // }
  2263. // customs = append(customs, cus)
  2264. // }
  2265. //}
  2266. }
  2267. var pagesize int = 50
  2268. var start int = 1
  2269. var stop int
  2270. var pagecount int
  2271. var curpage int
  2272. var isSuccess bool = true
  2273. //总页数,向上取整,注意除之前要先转换类型为float64
  2274. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2275. var ress []*Result
  2276. for curpage = 1; curpage <= pagecount; curpage++ {
  2277. if curpage == 1 {
  2278. start = 1
  2279. } else {
  2280. start = (curpage-1)*pagesize + 1
  2281. }
  2282. stop = curpage * pagesize
  2283. if stop > len(customs) {
  2284. stop = len(customs)
  2285. }
  2286. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2287. fmt.Println(result)
  2288. var dat map[string]interface{}
  2289. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2290. fmt.Println(dat)
  2291. } else {
  2292. fmt.Println(err)
  2293. }
  2294. userJSONBytes, _ := json.Marshal(dat)
  2295. var res Result
  2296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2297. utils.ErrorLog("解析失败:%v", err)
  2298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2299. return
  2300. }
  2301. if res.Transreturncode == "00000000" {
  2302. ress = append(ress, &res)
  2303. } else {
  2304. isSuccess = false
  2305. errlog := &models.HisOrderError{
  2306. UserOrgId: adminUser.CurrentOrgId,
  2307. Ctime: time.Now().Unix(),
  2308. Mtime: time.Now().Unix(),
  2309. Number: chrg_bchno,
  2310. ErrMsg: res.Transreturnmessage,
  2311. Status: 1,
  2312. PatientId: patient_id,
  2313. RecordTime: recordDateTime,
  2314. Stage: 4,
  2315. }
  2316. service.CreateErrMsgLog(errlog)
  2317. c.ServeSuccessJSON(map[string]interface{}{
  2318. "failed_code": -10,
  2319. "msg": res.Transreturnmessage,
  2320. })
  2321. return
  2322. }
  2323. //设置变量,根据变量的值来判断上传是否成功
  2324. }
  2325. if isSuccess == true {
  2326. order := &models.HisOrder{
  2327. UserOrgId: adminUser.CurrentOrgId,
  2328. HisPatientId: 0,
  2329. PatientId: patient_id,
  2330. SettleAccountsDate: recordDateTime,
  2331. Ctime: time.Now().Unix(),
  2332. Mtime: time.Now().Unix(),
  2333. Status: 0,
  2334. Number: chrg_bchno,
  2335. Infcode: 0,
  2336. WarnMsg: "",
  2337. Cainfo: "",
  2338. ErrMsg: "",
  2339. RespondTime: "",
  2340. InfRefmsgid: "",
  2341. OrderStatus: 1,
  2342. IsMedicineInsurance: 1,
  2343. SettleType: settle_accounts_type,
  2344. SettleStartTime: start_time,
  2345. SettleEndTime: end_time,
  2346. Creator: admin_user_id,
  2347. Modify: admin_user_id,
  2348. OrgSetlNumber: number,
  2349. MdtrtId: mz_number,
  2350. PType: 2,
  2351. }
  2352. data, _ := json.Marshal(ress)
  2353. order.DetailLog = string(data)
  2354. err = service.CreateOrder(order)
  2355. if err != nil {
  2356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2357. return
  2358. }
  2359. for _, subItem := range ress {
  2360. for _, item := range subItem.Transbody.Outputlist {
  2361. temp := strings.Split(item.Bkf500, "-")
  2362. var advice_id int64 = 0
  2363. var project_id int64 = 0
  2364. var types int64 = 0
  2365. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2366. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2367. if temp[1] == "1" {
  2368. advice_id = id
  2369. project_id = 0
  2370. } else if temp[1] == "2" {
  2371. advice_id = 0
  2372. project_id = id
  2373. }
  2374. info := &models.HisOrderInfo{
  2375. OrderNumber: order.Number,
  2376. FeedetlSn: item.Bkf500,
  2377. UploadDate: time.Now().Unix(),
  2378. AdviceId: advice_id,
  2379. DetItemFeeSumamt: item.Akc264,
  2380. Cnt: item.Akc226,
  2381. Pric: float64(item.Akc225),
  2382. PatientId: patient_id,
  2383. Status: 1,
  2384. ChrgitmLv: item.Aka065,
  2385. Mtime: time.Now().Unix(),
  2386. Ctime: time.Now().Unix(),
  2387. UserOrgId: adminUser.CurrentOrgId,
  2388. OrderId: order.ID,
  2389. ProjectId: project_id,
  2390. Type: types,
  2391. OverPricPsnPay: item.Akc268,
  2392. AllowReimburse: item.Cka319,
  2393. }
  2394. service.CreateOrderInfo(info)
  2395. }
  2396. }
  2397. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2398. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2399. var total float64
  2400. for _, item := range prescriptions {
  2401. if item.Type == 1 { //药品
  2402. for _, subItem := range item.HisDoctorAdviceInfo {
  2403. total = total + (subItem.Price * subItem.PrescribingNumber)
  2404. }
  2405. }
  2406. if item.Type == 2 { //项目
  2407. for _, subItem := range item.HisPrescriptionProject {
  2408. total = total + (subItem.Price * float64(subItem.Count))
  2409. }
  2410. }
  2411. }
  2412. for _, item := range prescriptions {
  2413. for _, subItem := range item.HisAdditionalCharge {
  2414. total = total + (subItem.Price * float64(subItem.Count))
  2415. }
  2416. }
  2417. total, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
  2418. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2419. if ret4 == 0 {
  2420. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2421. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2422. if tempPatient.ID == patient_id {
  2423. 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)
  2424. var dat map[string]interface{}
  2425. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2426. fmt.Println(dat)
  2427. } else {
  2428. fmt.Println(err)
  2429. }
  2430. userJSONBytes, _ := json.Marshal(dat)
  2431. var res ResultTwo
  2432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2433. utils.ErrorLog("解析失败:%v", err)
  2434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2435. return
  2436. }
  2437. if res.Transreturncode == "00000000" {
  2438. order.OrderStatus = 2
  2439. order.Status = 1
  2440. order.PayWay = pay_way
  2441. order.PayPrice = pay_price
  2442. order.PayCardNo = pay_card_no
  2443. order.PsnNo = health_card_no
  2444. order.DiscountPrice = discount_price
  2445. order.PreferentialPrice = preferential_price
  2446. order.RealityPrice = reality_price
  2447. order.FoundPrice = found_price
  2448. order.MedicalInsurancePrice = medical_insurance_price
  2449. order.PrivatePrice = private_price
  2450. order.Modify = admin_user_id
  2451. order.MedfeeSumamt = res.Transbody.Akc264
  2452. order.SetlId = res.Transbody.Ckc618
  2453. order.FundPaySumamt = res.Transbody.Akb068
  2454. order.AcctPay = res.Transbody.Akb066
  2455. order.PsnCashPay = res.Transbody.Akb067
  2456. order.PsnPartAmt = res.Transbody.Akb067
  2457. order.AccountPrice = res.Transbody.Aae240
  2458. order.MzNumber = mz_number
  2459. order.YiliaoNumber = yiliao_number
  2460. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2461. detailStrOne := string(setlDetailOne)
  2462. order.SzChargeInfo = detailStrOne
  2463. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2464. detailStrTwo := string(setlDetailTwo)
  2465. order.SzProjectInfo = detailStrTwo
  2466. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2467. detailStrThree := string(setlDetailThree)
  2468. order.SzMedicineInsuranceInfo = detailStrThree
  2469. order.Cainfo = result_three
  2470. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2471. err = service.UpDateOrderTwo(order)
  2472. c.ServeSuccessJSON(map[string]interface{}{
  2473. "msg": "结算成功",
  2474. })
  2475. } else {
  2476. //结算报错
  2477. errlog := &models.HisOrderError{
  2478. UserOrgId: adminUser.CurrentOrgId,
  2479. Ctime: time.Now().Unix(),
  2480. Mtime: time.Now().Unix(),
  2481. Number: chrg_bchno,
  2482. ErrMsg: res.Transreturnmessage,
  2483. Status: 1,
  2484. PatientId: patient_id,
  2485. RecordTime: recordDateTime,
  2486. Stage: 6,
  2487. }
  2488. service.CreateErrMsgLog(errlog)
  2489. c.ServeSuccessJSON(map[string]interface{}{
  2490. "failed_code": -10,
  2491. "msg": res.Transreturnmessage,
  2492. })
  2493. }
  2494. } else {
  2495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2496. return
  2497. }
  2498. } else {
  2499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2500. return
  2501. }
  2502. } else {
  2503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2504. return
  2505. }
  2506. }
  2507. //func (c *SZHisApiController) GetSettleInfo() {
  2508. // pay_way, _ := c.GetInt64("pay_way")
  2509. // pay_price, _ := c.GetFloat("pay_price")
  2510. // pay_card_no := c.GetString("pay_card_no")
  2511. // discount_price, _ := c.GetFloat("discount_price")
  2512. // preferential_price, _ := c.GetFloat("preferential_price")
  2513. // reality_price, _ := c.GetFloat("reality_price")
  2514. // found_price, _ := c.GetFloat("found_price")
  2515. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2516. // private_price, _ := c.GetFloat("private_price")
  2517. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2518. // patient_id, _ := c.GetInt64("id")
  2519. // record_time := c.GetString("record_time")
  2520. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2521. // timestamp := time.Now().Unix()
  2522. // tempTime := time.Unix(timestamp, 0)
  2523. // timeFormat := tempTime.Format("20060102150405")
  2524. // chrgBchno := rand.Intn(10000) + 1000
  2525. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  2526. // adminUser := c.GetAdminUserInfo()
  2527. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2528. // month := time.Unix(1557042972, 0).Format("1")
  2529. // year := time.Now().Format("2006")
  2530. // month = time.Now().Format("01")
  2531. // day := time.Now().Format("02")
  2532. //
  2533. // timeLayout := "2006-01-02"
  2534. // loc, _ := time.LoadLocation("Local")
  2535. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2536. // fmt.Println(err)
  2537. // if err != nil {
  2538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2539. // return
  2540. // }
  2541. // recordDateTime := theTime.Unix()
  2542. //
  2543. // var prescriptions []*models.HisPrescription
  2544. //
  2545. // var start_time int64
  2546. // var end_time int64
  2547. //
  2548. // if settle_accounts_type == 1 { //日结
  2549. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2550. //
  2551. // } else { //月结
  2552. // start_time_str := c.GetString("start_time")
  2553. // end_time_str := c.GetString("end_time")
  2554. // timeLayout := "2006-01-02"
  2555. // loc, _ := time.LoadLocation("Local")
  2556. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2557. // if err != nil {
  2558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2559. // return
  2560. // }
  2561. // recordStartTime := theStartTime.Unix()
  2562. // start_time = recordStartTime
  2563. //
  2564. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2565. // if err != nil {
  2566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2567. // return
  2568. // }
  2569. // recordEndTime := theEndTime.Unix()
  2570. // end_time = recordEndTime
  2571. //
  2572. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2573. // }
  2574. //
  2575. // var ids []int64
  2576. // for _, item := range prescriptions {
  2577. // ids = append(ids, item.ID)
  2578. // }
  2579. //
  2580. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2581. //
  2582. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2583. //
  2584. // adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2585. // his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2586. // mz_number := his.Number
  2587. // number := miConfig.Code + year + month + day +
  2588. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2589. // var doctor_name string
  2590. // var doctor_code string
  2591. // var drug_doctor_code string
  2592. // drug_doctor_code = adminRole_two.DoctorCode
  2593. // drug_doctor_name := adminRole_two.UserName
  2594. //
  2595. // if adminRole.ID == 0 {
  2596. // doctor_name = "黄亦轩"
  2597. // doctor_code = "1"
  2598. // } else {
  2599. // doctor_name = adminRole.UserName
  2600. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  2601. // }
  2602. //
  2603. // verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2604. // //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2605. // //version_code := "V0.3"
  2606. // var customs []*models.CustomDetail
  2607. // for _, item := range prescriptions {
  2608. // if item.Type == 1 { //药品
  2609. // for _, subItem := range item.HisDoctorAdviceInfo {
  2610. // fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2611. //
  2612. // if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2613. // _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2614. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2615. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2616. // temp := strings.Split(subItem.FeedetlSn, "-")
  2617. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2618. //
  2619. // cus := &models.CustomDetail{
  2620. // PrescriptionNumber: chrg_bchno,
  2621. // OrderType: "1",
  2622. // ChargeSerialNumber: newFl,
  2623. // Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2624. // CodeName: subItem.BaseDrugLib.DrugName,
  2625. // Flag: "1",
  2626. // Price: price,
  2627. // Count: subItem.PrescribingNumber,
  2628. // ChargeOrderDate: year + month + day,
  2629. // DoctorCode: doctor_code,
  2630. // Total: detItemFeeSumamt,
  2631. // DoseCode: dose_code,
  2632. // Spec: subItem.BaseDrugLib.DrugSpec,
  2633. // }
  2634. // customs = append(customs, cus)
  2635. // }
  2636. // }
  2637. // }
  2638. //
  2639. // if item.Type == 2 { //项目
  2640. // for _, subItem := range item.HisPrescriptionProject {
  2641. // if len(subItem.HisProject.MedicalCode) > 0 {
  2642. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2643. //
  2644. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2645. // temp := strings.Split(subItem.FeedetlSn, "-")
  2646. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2647. //
  2648. // cus := &models.CustomDetail{
  2649. // PrescriptionNumber: chrg_bchno,
  2650. // OrderType: "1",
  2651. // ChargeSerialNumber: newFl,
  2652. // Code: subItem.HisProject.MedicalCode,
  2653. // CodeName: subItem.HisProject.ProjectName,
  2654. // Flag: "1",
  2655. // Price: subItem.Price,
  2656. // Count: count,
  2657. // ChargeOrderDate: year + month + day,
  2658. // DoctorCode: doctor_code,
  2659. // Total: detItemFeeSumamt,
  2660. // DoseCode: "",
  2661. // Spec: "次",
  2662. // }
  2663. // customs = append(customs, cus)
  2664. // }
  2665. // }
  2666. // }
  2667. // //
  2668. // //for _, subItem := range item.HisAdditionalCharge {
  2669. // // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2670. // // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2671. // //
  2672. // // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2673. // // cus := &models.CustomDetail{
  2674. // // PrescriptionNumber: chrg_bchno,
  2675. // // OrderType: "1",
  2676. // // ChargeSerialNumber: subItem.FeedetlSn,
  2677. // // Code: subItem.XtHisAddtionConfig.Code,
  2678. // // CodeName: subItem.XtHisAddtionConfig.Name,
  2679. // // Flag: "1",
  2680. // // Price: subItem.Price,
  2681. // // Count: count,
  2682. // // ChargeOrderDate: year + month + day,
  2683. // // DoctorCode: doctor_code,
  2684. // // Total: detItemFeeSumamt,
  2685. // // DoseCode: "",
  2686. // // Spec: subItem.XtHisAddtionConfig.,
  2687. // // }
  2688. // // customs = append(customs, cus)
  2689. // // }
  2690. // //}
  2691. // }
  2692. //
  2693. // var pagesize int = 50
  2694. // var start int = 1
  2695. // var stop int
  2696. // var pagecount int
  2697. // var curpage int
  2698. // var isSuccess bool = true
  2699. // //总页数,向上取整,注意除之前要先转换类型为float64
  2700. // pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2701. //
  2702. // var ress []*Result
  2703. // for curpage = 1; curpage <= pagecount; curpage++ {
  2704. // if curpage == 1 {
  2705. // start = 1
  2706. // } else {
  2707. // start = (curpage-1)*pagesize + 1
  2708. // }
  2709. // stop = curpage * pagesize
  2710. // if stop > len(customs) {
  2711. // stop = len(customs)
  2712. // }
  2713. // result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2714. // fmt.Println(result)
  2715. //
  2716. // var dat map[string]interface{}
  2717. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2718. // fmt.Println(dat)
  2719. // } else {
  2720. // fmt.Println(err)
  2721. // }
  2722. //
  2723. // userJSONBytes, _ := json.Marshal(dat)
  2724. //
  2725. // var res Result
  2726. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2727. // utils.ErrorLog("解析失败:%v", err)
  2728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2729. // return
  2730. // }
  2731. // if res.Transreturncode == "00000000" {
  2732. // ress = append(ress, &res)
  2733. // } else {
  2734. // isSuccess = false
  2735. // errlog := &models.HisOrderError{
  2736. // UserOrgId: adminUser.CurrentOrgId,
  2737. // Ctime: time.Now().Unix(),
  2738. // Mtime: time.Now().Unix(),
  2739. // Number: chrg_bchno,
  2740. // ErrMsg: res.Transreturnmessage,
  2741. // Status: 1,
  2742. // PatientId: patient_id,
  2743. // RecordTime: recordDateTime,
  2744. // Stage: 4,
  2745. // }
  2746. // service.CreateErrMsgLog(errlog)
  2747. // c.ServeSuccessJSON(map[string]interface{}{
  2748. // "failed_code": -10,
  2749. // "msg": res.Transreturnmessage,
  2750. // })
  2751. // return
  2752. // }
  2753. // //设置变量,根据变量的值来判断上传是否成功
  2754. // }
  2755. // if isSuccess == true {
  2756. // order := &models.HisOrder{
  2757. // UserOrgId: adminUser.CurrentOrgId,
  2758. // HisPatientId: 0,
  2759. // PatientId: patient_id,
  2760. // SettleAccountsDate: recordDateTime,
  2761. // Ctime: time.Now().Unix(),
  2762. // Mtime: time.Now().Unix(),
  2763. // Status: 1,
  2764. // Number: chrg_bchno,
  2765. // Infcode: 0,
  2766. // WarnMsg: "",
  2767. // Cainfo: "",
  2768. // ErrMsg: "",
  2769. // RespondTime: "",
  2770. // InfRefmsgid: "",
  2771. // OrderStatus: 1,
  2772. // IsMedicineInsurance: 1,
  2773. // SettleType: settle_accounts_type,
  2774. // SettleStartTime: start_time,
  2775. // SettleEndTime: end_time,
  2776. // Creator: admin_user_id,
  2777. // Modify: admin_user_id,
  2778. // OrgSetlNumber: number,
  2779. // }
  2780. // data, _ := json.Marshal(ress)
  2781. // order.DetailLog = string(data)
  2782. //
  2783. // err = service.CreateOrder(order)
  2784. // if err != nil {
  2785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2786. // return
  2787. // }
  2788. //
  2789. // for _, subItem := range ress {
  2790. // for _, item := range subItem.Transbody.Outputlist {
  2791. //
  2792. // temp := strings.Split(item.Bkf500, "-")
  2793. // var advice_id int64 = 0
  2794. // var project_id int64 = 0
  2795. // var types int64 = 0
  2796. //
  2797. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2798. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2799. //
  2800. // if temp[1] == "1" {
  2801. // advice_id = id
  2802. // project_id = 0
  2803. // } else if temp[1] == "2" {
  2804. // advice_id = 0
  2805. // project_id = id
  2806. // }
  2807. //
  2808. // info := &models.HisOrderInfo{
  2809. // OrderNumber: order.Number,
  2810. // FeedetlSn: item.Bkf500,
  2811. // UploadDate: time.Now().Unix(),
  2812. // AdviceId: advice_id,
  2813. // DetItemFeeSumamt: item.Akc264,
  2814. // Cnt: item.Akc226,
  2815. // Pric: float64(item.Akc225),
  2816. // PatientId: patient_id,
  2817. // Status: 1,
  2818. // ChrgitmLv: item.Aka065,
  2819. // Mtime: time.Now().Unix(),
  2820. // Ctime: time.Now().Unix(),
  2821. // UserOrgId: adminUser.CurrentOrgId,
  2822. // OrderId: order.ID,
  2823. // ProjectId: project_id,
  2824. // Type: types,
  2825. //
  2826. // OverPricPsnPay: item.Akc268,
  2827. // AllowReimburse: item.Cka319,
  2828. // }
  2829. // service.CreateOrderInfo(info)
  2830. //
  2831. // }
  2832. // }
  2833. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2834. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2835. // var total float64
  2836. // for _, item := range prescriptions {
  2837. // if item.Type == 1 { //药品
  2838. // for _, subItem := range item.HisDoctorAdviceInfo {
  2839. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2840. // }
  2841. // }
  2842. // if item.Type == 2 { //项目
  2843. // for _, subItem := range item.HisPrescriptionProject {
  2844. // total = total + (subItem.Price * float64(subItem.Count))
  2845. // }
  2846. // }
  2847. // }
  2848. // for _, item := range prescriptions {
  2849. // for _, subItem := range item.HisAdditionalCharge {
  2850. // total = total + (subItem.Price * float64(subItem.Count))
  2851. // }
  2852. // }
  2853. //
  2854. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2855. // if ret4 == 0 {
  2856. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2857. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2858. // if tempPatient.ID == patient_id {
  2859. //
  2860. // 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)
  2861. // var dat map[string]interface{}
  2862. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2863. // fmt.Println(dat)
  2864. // } else {
  2865. // fmt.Println(err)
  2866. // }
  2867. // userJSONBytes, _ := json.Marshal(dat)
  2868. // var res ResultTwo
  2869. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2870. // utils.ErrorLog("解析失败:%v", err)
  2871. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2872. // return
  2873. // }
  2874. //
  2875. // if res.Transreturncode == "00000000" {
  2876. // order.OrderStatus = 2
  2877. // order.PayWay = pay_way
  2878. // order.PayPrice = pay_price
  2879. // order.PayCardNo = pay_card_no
  2880. // order.DiscountPrice = discount_price
  2881. // order.PreferentialPrice = preferential_price
  2882. // order.RealityPrice = reality_price
  2883. // order.FoundPrice = found_price
  2884. // order.MedicalInsurancePrice = medical_insurance_price
  2885. // order.PrivatePrice = private_price
  2886. // order.Modify = admin_user_id
  2887. // order.MedfeeSumamt = res.Transbody.Akc264
  2888. // order.SetlId = res.Transbody.Ckc618
  2889. // order.FundPaySumamt = res.Transbody.Akb068
  2890. // order.AcctPay = res.Transbody.Akb066
  2891. // order.PsnCashPay = res.Transbody.Akb067
  2892. // order.PsnPartAmt = res.Transbody.Akb067
  2893. // order.AccountPrice = res.Transbody.Aae240
  2894. // order.MzNumber = mz_number
  2895. // order.YiliaoNumber = yiliao_number
  2896. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2897. // detailStrOne := string(setlDetailOne)
  2898. // order.SzChargeInfo = detailStrOne
  2899. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2900. // detailStrTwo := string(setlDetailTwo)
  2901. // order.SzProjectInfo = detailStrTwo
  2902. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2903. // detailStrThree := string(setlDetailThree)
  2904. // order.SzMedicineInsuranceInfo = detailStrThree
  2905. // order.Cainfo = result_three
  2906. // err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2907. // err = service.UpDateOrderTwo(order)
  2908. // c.ServeSuccessJSON(map[string]interface{}{
  2909. // "msg": "结算成功",
  2910. // })
  2911. // } else {
  2912. // //结算报错
  2913. // errlog := &models.HisOrderError{
  2914. // UserOrgId: adminUser.CurrentOrgId,
  2915. // Ctime: time.Now().Unix(),
  2916. // Mtime: time.Now().Unix(),
  2917. // Number: chrg_bchno,
  2918. // ErrMsg: res.Transreturnmessage,
  2919. // Status: 1,
  2920. // PatientId: patient_id,
  2921. // RecordTime: recordDateTime,
  2922. // Stage: 6,
  2923. // }
  2924. // service.CreateErrMsgLog(errlog)
  2925. // c.ServeSuccessJSON(map[string]interface{}{
  2926. // "failed_code": -10,
  2927. // "msg": res.Transreturnmessage,
  2928. // })
  2929. // }
  2930. // } else {
  2931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2932. // return
  2933. // }
  2934. // } else {
  2935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2936. // return
  2937. // }
  2938. // } else {
  2939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2940. // return
  2941. // }
  2942. //}
  2943. //结算
  2944. //func (c *SZHisApiController) GetSettleInfo() {
  2945. // patient_id, _ := c.GetInt64("id")
  2946. // order_id, _ := c.GetInt64("order_id")
  2947. // record_time := c.GetString("record_time")
  2948. // pay_way, _ := c.GetInt64("pay_way")
  2949. // pay_price, _ := c.GetFloat("pay_price")
  2950. // pay_card_no := c.GetString("pay_card_no")
  2951. // discount_price, _ := c.GetFloat("discount_price")
  2952. // preferential_price, _ := c.GetFloat("preferential_price")
  2953. // reality_price, _ := c.GetFloat("reality_price")
  2954. // found_price, _ := c.GetFloat("found_price")
  2955. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2956. // private_price, _ := c.GetFloat("private_price")
  2957. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2958. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2959. //
  2960. // timeLayout := "2006-01-02"
  2961. // loc, _ := time.LoadLocation("Local")
  2962. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2963. // if err != nil {
  2964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2965. // return
  2966. // }
  2967. // recordDateTime := theTime.Unix()
  2968. // adminUser := c.GetAdminUserInfo()
  2969. //
  2970. // var prescriptions []*models.HisPrescription
  2971. //
  2972. // data := make(map[string]interface{})
  2973. // if settle_accounts_type == 1 { //日结
  2974. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2975. // data["pre"] = prescriptions
  2976. //
  2977. // } else { //月结
  2978. // start_time_str := c.GetString("start_time")
  2979. // end_time_str := c.GetString("end_time")
  2980. // timeLayout := "2006-01-02"
  2981. // loc, _ := time.LoadLocation("Local")
  2982. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2983. // if err != nil {
  2984. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2985. // return
  2986. // }
  2987. // recordStartTime := theStartTime.Unix()
  2988. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2989. // if err != nil {
  2990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2991. // return
  2992. // }
  2993. // recordEndTime := theEndTime.Unix()
  2994. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2995. // data["pre"] = prescriptions
  2996. //
  2997. // }
  2998. //
  2999. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3000. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3001. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3002. // strconv.FormatInt(his.PatientId, 10)
  3003. //
  3004. // order_src, _ := service.GetHisOrderByID(order_id)
  3005. //
  3006. // if order_src.ID == 0 {
  3007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3008. // return
  3009. // }
  3010. //
  3011. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3012. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3013. // if order_src.OrderStatus != 2 {
  3014. // var total float64
  3015. // for _, item := range prescriptions {
  3016. // if item.Type == 1 { //药品
  3017. // for _, subItem := range item.HisDoctorAdviceInfo {
  3018. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3019. // }
  3020. // }
  3021. // if item.Type == 2 { //项目
  3022. // for _, subItem := range item.HisPrescriptionProject {
  3023. // total = total + (subItem.Price * float64(subItem.Count))
  3024. // }
  3025. // }
  3026. // }
  3027. //
  3028. // for _, item := range prescriptions {
  3029. // for _, subItem := range item.HisAdditionalCharge {
  3030. // total = total + (subItem.Price * float64(subItem.Count))
  3031. // }
  3032. // }
  3033. //
  3034. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3035. //
  3036. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3037. //
  3038. // var drug_doctor string
  3039. // drug_doctor = adminRole_two.DoctorCode
  3040. // drug_doctor_name := adminRole_two.UserName
  3041. // //结算流程
  3042. // var doctor_name string
  3043. // var doctor_code string
  3044. // if roles.ID == 0 {
  3045. // doctor_name = "黄亦轩"
  3046. // doctor_code = "1010"
  3047. // } else {
  3048. // doctor_name = roles.UserName
  3049. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  3050. // }
  3051. // number := order_src.OrgSetlNumber
  3052. // mz_number := his.Number
  3053. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  3054. //
  3055. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  3056. // //version_code := "V0.3"
  3057. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  3058. // yiliao_number := his.YiliaoNumber
  3059. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  3060. // var dat map[string]interface{}
  3061. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  3062. // fmt.Println(dat)
  3063. // } else {
  3064. // fmt.Println(err)
  3065. // }
  3066. // userJSONBytes, _ := json.Marshal(dat)
  3067. // var res ResultTwo
  3068. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3069. // utils.ErrorLog("解析失败:%v", err)
  3070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3071. // return
  3072. // }
  3073. //
  3074. // if res.Transreturncode == "00000000" {
  3075. // order_src.OrderStatus = 2
  3076. // order_src.PayWay = pay_way
  3077. // order_src.PayPrice = pay_price
  3078. // order_src.PayCardNo = pay_card_no
  3079. // order_src.DiscountPrice = discount_price
  3080. // order_src.PreferentialPrice = preferential_price
  3081. // order_src.RealityPrice = reality_price
  3082. // order_src.FoundPrice = found_price
  3083. // order_src.MedicalInsurancePrice = medical_insurance_price
  3084. // order_src.PrivatePrice = private_price
  3085. // order_src.Creator = order_src.Creator
  3086. // order_src.Modify = roles.ID
  3087. // order_src.MedfeeSumamt = res.Transbody.Akc264
  3088. // order_src.SetlId = res.Transbody.Ckc618
  3089. // order_src.FundPaySumamt = res.Transbody.Akb068
  3090. // order_src.AcctPay = res.Transbody.Akb066
  3091. // order_src.PsnCashPay = res.Transbody.Akb067
  3092. // order_src.PsnPartAmt = res.Transbody.Akb067
  3093. // order_src.AccountPrice = res.Transbody.Aae240
  3094. // order_src.MzNumber = mz_number
  3095. // order_src.YiliaoNumber = yiliao_number
  3096. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  3097. // detailStrOne := string(setlDetailOne)
  3098. // order_src.SzChargeInfo = detailStrOne
  3099. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  3100. // detailStrTwo := string(setlDetailTwo)
  3101. // order_src.SzProjectInfo = detailStrTwo
  3102. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  3103. // detailStrThree := string(setlDetailThree)
  3104. // order_src.SzMedicineInsuranceInfo = detailStrThree
  3105. // order_src.Cainfo = result_three
  3106. //
  3107. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  3108. // err = service.UpDateOrder(order_src)
  3109. //
  3110. // c.ServeSuccessJSON(map[string]interface{}{
  3111. // "msg": "结算成功",
  3112. // })
  3113. // } else {
  3114. // //version_code := "0.03"
  3115. // c.ServeSuccessJSON(map[string]interface{}{
  3116. // "failed_code": -10,
  3117. // "msg": res.Transreturnmessage,
  3118. // })
  3119. //
  3120. // }
  3121. // } else {
  3122. //
  3123. // //错误提示
  3124. //
  3125. // }
  3126. // } else {
  3127. // //错误提示
  3128. //
  3129. // }
  3130. //}
  3131. //当月退费
  3132. func (c *SZHisApiController) Refund() {
  3133. order_id, _ := c.GetInt64("order_id")
  3134. record_time := c.GetString("record_time")
  3135. //patient_id, _ := c.GetInt64("patient_id")
  3136. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3137. admin_user_id, _ := c.GetInt64("admin_user_id")
  3138. timeLayout := "2006-01-02"
  3139. loc, _ := time.LoadLocation("Local")
  3140. adminUser := c.GetAdminUserInfo()
  3141. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3142. fmt.Println(err)
  3143. if err != nil {
  3144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3145. return
  3146. }
  3147. recordDateTime := theTime.Unix()
  3148. fmt.Println(recordDateTime)
  3149. var order models.HisOrder
  3150. order, _ = service.GetHisOrderByID(order_id)
  3151. if order.ID == 0 {
  3152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3153. return
  3154. }
  3155. //his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, theTime.Unix())
  3156. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3158. //结算流程
  3159. var doctor_name string
  3160. var doctor_code string
  3161. if roles.ID == 0 {
  3162. doctor_name = "管理员"
  3163. doctor_code = "01"
  3164. } else {
  3165. doctor_name = roles.UserName
  3166. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3167. }
  3168. month := time.Unix(1557042972, 0).Format("1")
  3169. year := time.Now().Format("2006")
  3170. month = time.Now().Format("01")
  3171. day := time.Now().Format("02")
  3172. //number := miConfig.Code + year + month + day + "1367866"
  3173. number := miConfig.Code + year + month + day +
  3174. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  3175. //number := miConfig.Code + year + month + day + "1590003"
  3176. //流水号
  3177. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3178. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  3179. //version_code := "V0.3"
  3180. //
  3181. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  3182. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3183. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3184. var customs []*models.CustomDetail
  3185. for _, item := range order_infos {
  3186. cus := &models.CustomDetail{
  3187. PrescriptionNumber: item.OrderNumber,
  3188. ChargeSerialNumber: item.FeedetlSn,
  3189. }
  3190. customs = append(customs, cus)
  3191. }
  3192. if config.IsOpen == 1 { //对接了医保,走医保流程
  3193. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  3194. fmt.Println(result)
  3195. var dat map[string]interface{}
  3196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3197. fmt.Println(dat)
  3198. } else {
  3199. fmt.Println(err)
  3200. }
  3201. userJSONBytes, _ := json.Marshal(dat)
  3202. var res ResultThree
  3203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3204. utils.ErrorLog("解析失败:%v", err)
  3205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3206. return
  3207. }
  3208. if res.Transreturncode == "00000000" {
  3209. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  3210. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId)
  3211. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3212. c.ServeSuccessJSON(map[string]interface{}{
  3213. "msg": "退费成功",
  3214. })
  3215. } else {
  3216. c.ServeSuccessJSON(map[string]interface{}{
  3217. "failed_code": -10,
  3218. "msg": res.Transreturnmessage,
  3219. })
  3220. }
  3221. }
  3222. }
  3223. //跨月退费
  3224. func (c *SZHisApiController) MonthRefund() {
  3225. order_id, _ := c.GetInt64("order_id")
  3226. record_time := c.GetString("record_time")
  3227. patient_id, _ := c.GetInt64("patient_id")
  3228. admin_user_id, _ := c.GetInt64("admin_user_id")
  3229. timeLayout := "2006-01-02"
  3230. loc, _ := time.LoadLocation("Local")
  3231. adminUser := c.GetAdminUserInfo()
  3232. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3233. fmt.Println(err)
  3234. if err != nil {
  3235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3236. return
  3237. }
  3238. recordDateTime := theTime.Unix()
  3239. var order models.HisOrder
  3240. order, _ = service.GetHisOrderByID(order_id)
  3241. if order.ID == 0 {
  3242. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3243. }
  3244. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3245. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3246. //结算流程
  3247. var doctor_name string
  3248. var doctor_code string
  3249. if roles.ID == 0 {
  3250. doctor_name = "管理员"
  3251. doctor_code = "01"
  3252. } else {
  3253. doctor_name = roles.UserName
  3254. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3255. }
  3256. month := time.Unix(1557042972, 0).Format("1")
  3257. year := time.Now().Format("2006")
  3258. month = time.Now().Format("01")
  3259. day := time.Now().Format("02")
  3260. //流水号
  3261. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3262. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  3263. version_code := "0.03"
  3264. fmt.Println(number_two)
  3265. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  3266. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3267. if config.IsOpen == 1 { //对接了医保,走医保流程
  3268. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3269. fmt.Println(result)
  3270. var dat map[string]interface{}
  3271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3272. fmt.Println(dat)
  3273. } else {
  3274. fmt.Println(err)
  3275. }
  3276. userJSONBytes, _ := json.Marshal(dat)
  3277. var res ResultThree
  3278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3279. utils.ErrorLog("解析失败:%v", err)
  3280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3281. return
  3282. }
  3283. if res.Transreturncode == "00000000" {
  3284. c.ServeSuccessJSON(map[string]interface{}{
  3285. "msg": "退费成功",
  3286. })
  3287. } else {
  3288. }
  3289. }
  3290. }
  3291. //查询
  3292. func (c *SZHisApiController) GetSettleAccounts() {
  3293. order_id, _ := c.GetInt64("order_id")
  3294. record_time := c.GetString("record_time")
  3295. patient_id, _ := c.GetInt64("patient_id")
  3296. admin_user_id, _ := c.GetInt64("admin_user_id")
  3297. timeLayout := "2006-01-02"
  3298. loc, _ := time.LoadLocation("Local")
  3299. adminUser := c.GetAdminUserInfo()
  3300. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3301. fmt.Println(err)
  3302. if err != nil {
  3303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3304. return
  3305. }
  3306. recordDateTime := theTime.Unix()
  3307. fmt.Println(recordDateTime)
  3308. var order models.HisOrder
  3309. order, _ = service.GetHisOrderByID(order_id)
  3310. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  3311. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3312. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3313. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3314. yiliao_leibie := ""
  3315. switch his.MedicalTreatmentType {
  3316. case 11:
  3317. yiliao_leibie = "普通门诊"
  3318. break
  3319. case 12:
  3320. yiliao_leibie = "家庭通道"
  3321. break
  3322. case 13:
  3323. yiliao_leibie = "门诊大病"
  3324. break
  3325. case 14:
  3326. yiliao_leibie = "重疾特药"
  3327. break
  3328. case 15:
  3329. yiliao_leibie = "门诊慢病"
  3330. break
  3331. case 16:
  3332. yiliao_leibie = "门诊特检"
  3333. break
  3334. case 17:
  3335. yiliao_leibie = "健康体检"
  3336. break
  3337. case 18:
  3338. yiliao_leibie = "预防接种"
  3339. break
  3340. case 19:
  3341. yiliao_leibie = "门诊输血"
  3342. break
  3343. case 91:
  3344. yiliao_leibie = "新冠肺炎门诊"
  3345. break
  3346. }
  3347. //departments, _ := service.Get(patientPrescription.Departments)
  3348. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3349. if order.ID == 0 {
  3350. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3352. return
  3353. }
  3354. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3355. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3356. //结算流程
  3357. var doctor_name string
  3358. var doctor_code string
  3359. if roles.ID == 0 {
  3360. doctor_name = "管理员"
  3361. doctor_code = "01"
  3362. } else {
  3363. doctor_name = roles.UserName
  3364. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3365. }
  3366. //month := time.Unix(1557042972, 0).Format("1")
  3367. //year := time.Now().Format("2006")
  3368. //month = time.Now().Format("01")
  3369. //day := time.Now().Format("02")
  3370. //流水号
  3371. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3372. //fmt.Println(number_two)
  3373. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3374. //version_code := "V0.3"
  3375. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  3376. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3377. if config.IsOpen == 1 { //对接了医保,走医保流程
  3378. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3379. fmt.Println(result)
  3380. var dat map[string]interface{}
  3381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3382. fmt.Println(dat)
  3383. } else {
  3384. fmt.Println(err)
  3385. }
  3386. userJSONBytes, _ := json.Marshal(dat)
  3387. var res ResultFour
  3388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3389. utils.ErrorLog("解析失败:%v", err)
  3390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3391. return
  3392. }
  3393. if res.Transreturncode == "00000000" {
  3394. var dat2 map[string]interface{}
  3395. if err := json.Unmarshal([]byte(his.PatientInfo), &dat2); err == nil {
  3396. fmt.Println(dat2)
  3397. } else {
  3398. fmt.Println(err)
  3399. }
  3400. userJSONBytes2, _ := json.Marshal(dat2)
  3401. var res2 ResultMZ001
  3402. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3403. utils.ErrorLog("解析失败:%v", err)
  3404. }
  3405. c.ServeSuccessJSON(map[string]interface{}{
  3406. "result": res,
  3407. "org_name": miConfig.OrgName,
  3408. "org_code": miConfig.Code,
  3409. "patient_name": patient.Name,
  3410. "doctor_code": adminRole_two.DoctorCode,
  3411. "doctor_name": doctor_name,
  3412. "health_card_no": order.PsnNo,
  3413. "health_card_no_two": res2.Transbody.Aaz500,
  3414. "order_number": order.Number,
  3415. "department": departments.Name,
  3416. "yiliao_leibie": yiliao_leibie,
  3417. "before_money": res2.Transbody.Aae240,
  3418. "after_money": order.AccountPrice,
  3419. })
  3420. } else {
  3421. c.ServeSuccessJSON(map[string]interface{}{
  3422. "failed_code": -10,
  3423. "msg": res.Transreturnmessage,
  3424. })
  3425. }
  3426. }
  3427. }
  3428. //费用录入取消
  3429. func (c *SZHisApiController) CancelOrderDetail() {
  3430. order_id, _ := c.GetInt64("order_id")
  3431. record_time := c.GetString("record_time")
  3432. patient_id, _ := c.GetInt64("patient_id")
  3433. admin_user_id, _ := c.GetInt64("admin_user_id")
  3434. timeLayout := "2006-01-02"
  3435. loc, _ := time.LoadLocation("Local")
  3436. adminUser := c.GetAdminUserInfo()
  3437. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3438. fmt.Println(err)
  3439. if err != nil {
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3441. return
  3442. }
  3443. recordDateTime := theTime.Unix()
  3444. var order models.HisOrder
  3445. order, _ = service.GetHisOrderByID(order_id)
  3446. if order.ID == 0 {
  3447. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3448. }
  3449. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3450. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3451. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3452. //结算流程
  3453. var doctor_name string
  3454. var doctor_code string
  3455. if roles.ID == 0 {
  3456. doctor_name = "管理员"
  3457. doctor_code = "1001"
  3458. } else {
  3459. doctor_name = roles.UserName
  3460. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3461. }
  3462. var customs []*models.CustomDetail
  3463. for _, item := range order_infos {
  3464. cus := &models.CustomDetail{
  3465. PrescriptionNumber: item.OrderNumber,
  3466. ChargeSerialNumber: item.FeedetlSn,
  3467. }
  3468. customs = append(customs, cus)
  3469. }
  3470. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3471. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3472. var pagesize int = 50
  3473. var start int = 1
  3474. var stop int
  3475. var pagecount int
  3476. var curpage int
  3477. var isSuccess bool = true
  3478. var ress []*ResultFive
  3479. //总页数,向上取整,注意除之前要先转换类型为float64
  3480. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  3481. for curpage = 1; curpage <= pagecount; curpage++ {
  3482. if curpage == 1 {
  3483. start = 1
  3484. } else {
  3485. start = (curpage-1)*pagesize + 1
  3486. }
  3487. stop = curpage * pagesize
  3488. if stop > len(customs) {
  3489. stop = len(customs)
  3490. }
  3491. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  3492. fmt.Println(result)
  3493. var dat map[string]interface{}
  3494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3495. fmt.Println(dat)
  3496. } else {
  3497. fmt.Println(err)
  3498. }
  3499. userJSONBytes, _ := json.Marshal(dat)
  3500. var res ResultFive
  3501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3502. utils.ErrorLog("解析失败:%v", err)
  3503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3504. return
  3505. }
  3506. if res.Transreturncode == "00000000" {
  3507. ress = append(ress, &res)
  3508. } else {
  3509. isSuccess = false
  3510. //预结算报错
  3511. errlog := &models.HisOrderError{
  3512. UserOrgId: adminUser.CurrentOrgId,
  3513. Ctime: time.Now().Unix(),
  3514. Mtime: time.Now().Unix(),
  3515. ErrMsg: res.Transreturnmessage,
  3516. Status: 1,
  3517. PatientId: patient_id,
  3518. RecordTime: recordDateTime,
  3519. Stage: 11,
  3520. }
  3521. service.CreateErrMsgLog(errlog)
  3522. c.ServeSuccessJSON(map[string]interface{}{
  3523. "faild_code": -10,
  3524. "msg": res.Transreturnmessage,
  3525. })
  3526. return
  3527. }
  3528. }
  3529. if isSuccess == true {
  3530. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3531. c.ServeSuccessJSON(map[string]interface{}{
  3532. "msg": "撤销成功",
  3533. })
  3534. }
  3535. }
  3536. //获取verifyCode
  3537. func ReadCardGetCode(request string) (string, string) {
  3538. request = request + "|"
  3539. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3540. readCards := DllDef2.MustFindProc("iVerifyCode")
  3541. str := request
  3542. str3 := make([]byte, 256)
  3543. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3544. fmt.Println(":", string(str3))
  3545. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3546. if ret4 == 0 {
  3547. result := string(str3)
  3548. fmt.Println(result)
  3549. result_arr := strings.Split(result, "|")
  3550. verifyCode := result_arr[0] + "|" + result_arr[1]
  3551. versionCode := result_arr[2]
  3552. return verifyCode, versionCode
  3553. }
  3554. return "", ""
  3555. }
  3556. ////获取卡信息
  3557. func ReadBasCardGetNumber(request string) (string, string, string, string, string, error, int64) {
  3558. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3559. readCards := DllDef2.MustFindProc("iReadCardBas")
  3560. str := request
  3561. str3 := make([]byte, 1024)
  3562. fmt.Println(":", request)
  3563. fmt.Println(":", StrPtr(str))
  3564. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3565. fmt.Println(":", string(str3))
  3566. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3567. if ret4 == 0 {
  3568. result := string(str3)
  3569. fmt.Println(result)
  3570. result_arr := strings.Split(result, "|")
  3571. //医疗证号
  3572. yiliao_number := result_arr[12]
  3573. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3574. id_card_number := result_arr[1]
  3575. verifyCode := result_arr[11] + "|" + result_arr[13]
  3576. versionCode := result_arr[14]
  3577. health_card_no := result_arr[2]
  3578. return yiliao_number, id_card_number, verifyCode, versionCode, health_card_no, err, 0
  3579. }
  3580. return "", "", "", "", "", err, -10
  3581. }
  3582. //读卡
  3583. func ReadBasCard(request string) (string, string, error, int64) {
  3584. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3585. readCards := DllDef2.MustFindProc("iReadCardBas")
  3586. str := request
  3587. str3 := make([]byte, 1024)
  3588. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3589. fmt.Println(":", string(str3))
  3590. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3591. if ret4 == 0 {
  3592. result := string(str3)
  3593. result_arr := strings.Split(result, "|")
  3594. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3595. id_card_number := result_arr[1]
  3596. health_card_no := result_arr[2]
  3597. return id_card_number, health_card_no, err, 0
  3598. }
  3599. return "", "", err, -10
  3600. }
  3601. //
  3602. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  3603. //func ReadCardBasHSM(number string) string {
  3604. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3605. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  3606. // str := make([]byte, 256)
  3607. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  3608. // fmt.Println(":", string(str))
  3609. //
  3610. // result_arr := strings.Split(string(str), "|")
  3611. //
  3612. // if ret == 0 {
  3613. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  3614. // str2 := make([]byte, 256)
  3615. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  3616. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  3617. // fmt.Println(":", string(str2))
  3618. //
  3619. // if ret2 == 0 {
  3620. // result_arr := strings.Split(string(str2), "|")
  3621. //
  3622. // if result_arr[2] == "0" {
  3623. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  3624. // str4 := result_arr[4] + "|" + result_arr[5]
  3625. // str5 := make([]byte, 256)
  3626. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  3627. //
  3628. // if ret3 == 0 {
  3629. // return string(str5)
  3630. //
  3631. // } else {
  3632. // return ""
  3633. // }
  3634. // } else {
  3635. // return ""
  3636. // }
  3637. // }
  3638. // return ""
  3639. // }
  3640. // return ""
  3641. //
  3642. //}
  3643. //
  3644. ////1904卡鉴权
  3645. //func CardAuth(request string) string {
  3646. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3647. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  3648. // str := request
  3649. // str3 := make([]byte, 256)
  3650. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3651. // fmt.Println(":", string(str3))
  3652. //
  3653. // if ret4 == 0 {
  3654. // return string(str3)
  3655. // }
  3656. // return ""
  3657. //}
  3658. func (c *SZHisApiController) GetDrugList() {
  3659. adminUserInfo := c.GetAdminUserInfo()
  3660. orgId := adminUserInfo.CurrentOrgId
  3661. admin_user_id, _ := c.GetInt64("admin_user_id")
  3662. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3663. ids := c.GetString("ids")
  3664. stringarr := strings.Split(ids, ",")
  3665. idss := make([]int64, 0)
  3666. for _, item := range stringarr {
  3667. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3668. id := int64(itemsss)
  3669. idss = append(idss, id)
  3670. }
  3671. //批量获取
  3672. list, _ := service.GetBatchDrugList(idss)
  3673. //获取药品剂型
  3674. drugs, _ := service.GetDrugDosageForm(orgId)
  3675. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3676. var doctor_name string
  3677. var doctor_code string
  3678. doctor_name = roles.UserName
  3679. doctor_code = "1001"
  3680. var isSuccess bool = true
  3681. timeLayout := "20060102"
  3682. //这里就可以查看开始和结束了
  3683. for _, item := range list {
  3684. recordDate := time.Unix(item.RecordDate, 0).Format(timeLayout)
  3685. detail := &models.DrugDetail{
  3686. MedicalInsuranceNumber: item.SocialSecurityDirectoryCode,
  3687. Code: item.Code,
  3688. DrugName: item.DrugName,
  3689. DrugSpec: item.DrugSpec,
  3690. DrugDosageName: item.DrugDosageName,
  3691. ManufacturerName: item.ManufacturerName,
  3692. MinUnit: item.MinUnit,
  3693. RetailPrice: item.RetailPrice,
  3694. LastPrice: item.LastPrice,
  3695. LimitRemark: item.LimitRemark,
  3696. PrescriptionMark: strconv.FormatInt(item.PrescriptionMark, 10),
  3697. RecordDate: recordDate,
  3698. }
  3699. for _, it := range drugs {
  3700. if item.DrugDosageForm == it.Value {
  3701. detail.DrugDosageName = it.Code
  3702. }
  3703. }
  3704. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3705. var dat map[string]interface{}
  3706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3707. //fmt.Println(dat)
  3708. } else {
  3709. //fmt.Println(err)
  3710. }
  3711. userJSONBytes, _ := json.Marshal(dat)
  3712. var res Result
  3713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3714. utils.ErrorLog("解析失败:%v", err)
  3715. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3716. c.ServeSuccessJSON(map[string]interface{}{
  3717. "failed_code": -10,
  3718. "msg": res.Transreturnmessage,
  3719. })
  3720. return
  3721. }
  3722. if res.Transreturncode == "00000000" {
  3723. //更新备案状态
  3724. _, err := service.UpdateBaseDrugById(item.ID)
  3725. fmt.Println("err", err)
  3726. c.ServeSuccessJSON(map[string]interface{}{
  3727. "failed_code": -10,
  3728. "msg": res.Transreturnmessage,
  3729. })
  3730. return
  3731. }
  3732. fmt.Println(isSuccess)
  3733. c.ServeSuccessJSON(map[string]interface{}{
  3734. "failed_code": -10,
  3735. "msg": res.Transreturnmessage,
  3736. })
  3737. return
  3738. }
  3739. }
  3740. func (c *SZHisApiController) GetTreatmentProject() {
  3741. adminUserInfo := c.GetAdminUserInfo()
  3742. orgId := adminUserInfo.CurrentOrgId
  3743. ids := c.GetString("ids")
  3744. stringarr := strings.Split(ids, ",")
  3745. idss := make([]int64, 0)
  3746. admin_user_id, _ := c.GetInt64("admin_user_id")
  3747. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3748. for _, item := range stringarr {
  3749. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3750. id := int64(itemsss)
  3751. idss = append(idss, id)
  3752. }
  3753. //获取项目库数据
  3754. list, _ := service.GetBathchMyPorjecgList(idss)
  3755. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3756. var doctor_name string
  3757. var doctor_code string
  3758. doctor_name = roles.UserName
  3759. doctor_code = "1001"
  3760. var isSuccess bool = true
  3761. for _, item := range list {
  3762. detail := &models.MyHisProject{
  3763. MedicalCode: item.MedicalCode, //社保目录
  3764. ProjectName: item.ProjectName,
  3765. Price: item.Price,
  3766. Category: item.Category,
  3767. Remark: item.Remark,
  3768. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  3769. SpecailProject: item.SpecailProject,
  3770. RecordDate: item.RecordDate,
  3771. }
  3772. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  3773. var dat map[string]interface{}
  3774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3775. fmt.Println(dat)
  3776. } else {
  3777. fmt.Println(err)
  3778. }
  3779. userJSONBytes, _ := json.Marshal(dat)
  3780. var res Result
  3781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3782. utils.ErrorLog("解析失败:%v", err)
  3783. c.ServeSuccessJSON(map[string]interface{}{
  3784. "failed_code": -10,
  3785. "msg": res.Transreturnmessage,
  3786. })
  3787. return
  3788. }
  3789. if res.Transreturncode == "00000000" {
  3790. //备案成功返回状态值
  3791. _, err := service.UpdateProjectById(item.ID)
  3792. fmt.Println("err", err)
  3793. } else {
  3794. isSuccess = false
  3795. //失败
  3796. c.ServeSuccessJSON(map[string]interface{}{
  3797. "failed_code": -10,
  3798. "msg": res.Transreturnmessage,
  3799. })
  3800. return
  3801. }
  3802. fmt.Println(isSuccess)
  3803. c.ServeSuccessJSON(map[string]interface{}{
  3804. "failed_code": -10,
  3805. "msg": res.Transreturnmessage,
  3806. })
  3807. return
  3808. }
  3809. }
  3810. func (c *SZHisApiController) GetRevocation() {
  3811. adminUserInfo := c.GetAdminUserInfo()
  3812. orgId := adminUserInfo.CurrentOrgId
  3813. id, _ := c.GetInt64("id")
  3814. admin_user_id, _ := c.GetInt64("admin_user_id")
  3815. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3816. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  3817. is_mark, _ := c.GetInt64("is_mark")
  3818. type_id, _ := c.GetInt64("type_id")
  3819. if type_id == 1 {
  3820. //撤销
  3821. if is_mark == 1 {
  3822. //获取药品库数据
  3823. list, _ := service.GetDrugListByDetail(orgId, id)
  3824. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3825. var doctor_name string
  3826. var doctor_code string
  3827. doctor_name = roles.UserName
  3828. doctor_code = "1001"
  3829. var pagesize int = 50
  3830. var start int = 1
  3831. var stop int
  3832. var pagecount int
  3833. var curpage int
  3834. var isSuccess bool = true
  3835. //总页数,向上取整,注意除之前要先转换类型为float64
  3836. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3837. for curpage = 1; curpage <= pagecount; curpage++ {
  3838. if curpage == 1 {
  3839. start = 1
  3840. } else {
  3841. start = (curpage-1)*pagesize + 1
  3842. }
  3843. stop = curpage * pagesize
  3844. if stop > len(list) {
  3845. stop = len(list)
  3846. }
  3847. //这里就可以查看开始和结束了
  3848. fmt.Println(list[start-1 : stop])
  3849. var customs []*models.DrugDetail
  3850. for _, item := range list {
  3851. detail := &models.DrugDetail{
  3852. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber, //社保目录
  3853. Code: item.Code, //协议机构内部目录编码
  3854. DrugName: item.DrugName, //协议机构内部目录名称
  3855. DrugSpec: item.DrugSpec,
  3856. ManufacturerName: item.ManufacturerName,
  3857. MinUnit: item.MinUnit,
  3858. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  3859. LimitRemark: item.LimitRemark,
  3860. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  3861. }
  3862. customs = append(customs, detail)
  3863. }
  3864. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3865. fmt.Println("reuslt", result)
  3866. var dat map[string]interface{}
  3867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3868. fmt.Println(dat)
  3869. } else {
  3870. fmt.Println(err)
  3871. }
  3872. userJSONBytes, _ := json.Marshal(dat)
  3873. var res Result
  3874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3875. utils.ErrorLog("解析失败:%v", err)
  3876. c.ServeSuccessJSON(map[string]interface{}{
  3877. "failed_code": -10,
  3878. "msg": res.Transreturnmessage,
  3879. })
  3880. return
  3881. }
  3882. if res.Transreturncode == "00000000" {
  3883. //撤销成功
  3884. _, err := service.UpdateDrugByIdDetail(id)
  3885. fmt.Println("err", err)
  3886. } else {
  3887. isSuccess = false
  3888. //失败
  3889. c.ServeSuccessJSON(map[string]interface{}{
  3890. "failed_code": -10,
  3891. "msg": res.Transreturnmessage,
  3892. })
  3893. return
  3894. }
  3895. fmt.Println(isSuccess)
  3896. c.ServeSuccessJSON(map[string]interface{}{
  3897. "failed_code": -10,
  3898. "msg": res.Transreturnmessage,
  3899. })
  3900. return
  3901. }
  3902. }
  3903. // 备案
  3904. if is_mark == 0 {
  3905. adminUserInfo := c.GetAdminUserInfo()
  3906. orgId := adminUserInfo.CurrentOrgId
  3907. //获取药品库数据
  3908. list, _ := service.GetDrugListByDetail(orgId, id)
  3909. //获取药品剂型
  3910. drugs, _ := service.GetDrugDosageForm(orgId)
  3911. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3912. var doctor_name string
  3913. var doctor_code string
  3914. doctor_name = roles.UserName
  3915. doctor_code = "1001"
  3916. var isSuccess bool = true
  3917. //这里就可以查看开始和结束了
  3918. for _, item := range list {
  3919. detail := &models.DrugDetail{
  3920. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  3921. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber,
  3922. Code: item.Code,
  3923. DrugName: item.DrugName,
  3924. DrugSpec: item.DrugSpec,
  3925. DrugDosageName: item.DrugDosageName,
  3926. ManufacturerName: item.ManufacturerName,
  3927. MinUnit: item.MinUnit,
  3928. RetailPrice: item.RetailPrice,
  3929. LastPrice: item.LastPrice,
  3930. LimitRemark: item.LimitRemark,
  3931. }
  3932. for _, it := range drugs {
  3933. if item.DrugDosageForm == it.Value {
  3934. detail.DrugDosageName = it.Code
  3935. }
  3936. }
  3937. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3938. var dat map[string]interface{}
  3939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3940. //fmt.Println(dat)
  3941. } else {
  3942. //fmt.Println(err)
  3943. }
  3944. userJSONBytes, _ := json.Marshal(dat)
  3945. var res Result
  3946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3947. utils.ErrorLog("解析失败:%v", err)
  3948. c.ServeSuccessJSON(map[string]interface{}{
  3949. "failed_code": -10,
  3950. "msg": res.Transreturnmessage,
  3951. })
  3952. return
  3953. }
  3954. if res.Transreturncode == "00000000" {
  3955. //更新备案状态
  3956. _, err := service.UpdateBaseDrugById(item.ID)
  3957. fmt.Println("err", err)
  3958. }
  3959. fmt.Println(isSuccess)
  3960. c.ServeSuccessJSON(map[string]interface{}{
  3961. "failed_code": -10,
  3962. "msg": res.Transreturnmessage,
  3963. })
  3964. return
  3965. }
  3966. }
  3967. }
  3968. if type_id == 2 {
  3969. //撤销
  3970. if is_mark == 1 {
  3971. //获取药品库数据
  3972. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  3973. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3974. var doctor_name string
  3975. var doctor_code string
  3976. doctor_name = roles.UserName
  3977. doctor_code = "1001"
  3978. var pagesize int = 50
  3979. var start int = 1
  3980. var stop int
  3981. var pagecount int
  3982. var curpage int
  3983. var isSuccess bool = true
  3984. //总页数,向上取整,注意除之前要先转换类型为float64
  3985. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3986. for curpage = 1; curpage <= pagecount; curpage++ {
  3987. if curpage == 1 {
  3988. start = 1
  3989. } else {
  3990. start = (curpage-1)*pagesize + 1
  3991. }
  3992. stop = curpage * pagesize
  3993. if stop > len(list) {
  3994. stop = len(list)
  3995. }
  3996. //这里就可以查看开始和结束了
  3997. fmt.Println(list[start-1 : stop])
  3998. var customs []*models.DrugDetail
  3999. for _, item := range list {
  4000. detail := &models.DrugDetail{
  4001. SocialSecurityDirectoryCode: item.MedicalCode,
  4002. }
  4003. customs = append(customs, detail)
  4004. }
  4005. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  4006. fmt.Println("reuslt", result)
  4007. var dat map[string]interface{}
  4008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4009. fmt.Println(dat)
  4010. } else {
  4011. fmt.Println(err)
  4012. }
  4013. userJSONBytes, _ := json.Marshal(dat)
  4014. var res Result
  4015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4016. utils.ErrorLog("解析失败:%v", err)
  4017. c.ServeSuccessJSON(map[string]interface{}{
  4018. "failed_code": -10,
  4019. "msg": res.Transreturnmessage,
  4020. })
  4021. return
  4022. }
  4023. if res.Transreturncode == "00000000" {
  4024. //核销成功返回状态码
  4025. _, err := service.UpdateMyProjectById(id)
  4026. fmt.Println("err", err)
  4027. } else {
  4028. isSuccess = false
  4029. //失败
  4030. c.ServeSuccessJSON(map[string]interface{}{
  4031. "failed_code": -10,
  4032. "msg": res.Transreturnmessage,
  4033. })
  4034. return
  4035. }
  4036. fmt.Println(isSuccess)
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": res.Transreturnmessage,
  4040. })
  4041. return
  4042. }
  4043. }
  4044. //备案
  4045. if is_mark == 0 {
  4046. adminUserInfo := c.GetAdminUserInfo()
  4047. orgId := adminUserInfo.CurrentOrgId
  4048. //获取药品库数据
  4049. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  4050. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4051. var doctor_name string
  4052. var doctor_code string
  4053. doctor_name = roles.UserName
  4054. doctor_code = "1001"
  4055. var isSuccess bool = true
  4056. for _, item := range list {
  4057. detail := &models.MyHisProject{
  4058. MedicalCode: item.MedicalCode, //社保目录
  4059. ProjectName: item.ProjectName,
  4060. Price: item.Price,
  4061. Category: item.Category,
  4062. Remark: item.Remark,
  4063. }
  4064. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  4065. fmt.Println("reuslt", result)
  4066. var dat map[string]interface{}
  4067. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4068. fmt.Println(dat)
  4069. } else {
  4070. fmt.Println(err)
  4071. }
  4072. userJSONBytes, _ := json.Marshal(dat)
  4073. var res Result
  4074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4075. utils.ErrorLog("解析失败:%v", err)
  4076. c.ServeSuccessJSON(map[string]interface{}{
  4077. "failed_code": -10,
  4078. "msg": res.Transreturnmessage,
  4079. })
  4080. return
  4081. }
  4082. if res.Transreturncode == "00000000" {
  4083. //备案成功返回状态值
  4084. _, err := service.UpdateProjectById(item.ID)
  4085. fmt.Println("err", err)
  4086. } else {
  4087. isSuccess = false
  4088. //失败
  4089. c.ServeSuccessJSON(map[string]interface{}{
  4090. "failed_code": -10,
  4091. "msg": res.Transreturnmessage,
  4092. })
  4093. return
  4094. }
  4095. fmt.Println(isSuccess)
  4096. c.ServeSuccessJSON(map[string]interface{}{
  4097. "failed_code": -10,
  4098. "msg": res.Transreturnmessage,
  4099. })
  4100. return
  4101. }
  4102. }
  4103. }
  4104. if type_id == 3 {
  4105. //撤销
  4106. if is_mark == 1 {
  4107. //获取药品库数据
  4108. list, _ := service.GetGoodListByDetail(orgId, id)
  4109. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4110. var doctor_name string
  4111. var doctor_code string
  4112. doctor_name = roles.UserName
  4113. doctor_code = "1001"
  4114. var pagesize int = 50
  4115. var start int = 1
  4116. var stop int
  4117. var pagecount int
  4118. var curpage int
  4119. var isSuccess bool = true
  4120. //总页数,向上取整,注意除之前要先转换类型为float64
  4121. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4122. for curpage = 1; curpage <= pagecount; curpage++ {
  4123. if curpage == 1 {
  4124. start = 1
  4125. } else {
  4126. start = (curpage-1)*pagesize + 1
  4127. }
  4128. stop = curpage * pagesize
  4129. if stop > len(list) {
  4130. stop = len(list)
  4131. }
  4132. //这里就可以查看开始和结束了
  4133. fmt.Println(list[start-1 : stop])
  4134. var customs []*models.DrugDetail
  4135. for _, item := range list {
  4136. fmt.Println("医疗机构编码", item.SocialSecurityDirectoryCode)
  4137. detail := &models.DrugDetail{
  4138. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4139. ManufacturerName: item.ManufacturerName,
  4140. }
  4141. customs = append(customs, detail)
  4142. }
  4143. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  4144. fmt.Println("reuslt", result)
  4145. var dat map[string]interface{}
  4146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4147. fmt.Println(dat)
  4148. } else {
  4149. fmt.Println(err)
  4150. }
  4151. userJSONBytes, _ := json.Marshal(dat)
  4152. var res Result
  4153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4154. utils.ErrorLog("解析失败:%v", err)
  4155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4156. return
  4157. }
  4158. if res.Transreturncode == "00000000" {
  4159. //撤销成功后改变状态
  4160. _, err := service.UpdateGoodInfoById(id)
  4161. fmt.Println("err", err)
  4162. } else {
  4163. isSuccess = false
  4164. //失败
  4165. c.ServeSuccessJSON(map[string]interface{}{
  4166. "failed_code": -10,
  4167. "msg": res.Transreturnmessage,
  4168. })
  4169. return
  4170. }
  4171. fmt.Println(isSuccess)
  4172. c.ServeSuccessJSON(map[string]interface{}{
  4173. "failed_code": -10,
  4174. "msg": res.Transreturnmessage,
  4175. })
  4176. return
  4177. }
  4178. }
  4179. //备案
  4180. if is_mark == 0 {
  4181. adminUserInfo := c.GetAdminUserInfo()
  4182. orgId := adminUserInfo.CurrentOrgId
  4183. //获取所有耗材信息
  4184. list, _ := service.GetGoodListByDetail(orgId, id)
  4185. //获取单位
  4186. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4187. var doctor_name string
  4188. var doctor_code string
  4189. doctor_name = roles.UserName
  4190. doctor_code = "1001"
  4191. var isSuccess bool = true
  4192. for _, item := range list {
  4193. detail := &models.XtGoodInformation{
  4194. GoodName: item.GoodName,
  4195. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4196. ManufacturerName: item.ManufacturerName,
  4197. ProductionType: item.ProductionType,
  4198. SpecialMedical: item.SpecialMedical,
  4199. BuyPrice: item.BuyPrice,
  4200. SellPrice: item.SellPrice,
  4201. Remark: item.Remark,
  4202. SpecificationName: item.SpecificationName,
  4203. }
  4204. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4205. fmt.Println("reuslt", result)
  4206. var dat map[string]interface{}
  4207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4208. fmt.Println(dat)
  4209. } else {
  4210. fmt.Println(err)
  4211. }
  4212. userJSONBytes, _ := json.Marshal(dat)
  4213. var res Result
  4214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4215. utils.ErrorLog("解析失败:%v", err)
  4216. c.ServeSuccessJSON(map[string]interface{}{
  4217. "failed_code": -10,
  4218. "msg": res.Transreturnmessage,
  4219. })
  4220. return
  4221. }
  4222. if res.Transreturncode == "00000000" {
  4223. //备案成功返回状态
  4224. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4225. fmt.Println("err", err)
  4226. } else {
  4227. isSuccess = false
  4228. //失败
  4229. c.ServeSuccessJSON(map[string]interface{}{
  4230. "failed_code": -10,
  4231. "msg": res.Transreturnmessage,
  4232. })
  4233. return
  4234. }
  4235. fmt.Println(isSuccess)
  4236. c.ServeSuccessJSON(map[string]interface{}{
  4237. "failed_code": -10,
  4238. "msg": res.Transreturnmessage,
  4239. })
  4240. return
  4241. }
  4242. }
  4243. }
  4244. }
  4245. func (c *SZHisApiController) GetDoctorList() {
  4246. adminUserInfo := c.GetAdminUserInfo()
  4247. orgid := adminUserInfo.CurrentOrgId
  4248. ids := c.GetString("ids")
  4249. admin_user_id, _ := c.GetInt64("admin_user_id")
  4250. roles, _ := service.GetAdminUserInfoByID(orgid, admin_user_id)
  4251. stringarr := strings.Split(ids, ",")
  4252. idss := make([]int64, 0)
  4253. for _, item := range stringarr {
  4254. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4255. id := int64(itemsss)
  4256. idss = append(idss, id)
  4257. }
  4258. //获取所有医生护士信息
  4259. //list, _ := service.GetDoctorList(orgid)
  4260. //批量查询
  4261. list, _ := service.GetBatchDoctorList(idss)
  4262. //获取所有角色名称
  4263. roleList, _ := service.GetRoleList(orgid)
  4264. miConfig, _ := service.FindMedicalInsuranceInfo(orgid)
  4265. for _, item := range list {
  4266. for _, it := range roleList {
  4267. if item.RoleId == it.ID {
  4268. item.Name = it.RoleName
  4269. }
  4270. }
  4271. }
  4272. var doctor_name string
  4273. var doctor_code string
  4274. doctor_name = roles.UserName
  4275. doctor_code = "1001"
  4276. var isSuccess bool = true
  4277. for _, item := range list {
  4278. depart, _ := service.GetDepartMentDetail(item.DepartmentId)
  4279. detail := &models.DocDetail{
  4280. UserName: item.UserName, //医护姓名
  4281. RoleId: item.Name, //医护人员类别
  4282. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4283. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4284. IdCard: item.IdCard, //证件号码
  4285. Phone: item.Mobile, //联系电话
  4286. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4287. Nation: "1", //民族
  4288. BirthDay: 20201022, // 出生日期
  4289. WorkTime: 20201022, //参加工作日期
  4290. Education: strconv.FormatInt(item.Education, 10), //学历
  4291. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4292. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4293. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4294. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4295. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4296. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4297. DoctorNumber: item.DoctorNumber, //医保医师编号
  4298. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4299. DoctorServiceStatus: "", //医师医保服务资格状态
  4300. MonitoringLevel: "", //监控等级
  4301. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4302. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4303. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4304. PharmacistType: "", //药师类别
  4305. PharmacistPracticeCategory: "", //药师执业类别
  4306. PharmacistsLicensing: "", //药师执业范围
  4307. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4308. OfficeCode: depart.Number, //科室编码
  4309. JobNumber: item.JobNumber, //工号
  4310. PostName: "", //职位名称
  4311. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4312. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4313. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4314. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4315. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4316. StartTime: 20201010, //开始日期
  4317. StaffCode: "", //医护人员编码
  4318. EndTime: 0, // 结束日期
  4319. }
  4320. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4321. fmt.Println("reuslt", result)
  4322. var dat map[string]interface{}
  4323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4324. fmt.Println(dat)
  4325. } else {
  4326. fmt.Println(err)
  4327. }
  4328. userJSONBytes, _ := json.Marshal(dat)
  4329. var res Result
  4330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4331. utils.ErrorLog("解析失败:%v", err)
  4332. c.ServeSuccessJSON(map[string]interface{}{
  4333. "failed_code": -10,
  4334. "msg": res.Transreturnmessage,
  4335. })
  4336. return
  4337. }
  4338. if res.Transreturncode == "00000000" {
  4339. //批量插入数据
  4340. _, err := service.UpdateAdminUserRoleById(item.AdminUserId, orgid)
  4341. fmt.Println("err", err)
  4342. } else {
  4343. isSuccess = false
  4344. //失败
  4345. c.ServeSuccessJSON(map[string]interface{}{
  4346. "failed_code": -10,
  4347. "msg": res.Transreturnmessage,
  4348. })
  4349. return
  4350. }
  4351. fmt.Println(isSuccess)
  4352. c.ServeSuccessJSON(map[string]interface{}{
  4353. "failed_code": -10,
  4354. "msg": res.Transreturnmessage,
  4355. })
  4356. return
  4357. }
  4358. }
  4359. func (c *SZHisApiController) GetMedicalList() {
  4360. adminUserInfo := c.GetAdminUserInfo()
  4361. orgId := adminUserInfo.CurrentOrgId
  4362. id, _ := c.GetInt64("id")
  4363. is_mark, _ := c.GetInt64("is_mark")
  4364. admin_user_id, _ := c.GetInt64("admin_user_id")
  4365. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4366. //去登记
  4367. if is_mark == 0 {
  4368. list, _ := service.GetDoctorListByDetail(orgId, id)
  4369. //获取所有角色名称
  4370. roleList, _ := service.GetRoleList(orgId)
  4371. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4372. for _, item := range list {
  4373. for _, it := range roleList {
  4374. if item.RoleId == it.ID {
  4375. item.Name = it.RoleName
  4376. }
  4377. }
  4378. }
  4379. var doctor_name string
  4380. var doctor_code string
  4381. doctor_name = roles.UserName
  4382. doctor_code = "1001"
  4383. var isSuccess bool = true
  4384. for _, item := range list {
  4385. detail := &models.DocDetail{
  4386. UserName: item.UserName, //医护姓名
  4387. RoleId: item.Name, //医护人员类别
  4388. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4389. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4390. IdCard: item.IdCard, //证件号码
  4391. Phone: item.Mobile, //联系电话
  4392. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4393. Nation: item.Nation, //民族
  4394. BirthDay: 20201022, // 出生日期
  4395. WorkTime: 20201022, //参加工作日期
  4396. Education: strconv.FormatInt(item.Education, 10), //学历
  4397. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4398. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4399. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4400. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4401. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4402. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4403. DoctorNumber: item.DoctorNumber, //医保医师编号
  4404. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4405. DoctorServiceStatus: "", //医师医保服务资格状态
  4406. MonitoringLevel: "", //监控等级
  4407. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4408. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4409. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4410. PharmacistType: "", //药师类别
  4411. PharmacistPracticeCategory: "", //药师执业类别
  4412. PharmacistsLicensing: "", //药师执业范围
  4413. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4414. OfficeCode: "", //科室编码
  4415. JobNumber: item.JobNumber, //工号
  4416. PostName: "", //职位名称
  4417. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4418. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4419. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4420. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4421. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4422. StartTime: 20201010, //开始日期
  4423. StaffCode: "", //医护人员编码
  4424. EndTime: 0, // 结束日期
  4425. }
  4426. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4427. var dat map[string]interface{}
  4428. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4429. fmt.Println(dat)
  4430. } else {
  4431. fmt.Println(err)
  4432. }
  4433. userJSONBytes, _ := json.Marshal(dat)
  4434. var res Result
  4435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4436. utils.ErrorLog("解析失败:%v", err)
  4437. c.ServeSuccessJSON(map[string]interface{}{
  4438. "failed_code": -10,
  4439. "msg": res.Transreturnmessage,
  4440. })
  4441. return
  4442. }
  4443. if res.Transreturncode == "00000000" {
  4444. //登记成功
  4445. service.UpdateAdminUserRoleById(item.ID, orgId)
  4446. } else {
  4447. isSuccess = false
  4448. //失败
  4449. c.ServeSuccessJSON(map[string]interface{}{
  4450. "failed_code": -10,
  4451. "msg": res.Transreturnmessage,
  4452. })
  4453. return
  4454. }
  4455. fmt.Println(isSuccess)
  4456. c.ServeSuccessJSON(map[string]interface{}{
  4457. "failed_code": -10,
  4458. "msg": res.Transreturnmessage,
  4459. })
  4460. return
  4461. }
  4462. }
  4463. //去撤销
  4464. if is_mark == 1 {
  4465. //获取所有医生护士信息
  4466. list, _ := service.GetDoctorListByDetail(orgId, id)
  4467. //获取所有角色名称
  4468. roleList, _ := service.GetRoleList(orgId)
  4469. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4470. for _, item := range list {
  4471. for _, it := range roleList {
  4472. if item.RoleId == it.ID {
  4473. item.Name = it.RoleName
  4474. }
  4475. }
  4476. }
  4477. var doctor_name string
  4478. var doctor_code string
  4479. doctor_name = "黄亦轩"
  4480. doctor_code = "1001"
  4481. var isSuccess bool = true
  4482. for _, item := range list {
  4483. detail := &models.DocDetail{
  4484. UserName: item.UserName, //医护姓名
  4485. RoleId: item.Name, //医护人员类别
  4486. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4487. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4488. IdCard: item.IdCard, //证件号码
  4489. Phone: item.Mobile, //联系电话
  4490. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4491. Nation: item.Nation, //民族
  4492. BirthDay: 20201022, // 出生日期
  4493. WorkTime: 20201022, //参加工作日期
  4494. Education: strconv.FormatInt(item.Education, 10), //学历
  4495. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4496. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4497. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4498. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4499. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4500. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4501. DoctorNumber: item.DoctorNumber, //医保医师编号
  4502. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4503. DoctorServiceStatus: "", //医师医保服务资格状态
  4504. MonitoringLevel: "", //监控等级
  4505. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4506. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4507. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4508. PharmacistType: "", //药师类别
  4509. PharmacistPracticeCategory: "", //药师执业类别
  4510. PharmacistsLicensing: "", //药师执业范围
  4511. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4512. OfficeCode: "", //科室编码
  4513. JobNumber: item.JobNumber, //工号
  4514. PostName: "", //职位名称
  4515. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4516. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4517. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4518. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4519. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4520. StartTime: 20201010, //开始日期
  4521. StaffCode: "", //医护人员编码
  4522. EndTime: 0, // 结束日期
  4523. }
  4524. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
  4525. var dat map[string]interface{}
  4526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4527. fmt.Println(dat)
  4528. } else {
  4529. fmt.Println(err)
  4530. }
  4531. userJSONBytes, _ := json.Marshal(dat)
  4532. var res Result
  4533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4534. utils.ErrorLog("解析失败:%v", err)
  4535. c.ServeSuccessJSON(map[string]interface{}{
  4536. "failed_code": -10,
  4537. "msg": res.Transreturnmessage,
  4538. })
  4539. return
  4540. }
  4541. if res.Transreturncode == "00000000" {
  4542. //去撤销
  4543. service.UpdateAdminUserRoleById(item.ID, orgId)
  4544. } else {
  4545. isSuccess = false
  4546. //失败
  4547. c.ServeSuccessJSON(map[string]interface{}{
  4548. "failed_code": -10,
  4549. "msg": res.Transreturnmessage,
  4550. })
  4551. return
  4552. }
  4553. fmt.Println(isSuccess)
  4554. c.ServeSuccessJSON(map[string]interface{}{
  4555. "failed_code": -10,
  4556. "msg": res.Transreturnmessage,
  4557. })
  4558. return
  4559. }
  4560. }
  4561. }
  4562. func (c *SZHisApiController) GetUpdateMedicalList() {
  4563. adminUserInfo := c.GetAdminUserInfo()
  4564. orgId := adminUserInfo.CurrentOrgId
  4565. //获取所有医生护士信息
  4566. list, _ := service.GetDoctorList(orgId)
  4567. //获取所有角色名称
  4568. roleList, _ := service.GetRoleList(orgId)
  4569. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4570. for _, item := range list {
  4571. for _, it := range roleList {
  4572. if item.RoleId == it.ID {
  4573. item.Name = it.RoleName
  4574. }
  4575. }
  4576. }
  4577. var doctor_name string
  4578. var doctor_code string
  4579. doctor_name = "黄亦轩"
  4580. doctor_code = "1001"
  4581. var pagesize int = 50
  4582. var start int = 1
  4583. var stop int
  4584. var pagecount int
  4585. var curpage int
  4586. var isSuccess bool = true
  4587. //总页数,向上取整,注意除之前要先转换类型为float64
  4588. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4589. var ress []*Result
  4590. for curpage = 1; curpage <= pagecount; curpage++ {
  4591. if curpage == 1 {
  4592. start = 1
  4593. } else {
  4594. start = (curpage-1)*pagesize + 1
  4595. }
  4596. stop = curpage * pagesize
  4597. if stop > len(list) {
  4598. stop = len(list)
  4599. }
  4600. //这里就可以查看开始和结束了
  4601. fmt.Println(list[start-1 : stop])
  4602. var customs []*models.DocDetail
  4603. for _, item := range list {
  4604. detail := &models.DocDetail{
  4605. StaffCode: "", //医护人员编码
  4606. UserName: item.UserName, //医护人员姓名
  4607. RoleId: item.Name, //医护人员类别
  4608. Sex: "", //性别
  4609. CardType: "", //证件类型
  4610. IdCard: "", //证件号码
  4611. Phone: "", //联系电话
  4612. WorkMajorName: "", //现从事专业名称
  4613. Nation: "", //民族
  4614. BirthDay: 20201022, //出生日期
  4615. WorkTime: 20201022, //参加工作日期
  4616. Education: "", //学历
  4617. StudyMajorName: "", //所学的专业名称
  4618. CertificateCode: "", //证书编码
  4619. MedicalCode: "", //医师资格编码
  4620. MedicalRangeCode: "", //医师执业范围代码
  4621. MedicalLevel: "", //医生级别
  4622. TypeJob: "", //职业类别
  4623. DoctorNumber: "", //医师编号
  4624. Licensing: "", //职业标志
  4625. DoctorServiceStatus: "", //医师医保服务资格状态
  4626. MonitoringLevel: "", //监控等级
  4627. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4628. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4629. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4630. PharmacistType: "", //药师类别
  4631. PharmacistPracticeCategory: "", //药师执业类别
  4632. PharmacistsLicensing: "", //药师执业范围
  4633. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4634. OfficeCode: "", //科室编码
  4635. JobNumber: "", //工号
  4636. PostName: "", //职位名称
  4637. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4638. IsActive: "", //在职与否
  4639. PrescriptionQualificationIdentification: "", //处方资格标识
  4640. IdentificationOutpatients: "", //门诊大病医师标识
  4641. OutpatientIllnessCategory: "", //门诊大病类别
  4642. StartTime: 20201022, //开始日期
  4643. EndTime: 20201022,
  4644. }
  4645. customs = append(customs, detail)
  4646. }
  4647. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  4648. var dat map[string]interface{}
  4649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4650. fmt.Println(dat)
  4651. } else {
  4652. fmt.Println(err)
  4653. }
  4654. userJSONBytes, _ := json.Marshal(dat)
  4655. var res Result
  4656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4657. utils.ErrorLog("解析失败:%v", err)
  4658. c.ServeSuccessJSON(map[string]interface{}{
  4659. "failed_code": -10,
  4660. "msg": res.Transreturnmessage,
  4661. })
  4662. return
  4663. }
  4664. if res.Transreturncode == "00000000" {
  4665. ress = append(ress, &res)
  4666. } else {
  4667. isSuccess = false
  4668. //失败
  4669. c.ServeSuccessJSON(map[string]interface{}{
  4670. "failed_code": -10,
  4671. "msg": res.Transreturnmessage,
  4672. })
  4673. return
  4674. }
  4675. fmt.Println(isSuccess)
  4676. c.ServeSuccessJSON(map[string]interface{}{
  4677. "failed_code": -10,
  4678. "msg": res.Transreturnmessage,
  4679. })
  4680. return
  4681. }
  4682. }
  4683. func (c *SZHisApiController) GetGoodsList() {
  4684. adminUserInfo := c.GetAdminUserInfo()
  4685. orgId := adminUserInfo.CurrentOrgId
  4686. ids := c.GetString("ids")
  4687. admin_user_id, _ := c.GetInt64("admin_user_id")
  4688. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4689. stringarr := strings.Split(ids, ",")
  4690. idss := make([]int64, 0)
  4691. for _, item := range stringarr {
  4692. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4693. id := int64(itemsss)
  4694. idss = append(idss, id)
  4695. }
  4696. //批量获取所有耗材信息
  4697. list, _ := service.GetBatchGoodInformationList(idss)
  4698. //获取单位
  4699. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4700. var doctor_name string
  4701. var doctor_code string
  4702. doctor_name = roles.UserName
  4703. doctor_code = "1001"
  4704. var isSuccess bool = true
  4705. for _, item := range list {
  4706. detail := &models.XtGoodInformation{
  4707. GoodName: item.GoodName,
  4708. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4709. ManufacturerName: item.ManufacturerName,
  4710. ProductionType: item.ProductionType,
  4711. SpecialMedical: item.SpecialMedical,
  4712. BuyPrice: item.BuyPrice,
  4713. SellPrice: item.SellPrice,
  4714. Remark: item.Remark,
  4715. SpecificationName: item.SpecificationName,
  4716. }
  4717. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4718. fmt.Println("reuslt", result)
  4719. var dat map[string]interface{}
  4720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4721. fmt.Println(dat)
  4722. } else {
  4723. fmt.Println(err)
  4724. }
  4725. userJSONBytes, _ := json.Marshal(dat)
  4726. var res Result
  4727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4728. utils.ErrorLog("解析失败:%v", err)
  4729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4730. return
  4731. }
  4732. if res.Transreturncode == "00000000" {
  4733. //备案成功返回状态
  4734. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4735. fmt.Println("err", err)
  4736. } else {
  4737. isSuccess = false
  4738. //失败
  4739. c.ServeSuccessJSON(map[string]interface{}{
  4740. "failed_code": -10,
  4741. "msg": res.Transreturnmessage,
  4742. })
  4743. return
  4744. }
  4745. fmt.Println(isSuccess)
  4746. c.ServeSuccessJSON(map[string]interface{}{
  4747. "failed_code": -10,
  4748. "msg": res.Transreturnmessage,
  4749. })
  4750. return
  4751. }
  4752. }
  4753. type Charset string
  4754. const (
  4755. UTF8 = Charset("UTF-8")
  4756. GB18030 = Charset("GB18030")
  4757. )
  4758. func ConvertToString(src string, srcCode string, tagCode string) string {
  4759. srcCoder := mahonia.NewDecoder(srcCode)
  4760. srcResult := srcCoder.ConvertString(src)
  4761. tagCoder := mahonia.NewDecoder(tagCode)
  4762. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  4763. result := string(cdata)
  4764. return result
  4765. }