his_api_controller.go 203KB

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