his_api_controller.go 187KB

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