his_api_controller.go 201KB

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