his_api_controller.go 182KB

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