his_api_controller.go 182KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242
  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/shopspring/decimal"
  14. "io"
  15. "io/ioutil"
  16. "math/rand"
  17. "net/http"
  18. "os"
  19. "path/filepath"
  20. "strconv"
  21. "strings"
  22. "syscall"
  23. "time"
  24. "unsafe"
  25. )
  26. type HisApiController struct {
  27. controllers.BaseAuthAPIController
  28. }
  29. func HisManagerApiRegistRouters() {
  30. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  31. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  32. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  33. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  34. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  35. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  36. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  37. beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  38. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  39. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  40. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  41. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  42. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  43. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  44. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  45. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  46. beego.Router("/api/pre_upload/get", &HisApiController{}, "get:GetPreUploadInfo")
  47. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  48. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  49. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  50. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  51. //备案撤销相关接口
  52. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  53. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  54. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  55. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  56. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  57. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  58. beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  59. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  60. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  61. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  62. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  63. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. }
  65. type CustomFundPay struct {
  66. FundPayType string `json:"fund_pay_type"`
  67. FundPayamt float64 `json:"fund_payamt"`
  68. }
  69. func (c *HisApiController) GetSettleList() {
  70. order_id, _ := c.GetInt64("order_id")
  71. admin_user_id, _ := c.GetInt64("admin_user_id")
  72. order, _ := service.GetHisOrderByIDTwo(order_id)
  73. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  74. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  75. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  76. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  77. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  78. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  79. if order.ID == 0 {
  80. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  81. return
  82. }
  83. struct4101 := service.Struct4101{
  84. PsnNo: order.PsnNo,
  85. MdtrtId: order.MdtrtId,
  86. SetlId: order.SetlId,
  87. PsnName: order.PsnName,
  88. Gend: order.Gend,
  89. Brdy: his.Brdy,
  90. Age: his.Age,
  91. Naty: order.Naty,
  92. PatnCertType: "01",
  93. Certno: order.Certno,
  94. Prfs: "90",
  95. ConerName: roles[0].UserName,
  96. PatnRlts: "99",
  97. ConerAddr: miConfig.OrgName,
  98. ConerTel: admin.Mobile,
  99. HiType: order.Insutype,
  100. Insuplc: miConfig.InsuplcAdmdvs,
  101. MaindiagFlag: "1",
  102. BillCode: order.FaPiaoCode,
  103. BillNo: order.FaPiaoNumber,
  104. BizSn: order.Number,
  105. PsnSelfPay: order.PsnPartAmt,
  106. PsnOwnPay: order.PsnPartAmt,
  107. AcctPay: order.AcctPay,
  108. PsnCashpay: order.PsnCashPay,
  109. HiPaymtd: "1",
  110. Hsorg: miConfig.InsuplcAdmdvs,
  111. HsorgOpter: miConfig.InsuplcAdmdvs,
  112. MedinsFillPsn: curRoles.UserName,
  113. MedinsFillDept: depart.Name,
  114. IptMedType: "2",
  115. }
  116. if order.SettleType == 1 {
  117. t := time.Unix(int64(order.SettleAccountsDate), 0)
  118. dateStr := t.Format("2006-01-02")
  119. struct4101.SetlBegnDate = dateStr
  120. struct4101.SetlEndDate = dateStr
  121. } else {
  122. t := time.Unix(int64(order.SettleStartTime), 0)
  123. t2 := time.Unix(int64(order.SettleEndTime), 0)
  124. dateStartStr := t.Format("2006-01-02")
  125. dateEndStr := t2.Format("2006-01-02")
  126. struct4101.SetlBegnDate = dateStartStr
  127. struct4101.SetlEndDate = dateEndStr
  128. }
  129. var rf []CustomFundPay
  130. json.Unmarshal([]byte(order.SetlDetail), &rf)
  131. var tempFunPays []service.CustomStruct
  132. for _, item := range rf {
  133. var tempFunPay service.CustomStruct
  134. tempFunPay.FundPayamt = item.FundPayamt
  135. tempFunPay.FundPayType = item.FundPayType
  136. tempFunPays = append(tempFunPays, tempFunPay)
  137. }
  138. struct4101.CustomStruct = tempFunPays
  139. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  140. var tempOpspdiseinfo service.OpspdiseinfoStruct
  141. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  142. sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  143. sickConfigTwo, _ := service.FindSickById(his.SickType)
  144. tempOpspdiseinfo.DiagCode = sickConfig.CountryCode
  145. tempOpspdiseinfo.DiagName = sickConfig.CountryContentName
  146. tempOpspdiseinfo.MaindiagFlag = "1"
  147. tempOpspdiseinfo.OprnOprtCode = ""
  148. tempOpspdiseinfo.OprnOprtName = ""
  149. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  150. tempOpspdiseinfo2.DiagCode = sickConfigTwo.CountryCode
  151. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  152. tempOpspdiseinfo2.MaindiagFlag = "2"
  153. tempOpspdiseinfo2.OprnOprtCode = ""
  154. tempOpspdiseinfo2.OprnOprtName = ""
  155. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  156. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  157. var iteminfo service.IteminfoStruct
  158. var bedCostTotal float64 = 0 //床位总费
  159. var bedCostSelfTotal float64 = 0 //床位自费
  160. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  161. var operationCostTotal float64 = 0 //手术费
  162. var operationCostSelfTotal float64 = 0 //手术费
  163. var operationCostPartSelfTotal float64 = 0 //手术费
  164. var otherCostTotal float64 = 0 //其他费用
  165. var otherCostSelfTotal float64 = 0 //其他费用
  166. var otherCostPartSelfTotal float64 = 0 //其他费用
  167. var materialCostTotal float64 = 0 //材料费
  168. var materialCostSelfTotal float64 = 0 //材料费
  169. var materialCostPartSelfTotal float64 = 0 //材料费
  170. var westernMedicineCostTotal float64 = 0 //西药费
  171. var westernMedicineCostSelfTotal float64 = 0 //西药费
  172. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  173. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  174. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  175. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  176. var checkCostTotal float64 = 0 //检查费
  177. var checkCostSelfTotal float64 = 0 //检查费
  178. var checkCostPartSelfTotal float64 = 0 //检查费
  179. var laboratoryCostTotal float64 = 0 //化验费
  180. var laboratoryCostSelfTotal float64 = 0 //化验费
  181. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  182. var treatCostTotal float64 = 0 //治疗费用
  183. var treatCostSelfTotal float64 = 0 //治疗费用
  184. var treatCostPartSelfTotal float64 = 0 //治疗费用
  185. decimal.DivisionPrecision = 2
  186. var bed_fulamt_ownpay_amt float64 = 0
  187. var operation_fulamt_ownpay_amt float64 = 0
  188. var other_fulamt_ownpay_amt float64 = 0
  189. var westernMedicine_fulamt_ownpay_amt float64 = 0
  190. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  191. var check_fulamt_ownpay_amt float64 = 0
  192. var material_fulamt_ownpay_amt float64 = 0
  193. var laboratory_fulamt_ownpay_amt float64 = 0
  194. var treat_fulamt_ownpay_amt float64 = 0
  195. var bed_claa_sunmfee float64 = 0
  196. var bed_clab_amt float64 = 0
  197. var bed_other_amt float64 = 0
  198. var operation_claa_sunmfee float64 = 0
  199. var operation_clab_amt float64 = 0
  200. var operation_other_amt float64 = 0
  201. var other_claa_sunmfee float64 = 0
  202. var other_clab_amt float64 = 0
  203. var other_other_amt float64 = 0
  204. var westernMedicine_claa_sunmfee float64 = 0
  205. var westernMedicine_clab_amt float64 = 0
  206. var westernMedicine_other_amt float64 = 0
  207. var chineseTraditional_claa_sunmfee float64 = 0
  208. var chineseTraditional_clab_amt float64 = 0
  209. var chineseTraditional_other_amt float64 = 0
  210. var check_claa_sunmfee float64 = 0
  211. var check_clab_amt float64 = 0
  212. var check_other_amt float64 = 0
  213. var material_claa_sunmfee float64 = 0
  214. var material_clab_amt float64 = 0
  215. var material_other_amt float64 = 0
  216. var laboratory_claa_sunmfee float64 = 0
  217. var laboratory_clab_amt float64 = 0
  218. var laboratory_other_amt float64 = 0
  219. var treat_claa_sunmfee float64 = 0
  220. var treat_clab_amt float64 = 0
  221. var treat_other_amt float64 = 0
  222. for _, item := range order.HisOrderInfo {
  223. if item.MedChrgitmType == "01" { //床位费
  224. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  225. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  226. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  227. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  228. if item.ChrgitmLv == "1" {
  229. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  230. }
  231. if item.ChrgitmLv == "2" {
  232. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  233. }
  234. if item.ChrgitmLv == "3" {
  235. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  236. }
  237. }
  238. if item.MedChrgitmType == "03" { //检查费
  239. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  240. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  241. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  242. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  243. if item.ChrgitmLv == "1" {
  244. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  245. }
  246. if item.ChrgitmLv == "2" {
  247. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  248. }
  249. if item.ChrgitmLv == "3" {
  250. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  251. }
  252. }
  253. if item.MedChrgitmType == "04" { //化验费
  254. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  255. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  256. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  257. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  258. if item.ChrgitmLv == "1" {
  259. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  260. }
  261. if item.ChrgitmLv == "2" {
  262. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  263. }
  264. if item.ChrgitmLv == "3" {
  265. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  266. }
  267. }
  268. if item.MedChrgitmType == "05" { //治疗费
  269. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  270. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  271. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  272. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  273. if item.ChrgitmLv == "1" {
  274. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  275. }
  276. if item.ChrgitmLv == "2" {
  277. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  278. }
  279. if item.ChrgitmLv == "3" {
  280. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  281. }
  282. }
  283. if item.MedChrgitmType == "06" { //手术费
  284. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  285. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  286. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  287. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  288. if item.ChrgitmLv == "1" {
  289. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  290. }
  291. if item.ChrgitmLv == "2" {
  292. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  293. }
  294. if item.ChrgitmLv == "3" {
  295. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  296. }
  297. }
  298. if item.MedChrgitmType == "08" { //材料费
  299. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  300. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  301. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  302. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  303. if item.ChrgitmLv == "1" {
  304. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  305. }
  306. if item.ChrgitmLv == "2" {
  307. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  308. }
  309. if item.ChrgitmLv == "3" {
  310. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  311. }
  312. }
  313. if item.MedChrgitmType == "09" { //西药费
  314. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  315. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  316. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  317. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  318. if item.ChrgitmLv == "1" {
  319. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  320. }
  321. if item.ChrgitmLv == "2" {
  322. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  323. }
  324. if item.ChrgitmLv == "3" {
  325. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  326. }
  327. }
  328. if item.MedChrgitmType == "11" { //中成费
  329. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  330. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  331. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  332. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  333. if item.ChrgitmLv == "1" {
  334. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  335. }
  336. if item.ChrgitmLv == "2" {
  337. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  338. }
  339. if item.ChrgitmLv == "3" {
  340. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  341. }
  342. }
  343. if item.MedChrgitmType == "14" { //其他费
  344. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  345. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  346. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  347. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  348. if item.ChrgitmLv == "1" {
  349. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  350. }
  351. if item.ChrgitmLv == "2" {
  352. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  353. }
  354. if item.ChrgitmLv == "3" {
  355. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  356. }
  357. }
  358. }
  359. var iteminfoStructs []service.IteminfoStruct
  360. if bedCostTotal != 0 {
  361. iteminfo.MedChrgitm = "01"
  362. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  363. iteminfo.Amt = bedCostTotal
  364. iteminfo.ClaaSumfee = bed_claa_sunmfee
  365. iteminfo.ClabAmt = bed_clab_amt
  366. iteminfo.OthAmt = bed_other_amt
  367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  368. }
  369. if checkCostTotal != 0 {
  370. iteminfo.MedChrgitm = "03"
  371. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  372. iteminfo.Amt = checkCostTotal
  373. iteminfo.ClaaSumfee = check_claa_sunmfee
  374. iteminfo.ClabAmt = check_clab_amt
  375. iteminfo.OthAmt = check_other_amt
  376. iteminfoStructs = append(iteminfoStructs, iteminfo)
  377. }
  378. if laboratoryCostTotal != 0 {
  379. iteminfo.MedChrgitm = "04"
  380. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  381. iteminfo.Amt = laboratoryCostTotal
  382. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  383. iteminfo.ClabAmt = laboratory_clab_amt
  384. iteminfo.OthAmt = laboratory_other_amt
  385. iteminfoStructs = append(iteminfoStructs, iteminfo)
  386. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  387. }
  388. if treatCostTotal != 0 {
  389. iteminfo.MedChrgitm = "05"
  390. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  391. iteminfo.Amt = treatCostTotal
  392. iteminfo.ClaaSumfee = treat_claa_sunmfee
  393. iteminfo.ClabAmt = treat_clab_amt
  394. iteminfo.OthAmt = treat_other_amt
  395. iteminfoStructs = append(iteminfoStructs, iteminfo)
  396. // (struct4101.IteminfoStruct, iteminfo)
  397. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  398. }
  399. if operationCostTotal != 0 {
  400. iteminfo.MedChrgitm = "06"
  401. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  402. iteminfo.Amt = operationCostTotal
  403. iteminfo.ClaaSumfee = operation_claa_sunmfee
  404. iteminfo.ClabAmt = operation_clab_amt
  405. iteminfo.OthAmt = operation_other_amt
  406. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  407. iteminfoStructs = append(iteminfoStructs, iteminfo)
  408. }
  409. if materialCostTotal != 0 {
  410. iteminfo.MedChrgitm = "08"
  411. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  412. iteminfo.Amt = materialCostTotal
  413. iteminfo.ClaaSumfee = material_claa_sunmfee
  414. iteminfo.ClabAmt = material_clab_amt
  415. iteminfo.OthAmt = material_other_amt
  416. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  417. iteminfoStructs = append(iteminfoStructs, iteminfo)
  418. }
  419. if westernMedicineCostTotal != 0 {
  420. iteminfo.MedChrgitm = "09"
  421. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  422. iteminfo.Amt = westernMedicineCostTotal
  423. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  424. iteminfo.ClabAmt = westernMedicine_clab_amt
  425. iteminfo.OthAmt = westernMedicine_other_amt
  426. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  427. iteminfoStructs = append(iteminfoStructs, iteminfo)
  428. }
  429. if chineseTraditionalMedicineCostTotal != 0 {
  430. iteminfo.MedChrgitm = "11"
  431. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  432. iteminfo.Amt = westernMedicineCostTotal
  433. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  434. iteminfo.ClabAmt = westernMedicine_clab_amt
  435. iteminfo.OthAmt = westernMedicine_other_amt
  436. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  437. iteminfoStructs = append(iteminfoStructs, iteminfo)
  438. }
  439. if otherCostTotal != 0 {
  440. iteminfo.MedChrgitm = "14"
  441. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  442. iteminfo.Amt = otherCostTotal
  443. iteminfo.ClaaSumfee = other_claa_sunmfee
  444. iteminfo.ClabAmt = other_clab_amt
  445. iteminfo.OthAmt = other_other_amt
  446. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  447. iteminfoStructs = append(iteminfoStructs, iteminfo)
  448. }
  449. struct4101.IteminfoStruct = iteminfoStructs
  450. struct4101.Ntly = "中国"
  451. struct4101.AdmCaty = "A03.06"
  452. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  453. fmt.Println(result)
  454. var dat map[string]interface{}
  455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  456. fmt.Println(dat)
  457. } else {
  458. fmt.Println(err)
  459. }
  460. userJSONBytes, _ := json.Marshal(dat)
  461. var res ResultSeventeen
  462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  463. utils.ErrorLog("解析失败:%v", err)
  464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  465. return
  466. }
  467. if res.Infcode != 0 {
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "failed_code": -10,
  470. "msg": res.ErrMsg,
  471. })
  472. return
  473. } else {
  474. hisFundSettleListResult := &models.HisFundSettleListResult{
  475. Number: res.Output.SetlListId,
  476. Status: 1,
  477. Ctime: time.Now().Unix(),
  478. Mtime: time.Now().Unix(),
  479. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  480. IsUpload: 1,
  481. OrderId: order_id,
  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. SetlListId string `json:"setl_list_id"`
  1415. } `json:"output"`
  1416. RefmsgTime string `json:"refmsg_time"`
  1417. RespondTime string `json:"respond_time"`
  1418. Signtype string `json:"signtype"`
  1419. WarnInfo string `json:"warn_info"`
  1420. }
  1421. type Custom struct {
  1422. DetItemFeeSumamt string
  1423. Cut string
  1424. FeedetlSn string
  1425. Price string
  1426. MedListCodg string
  1427. Type int64
  1428. AdviceId int64
  1429. ProjectId int64
  1430. ItemId int64
  1431. }
  1432. //获取个人信息----挂号-----上传就诊信息
  1433. func (c *HisApiController) GetRegisterInfo() {
  1434. id, _ := c.GetInt64("id")
  1435. record_time := c.GetString("record_time")
  1436. settlementValue, _ := c.GetInt64("settlement_value")
  1437. medical_insurance_card := c.GetString("medical_insurance_card")
  1438. name := c.GetString("name")
  1439. id_card_type, _ := c.GetInt64("id_card_type")
  1440. certificates, _ := c.GetInt64("certificates")
  1441. medical_care, _ := c.GetInt64("medical_care")
  1442. birthday := c.GetString("birthday")
  1443. //age, _ := c.GetInt64("age")
  1444. id_card := c.GetString("id_card")
  1445. register_type, _ := c.GetInt64("register")
  1446. doctor, _ := c.GetInt64("doctor")
  1447. department, _ := c.GetInt64("department")
  1448. gender, _ := c.GetInt64("sex")
  1449. //phone := c.GetString("phone")
  1450. registration_fee, _ := c.GetFloat("registration_fee")
  1451. medical_expenses, _ := c.GetFloat("medical_expenses")
  1452. social_type, _ := c.GetInt64("social_type")
  1453. admin_user_id, _ := c.GetInt64("admin_user_id")
  1454. diagnosis_id, _ := c.GetInt64("diagnosis")
  1455. sick_type, _ := c.GetInt64("sick_type")
  1456. reg_type, _ := c.GetInt64("p_type")
  1457. timeLayout := "2006-01-02"
  1458. loc, _ := time.LoadLocation("Local")
  1459. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1460. birthUnix := birthdays.Unix()
  1461. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1462. if err != nil {
  1463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1464. return
  1465. }
  1466. recordDateTime := theTime.Unix()
  1467. adminInfo := c.GetAdminUserInfo()
  1468. var patient service.Patients
  1469. if id == 0 {
  1470. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1471. } else {
  1472. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1473. }
  1474. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1475. if patientPrescription.ID == 0 {
  1476. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1477. }
  1478. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  1479. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  1480. sickConfig, _ := service.FindSickById(sick_type)
  1481. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1482. if patient.ID == 0 {
  1483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1484. return
  1485. }
  1486. if len(patient.IdCardNo) == 0 {
  1487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1488. return
  1489. }
  1490. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1491. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1492. //就诊结算未完成,不能进行二次挂号
  1493. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1494. if len(his) >= 1 {
  1495. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  1496. if len(his) >= 1 && order.ID == 0 {
  1497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  1498. return
  1499. }
  1500. }
  1501. if config.IsOpen == 1 {
  1502. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
  1503. resp, requestErr := http.Get(api)
  1504. if requestErr != nil {
  1505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1506. return
  1507. }
  1508. defer resp.Body.Close()
  1509. body, ioErr := ioutil.ReadAll(resp.Body)
  1510. if ioErr != nil {
  1511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1513. return
  1514. }
  1515. var respJSON map[string]interface{}
  1516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1519. return
  1520. }
  1521. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1522. userJSONBytes, _ := json.Marshal(userJSON)
  1523. var res ResultTwo
  1524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1525. utils.ErrorLog("解析失败:%v", err)
  1526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1527. return
  1528. }
  1529. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1530. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1531. infoStr := string(Iinfos)
  1532. idetinfoStr := string(Idetinfos)
  1533. if res.Infcode == 0 {
  1534. his := models.VMHisPatient{
  1535. Name: name,
  1536. Gender: gender,
  1537. Birthday: birthUnix,
  1538. MedicalTreatmentType: medical_care,
  1539. IdType: certificates,
  1540. IdCardNo: id_card,
  1541. BalanceAccountsType: settlementValue,
  1542. SocialType: social_type,
  1543. MedicalInsuranceNumber: medical_insurance_card,
  1544. RegisterType: register_type,
  1545. RegisterCost: registration_fee,
  1546. TreatmentCost: medical_expenses,
  1547. Status: 1,
  1548. Ctime: time.Now().Unix(),
  1549. Mtime: time.Now().Unix(),
  1550. PsnNo: res.Output.Baseinfo.PsnNo,
  1551. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1552. Certno: res.Output.Baseinfo.Certno,
  1553. PsnName: res.Output.Baseinfo.PsnName,
  1554. Gend: res.Output.Baseinfo.Gend,
  1555. Naty: res.Output.Baseinfo.Naty,
  1556. Brdy: res.Output.Baseinfo.Brdy,
  1557. Age: res.Output.Baseinfo.Age,
  1558. Iinfo: infoStr,
  1559. Idetinfo: idetinfoStr,
  1560. PatientId: patient.ID,
  1561. RecordDate: theTime.Unix(),
  1562. UserOrgId: adminInfo.CurrentOrgId,
  1563. AdminUserId: admin_user_id,
  1564. IsReturn: 1,
  1565. IdCardType: id_card_type,
  1566. Doctor: doctor,
  1567. Departments: department,
  1568. SickType: sick_type,
  1569. Diagnosis: diagnosis_id,
  1570. PType: reg_type,
  1571. }
  1572. timestamp := time.Now().Unix()
  1573. tempTime := time.Unix(timestamp, 0)
  1574. timeFormat := tempTime.Format("20060102150405")
  1575. chrgBchno := rand.Intn(100000) + 10000
  1576. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1577. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1578. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1579. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1580. IdCardNo := ""
  1581. if id_card_type == 1 {
  1582. IdCardNo = medical_insurance_card
  1583. } else {
  1584. IdCardNo = patient.IdCardNo
  1585. }
  1586. var insutypes []string
  1587. var insutype string
  1588. var is390 int = 0
  1589. var is310 int = 0
  1590. for _, item := range res.Output.Iinfo {
  1591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1592. insutypes = append(insutypes, item.Insutype)
  1593. }
  1594. }
  1595. if len(insutypes) == 1 {
  1596. insutype = insutypes[0]
  1597. } else {
  1598. for _, i := range insutypes {
  1599. if i == "390" {
  1600. is390 = 1
  1601. }
  1602. if i == "310" {
  1603. is310 = 1
  1604. }
  1605. }
  1606. }
  1607. if is390 == 1 {
  1608. insutype = "390"
  1609. }
  1610. if is310 == 1 {
  1611. insutype = "310"
  1612. }
  1613. if len(insutypes) == 0 {
  1614. insutype = "310"
  1615. }
  1616. insutype = "390"
  1617. //if count == 1 {
  1618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1619. // return
  1620. //}
  1621. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1622. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1623. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1624. "&dept=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  1625. resp, requestErr := http.Get(api)
  1626. if requestErr != nil {
  1627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1628. return
  1629. }
  1630. defer resp.Body.Close()
  1631. body, ioErr := ioutil.ReadAll(resp.Body)
  1632. if ioErr != nil {
  1633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1635. return
  1636. }
  1637. var respJSON map[string]interface{}
  1638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1641. return
  1642. }
  1643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1644. userJSONBytes, _ := json.Marshal(respJSON)
  1645. var res ResultThree
  1646. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1647. utils.ErrorLog("解析失败:%v", err)
  1648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1649. return
  1650. }
  1651. if res.Infcode != 0 {
  1652. adminUser := c.GetAdminUserInfo()
  1653. errlog := &models.HisOrderError{
  1654. UserOrgId: adminUser.CurrentOrgId,
  1655. Ctime: time.Now().Unix(),
  1656. Mtime: time.Now().Unix(),
  1657. ErrMsg: res.ErrMsg,
  1658. Status: 1,
  1659. PatientId: id,
  1660. RecordTime: recordDateTime,
  1661. Stage: 2,
  1662. }
  1663. service.CreateErrMsgLog(errlog)
  1664. c.ServeSuccessJSON(map[string]interface{}{
  1665. "failed_code": -10,
  1666. "msg": res.ErrMsg,
  1667. })
  1668. return
  1669. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1670. //return
  1671. }
  1672. his.Number = res.Output.Data.MdtrtID
  1673. his.PsnNo = res.Output.Data.PsnNo
  1674. his.IptOtpNo = res.Output.Data.IptOtpNo
  1675. his.IdCardNo = patient.IdCardNo
  1676. his.PhoneNumber = patient.Phone
  1677. his.UserOrgId = adminInfo.CurrentOrgId
  1678. his.Ctime = time.Now().Unix()
  1679. his.Mtime = time.Now().Unix()
  1680. his.Status = 0
  1681. service.CreateHisPatientTwo(&his)
  1682. if err == nil {
  1683. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  1684. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  1685. "&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 +
  1686. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName + "&dept=" + roles.UserName
  1687. resp2, requestErr2 := http.Get(api2)
  1688. if requestErr2 != nil {
  1689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1690. return
  1691. }
  1692. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1693. if ioErr2 != nil {
  1694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1696. return
  1697. }
  1698. var respJSON2 map[string]interface{}
  1699. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  1700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1702. return
  1703. }
  1704. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1705. userJSONBytes2, _ := json.Marshal(respJSON2)
  1706. var res2 ResultSix
  1707. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1708. utils.ErrorLog("解析失败:%v", err)
  1709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1710. return
  1711. }
  1712. if res2.Infcode != 0 {
  1713. adminUser := c.GetAdminUserInfo()
  1714. errlog := &models.HisOrderError{
  1715. UserOrgId: adminUser.CurrentOrgId,
  1716. Ctime: time.Now().Unix(),
  1717. Mtime: time.Now().Unix(),
  1718. ErrMsg: res2.ErrMsg,
  1719. Status: 1,
  1720. PatientId: id,
  1721. RecordTime: recordDateTime,
  1722. Stage: 3,
  1723. }
  1724. service.CreateErrMsgLog(errlog)
  1725. c.ServeSuccessJSON(map[string]interface{}{
  1726. "failed_code": -10,
  1727. "msg": res2.ErrMsg,
  1728. })
  1729. return
  1730. } else {
  1731. his.Status = 1
  1732. service.UpdateHisPatientStatus(&his)
  1733. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1734. if len(lists) == 1 {
  1735. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1736. }
  1737. c.ServeSuccessJSON(map[string]interface{}{
  1738. "his_info": his,
  1739. })
  1740. }
  1741. } else {
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1743. return
  1744. }
  1745. } else {
  1746. adminUser := c.GetAdminUserInfo()
  1747. errlog := &models.HisOrderError{
  1748. UserOrgId: adminUser.CurrentOrgId,
  1749. Ctime: time.Now().Unix(),
  1750. Mtime: time.Now().Unix(),
  1751. ErrMsg: res.ErrMsg,
  1752. Status: 1,
  1753. PatientId: id,
  1754. RecordTime: recordDateTime,
  1755. Stage: 1,
  1756. }
  1757. service.CreateErrMsgLog(errlog)
  1758. c.ServeSuccessJSON(map[string]interface{}{
  1759. "failed_code": -10,
  1760. "msg": res.ErrMsg,
  1761. })
  1762. return
  1763. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1764. }
  1765. }
  1766. }
  1767. //上传明细----预结算----确认订单
  1768. func (c *HisApiController) GetUploadInfo() {
  1769. id, _ := c.GetInt64("id")
  1770. record_time := c.GetString("record_time")
  1771. his_patient_id, _ := c.GetInt64("his_patient_id")
  1772. pay_way, _ := c.GetInt64("pay_way")
  1773. pay_price, _ := c.GetFloat("pay_price")
  1774. pay_card_no := c.GetString("pay_card_no")
  1775. discount_price, _ := c.GetFloat("discount_price")
  1776. preferential_price, _ := c.GetFloat("preferential_price")
  1777. reality_price, _ := c.GetFloat("reality_price")
  1778. found_price, _ := c.GetFloat("found_price")
  1779. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1780. private_price, _ := c.GetFloat("private_price")
  1781. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1782. admin_user_id, _ := c.GetInt64("admin_user_id")
  1783. fapiao_code := c.GetString("fapiao_code")
  1784. fapiao_number := c.GetString("fapiao_number")
  1785. timeLayout := "2006-01-02"
  1786. loc, _ := time.LoadLocation("Local")
  1787. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1788. if err != nil {
  1789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1790. return
  1791. }
  1792. recordDateTime := theTime.Unix()
  1793. adminUser := c.GetAdminUserInfo()
  1794. var prescriptions []*models.HisPrescription
  1795. var start_time int64
  1796. var end_time int64
  1797. //if adminUser.CurrentOrgId == 10106{
  1798. // if len(fapiao_code) == 0{
  1799. // fapiao_code = "144072080589"
  1800. // }
  1801. // if len(fapiao_number) == 0{
  1802. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1803. // if order.ID == 0{
  1804. // fapiao_number = "00001520"
  1805. // }else{
  1806. // //fapiao_code = "00001520"
  1807. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1808. // var zero string
  1809. // if fpNumber >= 1000{
  1810. // zero = "0000" + strconv.Itoa(fpNumber)
  1811. // }else if fpNumber >= 10000{
  1812. // zero = "000" + strconv.Itoa(fpNumber)
  1813. // } else if fpNumber >= 100000{
  1814. // zero = "00" + strconv.Itoa(fpNumber)
  1815. // } else if fpNumber >= 1000000{
  1816. // zero = "0" + strconv.Itoa(fpNumber)
  1817. // }else {
  1818. // zero = strconv.Itoa(fpNumber)
  1819. // }
  1820. // fapiao_number = zero
  1821. // }
  1822. // }
  1823. //}
  1824. data := make(map[string]interface{})
  1825. if settle_accounts_type == 1 { //日结
  1826. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1827. data["pre"] = prescriptions
  1828. } else { //月结
  1829. start_time_str := c.GetString("start_time")
  1830. end_time_str := c.GetString("end_time")
  1831. timeLayout := "2006-01-02"
  1832. loc, _ := time.LoadLocation("Local")
  1833. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1834. if err != nil {
  1835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1836. return
  1837. }
  1838. recordStartTime := theStartTime.Unix()
  1839. start_time = recordStartTime
  1840. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1841. if err != nil {
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1843. return
  1844. }
  1845. recordEndTime := theEndTime.Unix()
  1846. end_time = recordEndTime
  1847. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1848. data["pre"] = prescriptions
  1849. }
  1850. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1851. fmt.Println(his_patient_id)
  1852. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1853. timestamp := time.Now().Unix()
  1854. tempTime := time.Unix(timestamp, 0)
  1855. timeFormat := tempTime.Format("20060102150405")
  1856. chrgBchno := rand.Intn(100000) + 10000
  1857. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1858. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1859. patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1860. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1861. strconv.FormatInt(his.PatientId, 10)
  1862. client := &http.Client{}
  1863. data["psn_no"] = his.PsnNo
  1864. data["mdtrt_id"] = his.Number
  1865. data["chrg_bchno"] = chrg_bchno
  1866. data["org_name"] = miConfig.OrgName
  1867. data["doctor"] = roles.UserName
  1868. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1869. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1870. data["fixmedins_code"] = miConfig.Code
  1871. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1872. data["dept_code"] = "15"
  1873. } else {
  1874. data["dept_code"] = department.Number
  1875. }
  1876. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1877. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1878. data["secret_key"] = miConfig.SecretKey
  1879. var ids []int64
  1880. for _, item := range prescriptions {
  1881. ids = append(ids, item.ID)
  1882. }
  1883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1884. if config.IsOpen == 1 { //对接了医保,走医保流程
  1885. bytesData, _ := json.Marshal(data)
  1886. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1887. resp, _ := client.Do(req)
  1888. defer resp.Body.Close()
  1889. body, ioErr := ioutil.ReadAll(resp.Body)
  1890. if ioErr != nil {
  1891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1893. return
  1894. }
  1895. var respJSON map[string]interface{}
  1896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1899. return
  1900. }
  1901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1902. userJSONBytes, _ := json.Marshal(respJSON)
  1903. var res ResultFour
  1904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1905. utils.ErrorLog("解析失败:%v", err)
  1906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1907. return
  1908. }
  1909. if res.Infcode == 0 {
  1910. order := &models.HisOrder{
  1911. UserOrgId: adminUser.CurrentOrgId,
  1912. HisPatientId: his.ID,
  1913. PatientId: his.PatientId,
  1914. SettleAccountsDate: recordDateTime,
  1915. Ctime: time.Now().Unix(),
  1916. Mtime: time.Now().Unix(),
  1917. Status: 1,
  1918. Number: chrg_bchno,
  1919. Infcode: res.Infcode,
  1920. WarnMsg: res.WarnMsg,
  1921. Cainfo: res.Cainfo,
  1922. ErrMsg: res.ErrMsg,
  1923. RespondTime: res.RefmsgTime,
  1924. InfRefmsgid: res.InfRefmsgid,
  1925. OrderStatus: 1,
  1926. PayWay: pay_way,
  1927. PayPrice: pay_price,
  1928. PayCardNo: pay_card_no,
  1929. DiscountPrice: discount_price,
  1930. PreferentialPrice: preferential_price,
  1931. RealityPrice: reality_price,
  1932. FoundPrice: found_price,
  1933. MedicalInsurancePrice: medical_insurance_price,
  1934. PrivatePrice: private_price,
  1935. IsMedicineInsurance: 1,
  1936. SettleType: settle_accounts_type,
  1937. SettleStartTime: start_time,
  1938. SettleEndTime: end_time,
  1939. Creator: roles.AdminUserId,
  1940. Modify: roles.AdminUserId,
  1941. FaPiaoNumber: fapiao_number,
  1942. FaPiaoCode: fapiao_code,
  1943. PType: 2,
  1944. }
  1945. err = service.CreateOrder(order)
  1946. if err != nil {
  1947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1948. return
  1949. }
  1950. for _, item := range res.Output.Result {
  1951. temp := strings.Split(item.FeedetlSn, "-")
  1952. var advice_id int64 = 0
  1953. var project_id int64 = 0
  1954. var types int64 = 0
  1955. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1956. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1957. if temp[1] == "1" {
  1958. advice_id = id
  1959. project_id = 0
  1960. } else if temp[1] == "2" {
  1961. advice_id = 0
  1962. project_id = id
  1963. }
  1964. info := &models.HisOrderInfo{
  1965. OrderNumber: order.Number,
  1966. FeedetlSn: item.FeedetlSn,
  1967. UploadDate: time.Now().Unix(),
  1968. AdviceId: advice_id,
  1969. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1970. Cnt: item.Cnt,
  1971. Pric: float64(item.Pric),
  1972. PatientId: his.PatientId,
  1973. PricUplmtAmt: item.PricUplmtAmt,
  1974. SelfpayProp: item.SelfpayProp,
  1975. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1976. OverlmtAmt: item.OverlmtAmt,
  1977. PreselfpayAmt: item.PreselfpayAmt,
  1978. BasMednFlag: item.BasMednFlag,
  1979. MedChrgitmType: item.MedChrgitmType,
  1980. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1981. Status: 1,
  1982. Memo: item.Memo,
  1983. Mtime: time.Now().Unix(),
  1984. InscpScpAmt: item.InscpScpAmt,
  1985. DrtReimFlag: item.DrtReimFlag,
  1986. Ctime: time.Now().Unix(),
  1987. ListSpItemFlag: item.ListSpItemFlag,
  1988. ChldMedcFlag: item.ChldMedcFlag,
  1989. LmtUsedFlag: item.LmtUsedFlag,
  1990. ChrgitmLv: item.ChrgitmLv,
  1991. UserOrgId: adminUser.CurrentOrgId,
  1992. HisPatientId: his.ID,
  1993. OrderId: order.ID,
  1994. ProjectId: project_id,
  1995. Type: types,
  1996. }
  1997. service.CreateOrderInfo(info)
  1998. }
  1999. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2000. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2001. var total float64
  2002. for _, item := range prescriptions {
  2003. if item.Type == 1 { //药品
  2004. for _, subItem := range item.HisDoctorAdviceInfo {
  2005. total = total + (subItem.Price * subItem.PrescribingNumber)
  2006. }
  2007. }
  2008. if item.Type == 2 { //项目
  2009. for _, subItem := range item.HisPrescriptionProject {
  2010. total = total + (subItem.Price * float64(subItem.Count))
  2011. }
  2012. }
  2013. }
  2014. for _, item := range prescriptions {
  2015. for _, subItem := range item.HisAdditionalCharge {
  2016. total = total + (subItem.Price * float64(subItem.Count))
  2017. }
  2018. }
  2019. allTotal := fmt.Sprintf("%.2f", total)
  2020. if res.Infcode == 0 {
  2021. var rf []*ResultFive
  2022. json.Unmarshal([]byte(his.Iinfo), &rf)
  2023. chrg_bchno := chrg_bchno
  2024. cert_no := his.Certno
  2025. var insutypes []string
  2026. var insutype string
  2027. var is390 int = 0
  2028. var is310 int = 0
  2029. for _, item := range rf {
  2030. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2031. insutypes = append(insutypes, item.Insutype)
  2032. }
  2033. }
  2034. if len(insutypes) == 1 {
  2035. insutype = insutypes[0]
  2036. } else {
  2037. for _, i := range insutypes {
  2038. if i == "390" {
  2039. is390 = 1
  2040. }
  2041. if i == "310" {
  2042. is310 = 1
  2043. }
  2044. }
  2045. }
  2046. if is390 == 1 {
  2047. insutype = "390"
  2048. }
  2049. if is310 == 1 {
  2050. insutype = "310"
  2051. }
  2052. if len(insutypes) == 0 {
  2053. insutype = "310"
  2054. }
  2055. insutype = "390"
  2056. if his.IdCardType == 1 {
  2057. cert_no = his.MedicalInsuranceNumber
  2058. } else {
  2059. cert_no = his.Certno
  2060. }
  2061. 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)
  2062. var dat map[string]interface{}
  2063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2064. fmt.Println(dat)
  2065. } else {
  2066. fmt.Println(err)
  2067. }
  2068. userJSONBytes, _ := json.Marshal(dat)
  2069. var res ResultSeven
  2070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2071. utils.ErrorLog("解析失败:%v", err)
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. return
  2074. }
  2075. if res.Infcode != 0 {
  2076. errlog := &models.HisOrderError{
  2077. UserOrgId: adminUser.CurrentOrgId,
  2078. Ctime: time.Now().Unix(),
  2079. Mtime: time.Now().Unix(),
  2080. Number: chrg_bchno,
  2081. ErrMsg: res.ErrMsg,
  2082. Status: 1,
  2083. PatientId: id,
  2084. RecordTime: recordDateTime,
  2085. Stage: 6,
  2086. }
  2087. service.CreateErrMsgLog(errlog)
  2088. c.ServeSuccessJSON(map[string]interface{}{
  2089. "failed_code": -10,
  2090. "msg": res.ErrMsg,
  2091. })
  2092. return
  2093. } else {
  2094. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2095. order.OrderStatus = 2
  2096. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2097. order.SetlId = res.Output.Setlinfo.SetlID
  2098. order.PsnNo = res.Output.Setlinfo.PsnNo
  2099. order.PsnName = res.Output.Setlinfo.PsnName
  2100. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2101. order.Certno = res.Output.Setlinfo.Certno
  2102. order.Gend = res.Output.Setlinfo.Gend
  2103. order.Naty = res.Output.Setlinfo.Naty
  2104. order.Age = res.Output.Setlinfo.Age
  2105. order.Insutype = res.Output.Setlinfo.Insutype
  2106. order.PsnType = res.Output.Setlinfo.PsnType
  2107. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2108. order.SetlTime = res.Output.Setlinfo.SetlTime
  2109. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2110. order.MedType = res.Output.Setlinfo.MedType
  2111. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2112. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2113. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2114. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2115. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2116. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2117. order.HifpPay = res.Output.Setlinfo.HifpPay
  2118. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2119. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2120. order.HifesPay = res.Output.Setlinfo.HifesPay
  2121. order.HifobPay = res.Output.Setlinfo.HifobPay
  2122. order.MafPay = res.Output.Setlinfo.MafPay
  2123. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2124. order.OthPay = res.Output.Setlinfo.OthPay
  2125. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2126. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2127. order.AcctPay = res.Output.Setlinfo.AcctPay
  2128. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2129. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2130. order.Balc = res.Output.Setlinfo.Balc
  2131. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2132. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2133. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2134. order.ClrWay = res.Output.Setlinfo.ClrWay
  2135. order.Creator = order.Creator
  2136. order.Modify = roles.AdminUserId
  2137. order.RequestLog = src_resquest
  2138. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2139. detailStr := string(setlDetail)
  2140. order.SetlDetail = detailStr
  2141. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2142. err = service.UpDateOrder(order)
  2143. if err == nil {
  2144. c.ServeSuccessJSON(map[string]interface{}{
  2145. "msg": "结算成功",
  2146. })
  2147. } else {
  2148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2149. return
  2150. }
  2151. }
  2152. } else {
  2153. adminUser := c.GetAdminUserInfo()
  2154. errlog := &models.HisOrderError{
  2155. UserOrgId: adminUser.CurrentOrgId,
  2156. Ctime: time.Now().Unix(),
  2157. Mtime: time.Now().Unix(),
  2158. ErrMsg: res.ErrMsg,
  2159. Status: 1,
  2160. PatientId: id,
  2161. RecordTime: recordDateTime,
  2162. Stage: 4,
  2163. }
  2164. service.CreateErrMsgLog(errlog)
  2165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2166. return
  2167. }
  2168. } else {
  2169. adminUser := c.GetAdminUserInfo()
  2170. errlog := &models.HisOrderError{
  2171. UserOrgId: adminUser.CurrentOrgId,
  2172. Ctime: time.Now().Unix(),
  2173. Mtime: time.Now().Unix(),
  2174. ErrMsg: res.ErrMsg,
  2175. Status: 1,
  2176. PatientId: id,
  2177. RecordTime: recordDateTime,
  2178. Stage: 4,
  2179. }
  2180. service.CreateErrMsgLog(errlog)
  2181. c.ServeSuccessJSON(map[string]interface{}{
  2182. "failed_code": -10,
  2183. "msg": res.ErrMsg,
  2184. })
  2185. return
  2186. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2187. //return
  2188. }
  2189. }
  2190. }
  2191. func (c *HisApiController) GetPreUploadInfo() {
  2192. id, _ := c.GetInt64("id")
  2193. record_time := c.GetString("record_time")
  2194. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2195. admin_user_id, _ := c.GetInt64("admin_user_id")
  2196. timeLayout := "2006-01-02"
  2197. loc, _ := time.LoadLocation("Local")
  2198. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2199. if err != nil {
  2200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2201. return
  2202. }
  2203. recordDateTime := theTime.Unix()
  2204. adminUser := c.GetAdminUserInfo()
  2205. var prescriptions []*models.HisPrescription
  2206. var start_time int64
  2207. var end_time int64
  2208. data := make(map[string]interface{})
  2209. if settle_accounts_type == 1 { //日结
  2210. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2211. data["pre"] = prescriptions
  2212. } else { //月结
  2213. start_time_str := c.GetString("start_time")
  2214. end_time_str := c.GetString("end_time")
  2215. timeLayout := "2006-01-02"
  2216. loc, _ := time.LoadLocation("Local")
  2217. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2218. if err != nil {
  2219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2220. return
  2221. }
  2222. recordStartTime := theStartTime.Unix()
  2223. start_time = recordStartTime
  2224. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2225. if err != nil {
  2226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2227. return
  2228. }
  2229. recordEndTime := theEndTime.Unix()
  2230. end_time = recordEndTime
  2231. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2232. data["pre"] = prescriptions
  2233. }
  2234. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2235. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2236. timestamp := time.Now().Unix()
  2237. tempTime := time.Unix(timestamp, 0)
  2238. timeFormat := tempTime.Format("20060102150405")
  2239. chrgBchno := rand.Intn(100000) + 10000
  2240. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2241. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2242. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2243. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2244. strconv.FormatInt(his.PatientId, 10)
  2245. client := &http.Client{}
  2246. data["psn_no"] = his.PsnNo
  2247. data["mdtrt_id"] = his.Number
  2248. data["chrg_bchno"] = chrg_bchno
  2249. data["org_name"] = miConfig.OrgName
  2250. data["doctor"] = roles.UserName
  2251. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2252. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2253. data["fixmedins_code"] = miConfig.Code
  2254. data["dept_code"] = department.Number
  2255. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2257. data["secret_key"] = miConfig.SecretKey
  2258. var ids []int64
  2259. for _, item := range prescriptions {
  2260. ids = append(ids, item.ID)
  2261. }
  2262. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2263. if config.IsOpen == 1 { //对接了医保,走医保流程
  2264. bytesData, _ := json.Marshal(data)
  2265. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2266. resp, _ := client.Do(req)
  2267. defer resp.Body.Close()
  2268. body, ioErr := ioutil.ReadAll(resp.Body)
  2269. if ioErr != nil {
  2270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2272. return
  2273. }
  2274. var respJSON map[string]interface{}
  2275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2278. return
  2279. }
  2280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2281. userJSONBytes, _ := json.Marshal(respJSON)
  2282. var res ResultFour
  2283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2284. utils.ErrorLog("解析失败:%v", err)
  2285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2286. return
  2287. }
  2288. if res.Infcode == 0 {
  2289. order := &models.HisOrder{
  2290. UserOrgId: adminUser.CurrentOrgId,
  2291. HisPatientId: his.ID,
  2292. PatientId: his.PatientId,
  2293. SettleAccountsDate: recordDateTime,
  2294. Ctime: time.Now().Unix(),
  2295. Mtime: time.Now().Unix(),
  2296. Status: 1,
  2297. Number: chrg_bchno,
  2298. Infcode: res.Infcode,
  2299. WarnMsg: res.WarnMsg,
  2300. Cainfo: res.Cainfo,
  2301. ErrMsg: res.ErrMsg,
  2302. RespondTime: res.RefmsgTime,
  2303. InfRefmsgid: res.InfRefmsgid,
  2304. OrderStatus: 1,
  2305. IsMedicineInsurance: 1,
  2306. SettleType: settle_accounts_type,
  2307. SettleStartTime: start_time,
  2308. SettleEndTime: end_time,
  2309. Creator: roles.ID,
  2310. Modify: roles.ID,
  2311. }
  2312. err = service.CreateOrder(order)
  2313. if err != nil {
  2314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2315. return
  2316. }
  2317. for _, item := range res.Output.Result {
  2318. temp := strings.Split(item.FeedetlSn, "-")
  2319. var advice_id int64 = 0
  2320. var project_id int64 = 0
  2321. var types int64 = 0
  2322. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2323. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2324. if temp[1] == "1" {
  2325. advice_id = id
  2326. project_id = 0
  2327. } else if temp[1] == "2" {
  2328. advice_id = 0
  2329. project_id = id
  2330. }
  2331. info := &models.HisOrderInfo{
  2332. OrderNumber: order.Number,
  2333. FeedetlSn: item.FeedetlSn,
  2334. UploadDate: time.Now().Unix(),
  2335. AdviceId: advice_id,
  2336. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2337. Cnt: item.Cnt,
  2338. Pric: float64(item.Pric),
  2339. PatientId: his.PatientId,
  2340. PricUplmtAmt: item.PricUplmtAmt,
  2341. SelfpayProp: item.SelfpayProp,
  2342. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2343. OverlmtAmt: item.OverlmtAmt,
  2344. PreselfpayAmt: item.PreselfpayAmt,
  2345. BasMednFlag: item.BasMednFlag,
  2346. MedChrgitmType: item.MedChrgitmType,
  2347. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2348. Status: 1,
  2349. Memo: item.Memo,
  2350. Mtime: time.Now().Unix(),
  2351. InscpScpAmt: item.InscpScpAmt,
  2352. DrtReimFlag: item.DrtReimFlag,
  2353. Ctime: time.Now().Unix(),
  2354. ListSpItemFlag: item.ListSpItemFlag,
  2355. ChldMedcFlag: item.ChldMedcFlag,
  2356. LmtUsedFlag: item.LmtUsedFlag,
  2357. ChrgitmLv: item.ChrgitmLv,
  2358. UserOrgId: adminUser.CurrentOrgId,
  2359. HisPatientId: his.ID,
  2360. OrderId: order.ID,
  2361. ProjectId: project_id,
  2362. Type: types,
  2363. }
  2364. service.CreateOrderInfo(info)
  2365. }
  2366. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2367. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2368. var total float64
  2369. for _, item := range prescriptions {
  2370. if item.Type == 1 { //药品
  2371. for _, subItem := range item.HisDoctorAdviceInfo {
  2372. total = total + (subItem.Price * subItem.PrescribingNumber)
  2373. }
  2374. }
  2375. if item.Type == 2 { //项目
  2376. for _, subItem := range item.HisPrescriptionProject {
  2377. total = total + (subItem.Price * float64(subItem.Count))
  2378. }
  2379. }
  2380. }
  2381. for _, item := range prescriptions {
  2382. for _, subItem := range item.HisAdditionalCharge {
  2383. total = total + (subItem.Price * float64(subItem.Count))
  2384. }
  2385. }
  2386. allTotal := fmt.Sprintf("%.2f", total)
  2387. if res.Infcode == 0 {
  2388. var rf []*ResultFive
  2389. json.Unmarshal([]byte(his.Iinfo), &rf)
  2390. psn_no := his.PsnNo
  2391. mdtrt_id := his.Number
  2392. chrg_bchno := chrg_bchno
  2393. cert_no := his.Certno
  2394. insutype := rf[0].Insutype
  2395. if his.IdCardType == 1 {
  2396. cert_no = his.MedicalInsuranceNumber
  2397. } else {
  2398. cert_no = his.Certno
  2399. }
  2400. api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2401. insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2402. "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2403. miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2404. resp, requestErr := http.Get(api)
  2405. if requestErr != nil {
  2406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2407. return
  2408. }
  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(string(body)), &respJSON); err != nil {
  2418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2420. return
  2421. }
  2422. fmt.Println(respJSON)
  2423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2424. userJSONBytes, _ := json.Marshal(respJSON)
  2425. var res ResultSeven
  2426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2427. utils.ErrorLog("解析失败:%v", err)
  2428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2429. return
  2430. }
  2431. if res.Infcode != 0 {
  2432. errlog := &models.HisOrderError{
  2433. UserOrgId: adminUser.CurrentOrgId,
  2434. Ctime: time.Now().Unix(),
  2435. Mtime: time.Now().Unix(),
  2436. Number: chrg_bchno,
  2437. ErrMsg: res.ErrMsg,
  2438. Status: 1,
  2439. PatientId: id,
  2440. RecordTime: recordDateTime,
  2441. Stage: 7,
  2442. }
  2443. service.CreateErrMsgLog(errlog)
  2444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2445. return
  2446. } else {
  2447. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2448. order.OrderStatus = 1
  2449. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2450. order.SetlId = res.Output.Setlinfo.SetlID
  2451. order.PsnNo = res.Output.Setlinfo.PsnNo
  2452. order.PsnName = res.Output.Setlinfo.PsnName
  2453. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2454. order.Certno = res.Output.Setlinfo.Certno
  2455. order.Gend = res.Output.Setlinfo.Gend
  2456. order.Naty = res.Output.Setlinfo.Naty
  2457. order.Age = res.Output.Setlinfo.Age
  2458. order.Insutype = res.Output.Setlinfo.Insutype
  2459. order.PsnType = res.Output.Setlinfo.PsnType
  2460. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2461. order.SetlTime = res.Output.Setlinfo.SetlTime
  2462. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2463. order.MedType = res.Output.Setlinfo.MedType
  2464. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2465. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2466. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2467. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2468. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2469. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2470. order.HifpPay = res.Output.Setlinfo.HifpPay
  2471. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2472. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2473. order.HifesPay = res.Output.Setlinfo.HifesPay
  2474. order.HifobPay = res.Output.Setlinfo.HifobPay
  2475. order.MafPay = res.Output.Setlinfo.MafPay
  2476. order.OthPay = res.Output.Setlinfo.OthPay
  2477. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2478. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2479. order.AcctPay = res.Output.Setlinfo.AcctPay
  2480. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2481. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2482. order.Balc = res.Output.Setlinfo.Balc
  2483. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2484. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2485. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2486. order.ClrWay = res.Output.Setlinfo.ClrWay
  2487. order.Creator = order.Creator
  2488. order.Modify = roles.ID
  2489. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2490. detailStr := string(setlDetail)
  2491. order.SetlDetail = detailStr
  2492. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2493. err = service.UpDateOrder(order)
  2494. if err == nil {
  2495. c.ServeSuccessJSON(map[string]interface{}{
  2496. "msg": "预结算成功",
  2497. })
  2498. } else {
  2499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2500. return
  2501. }
  2502. }
  2503. } else {
  2504. adminUser := c.GetAdminUserInfo()
  2505. errlog := &models.HisOrderError{
  2506. UserOrgId: adminUser.CurrentOrgId,
  2507. Ctime: time.Now().Unix(),
  2508. Mtime: time.Now().Unix(),
  2509. ErrMsg: res.ErrMsg,
  2510. Status: 1,
  2511. PatientId: id,
  2512. RecordTime: recordDateTime,
  2513. Stage: 4,
  2514. }
  2515. service.CreateErrMsgLog(errlog)
  2516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2517. return
  2518. }
  2519. } else {
  2520. adminUser := c.GetAdminUserInfo()
  2521. errlog := &models.HisOrderError{
  2522. UserOrgId: adminUser.CurrentOrgId,
  2523. Ctime: time.Now().Unix(),
  2524. Mtime: time.Now().Unix(),
  2525. ErrMsg: res.ErrMsg,
  2526. Status: 1,
  2527. PatientId: id,
  2528. RecordTime: recordDateTime,
  2529. Stage: 4,
  2530. }
  2531. service.CreateErrMsgLog(errlog)
  2532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2533. return
  2534. }
  2535. } else {
  2536. var total float64
  2537. for _, item := range prescriptions {
  2538. if item.Type == 1 { //药品
  2539. for _, subItem := range item.HisDoctorAdviceInfo {
  2540. total = total + (subItem.Price * subItem.PrescribingNumber)
  2541. }
  2542. }
  2543. if item.Type == 2 { //项目
  2544. for _, subItem := range item.HisPrescriptionProject {
  2545. total = total + (subItem.Price * float64(subItem.Count))
  2546. }
  2547. }
  2548. for _, subItem := range item.HisAdditionalCharge {
  2549. total = total + (subItem.Price * float64(subItem.Count))
  2550. }
  2551. }
  2552. allTotal := fmt.Sprintf("%.2f", total)
  2553. totals, _ := strconv.ParseFloat(allTotal, 64)
  2554. order := &models.HisOrder{
  2555. UserOrgId: adminUser.CurrentOrgId,
  2556. HisPatientId: his.ID,
  2557. PatientId: id,
  2558. SettleAccountsDate: recordDateTime,
  2559. Ctime: time.Now().Unix(),
  2560. Mtime: time.Now().Unix(),
  2561. Status: 1,
  2562. OrderStatus: 2,
  2563. Number: chrg_bchno,
  2564. MedfeeSumamt: totals,
  2565. }
  2566. err = service.CreateOrder(order)
  2567. if err != nil {
  2568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2569. return
  2570. }
  2571. var customs []*Custom
  2572. for _, item := range prescriptions {
  2573. if item.Type == 1 { //药品
  2574. for _, subItem := range item.HisDoctorAdviceInfo {
  2575. cus := &Custom{
  2576. AdviceId: subItem.ID,
  2577. ProjectId: 0,
  2578. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2579. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2580. FeedetlSn: subItem.FeedetlSn,
  2581. Price: fmt.Sprintf("%.2f", subItem.Price),
  2582. MedListCodg: subItem.MedListCodg,
  2583. Type: 1,
  2584. }
  2585. customs = append(customs, cus)
  2586. }
  2587. }
  2588. if item.Type == 2 { //项目
  2589. for _, subItem := range item.HisPrescriptionProject {
  2590. cus := &Custom{
  2591. AdviceId: 0,
  2592. ProjectId: subItem.ID,
  2593. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2594. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2595. FeedetlSn: subItem.FeedetlSn,
  2596. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2597. MedListCodg: subItem.MedListCodg,
  2598. Type: 2,
  2599. }
  2600. customs = append(customs, cus)
  2601. }
  2602. }
  2603. for _, item := range item.HisAdditionalCharge {
  2604. cus := &Custom{
  2605. ItemId: item.ID,
  2606. AdviceId: 0,
  2607. ProjectId: 0,
  2608. DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2609. Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2610. FeedetlSn: item.FeedetlSn,
  2611. Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2612. MedListCodg: item.XtHisAddtionConfig.Code,
  2613. Type: 3,
  2614. }
  2615. customs = append(customs, cus)
  2616. }
  2617. }
  2618. for _, item := range customs {
  2619. var advice_id int64 = 0
  2620. var project_id int64 = 0
  2621. var item_id int64 = 0
  2622. var types int64 = 0
  2623. if item.Type == 1 {
  2624. advice_id = item.AdviceId
  2625. project_id = 0
  2626. item_id = 0
  2627. } else if item.Type == 2 {
  2628. advice_id = 0
  2629. item_id = 0
  2630. project_id = item.ProjectId
  2631. } else if item.Type == 3 {
  2632. advice_id = 0
  2633. item_id = item.ItemId
  2634. project_id = 0
  2635. }
  2636. detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2637. cut, _ := strconv.ParseFloat(item.Cut, 32)
  2638. pric, _ := strconv.ParseFloat(item.Price, 32)
  2639. info := &models.HisOrderInfo{
  2640. OrderNumber: order.Number,
  2641. UploadDate: time.Now().Unix(),
  2642. AdviceId: advice_id,
  2643. DetItemFeeSumamt: detItemFeeSumamt,
  2644. Cnt: cut,
  2645. Pric: pric,
  2646. PatientId: id,
  2647. Status: 1,
  2648. Mtime: time.Now().Unix(),
  2649. Ctime: time.Now().Unix(),
  2650. UserOrgId: adminUser.CurrentOrgId,
  2651. HisPatientId: his.ID,
  2652. OrderId: order.ID,
  2653. ProjectId: project_id,
  2654. Type: types,
  2655. ItemId: item_id,
  2656. }
  2657. service.CreateOrderInfo(info)
  2658. }
  2659. //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2660. err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2661. err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2662. err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2663. if err == nil {
  2664. c.ServeSuccessJSON(map[string]interface{}{
  2665. "msg": "结算成功",
  2666. })
  2667. } else {
  2668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2669. return
  2670. }
  2671. }
  2672. }
  2673. //func (c *HisApiController) GetSettleInfo() {
  2674. // id, _ := c.GetInt64("id")
  2675. // order_id, _ := c.GetInt64("order_id")
  2676. //
  2677. // record_time := c.GetString("record_time")
  2678. // pay_way, _ := c.GetInt64("pay_way")
  2679. // pay_price, _ := c.GetFloat("pay_price")
  2680. // pay_card_no := c.GetString("pay_card_no")
  2681. // discount_price, _ := c.GetFloat("discount_price")
  2682. // preferential_price, _ := c.GetFloat("preferential_price")
  2683. // reality_price, _ := c.GetFloat("reality_price")
  2684. // found_price, _ := c.GetFloat("found_price")
  2685. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2686. // private_price, _ := c.GetFloat("private_price")
  2687. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2688. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2689. //
  2690. // timeLayout := "2006-01-02"
  2691. // loc, _ := time.LoadLocation("Local")
  2692. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2693. // if err != nil {
  2694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2695. // return
  2696. // }
  2697. // recordDateTime := theTime.Unix()
  2698. // adminUser := c.GetAdminUserInfo()
  2699. //
  2700. // var prescriptions []*models.HisPrescription
  2701. //
  2702. // data := make(map[string]interface{})
  2703. // if settle_accounts_type == 1 { //日结
  2704. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2705. // data["pre"] = prescriptions
  2706. //
  2707. // } else { //月结
  2708. // start_time_str := c.GetString("start_time")
  2709. // end_time_str := c.GetString("end_time")
  2710. // timeLayout := "2006-01-02"
  2711. // loc, _ := time.LoadLocation("Local")
  2712. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2713. // if err != nil {
  2714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2715. // return
  2716. // }
  2717. // recordStartTime := theStartTime.Unix()
  2718. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2719. // if err != nil {
  2720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2721. // return
  2722. // }
  2723. // recordEndTime := theEndTime.Unix()
  2724. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2725. // data["pre"] = prescriptions
  2726. //
  2727. // }
  2728. //
  2729. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2730. //
  2731. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2732. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2733. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2734. // strconv.FormatInt(his.PatientId, 10)
  2735. //
  2736. // order_src, _ := service.GetHisOrderByID(order_id)
  2737. //
  2738. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2739. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2740. //
  2741. // var total float64
  2742. // for _, item := range prescriptions {
  2743. // if item.Type == 1 { //药品
  2744. // for _, subItem := range item.HisDoctorAdviceInfo {
  2745. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2746. // }
  2747. // }
  2748. // if item.Type == 2 { //项目
  2749. // for _, subItem := range item.HisPrescriptionProject {
  2750. // total = total + (subItem.Price * float64(subItem.Count))
  2751. // }
  2752. // }
  2753. // }
  2754. //
  2755. // for _, item := range prescriptions {
  2756. // for _, subItem := range item.HisAdditionalCharge {
  2757. // total = total + (subItem.Price * float64(subItem.Count))
  2758. // }
  2759. // }
  2760. //
  2761. // allTotal := fmt.Sprintf("%.2f", total)
  2762. // var rf []*ResultFive
  2763. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2764. // psn_no := order_src.PsnNo
  2765. // mdtrt_id := order_src.MdtrtId
  2766. // chrg_bchno := order_src.Number
  2767. // cert_no := order_src.Certno
  2768. // insutype := rf[0].Insutype
  2769. //
  2770. // if his.IdCardType == 1 {
  2771. // cert_no = his.MedicalInsuranceNumber
  2772. // } else {
  2773. // cert_no = his.Certno
  2774. // }
  2775. //
  2776. // 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)
  2777. // var dat map[string]interface{}
  2778. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2779. // fmt.Println(dat)
  2780. // } else {
  2781. // fmt.Println(err)
  2782. // }
  2783. //
  2784. // userJSONBytes, _ := json.Marshal(dat)
  2785. //
  2786. //
  2787. //
  2788. // var res ResultSeven
  2789. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2790. // utils.ErrorLog("解析失败:%v", err)
  2791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. // return
  2793. // }
  2794. // if res.Infcode == -1 {
  2795. // errlog := &models.HisOrderError{
  2796. // UserOrgId: adminUser.CurrentOrgId,
  2797. // Ctime: time.Now().Unix(),
  2798. // Mtime: time.Now().Unix(),
  2799. // Number: chrg_bchno,
  2800. // ErrMsg: res.ErrMsg,
  2801. // Status: 1,
  2802. // PatientId: id,
  2803. // RecordTime: recordDateTime,
  2804. // Stage: 6,
  2805. // }
  2806. // service.CreateErrMsgLog(errlog)
  2807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2808. // return
  2809. // } else {
  2810. // order_src.OrderStatus = 2
  2811. // order_src.PayWay = pay_way
  2812. // order_src.PayPrice = pay_price
  2813. // order_src.PayCardNo = pay_card_no
  2814. // order_src.DiscountPrice = discount_price
  2815. // order_src.PreferentialPrice = preferential_price
  2816. // order_src.RealityPrice = reality_price
  2817. // order_src.FoundPrice = found_price
  2818. // order_src.MedicalInsurancePrice = medical_insurance_price
  2819. // order_src.PrivatePrice = private_price
  2820. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  2821. // order_src.SetlId = res.Output.Setlinfo.SetlID
  2822. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  2823. // order_src.PsnName = res.Output.Setlinfo.PsnName
  2824. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  2825. // order_src.Certno = res.Output.Setlinfo.Certno
  2826. // order_src.Gend = res.Output.Setlinfo.Gend
  2827. // order_src.Naty = res.Output.Setlinfo.Naty
  2828. // order_src.Age = res.Output.Setlinfo.Age
  2829. // order_src.Insutype = res.Output.Setlinfo.Insutype
  2830. // order_src.PsnType = res.Output.Setlinfo.PsnType
  2831. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2832. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  2833. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2834. // order_src.MedType = res.Output.Setlinfo.MedType
  2835. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2836. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2837. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2838. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2839. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2840. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2841. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  2842. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  2843. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2844. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  2845. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  2846. // order_src.MafPay = res.Output.Setlinfo.MafPay
  2847. // order_src.OthPay = res.Output.Setlinfo.OthPay
  2848. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2849. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2850. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  2851. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2852. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2853. // order_src.Balc = res.Output.Setlinfo.Balc
  2854. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2855. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2856. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  2857. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  2858. // order_src.Creator = order_src.Creator
  2859. // order_src.Modify = roles.ID
  2860. // order_src.RequestLog = src_resquest
  2861. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2862. // detailStr := string(setlDetail)
  2863. // order_src.SetlDetail = detailStr
  2864. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2865. // err = service.UpDateOrder(order_src)
  2866. //
  2867. // if err == nil {
  2868. // c.ServeSuccessJSON(map[string]interface{}{
  2869. // "msg": "结算成功",
  2870. // })
  2871. // } else {
  2872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2873. // return
  2874. // }
  2875. // }
  2876. // }
  2877. //}
  2878. //退款
  2879. func (c *HisApiController) Refund() {
  2880. order_id, _ := c.GetInt64("order_id")
  2881. admin_user_id, _ := c.GetInt64("admin_user_id")
  2882. //record_time := c.GetString("record_time")
  2883. //patient_id, _ := c.GetInt64("patient_id")
  2884. //timeLayout := "2006-01-02"
  2885. //loc, _ := time.LoadLocation("Local")
  2886. adminUser := c.GetAdminUserInfo()
  2887. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2888. //if err != nil {
  2889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2890. // return
  2891. //}
  2892. //recordDateTime := theTime.Unix()
  2893. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2894. var order models.HisOrder
  2895. order, _ = service.GetHisOrderByID(order_id)
  2896. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2897. if order.ID == 0 {
  2898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2899. return
  2900. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  2901. }
  2902. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2903. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2904. if config.IsOpen == 1 { //对接了医保,走医保流程
  2905. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  2906. var dat map[string]interface{}
  2907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2908. fmt.Println(dat)
  2909. } else {
  2910. fmt.Println(err)
  2911. }
  2912. userJSONBytes, _ := json.Marshal(dat)
  2913. var res ResultSixteen
  2914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2915. utils.ErrorLog("解析失败:%v", err)
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2917. return
  2918. }
  2919. if res.Infcode == 0 {
  2920. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  2921. var dat map[string]interface{}
  2922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2923. fmt.Println(dat)
  2924. } else {
  2925. fmt.Println(err)
  2926. }
  2927. userJSONBytes, _ := json.Marshal(dat)
  2928. var res2 ResultSix
  2929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2930. utils.ErrorLog("解析失败:%v", err)
  2931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2932. return
  2933. }
  2934. if res2.Infcode == 0 {
  2935. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  2936. if err == nil {
  2937. c.ServeSuccessJSON(map[string]interface{}{
  2938. "msg": "退费成功",
  2939. })
  2940. } else {
  2941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2942. return
  2943. }
  2944. } else {
  2945. c.ServeSuccessJSON(map[string]interface{}{
  2946. "code": -10,
  2947. "msg": res2.ErrMsg,
  2948. })
  2949. }
  2950. } else {
  2951. c.ServeSuccessJSON(map[string]interface{}{
  2952. "code": -10,
  2953. "msg": res.ErrMsg,
  2954. })
  2955. }
  2956. }
  2957. }
  2958. func (c *HisApiController) RefundNumber() {
  2959. record_time := c.GetString("record_time")
  2960. //patient_id, _ := c.GetInt64("patient_id")
  2961. admin_user_id, _ := c.GetInt64("admin_user_id")
  2962. his_patient_id, _ := c.GetInt64("id")
  2963. timeLayout := "2006-01-02"
  2964. loc, _ := time.LoadLocation("Local")
  2965. adminUser := c.GetAdminUserInfo()
  2966. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2967. fmt.Println(err)
  2968. if err != nil {
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2970. return
  2971. }
  2972. recordDateTime := theTime.Unix()
  2973. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2974. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  2975. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2976. //order, _ := service.GetHisOrderByID(order_id)
  2977. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2978. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2979. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2980. if config.IsOpen == 1 { //对接了医保,走医保流程
  2981. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  2982. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  2983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  2984. resp3, requestErr3 := http.Get(api3)
  2985. if requestErr3 != nil {
  2986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. return
  2988. }
  2989. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  2990. if ioErr3 != nil {
  2991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  2992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2993. return
  2994. }
  2995. var respJSON3 map[string]interface{}
  2996. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  2997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2999. return
  3000. }
  3001. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3002. userJSONBytes3, _ := json.Marshal(respJSON3)
  3003. var res2 ResultSix
  3004. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3005. utils.ErrorLog("解析失败:%v", err)
  3006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3007. return
  3008. }
  3009. if res2.Infcode == 0 {
  3010. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  3011. if err == nil {
  3012. c.ServeSuccessJSON(map[string]interface{}{
  3013. "msg": "退号成功",
  3014. })
  3015. } else {
  3016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3017. return
  3018. }
  3019. } else {
  3020. c.ServeSuccessJSON(map[string]interface{}{
  3021. "code": -10,
  3022. "msg": res2.ErrMsg,
  3023. })
  3024. }
  3025. } else {
  3026. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3027. //if err == nil {
  3028. // c.ServeSuccessJSON(map[string]interface{}{
  3029. // "msg": "退费成功",
  3030. // })
  3031. //} else {
  3032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3033. // return
  3034. //}
  3035. }
  3036. }
  3037. func (c *HisApiController) RefundDetail() {
  3038. order_id, _ := c.GetInt64("order_id")
  3039. his_patient_id, _ := c.GetInt64("his_patient_id")
  3040. number := c.GetString("number")
  3041. record_time := c.GetString("record_time")
  3042. patient_id, _ := c.GetInt64("patient_id")
  3043. timeLayout := "2006-01-02"
  3044. loc, _ := time.LoadLocation("Local")
  3045. adminUser := c.GetAdminUserInfo()
  3046. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3047. fmt.Println(err)
  3048. if err != nil {
  3049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3050. return
  3051. }
  3052. recordDateTime := theTime.Unix()
  3053. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3054. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3055. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3056. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3057. var order models.HisOrder
  3058. order, _ = service.GetHisOrderByID(order_id)
  3059. if order.ID == 0 {
  3060. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3061. }
  3062. if config.IsOpen == 1 { //对接了医保,走医保流程
  3063. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3064. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3065. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3066. resp2, requestErr2 := http.Get(api2)
  3067. if requestErr2 != nil {
  3068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3069. return
  3070. }
  3071. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3072. if ioErr2 != nil {
  3073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. return
  3076. }
  3077. var respJSON2 map[string]interface{}
  3078. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return
  3082. }
  3083. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3084. if err == nil {
  3085. c.ServeSuccessJSON(map[string]interface{}{
  3086. "msg": "退费成功",
  3087. })
  3088. } else {
  3089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3090. return
  3091. }
  3092. } else {
  3093. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3094. if err == nil {
  3095. c.ServeSuccessJSON(map[string]interface{}{
  3096. "msg": "退费成功",
  3097. })
  3098. } else {
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. }
  3103. }
  3104. //对账
  3105. func (c *HisApiController) GetCheckAccount() {
  3106. start_time := c.GetString("start_time")
  3107. end_time := c.GetString("end_time")
  3108. insutype := c.GetString("insutype")
  3109. clr_type := c.GetString("clr_type")
  3110. admin_user_id, _ := c.GetInt64("admin_user_id")
  3111. adminUser := c.GetAdminUserInfo()
  3112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3113. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3114. timeLayout := "2006-01-02"
  3115. loc, _ := time.LoadLocation("Local")
  3116. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3117. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3118. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3119. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3120. fixmedins_setl_cnt := int64(len(orders))
  3121. //
  3122. ////撤销的算2条数据为一笔
  3123. //for _, item := range orders_two {
  3124. // if item.OrderStatus == 3 {
  3125. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3126. // }
  3127. //}
  3128. var medfee_sumamt float64
  3129. var acct_pay float64
  3130. var fund_pay_sumamt float64
  3131. for _, item := range orders {
  3132. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3133. acct_pay = acct_pay + item.AcctPay
  3134. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3135. }
  3136. var user_name string
  3137. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3138. if role.ID == 0 {
  3139. user_name = "xxx"
  3140. } else {
  3141. user_name = role.UserName
  3142. }
  3143. if config.IsOpen == 1 {
  3144. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3145. "insutype=" + insutype +
  3146. "&clr_type=" + clr_type +
  3147. "&setl_optins=" + "定点医保中心" +
  3148. "&stmt_begndate=" + start_time +
  3149. "&stm_enddate=" + end_time +
  3150. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3151. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3152. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3153. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3154. "&fixmedins_code=" + miConfig.Code +
  3155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3156. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3157. "&secret_key=" + miConfig.SecretKey +
  3158. "&org_name=" + miConfig.OrgName +
  3159. "&doctor=" + user_name
  3160. fmt.Println(api)
  3161. resp, requestErr := http.Get(api)
  3162. if requestErr != nil {
  3163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. return
  3165. }
  3166. body, ioErr := ioutil.ReadAll(resp.Body)
  3167. fmt.Println(body)
  3168. if ioErr != nil {
  3169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3171. return
  3172. }
  3173. var respJSON map[string]interface{}
  3174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3177. return
  3178. }
  3179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3180. userJSONBytes, _ := json.Marshal(respJSON)
  3181. var res ResultEight
  3182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3183. utils.ErrorLog("解析失败:%v", err)
  3184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3185. return
  3186. }
  3187. if res.Infcode == 0 {
  3188. if res.Output.Stmtinfo.StmtRslt == "0" {
  3189. micc := &models.MedicalInsuranceCostCompare{
  3190. StartTime: startime.Unix(),
  3191. EndTime: endtime.Unix(),
  3192. Insutype: insutype,
  3193. CheckType: 1,
  3194. Num: fixmedins_setl_cnt,
  3195. Mtime: time.Now().Unix(),
  3196. Status: 1,
  3197. UserOrgId: adminUser.CurrentOrgId,
  3198. CostTotal: medfee_sumamt,
  3199. FuncTotal: fund_pay_sumamt,
  3200. PsnPay: acct_pay,
  3201. Creator: admin_user_id,
  3202. Ctime: time.Now().Unix(),
  3203. }
  3204. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3205. if err == nil {
  3206. c.ServeSuccessJSON(map[string]interface{}{
  3207. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3208. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3209. })
  3210. } else {
  3211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3212. }
  3213. } else {
  3214. c.ServeSuccessJSON(map[string]interface{}{
  3215. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3216. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3217. })
  3218. }
  3219. } else {
  3220. c.ServeSuccessJSON(map[string]interface{}{
  3221. "code": -10,
  3222. "msg": res.ErrMsg,
  3223. })
  3224. }
  3225. }
  3226. }
  3227. func (c *HisApiController) Check310() {
  3228. adminUser := c.GetAdminUserInfo()
  3229. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3230. var user_name string
  3231. user_name = "xxx"
  3232. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3233. "insutype=" + "310" +
  3234. "&clr_type=" + "11" +
  3235. "&setl_optins=" + "定点医保中心" +
  3236. "&stmt_begndate=" + "2021-03-01" +
  3237. "&stm_enddate=" + "2021-03-31" +
  3238. "&medfee_sumamt=" + "11521" +
  3239. "&fund_pay_sumamt=" + "10166.66" +
  3240. "&acct_pay=" + "0" +
  3241. "&fixmedins_setl_cnt=" + "7" +
  3242. "&fixmedins_code=" + miConfig.Code +
  3243. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3244. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3245. "&secret_key=" + miConfig.SecretKey +
  3246. "&org_name=" + miConfig.OrgName +
  3247. "&doctor=" + user_name
  3248. fmt.Println(api)
  3249. resp, requestErr := http.Get(api)
  3250. if requestErr != nil {
  3251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3252. return
  3253. }
  3254. body, ioErr := ioutil.ReadAll(resp.Body)
  3255. fmt.Println(body)
  3256. if ioErr != nil {
  3257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3259. return
  3260. }
  3261. var respJSON map[string]interface{}
  3262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3265. return
  3266. }
  3267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3268. userJSONBytes, _ := json.Marshal(respJSON)
  3269. var res ResultEight
  3270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3271. utils.ErrorLog("解析失败:%v", err)
  3272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3273. return
  3274. }
  3275. }
  3276. func (c *HisApiController) Check390() {
  3277. adminUser := c.GetAdminUserInfo()
  3278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3279. var user_name string
  3280. user_name = "张俊杰"
  3281. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3282. "insutype=" + "390" +
  3283. "&clr_type=" + "11" +
  3284. "&setl_optins=" + "定点医保中心" +
  3285. "&stmt_begndate=" + "2021-03-01" +
  3286. "&stm_enddate=" + "2021-03-31" +
  3287. "&medfee_sumamt=" + "209318.43" +
  3288. "&fund_pay_sumamt=" + "188029.12" +
  3289. "&acct_pay=" + "0" +
  3290. "&fixmedins_setl_cnt=" + "48" +
  3291. "&fixmedins_code=" + miConfig.Code +
  3292. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3293. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3294. "&secret_key=" + miConfig.SecretKey +
  3295. "&org_name=" + miConfig.OrgName +
  3296. "&doctor=" + user_name
  3297. fmt.Println(api)
  3298. resp, requestErr := http.Get(api)
  3299. if requestErr != nil {
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3301. return
  3302. }
  3303. body, ioErr := ioutil.ReadAll(resp.Body)
  3304. fmt.Println(body)
  3305. if ioErr != nil {
  3306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. return
  3309. }
  3310. var respJSON map[string]interface{}
  3311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3314. return
  3315. }
  3316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3317. userJSONBytes, _ := json.Marshal(respJSON)
  3318. var res ResultEight
  3319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3320. utils.ErrorLog("解析失败:%v", err)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. return
  3323. }
  3324. }
  3325. //对账明细
  3326. func (c *HisApiController) GetCheckDetailAccount() {
  3327. start_time := c.GetString("start_time")
  3328. end_time := c.GetString("end_time")
  3329. admin_user_id, _ := c.GetInt64("admin_user_id")
  3330. adminUser := c.GetAdminUserInfo()
  3331. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3332. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3333. timeLayout := "2006-01-02"
  3334. loc, _ := time.LoadLocation("Local")
  3335. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3336. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3337. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  3338. Mkdir(miConfig.OrgName)
  3339. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  3340. file_name := file + ".txt"
  3341. zip_name := file + ".zip"
  3342. zip_path := miConfig.OrgName + "/" + zip_name
  3343. file_path := miConfig.OrgName + "/" + file_name
  3344. decimal.DivisionPrecision = 2
  3345. var medfee_sumamt float64
  3346. var psn_cash_pay float64
  3347. var fund_pay_sumamt float64
  3348. fixmedins_setl_cnt := int64(len(orders))
  3349. for _, item := range orders {
  3350. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3351. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  3352. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3353. }
  3354. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  3355. defer f.Close()
  3356. if err != nil {
  3357. fmt.Println(err.Error())
  3358. } else {
  3359. for _, item := range orders {
  3360. var refd_setl_flag string
  3361. if item.OrderStatus == 2 {
  3362. refd_setl_flag = "0"
  3363. var str string
  3364. str = item.SetlId + " " +
  3365. item.MdtrtId + " " +
  3366. item.PsnNo + " " +
  3367. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3368. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3369. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  3370. _, err = f.Write([]byte(str))
  3371. }
  3372. if item.OrderStatus == 3 {
  3373. var str string
  3374. str = item.SetlId + " " +
  3375. item.MdtrtId + " " +
  3376. item.PsnNo + " " +
  3377. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3378. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3379. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  3380. _, err = f.Write([]byte(str))
  3381. var str2 string
  3382. str2 = item.SetlId + " " +
  3383. item.MdtrtId + " " +
  3384. item.PsnNo + " " +
  3385. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  3386. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  3387. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  3388. _, err = f.Write([]byte(str2))
  3389. }
  3390. }
  3391. }
  3392. Zip(file_path, zip_path)
  3393. fmt.Println(ReadFile(zip_path))
  3394. fmt.Println(string(ReadFile(zip_path)))
  3395. if config.IsOpen == 1 {
  3396. var user_name string
  3397. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3398. if role.ID == 0 {
  3399. user_name = "管理员"
  3400. } else {
  3401. user_name = role.UserName
  3402. }
  3403. baseParams := models.BaseParams{
  3404. SecretKey: miConfig.SecretKey,
  3405. FixmedinsCode: miConfig.Code,
  3406. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3407. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3408. OrgName: miConfig.OrgName,
  3409. Doctor: user_name,
  3410. }
  3411. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  3412. var dat map[string]interface{}
  3413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3414. fmt.Println(dat)
  3415. } else {
  3416. fmt.Println(err)
  3417. }
  3418. userJSONBytes, _ := json.Marshal(dat)
  3419. var res ResultNine
  3420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3421. utils.ErrorLog("解析失败:%v", err)
  3422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3423. return
  3424. }
  3425. if res.Infcode == 0 {
  3426. fileNo := res.Output.FileQuryNo
  3427. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  3428. "file_qury_no=" + fileNo +
  3429. "&setl_optins=" + "定点医保中心" +
  3430. "&stmt_begndate=" + start_time +
  3431. "&stm_enddate=" + end_time +
  3432. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3433. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3434. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  3435. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3436. "&fixmedins_code=" + miConfig.Code +
  3437. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3438. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3439. "&secret_key=" + miConfig.SecretKey +
  3440. "&org_name=" + miConfig.OrgName +
  3441. "&doctor=" + user_name
  3442. resp, requestErr := http.Get(api)
  3443. if requestErr != nil {
  3444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3445. return
  3446. }
  3447. body, ioErr := ioutil.ReadAll(resp.Body)
  3448. if ioErr != nil {
  3449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3451. return
  3452. }
  3453. var respJSON map[string]interface{}
  3454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3457. return
  3458. }
  3459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3460. userJSONBytes, _ := json.Marshal(respJSON)
  3461. var res ResultTen
  3462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3463. utils.ErrorLog("解析失败:%v", err)
  3464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. return
  3466. }
  3467. if res.Infcode == 0 {
  3468. service.Gdyb9102(baseParams, zip_name, fileNo)
  3469. micc := &models.MedicalInsuranceCostCompare{
  3470. StartTime: startime.Unix(),
  3471. EndTime: endtime.Unix(),
  3472. Insutype: "0",
  3473. CheckType: 2,
  3474. Num: fixmedins_setl_cnt,
  3475. Mtime: time.Now().Unix(),
  3476. Status: 1,
  3477. UserOrgId: adminUser.CurrentOrgId,
  3478. CostTotal: medfee_sumamt,
  3479. FuncTotal: fund_pay_sumamt,
  3480. PsnPay: psn_cash_pay,
  3481. Creator: admin_user_id,
  3482. Ctime: time.Now().Unix(),
  3483. }
  3484. service.CreateMedicalInsuranceCostCompareRecord(micc)
  3485. c.ServeSuccessJSON(map[string]interface{}{
  3486. "msg": "明细对账成功",
  3487. })
  3488. }
  3489. } else {
  3490. }
  3491. }
  3492. }
  3493. func (c *HisApiController) GetSettleAccounts() {
  3494. //id, _ := c.GetInt64("id")
  3495. //record_time := c.GetString("record_time")
  3496. order_id, _ := c.GetInt64("order_id")
  3497. admin_user_id, _ := c.GetInt64("admin_user_id")
  3498. //timeLayout := "2006-01-02"
  3499. //loc, _ := time.LoadLocation("Local")
  3500. //
  3501. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3502. //if err != nil {
  3503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3504. // return
  3505. //}
  3506. //recordDateTime := theTime.Unix()
  3507. adminUser := c.GetAdminUserInfo()
  3508. order, _ := service.GetHisOrderByID(order_id)
  3509. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3510. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3511. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3512. orderInfos = append(orderInfos, orderInfos_two...)
  3513. diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  3514. var bedCostTotal float64 = 0 //床位总费
  3515. var bedCostSelfTotal float64 = 0 //床位自费
  3516. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3517. var operationCostTotal float64 = 0 //手术费
  3518. var operationCostSelfTotal float64 = 0 //手术费
  3519. var operationCostPartSelfTotal float64 = 0 //手术费
  3520. var otherCostTotal float64 = 0 //其他费用
  3521. var otherCostSelfTotal float64 = 0 //其他费用
  3522. var otherCostPartSelfTotal float64 = 0 //其他费用
  3523. var materialCostTotal float64 = 0 //材料费
  3524. var materialCostSelfTotal float64 = 0 //材料费
  3525. var materialCostPartSelfTotal float64 = 0 //材料费
  3526. var westernMedicineCostTotal float64 = 0 //西药费
  3527. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3528. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3529. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3530. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3531. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3532. var checkCostTotal float64 = 0 //检查费
  3533. var checkCostSelfTotal float64 = 0 //检查费
  3534. var checkCostPartSelfTotal float64 = 0 //检查费
  3535. var laboratoryCostTotal float64 = 0 //化验费
  3536. var laboratoryCostSelfTotal float64 = 0 //化验费
  3537. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3538. var treatCostTotal float64 = 0 //治疗费用
  3539. var treatCostSelfTotal float64 = 0 //治疗费用
  3540. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3541. decimal.DivisionPrecision = 2
  3542. for _, item := range orderInfos {
  3543. if item.MedChrgitmType == "01" { //床位费
  3544. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3545. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3546. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3547. }
  3548. if item.MedChrgitmType == "03" { //检查费
  3549. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3550. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3551. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3552. }
  3553. if item.MedChrgitmType == "04" { //化验费
  3554. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3555. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3556. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3557. }
  3558. if item.MedChrgitmType == "05" { //治疗费
  3559. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3560. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3561. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3562. }
  3563. if item.MedChrgitmType == "06" { //手术费
  3564. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3565. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3566. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3567. }
  3568. if item.MedChrgitmType == "08" { //材料费
  3569. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3570. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3571. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3572. }
  3573. if item.MedChrgitmType == "09" { //西药费
  3574. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3575. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3576. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3577. }
  3578. if item.MedChrgitmType == "11" { //中成费
  3579. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3580. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3581. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3582. }
  3583. if item.MedChrgitmType == "14" { //其他费
  3584. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3585. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3586. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3587. }
  3588. }
  3589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3591. var user_name string
  3592. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3593. if role.ID == 0 {
  3594. user_name = "管理员"
  3595. } else {
  3596. user_name = role.UserName
  3597. }
  3598. baseParams := models.BaseParams{
  3599. SecretKey: miConfig.SecretKey,
  3600. FixmedinsCode: miConfig.Code,
  3601. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3602. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3603. OrgName: miConfig.OrgName,
  3604. Doctor: user_name,
  3605. }
  3606. businessParams := models.BusinessParams{
  3607. PsnNo: order.PsnNo,
  3608. MdtrtId: order.MdtrtId,
  3609. SetlId: order.SetlId,
  3610. }
  3611. if config.IsOpen == 1 {
  3612. result := service.Gdyb5203(baseParams, businessParams)
  3613. var dat map[string]interface{}
  3614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3615. fmt.Println(dat)
  3616. } else {
  3617. fmt.Println(err)
  3618. }
  3619. userJSONBytes, _ := json.Marshal(dat)
  3620. var res ResultEleven
  3621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3622. utils.ErrorLog("解析失败:%v", err)
  3623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3624. return
  3625. }
  3626. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3627. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  3628. if res.Infcode == 0 {
  3629. c.ServeSuccessJSON(map[string]interface{}{
  3630. "diagnosis": diagnosisConfig.CountryContentName,
  3631. "order_infos": orderInfos,
  3632. "number": order.MdtrtId,
  3633. "date": order.SettleAccountsDate,
  3634. "charge_admin": charge_admin,
  3635. "printor_admin": printor_admin,
  3636. "info": res.Output.Setlinfo,
  3637. "bedCostTotal": bedCostTotal,
  3638. "bedCostSelfTotal": bedCostSelfTotal,
  3639. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  3640. "operationCostTotal": operationCostTotal,
  3641. "operationCostSelfTotal": operationCostSelfTotal,
  3642. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  3643. "otherCostTotal": otherCostTotal,
  3644. "otherCostSelfTotal": otherCostSelfTotal,
  3645. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  3646. "materialCostTotal": materialCostTotal,
  3647. "materialCostSelfTotal": materialCostSelfTotal,
  3648. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  3649. "westernMedicineCostTotal": westernMedicineCostTotal,
  3650. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  3651. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  3652. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  3653. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  3654. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  3655. "checkCostTotal": checkCostTotal,
  3656. "checkCostSelfTotal": checkCostSelfTotal,
  3657. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  3658. "laboratoryCostTotal": laboratoryCostTotal,
  3659. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  3660. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  3661. "treatCostTotal": treatCostTotal,
  3662. "treatCostSelfTotal": treatCostSelfTotal,
  3663. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  3664. })
  3665. }
  3666. }
  3667. }
  3668. func (c *HisApiController) CheckTreatment() {
  3669. patient_id, _ := c.GetInt64("patient_id", 0)
  3670. record_time := c.GetString("record_time")
  3671. insutype := c.GetString("insutype")
  3672. timeLayout := "2006-01-02"
  3673. loc, _ := time.LoadLocation("Local")
  3674. adminUser := c.GetAdminUserInfo()
  3675. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3676. fmt.Println(err)
  3677. if err != nil {
  3678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3679. return
  3680. }
  3681. recordDateTime := theTime.Unix()
  3682. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3683. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3686. var user_name string
  3687. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  3688. if role.ID == 0 {
  3689. user_name = "xxx"
  3690. } else {
  3691. user_name = role.UserName
  3692. }
  3693. baseParams := models.BaseParams{
  3694. SecretKey: miConfig.SecretKey,
  3695. FixmedinsCode: miConfig.Code,
  3696. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3697. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3698. OrgName: miConfig.OrgName,
  3699. Doctor: user_name,
  3700. }
  3701. if config.IsOpen == 1 {
  3702. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  3703. var dat map[string]interface{}
  3704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3705. fmt.Println(dat)
  3706. } else {
  3707. fmt.Println(err)
  3708. }
  3709. }
  3710. }
  3711. func (c *HisApiController) PutRecord() {
  3712. id, _ := c.GetInt64("id")
  3713. record_time := c.GetString("record_time")
  3714. timeLayout := "2006-01-02"
  3715. loc, _ := time.LoadLocation("Local")
  3716. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3717. if err != nil {
  3718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3719. return
  3720. }
  3721. recordDateTime := theTime.Unix()
  3722. adminInfo := c.GetAdminUserInfo()
  3723. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  3724. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3725. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3726. fmt.Println(miConfig.SecretKey)
  3727. if patient == nil {
  3728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3729. return
  3730. }
  3731. if len(patient.IdCardNo) == 0 {
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3733. return
  3734. }
  3735. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3736. if config.IsOpen == 1 {
  3737. 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
  3738. resp, requestErr := http.Get(api)
  3739. if requestErr != nil {
  3740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. return
  3742. }
  3743. defer resp.Body.Close()
  3744. body, ioErr := ioutil.ReadAll(resp.Body)
  3745. if ioErr != nil {
  3746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. return
  3749. }
  3750. var respJSON map[string]interface{}
  3751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3754. return
  3755. }
  3756. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3757. userJSONBytes, _ := json.Marshal(userJSON)
  3758. var res ResultTwo
  3759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3760. utils.ErrorLog("解析失败:%v", err)
  3761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. return
  3763. }
  3764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3766. infoStr := string(Iinfos)
  3767. idetinfoStr := string(Idetinfos)
  3768. if res.Infcode == 0 {
  3769. his := models.VMHisPatient{
  3770. Status: 1,
  3771. Ctime: time.Now().Unix(),
  3772. Mtime: time.Now().Unix(),
  3773. PsnNo: res.Output.Baseinfo.PsnNo,
  3774. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3775. Certno: res.Output.Baseinfo.Certno,
  3776. PsnName: res.Output.Baseinfo.PsnName,
  3777. Gend: res.Output.Baseinfo.Gend,
  3778. Naty: res.Output.Baseinfo.Naty,
  3779. Brdy: res.Output.Baseinfo.Brdy,
  3780. Age: res.Output.Baseinfo.Age,
  3781. Iinfo: infoStr,
  3782. Idetinfo: idetinfoStr,
  3783. PatientId: patient.ID,
  3784. RecordDate: theTime.Unix(),
  3785. UserOrgId: adminInfo.CurrentOrgId,
  3786. AdminUserId: adminInfo.AdminUser.Id,
  3787. IsReturn: 1,
  3788. }
  3789. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3790. 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")
  3791. 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")
  3792. var dat map[string]interface{}
  3793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3794. fmt.Println(dat)
  3795. } else {
  3796. fmt.Println(err)
  3797. }
  3798. var dat2 map[string]interface{}
  3799. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  3800. fmt.Println(dat2)
  3801. } else {
  3802. fmt.Println(err)
  3803. }
  3804. } else {
  3805. adminUser := c.GetAdminUserInfo()
  3806. errlog := &models.HisOrderError{
  3807. UserOrgId: adminUser.CurrentOrgId,
  3808. Ctime: time.Now().Unix(),
  3809. Mtime: time.Now().Unix(),
  3810. ErrMsg: res.ErrMsg,
  3811. Status: 1,
  3812. PatientId: id,
  3813. RecordTime: recordDateTime,
  3814. Stage: 1,
  3815. }
  3816. service.CreateErrMsgLog(errlog)
  3817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3818. return
  3819. }
  3820. }
  3821. }
  3822. func (c *HisApiController) GetUploadDiag() {
  3823. id, _ := c.GetInt64("id")
  3824. record_time := c.GetString("record_time")
  3825. diagnosis_id, _ := c.GetInt64("diagnosis")
  3826. sick_type, _ := c.GetInt64("sick_type")
  3827. reg_type, _ := c.GetInt64("reg_type")
  3828. timeLayout := "2006-01-02"
  3829. loc, _ := time.LoadLocation("Local")
  3830. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3831. if err != nil {
  3832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3833. return
  3834. }
  3835. var patientPrescription models.HisPrescriptionInfo
  3836. recordDateTime := theTime.Unix()
  3837. adminInfo := c.GetAdminUserInfo()
  3838. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3839. if patientPrescription.ID == 0 {
  3840. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3841. }
  3842. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3843. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  3844. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3845. sickConfig, _ := service.FindSickById(sick_type)
  3846. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3847. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  3848. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  3849. "&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 +
  3850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  3851. resp2, requestErr2 := http.Get(api2)
  3852. if requestErr2 != nil {
  3853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3854. return
  3855. }
  3856. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3857. if ioErr2 != nil {
  3858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3860. return
  3861. }
  3862. var respJSON2 map[string]interface{}
  3863. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3869. userJSONBytes2, _ := json.Marshal(respJSON2)
  3870. var res2 ResultSix
  3871. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3872. utils.ErrorLog("解析失败:%v", err)
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3874. return
  3875. }
  3876. if res2.Infcode != 0 {
  3877. adminUser := c.GetAdminUserInfo()
  3878. errlog := &models.HisOrderError{
  3879. UserOrgId: adminUser.CurrentOrgId,
  3880. Ctime: time.Now().Unix(),
  3881. Mtime: time.Now().Unix(),
  3882. ErrMsg: res2.ErrMsg,
  3883. Status: 1,
  3884. PatientId: id,
  3885. RecordTime: recordDateTime,
  3886. Stage: 3,
  3887. }
  3888. service.CreateErrMsgLog(errlog)
  3889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  3890. return
  3891. }
  3892. c.ServeSuccessJSON(map[string]interface{}{
  3893. "msg": "上传成功",
  3894. })
  3895. }
  3896. type QueryResult struct {
  3897. ID int64
  3898. Name string
  3899. Code string
  3900. List_type_code string
  3901. }
  3902. func (c *HisApiController) GetCheckCode() {
  3903. ids_str := c.GetString("ids")
  3904. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  3905. ids_arr := strings.Split(ids_str, ",")
  3906. var queryResult []QueryResult
  3907. ids := make([]int64, 0)
  3908. for _, item := range ids_arr {
  3909. id, _ := strconv.ParseInt(item, 10, 64)
  3910. ids = append(ids, id)
  3911. }
  3912. if record_type == 1 {
  3913. drugs, _ := service.GetBatchDrugList(ids)
  3914. for _, item := range drugs {
  3915. result := QueryResult{
  3916. ID: item.ID,
  3917. Name: item.DrugName,
  3918. Code: item.MedicalInsuranceNumber,
  3919. List_type_code: "101",
  3920. }
  3921. queryResult = append(queryResult, result)
  3922. }
  3923. } else if record_type == 2 {
  3924. goods, _ := service.GetBatchGoodInformationList(ids)
  3925. for _, item := range goods {
  3926. result := QueryResult{
  3927. ID: item.ID,
  3928. Name: item.GoodName,
  3929. Code: item.MedicalInsuranceNumber,
  3930. List_type_code: "301",
  3931. }
  3932. queryResult = append(queryResult, result)
  3933. }
  3934. } else if record_type == 3 {
  3935. projects, _ := service.GetBathchMyPorjecgList(ids)
  3936. for _, item := range projects {
  3937. result := QueryResult{
  3938. ID: item.ID,
  3939. Name: item.ProjectName,
  3940. Code: item.MedicalCode,
  3941. List_type_code: "201",
  3942. }
  3943. queryResult = append(queryResult, result)
  3944. }
  3945. }
  3946. admin_user_id, _ := c.GetInt64("admin_user_id")
  3947. adminUser := c.GetAdminUserInfo()
  3948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3949. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3950. var user_name string
  3951. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3952. if role.ID == 0 {
  3953. user_name = "xxx"
  3954. } else {
  3955. user_name = role.UserName
  3956. }
  3957. baseParams := &models.BaseParams{
  3958. SecretKey: miConfig.SecretKey,
  3959. FixmedinsCode: miConfig.Code,
  3960. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3961. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3962. OrgName: miConfig.OrgName,
  3963. Doctor: user_name,
  3964. }
  3965. if config.IsOpen == 1 {
  3966. for _, item := range queryResult {
  3967. var result string
  3968. if record_type == 1 {
  3969. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  3970. } else if record_type == 2 {
  3971. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  3972. } else if record_type == 3 {
  3973. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  3974. }
  3975. var dat map[string]interface{}
  3976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3977. fmt.Println(dat)
  3978. } else {
  3979. fmt.Println(err)
  3980. }
  3981. userJSONBytes, _ := json.Marshal(dat)
  3982. var res ResultSix
  3983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3984. utils.ErrorLog("解析失败:%v", err)
  3985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3986. return
  3987. }
  3988. if res.Infcode == 0 {
  3989. if record_type == 1 {
  3990. service.UpdateBaseDrugById(item.ID)
  3991. } else if record_type == 2 {
  3992. service.UpdateGoodInformaitonByDetail(item.ID)
  3993. } else if record_type == 3 {
  3994. service.UpdateProjectById(item.ID)
  3995. }
  3996. c.ServeSuccessJSON(map[string]interface{}{
  3997. "failed_code": 0,
  3998. "msg": "目录对照成功",
  3999. })
  4000. } else {
  4001. c.ServeSuccessJSON(map[string]interface{}{
  4002. "failed_code": -10,
  4003. "msg": res.ErrMsg,
  4004. })
  4005. }
  4006. }
  4007. }
  4008. }
  4009. func (c *HisApiController) UnCheckCode() {
  4010. ids_str := c.GetString("ids")
  4011. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4012. admin_user_id, _ := c.GetInt64("admin_user_id")
  4013. ids_arr := strings.Split(ids_str, ",")
  4014. var queryResult []QueryResult
  4015. ids := make([]int64, 0)
  4016. for _, item := range ids_arr {
  4017. id, _ := strconv.ParseInt(item, 10, 64)
  4018. ids = append(ids, id)
  4019. }
  4020. if record_type == 1 {
  4021. drugs, _ := service.GetBatchDrugList(ids)
  4022. for _, item := range drugs {
  4023. result := QueryResult{
  4024. ID: item.ID,
  4025. Name: item.DrugName,
  4026. Code: item.MedicalInsuranceNumber,
  4027. List_type_code: "101",
  4028. }
  4029. queryResult = append(queryResult, result)
  4030. }
  4031. } else if record_type == 2 {
  4032. goods, _ := service.GetBatchGoodInformationList(ids)
  4033. for _, item := range goods {
  4034. result := QueryResult{
  4035. ID: item.ID,
  4036. Name: item.GoodName,
  4037. Code: item.MedicalInsuranceNumber,
  4038. List_type_code: "301",
  4039. }
  4040. queryResult = append(queryResult, result)
  4041. }
  4042. } else if record_type == 3 {
  4043. projects, _ := service.GetBathchMyPorjecgList(ids)
  4044. for _, item := range projects {
  4045. result := QueryResult{
  4046. ID: item.ID,
  4047. Name: item.ProjectName,
  4048. Code: item.MedicalCode,
  4049. List_type_code: "201",
  4050. }
  4051. queryResult = append(queryResult, result)
  4052. }
  4053. }
  4054. adminUser := c.GetAdminUserInfo()
  4055. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4056. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4057. var user_name string
  4058. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4059. if role.ID == 0 {
  4060. user_name = "xxx"
  4061. } else {
  4062. user_name = role.UserName
  4063. }
  4064. baseParams := &models.BaseParams{
  4065. SecretKey: miConfig.SecretKey,
  4066. FixmedinsCode: miConfig.Code,
  4067. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4068. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4069. OrgName: miConfig.OrgName,
  4070. Doctor: user_name,
  4071. }
  4072. if config.IsOpen == 1 {
  4073. for _, item := range queryResult {
  4074. var result string
  4075. if record_type == 1 {
  4076. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4077. } else if record_type == 2 {
  4078. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4079. } else if record_type == 3 {
  4080. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4081. }
  4082. var dat2 map[string]interface{}
  4083. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4084. fmt.Println(dat2)
  4085. } else {
  4086. fmt.Println(err)
  4087. }
  4088. userJSONBytes, _ := json.Marshal(dat2)
  4089. var res ResultSix
  4090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4091. utils.ErrorLog("解析失败:%v", err)
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. return
  4094. }
  4095. if res.Infcode == 0 {
  4096. if record_type == 1 {
  4097. service.UpdateDrugByIdDetail(item.ID)
  4098. } else if record_type == 2 {
  4099. service.UpdateGoodInfoById(item.ID)
  4100. } else if record_type == 3 {
  4101. service.UpdateMyProjectById(item.ID)
  4102. }
  4103. c.ServeSuccessJSON(map[string]interface{}{
  4104. "failed_code": 0,
  4105. "msg": "撤销目录对照成功",
  4106. })
  4107. } else {
  4108. c.ServeSuccessJSON(map[string]interface{}{
  4109. "failed_code": -10,
  4110. "msg": res.ErrMsg,
  4111. })
  4112. }
  4113. }
  4114. }
  4115. }
  4116. func (c *HisApiController) GetPatientInfo() {
  4117. id_card_no := c.GetString("id_card_no")
  4118. admin_user_id, _ := c.GetInt64("admin_user_id")
  4119. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4120. if patient.ID == 0 {
  4121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4122. return
  4123. }
  4124. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4126. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4127. if config.IsOpen == 1 {
  4128. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4129. var dat map[string]interface{}
  4130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4131. fmt.Println(dat)
  4132. } else {
  4133. fmt.Println(err)
  4134. }
  4135. userJSONBytes, _ := json.Marshal(dat)
  4136. var res ResultTwo
  4137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4138. utils.ErrorLog("解析失败:%v", err)
  4139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4140. return
  4141. }
  4142. if res.Infcode != 0 {
  4143. c.ServeSuccessJSON(map[string]interface{}{
  4144. "failed_code": -10,
  4145. "msg": res.ErrMsg,
  4146. })
  4147. } else {
  4148. c.ServeSuccessJSON(map[string]interface{}{
  4149. "failed_code": 0,
  4150. "info": res,
  4151. })
  4152. }
  4153. }
  4154. }
  4155. func (c *HisApiController) PsnPutOnRecord() {
  4156. record_type, _ := c.GetInt64("type")
  4157. patient_id, _ := c.GetInt64("patient_id")
  4158. admin_user_id, _ := c.GetInt64("admin_user_id")
  4159. start_time := c.GetString("start_time")
  4160. end_time := c.GetString("end_time")
  4161. adminUser := c.GetAdminUserInfo()
  4162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4163. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4164. var patients []*models.Patients
  4165. if record_type == 1 { //全部备案
  4166. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4167. patients = append(patients, patient...)
  4168. } else { //单个备案
  4169. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4170. patients = append(patients, patient)
  4171. }
  4172. var user_name string
  4173. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4174. if role.ID == 0 {
  4175. user_name = "xxx"
  4176. } else {
  4177. user_name = role.UserName
  4178. }
  4179. if config.IsOpen == 1 {
  4180. for _, item := range patients {
  4181. 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
  4182. resp, requestErr := http.Get(api)
  4183. if requestErr != nil {
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. return
  4186. }
  4187. defer resp.Body.Close()
  4188. body, ioErr := ioutil.ReadAll(resp.Body)
  4189. if ioErr != nil {
  4190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. return
  4193. }
  4194. var respJSON map[string]interface{}
  4195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4201. userJSONBytes, _ := json.Marshal(userJSON)
  4202. var res ResultTwo
  4203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4204. utils.ErrorLog("解析失败:%v", err)
  4205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4206. return
  4207. }
  4208. if res.Infcode == 0 {
  4209. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4210. var dat map[string]interface{}
  4211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4212. fmt.Println(dat)
  4213. } else {
  4214. fmt.Println(err)
  4215. }
  4216. userJSONBytes, _ := json.Marshal(dat)
  4217. var res2 ResultThirteen
  4218. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4219. utils.ErrorLog("解析失败:%v", err)
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4221. return
  4222. }
  4223. if res2.Infcode == 0 {
  4224. psnResult := &models.GdybPsnRecord{
  4225. UserOrgId: adminUser.CurrentOrgId,
  4226. PatientId: item.ID,
  4227. PsnNo: res.Output.Baseinfo.PsnNo,
  4228. Ctime: time.Now().Unix(),
  4229. Mtime: time.Now().Unix(),
  4230. Status: 1,
  4231. IsCancel: 1,
  4232. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4233. }
  4234. service.CreatePsnRecord(psnResult)
  4235. } else {
  4236. c.ServeSuccessJSON(map[string]interface{}{
  4237. "failed_code": -10,
  4238. "msg": res2.ErrMsg,
  4239. })
  4240. return
  4241. }
  4242. }
  4243. }
  4244. }
  4245. }
  4246. func (c *HisApiController) PsnUnPutOnRecord() {
  4247. id, _ := c.GetInt64("id")
  4248. //record_type, _ := c.GetInt64("type")
  4249. admin_user_id, _ := c.GetInt64("admin_user_id")
  4250. adminUser := c.GetAdminUserInfo()
  4251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4252. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4253. var user_name string
  4254. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4255. if role.ID == 0 {
  4256. user_name = "xxx"
  4257. } else {
  4258. user_name = role.UserName
  4259. }
  4260. psn_record, _ := service.GetPsnRecordById(id)
  4261. if psn_record.ID == 0 {
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4263. return
  4264. }
  4265. if config.IsOpen == 1 {
  4266. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4267. var dat map[string]interface{}
  4268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4269. fmt.Println(dat)
  4270. } else {
  4271. fmt.Println(err)
  4272. }
  4273. userJSONBytes, _ := json.Marshal(dat)
  4274. var res ResultFourteen
  4275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4276. utils.ErrorLog("解析失败:%v", err)
  4277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4278. return
  4279. }
  4280. if res.Infcode == 0 {
  4281. psn_record.IsCancel = 2
  4282. service.CreatePsnRecord(&psn_record)
  4283. } else {
  4284. c.ServeSuccessJSON(map[string]interface{}{
  4285. "failed_code": -10,
  4286. "msg": res.ErrMsg,
  4287. })
  4288. return
  4289. }
  4290. }
  4291. }
  4292. func (c *HisApiController) PsnPutNCDSOnRecord() {
  4293. patient_id, _ := c.GetInt64("patient_id")
  4294. insutype := c.GetString("insutype")
  4295. psn_no := c.GetString("psn_no")
  4296. doctor_id, _ := c.GetInt64("doctor_id")
  4297. sick_id, _ := c.GetInt64("sick_id")
  4298. department_id, _ := c.GetInt64("department_id")
  4299. adminUser := c.GetAdminUserInfo()
  4300. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4301. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4302. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4303. sick, _ := service.FindSickById(sick_id)
  4304. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  4305. if config.IsOpen == 1 {
  4306. 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)
  4307. var dat map[string]interface{}
  4308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4309. fmt.Println(dat)
  4310. } else {
  4311. fmt.Println(err)
  4312. }
  4313. userJSONBytes, _ := json.Marshal(dat)
  4314. var res2 ResultThirteen
  4315. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4316. utils.ErrorLog("解析失败:%v", err)
  4317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4318. return
  4319. }
  4320. if res2.Infcode == 0 {
  4321. psnResult := &models.GdybPsnNcdsRecord{
  4322. UserOrgId: adminUser.CurrentOrgId,
  4323. PatientId: patient.ID,
  4324. PsnNo: psn_no,
  4325. DoctorId: doctor.AdminUserId,
  4326. DepartmentId: department_id,
  4327. SickType: sick_id,
  4328. Insutype: insutype,
  4329. Ctime: time.Now().Unix(),
  4330. Mtime: time.Now().Unix(),
  4331. Status: 1,
  4332. IsCancel: 1,
  4333. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4334. }
  4335. service.CreatePsnNCDSRecord(psnResult)
  4336. c.ServeSuccessJSON(map[string]interface{}{
  4337. "failed_code": 0,
  4338. "msg": "备案成功",
  4339. "result": psnResult,
  4340. })
  4341. } else {
  4342. c.ServeSuccessJSON(map[string]interface{}{
  4343. "failed_code": -10,
  4344. "msg": res2.ErrMsg,
  4345. })
  4346. return
  4347. }
  4348. }
  4349. }
  4350. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  4351. id, _ := c.GetInt64("id")
  4352. admin_user_id, _ := c.GetInt64("admin_user_id")
  4353. adminUser := c.GetAdminUserInfo()
  4354. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4355. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4356. var user_name string
  4357. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4358. if role.ID == 0 {
  4359. user_name = "xxx"
  4360. } else {
  4361. user_name = role.UserName
  4362. }
  4363. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4364. if psn_record.ID == 0 {
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4366. return
  4367. }
  4368. if config.IsOpen == 1 {
  4369. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4370. var dat map[string]interface{}
  4371. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4372. fmt.Println(dat)
  4373. } else {
  4374. fmt.Println(err)
  4375. }
  4376. userJSONBytes, _ := json.Marshal(dat)
  4377. var res ResultFourteen
  4378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4379. utils.ErrorLog("解析失败:%v", err)
  4380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4381. return
  4382. }
  4383. if res.Infcode == 0 {
  4384. psn_record.IsCancel = 2
  4385. service.CreatePsnNCDSRecord(&psn_record)
  4386. c.ServeSuccessJSON(map[string]interface{}{
  4387. "failed_code": 0,
  4388. "msg": "撤销备案成功",
  4389. })
  4390. } else {
  4391. c.ServeSuccessJSON(map[string]interface{}{
  4392. "failed_code": -10,
  4393. "msg": res.ErrMsg,
  4394. })
  4395. return
  4396. }
  4397. }
  4398. }
  4399. func (c *HisApiController) TestTest() {
  4400. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  4401. fmt.Println(patient.Iinfo)
  4402. }
  4403. type CustomData struct {
  4404. MsgId string
  4405. PsnNo string
  4406. Info string
  4407. }
  4408. func (c *HisApiController) ReversalData() {
  4409. var customData []*CustomData
  4410. custom := &CustomData{
  4411. MsgId: "H44022900158202103301714472004",
  4412. PsnNo: "44020000001101329945",
  4413. Info: "2207",
  4414. }
  4415. customData = append(customData, custom)
  4416. custom1 := &CustomData{
  4417. MsgId: "H4402290015820210330172057803",
  4418. PsnNo: "44020000001101161813",
  4419. Info: "2207",
  4420. }
  4421. customData = append(customData, custom1)
  4422. custom2 := &CustomData{
  4423. MsgId: "H44022900158202103301705198813",
  4424. PsnNo: "44190000133097375417",
  4425. Info: "2207",
  4426. }
  4427. customData = append(customData, custom2)
  4428. custom3 := &CustomData{
  4429. MsgId: "H44022900158202103301715524756",
  4430. PsnNo: "44020000001100187221",
  4431. Info: "2207",
  4432. }
  4433. customData = append(customData, custom3)
  4434. custom4 := &CustomData{
  4435. MsgId: "H44022900158202103301730376224",
  4436. PsnNo: "44020000001101959155",
  4437. Info: "2207",
  4438. }
  4439. customData = append(customData, custom4)
  4440. custom5 := &CustomData{
  4441. MsgId: "H44022900158202103301748008725",
  4442. PsnNo: "44020000001104246641",
  4443. Info: "2207",
  4444. }
  4445. customData = append(customData, custom5)
  4446. custom6 := &CustomData{
  4447. MsgId: "H44022900158202103301718096755",
  4448. PsnNo: "44020000001102211860",
  4449. Info: "2207",
  4450. }
  4451. customData = append(customData, custom6)
  4452. custom7 := &CustomData{
  4453. MsgId: "H44022900158202103301736551640",
  4454. PsnNo: "44020000001102687718",
  4455. Info: "2207",
  4456. }
  4457. customData = append(customData, custom7)
  4458. custom8 := &CustomData{
  4459. MsgId: "H44022900158202103301743097676",
  4460. PsnNo: "44020000001102127785",
  4461. Info: "2207",
  4462. }
  4463. customData = append(customData, custom8)
  4464. custom9 := &CustomData{
  4465. MsgId: "H44022900158202103301712304203",
  4466. PsnNo: "44020000001101518097",
  4467. Info: "2207",
  4468. }
  4469. customData = append(customData, custom9)
  4470. custom10 := &CustomData{
  4471. MsgId: "H44022900158202103301738448785",
  4472. PsnNo: "44020000001100500813",
  4473. Info: "2207",
  4474. }
  4475. customData = append(customData, custom10)
  4476. custom11 := &CustomData{
  4477. MsgId: "H44022900158202103301732455843",
  4478. PsnNo: "44020000001102690557",
  4479. Info: "2207",
  4480. }
  4481. customData = append(customData, custom11)
  4482. custom12 := &CustomData{
  4483. MsgId: "H44022900158202103301745421708",
  4484. PsnNo: "44020000001102211928",
  4485. Info: "2207",
  4486. }
  4487. customData = append(customData, custom12)
  4488. custom1212 := &CustomData{
  4489. MsgId: "H440229001582021033017351627",
  4490. PsnNo: "44020000001102481733",
  4491. Info: "2207",
  4492. }
  4493. customData = append(customData, custom1212)
  4494. custom13 := &CustomData{
  4495. MsgId: "H44022900158202103301740327951",
  4496. PsnNo: "44020000001103174866",
  4497. Info: "2207",
  4498. }
  4499. customData = append(customData, custom13)
  4500. custom14 := &CustomData{
  4501. MsgId: "H4402290015820210330174922668",
  4502. PsnNo: "44020000001102927272",
  4503. Info: "2207",
  4504. }
  4505. customData = append(customData, custom14)
  4506. custom15 := &CustomData{
  4507. MsgId: "H44022900158202103301752362273",
  4508. PsnNo: "44020000001102942890",
  4509. Info: "2207",
  4510. }
  4511. customData = append(customData, custom15)
  4512. custom16 := &CustomData{
  4513. MsgId: "H44022900158202103301751082917",
  4514. PsnNo: "44020000001101662162",
  4515. Info: "2207",
  4516. }
  4517. customData = append(customData, custom16)
  4518. custom17 := &CustomData{
  4519. MsgId: "H44022900158202103301754147728",
  4520. PsnNo: "44020000000229014511",
  4521. Info: "2207",
  4522. }
  4523. customData = append(customData, custom17)
  4524. adminUser := c.GetAdminUserInfo()
  4525. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4526. for _, item := range customData {
  4527. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4528. fmt.Println(result)
  4529. }
  4530. }
  4531. func (c *HisApiController) ReversalOtherData() {
  4532. var customData []*CustomData
  4533. custom := &CustomData{
  4534. MsgId: "H44022900158202103301714472004",
  4535. PsnNo: "44020000001101329945",
  4536. Info: "2208",
  4537. }
  4538. customData = append(customData, custom)
  4539. custom1 := &CustomData{
  4540. MsgId: "H4402290015820210330172057803",
  4541. PsnNo: "44020000001101161813",
  4542. Info: "2208",
  4543. }
  4544. customData = append(customData, custom1)
  4545. custom2 := &CustomData{
  4546. MsgId: "H44022900158202103301705198813",
  4547. PsnNo: "44190000133097375417",
  4548. Info: "2208",
  4549. }
  4550. customData = append(customData, custom2)
  4551. custom3 := &CustomData{
  4552. MsgId: "H44022900158202103301715524756",
  4553. PsnNo: "44020000001100187221",
  4554. Info: "2208",
  4555. }
  4556. customData = append(customData, custom3)
  4557. custom4 := &CustomData{
  4558. MsgId: "H44022900158202103301730376224",
  4559. PsnNo: "44020000001101959155",
  4560. Info: "2208",
  4561. }
  4562. customData = append(customData, custom4)
  4563. custom5 := &CustomData{
  4564. MsgId: "H44022900158202103301748008725",
  4565. PsnNo: "44020000001104246641",
  4566. Info: "2208",
  4567. }
  4568. customData = append(customData, custom5)
  4569. custom6 := &CustomData{
  4570. MsgId: "H44022900158202103301718096755",
  4571. PsnNo: "44020000001102211860",
  4572. Info: "2208",
  4573. }
  4574. customData = append(customData, custom6)
  4575. custom7 := &CustomData{
  4576. MsgId: "H44022900158202103301736551640",
  4577. PsnNo: "44020000001102687718",
  4578. Info: "2208",
  4579. }
  4580. customData = append(customData, custom7)
  4581. custom8 := &CustomData{
  4582. MsgId: "H44022900158202103301743097676",
  4583. PsnNo: "44020000001102127785",
  4584. Info: "2208",
  4585. }
  4586. customData = append(customData, custom8)
  4587. custom9 := &CustomData{
  4588. MsgId: "H44022900158202103301712304203",
  4589. PsnNo: "44020000001101518097",
  4590. Info: "2208",
  4591. }
  4592. customData = append(customData, custom9)
  4593. custom10 := &CustomData{
  4594. MsgId: "H44022900158202103301738448785",
  4595. PsnNo: "44020000001100500813",
  4596. Info: "2208",
  4597. }
  4598. customData = append(customData, custom10)
  4599. custom11 := &CustomData{
  4600. MsgId: "H44022900158202103301732455843",
  4601. PsnNo: "44020000001102690557",
  4602. Info: "2208",
  4603. }
  4604. customData = append(customData, custom11)
  4605. custom12 := &CustomData{
  4606. MsgId: "H44022900158202103301745421708",
  4607. PsnNo: "44020000001102211928",
  4608. Info: "2208",
  4609. }
  4610. customData = append(customData, custom12)
  4611. custom1212 := &CustomData{
  4612. MsgId: "H440229001582021033017351627",
  4613. PsnNo: "44020000001102481733",
  4614. Info: "2208",
  4615. }
  4616. customData = append(customData, custom1212)
  4617. custom13 := &CustomData{
  4618. MsgId: "H44022900158202103301740327951",
  4619. PsnNo: "44020000001103174866",
  4620. Info: "2208",
  4621. }
  4622. customData = append(customData, custom13)
  4623. custom14 := &CustomData{
  4624. MsgId: "H4402290015820210330174922668",
  4625. PsnNo: "44020000001102927272",
  4626. Info: "2208",
  4627. }
  4628. customData = append(customData, custom14)
  4629. custom15 := &CustomData{
  4630. MsgId: "H44022900158202103301752362273",
  4631. PsnNo: "44020000001102942890",
  4632. Info: "2208",
  4633. }
  4634. customData = append(customData, custom15)
  4635. custom16 := &CustomData{
  4636. MsgId: "H44022900158202103301751082917",
  4637. PsnNo: "44020000001101662162",
  4638. Info: "2208",
  4639. }
  4640. customData = append(customData, custom16)
  4641. custom17 := &CustomData{
  4642. MsgId: "H44022900158202103301754147728",
  4643. PsnNo: "44020000000229014511",
  4644. Info: "2208",
  4645. }
  4646. customData = append(customData, custom17)
  4647. adminUser := c.GetAdminUserInfo()
  4648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4649. for _, item := range customData {
  4650. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4651. fmt.Println(result)
  4652. }
  4653. }
  4654. func PathExists(path string) (bool, error) {
  4655. _, err := os.Stat(path)
  4656. if err == nil {
  4657. return true, nil
  4658. }
  4659. if os.IsNotExist(err) {
  4660. return false, nil
  4661. }
  4662. return false, err
  4663. }
  4664. //创建文件夹
  4665. func Mkdir(dir string) {
  4666. // 创建文件夹
  4667. exist, err := PathExists(dir)
  4668. if err != nil {
  4669. fmt.Println(err.Error())
  4670. } else {
  4671. if exist {
  4672. fmt.Println(dir + "文件夹已存在!")
  4673. } else {
  4674. // 文件夹名称,权限
  4675. err := os.Mkdir(dir, os.ModePerm)
  4676. if err != nil {
  4677. fmt.Println(dir+"文件夹创建失败:", err.Error())
  4678. } else {
  4679. fmt.Println(dir + "文件夹创建成功!")
  4680. }
  4681. }
  4682. }
  4683. }
  4684. //压缩文件
  4685. func Zip(srcFile string, destZip string) error {
  4686. zipfile, err := os.Create(destZip)
  4687. if err != nil {
  4688. return err
  4689. }
  4690. defer zipfile.Close()
  4691. archive := zip.NewWriter(zipfile)
  4692. defer archive.Close()
  4693. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  4694. if err != nil {
  4695. return err
  4696. }
  4697. header, err := zip.FileInfoHeader(info)
  4698. if err != nil {
  4699. return err
  4700. }
  4701. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  4702. // header.Name = path
  4703. if info.IsDir() {
  4704. header.Name += "/"
  4705. } else {
  4706. header.Method = zip.Deflate
  4707. }
  4708. writer, err := archive.CreateHeader(header)
  4709. if err != nil {
  4710. return err
  4711. }
  4712. if !info.IsDir() {
  4713. file, err := os.Open(path)
  4714. if err != nil {
  4715. return err
  4716. }
  4717. defer file.Close()
  4718. _, err = io.Copy(writer, file)
  4719. }
  4720. return err
  4721. })
  4722. return err
  4723. }
  4724. func ReadFile(filePath string) []byte {
  4725. f, err := os.Open(filePath)
  4726. if err != nil {
  4727. fmt.Println("read file fail", err)
  4728. return nil
  4729. }
  4730. defer f.Close()
  4731. fd, err := ioutil.ReadAll(f)
  4732. if err != nil {
  4733. fmt.Println("read to fd fail", err)
  4734. return nil
  4735. }
  4736. return fd
  4737. }
  4738. func RemoveRepeatedCode(arr []string) (newArr []string) {
  4739. newArr = make([]string, 0)
  4740. for i := 0; i < len(arr); i++ {
  4741. repeat := false
  4742. for j := i + 1; j < len(arr); j++ {
  4743. if arr[i] == arr[j] {
  4744. repeat = true
  4745. break
  4746. }
  4747. }
  4748. if !repeat {
  4749. newArr = append(newArr, arr[i])
  4750. }
  4751. }
  4752. return
  4753. }