sz_his_api_controller.go 207KB

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