his_api_controller.go 206KB

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