his_api_controller.go 202KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/jinzhu/gorm"
  14. "github.com/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func HisManagerApiRegistRouters() {
  31. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  32. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  33. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  34. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  35. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  36. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  37. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  38. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  39. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  40. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  41. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  42. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  43. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  44. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  45. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  46. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  47. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  48. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  49. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  50. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  51. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  52. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  53. //备案撤销相关接口
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  65. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  66. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  67. }
  68. func (c *HisApiController) ReadCard() {
  69. id_card_type, _ := c.GetInt64("id_card_type")
  70. admin_user_id, _ := c.GetInt64("admin_user_id")
  71. certificates, _ := c.GetInt64("certificates")
  72. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  73. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  74. if initFlag == 0 {
  75. c.TestGetBasBaseInit()
  76. }
  77. switch id_card_type {
  78. case 1:
  79. basStr := c.GetBasBaseInfo()
  80. fmt.Println(basStr)
  81. bas := strings.Split(basStr, "|")
  82. basNumber := bas[3]
  83. fmt.Println(basNumber)
  84. card_sn := bas[4]
  85. fmt.Println(card_sn)
  86. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  87. var dat map[string]interface{}
  88. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  89. fmt.Println(dat)
  90. } else {
  91. fmt.Println(err)
  92. }
  93. userJSONBytes, _ := json.Marshal(dat)
  94. var res ResultTwo
  95. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  96. utils.ErrorLog("解析失败:%v", err)
  97. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  98. return
  99. }
  100. if res.Infcode == 0 {
  101. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  102. if err == gorm.ErrRecordNotFound {
  103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  104. return
  105. } else if err != nil {
  106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  107. return
  108. } else {
  109. c.ServeSuccessJSON(map[string]interface{}{
  110. "patient": patient,
  111. "number": basNumber,
  112. })
  113. }
  114. } else {
  115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  116. return
  117. }
  118. break
  119. case 2:
  120. SFZStr := c.GetSFZBaseInfo()
  121. id_card_str := strings.Split(SFZStr, "^")
  122. id_card_number := id_card_str[0]
  123. card_sn := ""
  124. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  125. var dat map[string]interface{}
  126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  127. fmt.Println(dat)
  128. } else {
  129. fmt.Println(err)
  130. }
  131. userJSONBytes, _ := json.Marshal(dat)
  132. var res ResultTwo
  133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  134. utils.ErrorLog("解析失败:%v", err)
  135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  136. return
  137. }
  138. if res.Infcode == 0 {
  139. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  140. if err == gorm.ErrRecordNotFound {
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  142. return
  143. } else if err != nil {
  144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  145. return
  146. } else {
  147. c.ServeSuccessJSON(map[string]interface{}{
  148. "patient": patient,
  149. "number": id_card_number,
  150. })
  151. }
  152. } else {
  153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  154. return
  155. }
  156. break
  157. case 3:
  158. break
  159. }
  160. }
  161. var initFlag int64 = 0
  162. func (c *HisApiController) TestGetBasBaseInit() {
  163. DllDef := syscall.MustLoadDLL("SSCard.dll")
  164. Iinit := DllDef.MustFindProc("Init")
  165. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  166. if ret != 0 {
  167. fmt.Println("SSCard的报错原因:", err)
  168. fmt.Println("SSCard的运算结果为:", ret)
  169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  170. return
  171. }
  172. result := int(ret)
  173. fmt.Println("SSCard的运算结果为1:", result)
  174. initFlag = 1
  175. return
  176. }
  177. func (c *HisApiController) GetSFZBaseInfo() string {
  178. DllDef := syscall.MustLoadDLL("SSCard.dll")
  179. readCard := DllDef.MustFindProc("ReadSFZ")
  180. if readCard == nil {
  181. fmt.Println("readcard is nil")
  182. readCard = DllDef.MustFindProc("ReadSFZ")
  183. }
  184. str := make([]byte, 256)
  185. str1 := make([]byte, 256)
  186. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  187. fmt.Println(r)
  188. return string(str)
  189. }
  190. func (c *HisApiController) GetBasBaseInfo() string {
  191. DllDef := syscall.MustLoadDLL("SSCard.dll")
  192. readCard := DllDef.MustFindProc("ReadCardBas")
  193. if readCard == nil {
  194. fmt.Println("readcard is nil")
  195. readCard = DllDef.MustFindProc("ReadCardBas")
  196. }
  197. str := make([]byte, 1024)
  198. str1 := make([]byte, 1024)
  199. ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  200. if err2 != nil {
  201. fmt.Println("SSCard的运算结果为:", ret2)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  203. return ""
  204. }
  205. return string(str1)
  206. }
  207. func prttostr(vcode uintptr) string {
  208. var vbyte []byte
  209. for i := 0; i < 10; i++ {
  210. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  211. if sbyte == 0 {
  212. break
  213. }
  214. vbyte = append(vbyte, sbyte)
  215. vcode += 1
  216. }
  217. return string(vbyte)
  218. }
  219. type CustomFundPay struct {
  220. FundPayType string `json:"fund_pay_type"`
  221. FundPayamt float64 `json:"fund_payamt"`
  222. }
  223. func (c *HisApiController) GetSettleList() {
  224. order_id, _ := c.GetInt64("order_id")
  225. admin_user_id, _ := c.GetInt64("admin_user_id")
  226. order, _ := service.GetHisOrderByIDTwo(order_id)
  227. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  228. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  229. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  230. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  231. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  232. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  233. if order.ID == 0 {
  234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  235. return
  236. }
  237. struct4101 := service.Struct4101{
  238. PsnNo: order.PsnNo,
  239. MdtrtId: order.MdtrtId,
  240. SetlId: order.SetlId,
  241. PsnName: order.PsnName,
  242. Gend: order.Gend,
  243. Brdy: his.Brdy,
  244. Age: his.Age,
  245. Naty: order.Naty,
  246. PatnCertType: "01",
  247. Certno: order.Certno,
  248. Prfs: "90",
  249. ConerName: roles[0].UserName,
  250. PatnRlts: "99",
  251. ConerAddr: miConfig.OrgName,
  252. ConerTel: admin.Mobile,
  253. HiType: order.Insutype,
  254. Insuplc: miConfig.InsuplcAdmdvs,
  255. MaindiagFlag: "1",
  256. BillCode: order.FaPiaoCode,
  257. BillNo: order.FaPiaoNumber,
  258. BizSn: order.Number,
  259. PsnSelfPay: order.PsnPartAmt,
  260. PsnOwnPay: order.PsnPartAmt,
  261. AcctPay: order.AcctPay,
  262. PsnCashpay: order.PsnCashPay,
  263. HiPaymtd: "1",
  264. Hsorg: miConfig.InsuplcAdmdvs,
  265. HsorgOpter: miConfig.InsuplcAdmdvs,
  266. MedinsFillPsn: curRoles.UserName,
  267. MedinsFillDept: depart.Name,
  268. IptMedType: "2",
  269. }
  270. if order.SettleType == 1 {
  271. t := time.Unix(int64(order.SettleAccountsDate), 0)
  272. dateStr := t.Format("2006-01-02")
  273. struct4101.SetlBegnDate = dateStr
  274. struct4101.SetlEndDate = dateStr
  275. } else {
  276. t := time.Unix(int64(order.SettleStartTime), 0)
  277. t2 := time.Unix(int64(order.SettleEndTime), 0)
  278. dateStartStr := t.Format("2006-01-02")
  279. dateEndStr := t2.Format("2006-01-02")
  280. struct4101.SetlBegnDate = dateStartStr
  281. struct4101.SetlEndDate = dateEndStr
  282. }
  283. var rf []CustomFundPay
  284. json.Unmarshal([]byte(order.SetlDetail), &rf)
  285. var tempFunPays []service.CustomStruct
  286. for _, item := range rf {
  287. var tempFunPay service.CustomStruct
  288. tempFunPay.FundPayamt = item.FundPayamt
  289. tempFunPay.FundPayType = item.FundPayType
  290. tempFunPays = append(tempFunPays, tempFunPay)
  291. }
  292. struct4101.CustomStruct = tempFunPays
  293. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  294. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  295. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  296. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  297. var config []*models.HisXtDiagnoseConfig
  298. for _, item := range diagnosis_ids {
  299. id, _ := strconv.ParseInt(item, 10, 64)
  300. diagnosisConfig, _ := service.FindDiagnoseById(id)
  301. config = append(config, diagnosisConfig)
  302. }
  303. for _, item := range config {
  304. var tempOpspdiseinfo service.OpspdiseinfoStruct
  305. tempOpspdiseinfo.DiagCode = item.CountryCode
  306. tempOpspdiseinfo.DiagName = item.CountryContentName
  307. tempOpspdiseinfo.MaindiagFlag = "1"
  308. tempOpspdiseinfo.OprnOprtCode = ""
  309. tempOpspdiseinfo.OprnOprtName = ""
  310. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  311. }
  312. sickConfigTwo, _ := service.FindSickById(his.SickType)
  313. tempOpspdiseinfo2.DiagCode = sickConfigTwo.CountryCode
  314. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  315. tempOpspdiseinfo2.MaindiagFlag = "2"
  316. tempOpspdiseinfo2.OprnOprtCode = ""
  317. tempOpspdiseinfo2.OprnOprtName = ""
  318. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  319. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  320. var iteminfo service.IteminfoStruct
  321. var bedCostTotal float64 = 0 //床位总费
  322. var bedCostSelfTotal float64 = 0 //床位自费
  323. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  324. var operationCostTotal float64 = 0 //手术费
  325. var operationCostSelfTotal float64 = 0 //手术费
  326. var operationCostPartSelfTotal float64 = 0 //手术费
  327. var otherCostTotal float64 = 0 //其他费用
  328. var otherCostSelfTotal float64 = 0 //其他费用
  329. var otherCostPartSelfTotal float64 = 0 //其他费用
  330. var materialCostTotal float64 = 0 //材料费
  331. var materialCostSelfTotal float64 = 0 //材料费
  332. var materialCostPartSelfTotal float64 = 0 //材料费
  333. var westernMedicineCostTotal float64 = 0 //西药费
  334. var westernMedicineCostSelfTotal float64 = 0 //西药费
  335. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  336. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  337. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  338. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  339. var checkCostTotal float64 = 0 //检查费
  340. var checkCostSelfTotal float64 = 0 //检查费
  341. var checkCostPartSelfTotal float64 = 0 //检查费
  342. var laboratoryCostTotal float64 = 0 //化验费
  343. var laboratoryCostSelfTotal float64 = 0 //化验费
  344. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  345. var treatCostTotal float64 = 0 //治疗费用
  346. var treatCostSelfTotal float64 = 0 //治疗费用
  347. var treatCostPartSelfTotal float64 = 0 //治疗费用
  348. decimal.DivisionPrecision = 2
  349. var bed_fulamt_ownpay_amt float64 = 0
  350. var operation_fulamt_ownpay_amt float64 = 0
  351. var other_fulamt_ownpay_amt float64 = 0
  352. var westernMedicine_fulamt_ownpay_amt float64 = 0
  353. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  354. var check_fulamt_ownpay_amt float64 = 0
  355. var material_fulamt_ownpay_amt float64 = 0
  356. var laboratory_fulamt_ownpay_amt float64 = 0
  357. var treat_fulamt_ownpay_amt float64 = 0
  358. var bed_claa_sunmfee float64 = 0
  359. var bed_clab_amt float64 = 0
  360. var bed_other_amt float64 = 0
  361. var operation_claa_sunmfee float64 = 0
  362. var operation_clab_amt float64 = 0
  363. var operation_other_amt float64 = 0
  364. var other_claa_sunmfee float64 = 0
  365. var other_clab_amt float64 = 0
  366. var other_other_amt float64 = 0
  367. var westernMedicine_claa_sunmfee float64 = 0
  368. var westernMedicine_clab_amt float64 = 0
  369. var westernMedicine_other_amt float64 = 0
  370. var chineseTraditional_claa_sunmfee float64 = 0
  371. var chineseTraditional_clab_amt float64 = 0
  372. var chineseTraditional_other_amt float64 = 0
  373. var check_claa_sunmfee float64 = 0
  374. var check_clab_amt float64 = 0
  375. var check_other_amt float64 = 0
  376. var material_claa_sunmfee float64 = 0
  377. var material_clab_amt float64 = 0
  378. var material_other_amt float64 = 0
  379. var laboratory_claa_sunmfee float64 = 0
  380. var laboratory_clab_amt float64 = 0
  381. var laboratory_other_amt float64 = 0
  382. var treat_claa_sunmfee float64 = 0
  383. var treat_clab_amt float64 = 0
  384. var treat_other_amt float64 = 0
  385. for _, item := range order.HisOrderInfo {
  386. if item.MedChrgitmType == "01" { //床位费
  387. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  388. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  389. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  390. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  391. if item.ChrgitmLv == "1" {
  392. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  393. }
  394. if item.ChrgitmLv == "2" {
  395. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  396. }
  397. if item.ChrgitmLv == "3" {
  398. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  399. }
  400. }
  401. if item.MedChrgitmType == "03" { //检查费
  402. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  403. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  404. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  405. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  406. if item.ChrgitmLv == "1" {
  407. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  408. }
  409. if item.ChrgitmLv == "2" {
  410. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  411. }
  412. if item.ChrgitmLv == "3" {
  413. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  414. }
  415. }
  416. if item.MedChrgitmType == "04" { //化验费
  417. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  418. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  419. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  420. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  421. if item.ChrgitmLv == "1" {
  422. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  423. }
  424. if item.ChrgitmLv == "2" {
  425. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  426. }
  427. if item.ChrgitmLv == "3" {
  428. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  429. }
  430. }
  431. if item.MedChrgitmType == "05" { //治疗费
  432. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  433. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  434. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  435. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  436. if item.ChrgitmLv == "1" {
  437. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  438. }
  439. if item.ChrgitmLv == "2" {
  440. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  441. }
  442. if item.ChrgitmLv == "3" {
  443. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  444. }
  445. }
  446. if item.MedChrgitmType == "06" { //手术费
  447. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  448. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  449. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  450. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  451. if item.ChrgitmLv == "1" {
  452. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  453. }
  454. if item.ChrgitmLv == "2" {
  455. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  456. }
  457. if item.ChrgitmLv == "3" {
  458. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  459. }
  460. }
  461. if item.MedChrgitmType == "08" { //材料费
  462. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  463. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  464. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  465. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  466. if item.ChrgitmLv == "1" {
  467. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  468. }
  469. if item.ChrgitmLv == "2" {
  470. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  471. }
  472. if item.ChrgitmLv == "3" {
  473. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  474. }
  475. }
  476. if item.MedChrgitmType == "09" { //西药费
  477. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  478. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  479. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  480. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  481. if item.ChrgitmLv == "1" {
  482. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  483. }
  484. if item.ChrgitmLv == "2" {
  485. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  486. }
  487. if item.ChrgitmLv == "3" {
  488. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  489. }
  490. }
  491. if item.MedChrgitmType == "11" { //中成费
  492. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  493. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  494. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  495. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  496. if item.ChrgitmLv == "1" {
  497. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  498. }
  499. if item.ChrgitmLv == "2" {
  500. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  501. }
  502. if item.ChrgitmLv == "3" {
  503. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  504. }
  505. }
  506. if item.MedChrgitmType == "14" { //其他费
  507. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  508. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  509. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  510. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  511. if item.ChrgitmLv == "1" {
  512. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  513. }
  514. if item.ChrgitmLv == "2" {
  515. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  516. }
  517. if item.ChrgitmLv == "3" {
  518. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  519. }
  520. }
  521. }
  522. var iteminfoStructs []service.IteminfoStruct
  523. if bedCostTotal != 0 {
  524. iteminfo.MedChrgitm = "01"
  525. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  526. iteminfo.Amt = bedCostTotal
  527. iteminfo.ClaaSumfee = bed_claa_sunmfee
  528. iteminfo.ClabAmt = bed_clab_amt
  529. iteminfo.OthAmt = bed_other_amt
  530. iteminfoStructs = append(iteminfoStructs, iteminfo)
  531. }
  532. if checkCostTotal != 0 {
  533. iteminfo.MedChrgitm = "03"
  534. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  535. iteminfo.Amt = checkCostTotal
  536. iteminfo.ClaaSumfee = check_claa_sunmfee
  537. iteminfo.ClabAmt = check_clab_amt
  538. iteminfo.OthAmt = check_other_amt
  539. iteminfoStructs = append(iteminfoStructs, iteminfo)
  540. }
  541. if laboratoryCostTotal != 0 {
  542. iteminfo.MedChrgitm = "04"
  543. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  544. iteminfo.Amt = laboratoryCostTotal
  545. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  546. iteminfo.ClabAmt = laboratory_clab_amt
  547. iteminfo.OthAmt = laboratory_other_amt
  548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  549. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  550. }
  551. if treatCostTotal != 0 {
  552. iteminfo.MedChrgitm = "05"
  553. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  554. iteminfo.Amt = treatCostTotal
  555. iteminfo.ClaaSumfee = treat_claa_sunmfee
  556. iteminfo.ClabAmt = treat_clab_amt
  557. iteminfo.OthAmt = treat_other_amt
  558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  559. // (struct4101.IteminfoStruct, iteminfo)
  560. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  561. }
  562. if operationCostTotal != 0 {
  563. iteminfo.MedChrgitm = "06"
  564. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  565. iteminfo.Amt = operationCostTotal
  566. iteminfo.ClaaSumfee = operation_claa_sunmfee
  567. iteminfo.ClabAmt = operation_clab_amt
  568. iteminfo.OthAmt = operation_other_amt
  569. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  571. }
  572. if materialCostTotal != 0 {
  573. iteminfo.MedChrgitm = "08"
  574. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  575. iteminfo.Amt = materialCostTotal
  576. iteminfo.ClaaSumfee = material_claa_sunmfee
  577. iteminfo.ClabAmt = material_clab_amt
  578. iteminfo.OthAmt = material_other_amt
  579. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  580. iteminfoStructs = append(iteminfoStructs, iteminfo)
  581. }
  582. if westernMedicineCostTotal != 0 {
  583. iteminfo.MedChrgitm = "09"
  584. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  585. iteminfo.Amt = westernMedicineCostTotal
  586. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  587. iteminfo.ClabAmt = westernMedicine_clab_amt
  588. iteminfo.OthAmt = westernMedicine_other_amt
  589. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  590. iteminfoStructs = append(iteminfoStructs, iteminfo)
  591. }
  592. if chineseTraditionalMedicineCostTotal != 0 {
  593. iteminfo.MedChrgitm = "11"
  594. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  595. iteminfo.Amt = westernMedicineCostTotal
  596. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  597. iteminfo.ClabAmt = westernMedicine_clab_amt
  598. iteminfo.OthAmt = westernMedicine_other_amt
  599. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  600. iteminfoStructs = append(iteminfoStructs, iteminfo)
  601. }
  602. if otherCostTotal != 0 {
  603. iteminfo.MedChrgitm = "14"
  604. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  605. iteminfo.Amt = otherCostTotal
  606. iteminfo.ClaaSumfee = other_claa_sunmfee
  607. iteminfo.ClabAmt = other_clab_amt
  608. iteminfo.OthAmt = other_other_amt
  609. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  610. iteminfoStructs = append(iteminfoStructs, iteminfo)
  611. }
  612. struct4101.IteminfoStruct = iteminfoStructs
  613. struct4101.Ntly = "中国"
  614. struct4101.AdmCaty = "A03.06"
  615. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  616. fmt.Println(result)
  617. var dat map[string]interface{}
  618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  619. fmt.Println(dat)
  620. } else {
  621. fmt.Println(err)
  622. }
  623. userJSONBytes, _ := json.Marshal(dat)
  624. var res ResultSeventeen
  625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  626. utils.ErrorLog("解析失败:%v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. if res.Infcode != 0 {
  631. c.ServeSuccessJSON(map[string]interface{}{
  632. "failed_code": -10,
  633. "msg": res.ErrMsg,
  634. })
  635. return
  636. } else {
  637. hisFundSettleListResult := &models.HisFundSettleListResult{
  638. Number: res.Output.SetlListId,
  639. Status: 1,
  640. Ctime: time.Now().Unix(),
  641. Mtime: time.Now().Unix(),
  642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  643. IsUpload: 1,
  644. OrderId: order_id,
  645. }
  646. service.CreateUploadRecord(hisFundSettleListResult)
  647. c.ServeSuccessJSON(map[string]interface{}{
  648. "msg": "上传成功",
  649. "result": hisFundSettleListResult,
  650. })
  651. return
  652. }
  653. }
  654. //func (c *HisApiController) TestPay() {
  655. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  656. // readCards := DllDef2.MustFindProc("BankTrans")
  657. // inputData := make(map[string]interface{})
  658. // inputData["transId"] = "05"
  659. // inputData["amount"] = "0.01"
  660. // inputData["traceNo"] = "20210227093601325405377"
  661. // inputData["cardNo"] = "F36084348"
  662. // inputData["id"] = "44022919620927046X"
  663. // //jsonStr := `
  664. // // {
  665. // // "transId": "05",
  666. // // "amount":"1.00",
  667. // // "traceNo":"20210227093601325405377",
  668. // // "cardNo":"F36084348",
  669. // // "id":"44022919620927046X"
  670. // //
  671. // // }
  672. // //`
  673. //
  674. // bytes_arr, _ := json.Marshal(inputData)
  675. // str3 := make([]byte, 256)
  676. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  677. // fmt.Println(":", string(str3))
  678. //
  679. // if err4 != nil {
  680. // fmt.Println("SSCard的运算结果为:", ret4)
  681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  682. // return
  683. // }
  684. //
  685. //}
  686. //func (c *HisApiController) TestGetBasBaseInfo() {
  687. //
  688. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  689. // //fmt.Println(result)
  690. // //cs1 := C.CString("")
  691. // //cs2 := C.CString("")
  692. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  693. // //fmt.Println(cs1)
  694. // //fmt.Println(cs2)
  695. // //C.free(unsafe.Pointer(cs1))
  696. // //C.free(unsafe.Pointer(cs2))
  697. //
  698. // //
  699. //
  700. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  701. // Iinit := DllDef.MustFindProc("Init")
  702. // readCard := DllDef.MustFindProc("ReadCardBas")
  703. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  704. // if ret != 0 {
  705. // fmt.Println("SSCard的报错原因:", err)
  706. // fmt.Println("SSCard的运算结果为:", ret)
  707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  708. // return
  709. // }
  710. //
  711. // result := int(ret)
  712. // fmt.Println("SSCard的运算结果为1:", result)
  713. //
  714. // //path := ""
  715. // //bytePath := []byte( "\x00")
  716. // //bytePath2 := []byte( "\x00")
  717. // //ssss
  718. //
  719. // str := make([]byte, 256)
  720. // str1 := make([]byte, 256)
  721. // s2 := []byte(string(str))
  722. // s3 := []byte(string(str1))
  723. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  724. // fmt.Println(" Add(4,5)的结果为:", ret2)
  725. // fmt.Println(" str:", s2)
  726. // fmt.Println(" str1:", s3)
  727. // if err2 != nil {
  728. // fmt.Println("SSCard的运算结果为:", ret2)
  729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  730. // return
  731. // }
  732. //
  733. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  734. //
  735. //}
  736. func (c *HisApiController) GetOrgInfo() {
  737. miConfig, _ := service.FindMedicalInsuranceInfo(9919)
  738. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  739. }
  740. func (c *HisApiController) GetHisPatientInfo() {
  741. medical_insurance_card := c.GetString("medical_insurance_card")
  742. id_card_type, _ := c.GetInt64("id_card_type")
  743. id_card := c.GetString("id_card")
  744. adminInfo := c.GetAdminUserInfo()
  745. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  746. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  747. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  748. IdCardNo := ""
  749. if id_card_type == 1 {
  750. IdCardNo = medical_insurance_card
  751. } else if id_card_type == 2 {
  752. IdCardNo = id_card
  753. }
  754. if config.IsOpen == 1 {
  755. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  756. resp, requestErr := http.Get(api)
  757. if requestErr != nil {
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. defer resp.Body.Close()
  762. body, ioErr := ioutil.ReadAll(resp.Body)
  763. if ioErr != nil {
  764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. var respJSON map[string]interface{}
  769. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  775. userJSONBytes, _ := json.Marshal(userJSON)
  776. var res ResultTwo
  777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  778. utils.ErrorLog("解析失败:%v", err)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. return
  781. }
  782. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  783. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  784. infoStr := string(Iinfos)
  785. idetinfoStr := string(Idetinfos)
  786. if res.Infcode == 0 {
  787. his := models.VMHisPatient{
  788. Status: 1,
  789. Ctime: time.Now().Unix(),
  790. Mtime: time.Now().Unix(),
  791. PsnNo: res.Output.Baseinfo.PsnNo,
  792. PsnCertType: res.Output.Baseinfo.PsnCertType,
  793. Certno: res.Output.Baseinfo.Certno,
  794. PsnName: res.Output.Baseinfo.PsnName,
  795. Gend: res.Output.Baseinfo.Gend,
  796. Naty: res.Output.Baseinfo.Naty,
  797. Brdy: res.Output.Baseinfo.Brdy,
  798. Age: res.Output.Baseinfo.Age,
  799. Iinfo: infoStr,
  800. Idetinfo: idetinfoStr,
  801. UserOrgId: adminInfo.CurrentOrgId,
  802. IsReturn: 1,
  803. IdCardType: id_card_type,
  804. }
  805. c.ServeSuccessJSON(map[string]interface{}{
  806. "info": his,
  807. })
  808. } else {
  809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  810. return
  811. }
  812. }
  813. }
  814. //func GetBasBaseInfo() (jsonStr string, err error) {
  815. //
  816. // handle := syscall.NewLazyDLL("SSCard.dll")
  817. // add := handle.NewProc("ReadCardBas")
  818. // str := make([]byte, 1024)
  819. // str1 := make([]byte, 1024)
  820. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  821. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  822. //
  823. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  824. //
  825. // fmt.Println("> Add(4,5)的结果为:", ret)
  826. // handle.Release()
  827. //
  828. // return "", nil
  829. //
  830. //}
  831. //func GetQRBaseInfo() (jsonStr string, err error) {
  832. // handle := syscall.LoadDLL("SSCard.dll")
  833. // ReadCardBas := handle.FindProc("GetQRBase")
  834. //
  835. // str := make([]byte, 256)
  836. // str1 := make([]byte, 256)
  837. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  838. //
  839. // fmt.Println(string(str))
  840. // fmt.Println(r)
  841. // return string(str), nil
  842. //}
  843. func CardInit() int {
  844. DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  845. add := DllTestDef.MustFindProc("Init")
  846. ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  847. if err != nil {
  848. fmt.Println("SSCard的运算结果为:", ret)
  849. }
  850. result := int(ret)
  851. return result
  852. }
  853. //func CardInit() int {
  854. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  855. // if err != nil {
  856. // fmt.Println("SSCard的运算结果为:", ret)
  857. // }
  858. // fmt.Println(err)
  859. // result := int(ret)
  860. // return result
  861. //}
  862. func IntPtr(n int) uintptr {
  863. return uintptr(n)
  864. }
  865. func StrPtr(s string) uintptr {
  866. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  867. }
  868. type ResultTwo struct {
  869. ErrMsg string `json:"err_msg"`
  870. InfRefmsgid string `json:"inf_refmsgid"`
  871. Infcode int64 `json:"infcode"`
  872. Output struct {
  873. Baseinfo struct {
  874. Age float64 `json:"age"`
  875. Brdy string `json:"brdy"`
  876. Certno string `json:"certno"`
  877. Gend string `json:"gend"`
  878. Naty string `json:"naty"`
  879. PsnCertType string `json:"psn_cert_type"`
  880. PsnName string `json:"psn_name"`
  881. PsnNo string `json:"psn_no"`
  882. } `json:"baseinfo"`
  883. Idetinfo []interface{} `json:"idetinfo"`
  884. Iinfo []struct {
  885. Balc float64 `json:"balc"`
  886. CvlservFlag string `json:"cvlserv_flag"`
  887. EmpName string `json:"emp_name"`
  888. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  889. Insutype string `json:"insutype"`
  890. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  891. PausInsuDate string `json:"paus_insu_date"`
  892. PsnInsuDate string `json:"psn_insu_date"`
  893. PsnInsuStas string `json:"psn_insu_stas"`
  894. PsnType string `json:"psn_type"`
  895. } `json:"insuinfo"`
  896. } `json:"output"`
  897. RefmsgTime string `json:"refmsg_time"`
  898. RespondTime string `json:"respond_time"`
  899. Signtype interface{} `json:"signtype"`
  900. WarnInfo interface{} `json:"warn_info"`
  901. }
  902. type ResultThree struct {
  903. Cainfo interface{} `json:"cainfo"`
  904. ErrMsg string `json:"err_msg"`
  905. InfRefmsgid string `json:"inf_refmsgid"`
  906. Infcode int64 `json:"infcode"`
  907. Output struct {
  908. Data struct {
  909. IptOtpNo string `json:"ipt_otp_no"`
  910. MdtrtID string `json:"mdtrt_id"`
  911. PsnNo string `json:"psn_no"`
  912. } `json:"data"`
  913. } `json:"output"`
  914. RefmsgTime string `json:"refmsg_time"`
  915. RespondTime string `json:"respond_time"`
  916. Signtype interface{} `json:"signtype"`
  917. WarnMsg interface{} `json:"warn_msg"`
  918. }
  919. type ResultFour struct {
  920. Cainfo string `json:"cainfo"`
  921. ErrMsg string `json:"err_msg"`
  922. InfRefmsgid string `json:"inf_refmsgid"`
  923. Infcode int64 `json:"infcode"`
  924. Output struct {
  925. Result []struct {
  926. BasMednFlag string `json:"bas_medn_flag"`
  927. ChldMedcFlag string `json:"chld_medc_flag"`
  928. ChrgitmLv string `json:"chrgitm_lv"`
  929. Cnt float64 `json:"cnt"`
  930. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  931. DrtReimFlag string `json:"drt_reim_flag"`
  932. FeedetlSn string `json:"feedetl_sn"`
  933. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  934. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  935. InscpScpAmt float64 `json:"inscp_scp_amt"`
  936. ListSpItemFlag string `json:"list_sp_item_flag"`
  937. LmtUsedFlag string `json:"lmt_used_flag"`
  938. MedChrgitmType string `json:"med_chrgitm_type"`
  939. Memo string `json:"memo"`
  940. OverlmtAmt float64 `json:"overlmt_amt"`
  941. PreselfpayAmt float64 `json:"preselfpay_amt"`
  942. Pric float64 `json:"pric"`
  943. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  944. SelfpayProp float64 `json:"selfpay_prop"`
  945. } `json:"result"`
  946. } `json:"output"`
  947. RefmsgTime string `json:"refmsg_time"`
  948. RespondTime string `json:"respond_time"`
  949. Signtype string `json:"signtype"`
  950. WarnMsg string `json:"warn_msg"`
  951. }
  952. type ResultFive struct {
  953. Balc float64 `json:"balc"`
  954. CvlservFlag string `json:"cvlserv_flag"`
  955. EmpName string `json:"emp_name"`
  956. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  957. Insutype string `json:"insutype"`
  958. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  959. PausInsuDate string `json:"paus_insu_date"`
  960. PsnInsuDate string `json:"psn_insu_date"`
  961. PsnInsuStas string `json:"psn_insu_stas"`
  962. PsnType string `json:"psn_type"`
  963. }
  964. type ResultSix struct {
  965. Cainfo interface{} `json:"cainfo"`
  966. ErrMsg string `json:"err_msg"`
  967. InfRefmsgid string `json:"inf_refmsgid"`
  968. Infcode int64 `json:"infcode"`
  969. Output struct {
  970. } `json:"output"`
  971. RefmsgTime string `json:"refmsg_time"`
  972. RespondTime string `json:"respond_time"`
  973. Signtype interface{} `json:"signtype"`
  974. WarnMsg interface{} `json:"warn_msg"`
  975. }
  976. type ResultSeven struct {
  977. Cainfo string `json:"cainfo"`
  978. ErrMsg string `json:"err_msg"`
  979. InfRefmsgid string `json:"inf_refmsgid"`
  980. Infcode int64 `json:"infcode"`
  981. Output struct {
  982. Setldetail []interface{} `json:"setldetail"`
  983. Setlinfo struct {
  984. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  985. AcctPay float64 `json:"acct_pay"`
  986. ActPayDedc float64 `json:"act_pay_dedc"`
  987. Age float64 `json:"age"`
  988. Balc float64 `json:"balc"`
  989. Brdy string `json:"brdy"`
  990. Certno string `json:"certno"`
  991. ClrOptins string `json:"clr_optins"`
  992. ClrType string `json:"clr_type"`
  993. ClrWay string `json:"clr_way"`
  994. CvlservFlag string `json:"cvlserv_flag"`
  995. CvlservPay float64 `json:"cvlserv_pay"`
  996. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  997. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  998. Gend string `json:"gend"`
  999. HifesPay float64 `json:"hifes_pay"`
  1000. HifmiPay float64 `json:"hifmi_pay"`
  1001. HifpPay float64 `json:"hifp_pay"`
  1002. HospPartAmt float64 `json:"hosp_part_amt"`
  1003. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1004. Insutype string `json:"insutype"`
  1005. MafPay float64 `json:"maf_pay"`
  1006. MdtrtCertType string `json:"mdtrt_cert_type"`
  1007. HifobPay float64 `json:"hifob_pay"`
  1008. MdtrtID string `json:"mdtrt_id"`
  1009. MedType string `json:"med_type"`
  1010. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1011. MedinsSetlID string `json:"medins_setl_id"`
  1012. Naty string `json:"naty"`
  1013. OthPay float64 `json:"oth_pay"`
  1014. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1015. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1016. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1017. PsnCashPay float64 `json:"psn_cash_pay"`
  1018. PsnCertType string `json:"psn_cert_type"`
  1019. PsnName string `json:"psn_name"`
  1020. PsnNo string `json:"psn_no"`
  1021. PsnPartAmt float64 `json:"psn_part_amt"`
  1022. PsnType string `json:"psn_type"`
  1023. SetlID string `json:"setl_id"`
  1024. SetlTime string `json:"setl_time"`
  1025. } `json:"setlinfo"`
  1026. } `json:"output"`
  1027. RefmsgTime string `json:"refmsg_time"`
  1028. RespondTime string `json:"respond_time"`
  1029. Signtype interface{} `json:"signtype"`
  1030. WarnMsg interface{} `json:"warn_msg"`
  1031. }
  1032. type ResultEight struct {
  1033. Cainfo string `json:"cainfo"`
  1034. ErrMsg string `json:"err_msg"`
  1035. InfRefmsgid string `json:"inf_refmsgid"`
  1036. Infcode int64 `json:"infcode"`
  1037. Output struct {
  1038. Stmtinfo struct {
  1039. SetlOptins string `json:"setl_optins"`
  1040. StmtRslt string `json:"stmt_rslt"`
  1041. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1042. } `json:"stmtinfo"`
  1043. } `json:"output"`
  1044. RefmsgTime string `json:"refmsg_time"`
  1045. RespondTime string `json:"respond_time"`
  1046. Signtype interface{} `json:"signtype"`
  1047. WarnMsg interface{} `json:"warn_msg"`
  1048. }
  1049. type ResultNine struct {
  1050. Cainfo string `json:"cainfo"`
  1051. ErrMsg string `json:"err_msg"`
  1052. InfRefmsgid string `json:"inf_refmsgid"`
  1053. Infcode int64 `json:"infcode"`
  1054. Output struct {
  1055. FileQuryNo string `json:"file_qury_no"`
  1056. } `json:"output"`
  1057. RefmsgTime string `json:"refmsg_time"`
  1058. RespondTime string `json:"respond_time"`
  1059. Signtype interface{} `json:"signtype"`
  1060. WarnMsg interface{} `json:"warn_msg"`
  1061. }
  1062. type ResultTen struct {
  1063. Cainfo string `json:"cainfo"`
  1064. ErrMsg string `json:"err_msg"`
  1065. InfRefmsgid string `json:"inf_refmsgid"`
  1066. Infcode int64 `json:"infcode"`
  1067. Output struct {
  1068. DldEndtime string `json:"dld_endtime"`
  1069. FileQuryNo string `json:"file_qury_no"`
  1070. Filename string `json:"filename"`
  1071. } `json:"output"`
  1072. RefmsgTime string `json:"refmsg_time"`
  1073. RespondTime string `json:"respond_time"`
  1074. Signtype interface{} `json:"signtype"`
  1075. WarnMsg interface{} `json:"warn_msg"`
  1076. }
  1077. //type Autogenerated struct {
  1078. // Output struct {
  1079. // Setlinfo struct {
  1080. // SetlTime string `json:"setl_time"`
  1081. // CvlservPay float64 `json:"cvlserv_pay"`
  1082. // Year string `json:"year"`
  1083. // MedType string `json:"med_type"`
  1084. // PsnPay float64 `json:"psn_pay"`
  1085. // OpterID string `json:"opter_id"`
  1086. // Begndate string `json:"begndate"`
  1087. // FlxempeFlag string `json:"flxempe_flag"`
  1088. // HifmiPay float64 `json:"hifmi_pay"`
  1089. // PsnNo string `json:"psn_no"`
  1090. // ActPayDedc float64 `json:"act_pay_dedc"`
  1091. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1092. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1093. // ClrWay string `json:"clr_way"`
  1094. // OthPay float64 `json:"oth_pay"`
  1095. // Gend string `json:"gend"`
  1096. // MdtrtID string `json:"mdtrt_id"`
  1097. // AcctPay float64 `json:"acct_pay"`
  1098. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1099. // Insutype string `json:"insutype"`
  1100. // Invono interface{} `json:"invono"`
  1101. // Enddate string `json:"enddate"`
  1102. // CashPayamt float64 `json:"cash_payamt"`
  1103. // PsnType string `json:"psn_type"`
  1104. // FixmedinsName string `json:"fixmedins_name"`
  1105. // HifpPay float64 `json:"hifp_pay"`
  1106. // NewFlag interface{} `json:"new_flag"`
  1107. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1108. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1109. // PayLoc string `json:"pay_loc"`
  1110. // ClrType string `json:"clr_type"`
  1111. // RefdSetlFlag string `json:"refd_setl_flag"`
  1112. // CvlservFlag string `json:"cvlserv_flag"`
  1113. // EmpName string `json:"emp_name"`
  1114. // Brdy string `json:"brdy"`
  1115. // Naty string `json:"naty"`
  1116. // Certno string `json:"certno"`
  1117. // DiseCode string `json:"dise_code"`
  1118. // FixmedinsCode string `json:"fixmedins_code"`
  1119. // DedcHospLv string `json:"dedc_hosp_lv"`
  1120. // OpterName string `json:"opter_name"`
  1121. // Balc float64 `json:"balc"`
  1122. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1123. // PsnCertType string `json:"psn_cert_type"`
  1124. // HifobPay float64 `json:"hifob_pay"`
  1125. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1126. // HifesPay float64 `json:"hifes_pay"`
  1127. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1128. // OptTime string `json:"opt_time"`
  1129. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1130. // SetlID string `json:"setl_id"`
  1131. // MafPay float64 `json:"maf_pay"`
  1132. // PsnName string `json:"psn_name"`
  1133. // InsuOptins interface{} `json:"insu_optins"`
  1134. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1135. // ClrOptins string `json:"clr_optins"`
  1136. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1137. // DiseName string `json:"dise_name"`
  1138. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1139. // Age float64 `json:"age"`
  1140. // DtrtCertType string `json:"dtrt_cert_type"`
  1141. // HospLv string `json:"hosp_lv"`
  1142. // } `json:"setlinfo"`
  1143. // Setldetail []struct {
  1144. // FundPayType string `json:"fund_pay_type"`
  1145. // FundPayamt float64 `json:"fund_payamt"`
  1146. // SetlProcInfo interface{} `json:"setl_proc_info"`
  1147. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  1148. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  1149. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  1150. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1151. // } `json:"setldetail"`
  1152. // } `json:"output"`
  1153. // Infcode int `json:"infcode"`
  1154. // WarnMsg interface{} `json:"warn_msg"`
  1155. // Cainfo interface{} `json:"cainfo"`
  1156. // ErrMsg interface{} `json:"err_msg"`
  1157. // RefmsgTime string `json:"refmsg_time"`
  1158. // Signtype interface{} `json:"signtype"`
  1159. // RespondTime string `json:"respond_time"`
  1160. // InfRefmsgid string `json:"inf_refmsgid"`
  1161. //}
  1162. type ResultEleven struct {
  1163. Cainfo string `json:"cainfo"`
  1164. ErrMsg string `json:"err_msg"`
  1165. InfRefmsgid string `json:"inf_refmsgid"`
  1166. Infcode int64 `json:"infcode"`
  1167. Output struct {
  1168. Setlinfo struct {
  1169. SetlTime string `json:"setl_time"`
  1170. CvlservPay float64 `json:"cvlserv_pay"`
  1171. Year string `json:"year"`
  1172. MedType string `json:"med_type"`
  1173. PsnPay float64 `json:"psn_pay"`
  1174. OpterID string `json:"opter_id"`
  1175. Begndate string `json:"begndate"`
  1176. FlxempeFlag string `json:"flxempe_flag"`
  1177. HifmiPay float64 `json:"hifmi_pay"`
  1178. PsnNo string `json:"psn_no"`
  1179. ActPayDedc float64 `json:"act_pay_dedc"`
  1180. MedinsSetlID interface{} `json:"medins_setl_id"`
  1181. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1182. ClrWay string `json:"clr_way"`
  1183. OthPay float64 `json:"oth_pay"`
  1184. Gend string `json:"gend"`
  1185. MdtrtID string `json:"mdtrt_id"`
  1186. AcctPay float64 `json:"acct_pay"`
  1187. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1188. Insutype string `json:"insutype"`
  1189. Invono interface{} `json:"invono"`
  1190. Enddate string `json:"enddate"`
  1191. CashPayamt float64 `json:"cash_payamt"`
  1192. PsnType string `json:"psn_type"`
  1193. FixmedinsName string `json:"fixmedins_name"`
  1194. HifpPay float64 `json:"hifp_pay"`
  1195. NewFlag interface{} `json:"new_flag"`
  1196. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1198. PayLoc string `json:"pay_loc"`
  1199. ClrType string `json:"clr_type"`
  1200. RefdSetlFlag string `json:"refd_setl_flag"`
  1201. CvlservFlag string `json:"cvlserv_flag"`
  1202. EmpName string `json:"emp_name"`
  1203. Brdy string `json:"brdy"`
  1204. Naty string `json:"naty"`
  1205. Certno string `json:"certno"`
  1206. DiseCode string `json:"dise_code"`
  1207. FixmedinsCode string `json:"fixmedins_code"`
  1208. DedcHospLv string `json:"dedc_hosp_lv"`
  1209. OpterName string `json:"opter_name"`
  1210. Balc float64 `json:"balc"`
  1211. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1212. PsnCertType string `json:"psn_cert_type"`
  1213. HifobPay float64 `json:"hifob_pay"`
  1214. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1215. HifesPay float64 `json:"hifes_pay"`
  1216. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1217. OptTime string `json:"opt_time"`
  1218. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1219. SetlID string `json:"setl_id"`
  1220. MafPay float64 `json:"maf_pay"`
  1221. PsnName string `json:"psn_name"`
  1222. InsuOptins interface{} `json:"insu_optins"`
  1223. PrefFundPay interface{} `json:"pref_fund_pay"`
  1224. ClrOptins string `json:"clr_optins"`
  1225. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1226. DiseName string `json:"dise_name"`
  1227. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1228. Age float64 `json:"age"`
  1229. DtrtCertType string `json:"dtrt_cert_type"`
  1230. HospLv string `json:"hosp_lv"`
  1231. } `json:"setlinfo"`
  1232. } `json:"output"`
  1233. RefmsgTime string `json:"refmsg_time"`
  1234. RespondTime string `json:"respond_time"`
  1235. Signtype interface{} `json:"signtype"`
  1236. WarnMsg interface{} `json:"warn_msg"`
  1237. }
  1238. type ResultTwelve struct {
  1239. Cainfo string `json:"cainfo"`
  1240. ErrMsg string `json:"err_msg"`
  1241. InfRefmsgid string `json:"inf_refmsgid"`
  1242. Infcode int64 `json:"infcode"`
  1243. Output struct {
  1244. MdtrtId string `json:"mdtrt_id"`
  1245. ChrgBchno string `json:"chrg_bchno"`
  1246. PsnNo string `json:"psn_no"`
  1247. } `json:"output"`
  1248. RefmsgTime string `json:"refmsg_time"`
  1249. RespondTime string `json:"respond_time"`
  1250. Signtype interface{} `json:"signtype"`
  1251. WarnMsg interface{} `json:"warn_msg"`
  1252. }
  1253. type ResultThirteen struct {
  1254. ErrMsg string `json:"err_msg"`
  1255. InfRefmsgid string `json:"inf_refmsgid"`
  1256. Infcode int64 `json:"infcode"`
  1257. Output struct {
  1258. Result struct {
  1259. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  1260. } `json:"result"`
  1261. } `json:"output"`
  1262. RefmsgTime string `json:"refmsg_time"`
  1263. RespondTime string `json:"respond_time"`
  1264. Signtype interface{} `json:"signtype"`
  1265. WarnInfo interface{} `json:"warn_info"`
  1266. }
  1267. type ResultFourteen struct {
  1268. ErrMsg string `json:"err_msg"`
  1269. InfRefmsgid string `json:"inf_refmsgid"`
  1270. Infcode int64 `json:"infcode"`
  1271. Output struct {
  1272. } `json:"output"`
  1273. RefmsgTime string `json:"refmsg_time"`
  1274. RespondTime string `json:"respond_time"`
  1275. Signtype interface{} `json:"signtype"`
  1276. WarnInfo interface{} `json:"warn_info"`
  1277. }
  1278. type ResultSixteen struct {
  1279. Cainfo string `json:"cainfo"`
  1280. ErrMsg string `json:"err_msg"`
  1281. InfRefmsgid string `json:"inf_refmsgid"`
  1282. Infcode int64 `json:"infcode"`
  1283. Output struct {
  1284. Setldetail []interface{} `json:"setldetail"`
  1285. Setlinfo struct {
  1286. MdtrtID string `json:"mdtrt_id"`
  1287. SetlID string `json:"setl_id"`
  1288. ClrOptins string `json:"clr_optins"`
  1289. SetlTime string `json:"setl_time"`
  1290. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1291. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1292. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1293. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1294. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1295. ActPayDedc float64 `json:"act_pay_dedc"`
  1296. HifpPay float64 `json:"hifp_pay"`
  1297. PoolPropSe float64 `json:"pool_prop_selfpay"`
  1298. Lfpay float64 `json:"selfpay"`
  1299. CvlservPay float64 `json:"cvlserv_pay"`
  1300. HifesPay float64 `json:"hifes_pay"`
  1301. HifmiPay float64 `json:"hifmi_pay"`
  1302. HifobPay float64 `json:"hifob_pay"`
  1303. MafPay float64 `json:"maf_pay"`
  1304. OthPay float64 `json:"oth_pay"`
  1305. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1306. PsnPartAmt float64 `json:"psn_part_amt"`
  1307. AcctPay float64 `json:"acct_pay"`
  1308. Balc float64 `json:"balc"`
  1309. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1310. HospPartAmt float64 `json:"hosp_part_amt"`
  1311. MedinsSetlID string `json:"medins_setl_id"`
  1312. PdnCashPay string `json:"pdn_cash_pay"`
  1313. } `json:"setlinfo"`
  1314. } `json:"output"`
  1315. RefmsgTime string `json:"refmsg_time"`
  1316. RespondTime string `json:"respond_time"`
  1317. Signtype interface{} `json:"signtype"`
  1318. WarnMsg interface{} `json:"warn_msg"`
  1319. }
  1320. type ResultSeventeen struct {
  1321. ErrMsg string `json:"err_msg"`
  1322. InfRefmsgid string `json:"inf_refmsgid"`
  1323. Infcode int64 `json:"infcode"`
  1324. Output struct {
  1325. SetlListId string `json:"setl_list_id"`
  1326. } `json:"output"`
  1327. RefmsgTime string `json:"refmsg_time"`
  1328. RespondTime string `json:"respond_time"`
  1329. Signtype string `json:"signtype"`
  1330. WarnInfo string `json:"warn_info"`
  1331. }
  1332. type Custom struct {
  1333. DetItemFeeSumamt string
  1334. Cut string
  1335. FeedetlSn string
  1336. Price string
  1337. MedListCodg string
  1338. Type int64
  1339. AdviceId int64
  1340. ProjectId int64
  1341. ItemId int64
  1342. }
  1343. //获取个人信息----挂号-----上传就诊信息
  1344. func (c *HisApiController) GetRegisterInfo() {
  1345. id, _ := c.GetInt64("id")
  1346. record_time := c.GetString("record_time")
  1347. settlementValue, _ := c.GetInt64("settlement_value")
  1348. medical_insurance_card := c.GetString("medical_insurance_card")
  1349. name := c.GetString("name")
  1350. id_card_type, _ := c.GetInt64("id_card_type")
  1351. certificates, _ := c.GetInt64("certificates")
  1352. medical_care, _ := c.GetInt64("medical_care")
  1353. birthday := c.GetString("birthday")
  1354. //age, _ := c.GetInt64("age")
  1355. id_card := c.GetString("id_card")
  1356. register_type, _ := c.GetInt64("register")
  1357. doctor, _ := c.GetInt64("doctor")
  1358. department, _ := c.GetInt64("department")
  1359. gender, _ := c.GetInt64("sex")
  1360. //phone := c.GetString("phone")
  1361. registration_fee, _ := c.GetFloat("registration_fee")
  1362. medical_expenses, _ := c.GetFloat("medical_expenses")
  1363. social_type, _ := c.GetInt64("social_type")
  1364. admin_user_id, _ := c.GetInt64("admin_user_id")
  1365. timeLayout := "2006-01-02"
  1366. loc, _ := time.LoadLocation("Local")
  1367. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1368. birthUnix := birthdays.Unix()
  1369. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1370. if err != nil {
  1371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1372. return
  1373. }
  1374. recordDateTime := theTime.Unix()
  1375. adminInfo := c.GetAdminUserInfo()
  1376. var patient service.Patients
  1377. if id == 0 {
  1378. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1379. } else {
  1380. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1381. }
  1382. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1383. if patientPrescription.ID == 0 {
  1384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1385. }
  1386. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  1387. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  1388. //sickConfig, _ := service.FindSickById(sick_type)
  1389. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1390. if patient.ID == 0 {
  1391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1392. return
  1393. }
  1394. if len(patient.IdCardNo) == 0 {
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1396. return
  1397. }
  1398. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1399. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1400. //就诊结算未完成,不能进行二次挂号
  1401. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1402. if len(his) >= 1 {
  1403. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  1404. if len(his) >= 1 && order.ID == 0 {
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  1406. return
  1407. }
  1408. }
  1409. if config.IsOpen == 1 {
  1410. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
  1411. resp, requestErr := http.Get(api)
  1412. if requestErr != nil {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. return
  1415. }
  1416. defer resp.Body.Close()
  1417. body, ioErr := ioutil.ReadAll(resp.Body)
  1418. if ioErr != nil {
  1419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1421. return
  1422. }
  1423. var respJSON map[string]interface{}
  1424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1427. return
  1428. }
  1429. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1430. userJSONBytes, _ := json.Marshal(userJSON)
  1431. var res ResultTwo
  1432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1433. utils.ErrorLog("解析失败:%v", err)
  1434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1435. return
  1436. }
  1437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1439. infoStr := string(Iinfos)
  1440. idetinfoStr := string(Idetinfos)
  1441. if res.Infcode == 0 {
  1442. his := models.VMHisPatient{
  1443. Name: name,
  1444. Gender: gender,
  1445. Birthday: birthUnix,
  1446. MedicalTreatmentType: medical_care,
  1447. IdType: certificates,
  1448. IdCardNo: id_card,
  1449. BalanceAccountsType: settlementValue,
  1450. SocialType: social_type,
  1451. MedicalInsuranceNumber: medical_insurance_card,
  1452. RegisterType: register_type,
  1453. RegisterCost: registration_fee,
  1454. TreatmentCost: medical_expenses,
  1455. Status: 1,
  1456. Ctime: time.Now().Unix(),
  1457. Mtime: time.Now().Unix(),
  1458. PsnNo: res.Output.Baseinfo.PsnNo,
  1459. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1460. Certno: res.Output.Baseinfo.Certno,
  1461. PsnName: res.Output.Baseinfo.PsnName,
  1462. Gend: res.Output.Baseinfo.Gend,
  1463. Naty: res.Output.Baseinfo.Naty,
  1464. Brdy: res.Output.Baseinfo.Brdy,
  1465. Age: res.Output.Baseinfo.Age,
  1466. Iinfo: infoStr,
  1467. Idetinfo: idetinfoStr,
  1468. PatientId: patient.ID,
  1469. RecordDate: theTime.Unix(),
  1470. UserOrgId: adminInfo.CurrentOrgId,
  1471. AdminUserId: admin_user_id,
  1472. IsReturn: 1,
  1473. IdCardType: id_card_type,
  1474. Doctor: doctor,
  1475. Departments: department,
  1476. }
  1477. timestamp := time.Now().Unix()
  1478. tempTime := time.Unix(timestamp, 0)
  1479. timeFormat := tempTime.Format("20060102150405")
  1480. chrgBchno := rand.Intn(100000) + 10000
  1481. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1482. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1483. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1484. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1485. IdCardNo := ""
  1486. if id_card_type == 1 {
  1487. IdCardNo = medical_insurance_card
  1488. } else {
  1489. IdCardNo = patient.IdCardNo
  1490. }
  1491. var insutypes []string
  1492. var insutype string
  1493. var is390 int = 0
  1494. var is310 int = 0
  1495. for _, item := range res.Output.Iinfo {
  1496. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1497. insutypes = append(insutypes, item.Insutype)
  1498. }
  1499. }
  1500. if len(insutypes) == 1 {
  1501. insutype = insutypes[0]
  1502. } else {
  1503. for _, i := range insutypes {
  1504. if i == "390" {
  1505. is390 = 1
  1506. }
  1507. if i == "310" {
  1508. is310 = 1
  1509. }
  1510. }
  1511. }
  1512. if is390 == 1 {
  1513. insutype = "390"
  1514. }
  1515. if is310 == 1 {
  1516. insutype = "310"
  1517. }
  1518. if len(insutypes) == 0 {
  1519. insutype = "310"
  1520. }
  1521. //insutype = "390"
  1522. //if count == 1 {
  1523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1524. // return
  1525. //}
  1526. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1527. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1528. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1529. "&dept=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  1530. resp, requestErr := http.Get(api)
  1531. if requestErr != nil {
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. return
  1534. }
  1535. defer resp.Body.Close()
  1536. body, ioErr := ioutil.ReadAll(resp.Body)
  1537. if ioErr != nil {
  1538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1540. return
  1541. }
  1542. var respJSON map[string]interface{}
  1543. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1546. return
  1547. }
  1548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1549. userJSONBytes, _ := json.Marshal(respJSON)
  1550. var res ResultThree
  1551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. if res.Infcode != 0 {
  1557. adminUser := c.GetAdminUserInfo()
  1558. errlog := &models.HisOrderError{
  1559. UserOrgId: adminUser.CurrentOrgId,
  1560. Ctime: time.Now().Unix(),
  1561. Mtime: time.Now().Unix(),
  1562. ErrMsg: res.ErrMsg,
  1563. Status: 1,
  1564. PatientId: id,
  1565. RecordTime: recordDateTime,
  1566. Stage: 2,
  1567. }
  1568. service.CreateErrMsgLog(errlog)
  1569. c.ServeSuccessJSON(map[string]interface{}{
  1570. "failed_code": -10,
  1571. "msg": res.ErrMsg,
  1572. })
  1573. return
  1574. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1575. //return
  1576. }
  1577. his.Number = res.Output.Data.MdtrtID
  1578. his.PsnNo = res.Output.Data.PsnNo
  1579. his.IptOtpNo = res.Output.Data.IptOtpNo
  1580. his.IdCardNo = patient.IdCardNo
  1581. his.PhoneNumber = patient.Phone
  1582. his.UserOrgId = adminInfo.CurrentOrgId
  1583. his.Ctime = time.Now().Unix()
  1584. his.Mtime = time.Now().Unix()
  1585. his.Status = 1
  1586. service.UpdateHisPatientStatus(&his)
  1587. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1588. if len(lists) == 1 {
  1589. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1590. }
  1591. c.ServeSuccessJSON(map[string]interface{}{
  1592. "his_info": his,
  1593. })
  1594. } else {
  1595. adminUser := c.GetAdminUserInfo()
  1596. errlog := &models.HisOrderError{
  1597. UserOrgId: adminUser.CurrentOrgId,
  1598. Ctime: time.Now().Unix(),
  1599. Mtime: time.Now().Unix(),
  1600. ErrMsg: res.ErrMsg,
  1601. Status: 1,
  1602. PatientId: id,
  1603. RecordTime: recordDateTime,
  1604. Stage: 1,
  1605. }
  1606. service.CreateErrMsgLog(errlog)
  1607. c.ServeSuccessJSON(map[string]interface{}{
  1608. "failed_code": -10,
  1609. "msg": res.ErrMsg,
  1610. })
  1611. return
  1612. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1613. }
  1614. }
  1615. }
  1616. //上传明细----预结算----确认订单
  1617. func (c *HisApiController) GetUploadInfo() {
  1618. id, _ := c.GetInt64("id")
  1619. record_time := c.GetString("record_time")
  1620. his_patient_id, _ := c.GetInt64("his_patient_id")
  1621. order_id, _ := c.GetInt64("order_id")
  1622. pay_way, _ := c.GetInt64("pay_way")
  1623. pay_price, _ := c.GetFloat("pay_price")
  1624. pay_card_no := c.GetString("pay_card_no")
  1625. discount_price, _ := c.GetFloat("discount_price")
  1626. preferential_price, _ := c.GetFloat("preferential_price")
  1627. reality_price, _ := c.GetFloat("reality_price")
  1628. found_price, _ := c.GetFloat("found_price")
  1629. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1630. private_price, _ := c.GetFloat("private_price")
  1631. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1632. admin_user_id, _ := c.GetInt64("admin_user_id")
  1633. fapiao_code := c.GetString("fapiao_code")
  1634. fapiao_number := c.GetString("fapiao_number")
  1635. diagnosis_id := c.GetString("diagnosis")
  1636. sick_type, _ := c.GetInt64("sick_type")
  1637. reg_type, _ := c.GetInt64("p_type")
  1638. timeLayout := "2006-01-02"
  1639. loc, _ := time.LoadLocation("Local")
  1640. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1641. if err != nil {
  1642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1643. return
  1644. }
  1645. recordDateTime := theTime.Unix()
  1646. adminUser := c.GetAdminUserInfo()
  1647. tempOrder, _ := service.GetHisOrderByID(order_id)
  1648. var prescriptions []*models.HisPrescription
  1649. var start_time int64
  1650. var end_time int64
  1651. //if adminUser.CurrentOrgId == 10106{
  1652. // if len(fapiao_code) == 0{
  1653. // fapiao_code = "144072080589"
  1654. // }
  1655. // if len(fapiao_number) == 0{
  1656. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1657. // if order.ID == 0{
  1658. // fapiao_number = "00001520"
  1659. // }else{
  1660. // //fapiao_code = "00001520"
  1661. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1662. // var zero string
  1663. // if fpNumber >= 1000{
  1664. // zero = "0000" + strconv.Itoa(fpNumber)
  1665. // }else if fpNumber >= 10000{
  1666. // zero = "000" + strconv.Itoa(fpNumber)
  1667. // } else if fpNumber >= 100000{
  1668. // zero = "00" + strconv.Itoa(fpNumber)
  1669. // } else if fpNumber >= 1000000{
  1670. // zero = "0" + strconv.Itoa(fpNumber)
  1671. // }else {
  1672. // zero = strconv.Itoa(fpNumber)
  1673. // }
  1674. // fapiao_number = zero
  1675. // }
  1676. // }
  1677. //}
  1678. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1679. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1680. patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1681. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1682. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1683. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1684. var config []*models.HisXtDiagnoseConfig
  1685. for _, item := range diagnosis_ids {
  1686. id, _ := strconv.ParseInt(item, 10, 64)
  1687. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1688. config = append(config, diagnosisConfig)
  1689. }
  1690. sickConfig, _ := service.FindSickById(sick_type)
  1691. if tempOrder.ID == 0 {
  1692. var result string
  1693. if miConfig.InsuplcAdmdvs == "440781" { //
  1694. result = service.Gdyb2203A(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1695. } else {
  1696. result = service.Gdyb2203(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1697. }
  1698. var respJSON2 map[string]interface{}
  1699. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1702. return
  1703. }
  1704. userJSONBytes2, _ := json.Marshal(respJSON2)
  1705. var res2 ResultSix
  1706. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1707. utils.ErrorLog("解析失败:%v", err)
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1709. return
  1710. }
  1711. if res2.Infcode != 0 {
  1712. adminUser := c.GetAdminUserInfo()
  1713. errlog := &models.HisOrderError{
  1714. UserOrgId: adminUser.CurrentOrgId,
  1715. Ctime: time.Now().Unix(),
  1716. Mtime: time.Now().Unix(),
  1717. ErrMsg: res2.ErrMsg,
  1718. Status: 1,
  1719. PatientId: id,
  1720. RecordTime: recordDateTime,
  1721. Stage: 3,
  1722. }
  1723. service.CreateErrMsgLog(errlog)
  1724. c.ServeSuccessJSON(map[string]interface{}{
  1725. "failed_code": -10,
  1726. "msg": res2.ErrMsg,
  1727. })
  1728. return
  1729. } else {
  1730. his.Diagnosis = diagnosis_id
  1731. his.SickType = sickConfig.ID
  1732. his.PType = fmt.Sprintf("%d", reg_type)
  1733. service.UpdateHisPatientThree(&his)
  1734. data := make(map[string]interface{})
  1735. if settle_accounts_type == 1 { //日结
  1736. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  1737. data["pre"] = prescriptions
  1738. } else { //月结
  1739. start_time_str := c.GetString("start_time")
  1740. end_time_str := c.GetString("end_time")
  1741. timeLayout := "2006-01-02"
  1742. loc, _ := time.LoadLocation("Local")
  1743. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1744. if err != nil {
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1746. return
  1747. }
  1748. recordStartTime := theStartTime.Unix()
  1749. start_time = recordStartTime
  1750. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1751. if err != nil {
  1752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1753. return
  1754. }
  1755. recordEndTime := theEndTime.Unix()
  1756. end_time = recordEndTime
  1757. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  1758. data["pre"] = prescriptions
  1759. }
  1760. timestamp := time.Now().Unix()
  1761. tempTime := time.Unix(timestamp, 0)
  1762. timeFormat := tempTime.Format("20060102150405")
  1763. chrgBchno := rand.Intn(100000) + 10000
  1764. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1765. strconv.FormatInt(his.PatientId, 10)
  1766. client := &http.Client{}
  1767. data["psn_no"] = his.PsnNo
  1768. data["mdtrt_id"] = his.Number
  1769. data["chrg_bchno"] = chrg_bchno
  1770. data["org_name"] = miConfig.OrgName
  1771. data["doctor"] = roles.UserName
  1772. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1773. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1774. data["fixmedins_code"] = miConfig.Code
  1775. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1776. data["dept_code"] = "15"
  1777. } else {
  1778. data["dept_code"] = department.Number
  1779. }
  1780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1782. data["secret_key"] = miConfig.SecretKey
  1783. var ids []int64
  1784. for _, item := range prescriptions {
  1785. ids = append(ids, item.ID)
  1786. }
  1787. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1788. if config.IsOpen == 1 { //对接了医保,走医保流程
  1789. bytesData, _ := json.Marshal(data)
  1790. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1791. resp, _ := client.Do(req)
  1792. defer resp.Body.Close()
  1793. body, ioErr := ioutil.ReadAll(resp.Body)
  1794. if ioErr != nil {
  1795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1797. return
  1798. }
  1799. var respJSON map[string]interface{}
  1800. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1803. return
  1804. }
  1805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1806. userJSONBytes, _ := json.Marshal(respJSON)
  1807. var res ResultFour
  1808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1809. utils.ErrorLog("解析失败:%v", err)
  1810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. return
  1812. }
  1813. if res.Infcode == 0 {
  1814. order := &models.HisOrder{
  1815. UserOrgId: adminUser.CurrentOrgId,
  1816. HisPatientId: his.ID,
  1817. PatientId: his.PatientId,
  1818. SettleAccountsDate: recordDateTime,
  1819. Ctime: time.Now().Unix(),
  1820. Mtime: time.Now().Unix(),
  1821. Status: 1,
  1822. Number: chrg_bchno,
  1823. Infcode: res.Infcode,
  1824. WarnMsg: res.WarnMsg,
  1825. Cainfo: res.Cainfo,
  1826. ErrMsg: res.ErrMsg,
  1827. RespondTime: res.RefmsgTime,
  1828. InfRefmsgid: res.InfRefmsgid,
  1829. OrderStatus: 1,
  1830. PayWay: pay_way,
  1831. PayPrice: pay_price,
  1832. PayCardNo: pay_card_no,
  1833. DiscountPrice: discount_price,
  1834. PreferentialPrice: preferential_price,
  1835. RealityPrice: reality_price,
  1836. FoundPrice: found_price,
  1837. MedicalInsurancePrice: medical_insurance_price,
  1838. PrivatePrice: private_price,
  1839. IsMedicineInsurance: 1,
  1840. SettleType: settle_accounts_type,
  1841. SettleStartTime: start_time,
  1842. SettleEndTime: end_time,
  1843. Creator: roles.AdminUserId,
  1844. Modify: roles.AdminUserId,
  1845. FaPiaoNumber: fapiao_number,
  1846. FaPiaoCode: fapiao_code,
  1847. PType: 2,
  1848. Diagnosis: diagnosis_id,
  1849. }
  1850. err = service.CreateOrder(order)
  1851. if err != nil {
  1852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1853. return
  1854. }
  1855. for _, item := range res.Output.Result {
  1856. temp := strings.Split(item.FeedetlSn, "-")
  1857. var advice_id int64 = 0
  1858. var project_id int64 = 0
  1859. var types int64 = 0
  1860. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1861. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1862. if temp[1] == "1" {
  1863. advice_id = id
  1864. project_id = 0
  1865. } else if temp[1] == "2" {
  1866. advice_id = 0
  1867. project_id = id
  1868. }
  1869. info := &models.HisOrderInfo{
  1870. OrderNumber: order.Number,
  1871. FeedetlSn: item.FeedetlSn,
  1872. UploadDate: time.Now().Unix(),
  1873. AdviceId: advice_id,
  1874. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1875. Cnt: item.Cnt,
  1876. Pric: float64(item.Pric),
  1877. PatientId: his.PatientId,
  1878. PricUplmtAmt: item.PricUplmtAmt,
  1879. SelfpayProp: item.SelfpayProp,
  1880. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1881. OverlmtAmt: item.OverlmtAmt,
  1882. PreselfpayAmt: item.PreselfpayAmt,
  1883. BasMednFlag: item.BasMednFlag,
  1884. MedChrgitmType: item.MedChrgitmType,
  1885. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1886. Status: 1,
  1887. Memo: item.Memo,
  1888. Mtime: time.Now().Unix(),
  1889. InscpScpAmt: item.InscpScpAmt,
  1890. DrtReimFlag: item.DrtReimFlag,
  1891. Ctime: time.Now().Unix(),
  1892. ListSpItemFlag: item.ListSpItemFlag,
  1893. ChldMedcFlag: item.ChldMedcFlag,
  1894. LmtUsedFlag: item.LmtUsedFlag,
  1895. ChrgitmLv: item.ChrgitmLv,
  1896. UserOrgId: adminUser.CurrentOrgId,
  1897. HisPatientId: his.ID,
  1898. OrderId: order.ID,
  1899. ProjectId: project_id,
  1900. Type: types,
  1901. }
  1902. service.CreateOrderInfo(info)
  1903. }
  1904. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1905. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  1906. var total float64
  1907. for _, item := range prescriptions {
  1908. if item.Type == 1 { //药品
  1909. for _, subItem := range item.HisDoctorAdviceInfo {
  1910. total = total + (subItem.Price * subItem.PrescribingNumber)
  1911. }
  1912. }
  1913. if item.Type == 2 { //项目
  1914. for _, subItem := range item.HisPrescriptionProject {
  1915. total = total + (subItem.Price * float64(subItem.Count))
  1916. }
  1917. }
  1918. }
  1919. for _, item := range prescriptions {
  1920. for _, subItem := range item.HisAdditionalCharge {
  1921. total = total + (subItem.Price * float64(subItem.Count))
  1922. }
  1923. }
  1924. allTotal := fmt.Sprintf("%.2f", total)
  1925. if res.Infcode == 0 {
  1926. var rf []*ResultFive
  1927. json.Unmarshal([]byte(his.Iinfo), &rf)
  1928. chrg_bchno := chrg_bchno
  1929. cert_no := his.Certno
  1930. var insutypes []string
  1931. var insutype string
  1932. var is390 int = 0
  1933. var is310 int = 0
  1934. for _, item := range rf {
  1935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1936. insutypes = append(insutypes, item.Insutype)
  1937. }
  1938. }
  1939. if len(insutypes) == 1 {
  1940. insutype = insutypes[0]
  1941. } else {
  1942. for _, i := range insutypes {
  1943. if i == "390" {
  1944. is390 = 1
  1945. }
  1946. if i == "310" {
  1947. is310 = 1
  1948. }
  1949. }
  1950. }
  1951. if is390 == 1 {
  1952. insutype = "390"
  1953. }
  1954. if is310 == 1 {
  1955. insutype = "310"
  1956. }
  1957. if len(insutypes) == 0 {
  1958. insutype = "310"
  1959. }
  1960. //insutype = "390"
  1961. if his.IdCardType == 1 {
  1962. cert_no = his.MedicalInsuranceNumber
  1963. } else {
  1964. cert_no = his.Certno
  1965. }
  1966. result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  1967. var dat map[string]interface{}
  1968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1969. fmt.Println(dat)
  1970. } else {
  1971. fmt.Println(err)
  1972. }
  1973. userJSONBytes, _ := json.Marshal(dat)
  1974. var res ResultSeven
  1975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1976. utils.ErrorLog("解析失败:%v", err)
  1977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1978. return
  1979. }
  1980. if res.Infcode != 0 {
  1981. errlog := &models.HisOrderError{
  1982. UserOrgId: adminUser.CurrentOrgId,
  1983. Ctime: time.Now().Unix(),
  1984. Mtime: time.Now().Unix(),
  1985. Number: chrg_bchno,
  1986. ErrMsg: res.ErrMsg,
  1987. Status: 1,
  1988. PatientId: id,
  1989. RecordTime: recordDateTime,
  1990. Stage: 6,
  1991. }
  1992. service.CreateErrMsgLog(errlog)
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "failed_code": -10,
  1995. "msg": res.ErrMsg,
  1996. })
  1997. return
  1998. } else {
  1999. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2000. order.OrderStatus = 2
  2001. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2002. order.SetlId = res.Output.Setlinfo.SetlID
  2003. order.PsnNo = res.Output.Setlinfo.PsnNo
  2004. order.PsnName = res.Output.Setlinfo.PsnName
  2005. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2006. order.Certno = res.Output.Setlinfo.Certno
  2007. order.Gend = res.Output.Setlinfo.Gend
  2008. order.Naty = res.Output.Setlinfo.Naty
  2009. order.Age = res.Output.Setlinfo.Age
  2010. order.Insutype = res.Output.Setlinfo.Insutype
  2011. order.PsnType = res.Output.Setlinfo.PsnType
  2012. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2013. order.SetlTime = res.Output.Setlinfo.SetlTime
  2014. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2015. order.MedType = res.Output.Setlinfo.MedType
  2016. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2017. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2018. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2019. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2020. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2021. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2022. order.HifpPay = res.Output.Setlinfo.HifpPay
  2023. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2024. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2025. order.HifesPay = res.Output.Setlinfo.HifesPay
  2026. order.HifobPay = res.Output.Setlinfo.HifobPay
  2027. order.MafPay = res.Output.Setlinfo.MafPay
  2028. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2029. order.OthPay = res.Output.Setlinfo.OthPay
  2030. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2031. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2032. order.AcctPay = res.Output.Setlinfo.AcctPay
  2033. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2034. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2035. order.Balc = res.Output.Setlinfo.Balc
  2036. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2037. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2038. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2039. order.ClrWay = res.Output.Setlinfo.ClrWay
  2040. order.Creator = order.Creator
  2041. order.Modify = roles.AdminUserId
  2042. order.RequestLog = src_resquest
  2043. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2044. detailStr := string(setlDetail)
  2045. order.SetlDetail = detailStr
  2046. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2047. err = service.UpDateOrder(order)
  2048. if err == nil {
  2049. c.ServeSuccessJSON(map[string]interface{}{
  2050. "msg": "结算成功",
  2051. })
  2052. } else {
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2054. return
  2055. }
  2056. }
  2057. } else {
  2058. adminUser := c.GetAdminUserInfo()
  2059. errlog := &models.HisOrderError{
  2060. UserOrgId: adminUser.CurrentOrgId,
  2061. Ctime: time.Now().Unix(),
  2062. Mtime: time.Now().Unix(),
  2063. ErrMsg: res.ErrMsg,
  2064. Status: 1,
  2065. PatientId: id,
  2066. RecordTime: recordDateTime,
  2067. Stage: 4,
  2068. }
  2069. service.CreateErrMsgLog(errlog)
  2070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2071. return
  2072. }
  2073. } else {
  2074. adminUser := c.GetAdminUserInfo()
  2075. errlog := &models.HisOrderError{
  2076. UserOrgId: adminUser.CurrentOrgId,
  2077. Ctime: time.Now().Unix(),
  2078. Mtime: time.Now().Unix(),
  2079. ErrMsg: res.ErrMsg,
  2080. Status: 1,
  2081. PatientId: id,
  2082. RecordTime: recordDateTime,
  2083. Stage: 4,
  2084. }
  2085. service.CreateErrMsgLog(errlog)
  2086. c.ServeSuccessJSON(map[string]interface{}{
  2087. "failed_code": -10,
  2088. "msg": res.ErrMsg,
  2089. })
  2090. return
  2091. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2092. //return
  2093. }
  2094. }
  2095. }
  2096. } else if tempOrder.ID > 0 {
  2097. if tempOrder.IsPre == 1 {
  2098. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  2099. var rf []*ResultFive
  2100. json.Unmarshal([]byte(his.Iinfo), &rf)
  2101. chrg_bchno := tempOrder.Number
  2102. cert_no := his.Certno
  2103. var insutypes []string
  2104. var insutype string
  2105. var is390 int = 0
  2106. var is310 int = 0
  2107. for _, item := range rf {
  2108. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2109. insutypes = append(insutypes, item.Insutype)
  2110. }
  2111. }
  2112. if len(insutypes) == 1 {
  2113. insutype = insutypes[0]
  2114. } else {
  2115. for _, i := range insutypes {
  2116. if i == "390" {
  2117. is390 = 1
  2118. }
  2119. if i == "310" {
  2120. is310 = 1
  2121. }
  2122. }
  2123. }
  2124. if is390 == 1 {
  2125. insutype = "390"
  2126. }
  2127. if is310 == 1 {
  2128. insutype = "310"
  2129. }
  2130. if len(insutypes) == 0 {
  2131. insutype = "310"
  2132. }
  2133. //insutype = "390"
  2134. if his.IdCardType == 1 {
  2135. cert_no = his.MedicalInsuranceNumber
  2136. } else {
  2137. cert_no = his.Certno
  2138. }
  2139. result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
  2140. var dat map[string]interface{}
  2141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2142. fmt.Println(dat)
  2143. } else {
  2144. fmt.Println(err)
  2145. }
  2146. userJSONBytes, _ := json.Marshal(dat)
  2147. var res ResultSeven
  2148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2149. utils.ErrorLog("解析失败:%v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. return
  2152. }
  2153. if res.Infcode != 0 {
  2154. errlog := &models.HisOrderError{
  2155. UserOrgId: adminUser.CurrentOrgId,
  2156. Ctime: time.Now().Unix(),
  2157. Mtime: time.Now().Unix(),
  2158. Number: chrg_bchno,
  2159. ErrMsg: res.ErrMsg,
  2160. Status: 1,
  2161. PatientId: id,
  2162. RecordTime: recordDateTime,
  2163. Stage: 6,
  2164. }
  2165. service.CreateErrMsgLog(errlog)
  2166. c.ServeSuccessJSON(map[string]interface{}{
  2167. "failed_code": -10,
  2168. "msg": res.ErrMsg,
  2169. })
  2170. return
  2171. } else {
  2172. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2173. order.OrderStatus = 2
  2174. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2175. order.SetlId = res.Output.Setlinfo.SetlID
  2176. order.PsnNo = res.Output.Setlinfo.PsnNo
  2177. order.PsnName = res.Output.Setlinfo.PsnName
  2178. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2179. order.Certno = res.Output.Setlinfo.Certno
  2180. order.Gend = res.Output.Setlinfo.Gend
  2181. order.Naty = res.Output.Setlinfo.Naty
  2182. order.Age = res.Output.Setlinfo.Age
  2183. order.Insutype = res.Output.Setlinfo.Insutype
  2184. order.PsnType = res.Output.Setlinfo.PsnType
  2185. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2186. order.SetlTime = res.Output.Setlinfo.SetlTime
  2187. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2188. order.MedType = res.Output.Setlinfo.MedType
  2189. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2190. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2191. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2192. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2193. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2194. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2195. order.HifpPay = res.Output.Setlinfo.HifpPay
  2196. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2197. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2198. order.HifesPay = res.Output.Setlinfo.HifesPay
  2199. order.HifobPay = res.Output.Setlinfo.HifobPay
  2200. order.MafPay = res.Output.Setlinfo.MafPay
  2201. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2202. order.OthPay = res.Output.Setlinfo.OthPay
  2203. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2204. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2205. order.AcctPay = res.Output.Setlinfo.AcctPay
  2206. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2207. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2208. order.Balc = res.Output.Setlinfo.Balc
  2209. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2210. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2211. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2212. order.ClrWay = res.Output.Setlinfo.ClrWay
  2213. order.Creator = order.Creator
  2214. order.Modify = roles.AdminUserId
  2215. order.RequestLog = src_resquest
  2216. order.Diagnosis = diagnosis_id
  2217. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2218. detailStr := string(setlDetail)
  2219. order.SetlDetail = detailStr
  2220. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2221. err = service.UpDateOrder(order)
  2222. if err == nil {
  2223. c.ServeSuccessJSON(map[string]interface{}{
  2224. "msg": "结算成功",
  2225. })
  2226. } else {
  2227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2228. return
  2229. }
  2230. }
  2231. }
  2232. }
  2233. }
  2234. //func (c *HisApiController) GetPreUploadInfo() {
  2235. // id, _ := c.GetInt64("id")
  2236. // record_time := c.GetString("record_time")
  2237. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2238. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2239. //
  2240. // timeLayout := "2006-01-02"
  2241. // loc, _ := time.LoadLocation("Local")
  2242. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2243. // if err != nil {
  2244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2245. // return
  2246. // }
  2247. // recordDateTime := theTime.Unix()
  2248. // adminUser := c.GetAdminUserInfo()
  2249. //
  2250. // var prescriptions []*models.HisPrescription
  2251. //
  2252. // var start_time int64
  2253. // var end_time int64
  2254. //
  2255. // data := make(map[string]interface{})
  2256. // if settle_accounts_type == 1 { //日结
  2257. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2258. // data["pre"] = prescriptions
  2259. //
  2260. // } else { //月结
  2261. // start_time_str := c.GetString("start_time")
  2262. // end_time_str := c.GetString("end_time")
  2263. // timeLayout := "2006-01-02"
  2264. // loc, _ := time.LoadLocation("Local")
  2265. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2266. // if err != nil {
  2267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2268. // return
  2269. // }
  2270. // recordStartTime := theStartTime.Unix()
  2271. // start_time = recordStartTime
  2272. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2273. // if err != nil {
  2274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2275. // return
  2276. // }
  2277. // recordEndTime := theEndTime.Unix()
  2278. // end_time = recordEndTime
  2279. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2280. // data["pre"] = prescriptions
  2281. //
  2282. // }
  2283. //
  2284. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2285. //
  2286. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2287. // timestamp := time.Now().Unix()
  2288. // tempTime := time.Unix(timestamp, 0)
  2289. // timeFormat := tempTime.Format("20060102150405")
  2290. // chrgBchno := rand.Intn(100000) + 10000
  2291. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2292. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2293. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2294. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2295. // strconv.FormatInt(his.PatientId, 10)
  2296. // client := &http.Client{}
  2297. // data["psn_no"] = his.PsnNo
  2298. // data["mdtrt_id"] = his.Number
  2299. // data["chrg_bchno"] = chrg_bchno
  2300. // data["org_name"] = miConfig.OrgName
  2301. // data["doctor"] = roles.UserName
  2302. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2303. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2304. // data["fixmedins_code"] = miConfig.Code
  2305. // data["dept_code"] = department.Number
  2306. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2307. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2308. // data["secret_key"] = miConfig.SecretKey
  2309. // var ids []int64
  2310. //
  2311. // for _, item := range prescriptions {
  2312. // ids = append(ids, item.ID)
  2313. // }
  2314. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2315. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2316. // bytesData, _ := json.Marshal(data)
  2317. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2318. // resp, _ := client.Do(req)
  2319. // defer resp.Body.Close()
  2320. // body, ioErr := ioutil.ReadAll(resp.Body)
  2321. // if ioErr != nil {
  2322. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2324. // return
  2325. // }
  2326. // var respJSON map[string]interface{}
  2327. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2328. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2330. // return
  2331. // }
  2332. //
  2333. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2334. // userJSONBytes, _ := json.Marshal(respJSON)
  2335. // var res ResultFour
  2336. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2337. // utils.ErrorLog("解析失败:%v", err)
  2338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2339. // return
  2340. // }
  2341. //
  2342. // if res.Infcode == 0 {
  2343. // order := &models.HisOrder{
  2344. // UserOrgId: adminUser.CurrentOrgId,
  2345. // HisPatientId: his.ID,
  2346. // PatientId: his.PatientId,
  2347. // SettleAccountsDate: recordDateTime,
  2348. // Ctime: time.Now().Unix(),
  2349. // Mtime: time.Now().Unix(),
  2350. // Status: 1,
  2351. // Number: chrg_bchno,
  2352. // Infcode: res.Infcode,
  2353. // WarnMsg: res.WarnMsg,
  2354. // Cainfo: res.Cainfo,
  2355. // ErrMsg: res.ErrMsg,
  2356. // RespondTime: res.RefmsgTime,
  2357. // InfRefmsgid: res.InfRefmsgid,
  2358. // OrderStatus: 1,
  2359. // IsMedicineInsurance: 1,
  2360. // SettleType: settle_accounts_type,
  2361. // SettleStartTime: start_time,
  2362. // SettleEndTime: end_time,
  2363. // Creator: roles.ID,
  2364. // Modify: roles.ID,
  2365. // PType: 2,
  2366. // }
  2367. // err = service.CreateOrder(order)
  2368. // if err != nil {
  2369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2370. // return
  2371. // }
  2372. //
  2373. // for _, item := range res.Output.Result {
  2374. // temp := strings.Split(item.FeedetlSn, "-")
  2375. // var advice_id int64 = 0
  2376. // var project_id int64 = 0
  2377. // var types int64 = 0
  2378. //
  2379. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2380. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2381. //
  2382. // if temp[1] == "1" {
  2383. // advice_id = id
  2384. // project_id = 0
  2385. // } else if temp[1] == "2" {
  2386. // advice_id = 0
  2387. // project_id = id
  2388. // }
  2389. //
  2390. // info := &models.HisOrderInfo{
  2391. // OrderNumber: order.Number,
  2392. // FeedetlSn: item.FeedetlSn,
  2393. // UploadDate: time.Now().Unix(),
  2394. // AdviceId: advice_id,
  2395. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  2396. // Cnt: item.Cnt,
  2397. // Pric: float64(item.Pric),
  2398. // PatientId: his.PatientId,
  2399. // PricUplmtAmt: item.PricUplmtAmt,
  2400. // SelfpayProp: item.SelfpayProp,
  2401. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2402. // OverlmtAmt: item.OverlmtAmt,
  2403. // PreselfpayAmt: item.PreselfpayAmt,
  2404. // BasMednFlag: item.BasMednFlag,
  2405. // MedChrgitmType: item.MedChrgitmType,
  2406. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  2407. // Status: 1,
  2408. // Memo: item.Memo,
  2409. // Mtime: time.Now().Unix(),
  2410. // InscpScpAmt: item.InscpScpAmt,
  2411. // DrtReimFlag: item.DrtReimFlag,
  2412. // Ctime: time.Now().Unix(),
  2413. // ListSpItemFlag: item.ListSpItemFlag,
  2414. // ChldMedcFlag: item.ChldMedcFlag,
  2415. // LmtUsedFlag: item.LmtUsedFlag,
  2416. // ChrgitmLv: item.ChrgitmLv,
  2417. // UserOrgId: adminUser.CurrentOrgId,
  2418. // HisPatientId: his.ID,
  2419. // OrderId: order.ID,
  2420. // ProjectId: project_id,
  2421. // Type: types,
  2422. // }
  2423. // service.CreateOrderInfo(info)
  2424. //
  2425. // }
  2426. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2427. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2428. //
  2429. // var total float64
  2430. // for _, item := range prescriptions {
  2431. // if item.Type == 1 { //药品
  2432. // for _, subItem := range item.HisDoctorAdviceInfo {
  2433. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2434. // }
  2435. // }
  2436. // if item.Type == 2 { //项目
  2437. // for _, subItem := range item.HisPrescriptionProject {
  2438. // total = total + (subItem.Price * float64(subItem.Count))
  2439. // }
  2440. // }
  2441. // }
  2442. //
  2443. // for _, item := range prescriptions {
  2444. // for _, subItem := range item.HisAdditionalCharge {
  2445. // total = total + (subItem.Price * float64(subItem.Count))
  2446. // }
  2447. // }
  2448. //
  2449. // allTotal := fmt.Sprintf("%.2f", total)
  2450. // if res.Infcode == 0 {
  2451. // var rf []*ResultFive
  2452. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2453. // psn_no := his.PsnNo
  2454. // mdtrt_id := his.Number
  2455. // chrg_bchno := chrg_bchno
  2456. // cert_no := his.Certno
  2457. // insutype := rf[0].Insutype
  2458. //
  2459. // if his.IdCardType == 1 {
  2460. // cert_no = his.MedicalInsuranceNumber
  2461. //
  2462. // } else {
  2463. //
  2464. // cert_no = his.Certno
  2465. //
  2466. // }
  2467. //
  2468. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2469. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2470. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2471. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2472. // resp, requestErr := http.Get(api)
  2473. // if requestErr != nil {
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // defer resp.Body.Close()
  2478. // body, ioErr := ioutil.ReadAll(resp.Body)
  2479. // if ioErr != nil {
  2480. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2482. // return
  2483. // }
  2484. // var respJSON map[string]interface{}
  2485. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2486. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2488. // return
  2489. // }
  2490. // fmt.Println(respJSON)
  2491. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2492. // userJSONBytes, _ := json.Marshal(respJSON)
  2493. // var res ResultSeven
  2494. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2495. // utils.ErrorLog("解析失败:%v", err)
  2496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2497. // return
  2498. // }
  2499. // if res.Infcode != 0 {
  2500. // errlog := &models.HisOrderError{
  2501. // UserOrgId: adminUser.CurrentOrgId,
  2502. // Ctime: time.Now().Unix(),
  2503. // Mtime: time.Now().Unix(),
  2504. // Number: chrg_bchno,
  2505. // ErrMsg: res.ErrMsg,
  2506. // Status: 1,
  2507. // PatientId: id,
  2508. // RecordTime: recordDateTime,
  2509. // Stage: 7,
  2510. // }
  2511. // service.CreateErrMsgLog(errlog)
  2512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2513. // return
  2514. // } else {
  2515. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2516. // order.OrderStatus = 1
  2517. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2518. // order.SetlId = res.Output.Setlinfo.SetlID
  2519. // order.PsnNo = res.Output.Setlinfo.PsnNo
  2520. // order.PsnName = res.Output.Setlinfo.PsnName
  2521. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2522. // order.Certno = res.Output.Setlinfo.Certno
  2523. // order.Gend = res.Output.Setlinfo.Gend
  2524. // order.Naty = res.Output.Setlinfo.Naty
  2525. // order.Age = res.Output.Setlinfo.Age
  2526. // order.Insutype = res.Output.Setlinfo.Insutype
  2527. // order.PsnType = res.Output.Setlinfo.PsnType
  2528. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2529. // order.SetlTime = res.Output.Setlinfo.SetlTime
  2530. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2531. // order.MedType = res.Output.Setlinfo.MedType
  2532. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2533. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2534. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2535. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2536. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2537. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2538. // order.HifpPay = res.Output.Setlinfo.HifpPay
  2539. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2540. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2541. // order.HifesPay = res.Output.Setlinfo.HifesPay
  2542. // order.HifobPay = res.Output.Setlinfo.HifobPay
  2543. // order.MafPay = res.Output.Setlinfo.MafPay
  2544. // order.OthPay = res.Output.Setlinfo.OthPay
  2545. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2546. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2547. // order.AcctPay = res.Output.Setlinfo.AcctPay
  2548. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2549. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2550. // order.Balc = res.Output.Setlinfo.Balc
  2551. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2552. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2553. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2554. // order.ClrWay = res.Output.Setlinfo.ClrWay
  2555. // order.Creator = order.Creator
  2556. // order.Modify = roles.ID
  2557. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2558. // detailStr := string(setlDetail)
  2559. // order.SetlDetail = detailStr
  2560. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2561. // err = service.UpDateOrder(order)
  2562. // if err == nil {
  2563. // c.ServeSuccessJSON(map[string]interface{}{
  2564. // "msg": "预结算成功",
  2565. // })
  2566. // } else {
  2567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2568. // return
  2569. // }
  2570. // }
  2571. // } else {
  2572. // adminUser := c.GetAdminUserInfo()
  2573. // errlog := &models.HisOrderError{
  2574. // UserOrgId: adminUser.CurrentOrgId,
  2575. // Ctime: time.Now().Unix(),
  2576. // Mtime: time.Now().Unix(),
  2577. // ErrMsg: res.ErrMsg,
  2578. // Status: 1,
  2579. // PatientId: id,
  2580. // RecordTime: recordDateTime,
  2581. // Stage: 4,
  2582. // }
  2583. // service.CreateErrMsgLog(errlog)
  2584. //
  2585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2586. // return
  2587. // }
  2588. // } else {
  2589. // adminUser := c.GetAdminUserInfo()
  2590. // errlog := &models.HisOrderError{
  2591. // UserOrgId: adminUser.CurrentOrgId,
  2592. // Ctime: time.Now().Unix(),
  2593. // Mtime: time.Now().Unix(),
  2594. // ErrMsg: res.ErrMsg,
  2595. // Status: 1,
  2596. // PatientId: id,
  2597. // RecordTime: recordDateTime,
  2598. // Stage: 4,
  2599. // }
  2600. // service.CreateErrMsgLog(errlog)
  2601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2602. // return
  2603. // }
  2604. //
  2605. // } else {
  2606. // var total float64
  2607. // for _, item := range prescriptions {
  2608. // if item.Type == 1 { //药品
  2609. // for _, subItem := range item.HisDoctorAdviceInfo {
  2610. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2611. // }
  2612. // }
  2613. // if item.Type == 2 { //项目
  2614. // for _, subItem := range item.HisPrescriptionProject {
  2615. // total = total + (subItem.Price * float64(subItem.Count))
  2616. // }
  2617. // }
  2618. //
  2619. // for _, subItem := range item.HisAdditionalCharge {
  2620. // total = total + (subItem.Price * float64(subItem.Count))
  2621. // }
  2622. // }
  2623. //
  2624. // allTotal := fmt.Sprintf("%.2f", total)
  2625. // totals, _ := strconv.ParseFloat(allTotal, 64)
  2626. // order := &models.HisOrder{
  2627. // UserOrgId: adminUser.CurrentOrgId,
  2628. // HisPatientId: his.ID,
  2629. // PatientId: id,
  2630. // SettleAccountsDate: recordDateTime,
  2631. // Ctime: time.Now().Unix(),
  2632. // Mtime: time.Now().Unix(),
  2633. // Status: 1,
  2634. // OrderStatus: 2,
  2635. // Number: chrg_bchno,
  2636. // MedfeeSumamt: totals,
  2637. // }
  2638. // err = service.CreateOrder(order)
  2639. // if err != nil {
  2640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2641. // return
  2642. // }
  2643. //
  2644. // var customs []*Custom
  2645. // for _, item := range prescriptions {
  2646. //
  2647. // if item.Type == 1 { //药品
  2648. // for _, subItem := range item.HisDoctorAdviceInfo {
  2649. // cus := &Custom{
  2650. // AdviceId: subItem.ID,
  2651. // ProjectId: 0,
  2652. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2653. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2654. // FeedetlSn: subItem.FeedetlSn,
  2655. // Price: fmt.Sprintf("%.2f", subItem.Price),
  2656. // MedListCodg: subItem.MedListCodg,
  2657. // Type: 1,
  2658. // }
  2659. // customs = append(customs, cus)
  2660. // }
  2661. // }
  2662. //
  2663. // if item.Type == 2 { //项目
  2664. // for _, subItem := range item.HisPrescriptionProject {
  2665. //
  2666. // cus := &Custom{
  2667. // AdviceId: 0,
  2668. // ProjectId: subItem.ID,
  2669. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2670. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2671. // FeedetlSn: subItem.FeedetlSn,
  2672. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2673. // MedListCodg: subItem.MedListCodg,
  2674. // Type: 2,
  2675. // }
  2676. //
  2677. // customs = append(customs, cus)
  2678. // }
  2679. // }
  2680. //
  2681. // for _, item := range item.HisAdditionalCharge {
  2682. // cus := &Custom{
  2683. // ItemId: item.ID,
  2684. // AdviceId: 0,
  2685. // ProjectId: 0,
  2686. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2687. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2688. // FeedetlSn: item.FeedetlSn,
  2689. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2690. // MedListCodg: item.XtHisAddtionConfig.Code,
  2691. // Type: 3,
  2692. // }
  2693. //
  2694. // customs = append(customs, cus)
  2695. // }
  2696. //
  2697. // }
  2698. //
  2699. // for _, item := range customs {
  2700. // var advice_id int64 = 0
  2701. // var project_id int64 = 0
  2702. // var item_id int64 = 0
  2703. //
  2704. // var types int64 = 0
  2705. //
  2706. // if item.Type == 1 {
  2707. // advice_id = item.AdviceId
  2708. // project_id = 0
  2709. // item_id = 0
  2710. // } else if item.Type == 2 {
  2711. // advice_id = 0
  2712. // item_id = 0
  2713. //
  2714. // project_id = item.ProjectId
  2715. // } else if item.Type == 3 {
  2716. // advice_id = 0
  2717. // item_id = item.ItemId
  2718. // project_id = 0
  2719. // }
  2720. //
  2721. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2722. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  2723. // pric, _ := strconv.ParseFloat(item.Price, 32)
  2724. //
  2725. // info := &models.HisOrderInfo{
  2726. // OrderNumber: order.Number,
  2727. // UploadDate: time.Now().Unix(),
  2728. // AdviceId: advice_id,
  2729. // DetItemFeeSumamt: detItemFeeSumamt,
  2730. // Cnt: cut,
  2731. // Pric: pric,
  2732. // PatientId: id,
  2733. // Status: 1,
  2734. // Mtime: time.Now().Unix(),
  2735. // Ctime: time.Now().Unix(),
  2736. // UserOrgId: adminUser.CurrentOrgId,
  2737. // HisPatientId: his.ID,
  2738. // OrderId: order.ID,
  2739. // ProjectId: project_id,
  2740. // Type: types,
  2741. // ItemId: item_id,
  2742. // }
  2743. // service.CreateOrderInfo(info)
  2744. // }
  2745. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2746. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2747. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2748. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2749. // if err == nil {
  2750. // c.ServeSuccessJSON(map[string]interface{}{
  2751. // "msg": "结算成功",
  2752. // })
  2753. // } else {
  2754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2755. // return
  2756. // }
  2757. // }
  2758. //}
  2759. //上传明细-预结算-
  2760. func (c *HisApiController) GetPreUploadInfo() {
  2761. id, _ := c.GetInt64("id")
  2762. record_time := c.GetString("record_time")
  2763. his_patient_id, _ := c.GetInt64("his_patient_id")
  2764. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2765. admin_user_id, _ := c.GetInt64("admin_user_id")
  2766. diagnosis_id := c.GetString("diagnosis")
  2767. sick_type, _ := c.GetInt64("sick_type")
  2768. reg_type, _ := c.GetInt64("p_type")
  2769. timeLayout := "2006-01-02"
  2770. loc, _ := time.LoadLocation("Local")
  2771. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2772. if err != nil {
  2773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2774. return
  2775. }
  2776. recordDateTime := theTime.Unix()
  2777. adminUser := c.GetAdminUserInfo()
  2778. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2779. var config []*models.HisXtDiagnoseConfig
  2780. for _, item := range diagnosis_ids {
  2781. id, _ := strconv.ParseInt(item, 10, 64)
  2782. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2783. config = append(config, diagnosisConfig)
  2784. }
  2785. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2786. sickConfig, _ := service.FindSickById(sick_type)
  2787. var prescriptions []*models.HisPrescription
  2788. var start_time int64
  2789. var end_time int64
  2790. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2791. fmt.Println(his_patient_id)
  2792. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2793. timestamp := time.Now().Unix()
  2794. tempTime := time.Unix(timestamp, 0)
  2795. timeFormat := tempTime.Format("20060102150405")
  2796. chrgBchno := rand.Intn(100000) + 10000
  2797. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2798. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2799. patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2800. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2801. strconv.FormatInt(his.PatientId, 10)
  2802. var result string
  2803. if miConfig.InsuplcAdmdvs == "440781" { //
  2804. result = service.Gdyb2203A(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2805. } else {
  2806. result = service.Gdyb2203(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2807. }
  2808. var respJSON2 map[string]interface{}
  2809. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2812. return
  2813. }
  2814. userJSONBytes2, _ := json.Marshal(respJSON2)
  2815. var res2 ResultSix
  2816. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2817. utils.ErrorLog("解析失败:%v", err)
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. return
  2820. }
  2821. if res2.Infcode != 0 {
  2822. adminUser := c.GetAdminUserInfo()
  2823. errlog := &models.HisOrderError{
  2824. UserOrgId: adminUser.CurrentOrgId,
  2825. Ctime: time.Now().Unix(),
  2826. Mtime: time.Now().Unix(),
  2827. ErrMsg: res2.ErrMsg,
  2828. Status: 1,
  2829. PatientId: id,
  2830. RecordTime: recordDateTime,
  2831. Stage: 3,
  2832. }
  2833. service.CreateErrMsgLog(errlog)
  2834. c.ServeSuccessJSON(map[string]interface{}{
  2835. "failed_code": -10,
  2836. "msg": res2.ErrMsg,
  2837. })
  2838. return
  2839. } else {
  2840. his.Diagnosis = diagnosis_id
  2841. his.SickType = sickConfig.ID
  2842. his.PType = fmt.Sprintf("%d", reg_type)
  2843. service.UpdateHisPatientThree(&his)
  2844. data := make(map[string]interface{})
  2845. if settle_accounts_type == 1 { //日结
  2846. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  2847. data["pre"] = prescriptions
  2848. } else { //月结
  2849. start_time_str := c.GetString("start_time")
  2850. end_time_str := c.GetString("end_time")
  2851. timeLayout := "2006-01-02"
  2852. loc, _ := time.LoadLocation("Local")
  2853. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2854. if err != nil {
  2855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2856. return
  2857. }
  2858. recordStartTime := theStartTime.Unix()
  2859. start_time = recordStartTime
  2860. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2861. if err != nil {
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2863. return
  2864. }
  2865. recordEndTime := theEndTime.Unix()
  2866. end_time = recordEndTime
  2867. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  2868. data["pre"] = prescriptions
  2869. }
  2870. client := &http.Client{}
  2871. data["psn_no"] = his.PsnNo
  2872. data["mdtrt_id"] = his.Number
  2873. data["chrg_bchno"] = chrg_bchno
  2874. data["org_name"] = miConfig.OrgName
  2875. data["doctor"] = roles.UserName
  2876. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2877. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2878. data["fixmedins_code"] = miConfig.Code
  2879. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  2880. data["dept_code"] = "15"
  2881. } else {
  2882. data["dept_code"] = department.Number
  2883. }
  2884. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2886. data["secret_key"] = miConfig.SecretKey
  2887. var ids []int64
  2888. for _, item := range prescriptions {
  2889. ids = append(ids, item.ID)
  2890. }
  2891. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2892. if config.IsOpen == 1 { //对接了医保,走医保流程
  2893. bytesData, _ := json.Marshal(data)
  2894. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2895. resp, _ := client.Do(req)
  2896. defer resp.Body.Close()
  2897. body, ioErr := ioutil.ReadAll(resp.Body)
  2898. if ioErr != nil {
  2899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2901. return
  2902. }
  2903. var respJSON map[string]interface{}
  2904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. userJSONBytes, _ := json.Marshal(respJSON)
  2911. var res ResultFour
  2912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2913. utils.ErrorLog("解析失败:%v", err)
  2914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2915. return
  2916. }
  2917. if res.Infcode == 0 {
  2918. order := &models.HisOrder{
  2919. UserOrgId: adminUser.CurrentOrgId,
  2920. HisPatientId: his.ID,
  2921. PatientId: his.PatientId,
  2922. SettleAccountsDate: recordDateTime,
  2923. Ctime: time.Now().Unix(),
  2924. Mtime: time.Now().Unix(),
  2925. Status: 1,
  2926. Number: chrg_bchno,
  2927. Infcode: res.Infcode,
  2928. WarnMsg: res.WarnMsg,
  2929. Cainfo: res.Cainfo,
  2930. ErrMsg: res.ErrMsg,
  2931. RespondTime: res.RefmsgTime,
  2932. InfRefmsgid: res.InfRefmsgid,
  2933. OrderStatus: 1,
  2934. IsMedicineInsurance: 1,
  2935. SettleType: settle_accounts_type,
  2936. SettleStartTime: start_time,
  2937. SettleEndTime: end_time,
  2938. Creator: roles.AdminUserId,
  2939. Modify: roles.AdminUserId,
  2940. PType: 2,
  2941. Diagnosis: diagnosis_id,
  2942. }
  2943. err = service.CreateOrder(order)
  2944. if err != nil {
  2945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2946. return
  2947. }
  2948. for _, item := range res.Output.Result {
  2949. temp := strings.Split(item.FeedetlSn, "-")
  2950. var advice_id int64 = 0
  2951. var project_id int64 = 0
  2952. var types int64 = 0
  2953. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2954. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2955. if temp[1] == "1" {
  2956. advice_id = id
  2957. project_id = 0
  2958. } else if temp[1] == "2" {
  2959. advice_id = 0
  2960. project_id = id
  2961. }
  2962. info := &models.HisOrderInfo{
  2963. OrderNumber: order.Number,
  2964. FeedetlSn: item.FeedetlSn,
  2965. UploadDate: time.Now().Unix(),
  2966. AdviceId: advice_id,
  2967. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2968. Cnt: item.Cnt,
  2969. Pric: float64(item.Pric),
  2970. PatientId: his.PatientId,
  2971. PricUplmtAmt: item.PricUplmtAmt,
  2972. SelfpayProp: item.SelfpayProp,
  2973. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2974. OverlmtAmt: item.OverlmtAmt,
  2975. PreselfpayAmt: item.PreselfpayAmt,
  2976. BasMednFlag: item.BasMednFlag,
  2977. MedChrgitmType: item.MedChrgitmType,
  2978. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2979. Status: 1,
  2980. Memo: item.Memo,
  2981. Mtime: time.Now().Unix(),
  2982. InscpScpAmt: item.InscpScpAmt,
  2983. DrtReimFlag: item.DrtReimFlag,
  2984. Ctime: time.Now().Unix(),
  2985. ListSpItemFlag: item.ListSpItemFlag,
  2986. ChldMedcFlag: item.ChldMedcFlag,
  2987. LmtUsedFlag: item.LmtUsedFlag,
  2988. ChrgitmLv: item.ChrgitmLv,
  2989. UserOrgId: adminUser.CurrentOrgId,
  2990. HisPatientId: his.ID,
  2991. OrderId: order.ID,
  2992. ProjectId: project_id,
  2993. Type: types,
  2994. }
  2995. service.CreateOrderInfo(info)
  2996. }
  2997. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2998. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2999. var total float64
  3000. for _, item := range prescriptions {
  3001. if item.Type == 1 { //药品
  3002. for _, subItem := range item.HisDoctorAdviceInfo {
  3003. total = total + (subItem.Price * subItem.PrescribingNumber)
  3004. }
  3005. }
  3006. if item.Type == 2 { //项目
  3007. for _, subItem := range item.HisPrescriptionProject {
  3008. total = total + (subItem.Price * float64(subItem.Count))
  3009. }
  3010. }
  3011. }
  3012. for _, item := range prescriptions {
  3013. for _, subItem := range item.HisAdditionalCharge {
  3014. total = total + (subItem.Price * float64(subItem.Count))
  3015. }
  3016. }
  3017. allTotal := fmt.Sprintf("%.2f", total)
  3018. if res.Infcode == 0 {
  3019. var rf []*ResultFive
  3020. json.Unmarshal([]byte(his.Iinfo), &rf)
  3021. chrg_bchno := chrg_bchno
  3022. cert_no := his.Certno
  3023. var insutypes []string
  3024. var insutype string
  3025. var is390 int = 0
  3026. var is310 int = 0
  3027. for _, item := range rf {
  3028. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3029. insutypes = append(insutypes, item.Insutype)
  3030. }
  3031. }
  3032. if len(insutypes) == 1 {
  3033. insutype = insutypes[0]
  3034. } else {
  3035. for _, i := range insutypes {
  3036. if i == "390" {
  3037. is390 = 1
  3038. }
  3039. if i == "310" {
  3040. is310 = 1
  3041. }
  3042. }
  3043. }
  3044. if is390 == 1 {
  3045. insutype = "390"
  3046. }
  3047. if is310 == 1 {
  3048. insutype = "310"
  3049. }
  3050. if len(insutypes) == 0 {
  3051. insutype = "310"
  3052. }
  3053. //insutype = "390"
  3054. if his.IdCardType == 1 {
  3055. cert_no = his.MedicalInsuranceNumber
  3056. } else {
  3057. cert_no = his.Certno
  3058. }
  3059. result := service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  3060. var dat map[string]interface{}
  3061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3062. fmt.Println(dat)
  3063. } else {
  3064. fmt.Println(err)
  3065. }
  3066. userJSONBytes, _ := json.Marshal(dat)
  3067. var res ResultSeven
  3068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3069. utils.ErrorLog("解析失败:%v", err)
  3070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3071. return
  3072. }
  3073. if res.Infcode != 0 {
  3074. errlog := &models.HisOrderError{
  3075. UserOrgId: adminUser.CurrentOrgId,
  3076. Ctime: time.Now().Unix(),
  3077. Mtime: time.Now().Unix(),
  3078. Number: chrg_bchno,
  3079. ErrMsg: res.ErrMsg,
  3080. Status: 1,
  3081. PatientId: id,
  3082. RecordTime: recordDateTime,
  3083. Stage: 20,
  3084. }
  3085. service.CreateErrMsgLog(errlog)
  3086. c.ServeSuccessJSON(map[string]interface{}{
  3087. "failed_code": -10,
  3088. "msg": res.ErrMsg,
  3089. })
  3090. return
  3091. } else {
  3092. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3093. order.OrderStatus = 1
  3094. order.IsPre = 1
  3095. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3096. order.SetlId = res.Output.Setlinfo.SetlID
  3097. order.PsnNo = res.Output.Setlinfo.PsnNo
  3098. order.PsnName = res.Output.Setlinfo.PsnName
  3099. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3100. order.Certno = res.Output.Setlinfo.Certno
  3101. order.Gend = res.Output.Setlinfo.Gend
  3102. order.Naty = res.Output.Setlinfo.Naty
  3103. order.Age = res.Output.Setlinfo.Age
  3104. order.Insutype = res.Output.Setlinfo.Insutype
  3105. order.PsnType = res.Output.Setlinfo.PsnType
  3106. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3107. order.SetlTime = res.Output.Setlinfo.SetlTime
  3108. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3109. order.MedType = res.Output.Setlinfo.MedType
  3110. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3111. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3112. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3113. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3114. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3115. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3116. order.HifpPay = res.Output.Setlinfo.HifpPay
  3117. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3118. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3119. order.HifesPay = res.Output.Setlinfo.HifesPay
  3120. order.HifobPay = res.Output.Setlinfo.HifobPay
  3121. order.MafPay = res.Output.Setlinfo.MafPay
  3122. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3123. order.OthPay = res.Output.Setlinfo.OthPay
  3124. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3125. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3126. order.AcctPay = res.Output.Setlinfo.AcctPay
  3127. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3128. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3129. order.Balc = res.Output.Setlinfo.Balc
  3130. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3131. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3132. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3133. order.ClrWay = res.Output.Setlinfo.ClrWay
  3134. order.Creator = order.Creator
  3135. order.Modify = roles.AdminUserId
  3136. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3137. detailStr := string(setlDetail)
  3138. order.SetlDetail = detailStr
  3139. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3140. err = service.UpDateOrder(order)
  3141. if err == nil {
  3142. c.ServeSuccessJSON(map[string]interface{}{
  3143. "msg": "预结算成功",
  3144. })
  3145. } else {
  3146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3147. return
  3148. }
  3149. }
  3150. } else {
  3151. adminUser := c.GetAdminUserInfo()
  3152. errlog := &models.HisOrderError{
  3153. UserOrgId: adminUser.CurrentOrgId,
  3154. Ctime: time.Now().Unix(),
  3155. Mtime: time.Now().Unix(),
  3156. ErrMsg: res.ErrMsg,
  3157. Status: 1,
  3158. PatientId: id,
  3159. RecordTime: recordDateTime,
  3160. Stage: 4,
  3161. }
  3162. service.CreateErrMsgLog(errlog)
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3164. return
  3165. }
  3166. } else {
  3167. adminUser := c.GetAdminUserInfo()
  3168. errlog := &models.HisOrderError{
  3169. UserOrgId: adminUser.CurrentOrgId,
  3170. Ctime: time.Now().Unix(),
  3171. Mtime: time.Now().Unix(),
  3172. ErrMsg: res.ErrMsg,
  3173. Status: 1,
  3174. PatientId: id,
  3175. RecordTime: recordDateTime,
  3176. Stage: 4,
  3177. }
  3178. service.CreateErrMsgLog(errlog)
  3179. c.ServeSuccessJSON(map[string]interface{}{
  3180. "failed_code": -10,
  3181. "msg": res.ErrMsg,
  3182. })
  3183. return
  3184. }
  3185. }
  3186. }
  3187. }
  3188. //func (c *HisApiController) GetSettleInfo() {
  3189. // id, _ := c.GetInt64("id")
  3190. // order_id, _ := c.GetInt64("order_id")
  3191. //
  3192. // record_time := c.GetString("record_time")
  3193. // pay_way, _ := c.GetInt64("pay_way")
  3194. // pay_price, _ := c.GetFloat("pay_price")
  3195. // pay_card_no := c.GetString("pay_card_no")
  3196. // discount_price, _ := c.GetFloat("discount_price")
  3197. // preferential_price, _ := c.GetFloat("preferential_price")
  3198. // reality_price, _ := c.GetFloat("reality_price")
  3199. // found_price, _ := c.GetFloat("found_price")
  3200. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3201. // private_price, _ := c.GetFloat("private_price")
  3202. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3203. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3204. //
  3205. // timeLayout := "2006-01-02"
  3206. // loc, _ := time.LoadLocation("Local")
  3207. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3208. // if err != nil {
  3209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3210. // return
  3211. // }
  3212. // recordDateTime := theTime.Unix()
  3213. // adminUser := c.GetAdminUserInfo()
  3214. //
  3215. // var prescriptions []*models.HisPrescription
  3216. //
  3217. // data := make(map[string]interface{})
  3218. // if settle_accounts_type == 1 { //日结
  3219. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3220. // data["pre"] = prescriptions
  3221. //
  3222. // } else { //月结
  3223. // start_time_str := c.GetString("start_time")
  3224. // end_time_str := c.GetString("end_time")
  3225. // timeLayout := "2006-01-02"
  3226. // loc, _ := time.LoadLocation("Local")
  3227. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3228. // if err != nil {
  3229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3230. // return
  3231. // }
  3232. // recordStartTime := theStartTime.Unix()
  3233. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3234. // if err != nil {
  3235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3236. // return
  3237. // }
  3238. // recordEndTime := theEndTime.Unix()
  3239. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3240. // data["pre"] = prescriptions
  3241. //
  3242. // }
  3243. //
  3244. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3245. //
  3246. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3247. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3248. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3249. // strconv.FormatInt(his.PatientId, 10)
  3250. //
  3251. // order_src, _ := service.GetHisOrderByID(order_id)
  3252. //
  3253. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3254. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3255. //
  3256. // var total float64
  3257. // for _, item := range prescriptions {
  3258. // if item.Type == 1 { //药品
  3259. // for _, subItem := range item.HisDoctorAdviceInfo {
  3260. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3261. // }
  3262. // }
  3263. // if item.Type == 2 { //项目
  3264. // for _, subItem := range item.HisPrescriptionProject {
  3265. // total = total + (subItem.Price * float64(subItem.Count))
  3266. // }
  3267. // }
  3268. // }
  3269. //
  3270. // for _, item := range prescriptions {
  3271. // for _, subItem := range item.HisAdditionalCharge {
  3272. // total = total + (subItem.Price * float64(subItem.Count))
  3273. // }
  3274. // }
  3275. //
  3276. // allTotal := fmt.Sprintf("%.2f", total)
  3277. // var rf []*ResultFive
  3278. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3279. // psn_no := order_src.PsnNo
  3280. // mdtrt_id := order_src.MdtrtId
  3281. // chrg_bchno := order_src.Number
  3282. // cert_no := order_src.Certno
  3283. // insutype := rf[0].Insutype
  3284. //
  3285. // if his.IdCardType == 1 {
  3286. // cert_no = his.MedicalInsuranceNumber
  3287. // } else {
  3288. // cert_no = his.Certno
  3289. // }
  3290. //
  3291. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  3292. // var dat map[string]interface{}
  3293. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3294. // fmt.Println(dat)
  3295. // } else {
  3296. // fmt.Println(err)
  3297. // }
  3298. //
  3299. // userJSONBytes, _ := json.Marshal(dat)
  3300. //
  3301. //
  3302. //
  3303. // var res ResultSeven
  3304. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3305. // utils.ErrorLog("解析失败:%v", err)
  3306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3307. // return
  3308. // }
  3309. // if res.Infcode == -1 {
  3310. // errlog := &models.HisOrderError{
  3311. // UserOrgId: adminUser.CurrentOrgId,
  3312. // Ctime: time.Now().Unix(),
  3313. // Mtime: time.Now().Unix(),
  3314. // Number: chrg_bchno,
  3315. // ErrMsg: res.ErrMsg,
  3316. // Status: 1,
  3317. // PatientId: id,
  3318. // RecordTime: recordDateTime,
  3319. // Stage: 6,
  3320. // }
  3321. // service.CreateErrMsgLog(errlog)
  3322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3323. // return
  3324. // } else {
  3325. // order_src.OrderStatus = 2
  3326. // order_src.PayWay = pay_way
  3327. // order_src.PayPrice = pay_price
  3328. // order_src.PayCardNo = pay_card_no
  3329. // order_src.DiscountPrice = discount_price
  3330. // order_src.PreferentialPrice = preferential_price
  3331. // order_src.RealityPrice = reality_price
  3332. // order_src.FoundPrice = found_price
  3333. // order_src.MedicalInsurancePrice = medical_insurance_price
  3334. // order_src.PrivatePrice = private_price
  3335. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  3336. // order_src.SetlId = res.Output.Setlinfo.SetlID
  3337. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  3338. // order_src.PsnName = res.Output.Setlinfo.PsnName
  3339. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  3340. // order_src.Certno = res.Output.Setlinfo.Certno
  3341. // order_src.Gend = res.Output.Setlinfo.Gend
  3342. // order_src.Naty = res.Output.Setlinfo.Naty
  3343. // order_src.Age = res.Output.Setlinfo.Age
  3344. // order_src.Insutype = res.Output.Setlinfo.Insutype
  3345. // order_src.PsnType = res.Output.Setlinfo.PsnType
  3346. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3347. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  3348. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3349. // order_src.MedType = res.Output.Setlinfo.MedType
  3350. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3351. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3352. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3353. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3354. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3355. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3356. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  3357. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  3358. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3359. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  3360. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  3361. // order_src.MafPay = res.Output.Setlinfo.MafPay
  3362. // order_src.OthPay = res.Output.Setlinfo.OthPay
  3363. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3364. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3365. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  3366. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3367. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3368. // order_src.Balc = res.Output.Setlinfo.Balc
  3369. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3370. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3371. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  3372. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  3373. // order_src.Creator = order_src.Creator
  3374. // order_src.Modify = roles.ID
  3375. // order_src.RequestLog = src_resquest
  3376. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3377. // detailStr := string(setlDetail)
  3378. // order_src.SetlDetail = detailStr
  3379. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3380. // err = service.UpDateOrder(order_src)
  3381. //
  3382. // if err == nil {
  3383. // c.ServeSuccessJSON(map[string]interface{}{
  3384. // "msg": "结算成功",
  3385. // })
  3386. // } else {
  3387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3388. // return
  3389. // }
  3390. // }
  3391. // }
  3392. //}
  3393. //退款
  3394. func (c *HisApiController) Refund() {
  3395. order_id, _ := c.GetInt64("order_id")
  3396. admin_user_id, _ := c.GetInt64("admin_user_id")
  3397. //record_time := c.GetString("record_time")
  3398. //patient_id, _ := c.GetInt64("patient_id")
  3399. //timeLayout := "2006-01-02"
  3400. //loc, _ := time.LoadLocation("Local")
  3401. adminUser := c.GetAdminUserInfo()
  3402. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3403. //if err != nil {
  3404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3405. // return
  3406. //}
  3407. //recordDateTime := theTime.Unix()
  3408. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3409. var order models.HisOrder
  3410. order, _ = service.GetHisOrderByID(order_id)
  3411. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3412. if order.ID == 0 {
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3414. return
  3415. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3416. }
  3417. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3418. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3419. if config.IsOpen == 1 { //对接了医保,走医保流程
  3420. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3421. var dat map[string]interface{}
  3422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3423. fmt.Println(dat)
  3424. } else {
  3425. fmt.Println(err)
  3426. }
  3427. userJSONBytes, _ := json.Marshal(dat)
  3428. var res ResultSixteen
  3429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3430. utils.ErrorLog("解析失败:%v", err)
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3432. return
  3433. }
  3434. if res.Infcode == 0 {
  3435. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  3436. var dat map[string]interface{}
  3437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3438. fmt.Println(dat)
  3439. } else {
  3440. fmt.Println(err)
  3441. }
  3442. userJSONBytes, _ := json.Marshal(dat)
  3443. var res2 ResultSix
  3444. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3445. utils.ErrorLog("解析失败:%v", err)
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3447. return
  3448. }
  3449. if res2.Infcode == 0 {
  3450. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  3451. if err == nil {
  3452. c.ServeSuccessJSON(map[string]interface{}{
  3453. "msg": "退费成功",
  3454. })
  3455. } else {
  3456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3457. return
  3458. }
  3459. } else {
  3460. c.ServeSuccessJSON(map[string]interface{}{
  3461. "code": -10,
  3462. "msg": res2.ErrMsg,
  3463. })
  3464. }
  3465. } else {
  3466. c.ServeSuccessJSON(map[string]interface{}{
  3467. "code": -10,
  3468. "msg": res.ErrMsg,
  3469. })
  3470. }
  3471. }
  3472. }
  3473. func (c *HisApiController) RefundNumber() {
  3474. record_time := c.GetString("record_time")
  3475. //patient_id, _ := c.GetInt64("patient_id")
  3476. admin_user_id, _ := c.GetInt64("admin_user_id")
  3477. his_patient_id, _ := c.GetInt64("id")
  3478. timeLayout := "2006-01-02"
  3479. loc, _ := time.LoadLocation("Local")
  3480. adminUser := c.GetAdminUserInfo()
  3481. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3482. fmt.Println(err)
  3483. if err != nil {
  3484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3485. return
  3486. }
  3487. recordDateTime := theTime.Unix()
  3488. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3489. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  3490. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3491. //order, _ := service.GetHisOrderByID(order_id)
  3492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3494. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3495. if config.IsOpen == 1 { //对接了医保,走医保流程
  3496. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  3497. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3499. resp3, requestErr3 := http.Get(api3)
  3500. if requestErr3 != nil {
  3501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. return
  3503. }
  3504. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  3505. if ioErr3 != nil {
  3506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  3507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3508. return
  3509. }
  3510. var respJSON3 map[string]interface{}
  3511. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  3512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3517. userJSONBytes3, _ := json.Marshal(respJSON3)
  3518. var res2 ResultSix
  3519. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3520. utils.ErrorLog("解析失败:%v", err)
  3521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3522. return
  3523. }
  3524. if res2.Infcode == 0 {
  3525. if err == nil {
  3526. c.ServeSuccessJSON(map[string]interface{}{
  3527. "msg": "退号成功",
  3528. })
  3529. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  3530. } else {
  3531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3532. return
  3533. }
  3534. } else {
  3535. c.ServeSuccessJSON(map[string]interface{}{
  3536. "code": -10,
  3537. "msg": res2.ErrMsg,
  3538. })
  3539. }
  3540. } else {
  3541. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3542. //if err == nil {
  3543. // c.ServeSuccessJSON(map[string]interface{}{
  3544. // "msg": "退费成功",
  3545. // })
  3546. //} else {
  3547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3548. // return
  3549. //}
  3550. }
  3551. }
  3552. func (c *HisApiController) RefundDetail() {
  3553. order_id, _ := c.GetInt64("order_id")
  3554. his_patient_id, _ := c.GetInt64("his_patient_id")
  3555. number := c.GetString("number")
  3556. record_time := c.GetString("record_time")
  3557. patient_id, _ := c.GetInt64("patient_id")
  3558. timeLayout := "2006-01-02"
  3559. loc, _ := time.LoadLocation("Local")
  3560. adminUser := c.GetAdminUserInfo()
  3561. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3562. fmt.Println(err)
  3563. if err != nil {
  3564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3565. return
  3566. }
  3567. recordDateTime := theTime.Unix()
  3568. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3569. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3571. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3572. var order models.HisOrder
  3573. order, _ = service.GetHisOrderByID(order_id)
  3574. if order.ID == 0 {
  3575. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3576. }
  3577. if config.IsOpen == 1 { //对接了医保,走医保流程
  3578. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3579. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3580. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3581. resp2, requestErr2 := http.Get(api2)
  3582. if requestErr2 != nil {
  3583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3584. return
  3585. }
  3586. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3587. if ioErr2 != nil {
  3588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3590. return
  3591. }
  3592. var respJSON2 map[string]interface{}
  3593. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3596. return
  3597. }
  3598. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3599. if err == nil {
  3600. c.ServeSuccessJSON(map[string]interface{}{
  3601. "msg": "退费成功",
  3602. })
  3603. } else {
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. } else {
  3608. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3609. if err == nil {
  3610. c.ServeSuccessJSON(map[string]interface{}{
  3611. "msg": "退费成功",
  3612. })
  3613. } else {
  3614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3615. return
  3616. }
  3617. }
  3618. }
  3619. //对账
  3620. func (c *HisApiController) GetCheckAccount() {
  3621. start_time := c.GetString("start_time")
  3622. end_time := c.GetString("end_time")
  3623. insutype := c.GetString("insutype")
  3624. clr_type := c.GetString("clr_type")
  3625. admin_user_id, _ := c.GetInt64("admin_user_id")
  3626. adminUser := c.GetAdminUserInfo()
  3627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3628. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3629. timeLayout := "2006-01-02"
  3630. loc, _ := time.LoadLocation("Local")
  3631. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3632. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3633. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3634. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3635. fixmedins_setl_cnt := int64(len(orders))
  3636. //
  3637. ////撤销的算2条数据为一笔
  3638. //for _, item := range orders_two {
  3639. // if item.OrderStatus == 3 {
  3640. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3641. // }
  3642. //}
  3643. var medfee_sumamt float64
  3644. var acct_pay float64
  3645. var fund_pay_sumamt float64
  3646. for _, item := range orders {
  3647. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3648. acct_pay = acct_pay + item.AcctPay
  3649. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3650. }
  3651. var user_name string
  3652. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3653. if role.ID == 0 {
  3654. user_name = "xxx"
  3655. } else {
  3656. user_name = role.UserName
  3657. }
  3658. if config.IsOpen == 1 {
  3659. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3660. "insutype=" + insutype +
  3661. "&clr_type=" + clr_type +
  3662. "&setl_optins=" + "定点医保中心" +
  3663. "&stmt_begndate=" + start_time +
  3664. "&stm_enddate=" + end_time +
  3665. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3666. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3667. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3668. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3669. "&fixmedins_code=" + miConfig.Code +
  3670. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3671. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3672. "&secret_key=" + miConfig.SecretKey +
  3673. "&org_name=" + miConfig.OrgName +
  3674. "&doctor=" + user_name
  3675. fmt.Println(api)
  3676. resp, requestErr := http.Get(api)
  3677. if requestErr != nil {
  3678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3679. return
  3680. }
  3681. body, ioErr := ioutil.ReadAll(resp.Body)
  3682. fmt.Println(body)
  3683. if ioErr != nil {
  3684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3686. return
  3687. }
  3688. var respJSON map[string]interface{}
  3689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. return
  3693. }
  3694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3695. userJSONBytes, _ := json.Marshal(respJSON)
  3696. var res ResultEight
  3697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3698. utils.ErrorLog("解析失败:%v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. if res.Infcode == 0 {
  3703. if res.Output.Stmtinfo.StmtRslt == "0" {
  3704. micc := &models.MedicalInsuranceCostCompare{
  3705. StartTime: startime.Unix(),
  3706. EndTime: endtime.Unix(),
  3707. Insutype: insutype,
  3708. CheckType: 1,
  3709. Num: fixmedins_setl_cnt,
  3710. Mtime: time.Now().Unix(),
  3711. Status: 1,
  3712. UserOrgId: adminUser.CurrentOrgId,
  3713. CostTotal: medfee_sumamt,
  3714. FuncTotal: fund_pay_sumamt,
  3715. PsnPay: acct_pay,
  3716. Creator: admin_user_id,
  3717. Ctime: time.Now().Unix(),
  3718. }
  3719. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3720. if err == nil {
  3721. c.ServeSuccessJSON(map[string]interface{}{
  3722. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3723. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3724. })
  3725. } else {
  3726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3727. }
  3728. } else {
  3729. c.ServeSuccessJSON(map[string]interface{}{
  3730. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3731. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3732. })
  3733. }
  3734. } else {
  3735. c.ServeSuccessJSON(map[string]interface{}{
  3736. "code": -10,
  3737. "msg": res.ErrMsg,
  3738. })
  3739. }
  3740. }
  3741. }
  3742. func (c *HisApiController) Check310() {
  3743. adminUser := c.GetAdminUserInfo()
  3744. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3745. var user_name string
  3746. user_name = "xxx"
  3747. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3748. "insutype=" + "310" +
  3749. "&clr_type=" + "11" +
  3750. "&setl_optins=" + "定点医保中心" +
  3751. "&stmt_begndate=" + "2021-03-01" +
  3752. "&stm_enddate=" + "2021-03-31" +
  3753. "&medfee_sumamt=" + "11521" +
  3754. "&fund_pay_sumamt=" + "10166.66" +
  3755. "&acct_pay=" + "0" +
  3756. "&fixmedins_setl_cnt=" + "7" +
  3757. "&fixmedins_code=" + miConfig.Code +
  3758. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3759. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3760. "&secret_key=" + miConfig.SecretKey +
  3761. "&org_name=" + miConfig.OrgName +
  3762. "&doctor=" + user_name
  3763. fmt.Println(api)
  3764. resp, requestErr := http.Get(api)
  3765. if requestErr != nil {
  3766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3767. return
  3768. }
  3769. body, ioErr := ioutil.ReadAll(resp.Body)
  3770. fmt.Println(body)
  3771. if ioErr != nil {
  3772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3774. return
  3775. }
  3776. var respJSON map[string]interface{}
  3777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3780. return
  3781. }
  3782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3783. userJSONBytes, _ := json.Marshal(respJSON)
  3784. var res ResultEight
  3785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3786. utils.ErrorLog("解析失败:%v", err)
  3787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. return
  3789. }
  3790. }
  3791. func (c *HisApiController) Check390() {
  3792. adminUser := c.GetAdminUserInfo()
  3793. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3794. var user_name string
  3795. user_name = "张俊杰"
  3796. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3797. "insutype=" + "390" +
  3798. "&clr_type=" + "11" +
  3799. "&setl_optins=" + "定点医保中心" +
  3800. "&stmt_begndate=" + "2021-03-01" +
  3801. "&stm_enddate=" + "2021-03-31" +
  3802. "&medfee_sumamt=" + "209318.43" +
  3803. "&fund_pay_sumamt=" + "188029.12" +
  3804. "&acct_pay=" + "0" +
  3805. "&fixmedins_setl_cnt=" + "48" +
  3806. "&fixmedins_code=" + miConfig.Code +
  3807. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3808. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3809. "&secret_key=" + miConfig.SecretKey +
  3810. "&org_name=" + miConfig.OrgName +
  3811. "&doctor=" + user_name
  3812. fmt.Println(api)
  3813. resp, requestErr := http.Get(api)
  3814. if requestErr != nil {
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. body, ioErr := ioutil.ReadAll(resp.Body)
  3819. fmt.Println(body)
  3820. if ioErr != nil {
  3821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3823. return
  3824. }
  3825. var respJSON map[string]interface{}
  3826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3829. return
  3830. }
  3831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3832. userJSONBytes, _ := json.Marshal(respJSON)
  3833. var res ResultEight
  3834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3835. utils.ErrorLog("解析失败:%v", err)
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3837. return
  3838. }
  3839. }
  3840. //对账明细
  3841. func (c *HisApiController) GetCheckDetailAccount() {
  3842. start_time := c.GetString("start_time")
  3843. end_time := c.GetString("end_time")
  3844. admin_user_id, _ := c.GetInt64("admin_user_id")
  3845. adminUser := c.GetAdminUserInfo()
  3846. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3847. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3848. timeLayout := "2006-01-02"
  3849. loc, _ := time.LoadLocation("Local")
  3850. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3851. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3852. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  3853. Mkdir(miConfig.OrgName)
  3854. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  3855. file_name := file + ".txt"
  3856. zip_name := file + ".zip"
  3857. zip_path := miConfig.OrgName + "/" + zip_name
  3858. file_path := miConfig.OrgName + "/" + file_name
  3859. decimal.DivisionPrecision = 2
  3860. var medfee_sumamt float64
  3861. var psn_cash_pay float64
  3862. var fund_pay_sumamt float64
  3863. fixmedins_setl_cnt := int64(len(orders))
  3864. for _, item := range orders {
  3865. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3866. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  3867. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3868. }
  3869. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  3870. defer f.Close()
  3871. if err != nil {
  3872. fmt.Println(err.Error())
  3873. } else {
  3874. for _, item := range orders {
  3875. var refd_setl_flag string
  3876. if item.OrderStatus == 2 {
  3877. refd_setl_flag = "0"
  3878. var str string
  3879. str = item.SetlId + " " +
  3880. item.MdtrtId + " " +
  3881. item.PsnNo + " " +
  3882. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3883. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3884. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  3885. _, err = f.Write([]byte(str))
  3886. }
  3887. if item.OrderStatus == 3 {
  3888. var str string
  3889. str = item.SetlId + " " +
  3890. item.MdtrtId + " " +
  3891. item.PsnNo + " " +
  3892. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3893. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3894. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  3895. _, err = f.Write([]byte(str))
  3896. var str2 string
  3897. str2 = item.SetlId + " " +
  3898. item.MdtrtId + " " +
  3899. item.PsnNo + " " +
  3900. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  3901. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  3902. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  3903. _, err = f.Write([]byte(str2))
  3904. }
  3905. }
  3906. }
  3907. Zip(file_path, zip_path)
  3908. fmt.Println(ReadFile(zip_path))
  3909. fmt.Println(string(ReadFile(zip_path)))
  3910. if config.IsOpen == 1 {
  3911. var user_name string
  3912. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3913. if role.ID == 0 {
  3914. user_name = "管理员"
  3915. } else {
  3916. user_name = role.UserName
  3917. }
  3918. baseParams := models.BaseParams{
  3919. SecretKey: miConfig.SecretKey,
  3920. FixmedinsCode: miConfig.Code,
  3921. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3922. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3923. OrgName: miConfig.OrgName,
  3924. Doctor: user_name,
  3925. }
  3926. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  3927. var dat map[string]interface{}
  3928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3929. fmt.Println(dat)
  3930. } else {
  3931. fmt.Println(err)
  3932. }
  3933. userJSONBytes, _ := json.Marshal(dat)
  3934. var res ResultNine
  3935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3936. utils.ErrorLog("解析失败:%v", err)
  3937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3938. return
  3939. }
  3940. if res.Infcode == 0 {
  3941. fileNo := res.Output.FileQuryNo
  3942. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  3943. "file_qury_no=" + fileNo +
  3944. "&setl_optins=" + "定点医保中心" +
  3945. "&stmt_begndate=" + start_time +
  3946. "&stm_enddate=" + end_time +
  3947. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3948. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3949. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  3950. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3951. "&fixmedins_code=" + miConfig.Code +
  3952. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3953. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3954. "&secret_key=" + miConfig.SecretKey +
  3955. "&org_name=" + miConfig.OrgName +
  3956. "&doctor=" + user_name
  3957. resp, requestErr := http.Get(api)
  3958. if requestErr != nil {
  3959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. return
  3961. }
  3962. body, ioErr := ioutil.ReadAll(resp.Body)
  3963. if ioErr != nil {
  3964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. return
  3967. }
  3968. var respJSON map[string]interface{}
  3969. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3972. return
  3973. }
  3974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3975. userJSONBytes, _ := json.Marshal(respJSON)
  3976. var res ResultTen
  3977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3978. utils.ErrorLog("解析失败:%v", err)
  3979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3980. return
  3981. }
  3982. if res.Infcode == 0 {
  3983. service.Gdyb9102(baseParams, zip_name, fileNo)
  3984. micc := &models.MedicalInsuranceCostCompare{
  3985. StartTime: startime.Unix(),
  3986. EndTime: endtime.Unix(),
  3987. Insutype: "0",
  3988. CheckType: 2,
  3989. Num: fixmedins_setl_cnt,
  3990. Mtime: time.Now().Unix(),
  3991. Status: 1,
  3992. UserOrgId: adminUser.CurrentOrgId,
  3993. CostTotal: medfee_sumamt,
  3994. FuncTotal: fund_pay_sumamt,
  3995. PsnPay: psn_cash_pay,
  3996. Creator: admin_user_id,
  3997. Ctime: time.Now().Unix(),
  3998. }
  3999. service.CreateMedicalInsuranceCostCompareRecord(micc)
  4000. c.ServeSuccessJSON(map[string]interface{}{
  4001. "msg": "明细对账成功",
  4002. })
  4003. }
  4004. } else {
  4005. }
  4006. }
  4007. }
  4008. func (c *HisApiController) GetSettleAccounts() {
  4009. //id, _ := c.GetInt64("id")
  4010. //record_time := c.GetString("record_time")
  4011. order_id, _ := c.GetInt64("order_id")
  4012. admin_user_id, _ := c.GetInt64("admin_user_id")
  4013. //timeLayout := "2006-01-02"
  4014. //loc, _ := time.LoadLocation("Local")
  4015. //
  4016. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4017. //if err != nil {
  4018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4019. // return
  4020. //}
  4021. //recordDateTime := theTime.Unix()
  4022. adminUser := c.GetAdminUserInfo()
  4023. order, _ := service.GetHisOrderByID(order_id)
  4024. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4025. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  4026. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4027. orderInfos = append(orderInfos, orderInfos_two...)
  4028. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  4029. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4030. //var config []*models.HisXtDiagnoseConfig
  4031. var name string
  4032. for _, item := range diagnosis_ids {
  4033. id, _ := strconv.ParseInt(item, 10, 64)
  4034. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4035. if len(name) == 0 {
  4036. name = diagnosisConfig.ClassName
  4037. } else {
  4038. name = name + "," + diagnosisConfig.ClassName
  4039. }
  4040. }
  4041. var bedCostTotal float64 = 0 //床位总费
  4042. var bedCostSelfTotal float64 = 0 //床位自费
  4043. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4044. var operationCostTotal float64 = 0 //手术费
  4045. var operationCostSelfTotal float64 = 0 //手术费
  4046. var operationCostPartSelfTotal float64 = 0 //手术费
  4047. var otherCostTotal float64 = 0 //其他费用
  4048. var otherCostSelfTotal float64 = 0 //其他费用
  4049. var otherCostPartSelfTotal float64 = 0 //其他费用
  4050. var materialCostTotal float64 = 0 //材料费
  4051. var materialCostSelfTotal float64 = 0 //材料费
  4052. var materialCostPartSelfTotal float64 = 0 //材料费
  4053. var westernMedicineCostTotal float64 = 0 //西药费
  4054. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4055. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4056. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4057. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4058. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4059. var checkCostTotal float64 = 0 //检查费
  4060. var checkCostSelfTotal float64 = 0 //检查费
  4061. var checkCostPartSelfTotal float64 = 0 //检查费
  4062. var laboratoryCostTotal float64 = 0 //化验费
  4063. var laboratoryCostSelfTotal float64 = 0 //化验费
  4064. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4065. var treatCostTotal float64 = 0 //治疗费用
  4066. var treatCostSelfTotal float64 = 0 //治疗费用
  4067. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4068. decimal.DivisionPrecision = 2
  4069. for _, item := range orderInfos {
  4070. if item.MedChrgitmType == "01" { //床位费
  4071. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4072. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4073. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4074. }
  4075. if item.MedChrgitmType == "03" { //检查费
  4076. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4077. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4078. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4079. }
  4080. if item.MedChrgitmType == "04" { //化验费
  4081. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4082. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4083. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4084. }
  4085. if item.MedChrgitmType == "05" { //治疗费
  4086. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4087. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4088. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4089. }
  4090. if item.MedChrgitmType == "06" { //手术费
  4091. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4092. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4093. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4094. }
  4095. if item.MedChrgitmType == "08" { //材料费
  4096. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4097. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4098. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4099. }
  4100. if item.MedChrgitmType == "09" { //西药费
  4101. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4102. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4103. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4104. }
  4105. if item.MedChrgitmType == "11" { //中成费
  4106. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4107. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4108. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4109. }
  4110. if item.MedChrgitmType == "14" { //其他费
  4111. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4112. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4113. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4114. }
  4115. }
  4116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4117. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4118. var user_name string
  4119. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4120. if role.ID == 0 {
  4121. user_name = "管理员"
  4122. } else {
  4123. user_name = role.UserName
  4124. }
  4125. baseParams := models.BaseParams{
  4126. SecretKey: miConfig.SecretKey,
  4127. FixmedinsCode: miConfig.Code,
  4128. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4129. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4130. OrgName: miConfig.OrgName,
  4131. Doctor: user_name,
  4132. }
  4133. businessParams := models.BusinessParams{
  4134. PsnNo: order.PsnNo,
  4135. MdtrtId: order.MdtrtId,
  4136. SetlId: order.SetlId,
  4137. }
  4138. if config.IsOpen == 1 {
  4139. result := service.Gdyb5203(baseParams, businessParams)
  4140. var dat map[string]interface{}
  4141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4142. fmt.Println(dat)
  4143. } else {
  4144. fmt.Println(err)
  4145. }
  4146. userJSONBytes, _ := json.Marshal(dat)
  4147. var res ResultEleven
  4148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4149. utils.ErrorLog("解析失败:%v", err)
  4150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4151. return
  4152. }
  4153. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4154. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  4155. if res.Infcode == 0 {
  4156. c.ServeSuccessJSON(map[string]interface{}{
  4157. "diagnosis": name,
  4158. "order_infos": orderInfos,
  4159. "number": order.MdtrtId,
  4160. "date": order.SettleAccountsDate,
  4161. "charge_admin": charge_admin,
  4162. "printor_admin": printor_admin,
  4163. "info": res.Output.Setlinfo,
  4164. "bedCostTotal": bedCostTotal,
  4165. "bedCostSelfTotal": bedCostSelfTotal,
  4166. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  4167. "operationCostTotal": operationCostTotal,
  4168. "operationCostSelfTotal": operationCostSelfTotal,
  4169. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  4170. "otherCostTotal": otherCostTotal,
  4171. "otherCostSelfTotal": otherCostSelfTotal,
  4172. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  4173. "materialCostTotal": materialCostTotal,
  4174. "materialCostSelfTotal": materialCostSelfTotal,
  4175. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  4176. "westernMedicineCostTotal": westernMedicineCostTotal,
  4177. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  4178. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  4179. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  4180. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  4181. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  4182. "checkCostTotal": checkCostTotal,
  4183. "checkCostSelfTotal": checkCostSelfTotal,
  4184. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  4185. "laboratoryCostTotal": laboratoryCostTotal,
  4186. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  4187. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  4188. "treatCostTotal": treatCostTotal,
  4189. "treatCostSelfTotal": treatCostSelfTotal,
  4190. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  4191. })
  4192. }
  4193. }
  4194. }
  4195. func (c *HisApiController) CheckTreatment() {
  4196. patient_id, _ := c.GetInt64("patient_id", 0)
  4197. record_time := c.GetString("record_time")
  4198. insutype := c.GetString("insutype")
  4199. timeLayout := "2006-01-02"
  4200. loc, _ := time.LoadLocation("Local")
  4201. adminUser := c.GetAdminUserInfo()
  4202. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4203. fmt.Println(err)
  4204. if err != nil {
  4205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4206. return
  4207. }
  4208. recordDateTime := theTime.Unix()
  4209. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4210. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4211. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4212. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4213. var user_name string
  4214. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  4215. if role.ID == 0 {
  4216. user_name = "xxx"
  4217. } else {
  4218. user_name = role.UserName
  4219. }
  4220. baseParams := models.BaseParams{
  4221. SecretKey: miConfig.SecretKey,
  4222. FixmedinsCode: miConfig.Code,
  4223. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4224. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4225. OrgName: miConfig.OrgName,
  4226. Doctor: user_name,
  4227. }
  4228. if config.IsOpen == 1 {
  4229. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  4230. var dat map[string]interface{}
  4231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4232. fmt.Println(dat)
  4233. } else {
  4234. fmt.Println(err)
  4235. }
  4236. }
  4237. }
  4238. func (c *HisApiController) PutRecord() {
  4239. id, _ := c.GetInt64("id")
  4240. record_time := c.GetString("record_time")
  4241. timeLayout := "2006-01-02"
  4242. loc, _ := time.LoadLocation("Local")
  4243. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4244. if err != nil {
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4246. return
  4247. }
  4248. recordDateTime := theTime.Unix()
  4249. adminInfo := c.GetAdminUserInfo()
  4250. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  4251. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4252. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4253. fmt.Println(miConfig.SecretKey)
  4254. if patient == nil {
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4256. return
  4257. }
  4258. if len(patient.IdCardNo) == 0 {
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4260. return
  4261. }
  4262. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4263. if config.IsOpen == 1 {
  4264. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4265. resp, requestErr := http.Get(api)
  4266. if requestErr != nil {
  4267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4268. return
  4269. }
  4270. defer resp.Body.Close()
  4271. body, ioErr := ioutil.ReadAll(resp.Body)
  4272. if ioErr != nil {
  4273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. return
  4276. }
  4277. var respJSON map[string]interface{}
  4278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4281. return
  4282. }
  4283. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4284. userJSONBytes, _ := json.Marshal(userJSON)
  4285. var res ResultTwo
  4286. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4287. utils.ErrorLog("解析失败:%v", err)
  4288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4289. return
  4290. }
  4291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4293. infoStr := string(Iinfos)
  4294. idetinfoStr := string(Idetinfos)
  4295. if res.Infcode == 0 {
  4296. his := models.VMHisPatient{
  4297. Status: 1,
  4298. Ctime: time.Now().Unix(),
  4299. Mtime: time.Now().Unix(),
  4300. PsnNo: res.Output.Baseinfo.PsnNo,
  4301. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4302. Certno: res.Output.Baseinfo.Certno,
  4303. PsnName: res.Output.Baseinfo.PsnName,
  4304. Gend: res.Output.Baseinfo.Gend,
  4305. Naty: res.Output.Baseinfo.Naty,
  4306. Brdy: res.Output.Baseinfo.Brdy,
  4307. Age: res.Output.Baseinfo.Age,
  4308. Iinfo: infoStr,
  4309. Idetinfo: idetinfoStr,
  4310. PatientId: patient.ID,
  4311. RecordDate: theTime.Unix(),
  4312. UserOrgId: adminInfo.CurrentOrgId,
  4313. AdminUserId: adminInfo.AdminUser.Id,
  4314. IsReturn: 1,
  4315. }
  4316. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4317. result := service.Gdyb2503(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  4318. result2 := service.Gdyb5301(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  4319. var dat map[string]interface{}
  4320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4321. fmt.Println(dat)
  4322. } else {
  4323. fmt.Println(err)
  4324. }
  4325. var dat2 map[string]interface{}
  4326. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  4327. fmt.Println(dat2)
  4328. } else {
  4329. fmt.Println(err)
  4330. }
  4331. } else {
  4332. adminUser := c.GetAdminUserInfo()
  4333. errlog := &models.HisOrderError{
  4334. UserOrgId: adminUser.CurrentOrgId,
  4335. Ctime: time.Now().Unix(),
  4336. Mtime: time.Now().Unix(),
  4337. ErrMsg: res.ErrMsg,
  4338. Status: 1,
  4339. PatientId: id,
  4340. RecordTime: recordDateTime,
  4341. Stage: 1,
  4342. }
  4343. service.CreateErrMsgLog(errlog)
  4344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4345. return
  4346. }
  4347. }
  4348. }
  4349. func (c *HisApiController) GetUploadDiag() {
  4350. id, _ := c.GetInt64("id")
  4351. record_time := c.GetString("record_time")
  4352. diagnosis_id, _ := c.GetInt64("diagnosis")
  4353. sick_type, _ := c.GetInt64("sick_type")
  4354. reg_type, _ := c.GetInt64("reg_type")
  4355. timeLayout := "2006-01-02"
  4356. loc, _ := time.LoadLocation("Local")
  4357. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4358. if err != nil {
  4359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4360. return
  4361. }
  4362. var patientPrescription models.HisPrescriptionInfo
  4363. recordDateTime := theTime.Unix()
  4364. adminInfo := c.GetAdminUserInfo()
  4365. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4366. if patientPrescription.ID == 0 {
  4367. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4368. }
  4369. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4370. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4371. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4372. sickConfig, _ := service.FindSickById(sick_type)
  4373. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4374. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  4375. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  4376. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  4377. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  4378. resp2, requestErr2 := http.Get(api2)
  4379. if requestErr2 != nil {
  4380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4381. return
  4382. }
  4383. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4384. if ioErr2 != nil {
  4385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4387. return
  4388. }
  4389. var respJSON2 map[string]interface{}
  4390. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. return
  4394. }
  4395. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4396. userJSONBytes2, _ := json.Marshal(respJSON2)
  4397. var res2 ResultSix
  4398. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4399. utils.ErrorLog("解析失败:%v", err)
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. if res2.Infcode != 0 {
  4404. adminUser := c.GetAdminUserInfo()
  4405. errlog := &models.HisOrderError{
  4406. UserOrgId: adminUser.CurrentOrgId,
  4407. Ctime: time.Now().Unix(),
  4408. Mtime: time.Now().Unix(),
  4409. ErrMsg: res2.ErrMsg,
  4410. Status: 1,
  4411. PatientId: id,
  4412. RecordTime: recordDateTime,
  4413. Stage: 3,
  4414. }
  4415. service.CreateErrMsgLog(errlog)
  4416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  4417. return
  4418. }
  4419. c.ServeSuccessJSON(map[string]interface{}{
  4420. "msg": "上传成功",
  4421. })
  4422. }
  4423. type QueryResult struct {
  4424. ID int64
  4425. Name string
  4426. Code string
  4427. List_type_code string
  4428. }
  4429. func (c *HisApiController) GetCheckCode() {
  4430. ids_str := c.GetString("ids")
  4431. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4432. ids_arr := strings.Split(ids_str, ",")
  4433. var queryResult []QueryResult
  4434. ids := make([]int64, 0)
  4435. for _, item := range ids_arr {
  4436. id, _ := strconv.ParseInt(item, 10, 64)
  4437. ids = append(ids, id)
  4438. }
  4439. if record_type == 1 {
  4440. drugs, _ := service.GetBatchDrugList(ids)
  4441. for _, item := range drugs {
  4442. result := QueryResult{
  4443. ID: item.ID,
  4444. Name: item.DrugName,
  4445. Code: item.MedicalInsuranceNumber,
  4446. List_type_code: "101",
  4447. }
  4448. queryResult = append(queryResult, result)
  4449. }
  4450. } else if record_type == 2 {
  4451. goods, _ := service.GetBatchGoodInformationList(ids)
  4452. for _, item := range goods {
  4453. result := QueryResult{
  4454. ID: item.ID,
  4455. Name: item.GoodName,
  4456. Code: item.MedicalInsuranceNumber,
  4457. List_type_code: "301",
  4458. }
  4459. queryResult = append(queryResult, result)
  4460. }
  4461. } else if record_type == 3 {
  4462. projects, _ := service.GetBathchMyPorjecgList(ids)
  4463. for _, item := range projects {
  4464. result := QueryResult{
  4465. ID: item.ID,
  4466. Name: item.ProjectName,
  4467. Code: item.MedicalCode,
  4468. List_type_code: "201",
  4469. }
  4470. queryResult = append(queryResult, result)
  4471. }
  4472. }
  4473. admin_user_id, _ := c.GetInt64("admin_user_id")
  4474. adminUser := c.GetAdminUserInfo()
  4475. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4476. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4477. var user_name string
  4478. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4479. if role.ID == 0 {
  4480. user_name = "xxx"
  4481. } else {
  4482. user_name = role.UserName
  4483. }
  4484. baseParams := &models.BaseParams{
  4485. SecretKey: miConfig.SecretKey,
  4486. FixmedinsCode: miConfig.Code,
  4487. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4488. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4489. OrgName: miConfig.OrgName,
  4490. Doctor: user_name,
  4491. }
  4492. if config.IsOpen == 1 {
  4493. for _, item := range queryResult {
  4494. var result string
  4495. if record_type == 1 {
  4496. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4497. } else if record_type == 2 {
  4498. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4499. } else if record_type == 3 {
  4500. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4501. }
  4502. var dat map[string]interface{}
  4503. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4504. fmt.Println(dat)
  4505. } else {
  4506. fmt.Println(err)
  4507. }
  4508. userJSONBytes, _ := json.Marshal(dat)
  4509. var res ResultSix
  4510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4511. utils.ErrorLog("解析失败:%v", err)
  4512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4513. return
  4514. }
  4515. if res.Infcode == 0 {
  4516. if record_type == 1 {
  4517. service.UpdateBaseDrugById(item.ID)
  4518. } else if record_type == 2 {
  4519. service.UpdateGoodInformaitonByDetail(item.ID)
  4520. } else if record_type == 3 {
  4521. service.UpdateProjectById(item.ID)
  4522. }
  4523. c.ServeSuccessJSON(map[string]interface{}{
  4524. "failed_code": 0,
  4525. "msg": "目录对照成功",
  4526. })
  4527. } else {
  4528. c.ServeSuccessJSON(map[string]interface{}{
  4529. "failed_code": -10,
  4530. "msg": res.ErrMsg,
  4531. })
  4532. }
  4533. }
  4534. }
  4535. }
  4536. func (c *HisApiController) UnCheckCode() {
  4537. ids_str := c.GetString("ids")
  4538. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4539. admin_user_id, _ := c.GetInt64("admin_user_id")
  4540. ids_arr := strings.Split(ids_str, ",")
  4541. var queryResult []QueryResult
  4542. ids := make([]int64, 0)
  4543. for _, item := range ids_arr {
  4544. id, _ := strconv.ParseInt(item, 10, 64)
  4545. ids = append(ids, id)
  4546. }
  4547. if record_type == 1 {
  4548. drugs, _ := service.GetBatchDrugList(ids)
  4549. for _, item := range drugs {
  4550. result := QueryResult{
  4551. ID: item.ID,
  4552. Name: item.DrugName,
  4553. Code: item.MedicalInsuranceNumber,
  4554. List_type_code: "101",
  4555. }
  4556. queryResult = append(queryResult, result)
  4557. }
  4558. } else if record_type == 2 {
  4559. goods, _ := service.GetBatchGoodInformationList(ids)
  4560. for _, item := range goods {
  4561. result := QueryResult{
  4562. ID: item.ID,
  4563. Name: item.GoodName,
  4564. Code: item.MedicalInsuranceNumber,
  4565. List_type_code: "301",
  4566. }
  4567. queryResult = append(queryResult, result)
  4568. }
  4569. } else if record_type == 3 {
  4570. projects, _ := service.GetBathchMyPorjecgList(ids)
  4571. for _, item := range projects {
  4572. result := QueryResult{
  4573. ID: item.ID,
  4574. Name: item.ProjectName,
  4575. Code: item.MedicalCode,
  4576. List_type_code: "201",
  4577. }
  4578. queryResult = append(queryResult, result)
  4579. }
  4580. }
  4581. adminUser := c.GetAdminUserInfo()
  4582. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4583. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4584. var user_name string
  4585. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4586. if role.ID == 0 {
  4587. user_name = "xxx"
  4588. } else {
  4589. user_name = role.UserName
  4590. }
  4591. baseParams := &models.BaseParams{
  4592. SecretKey: miConfig.SecretKey,
  4593. FixmedinsCode: miConfig.Code,
  4594. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4595. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4596. OrgName: miConfig.OrgName,
  4597. Doctor: user_name,
  4598. }
  4599. if config.IsOpen == 1 {
  4600. for _, item := range queryResult {
  4601. var result string
  4602. if record_type == 1 {
  4603. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4604. } else if record_type == 2 {
  4605. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4606. } else if record_type == 3 {
  4607. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4608. }
  4609. var dat2 map[string]interface{}
  4610. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4611. fmt.Println(dat2)
  4612. } else {
  4613. fmt.Println(err)
  4614. }
  4615. userJSONBytes, _ := json.Marshal(dat2)
  4616. var res ResultSix
  4617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4618. utils.ErrorLog("解析失败:%v", err)
  4619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4620. return
  4621. }
  4622. if res.Infcode == 0 {
  4623. if record_type == 1 {
  4624. service.UpdateDrugByIdDetail(item.ID)
  4625. } else if record_type == 2 {
  4626. service.UpdateGoodInfoById(item.ID)
  4627. } else if record_type == 3 {
  4628. service.UpdateMyProjectById(item.ID)
  4629. }
  4630. c.ServeSuccessJSON(map[string]interface{}{
  4631. "failed_code": 0,
  4632. "msg": "撤销目录对照成功",
  4633. })
  4634. } else {
  4635. c.ServeSuccessJSON(map[string]interface{}{
  4636. "failed_code": -10,
  4637. "msg": res.ErrMsg,
  4638. })
  4639. }
  4640. }
  4641. }
  4642. }
  4643. func (c *HisApiController) GetPatientInfo() {
  4644. id_card_no := c.GetString("id_card_no")
  4645. admin_user_id, _ := c.GetInt64("admin_user_id")
  4646. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4647. if patient.ID == 0 {
  4648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4649. return
  4650. }
  4651. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4652. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4653. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4654. if config.IsOpen == 1 {
  4655. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4656. var dat map[string]interface{}
  4657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4658. fmt.Println(dat)
  4659. } else {
  4660. fmt.Println(err)
  4661. }
  4662. userJSONBytes, _ := json.Marshal(dat)
  4663. var res ResultTwo
  4664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4665. utils.ErrorLog("解析失败:%v", err)
  4666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4667. return
  4668. }
  4669. if res.Infcode != 0 {
  4670. c.ServeSuccessJSON(map[string]interface{}{
  4671. "failed_code": -10,
  4672. "msg": res.ErrMsg,
  4673. })
  4674. } else {
  4675. c.ServeSuccessJSON(map[string]interface{}{
  4676. "failed_code": 0,
  4677. "info": res,
  4678. })
  4679. }
  4680. }
  4681. }
  4682. func (c *HisApiController) PsnPutOnRecord() {
  4683. record_type, _ := c.GetInt64("type")
  4684. patient_id, _ := c.GetInt64("patient_id")
  4685. admin_user_id, _ := c.GetInt64("admin_user_id")
  4686. start_time := c.GetString("start_time")
  4687. end_time := c.GetString("end_time")
  4688. adminUser := c.GetAdminUserInfo()
  4689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4690. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4691. var patients []*models.Patients
  4692. if record_type == 1 { //全部备案
  4693. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4694. patients = append(patients, patient...)
  4695. } else { //单个备案
  4696. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4697. patients = append(patients, patient)
  4698. }
  4699. var user_name string
  4700. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4701. if role.ID == 0 {
  4702. user_name = "xxx"
  4703. } else {
  4704. user_name = role.UserName
  4705. }
  4706. if config.IsOpen == 1 {
  4707. for _, item := range patients {
  4708. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4709. resp, requestErr := http.Get(api)
  4710. if requestErr != nil {
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. return
  4713. }
  4714. defer resp.Body.Close()
  4715. body, ioErr := ioutil.ReadAll(resp.Body)
  4716. if ioErr != nil {
  4717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. var respJSON map[string]interface{}
  4722. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4725. return
  4726. }
  4727. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4728. userJSONBytes, _ := json.Marshal(userJSON)
  4729. var res ResultTwo
  4730. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4731. utils.ErrorLog("解析失败:%v", err)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. if res.Infcode == 0 {
  4736. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4737. var dat map[string]interface{}
  4738. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4739. fmt.Println(dat)
  4740. } else {
  4741. fmt.Println(err)
  4742. }
  4743. userJSONBytes, _ := json.Marshal(dat)
  4744. var res2 ResultThirteen
  4745. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4746. utils.ErrorLog("解析失败:%v", err)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. if res2.Infcode == 0 {
  4751. psnResult := &models.GdybPsnRecord{
  4752. UserOrgId: adminUser.CurrentOrgId,
  4753. PatientId: item.ID,
  4754. PsnNo: res.Output.Baseinfo.PsnNo,
  4755. Ctime: time.Now().Unix(),
  4756. Mtime: time.Now().Unix(),
  4757. Status: 1,
  4758. IsCancel: 1,
  4759. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4760. }
  4761. service.CreatePsnRecord(psnResult)
  4762. } else {
  4763. c.ServeSuccessJSON(map[string]interface{}{
  4764. "failed_code": -10,
  4765. "msg": res2.ErrMsg,
  4766. })
  4767. return
  4768. }
  4769. }
  4770. }
  4771. }
  4772. }
  4773. func (c *HisApiController) PsnUnPutOnRecord() {
  4774. id, _ := c.GetInt64("id")
  4775. //record_type, _ := c.GetInt64("type")
  4776. admin_user_id, _ := c.GetInt64("admin_user_id")
  4777. adminUser := c.GetAdminUserInfo()
  4778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4779. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4780. var user_name string
  4781. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4782. if role.ID == 0 {
  4783. user_name = "xxx"
  4784. } else {
  4785. user_name = role.UserName
  4786. }
  4787. psn_record, _ := service.GetPsnRecordById(id)
  4788. if psn_record.ID == 0 {
  4789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4790. return
  4791. }
  4792. if config.IsOpen == 1 {
  4793. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4794. var dat map[string]interface{}
  4795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4796. fmt.Println(dat)
  4797. } else {
  4798. fmt.Println(err)
  4799. }
  4800. userJSONBytes, _ := json.Marshal(dat)
  4801. var res ResultFourteen
  4802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4803. utils.ErrorLog("解析失败:%v", err)
  4804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. return
  4806. }
  4807. if res.Infcode == 0 {
  4808. psn_record.IsCancel = 2
  4809. service.CreatePsnRecord(&psn_record)
  4810. } else {
  4811. c.ServeSuccessJSON(map[string]interface{}{
  4812. "failed_code": -10,
  4813. "msg": res.ErrMsg,
  4814. })
  4815. return
  4816. }
  4817. }
  4818. }
  4819. func (c *HisApiController) PsnPutNCDSOnRecord() {
  4820. patient_id, _ := c.GetInt64("patient_id")
  4821. insutype := c.GetString("insutype")
  4822. psn_no := c.GetString("psn_no")
  4823. doctor_id, _ := c.GetInt64("doctor_id")
  4824. sick_id, _ := c.GetInt64("sick_id")
  4825. department_id, _ := c.GetInt64("department_id")
  4826. adminUser := c.GetAdminUserInfo()
  4827. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4829. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4830. sick, _ := service.FindSickById(sick_id)
  4831. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  4832. if config.IsOpen == 1 {
  4833. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.CountryCode)
  4834. var dat map[string]interface{}
  4835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4836. fmt.Println(dat)
  4837. } else {
  4838. fmt.Println(err)
  4839. }
  4840. userJSONBytes, _ := json.Marshal(dat)
  4841. var res2 ResultThirteen
  4842. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4843. utils.ErrorLog("解析失败:%v", err)
  4844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4845. return
  4846. }
  4847. if res2.Infcode == 0 {
  4848. psnResult := &models.GdybPsnNcdsRecord{
  4849. UserOrgId: adminUser.CurrentOrgId,
  4850. PatientId: patient.ID,
  4851. PsnNo: psn_no,
  4852. DoctorId: doctor.AdminUserId,
  4853. DepartmentId: department_id,
  4854. SickType: sick_id,
  4855. Insutype: insutype,
  4856. Ctime: time.Now().Unix(),
  4857. Mtime: time.Now().Unix(),
  4858. Status: 1,
  4859. IsCancel: 1,
  4860. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4861. }
  4862. service.CreatePsnNCDSRecord(psnResult)
  4863. c.ServeSuccessJSON(map[string]interface{}{
  4864. "failed_code": 0,
  4865. "msg": "备案成功",
  4866. "result": psnResult,
  4867. })
  4868. } else {
  4869. c.ServeSuccessJSON(map[string]interface{}{
  4870. "failed_code": -10,
  4871. "msg": res2.ErrMsg,
  4872. })
  4873. return
  4874. }
  4875. }
  4876. }
  4877. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  4878. id, _ := c.GetInt64("id")
  4879. admin_user_id, _ := c.GetInt64("admin_user_id")
  4880. adminUser := c.GetAdminUserInfo()
  4881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4882. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4883. var user_name string
  4884. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4885. if role.ID == 0 {
  4886. user_name = "xxx"
  4887. } else {
  4888. user_name = role.UserName
  4889. }
  4890. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4891. if psn_record.ID == 0 {
  4892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4893. return
  4894. }
  4895. if config.IsOpen == 1 {
  4896. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4897. var dat map[string]interface{}
  4898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4899. fmt.Println(dat)
  4900. } else {
  4901. fmt.Println(err)
  4902. }
  4903. userJSONBytes, _ := json.Marshal(dat)
  4904. var res ResultFourteen
  4905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4906. utils.ErrorLog("解析失败:%v", err)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return
  4909. }
  4910. if res.Infcode == 0 {
  4911. psn_record.IsCancel = 2
  4912. service.CreatePsnNCDSRecord(&psn_record)
  4913. c.ServeSuccessJSON(map[string]interface{}{
  4914. "failed_code": 0,
  4915. "msg": "撤销备案成功",
  4916. })
  4917. } else {
  4918. c.ServeSuccessJSON(map[string]interface{}{
  4919. "failed_code": -10,
  4920. "msg": res.ErrMsg,
  4921. })
  4922. return
  4923. }
  4924. }
  4925. }
  4926. func (c *HisApiController) TestTest() {
  4927. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  4928. fmt.Println(patient.Iinfo)
  4929. }
  4930. type CustomData struct {
  4931. MsgId string
  4932. PsnNo string
  4933. Info string
  4934. }
  4935. func (c *HisApiController) ReversalData() {
  4936. var customData []*CustomData
  4937. custom := &CustomData{
  4938. MsgId: "H44022900158202103301714472004",
  4939. PsnNo: "44020000001101329945",
  4940. Info: "2207",
  4941. }
  4942. customData = append(customData, custom)
  4943. custom1 := &CustomData{
  4944. MsgId: "H4402290015820210330172057803",
  4945. PsnNo: "44020000001101161813",
  4946. Info: "2207",
  4947. }
  4948. customData = append(customData, custom1)
  4949. custom2 := &CustomData{
  4950. MsgId: "H44022900158202103301705198813",
  4951. PsnNo: "44190000133097375417",
  4952. Info: "2207",
  4953. }
  4954. customData = append(customData, custom2)
  4955. custom3 := &CustomData{
  4956. MsgId: "H44022900158202103301715524756",
  4957. PsnNo: "44020000001100187221",
  4958. Info: "2207",
  4959. }
  4960. customData = append(customData, custom3)
  4961. custom4 := &CustomData{
  4962. MsgId: "H44022900158202103301730376224",
  4963. PsnNo: "44020000001101959155",
  4964. Info: "2207",
  4965. }
  4966. customData = append(customData, custom4)
  4967. custom5 := &CustomData{
  4968. MsgId: "H44022900158202103301748008725",
  4969. PsnNo: "44020000001104246641",
  4970. Info: "2207",
  4971. }
  4972. customData = append(customData, custom5)
  4973. custom6 := &CustomData{
  4974. MsgId: "H44022900158202103301718096755",
  4975. PsnNo: "44020000001102211860",
  4976. Info: "2207",
  4977. }
  4978. customData = append(customData, custom6)
  4979. custom7 := &CustomData{
  4980. MsgId: "H44022900158202103301736551640",
  4981. PsnNo: "44020000001102687718",
  4982. Info: "2207",
  4983. }
  4984. customData = append(customData, custom7)
  4985. custom8 := &CustomData{
  4986. MsgId: "H44022900158202103301743097676",
  4987. PsnNo: "44020000001102127785",
  4988. Info: "2207",
  4989. }
  4990. customData = append(customData, custom8)
  4991. custom9 := &CustomData{
  4992. MsgId: "H44022900158202103301712304203",
  4993. PsnNo: "44020000001101518097",
  4994. Info: "2207",
  4995. }
  4996. customData = append(customData, custom9)
  4997. custom10 := &CustomData{
  4998. MsgId: "H44022900158202103301738448785",
  4999. PsnNo: "44020000001100500813",
  5000. Info: "2207",
  5001. }
  5002. customData = append(customData, custom10)
  5003. custom11 := &CustomData{
  5004. MsgId: "H44022900158202103301732455843",
  5005. PsnNo: "44020000001102690557",
  5006. Info: "2207",
  5007. }
  5008. customData = append(customData, custom11)
  5009. custom12 := &CustomData{
  5010. MsgId: "H44022900158202103301745421708",
  5011. PsnNo: "44020000001102211928",
  5012. Info: "2207",
  5013. }
  5014. customData = append(customData, custom12)
  5015. custom1212 := &CustomData{
  5016. MsgId: "H440229001582021033017351627",
  5017. PsnNo: "44020000001102481733",
  5018. Info: "2207",
  5019. }
  5020. customData = append(customData, custom1212)
  5021. custom13 := &CustomData{
  5022. MsgId: "H44022900158202103301740327951",
  5023. PsnNo: "44020000001103174866",
  5024. Info: "2207",
  5025. }
  5026. customData = append(customData, custom13)
  5027. custom14 := &CustomData{
  5028. MsgId: "H4402290015820210330174922668",
  5029. PsnNo: "44020000001102927272",
  5030. Info: "2207",
  5031. }
  5032. customData = append(customData, custom14)
  5033. custom15 := &CustomData{
  5034. MsgId: "H44022900158202103301752362273",
  5035. PsnNo: "44020000001102942890",
  5036. Info: "2207",
  5037. }
  5038. customData = append(customData, custom15)
  5039. custom16 := &CustomData{
  5040. MsgId: "H44022900158202103301751082917",
  5041. PsnNo: "44020000001101662162",
  5042. Info: "2207",
  5043. }
  5044. customData = append(customData, custom16)
  5045. custom17 := &CustomData{
  5046. MsgId: "H44022900158202103301754147728",
  5047. PsnNo: "44020000000229014511",
  5048. Info: "2207",
  5049. }
  5050. customData = append(customData, custom17)
  5051. adminUser := c.GetAdminUserInfo()
  5052. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5053. for _, item := range customData {
  5054. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5055. fmt.Println(result)
  5056. }
  5057. }
  5058. func (c *HisApiController) ReversalOtherData() {
  5059. var customData []*CustomData
  5060. custom := &CustomData{
  5061. MsgId: "H44022900158202103301714472004",
  5062. PsnNo: "44020000001101329945",
  5063. Info: "2208",
  5064. }
  5065. customData = append(customData, custom)
  5066. custom1 := &CustomData{
  5067. MsgId: "H4402290015820210330172057803",
  5068. PsnNo: "44020000001101161813",
  5069. Info: "2208",
  5070. }
  5071. customData = append(customData, custom1)
  5072. custom2 := &CustomData{
  5073. MsgId: "H44022900158202103301705198813",
  5074. PsnNo: "44190000133097375417",
  5075. Info: "2208",
  5076. }
  5077. customData = append(customData, custom2)
  5078. custom3 := &CustomData{
  5079. MsgId: "H44022900158202103301715524756",
  5080. PsnNo: "44020000001100187221",
  5081. Info: "2208",
  5082. }
  5083. customData = append(customData, custom3)
  5084. custom4 := &CustomData{
  5085. MsgId: "H44022900158202103301730376224",
  5086. PsnNo: "44020000001101959155",
  5087. Info: "2208",
  5088. }
  5089. customData = append(customData, custom4)
  5090. custom5 := &CustomData{
  5091. MsgId: "H44022900158202103301748008725",
  5092. PsnNo: "44020000001104246641",
  5093. Info: "2208",
  5094. }
  5095. customData = append(customData, custom5)
  5096. custom6 := &CustomData{
  5097. MsgId: "H44022900158202103301718096755",
  5098. PsnNo: "44020000001102211860",
  5099. Info: "2208",
  5100. }
  5101. customData = append(customData, custom6)
  5102. custom7 := &CustomData{
  5103. MsgId: "H44022900158202103301736551640",
  5104. PsnNo: "44020000001102687718",
  5105. Info: "2208",
  5106. }
  5107. customData = append(customData, custom7)
  5108. custom8 := &CustomData{
  5109. MsgId: "H44022900158202103301743097676",
  5110. PsnNo: "44020000001102127785",
  5111. Info: "2208",
  5112. }
  5113. customData = append(customData, custom8)
  5114. custom9 := &CustomData{
  5115. MsgId: "H44022900158202103301712304203",
  5116. PsnNo: "44020000001101518097",
  5117. Info: "2208",
  5118. }
  5119. customData = append(customData, custom9)
  5120. custom10 := &CustomData{
  5121. MsgId: "H44022900158202103301738448785",
  5122. PsnNo: "44020000001100500813",
  5123. Info: "2208",
  5124. }
  5125. customData = append(customData, custom10)
  5126. custom11 := &CustomData{
  5127. MsgId: "H44022900158202103301732455843",
  5128. PsnNo: "44020000001102690557",
  5129. Info: "2208",
  5130. }
  5131. customData = append(customData, custom11)
  5132. custom12 := &CustomData{
  5133. MsgId: "H44022900158202103301745421708",
  5134. PsnNo: "44020000001102211928",
  5135. Info: "2208",
  5136. }
  5137. customData = append(customData, custom12)
  5138. custom1212 := &CustomData{
  5139. MsgId: "H440229001582021033017351627",
  5140. PsnNo: "44020000001102481733",
  5141. Info: "2208",
  5142. }
  5143. customData = append(customData, custom1212)
  5144. custom13 := &CustomData{
  5145. MsgId: "H44022900158202103301740327951",
  5146. PsnNo: "44020000001103174866",
  5147. Info: "2208",
  5148. }
  5149. customData = append(customData, custom13)
  5150. custom14 := &CustomData{
  5151. MsgId: "H4402290015820210330174922668",
  5152. PsnNo: "44020000001102927272",
  5153. Info: "2208",
  5154. }
  5155. customData = append(customData, custom14)
  5156. custom15 := &CustomData{
  5157. MsgId: "H44022900158202103301752362273",
  5158. PsnNo: "44020000001102942890",
  5159. Info: "2208",
  5160. }
  5161. customData = append(customData, custom15)
  5162. custom16 := &CustomData{
  5163. MsgId: "H44022900158202103301751082917",
  5164. PsnNo: "44020000001101662162",
  5165. Info: "2208",
  5166. }
  5167. customData = append(customData, custom16)
  5168. custom17 := &CustomData{
  5169. MsgId: "H44022900158202103301754147728",
  5170. PsnNo: "44020000000229014511",
  5171. Info: "2208",
  5172. }
  5173. customData = append(customData, custom17)
  5174. adminUser := c.GetAdminUserInfo()
  5175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5176. for _, item := range customData {
  5177. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5178. fmt.Println(result)
  5179. }
  5180. }
  5181. func PathExists(path string) (bool, error) {
  5182. _, err := os.Stat(path)
  5183. if err == nil {
  5184. return true, nil
  5185. }
  5186. if os.IsNotExist(err) {
  5187. return false, nil
  5188. }
  5189. return false, err
  5190. }
  5191. //创建文件夹
  5192. func Mkdir(dir string) {
  5193. // 创建文件夹
  5194. exist, err := PathExists(dir)
  5195. if err != nil {
  5196. fmt.Println(err.Error())
  5197. } else {
  5198. if exist {
  5199. fmt.Println(dir + "文件夹已存在!")
  5200. } else {
  5201. // 文件夹名称,权限
  5202. err := os.Mkdir(dir, os.ModePerm)
  5203. if err != nil {
  5204. fmt.Println(dir+"文件夹创建失败:", err.Error())
  5205. } else {
  5206. fmt.Println(dir + "文件夹创建成功!")
  5207. }
  5208. }
  5209. }
  5210. }
  5211. //压缩文件
  5212. func Zip(srcFile string, destZip string) error {
  5213. zipfile, err := os.Create(destZip)
  5214. if err != nil {
  5215. return err
  5216. }
  5217. defer zipfile.Close()
  5218. archive := zip.NewWriter(zipfile)
  5219. defer archive.Close()
  5220. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  5221. if err != nil {
  5222. return err
  5223. }
  5224. header, err := zip.FileInfoHeader(info)
  5225. if err != nil {
  5226. return err
  5227. }
  5228. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  5229. // header.Name = path
  5230. if info.IsDir() {
  5231. header.Name += "/"
  5232. } else {
  5233. header.Method = zip.Deflate
  5234. }
  5235. writer, err := archive.CreateHeader(header)
  5236. if err != nil {
  5237. return err
  5238. }
  5239. if !info.IsDir() {
  5240. file, err := os.Open(path)
  5241. if err != nil {
  5242. return err
  5243. }
  5244. defer file.Close()
  5245. _, err = io.Copy(writer, file)
  5246. }
  5247. return err
  5248. })
  5249. return err
  5250. }
  5251. func ReadFile(filePath string) []byte {
  5252. f, err := os.Open(filePath)
  5253. if err != nil {
  5254. fmt.Println("read file fail", err)
  5255. return nil
  5256. }
  5257. defer f.Close()
  5258. fd, err := ioutil.ReadAll(f)
  5259. if err != nil {
  5260. fmt.Println("read to fd fail", err)
  5261. return nil
  5262. }
  5263. return fd
  5264. }
  5265. func RemoveRepeatedCode(arr []string) (newArr []string) {
  5266. newArr = make([]string, 0)
  5267. for i := 0; i < len(arr); i++ {
  5268. repeat := false
  5269. for j := i + 1; j < len(arr); j++ {
  5270. if arr[i] == arr[j] {
  5271. repeat = true
  5272. break
  5273. }
  5274. }
  5275. if !repeat {
  5276. newArr = append(newArr, arr[i])
  5277. }
  5278. }
  5279. return
  5280. }