his_api_controller.go 271KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630
  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/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. fmt.Println("----------")
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  37. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  38. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  39. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  40. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  41. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  42. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  43. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  44. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  45. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  46. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  47. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  48. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  49. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. //备案撤销相关接口
  56. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  57. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  58. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  59. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  60. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  61. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  62. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  63. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  64. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  67. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  68. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  69. //beego.Router("/api/checkdetailaccount/handle", &HisApiController{}, "get:HandleCheckDetailAccount")
  70. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  71. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  72. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  73. }
  74. func (c *HisApiController) CheckInsutype() {
  75. his_patient_id, _ := c.GetInt64("his_patient_id")
  76. admin_user_id, _ := c.GetInt64("admin_user_id")
  77. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  78. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  79. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  80. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  81. var dat map[string]interface{}
  82. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  83. fmt.Println(dat)
  84. } else {
  85. fmt.Println(err)
  86. }
  87. userJSONBytes, _ := json.Marshal(dat)
  88. var res Result90100
  89. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  90. utils.ErrorLog("解析失败:%v", err)
  91. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  92. return
  93. }
  94. if res.Infcode != 0 {
  95. c.ServeSuccessJSON(map[string]interface{}{
  96. "failed_code": -10,
  97. "msg": res.ErrMsg,
  98. })
  99. return
  100. } else {
  101. fmt.Println(res)
  102. }
  103. }
  104. func (c *HisApiController) CheckCardPWD() {
  105. card_pwd := c.GetString("card_pwd")
  106. his_patient_id, _ := c.GetInt64("his_patient_id")
  107. admin_user_id, _ := c.GetInt64("admin_user_id")
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  110. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  111. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  112. var dat map[string]interface{}
  113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  114. fmt.Println(dat)
  115. } else {
  116. fmt.Println(err)
  117. }
  118. userJSONBytes, _ := json.Marshal(dat)
  119. var res Result90991
  120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  121. utils.ErrorLog("解析失败:%v", err)
  122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  123. return
  124. }
  125. if res.Infcode != 0 {
  126. c.ServeSuccessJSON(map[string]interface{}{
  127. "failed_code": -10,
  128. "msg": res.ErrMsg,
  129. })
  130. return
  131. } else {
  132. if res.Output.Result.CheckStat == "0" {
  133. var msg string
  134. switch res.Output.Result.CardStat {
  135. case "00":
  136. msg = "未激活"
  137. break
  138. case "10":
  139. msg = "激活"
  140. break
  141. case "20":
  142. msg = "窗口挂失"
  143. break
  144. case "21":
  145. msg = "电话挂失"
  146. break
  147. case "22":
  148. msg = "单位网上申报挂失"
  149. break
  150. case "23":
  151. msg = "保健办挂失"
  152. break
  153. case "24":
  154. msg = "个人网上挂失"
  155. break
  156. case "25":
  157. msg = "网上服务大厅挂失"
  158. break
  159. case "30":
  160. msg = "注销"
  161. break
  162. case "40":
  163. msg = "回收"
  164. break
  165. case "99":
  166. msg = "制卡中(无效卡)"
  167. break
  168. }
  169. c.ServeSuccessJSON(map[string]interface{}{
  170. "failed_code": -10,
  171. "msg": msg,
  172. })
  173. return
  174. } else {
  175. c.ServeSuccessJSON(map[string]interface{}{
  176. "msg": "校验成功",
  177. })
  178. return
  179. }
  180. }
  181. }
  182. func (c *HisApiController) ReadCard() {
  183. id_card_type, _ := c.GetInt64("id_card_type")
  184. admin_user_id, _ := c.GetInt64("admin_user_id")
  185. certificates, _ := c.GetInt64("certificates")
  186. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  187. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  189. switch id_card_type {
  190. case 1:
  191. if miConfig.MdtrtareaAdmvs == "421300" {
  192. var res ResultTwo
  193. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  194. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  195. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  196. resp, requestErr := http.Get(api)
  197. if requestErr != nil {
  198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  199. return
  200. }
  201. body, ioErr := ioutil.ReadAll(resp.Body)
  202. if ioErr != nil {
  203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. var respJSON map[string]interface{}
  208. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  224. if err == gorm.ErrRecordNotFound {
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  226. return
  227. } else if err != nil {
  228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  229. return
  230. } else {
  231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  233. infoStr := string(Iinfos)
  234. idetinfoStr := string(Idetinfos)
  235. psn := &models.HisPsn{
  236. PsnNo: res.Output.Baseinfo.PsnNo,
  237. Age: res.Output.Baseinfo.Age,
  238. PatientId: patient.ID,
  239. Certno: res.Output.Baseinfo.Certno,
  240. Brdy: res.Output.Baseinfo.Brdy,
  241. Gend: res.Output.Baseinfo.Gend,
  242. Naty: res.Output.Baseinfo.Naty,
  243. PsnCertType: res.Output.Baseinfo.PsnCertType,
  244. PsnName: res.Output.Baseinfo.PsnName,
  245. Idetinfo: idetinfoStr,
  246. Insuinfo: infoStr,
  247. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  248. }
  249. service.CreateHisPsn(psn)
  250. c.ServeSuccessJSON(map[string]interface{}{
  251. "patient": patient,
  252. "number": res.Output.Baseinfo.Certno,
  253. })
  254. }
  255. } else {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  257. return
  258. }
  259. } else {
  260. if initFlag == 0 {
  261. c.TestGetBasBaseInit()
  262. }
  263. basStr := c.GetBasBaseInfo()
  264. if len(basStr) == 0 {
  265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  266. return
  267. }
  268. fmt.Println(basStr)
  269. bas := strings.Split(basStr, "|")
  270. basNumber := bas[1]
  271. fmt.Println(basNumber)
  272. card_sn := bas[3]
  273. fmt.Println(card_sn)
  274. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  275. var dat map[string]interface{}
  276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  277. fmt.Println(dat)
  278. } else {
  279. fmt.Println(err)
  280. }
  281. userJSONBytes, _ := json.Marshal(dat)
  282. var res ResultTwo
  283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  284. utils.ErrorLog("解析失败:%v", err)
  285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  286. return
  287. }
  288. if res.Infcode == 0 {
  289. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  290. if err == gorm.ErrRecordNotFound {
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  292. return
  293. } else if err != nil {
  294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  295. return
  296. } else {
  297. c.ServeSuccessJSON(map[string]interface{}{
  298. "patient": patient,
  299. "number": basNumber,
  300. })
  301. }
  302. } else {
  303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  304. return
  305. }
  306. break
  307. }
  308. case 2:
  309. SFZStr := c.GetSFZBaseInfo()
  310. id_card_str := strings.Split(SFZStr, "^")
  311. id_card_number := id_card_str[0]
  312. card_sn := ""
  313. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  314. var dat map[string]interface{}
  315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  316. fmt.Println(dat)
  317. } else {
  318. fmt.Println(err)
  319. }
  320. userJSONBytes, _ := json.Marshal(dat)
  321. var res ResultTwo
  322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  323. utils.ErrorLog("解析失败:%v", err)
  324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  325. return
  326. }
  327. if res.Infcode == 0 {
  328. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  329. if err == gorm.ErrRecordNotFound {
  330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  331. return
  332. } else if err != nil {
  333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  334. return
  335. } else {
  336. c.ServeSuccessJSON(map[string]interface{}{
  337. "patient": patient,
  338. "number": id_card_number,
  339. })
  340. }
  341. } else {
  342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  343. return
  344. }
  345. break
  346. case 3:
  347. break
  348. }
  349. }
  350. var initFlag int64 = 0
  351. func (c *HisApiController) TestGetBasBaseInit() {
  352. DllDef := syscall.MustLoadDLL("SSCard.dll")
  353. Iinit := DllDef.MustFindProc("Init")
  354. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  355. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  356. if ret != 0 {
  357. fmt.Println("SSCard的报错原因:", err)
  358. fmt.Println("SSCard的运算结果为:", ret)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  360. return
  361. }
  362. result := int(ret)
  363. fmt.Println("SSCard的运算结果为1:", result)
  364. initFlag = 1
  365. return
  366. }
  367. func (c *HisApiController) GetSFZBaseInfo() string {
  368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  369. readCard := DllDef.MustFindProc("ReadSFZ")
  370. if readCard == nil {
  371. fmt.Println("readcard is nil")
  372. readCard = DllDef.MustFindProc("ReadSFZ")
  373. }
  374. str := make([]byte, 256)
  375. str1 := make([]byte, 256)
  376. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  377. fmt.Println(r)
  378. return string(str)
  379. }
  380. func (c *HisApiController) GetBasBaseInfo() string {
  381. DllDef := syscall.MustLoadDLL("SSCard.dll")
  382. readCard := DllDef.MustFindProc("ReadCardBas")
  383. if readCard == nil {
  384. fmt.Println("readcard is nil")
  385. readCard = DllDef.MustFindProc("ReadCardBas")
  386. }
  387. str := make([]byte, 1024)
  388. str1 := make([]byte, 1024)
  389. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  390. fmt.Println(string(str1))
  391. fmt.Println(string(str))
  392. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  393. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  394. if ret2 != 0 {
  395. return ""
  396. }
  397. return string(str)
  398. }
  399. func prttostr(vcode uintptr) string {
  400. var vbyte []byte
  401. for i := 0; i < 10; i++ {
  402. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  403. if sbyte == 0 {
  404. break
  405. }
  406. vbyte = append(vbyte, sbyte)
  407. vcode += 1
  408. }
  409. return string(vbyte)
  410. }
  411. type CustomFundPay struct {
  412. FundPayType string `json:"fund_pay_type"`
  413. FundPayamt float64 `json:"fund_payamt"`
  414. }
  415. func (c *HisApiController) GetSettleList() {
  416. order_id, _ := c.GetInt64("order_id")
  417. admin_user_id, _ := c.GetInt64("admin_user_id")
  418. order, _ := service.GetHisOrderByIDTwo(order_id)
  419. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  420. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  421. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  422. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  423. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  425. if order.ID == 0 {
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  427. return
  428. }
  429. struct4101 := service.Struct4101{
  430. PsnNo: order.PsnNo,
  431. MdtrtId: order.MdtrtId,
  432. SetlId: order.SetlId,
  433. PsnName: order.PsnName,
  434. Gend: order.Gend,
  435. Brdy: his.Brdy,
  436. Age: his.Age,
  437. Naty: order.Naty,
  438. PatnCertType: "01",
  439. Certno: order.Certno,
  440. Prfs: "90",
  441. ConerName: roles[0].UserName,
  442. PatnRlts: "99",
  443. ConerAddr: miConfig.OrgName,
  444. ConerTel: admin.Mobile,
  445. HiType: order.Insutype,
  446. Insuplc: miConfig.InsuplcAdmdvs,
  447. MaindiagFlag: "1",
  448. BillCode: order.FaPiaoCode,
  449. BillNo: order.FaPiaoNumber,
  450. BizSn: order.Number,
  451. PsnSelfPay: order.PsnPartAmt,
  452. PsnOwnPay: order.PsnPartAmt,
  453. AcctPay: order.AcctPay,
  454. PsnCashpay: order.PsnCashPay,
  455. HiPaymtd: "1",
  456. Hsorg: miConfig.InsuplcAdmdvs,
  457. HsorgOpter: miConfig.InsuplcAdmdvs,
  458. MedinsFillPsn: curRoles.UserName,
  459. MedinsFillDept: depart.Name,
  460. IptMedType: "2",
  461. }
  462. struct4101.SetlBegnDate = order.SetlTime
  463. struct4101.SetlEndDate = order.SetlTime
  464. //if order.SettleType == 1 {
  465. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  466. // dateStr := t.Format("2006-01-02")
  467. // struct4101.SetlBegnDate = dateStr
  468. // struct4101.SetlEndDate = dateStr
  469. //} else {
  470. // t := time.Unix(int64(order.SettleStartTime), 0)
  471. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  472. // dateStartStr := t.Format("2006-01-02")
  473. // dateEndStr := t2.Format("2006-01-02")
  474. // struct4101.SetlBegnDate = dateStartStr
  475. // struct4101.SetlEndDate = dateEndStr
  476. //}
  477. var rf []CustomFundPay
  478. json.Unmarshal([]byte(order.SetlDetail), &rf)
  479. var tempFunPays []service.CustomStruct
  480. for _, item := range rf {
  481. var tempFunPay service.CustomStruct
  482. tempFunPay.FundPayamt = item.FundPayamt
  483. tempFunPay.FundPayType = item.FundPayType
  484. tempFunPays = append(tempFunPays, tempFunPay)
  485. }
  486. struct4101.CustomStruct = tempFunPays
  487. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  488. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  489. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  490. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  491. var config []*models.HisXtDiagnoseConfig
  492. for _, item := range diagnosis_ids {
  493. id, _ := strconv.ParseInt(item, 10, 64)
  494. diagnosisConfig, _ := service.FindDiagnoseById(id)
  495. config = append(config, &diagnosisConfig)
  496. }
  497. for _, item := range config {
  498. var tempOpspdiseinfo service.OpspdiseinfoStruct
  499. tempOpspdiseinfo.DiagCode = item.CountryCode
  500. tempOpspdiseinfo.DiagName = item.CountryContentName
  501. tempOpspdiseinfo.MaindiagFlag = "1"
  502. tempOpspdiseinfo.OprnOprtCode = ""
  503. tempOpspdiseinfo.OprnOprtName = ""
  504. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  505. }
  506. sickConfigTwo, _ := service.FindSickById(his.SickType)
  507. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  508. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  509. tempOpspdiseinfo2.MaindiagFlag = "2"
  510. tempOpspdiseinfo2.OprnOprtCode = ""
  511. tempOpspdiseinfo2.OprnOprtName = ""
  512. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  513. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  514. var iteminfo service.IteminfoStruct
  515. var bedCostTotal float64 = 0 //床位总费
  516. var bedCostSelfTotal float64 = 0 //床位自费
  517. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  518. var operationCostTotal float64 = 0 //手术费
  519. var operationCostSelfTotal float64 = 0 //手术费
  520. var operationCostPartSelfTotal float64 = 0 //手术费
  521. var otherCostTotal float64 = 0 //其他费用
  522. var otherCostSelfTotal float64 = 0 //其他费用
  523. var otherCostPartSelfTotal float64 = 0 //其他费用
  524. var materialCostTotal float64 = 0 //材料费
  525. var materialCostSelfTotal float64 = 0 //材料费
  526. var materialCostPartSelfTotal float64 = 0 //材料费
  527. var westernMedicineCostTotal float64 = 0 //西药费
  528. var westernMedicineCostSelfTotal float64 = 0 //西药费
  529. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  530. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  531. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  532. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  533. var checkCostTotal float64 = 0 //检查费
  534. var checkCostSelfTotal float64 = 0 //检查费
  535. var checkCostPartSelfTotal float64 = 0 //检查费
  536. var laboratoryCostTotal float64 = 0 //化验费
  537. var laboratoryCostSelfTotal float64 = 0 //化验费
  538. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  539. var treatCostTotal float64 = 0 //治疗费用
  540. var treatCostSelfTotal float64 = 0 //治疗费用
  541. var treatCostPartSelfTotal float64 = 0 //治疗费用
  542. decimal.DivisionPrecision = 2
  543. var bed_fulamt_ownpay_amt float64 = 0
  544. var operation_fulamt_ownpay_amt float64 = 0
  545. var other_fulamt_ownpay_amt float64 = 0
  546. var westernMedicine_fulamt_ownpay_amt float64 = 0
  547. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  548. var check_fulamt_ownpay_amt float64 = 0
  549. var material_fulamt_ownpay_amt float64 = 0
  550. var laboratory_fulamt_ownpay_amt float64 = 0
  551. var treat_fulamt_ownpay_amt float64 = 0
  552. var bed_claa_sunmfee float64 = 0
  553. var bed_clab_amt float64 = 0
  554. var bed_other_amt float64 = 0
  555. var operation_claa_sunmfee float64 = 0
  556. var operation_clab_amt float64 = 0
  557. var operation_other_amt float64 = 0
  558. var other_claa_sunmfee float64 = 0
  559. var other_clab_amt float64 = 0
  560. var other_other_amt float64 = 0
  561. var westernMedicine_claa_sunmfee float64 = 0
  562. var westernMedicine_clab_amt float64 = 0
  563. var westernMedicine_other_amt float64 = 0
  564. var chineseTraditional_claa_sunmfee float64 = 0
  565. var chineseTraditional_clab_amt float64 = 0
  566. var chineseTraditional_other_amt float64 = 0
  567. var check_claa_sunmfee float64 = 0
  568. var check_clab_amt float64 = 0
  569. var check_other_amt float64 = 0
  570. var material_claa_sunmfee float64 = 0
  571. var material_clab_amt float64 = 0
  572. var material_other_amt float64 = 0
  573. var laboratory_claa_sunmfee float64 = 0
  574. var laboratory_clab_amt float64 = 0
  575. var laboratory_other_amt float64 = 0
  576. var treat_claa_sunmfee float64 = 0
  577. var treat_clab_amt float64 = 0
  578. var treat_other_amt float64 = 0
  579. for _, item := range order.HisOrderInfo {
  580. if item.MedChrgitmType == "01" { //床位费
  581. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  582. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  583. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  584. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  585. if item.ChrgitmLv == "1" {
  586. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  587. }
  588. if item.ChrgitmLv == "2" {
  589. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  590. }
  591. if item.ChrgitmLv == "3" {
  592. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  593. }
  594. }
  595. if item.MedChrgitmType == "03" { //检查费
  596. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  597. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  598. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  599. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  600. if item.ChrgitmLv == "1" {
  601. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  602. }
  603. if item.ChrgitmLv == "2" {
  604. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  605. }
  606. if item.ChrgitmLv == "3" {
  607. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  608. }
  609. }
  610. if item.MedChrgitmType == "04" { //化验费
  611. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  612. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  613. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  614. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  615. if item.ChrgitmLv == "1" {
  616. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  617. }
  618. if item.ChrgitmLv == "2" {
  619. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  620. }
  621. if item.ChrgitmLv == "3" {
  622. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  623. }
  624. }
  625. if item.MedChrgitmType == "05" { //治疗费
  626. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  627. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  628. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  629. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  630. if item.ChrgitmLv == "1" {
  631. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  632. }
  633. if item.ChrgitmLv == "2" {
  634. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  635. }
  636. if item.ChrgitmLv == "3" {
  637. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  638. }
  639. }
  640. if item.MedChrgitmType == "06" { //手术费
  641. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  642. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  643. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  644. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  645. if item.ChrgitmLv == "1" {
  646. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  647. }
  648. if item.ChrgitmLv == "2" {
  649. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  650. }
  651. if item.ChrgitmLv == "3" {
  652. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  653. }
  654. }
  655. if item.MedChrgitmType == "08" { //材料费
  656. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  657. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  658. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  659. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  660. if item.ChrgitmLv == "1" {
  661. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  662. }
  663. if item.ChrgitmLv == "2" {
  664. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  665. }
  666. if item.ChrgitmLv == "3" {
  667. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  668. }
  669. }
  670. if item.MedChrgitmType == "09" { //西药费
  671. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  672. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  673. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  674. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  675. if item.ChrgitmLv == "1" {
  676. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  677. }
  678. if item.ChrgitmLv == "2" {
  679. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  680. }
  681. if item.ChrgitmLv == "3" {
  682. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  683. }
  684. }
  685. if item.MedChrgitmType == "11" { //中成费
  686. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  687. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  688. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  689. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  690. if item.ChrgitmLv == "1" {
  691. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  692. }
  693. if item.ChrgitmLv == "2" {
  694. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  695. }
  696. if item.ChrgitmLv == "3" {
  697. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  698. }
  699. }
  700. if item.MedChrgitmType == "14" { //其他费
  701. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  702. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  703. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  704. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  705. if item.ChrgitmLv == "1" {
  706. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  707. }
  708. if item.ChrgitmLv == "2" {
  709. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  710. }
  711. if item.ChrgitmLv == "3" {
  712. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  713. }
  714. }
  715. }
  716. var iteminfoStructs []service.IteminfoStruct
  717. if bedCostTotal != 0 {
  718. iteminfo.MedChrgitm = "01"
  719. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  720. iteminfo.Amt = bedCostTotal
  721. iteminfo.ClaaSumfee = bed_claa_sunmfee
  722. iteminfo.ClabAmt = bed_clab_amt
  723. iteminfo.OthAmt = bed_other_amt
  724. iteminfoStructs = append(iteminfoStructs, iteminfo)
  725. }
  726. if checkCostTotal != 0 {
  727. iteminfo.MedChrgitm = "03"
  728. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  729. iteminfo.Amt = checkCostTotal
  730. iteminfo.ClaaSumfee = check_claa_sunmfee
  731. iteminfo.ClabAmt = check_clab_amt
  732. iteminfo.OthAmt = check_other_amt
  733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  734. }
  735. if laboratoryCostTotal != 0 {
  736. iteminfo.MedChrgitm = "04"
  737. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  738. iteminfo.Amt = laboratoryCostTotal
  739. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  740. iteminfo.ClabAmt = laboratory_clab_amt
  741. iteminfo.OthAmt = laboratory_other_amt
  742. iteminfoStructs = append(iteminfoStructs, iteminfo)
  743. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  744. }
  745. if treatCostTotal != 0 {
  746. iteminfo.MedChrgitm = "05"
  747. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  748. iteminfo.Amt = treatCostTotal
  749. iteminfo.ClaaSumfee = treat_claa_sunmfee
  750. iteminfo.ClabAmt = treat_clab_amt
  751. iteminfo.OthAmt = treat_other_amt
  752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  753. //(struct4101.IteminfoStruct, iteminfo)
  754. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  755. }
  756. if operationCostTotal != 0 {
  757. iteminfo.MedChrgitm = "06"
  758. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  759. iteminfo.Amt = operationCostTotal
  760. iteminfo.ClaaSumfee = operation_claa_sunmfee
  761. iteminfo.ClabAmt = operation_clab_amt
  762. iteminfo.OthAmt = operation_other_amt
  763. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  764. iteminfoStructs = append(iteminfoStructs, iteminfo)
  765. }
  766. if materialCostTotal != 0 {
  767. iteminfo.MedChrgitm = "08"
  768. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  769. iteminfo.Amt = materialCostTotal
  770. iteminfo.ClaaSumfee = material_claa_sunmfee
  771. iteminfo.ClabAmt = material_clab_amt
  772. iteminfo.OthAmt = material_other_amt
  773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  774. iteminfoStructs = append(iteminfoStructs, iteminfo)
  775. }
  776. if westernMedicineCostTotal != 0 {
  777. iteminfo.MedChrgitm = "09"
  778. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  779. iteminfo.Amt = westernMedicineCostTotal
  780. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  781. iteminfo.ClabAmt = westernMedicine_clab_amt
  782. iteminfo.OthAmt = westernMedicine_other_amt
  783. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  784. iteminfoStructs = append(iteminfoStructs, iteminfo)
  785. }
  786. if chineseTraditionalMedicineCostTotal != 0 {
  787. iteminfo.MedChrgitm = "11"
  788. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  789. iteminfo.Amt = westernMedicineCostTotal
  790. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  791. iteminfo.ClabAmt = westernMedicine_clab_amt
  792. iteminfo.OthAmt = westernMedicine_other_amt
  793. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  795. }
  796. if otherCostTotal != 0 {
  797. iteminfo.MedChrgitm = "14"
  798. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  799. iteminfo.Amt = otherCostTotal
  800. iteminfo.ClaaSumfee = other_claa_sunmfee
  801. iteminfo.ClabAmt = other_clab_amt
  802. iteminfo.OthAmt = other_other_amt
  803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  805. }
  806. struct4101.IteminfoStruct = iteminfoStructs
  807. struct4101.Ntly = "中国"
  808. struct4101.AdmCaty = "A03.06"
  809. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  810. fmt.Println(result)
  811. var dat map[string]interface{}
  812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  813. fmt.Println(dat)
  814. } else {
  815. fmt.Println(err)
  816. }
  817. userJSONBytes, _ := json.Marshal(dat)
  818. var res ResultSeventeen
  819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  820. utils.ErrorLog("解析失败:%v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. if res.Infcode != 0 {
  825. c.ServeSuccessJSON(map[string]interface{}{
  826. "failed_code": -10,
  827. "msg": res.ErrMsg,
  828. })
  829. return
  830. } else {
  831. hisFundSettleListResult := &models.HisFundSettleListResult{
  832. Number: res.Output.SetlListId,
  833. Status: 1,
  834. Ctime: time.Now().Unix(),
  835. Mtime: time.Now().Unix(),
  836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  837. IsUpload: 1,
  838. OrderId: order_id,
  839. }
  840. service.CreateUploadRecord(hisFundSettleListResult)
  841. c.ServeSuccessJSON(map[string]interface{}{
  842. "msg": "上传成功",
  843. "result": hisFundSettleListResult,
  844. })
  845. return
  846. }
  847. }
  848. func (c *HisApiController) GetBatchSettleList() {
  849. org_id, _ := beego.AppConfig.Int64("org_id")
  850. //stage, _ := c.GetInt64("stage")
  851. orders, _ := service.GetAllHisOrder(org_id)
  852. for _, item := range orders {
  853. order_id := item.ID
  854. order, _ := service.GetHisOrderByIDTwo(order_id)
  855. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  856. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  857. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  858. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  859. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. if order.ID == 0 {
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  863. return
  864. }
  865. if his.BalanceAccountsType == 2 {
  866. continue
  867. }
  868. struct4101 := service.Struct4101{
  869. PsnNo: order.PsnNo,
  870. MdtrtId: order.MdtrtId,
  871. SetlId: order.SetlId,
  872. PsnName: order.PsnName,
  873. Gend: order.Gend,
  874. Brdy: his.Brdy,
  875. Age: his.Age,
  876. Naty: order.Naty,
  877. PatnCertType: "01",
  878. Certno: order.Certno,
  879. Prfs: "90",
  880. ConerName: roles[0].UserName,
  881. PatnRlts: "99",
  882. ConerAddr: miConfig.OrgName,
  883. ConerTel: admin.Mobile,
  884. HiType: order.Insutype,
  885. Insuplc: miConfig.InsuplcAdmdvs,
  886. MaindiagFlag: "1",
  887. BillCode: order.FaPiaoCode,
  888. BillNo: order.FaPiaoNumber,
  889. BizSn: order.Number,
  890. PsnSelfPay: order.PsnPartAmt,
  891. PsnOwnPay: order.PsnPartAmt,
  892. AcctPay: order.AcctPay,
  893. PsnCashpay: order.PsnCashPay,
  894. HiPaymtd: "1",
  895. Hsorg: miConfig.InsuplcAdmdvs,
  896. HsorgOpter: miConfig.InsuplcAdmdvs,
  897. MedinsFillPsn: curRoles.UserName,
  898. MedinsFillDept: depart.Name,
  899. IptMedType: "2",
  900. }
  901. struct4101.SetlBegnDate = order.SetlTime
  902. struct4101.SetlEndDate = order.SetlTime
  903. //if order.SettleType == 1 {
  904. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  905. // dateStr := t.Format("2006-01-02")
  906. // struct4101.SetlBegnDate = dateStr
  907. // struct4101.SetlEndDate = dateStr
  908. //} else {
  909. // t := time.Unix(int64(order.SettleStartTime), 0)
  910. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  911. // dateStartStr := t.Format("2006-01-02")
  912. // dateEndStr := t2.Format("2006-01-02")
  913. // struct4101.SetlBegnDate = dateStartStr
  914. // struct4101.SetlEndDate = dateEndStr
  915. //}
  916. var rf []CustomFundPay
  917. json.Unmarshal([]byte(order.SetlDetail), &rf)
  918. var tempFunPays []service.CustomStruct
  919. var tempFunPay610100 service.CustomStruct
  920. for _, item := range rf {
  921. if item.FundPayType == "610100" {
  922. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  923. tempFunPay610100.FundPayType = item.FundPayType
  924. } else {
  925. var tempFunPay service.CustomStruct
  926. tempFunPay.FundPayamt = item.FundPayamt
  927. tempFunPay.FundPayType = item.FundPayType
  928. tempFunPays = append(tempFunPays, tempFunPay)
  929. }
  930. }
  931. tempFunPays = append(tempFunPays, tempFunPay610100)
  932. struct4101.CustomStruct = tempFunPays
  933. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  934. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  935. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  936. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  937. var config []*models.HisXtDiagnoseConfig
  938. for _, item := range diagnosis_ids {
  939. id, _ := strconv.ParseInt(item, 10, 64)
  940. diagnosisConfig, _ := service.FindDiagnoseById(id)
  941. config = append(config, &diagnosisConfig)
  942. }
  943. for _, item := range config {
  944. var tempOpspdiseinfo service.OpspdiseinfoStruct
  945. tempOpspdiseinfo.DiagCode = item.CountryCode
  946. tempOpspdiseinfo.DiagName = item.CountryContentName
  947. tempOpspdiseinfo.MaindiagFlag = "1"
  948. tempOpspdiseinfo.OprnOprtCode = ""
  949. tempOpspdiseinfo.OprnOprtName = ""
  950. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  951. }
  952. sickConfigTwo, _ := service.FindSickById(his.SickType)
  953. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  954. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  955. tempOpspdiseinfo2.MaindiagFlag = "2"
  956. tempOpspdiseinfo2.OprnOprtCode = ""
  957. tempOpspdiseinfo2.OprnOprtName = ""
  958. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  959. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  960. var iteminfo service.IteminfoStruct
  961. var bedCostTotal float64 = 0 //床位总费
  962. var bedCostSelfTotal float64 = 0 //床位自费
  963. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  964. var examineCostTotal float64 = 0 //诊查总费
  965. var examineCostSelfTotal float64 = 0 //诊查自费
  966. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  967. var nursingCostTotal float64 = 0 //护理总费
  968. var nursingCostSelfTotal float64 = 0 //护理自费
  969. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  970. var chineseMedicineCostTotal float64 = 0 //中成药
  971. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  972. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  973. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  974. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  975. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  976. var registerCostTotal float64 = 0 //一般诊疗费
  977. var registerCostSelfTotal float64 = 0 //一般诊疗费
  978. var registerPartSelfTotal float64 = 0 //一般诊疗费
  979. var operationCostTotal float64 = 0 //手术费
  980. var operationCostSelfTotal float64 = 0 //手术费
  981. var operationCostPartSelfTotal float64 = 0 //手术费
  982. var otherCostTotal float64 = 0 //其他费用
  983. var otherCostSelfTotal float64 = 0 //其他费用
  984. var otherCostPartSelfTotal float64 = 0 //其他费用
  985. var materialCostTotal float64 = 0 //材料费
  986. var materialCostSelfTotal float64 = 0 //材料费
  987. var materialCostPartSelfTotal float64 = 0 //材料费
  988. var westernMedicineCostTotal float64 = 0 //西药费
  989. var westernMedicineCostSelfTotal float64 = 0 //西药费
  990. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  991. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  992. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  993. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  994. var checkCostTotal float64 = 0 //检查费
  995. var checkCostSelfTotal float64 = 0 //检查费
  996. var checkCostPartSelfTotal float64 = 0 //检查费
  997. var laboratoryCostTotal float64 = 0 //化验费
  998. var laboratoryCostSelfTotal float64 = 0 //化验费
  999. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1000. var treatCostTotal float64 = 0 //治疗费用
  1001. var treatCostSelfTotal float64 = 0 //治疗费用
  1002. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1003. decimal.DivisionPrecision = 2
  1004. var bed_fulamt_ownpay_amt float64 = 0
  1005. var examine_fulamt_ownpay_amt float64 = 0
  1006. var nursing_fulamt_ownpay_amt float64 = 0
  1007. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1008. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1009. var register_fulamt_ownpay_amt float64 = 0
  1010. var operation_fulamt_ownpay_amt float64 = 0
  1011. var other_fulamt_ownpay_amt float64 = 0
  1012. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1013. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1014. var check_fulamt_ownpay_amt float64 = 0
  1015. var material_fulamt_ownpay_amt float64 = 0
  1016. var laboratory_fulamt_ownpay_amt float64 = 0
  1017. var treat_fulamt_ownpay_amt float64 = 0
  1018. var bed_claa_sunmfee float64 = 0
  1019. var bed_clab_amt float64 = 0
  1020. var bed_other_amt float64 = 0
  1021. var examine_claa_sunmfee float64 = 0
  1022. var examine_clab_amt float64 = 0
  1023. var examine_other_amt float64 = 0
  1024. var nursing_claa_sunmfee float64 = 0
  1025. var nursing_clab_amt float64 = 0
  1026. var nursing_other_amt float64 = 0
  1027. var chinese_medicine_claa_sunmfee float64 = 0
  1028. var chinese_medicine_clab_amt float64 = 0
  1029. var chinese_medicine_other_amt float64 = 0
  1030. var commonly_treatment_claa_sunmfee float64 = 0
  1031. var commonly_treatment_clab_amt float64 = 0
  1032. var commonly_treatment_other_amt float64 = 0
  1033. var operation_claa_sunmfee float64 = 0
  1034. var operation_clab_amt float64 = 0
  1035. var operation_other_amt float64 = 0
  1036. var other_claa_sunmfee float64 = 0
  1037. var other_clab_amt float64 = 0
  1038. var other_other_amt float64 = 0
  1039. var westernMedicine_claa_sunmfee float64 = 0
  1040. var westernMedicine_clab_amt float64 = 0
  1041. var westernMedicine_other_amt float64 = 0
  1042. var chineseTraditional_claa_sunmfee float64 = 0
  1043. var chineseTraditional_clab_amt float64 = 0
  1044. var chineseTraditional_other_amt float64 = 0
  1045. var check_claa_sunmfee float64 = 0
  1046. var check_clab_amt float64 = 0
  1047. var check_other_amt float64 = 0
  1048. var material_claa_sunmfee float64 = 0
  1049. var material_clab_amt float64 = 0
  1050. var material_other_amt float64 = 0
  1051. var laboratory_claa_sunmfee float64 = 0
  1052. var laboratory_clab_amt float64 = 0
  1053. var laboratory_other_amt float64 = 0
  1054. var treat_claa_sunmfee float64 = 0
  1055. var treat_clab_amt float64 = 0
  1056. var treat_other_amt float64 = 0
  1057. var register_claa_sunmfee float64 = 0
  1058. var register_clab_amt float64 = 0
  1059. var register_other_amt float64 = 0
  1060. for _, item := range order.HisOrderInfo {
  1061. if item.MedChrgitmType == "01" { //床位费
  1062. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1063. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1064. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1065. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1066. if item.ChrgitmLv == "1" {
  1067. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1068. }
  1069. if item.ChrgitmLv == "2" {
  1070. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1071. }
  1072. if item.ChrgitmLv == "3" {
  1073. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1074. }
  1075. }
  1076. if item.MedChrgitmType == "02" { //诊查
  1077. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1078. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1079. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1080. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1081. if item.ChrgitmLv == "1" {
  1082. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1083. }
  1084. if item.ChrgitmLv == "2" {
  1085. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1086. }
  1087. if item.ChrgitmLv == "3" {
  1088. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1089. }
  1090. }
  1091. if item.MedChrgitmType == "03" { //检查费
  1092. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1094. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1095. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1096. if item.ChrgitmLv == "1" {
  1097. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1098. }
  1099. if item.ChrgitmLv == "2" {
  1100. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1101. }
  1102. if item.ChrgitmLv == "3" {
  1103. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1104. }
  1105. }
  1106. if item.MedChrgitmType == "04" { //化验费
  1107. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1108. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1109. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1110. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1111. if item.ChrgitmLv == "1" {
  1112. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1113. }
  1114. if item.ChrgitmLv == "2" {
  1115. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1116. }
  1117. if item.ChrgitmLv == "3" {
  1118. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1119. }
  1120. }
  1121. if item.MedChrgitmType == "05" { //治疗费
  1122. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1123. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1124. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1125. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1126. if item.ChrgitmLv == "1" {
  1127. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1128. }
  1129. if item.ChrgitmLv == "2" {
  1130. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1131. }
  1132. if item.ChrgitmLv == "3" {
  1133. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1134. }
  1135. }
  1136. if item.MedChrgitmType == "06" { //手术费
  1137. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1138. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1139. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1140. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1141. if item.ChrgitmLv == "1" {
  1142. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1143. }
  1144. if item.ChrgitmLv == "2" {
  1145. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1146. }
  1147. if item.ChrgitmLv == "3" {
  1148. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1149. }
  1150. }
  1151. if item.MedChrgitmType == "07" { //手术费
  1152. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1153. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1154. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1155. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1156. if item.ChrgitmLv == "1" {
  1157. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1158. }
  1159. if item.ChrgitmLv == "2" {
  1160. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1161. }
  1162. if item.ChrgitmLv == "3" {
  1163. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1164. }
  1165. }
  1166. if item.MedChrgitmType == "08" { //材料费
  1167. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1168. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1169. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1170. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1171. if item.ChrgitmLv == "1" {
  1172. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1173. }
  1174. if item.ChrgitmLv == "2" {
  1175. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1176. }
  1177. if item.ChrgitmLv == "3" {
  1178. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1179. }
  1180. }
  1181. if item.MedChrgitmType == "09" { //西药费
  1182. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1183. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1184. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1185. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1186. if item.ChrgitmLv == "1" {
  1187. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1188. }
  1189. if item.ChrgitmLv == "2" {
  1190. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1191. }
  1192. if item.ChrgitmLv == "3" {
  1193. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1194. }
  1195. }
  1196. if item.MedChrgitmType == "10" { //中药饮片
  1197. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1198. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1199. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1200. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1201. if item.ChrgitmLv == "1" {
  1202. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1203. }
  1204. if item.ChrgitmLv == "2" {
  1205. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1206. }
  1207. if item.ChrgitmLv == "3" {
  1208. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1209. }
  1210. }
  1211. if item.MedChrgitmType == "11" { //中成费
  1212. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1213. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1214. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1215. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1216. if item.ChrgitmLv == "1" {
  1217. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1218. }
  1219. if item.ChrgitmLv == "2" {
  1220. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1221. }
  1222. if item.ChrgitmLv == "3" {
  1223. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1224. }
  1225. }
  1226. if item.MedChrgitmType == "12" { //中成费
  1227. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1228. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1229. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1230. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1231. if item.ChrgitmLv == "1" {
  1232. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1233. }
  1234. if item.ChrgitmLv == "2" {
  1235. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1236. }
  1237. if item.ChrgitmLv == "3" {
  1238. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1239. }
  1240. }
  1241. if item.MedChrgitmType == "13" { //中成费
  1242. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1243. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1244. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1245. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1246. if item.ChrgitmLv == "1" {
  1247. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1248. }
  1249. if item.ChrgitmLv == "2" {
  1250. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1251. }
  1252. if item.ChrgitmLv == "3" {
  1253. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1254. }
  1255. }
  1256. if item.MedChrgitmType == "14" { //其他费
  1257. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1258. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1259. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1260. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1261. if item.ChrgitmLv == "1" {
  1262. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1263. }
  1264. if item.ChrgitmLv == "2" {
  1265. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1266. }
  1267. if item.ChrgitmLv == "3" {
  1268. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1269. }
  1270. }
  1271. }
  1272. var iteminfoStructs []service.IteminfoStruct
  1273. if bedCostTotal != 0 {
  1274. iteminfo.MedChrgitm = "01"
  1275. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1276. iteminfo.Amt = bedCostTotal
  1277. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1278. iteminfo.ClabAmt = bed_clab_amt
  1279. iteminfo.OthAmt = bed_other_amt
  1280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1281. }
  1282. if examineCostTotal != 0 {
  1283. iteminfo.MedChrgitm = "02"
  1284. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1285. iteminfo.Amt = examineCostTotal
  1286. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1287. iteminfo.ClabAmt = examine_clab_amt
  1288. iteminfo.OthAmt = examine_other_amt
  1289. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1290. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1291. }
  1292. if checkCostTotal != 0 {
  1293. iteminfo.MedChrgitm = "03"
  1294. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1295. iteminfo.Amt = checkCostTotal
  1296. iteminfo.ClaaSumfee = check_claa_sunmfee
  1297. iteminfo.ClabAmt = check_clab_amt
  1298. iteminfo.OthAmt = check_other_amt
  1299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1300. }
  1301. if laboratoryCostTotal != 0 {
  1302. iteminfo.MedChrgitm = "04"
  1303. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1304. iteminfo.Amt = laboratoryCostTotal
  1305. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1306. iteminfo.ClabAmt = laboratory_clab_amt
  1307. iteminfo.OthAmt = laboratory_other_amt
  1308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1309. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1310. }
  1311. if treatCostTotal != 0 {
  1312. iteminfo.MedChrgitm = "05"
  1313. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1314. iteminfo.Amt = treatCostTotal
  1315. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1316. iteminfo.ClabAmt = treat_clab_amt
  1317. iteminfo.OthAmt = treat_other_amt
  1318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1319. //(struct4101.IteminfoStruct, iteminfo)
  1320. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1321. }
  1322. if operationCostTotal != 0 {
  1323. iteminfo.MedChrgitm = "06"
  1324. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1325. iteminfo.Amt = operationCostTotal
  1326. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1327. iteminfo.ClabAmt = operation_clab_amt
  1328. iteminfo.OthAmt = operation_other_amt
  1329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1331. }
  1332. if nursingCostTotal != 0 {
  1333. iteminfo.MedChrgitm = "07"
  1334. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1335. iteminfo.Amt = nursingCostTotal
  1336. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1337. iteminfo.ClabAmt = nursing_clab_amt
  1338. iteminfo.OthAmt = nursing_other_amt
  1339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1340. }
  1341. if materialCostTotal != 0 {
  1342. iteminfo.MedChrgitm = "08"
  1343. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1344. iteminfo.Amt = materialCostTotal
  1345. iteminfo.ClaaSumfee = material_claa_sunmfee
  1346. iteminfo.ClabAmt = material_clab_amt
  1347. iteminfo.OthAmt = material_other_amt
  1348. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1349. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1350. }
  1351. if westernMedicineCostTotal != 0 {
  1352. iteminfo.MedChrgitm = "09"
  1353. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1354. iteminfo.Amt = westernMedicineCostTotal
  1355. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1356. iteminfo.ClabAmt = westernMedicine_clab_amt
  1357. iteminfo.OthAmt = westernMedicine_other_amt
  1358. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1359. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1360. }
  1361. if chineseMedicineCostTotal != 0 {
  1362. iteminfo.MedChrgitm = "10"
  1363. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1364. iteminfo.Amt = chineseMedicineCostTotal
  1365. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1366. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1367. iteminfo.OthAmt = chinese_medicine_other_amt
  1368. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. }
  1371. if chineseTraditionalMedicineCostTotal != 0 {
  1372. iteminfo.MedChrgitm = "11"
  1373. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1374. iteminfo.Amt = westernMedicineCostTotal
  1375. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1376. iteminfo.ClabAmt = westernMedicine_clab_amt
  1377. iteminfo.OthAmt = westernMedicine_other_amt
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. }
  1381. if commonlyTreatmentCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "12"
  1383. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1384. iteminfo.Amt = commonlyTreatmentCostTotal
  1385. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1386. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1387. iteminfo.OthAmt = commonly_treatment_other_amt
  1388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1390. }
  1391. if registerCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "13"
  1393. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  1394. iteminfo.Amt = registerCostTotal
  1395. iteminfo.ClaaSumfee = register_claa_sunmfee
  1396. iteminfo.ClabAmt = register_clab_amt
  1397. iteminfo.OthAmt = register_other_amt
  1398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1400. }
  1401. if otherCostTotal != 0 {
  1402. iteminfo.MedChrgitm = "14"
  1403. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1404. iteminfo.Amt = otherCostTotal
  1405. iteminfo.ClaaSumfee = other_claa_sunmfee
  1406. iteminfo.ClabAmt = other_clab_amt
  1407. iteminfo.OthAmt = other_other_amt
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1410. }
  1411. struct4101.IteminfoStruct = iteminfoStructs
  1412. struct4101.Ntly = "中国"
  1413. struct4101.AdmCaty = "A03.06"
  1414. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1415. fmt.Println(result)
  1416. var dat map[string]interface{}
  1417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1418. fmt.Println(dat)
  1419. } else {
  1420. fmt.Println(err)
  1421. }
  1422. userJSONBytes, _ := json.Marshal(dat)
  1423. var res ResultSeventeen
  1424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1425. utils.ErrorLog("解析失败:%v", err)
  1426. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1427. adminUser := c.GetAdminUserInfo()
  1428. errlog := &models.HisOrderError{
  1429. UserOrgId: adminUser.CurrentOrgId,
  1430. Ctime: time.Now().Unix(),
  1431. Mtime: time.Now().Unix(),
  1432. ErrMsg: res.ErrMsg + "解析失败",
  1433. Status: 1,
  1434. PatientId: order_id,
  1435. Stage: 40,
  1436. }
  1437. service.CreateErrMsgLog(errlog)
  1438. continue
  1439. }
  1440. if res.Infcode != 0 {
  1441. adminUser := c.GetAdminUserInfo()
  1442. errlog := &models.HisOrderError{
  1443. UserOrgId: adminUser.CurrentOrgId,
  1444. Ctime: time.Now().Unix(),
  1445. Mtime: time.Now().Unix(),
  1446. ErrMsg: res.ErrMsg,
  1447. Status: 1,
  1448. PatientId: order_id,
  1449. Stage: 40,
  1450. }
  1451. service.CreateErrMsgLog(errlog)
  1452. continue
  1453. } else {
  1454. hisFundSettleListResult := &models.HisFundSettleListResult{
  1455. Number: res.Output.SetlListId,
  1456. Status: 1,
  1457. Ctime: time.Now().Unix(),
  1458. Mtime: time.Now().Unix(),
  1459. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1460. IsUpload: 1,
  1461. OrderId: order_id,
  1462. }
  1463. service.CreateUploadRecord(hisFundSettleListResult)
  1464. continue
  1465. }
  1466. }
  1467. }
  1468. //func (c *HisApiController) TestPay() {
  1469. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1470. // readCards := DllDef2.MustFindProc("BankTrans")
  1471. // inputData := make(map[string]interface{})
  1472. // inputData["transId"] = "05"
  1473. // inputData["amount"] = "0.01"
  1474. // inputData["traceNo"] = "20210227093601325405377"
  1475. // inputData["cardNo"] = "F36084348"
  1476. // inputData["id"] = "44022919620927046X"
  1477. // //jsonStr := `
  1478. // // {
  1479. // // "transId": "05",
  1480. // // "amount":"1.00",
  1481. // // "traceNo":"20210227093601325405377",
  1482. // // "cardNo":"F36084348",
  1483. // // "id":"44022919620927046X"
  1484. // //
  1485. // // }
  1486. // //`
  1487. //
  1488. // bytes_arr, _ := json.Marshal(inputData)
  1489. // str3 := make([]byte, 256)
  1490. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  1491. // fmt.Println(":", string(str3))
  1492. //
  1493. // if err4 != nil {
  1494. // fmt.Println("SSCard的运算结果为:", ret4)
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1496. // return
  1497. // }
  1498. //
  1499. //}
  1500. //func (c *HisApiController) TestGetBasBaseInfo() {
  1501. //
  1502. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1503. // //fmt.Println(result)
  1504. // //cs1 := C.CString("")
  1505. // //cs2 := C.CString("")
  1506. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  1507. // //fmt.Println(cs1)
  1508. // //fmt.Println(cs2)
  1509. // //C.free(unsafe.Pointer(cs1))
  1510. // //C.free(unsafe.Pointer(cs2))
  1511. //
  1512. // //
  1513. //
  1514. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1515. // Iinit := DllDef.MustFindProc("Init")
  1516. // readCard := DllDef.MustFindProc("ReadCardBas")
  1517. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1518. // if ret != 0 {
  1519. // fmt.Println("SSCard的报错原因:", err)
  1520. // fmt.Println("SSCard的运算结果为:", ret)
  1521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1522. // return
  1523. // }
  1524. //
  1525. // result := int(ret)
  1526. // fmt.Println("SSCard的运算结果为1:", result)
  1527. //
  1528. // //path := ""
  1529. // //bytePath := []byte( "\x00")
  1530. // //bytePath2 := []byte( "\x00")
  1531. // //ssss
  1532. //
  1533. // str := make([]byte, 256)
  1534. // str1 := make([]byte, 256)
  1535. // s2 := []byte(string(str))
  1536. // s3 := []byte(string(str1))
  1537. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  1538. // fmt.Println(" Add(4,5)的结果为:", ret2)
  1539. // fmt.Println(" str:", s2)
  1540. // fmt.Println(" str1:", s3)
  1541. // if err2 != nil {
  1542. // fmt.Println("SSCard的运算结果为:", ret2)
  1543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1544. // return
  1545. // }
  1546. //
  1547. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  1548. //
  1549. //}
  1550. func (c *HisApiController) GetOrgInfo() {
  1551. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  1552. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1553. }
  1554. func (c *HisApiController) GetHisPatientInfo() {
  1555. medical_insurance_card := c.GetString("medical_insurance_card")
  1556. id_card_type, _ := c.GetInt64("id_card_type")
  1557. id_card := c.GetString("id_card")
  1558. adminInfo := c.GetAdminUserInfo()
  1559. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1560. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1561. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  1562. IdCardNo := ""
  1563. if id_card_type == 1 {
  1564. IdCardNo = medical_insurance_card
  1565. } else if id_card_type == 2 {
  1566. IdCardNo = id_card
  1567. }
  1568. if config.IsOpen == 1 {
  1569. 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
  1570. resp, requestErr := http.Get(api)
  1571. if requestErr != nil {
  1572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1573. return
  1574. }
  1575. defer resp.Body.Close()
  1576. body, ioErr := ioutil.ReadAll(resp.Body)
  1577. if ioErr != nil {
  1578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1580. return
  1581. }
  1582. var respJSON map[string]interface{}
  1583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1589. userJSONBytes, _ := json.Marshal(userJSON)
  1590. var res ResultTwo
  1591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1592. utils.ErrorLog("解析失败:%v", err)
  1593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1594. return
  1595. }
  1596. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1597. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1598. infoStr := string(Iinfos)
  1599. idetinfoStr := string(Idetinfos)
  1600. if res.Infcode == 0 {
  1601. his := models.VMHisPatient{
  1602. Status: 1,
  1603. Ctime: time.Now().Unix(),
  1604. Mtime: time.Now().Unix(),
  1605. PsnNo: res.Output.Baseinfo.PsnNo,
  1606. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1607. Certno: res.Output.Baseinfo.Certno,
  1608. PsnName: res.Output.Baseinfo.PsnName,
  1609. Gend: res.Output.Baseinfo.Gend,
  1610. Naty: res.Output.Baseinfo.Naty,
  1611. Brdy: res.Output.Baseinfo.Brdy,
  1612. Age: res.Output.Baseinfo.Age,
  1613. Iinfo: infoStr,
  1614. Idetinfo: idetinfoStr,
  1615. UserOrgId: adminInfo.CurrentOrgId,
  1616. IsReturn: 1,
  1617. IdCardType: id_card_type,
  1618. }
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "info": his,
  1621. })
  1622. } else {
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1624. return
  1625. }
  1626. }
  1627. }
  1628. //func GetBasBaseInfo() (jsonStr string, err error) {
  1629. //
  1630. // handle := syscall.NewLazyDLL("SSCard.dll")
  1631. // add := handle.NewProc("ReadCardBas")
  1632. // str := make([]byte, 1024)
  1633. // str1 := make([]byte, 1024)
  1634. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1635. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  1636. //
  1637. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  1638. //
  1639. // fmt.Println("> Add(4,5)的结果为:", ret)
  1640. // handle.Release()
  1641. //
  1642. // return "", nil
  1643. //
  1644. //}
  1645. //func GetQRBaseInfo() (jsonStr string, err error) {
  1646. // handle := syscall.LoadDLL("SSCard.dll")
  1647. // ReadCardBas := handle.FindProc("GetQRBase")
  1648. //
  1649. // str := make([]byte, 256)
  1650. // str1 := make([]byte, 256)
  1651. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1652. //
  1653. // fmt.Println(string(str))
  1654. // fmt.Println(r)
  1655. // return string(str), nil
  1656. //}
  1657. //func CardInit() int {
  1658. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  1659. // add := DllTestDef.MustFindProc("Init")
  1660. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1661. // if err != nil {
  1662. // fmt.Println("SSCard的运算结果为:", ret)
  1663. // }
  1664. // result := int(ret)
  1665. // return result
  1666. //}
  1667. //func CardInit() int {
  1668. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1669. // if err != nil {
  1670. // fmt.Println("SSCard的运算结果为:", ret)
  1671. // }
  1672. // fmt.Println(err)
  1673. // result := int(ret)
  1674. // return result
  1675. //}
  1676. func IntPtr(n int) uintptr {
  1677. return uintptr(n)
  1678. }
  1679. func StrPtr(s string) uintptr {
  1680. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1681. }
  1682. type ResultTwo struct {
  1683. ErrMsg string `json:"err_msg"`
  1684. InfRefmsgid string `json:"inf_refmsgid"`
  1685. Infcode int64 `json:"infcode"`
  1686. Output struct {
  1687. Baseinfo struct {
  1688. Age float64 `json:"age"`
  1689. Brdy string `json:"brdy"`
  1690. Certno string `json:"certno"`
  1691. Gend string `json:"gend"`
  1692. Naty string `json:"naty"`
  1693. PsnCertType string `json:"psn_cert_type"`
  1694. PsnName string `json:"psn_name"`
  1695. PsnNo string `json:"psn_no"`
  1696. } `json:"baseinfo"`
  1697. Idetinfo []interface{} `json:"idetinfo"`
  1698. Iinfo []struct {
  1699. Balc float64 `json:"balc"`
  1700. CvlservFlag string `json:"cvlserv_flag"`
  1701. EmpName string `json:"emp_name"`
  1702. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1703. Insutype string `json:"insutype"`
  1704. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1705. PausInsuDate string `json:"paus_insu_date"`
  1706. PsnInsuDate string `json:"psn_insu_date"`
  1707. PsnInsuStas string `json:"psn_insu_stas"`
  1708. PsnType string `json:"psn_type"`
  1709. } `json:"insuinfo"`
  1710. } `json:"output"`
  1711. RefmsgTime string `json:"refmsg_time"`
  1712. RespondTime string `json:"respond_time"`
  1713. Signtype interface{} `json:"signtype"`
  1714. WarnInfo interface{} `json:"warn_info"`
  1715. }
  1716. type ResultTwo10265 struct {
  1717. ErrMsg string `json:"err_msg"`
  1718. InfRefmsgid string `json:"inf_refmsgid"`
  1719. Infcode string `json:"infcode"`
  1720. Output struct {
  1721. Baseinfo struct {
  1722. Age float64 `json:"age"`
  1723. Brdy string `json:"brdy"`
  1724. Certno string `json:"certno"`
  1725. Gend string `json:"gend"`
  1726. Naty string `json:"naty"`
  1727. PsnCertType string `json:"psn_cert_type"`
  1728. PsnName string `json:"psn_name"`
  1729. PsnNo string `json:"psn_no"`
  1730. } `json:"baseinfo"`
  1731. Idetinfo []interface{} `json:"idetinfo"`
  1732. Iinfo []struct {
  1733. Balc float64 `json:"balc"`
  1734. CvlservFlag string `json:"cvlserv_flag"`
  1735. EmpName string `json:"emp_name"`
  1736. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1737. Insutype string `json:"insutype"`
  1738. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1739. PausInsuDate string `json:"paus_insu_date"`
  1740. PsnInsuDate string `json:"psn_insu_date"`
  1741. PsnInsuStas string `json:"psn_insu_stas"`
  1742. PsnType string `json:"psn_type"`
  1743. } `json:"insuinfo"`
  1744. } `json:"output"`
  1745. RefmsgTime string `json:"refmsg_time"`
  1746. RespondTime string `json:"respond_time"`
  1747. Signtype interface{} `json:"signtype"`
  1748. WarnInfo interface{} `json:"warn_info"`
  1749. }
  1750. type ResultThree struct {
  1751. Cainfo interface{} `json:"cainfo"`
  1752. ErrMsg string `json:"err_msg"`
  1753. InfRefmsgid string `json:"inf_refmsgid"`
  1754. Infcode int64 `json:"infcode"`
  1755. Output struct {
  1756. Data struct {
  1757. IptOtpNo string `json:"ipt_otp_no"`
  1758. MdtrtID string `json:"mdtrt_id"`
  1759. PsnNo string `json:"psn_no"`
  1760. } `json:"data"`
  1761. } `json:"output"`
  1762. RefmsgTime string `json:"refmsg_time"`
  1763. RespondTime string `json:"respond_time"`
  1764. Signtype interface{} `json:"signtype"`
  1765. WarnMsg interface{} `json:"warn_msg"`
  1766. }
  1767. type ResultThree10265 struct {
  1768. Cainfo interface{} `json:"cainfo"`
  1769. ErrMsg string `json:"err_msg"`
  1770. InfRefmsgid string `json:"inf_refmsgid"`
  1771. Infcode string `json:"infcode"`
  1772. Output struct {
  1773. Data struct {
  1774. IptOtpNo string `json:"ipt_otp_no"`
  1775. MdtrtID string `json:"mdtrt_id"`
  1776. PsnNo string `json:"psn_no"`
  1777. } `json:"data"`
  1778. } `json:"output"`
  1779. RefmsgTime string `json:"refmsg_time"`
  1780. RespondTime string `json:"respond_time"`
  1781. Signtype interface{} `json:"signtype"`
  1782. WarnMsg interface{} `json:"warn_msg"`
  1783. }
  1784. type ResultFour struct {
  1785. Cainfo string `json:"cainfo"`
  1786. ErrMsg string `json:"err_msg"`
  1787. InfRefmsgid string `json:"inf_refmsgid"`
  1788. Infcode int64 `json:"infcode"`
  1789. Output struct {
  1790. Result []struct {
  1791. BasMednFlag string `json:"bas_medn_flag"`
  1792. ChldMedcFlag string `json:"chld_medc_flag"`
  1793. ChrgitmLv string `json:"chrgitm_lv"`
  1794. Cnt float64 `json:"cnt"`
  1795. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1796. DrtReimFlag string `json:"drt_reim_flag"`
  1797. FeedetlSn string `json:"feedetl_sn"`
  1798. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1799. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1800. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1801. ListSpItemFlag string `json:"list_sp_item_flag"`
  1802. LmtUsedFlag string `json:"lmt_used_flag"`
  1803. MedChrgitmType string `json:"med_chrgitm_type"`
  1804. Memo string `json:"memo"`
  1805. OverlmtAmt float64 `json:"overlmt_amt"`
  1806. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1807. Pric float64 `json:"pric"`
  1808. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1809. SelfpayProp float64 `json:"selfpay_prop"`
  1810. } `json:"result"`
  1811. } `json:"output"`
  1812. RefmsgTime string `json:"refmsg_time"`
  1813. RespondTime string `json:"respond_time"`
  1814. Signtype string `json:"signtype"`
  1815. WarnMsg string `json:"warn_msg"`
  1816. }
  1817. type ResultFive struct {
  1818. Balc float64 `json:"balc"`
  1819. CvlservFlag string `json:"cvlserv_flag"`
  1820. EmpName string `json:"emp_name"`
  1821. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1822. Insutype string `json:"insutype"`
  1823. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1824. PausInsuDate string `json:"paus_insu_date"`
  1825. PsnInsuDate string `json:"psn_insu_date"`
  1826. PsnInsuStas string `json:"psn_insu_stas"`
  1827. PsnType string `json:"psn_type"`
  1828. }
  1829. type ResultSix struct {
  1830. Cainfo interface{} `json:"cainfo"`
  1831. ErrMsg string `json:"err_msg"`
  1832. InfRefmsgid string `json:"inf_refmsgid"`
  1833. Infcode int64 `json:"infcode"`
  1834. Output struct {
  1835. } `json:"output"`
  1836. RefmsgTime string `json:"refmsg_time"`
  1837. RespondTime string `json:"respond_time"`
  1838. Signtype interface{} `json:"signtype"`
  1839. WarnMsg interface{} `json:"warn_msg"`
  1840. }
  1841. type ResultSeven struct {
  1842. Cainfo string `json:"cainfo"`
  1843. ErrMsg string `json:"err_msg"`
  1844. InfRefmsgid string `json:"inf_refmsgid"`
  1845. Infcode int64 `json:"infcode"`
  1846. Output struct {
  1847. Setldetail []interface{} `json:"setldetail"`
  1848. Setlinfo struct {
  1849. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1850. AcctPay float64 `json:"acct_pay"`
  1851. ActPayDedc float64 `json:"act_pay_dedc"`
  1852. Age float64 `json:"age"`
  1853. Balc float64 `json:"balc"`
  1854. Brdy string `json:"brdy"`
  1855. Certno string `json:"certno"`
  1856. ClrOptins string `json:"clr_optins"`
  1857. ClrType string `json:"clr_type"`
  1858. ClrWay string `json:"clr_way"`
  1859. CvlservFlag string `json:"cvlserv_flag"`
  1860. CvlservPay float64 `json:"cvlserv_pay"`
  1861. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1862. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1863. Gend string `json:"gend"`
  1864. HifesPay float64 `json:"hifes_pay"`
  1865. HifmiPay float64 `json:"hifmi_pay"`
  1866. HifpPay float64 `json:"hifp_pay"`
  1867. HospPartAmt float64 `json:"hosp_part_amt"`
  1868. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1869. Insutype string `json:"insutype"`
  1870. MafPay float64 `json:"maf_pay"`
  1871. MdtrtCertType string `json:"mdtrt_cert_type"`
  1872. HifobPay float64 `json:"hifob_pay"`
  1873. MdtrtID string `json:"mdtrt_id"`
  1874. MedType string `json:"med_type"`
  1875. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1876. MedinsSetlID string `json:"medins_setl_id"`
  1877. Naty string `json:"naty"`
  1878. OthPay float64 `json:"oth_pay"`
  1879. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1880. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1881. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1882. PsnCashPay float64 `json:"psn_cash_pay"`
  1883. PsnCertType string `json:"psn_cert_type"`
  1884. PsnName string `json:"psn_name"`
  1885. PsnNo string `json:"psn_no"`
  1886. PsnPartAmt float64 `json:"psn_part_amt"`
  1887. PsnType string `json:"psn_type"`
  1888. SetlID string `json:"setl_id"`
  1889. SetlTime string `json:"setl_time"`
  1890. } `json:"setlinfo"`
  1891. } `json:"output"`
  1892. RefmsgTime string `json:"refmsg_time"`
  1893. RespondTime string `json:"respond_time"`
  1894. Signtype interface{} `json:"signtype"`
  1895. WarnMsg interface{} `json:"warn_msg"`
  1896. }
  1897. type ResultEight struct {
  1898. Cainfo string `json:"cainfo"`
  1899. ErrMsg string `json:"err_msg"`
  1900. InfRefmsgid string `json:"inf_refmsgid"`
  1901. Infcode int64 `json:"infcode"`
  1902. Output struct {
  1903. Stmtinfo struct {
  1904. SetlOptins string `json:"setl_optins"`
  1905. StmtRslt string `json:"stmt_rslt"`
  1906. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1907. } `json:"stmtinfo"`
  1908. } `json:"output"`
  1909. RefmsgTime string `json:"refmsg_time"`
  1910. RespondTime string `json:"respond_time"`
  1911. Signtype interface{} `json:"signtype"`
  1912. WarnMsg interface{} `json:"warn_msg"`
  1913. }
  1914. type ResultNine struct {
  1915. Cainfo string `json:"cainfo"`
  1916. ErrMsg string `json:"err_msg"`
  1917. InfRefmsgid string `json:"inf_refmsgid"`
  1918. Infcode int64 `json:"infcode"`
  1919. Output struct {
  1920. FileQuryNo string `json:"file_qury_no"`
  1921. } `json:"output"`
  1922. RefmsgTime string `json:"refmsg_time"`
  1923. RespondTime string `json:"respond_time"`
  1924. Signtype interface{} `json:"signtype"`
  1925. WarnMsg interface{} `json:"warn_msg"`
  1926. }
  1927. type ResultTen struct {
  1928. Cainfo string `json:"cainfo"`
  1929. ErrMsg string `json:"err_msg"`
  1930. InfRefmsgid string `json:"inf_refmsgid"`
  1931. Infcode int64 `json:"infcode"`
  1932. Output struct {
  1933. DldEndtime string `json:"dld_endtime"`
  1934. FileQuryNo string `json:"file_qury_no"`
  1935. Filename string `json:"filename"`
  1936. } `json:"output"`
  1937. RefmsgTime string `json:"refmsg_time"`
  1938. RespondTime string `json:"respond_time"`
  1939. Signtype interface{} `json:"signtype"`
  1940. WarnMsg interface{} `json:"warn_msg"`
  1941. }
  1942. //type Autogenerated struct {
  1943. // Output struct {
  1944. // Setlinfo struct {
  1945. // SetlTime string `json:"setl_time"`
  1946. // CvlservPay float64 `json:"cvlserv_pay"`
  1947. // Year string `json:"year"`
  1948. // MedType string `json:"med_type"`
  1949. // PsnPay float64 `json:"psn_pay"`
  1950. // OpterID string `json:"opter_id"`
  1951. // Begndate string `json:"begndate"`
  1952. // FlxempeFlag string `json:"flxempe_flag"`
  1953. // HifmiPay float64 `json:"hifmi_pay"`
  1954. // PsnNo string `json:"psn_no"`
  1955. // ActPayDedc float64 `json:"act_pay_dedc"`
  1956. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1957. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1958. // ClrWay string `json:"clr_way"`
  1959. // OthPay float64 `json:"oth_pay"`
  1960. // Gend string `json:"gend"`
  1961. // MdtrtID string `json:"mdtrt_id"`
  1962. // AcctPay float64 `json:"acct_pay"`
  1963. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1964. // Insutype string `json:"insutype"`
  1965. // Invono interface{} `json:"invono"`
  1966. // Enddate string `json:"enddate"`
  1967. // CashPayamt float64 `json:"cash_payamt"`
  1968. // PsnType string `json:"psn_type"`
  1969. // FixmedinsName string `json:"fixmedins_name"`
  1970. // HifpPay float64 `json:"hifp_pay"`
  1971. // NewFlag interface{} `json:"new_flag"`
  1972. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1973. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1974. // PayLoc string `json:"pay_loc"`
  1975. // ClrType string `json:"clr_type"`
  1976. // RefdSetlFlag string `json:"refd_setl_flag"`
  1977. // CvlservFlag string `json:"cvlserv_flag"`
  1978. // EmpName string `json:"emp_name"`
  1979. // Brdy string `json:"brdy"`
  1980. // Naty string `json:"naty"`
  1981. // Certno string `json:"certno"`
  1982. // DiseCode string `json:"dise_code"`
  1983. // FixmedinsCode string `json:"fixmedins_code"`
  1984. // DedcHospLv string `json:"dedc_hosp_lv"`
  1985. // OpterName string `json:"opter_name"`
  1986. // Balc float64 `json:"balc"`
  1987. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1988. // PsnCertType string `json:"psn_cert_type"`
  1989. // HifobPay float64 `json:"hifob_pay"`
  1990. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1991. // HifesPay float64 `json:"hifes_pay"`
  1992. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1993. // OptTime string `json:"opt_time"`
  1994. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1995. // SetlID string `json:"setl_id"`
  1996. // MafPay float64 `json:"maf_pay"`
  1997. // PsnName string `json:"psn_name"`
  1998. // InsuOptins interface{} `json:"insu_optins"`
  1999. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2000. // ClrOptins string `json:"clr_optins"`
  2001. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2002. // DiseName string `json:"dise_name"`
  2003. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2004. // Age float64 `json:"age"`
  2005. // DtrtCertType string `json:"dtrt_cert_type"`
  2006. // HospLv string `json:"hosp_lv"`
  2007. // } `json:"setlinfo"`
  2008. // Setldetail []struct {
  2009. // FundPayType string `json:"fund_pay_type"`
  2010. // FundPayamt float64 `json:"fund_payamt"`
  2011. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2012. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2013. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2014. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2015. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2016. // } `json:"setldetail"`
  2017. // } `json:"output"`
  2018. // Infcode int `json:"infcode"`
  2019. // WarnMsg interface{} `json:"warn_msg"`
  2020. // Cainfo interface{} `json:"cainfo"`
  2021. // ErrMsg interface{} `json:"err_msg"`
  2022. // RefmsgTime string `json:"refmsg_time"`
  2023. // Signtype interface{} `json:"signtype"`
  2024. // RespondTime string `json:"respond_time"`
  2025. // InfRefmsgid string `json:"inf_refmsgid"`
  2026. //}
  2027. type ResultEleven struct {
  2028. Cainfo string `json:"cainfo"`
  2029. ErrMsg string `json:"err_msg"`
  2030. InfRefmsgid string `json:"inf_refmsgid"`
  2031. Infcode int64 `json:"infcode"`
  2032. Output struct {
  2033. Setlinfo struct {
  2034. SetlTime string `json:"setl_time"`
  2035. CvlservPay float64 `json:"cvlserv_pay"`
  2036. Year string `json:"year"`
  2037. MedType string `json:"med_type"`
  2038. PsnPay float64 `json:"psn_pay"`
  2039. OpterID string `json:"opter_id"`
  2040. Begndate string `json:"begndate"`
  2041. FlxempeFlag string `json:"flxempe_flag"`
  2042. HifmiPay float64 `json:"hifmi_pay"`
  2043. PsnNo string `json:"psn_no"`
  2044. ActPayDedc float64 `json:"act_pay_dedc"`
  2045. MedinsSetlID interface{} `json:"medins_setl_id"`
  2046. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2047. ClrWay string `json:"clr_way"`
  2048. OthPay float64 `json:"oth_pay"`
  2049. Gend string `json:"gend"`
  2050. MdtrtID string `json:"mdtrt_id"`
  2051. AcctPay float64 `json:"acct_pay"`
  2052. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2053. Insutype string `json:"insutype"`
  2054. Invono interface{} `json:"invono"`
  2055. Enddate string `json:"enddate"`
  2056. CashPayamt float64 `json:"cash_payamt"`
  2057. PsnType string `json:"psn_type"`
  2058. FixmedinsName string `json:"fixmedins_name"`
  2059. HifpPay float64 `json:"hifp_pay"`
  2060. NewFlag interface{} `json:"new_flag"`
  2061. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2062. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2063. PayLoc string `json:"pay_loc"`
  2064. ClrType string `json:"clr_type"`
  2065. RefdSetlFlag string `json:"refd_setl_flag"`
  2066. CvlservFlag string `json:"cvlserv_flag"`
  2067. EmpName string `json:"emp_name"`
  2068. Brdy string `json:"brdy"`
  2069. Naty string `json:"naty"`
  2070. Certno string `json:"certno"`
  2071. DiseCode string `json:"dise_code"`
  2072. FixmedinsCode string `json:"fixmedins_code"`
  2073. DedcHospLv string `json:"dedc_hosp_lv"`
  2074. OpterName string `json:"opter_name"`
  2075. Balc float64 `json:"balc"`
  2076. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2077. PsnCertType string `json:"psn_cert_type"`
  2078. HifobPay float64 `json:"hifob_pay"`
  2079. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2080. HifesPay float64 `json:"hifes_pay"`
  2081. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2082. OptTime string `json:"opt_time"`
  2083. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2084. SetlID string `json:"setl_id"`
  2085. MafPay float64 `json:"maf_pay"`
  2086. PsnName string `json:"psn_name"`
  2087. InsuOptins interface{} `json:"insu_optins"`
  2088. PrefFundPay interface{} `json:"pref_fund_pay"`
  2089. ClrOptins string `json:"clr_optins"`
  2090. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2091. DiseName string `json:"dise_name"`
  2092. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2093. Age float64 `json:"age"`
  2094. DtrtCertType string `json:"dtrt_cert_type"`
  2095. HospLv string `json:"hosp_lv"`
  2096. } `json:"setlinfo"`
  2097. } `json:"output"`
  2098. RefmsgTime string `json:"refmsg_time"`
  2099. RespondTime string `json:"respond_time"`
  2100. Signtype interface{} `json:"signtype"`
  2101. WarnMsg interface{} `json:"warn_msg"`
  2102. }
  2103. type ResultTwelve struct {
  2104. Cainfo string `json:"cainfo"`
  2105. ErrMsg string `json:"err_msg"`
  2106. InfRefmsgid string `json:"inf_refmsgid"`
  2107. Infcode int64 `json:"infcode"`
  2108. Output struct {
  2109. MdtrtId string `json:"mdtrt_id"`
  2110. ChrgBchno string `json:"chrg_bchno"`
  2111. PsnNo string `json:"psn_no"`
  2112. } `json:"output"`
  2113. RefmsgTime string `json:"refmsg_time"`
  2114. RespondTime string `json:"respond_time"`
  2115. Signtype interface{} `json:"signtype"`
  2116. WarnMsg interface{} `json:"warn_msg"`
  2117. }
  2118. type ResultThirteen struct {
  2119. ErrMsg string `json:"err_msg"`
  2120. InfRefmsgid string `json:"inf_refmsgid"`
  2121. Infcode int64 `json:"infcode"`
  2122. Output struct {
  2123. Result struct {
  2124. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2125. } `json:"result"`
  2126. } `json:"output"`
  2127. RefmsgTime string `json:"refmsg_time"`
  2128. RespondTime string `json:"respond_time"`
  2129. Signtype interface{} `json:"signtype"`
  2130. WarnInfo interface{} `json:"warn_info"`
  2131. }
  2132. type ResultFourteen struct {
  2133. ErrMsg string `json:"err_msg"`
  2134. InfRefmsgid string `json:"inf_refmsgid"`
  2135. Infcode int64 `json:"infcode"`
  2136. Output struct {
  2137. } `json:"output"`
  2138. RefmsgTime string `json:"refmsg_time"`
  2139. RespondTime string `json:"respond_time"`
  2140. Signtype interface{} `json:"signtype"`
  2141. WarnInfo interface{} `json:"warn_info"`
  2142. }
  2143. type ResultSixteen struct {
  2144. Cainfo string `json:"cainfo"`
  2145. ErrMsg string `json:"err_msg"`
  2146. InfRefmsgid string `json:"inf_refmsgid"`
  2147. Infcode int64 `json:"infcode"`
  2148. Output struct {
  2149. Setldetail []interface{} `json:"setldetail"`
  2150. Setlinfo struct {
  2151. MdtrtID string `json:"mdtrt_id"`
  2152. SetlID string `json:"setl_id"`
  2153. ClrOptins string `json:"clr_optins"`
  2154. SetlTime string `json:"setl_time"`
  2155. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2156. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2157. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2158. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2159. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2160. ActPayDedc float64 `json:"act_pay_dedc"`
  2161. HifpPay float64 `json:"hifp_pay"`
  2162. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2163. Lfpay float64 `json:"selfpay"`
  2164. CvlservPay float64 `json:"cvlserv_pay"`
  2165. HifesPay float64 `json:"hifes_pay"`
  2166. HifmiPay float64 `json:"hifmi_pay"`
  2167. HifobPay float64 `json:"hifob_pay"`
  2168. MafPay float64 `json:"maf_pay"`
  2169. OthPay float64 `json:"oth_pay"`
  2170. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2171. PsnPartAmt float64 `json:"psn_part_amt"`
  2172. AcctPay float64 `json:"acct_pay"`
  2173. Balc float64 `json:"balc"`
  2174. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2175. HospPartAmt float64 `json:"hosp_part_amt"`
  2176. MedinsSetlID string `json:"medins_setl_id"`
  2177. PdnCashPay string `json:"pdn_cash_pay"`
  2178. } `json:"setlinfo"`
  2179. } `json:"output"`
  2180. RefmsgTime string `json:"refmsg_time"`
  2181. RespondTime string `json:"respond_time"`
  2182. Signtype interface{} `json:"signtype"`
  2183. WarnMsg interface{} `json:"warn_msg"`
  2184. }
  2185. type ResultSeventeen struct {
  2186. ErrMsg string `json:"err_msg"`
  2187. InfRefmsgid string `json:"inf_refmsgid"`
  2188. Infcode int64 `json:"infcode"`
  2189. Output struct {
  2190. SetlListId string `json:"setl_list_id"`
  2191. } `json:"output"`
  2192. RefmsgTime string `json:"refmsg_time"`
  2193. RespondTime string `json:"respond_time"`
  2194. Signtype string `json:"signtype"`
  2195. WarnInfo string `json:"warn_info"`
  2196. }
  2197. type Result90991 struct {
  2198. ErrMsg string `json:"err_msg"`
  2199. InfRefmsgid string `json:"inf_refmsgid"`
  2200. Infcode int64 `json:"infcode"`
  2201. Output struct {
  2202. Result struct {
  2203. PsnNo string `json:"psn_no"`
  2204. CardStat string `json:"card_stat"`
  2205. Certno string `json:"certno"`
  2206. PsnName string `json:"psn_name"`
  2207. CheckStat string `json:"check_stat"`
  2208. } `json:"result"`
  2209. } `json:"output"`
  2210. RefmsgTime string `json:"refmsg_time"`
  2211. RespondTime string `json:"respond_time"`
  2212. Signtype interface{} `json:"signtype"`
  2213. WarnInfo interface{} `json:"warn_info"`
  2214. }
  2215. type Result90100 struct {
  2216. ErrMsg string `json:"err_msg"`
  2217. InfRefmsgid string `json:"inf_refmsgid"`
  2218. Infcode int64 `json:"infcode"`
  2219. Output struct {
  2220. PoolareaNo string `json:"poolarea_no"`
  2221. PoolareaNoName string `json:"poolarea_no_name"`
  2222. Insutype string `json:"insutype"`
  2223. InsutypeName string `json:"insutype_name"`
  2224. ClctType string `json:"clct_type"`
  2225. ClctTypeName string `json:"clct_type_name"`
  2226. ClctFlag string `json:"clct_flag"`
  2227. ClctFlagName string `json:"clct_flag_name"`
  2228. AccrymBegn string `json:"accrym_begn"`
  2229. AccrymEnd string `json:"accrym_end"`
  2230. ClctTime string `json:"clct_time"`
  2231. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2232. } `json:"output"`
  2233. RefmsgTime string `json:"refmsg_time"`
  2234. RespondTime string `json:"respond_time"`
  2235. Signtype interface{} `json:"signtype"`
  2236. WarnInfo interface{} `json:"warn_info"`
  2237. }
  2238. type Custom struct {
  2239. DetItemFeeSumamt string
  2240. Cut string
  2241. FeedetlSn string
  2242. Price string
  2243. MedListCodg string
  2244. Type int64
  2245. AdviceId int64
  2246. ProjectId int64
  2247. ItemId int64
  2248. }
  2249. //获取个人信息----挂号-----上传就诊信息
  2250. func (c *HisApiController) GetRegisterInfo() {
  2251. fmt.Println("~~~~~~~~")
  2252. id, _ := c.GetInt64("id")
  2253. record_time := c.GetString("record_time")
  2254. settlementValue, _ := c.GetInt64("settlement_value")
  2255. medical_insurance_card := c.GetString("medical_insurance_card")
  2256. name := c.GetString("name")
  2257. id_card_type, _ := c.GetInt64("id_card_type")
  2258. certificates, _ := c.GetInt64("certificates")
  2259. medical_care, _ := c.GetInt64("medical_care")
  2260. birthday := c.GetString("birthday")
  2261. //age, _ := c.GetInt64("age")
  2262. id_card := c.GetString("id_card")
  2263. register_type, _ := c.GetInt64("register")
  2264. doctor, _ := c.GetInt64("doctor")
  2265. department, _ := c.GetInt64("department")
  2266. gender, _ := c.GetInt64("sex")
  2267. //phone := c.GetString("phone")
  2268. registration_fee, _ := c.GetFloat("registration_fee")
  2269. medical_expenses, _ := c.GetFloat("medical_expenses")
  2270. social_type, _ := c.GetInt64("social_type")
  2271. med_type := c.GetString("social_type")
  2272. admin_user_id, _ := c.GetInt64("admin_user_id")
  2273. timeLayout := "2006-01-02"
  2274. loc, _ := time.LoadLocation("Local")
  2275. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2276. birthUnix := birthdays.Unix()
  2277. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2278. if err != nil {
  2279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2280. return
  2281. }
  2282. recordDateTime := theTime.Unix()
  2283. adminInfo := c.GetAdminUserInfo()
  2284. var patient service.Patients
  2285. if id == 0 {
  2286. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2287. } else {
  2288. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2289. }
  2290. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2291. if patientPrescription.ID == 0 {
  2292. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2293. }
  2294. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  2295. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2296. //sickConfig, _ := service.FindSickById(sick_type)
  2297. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2298. if patient.ID == 0 {
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2300. return
  2301. }
  2302. if len(patient.IdCardNo) == 0 {
  2303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2304. return
  2305. }
  2306. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2307. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2308. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2309. //就诊结算未完成,不能进行二次挂号
  2310. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2311. if len(his) >= 1 {
  2312. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2313. if len(his) >= 1 && order.ID == 0 {
  2314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2315. return
  2316. }
  2317. }
  2318. //var register_log string
  2319. if config.IsOpen == 1 {
  2320. var res ResultTwo
  2321. var res10265 ResultTwo10265
  2322. var PsnNo string
  2323. var PsnCertType string
  2324. var Certno string
  2325. var PsnName string
  2326. var Gend string
  2327. var Naty string
  2328. var Brdy string
  2329. var Age float64
  2330. var infoStr string
  2331. var idetinfoStr string
  2332. var infocode int64
  2333. if miConfig.MdtrtareaAdmvs == "421300" {
  2334. psn_info, _ := service.GetPsnByPatientId(id)
  2335. PsnNo = psn_info.PsnNo
  2336. PsnCertType = psn_info.PsnCertType
  2337. Certno = psn_info.Certno
  2338. PsnName = psn_info.PsnName
  2339. Gend = psn_info.Gend
  2340. Naty = psn_info.Naty
  2341. Brdy = psn_info.Brdy
  2342. Age = psn_info.Age
  2343. infoStr = psn_info.Insuinfo
  2344. idetinfoStr = psn_info.Idetinfo
  2345. } else {
  2346. result, requestLog := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  2347. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2348. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2349. utils.ErrorLog("解析失败:%v", err)
  2350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2351. return
  2352. }
  2353. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2354. utils.ErrorLog("解析失败:%v", err)
  2355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2356. return
  2357. }
  2358. PsnNo = res.Output.Baseinfo.PsnNo
  2359. PsnCertType = res.Output.Baseinfo.PsnCertType
  2360. Certno = res.Output.Baseinfo.Certno
  2361. PsnName = res.Output.Baseinfo.PsnName
  2362. Gend = res.Output.Baseinfo.Gend
  2363. Naty = res.Output.Baseinfo.Naty
  2364. Brdy = res.Output.Baseinfo.Brdy
  2365. Age = res.Output.Baseinfo.Age
  2366. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2367. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2368. infoStr = string(Iinfos)
  2369. idetinfoStr = string(Idetinfos)
  2370. if miConfig.Code == "H15049901371" {
  2371. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2372. } else {
  2373. infocode = res.Infcode
  2374. }
  2375. }
  2376. if infocode == 0 {
  2377. his := models.VMHisPatient{
  2378. Name: name,
  2379. Gender: gender,
  2380. Birthday: birthUnix,
  2381. MedicalTreatmentType: medical_care,
  2382. IdType: certificates,
  2383. IdCardNo: id_card,
  2384. BalanceAccountsType: settlementValue,
  2385. SocialType: social_type,
  2386. MedicalInsuranceNumber: medical_insurance_card,
  2387. RegisterType: register_type,
  2388. RegisterCost: registration_fee,
  2389. TreatmentCost: medical_expenses,
  2390. Status: 1,
  2391. Ctime: time.Now().Unix(),
  2392. Mtime: time.Now().Unix(),
  2393. PsnNo: PsnNo,
  2394. PsnCertType: PsnCertType,
  2395. Certno: Certno,
  2396. PsnName: PsnName,
  2397. Gend: Gend,
  2398. Naty: Naty,
  2399. Brdy: Brdy,
  2400. Age: Age,
  2401. Iinfo: infoStr,
  2402. Idetinfo: idetinfoStr,
  2403. PatientId: patient.ID,
  2404. RecordDate: theTime.Unix(),
  2405. UserOrgId: adminInfo.CurrentOrgId,
  2406. AdminUserId: admin_user_id,
  2407. IsReturn: 1,
  2408. IdCardType: id_card_type,
  2409. Doctor: doctor,
  2410. Departments: department,
  2411. }
  2412. timestamp := time.Now().Unix()
  2413. tempTime := time.Unix(timestamp, 0)
  2414. timeFormat := tempTime.Format("20060102150405")
  2415. chrgBchno := rand.Intn(100000) + 10000
  2416. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2417. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2418. department, _ := service.GetDepartMentDetail(department)
  2419. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2420. IdCardNo := ""
  2421. if id_card_type == 1 {
  2422. // IdCardNo = medical_insurance_card
  2423. IdCardNo = patient.IdCardNo
  2424. } else {
  2425. IdCardNo = patient.IdCardNo
  2426. }
  2427. var rf []*ResultFive
  2428. json.Unmarshal([]byte(his.Iinfo), &rf)
  2429. var insutypes []*ResultFive
  2430. var insutype string
  2431. var insuplc_admdvs string
  2432. var is390 int = 0
  2433. var is310 int = 0
  2434. for _, item := range rf {
  2435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2436. insutypes = append(insutypes, item)
  2437. }
  2438. }
  2439. if len(insutypes) == 1 {
  2440. insutype = insutypes[0].Insutype
  2441. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2442. } else {
  2443. for _, i := range insutypes {
  2444. if i.Insutype == "390" {
  2445. is390 = 1
  2446. }
  2447. if i.Insutype == "310" {
  2448. is310 = 1
  2449. }
  2450. }
  2451. }
  2452. if is390 == 1 {
  2453. insutype = "390"
  2454. }
  2455. if is310 == 1 {
  2456. insutype = "310"
  2457. }
  2458. if len(insutypes) == 0 {
  2459. insutype = "310"
  2460. }
  2461. if len(insutypes) == 2 {
  2462. insutype = med_type
  2463. }
  2464. for _, item := range rf {
  2465. if item.Insutype == insutype {
  2466. insuplc_admdvs = item.InsuplcAdmdvs
  2467. }
  2468. }
  2469. var infocode int64
  2470. var resThree ResultThree
  2471. var resThree10265 ResultThree10265
  2472. if miConfig.MdtrtareaAdmvs == "421300" {
  2473. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2474. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2475. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id
  2476. resp, requestErr := http.Get(api)
  2477. if requestErr != nil {
  2478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2479. return
  2480. }
  2481. body, ioErr := ioutil.ReadAll(resp.Body)
  2482. if ioErr != nil {
  2483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2485. return
  2486. }
  2487. var respJSON map[string]interface{}
  2488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2491. return
  2492. }
  2493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2494. result, _ := json.Marshal(respJSON)
  2495. fmt.Println("log")
  2496. fmt.Println(string(result))
  2497. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2498. utils.ErrorLog("解析失败:%v", err)
  2499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2500. return
  2501. }
  2502. infocode = resThree.Infcode
  2503. } else {
  2504. fmt.Println(roles.UserName)
  2505. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  2506. saveLog(result, requestLog, "2201", "挂号")
  2507. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2508. utils.ErrorLog("解析失败:%v", err)
  2509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2510. return
  2511. }
  2512. if miConfig.Code == "H15049901371" {
  2513. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2514. } else {
  2515. infocode = resThree.Infcode
  2516. }
  2517. }
  2518. if infocode != 0 {
  2519. adminUser := c.GetAdminUserInfo()
  2520. errlog := &models.HisOrderError{
  2521. UserOrgId: adminUser.CurrentOrgId,
  2522. Ctime: time.Now().Unix(),
  2523. Mtime: time.Now().Unix(),
  2524. ErrMsg: resThree.ErrMsg,
  2525. Status: 1,
  2526. PatientId: id,
  2527. RecordTime: recordDateTime,
  2528. Stage: 2,
  2529. }
  2530. service.CreateErrMsgLog(errlog)
  2531. c.ServeSuccessJSON(map[string]interface{}{
  2532. "failed_code": -10,
  2533. "msg": resThree.ErrMsg,
  2534. })
  2535. return
  2536. }
  2537. his.Number = resThree.Output.Data.MdtrtID
  2538. his.PsnNo = resThree.Output.Data.PsnNo
  2539. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2540. his.IdCardNo = patient.IdCardNo
  2541. his.PhoneNumber = patient.Phone
  2542. his.UserOrgId = adminInfo.CurrentOrgId
  2543. his.Ctime = time.Now().Unix()
  2544. his.Mtime = time.Now().Unix()
  2545. his.InsuplcAdmdvs = insuplc_admdvs
  2546. his.Status = 1
  2547. service.UpdateHisPatientStatus(&his)
  2548. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2549. c.ServeSuccessJSON(map[string]interface{}{
  2550. "his_info": his,
  2551. })
  2552. } else {
  2553. adminUser := c.GetAdminUserInfo()
  2554. errlog := &models.HisOrderError{
  2555. UserOrgId: adminUser.CurrentOrgId,
  2556. Ctime: time.Now().Unix(),
  2557. Mtime: time.Now().Unix(),
  2558. ErrMsg: res.ErrMsg,
  2559. Status: 1,
  2560. PatientId: id,
  2561. RecordTime: recordDateTime,
  2562. Stage: 1,
  2563. }
  2564. service.CreateErrMsgLog(errlog)
  2565. c.ServeSuccessJSON(map[string]interface{}{
  2566. "failed_code": -10,
  2567. "msg": res.ErrMsg,
  2568. })
  2569. return
  2570. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2571. }
  2572. }
  2573. }
  2574. //上传明细----预结算----确认订单
  2575. func (c *HisApiController) GetUploadInfo() {
  2576. id, _ := c.GetInt64("id")
  2577. record_time := c.GetString("record_time")
  2578. his_patient_id, _ := c.GetInt64("his_patient_id")
  2579. order_id, _ := c.GetInt64("order_id")
  2580. pay_way, _ := c.GetInt64("pay_way")
  2581. pay_price, _ := c.GetFloat("pay_price")
  2582. pay_card_no := c.GetString("pay_card_no")
  2583. discount_price, _ := c.GetFloat("discount_price")
  2584. preferential_price, _ := c.GetFloat("preferential_price")
  2585. reality_price, _ := c.GetFloat("reality_price")
  2586. found_price, _ := c.GetFloat("found_price")
  2587. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2588. private_price, _ := c.GetFloat("private_price")
  2589. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2590. admin_user_id, _ := c.GetInt64("admin_user_id")
  2591. fapiao_code := c.GetString("fapiao_code")
  2592. fapiao_number := c.GetString("fapiao_number")
  2593. diagnosis_id := c.GetString("diagnosis")
  2594. sick_type, _ := c.GetInt64("sick_type")
  2595. reg_type, _ := c.GetInt64("p_type")
  2596. id_str := c.GetString("ids")
  2597. ids_arr := strings.Split(id_str, ",")
  2598. timeLayout := "2006-01-02"
  2599. loc, _ := time.LoadLocation("Local")
  2600. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2601. if err != nil {
  2602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2603. return
  2604. }
  2605. recordDateTime := theTime.Unix()
  2606. adminUser := c.GetAdminUserInfo()
  2607. var tempOrder models.HisOrder
  2608. tempOrder, _ = service.GetHisOrderByID(order_id)
  2609. var prescriptions []*models.HisPrescription
  2610. var start_time int64
  2611. var end_time int64
  2612. //if adminUser.CurrentOrgId == 10106{
  2613. // if len(fapiao_code) == 0{
  2614. // fapiao_code = "144072080589"
  2615. // }
  2616. // if len(fapiao_number) == 0{
  2617. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  2618. // if order.ID == 0{
  2619. // fapiao_number = "00001520"
  2620. // }else{
  2621. // //fapiao_code = "00001520"
  2622. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  2623. // var zero string
  2624. // if fpNumber >= 1000{
  2625. // zero = "0000" + strconv.Itoa(fpNumber)
  2626. // }else if fpNumber >= 10000{
  2627. // zero = "000" + strconv.Itoa(fpNumber)
  2628. // } else if fpNumber >= 100000{
  2629. // zero = "00" + strconv.Itoa(fpNumber)
  2630. // } else if fpNumber >= 1000000{
  2631. // zero = "0" + strconv.Itoa(fpNumber)
  2632. // }else {
  2633. // zero = strconv.Itoa(fpNumber)
  2634. // }
  2635. // fapiao_number = zero
  2636. // }
  2637. // }
  2638. //}
  2639. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2640. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2641. var patientPrescription models.HisPrescriptionInfo
  2642. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2643. if patientPrescription.ID == 0 {
  2644. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2645. }
  2646. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2647. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2648. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2649. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2650. var config []*models.HisXtDiagnoseConfig
  2651. for _, item := range diagnosis_ids {
  2652. id, _ := strconv.ParseInt(item, 10, 64)
  2653. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2654. config = append(config, &diagnosisConfig)
  2655. }
  2656. sickConfig, _ := service.FindSickById(sick_type)
  2657. if tempOrder.ID == 0 {
  2658. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  2659. }
  2660. if tempOrder.ID == 0 {
  2661. var result string
  2662. var requestLog string
  2663. var res2 ResultSix
  2664. if miConfig.InsuplcAdmdvs == "421300" {
  2665. data := make(map[string]interface{})
  2666. client := &http.Client{}
  2667. data["psn_no"] = his.PsnNo
  2668. data["mdtrt_id"] = his.Number
  2669. data["doctor"] = roles.UserName
  2670. data["department"] = department.Name
  2671. data["org_name"] = miConfig.OrgName
  2672. data["med_type"] = strconv.FormatInt(reg_type, 10)
  2673. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  2674. data["fixmedins_code"] = miConfig.Code
  2675. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2676. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2677. data["secret_key"] = miConfig.SecretKey
  2678. data["sick_code"] = sickConfig.CountryCode
  2679. data["sick_name"] = sickConfig.ClassName
  2680. data["dept"] = strconv.FormatInt(department.ID, 10)
  2681. data["config"] = config
  2682. bytesData, _ := json.Marshal(data)
  2683. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  2684. resp, _ := client.Do(req)
  2685. defer resp.Body.Close()
  2686. body, ioErr := ioutil.ReadAll(resp.Body)
  2687. if ioErr != nil {
  2688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. return
  2691. }
  2692. var respJSON map[string]interface{}
  2693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. return
  2697. }
  2698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2699. userJSONBytes, _ := json.Marshal(respJSON)
  2700. fmt.Println("log")
  2701. fmt.Println(string(userJSONBytes))
  2702. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2703. utils.ErrorLog("解析失败:%v", err)
  2704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2705. return
  2706. }
  2707. } else {
  2708. if miConfig.InsuplcAdmdvs == "440781" { //
  2709. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2710. } else {
  2711. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2712. }
  2713. saveLog(result, requestLog, "2203", "上传就诊信息")
  2714. var respJSON2 map[string]interface{}
  2715. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. return
  2719. }
  2720. userJSONBytes2, _ := json.Marshal(respJSON2)
  2721. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2722. utils.ErrorLog("解析失败:%v", err)
  2723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2724. return
  2725. }
  2726. }
  2727. if res2.Infcode != 0 {
  2728. adminUser := c.GetAdminUserInfo()
  2729. errlog := &models.HisOrderError{
  2730. UserOrgId: adminUser.CurrentOrgId,
  2731. Ctime: time.Now().Unix(),
  2732. Mtime: time.Now().Unix(),
  2733. ErrMsg: res2.ErrMsg,
  2734. Status: 1,
  2735. PatientId: id,
  2736. RecordTime: recordDateTime,
  2737. Stage: 3,
  2738. }
  2739. service.CreateErrMsgLog(errlog)
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "failed_code": -10,
  2742. "msg": res2.ErrMsg,
  2743. })
  2744. return
  2745. } else {
  2746. his.Diagnosis = diagnosis_id
  2747. his.SickType = sickConfig.ID
  2748. var p_type int64
  2749. if reg_type == 1111 || reg_type == 1112 {
  2750. p_type = 11
  2751. }
  2752. his.PType = fmt.Sprintf("%d", p_type)
  2753. service.UpdateHisPatientThree(&his)
  2754. data := make(map[string]interface{})
  2755. if settle_accounts_type == 1 { //日结
  2756. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  2757. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  2758. } else {
  2759. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  2760. }
  2761. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  2762. data["pre"] = prescriptions
  2763. } else { //月结
  2764. start_time_str := c.GetString("start_time")
  2765. end_time_str := c.GetString("end_time")
  2766. timeLayout := "2006-01-02"
  2767. loc, _ := time.LoadLocation("Local")
  2768. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2769. if err != nil {
  2770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2771. return
  2772. }
  2773. recordStartTime := theStartTime.Unix()
  2774. start_time = recordStartTime
  2775. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2776. if err != nil {
  2777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2778. return
  2779. }
  2780. recordEndTime := theEndTime.Unix()
  2781. end_time = recordEndTime
  2782. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  2783. data["pre"] = prescriptions
  2784. }
  2785. timestamp := time.Now().Unix()
  2786. tempTime := time.Unix(timestamp, 0)
  2787. timeFormat := tempTime.Format("20060102150405")
  2788. chrgBchno := rand.Intn(100000) + 10000
  2789. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2790. strconv.FormatInt(his.PatientId, 10)
  2791. client := &http.Client{}
  2792. data["psn_no"] = his.PsnNo
  2793. data["mdtrt_id"] = his.Number
  2794. data["chrg_bchno"] = chrg_bchno
  2795. data["org_name"] = miConfig.OrgName
  2796. data["doctor"] = roles.UserName
  2797. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2798. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2799. data["fixmedins_code"] = miConfig.Code
  2800. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  2801. data["dept_code"] = "15"
  2802. } else {
  2803. data["dept_code"] = department.Number
  2804. }
  2805. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2806. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2807. data["secret_key"] = miConfig.SecretKey
  2808. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  2809. var ids []int64
  2810. for _, item := range prescriptions {
  2811. ids = append(ids, item.ID)
  2812. }
  2813. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2814. if config.IsOpen == 1 { //对接了医保,走医保流程
  2815. var res ResultFour
  2816. if miConfig.MdtrtareaAdmvs == "421300" {
  2817. bytesData, _ := json.Marshal(data)
  2818. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  2819. resp, _ := client.Do(req)
  2820. defer resp.Body.Close()
  2821. body, ioErr := ioutil.ReadAll(resp.Body)
  2822. if ioErr != nil {
  2823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2825. return
  2826. }
  2827. var respJSON map[string]interface{}
  2828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2831. return
  2832. }
  2833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2834. userJSONBytes, _ := json.Marshal(respJSON)
  2835. fmt.Println("log")
  2836. fmt.Println(string(userJSONBytes))
  2837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2838. utils.ErrorLog("解析失败:%v", err)
  2839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2840. return
  2841. }
  2842. } else {
  2843. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10))
  2844. var dat map[string]interface{}
  2845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2846. fmt.Println(dat)
  2847. } else {
  2848. fmt.Println(err)
  2849. }
  2850. saveLog(result, request_log, "2204", "上传费用明细")
  2851. userJSONBytes, _ := json.Marshal(dat)
  2852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2853. utils.ErrorLog("解析失败:%v", err)
  2854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2855. return
  2856. }
  2857. }
  2858. if res.Infcode == 0 {
  2859. order := &models.HisOrder{
  2860. UserOrgId: adminUser.CurrentOrgId,
  2861. HisPatientId: his.ID,
  2862. PatientId: his.PatientId,
  2863. SettleAccountsDate: recordDateTime,
  2864. Ctime: time.Now().Unix(),
  2865. Mtime: time.Now().Unix(),
  2866. Status: 1,
  2867. Number: chrg_bchno,
  2868. Infcode: res.Infcode,
  2869. WarnMsg: res.WarnMsg,
  2870. Cainfo: res.Cainfo,
  2871. ErrMsg: res.ErrMsg,
  2872. RespondTime: res.RefmsgTime,
  2873. InfRefmsgid: res.InfRefmsgid,
  2874. OrderStatus: 1,
  2875. PayWay: pay_way,
  2876. PayPrice: pay_price,
  2877. PayCardNo: pay_card_no,
  2878. DiscountPrice: discount_price,
  2879. PreferentialPrice: preferential_price,
  2880. RealityPrice: reality_price,
  2881. FoundPrice: found_price,
  2882. MedicalInsurancePrice: medical_insurance_price,
  2883. PrivatePrice: private_price,
  2884. IsMedicineInsurance: 1,
  2885. SettleType: settle_accounts_type,
  2886. SettleStartTime: start_time,
  2887. SettleEndTime: end_time,
  2888. Creator: roles.AdminUserId,
  2889. Modify: roles.AdminUserId,
  2890. FaPiaoNumber: fapiao_number,
  2891. FaPiaoCode: fapiao_code,
  2892. PType: 2,
  2893. Diagnosis: diagnosis_id,
  2894. }
  2895. err = service.CreateOrder(order)
  2896. if err != nil {
  2897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2898. return
  2899. }
  2900. for _, item := range res.Output.Result {
  2901. temp := strings.Split(item.FeedetlSn, "-")
  2902. var advice_id int64 = 0
  2903. var project_id int64 = 0
  2904. var types int64 = 0
  2905. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2906. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2907. if temp[1] == "1" {
  2908. advice_id = id
  2909. project_id = 0
  2910. } else if temp[1] == "2" {
  2911. advice_id = 0
  2912. project_id = id
  2913. }
  2914. info := &models.HisOrderInfo{
  2915. OrderNumber: order.Number,
  2916. FeedetlSn: item.FeedetlSn,
  2917. UploadDate: time.Now().Unix(),
  2918. AdviceId: advice_id,
  2919. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2920. Cnt: item.Cnt,
  2921. Pric: float64(item.Pric),
  2922. PatientId: his.PatientId,
  2923. PricUplmtAmt: item.PricUplmtAmt,
  2924. SelfpayProp: item.SelfpayProp,
  2925. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2926. OverlmtAmt: item.OverlmtAmt,
  2927. PreselfpayAmt: item.PreselfpayAmt,
  2928. BasMednFlag: item.BasMednFlag,
  2929. MedChrgitmType: item.MedChrgitmType,
  2930. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2931. Status: 1,
  2932. Memo: item.Memo,
  2933. Mtime: time.Now().Unix(),
  2934. InscpScpAmt: item.InscpScpAmt,
  2935. DrtReimFlag: item.DrtReimFlag,
  2936. Ctime: time.Now().Unix(),
  2937. ListSpItemFlag: item.ListSpItemFlag,
  2938. ChldMedcFlag: item.ChldMedcFlag,
  2939. LmtUsedFlag: item.LmtUsedFlag,
  2940. ChrgitmLv: item.ChrgitmLv,
  2941. UserOrgId: adminUser.CurrentOrgId,
  2942. HisPatientId: his.ID,
  2943. OrderId: order.ID,
  2944. ProjectId: project_id,
  2945. Type: types,
  2946. }
  2947. service.CreateOrderInfo(info)
  2948. }
  2949. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2950. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2951. var total float64
  2952. for _, item := range prescriptions {
  2953. if item.Type == 1 { //药品
  2954. for _, subItem := range item.HisDoctorAdviceInfo {
  2955. total = total + (subItem.Price * subItem.PrescribingNumber)
  2956. }
  2957. }
  2958. if item.Type == 2 { //项目
  2959. for _, subItem := range item.HisPrescriptionProject {
  2960. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2961. total = total + (subItem.Price * cnt)
  2962. }
  2963. }
  2964. }
  2965. for _, item := range prescriptions {
  2966. for _, subItem := range item.HisAdditionalCharge {
  2967. total = total + (subItem.Price * float64(subItem.Count))
  2968. }
  2969. }
  2970. var allTotal string
  2971. if adminUser.CurrentOrgId == 9919 {
  2972. allTotal = fmt.Sprintf("%.2f", total)
  2973. } else {
  2974. allTotal = fmt.Sprintf("%.4f", total)
  2975. }
  2976. if res.Infcode == 0 {
  2977. var rf []*ResultFive
  2978. json.Unmarshal([]byte(his.Iinfo), &rf)
  2979. chrg_bchno := chrg_bchno
  2980. cert_no := his.Certno
  2981. var insutypes []string
  2982. var insutype string
  2983. var is390 int = 0
  2984. var is310 int = 0
  2985. for _, item := range rf {
  2986. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2987. insutypes = append(insutypes, item.Insutype)
  2988. }
  2989. }
  2990. if len(insutypes) == 1 {
  2991. insutype = insutypes[0]
  2992. } else {
  2993. for _, i := range insutypes {
  2994. if i == "390" {
  2995. is390 = 1
  2996. }
  2997. if i == "310" {
  2998. is310 = 1
  2999. }
  3000. }
  3001. }
  3002. if is390 == 1 {
  3003. insutype = "390"
  3004. }
  3005. if is310 == 1 {
  3006. insutype = "310"
  3007. }
  3008. if len(insutypes) == 0 {
  3009. insutype = "310"
  3010. }
  3011. if len(insutypes) == 2 {
  3012. insutype = strconv.FormatInt(his.SocialType, 10)
  3013. }
  3014. //insutype = "390"
  3015. if his.IdCardType == 1 {
  3016. // cert_no = his.MedicalInsuranceNumber
  3017. cert_no = his.Certno
  3018. } else {
  3019. cert_no = his.Certno
  3020. }
  3021. var res ResultSeven
  3022. var src_resquest string
  3023. var result2 string
  3024. var acct_used_flag string
  3025. fmt.Println("pay_way")
  3026. fmt.Println(pay_way)
  3027. fmt.Println("pay_way")
  3028. if pay_way == 4 {
  3029. acct_used_flag = "1"
  3030. } else {
  3031. acct_used_flag = "0"
  3032. }
  3033. if miConfig.MdtrtareaAdmvs == "421300" {
  3034. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3036. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3037. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3040. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3041. resp, requestErr := http.Get(api)
  3042. if requestErr != nil {
  3043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3044. return
  3045. }
  3046. body, ioErr := ioutil.ReadAll(resp.Body)
  3047. if ioErr != nil {
  3048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3050. return
  3051. }
  3052. var respJSON map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3059. result, _ := json.Marshal(respJSON)
  3060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. } else {
  3066. result2, 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, acct_used_flag)
  3067. var dat map[string]interface{}
  3068. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3069. fmt.Println(dat)
  3070. } else {
  3071. fmt.Println(err)
  3072. }
  3073. saveLog(result2, src_resquest, "2207", "结算")
  3074. userJSONBytes, _ := json.Marshal(dat)
  3075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3076. utils.ErrorLog("解析失败:%v", err)
  3077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3078. return
  3079. }
  3080. }
  3081. if res.Infcode != 0 {
  3082. errlog := &models.HisOrderError{
  3083. UserOrgId: adminUser.CurrentOrgId,
  3084. Ctime: time.Now().Unix(),
  3085. Mtime: time.Now().Unix(),
  3086. Number: chrg_bchno,
  3087. ErrMsg: res.ErrMsg,
  3088. Status: 1,
  3089. PatientId: id,
  3090. RecordTime: recordDateTime,
  3091. Stage: 6,
  3092. }
  3093. service.CreateErrMsgLog(errlog)
  3094. c.ServeSuccessJSON(map[string]interface{}{
  3095. "failed_code": -10,
  3096. "msg": res.ErrMsg,
  3097. })
  3098. return
  3099. } else {
  3100. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3101. order.OrderStatus = 2
  3102. order.Status = 1
  3103. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3104. order.SetlId = res.Output.Setlinfo.SetlID
  3105. order.PsnNo = res.Output.Setlinfo.PsnNo
  3106. order.PsnName = res.Output.Setlinfo.PsnName
  3107. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3108. order.Certno = res.Output.Setlinfo.Certno
  3109. order.Gend = res.Output.Setlinfo.Gend
  3110. order.Naty = res.Output.Setlinfo.Naty
  3111. order.Age = res.Output.Setlinfo.Age
  3112. order.Insutype = res.Output.Setlinfo.Insutype
  3113. order.PsnType = res.Output.Setlinfo.PsnType
  3114. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3115. order.SetlTime = res.Output.Setlinfo.SetlTime
  3116. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3117. if res.Output.Setlinfo.MedType == "140101" {
  3118. order.MedType = "14"
  3119. } else {
  3120. order.MedType = res.Output.Setlinfo.MedType
  3121. }
  3122. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3123. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3124. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3125. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3126. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3127. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3128. order.HifpPay = res.Output.Setlinfo.HifpPay
  3129. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3130. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3131. order.HifesPay = res.Output.Setlinfo.HifesPay
  3132. order.HifobPay = res.Output.Setlinfo.HifobPay
  3133. order.MafPay = res.Output.Setlinfo.MafPay
  3134. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3135. order.OthPay = res.Output.Setlinfo.OthPay
  3136. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3137. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3138. order.AcctPay = res.Output.Setlinfo.AcctPay
  3139. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3140. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3141. order.Balc = res.Output.Setlinfo.Balc
  3142. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3143. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3144. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3145. order.ClrWay = res.Output.Setlinfo.ClrWay
  3146. order.Creator = order.Creator
  3147. order.Modify = roles.AdminUserId
  3148. order.RequestLog = src_resquest
  3149. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3150. detailStr := string(setlDetail)
  3151. order.SetlDetail = detailStr
  3152. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3153. err = service.UpDateOrder(order)
  3154. if err == nil {
  3155. c.ServeSuccessJSON(map[string]interface{}{
  3156. "msg": "结算成功",
  3157. })
  3158. } else {
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3160. return
  3161. }
  3162. }
  3163. } else {
  3164. adminUser := c.GetAdminUserInfo()
  3165. errlog := &models.HisOrderError{
  3166. UserOrgId: adminUser.CurrentOrgId,
  3167. Ctime: time.Now().Unix(),
  3168. Mtime: time.Now().Unix(),
  3169. ErrMsg: res.ErrMsg,
  3170. Status: 1,
  3171. PatientId: id,
  3172. RecordTime: recordDateTime,
  3173. Stage: 4,
  3174. }
  3175. service.CreateErrMsgLog(errlog)
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3177. return
  3178. }
  3179. } else {
  3180. adminUser := c.GetAdminUserInfo()
  3181. errlog := &models.HisOrderError{
  3182. UserOrgId: adminUser.CurrentOrgId,
  3183. Ctime: time.Now().Unix(),
  3184. Mtime: time.Now().Unix(),
  3185. ErrMsg: res.ErrMsg,
  3186. Status: 1,
  3187. PatientId: id,
  3188. RecordTime: recordDateTime,
  3189. Stage: 4,
  3190. }
  3191. service.CreateErrMsgLog(errlog)
  3192. c.ServeSuccessJSON(map[string]interface{}{
  3193. "failed_code": -10,
  3194. "msg": res.ErrMsg,
  3195. })
  3196. return
  3197. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3198. //return
  3199. }
  3200. }
  3201. }
  3202. } else if tempOrder.ID > 0 {
  3203. if tempOrder.IsPre == 1 {
  3204. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3205. var rf []*ResultFive
  3206. json.Unmarshal([]byte(his.Iinfo), &rf)
  3207. chrg_bchno := tempOrder.Number
  3208. cert_no := his.Certno
  3209. var insutypes []string
  3210. var insutype string
  3211. var is390 int = 0
  3212. var is310 int = 0
  3213. for _, item := range rf {
  3214. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3215. insutypes = append(insutypes, item.Insutype)
  3216. }
  3217. }
  3218. if len(insutypes) == 1 {
  3219. insutype = insutypes[0]
  3220. } else {
  3221. for _, i := range insutypes {
  3222. if i == "390" {
  3223. is390 = 1
  3224. }
  3225. if i == "310" {
  3226. is310 = 1
  3227. }
  3228. }
  3229. }
  3230. if is390 == 1 {
  3231. insutype = "390"
  3232. }
  3233. if is310 == 1 {
  3234. insutype = "310"
  3235. }
  3236. if len(insutypes) == 0 {
  3237. insutype = "310"
  3238. }
  3239. if len(insutypes) == 2 {
  3240. insutype = strconv.FormatInt(his.SocialType, 64)
  3241. }
  3242. //insutype = "390"
  3243. if his.IdCardType == 1 {
  3244. // cert_no = his.MedicalInsuranceNumber
  3245. cert_no = his.Certno
  3246. } else {
  3247. cert_no = his.Certno
  3248. }
  3249. var res ResultSeven
  3250. var src_resquest string
  3251. var result2 string
  3252. var acct_used_flag string
  3253. fmt.Println("pay_way")
  3254. fmt.Println(pay_way)
  3255. fmt.Println("pay_way")
  3256. if pay_way == 4 {
  3257. acct_used_flag = "1"
  3258. } else {
  3259. acct_used_flag = "0"
  3260. }
  3261. if miConfig.MdtrtareaAdmvs == "421300" {
  3262. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3263. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3264. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3265. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3266. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3267. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3268. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3269. resp, requestErr := http.Get(api)
  3270. if requestErr != nil {
  3271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3272. return
  3273. }
  3274. body, ioErr := ioutil.ReadAll(resp.Body)
  3275. if ioErr != nil {
  3276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3278. return
  3279. }
  3280. var respJSON map[string]interface{}
  3281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3284. return
  3285. }
  3286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3287. result, _ := json.Marshal(respJSON)
  3288. fmt.Println("log")
  3289. fmt.Println(string(result))
  3290. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3291. utils.ErrorLog("解析失败:%v", err)
  3292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. return
  3294. }
  3295. } else {
  3296. result2, 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, acct_used_flag)
  3297. var dat map[string]interface{}
  3298. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3299. fmt.Println(dat)
  3300. } else {
  3301. fmt.Println(err)
  3302. }
  3303. saveLog(result2, src_resquest, "2207", "结算")
  3304. userJSONBytes, _ := json.Marshal(dat)
  3305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3306. utils.ErrorLog("解析失败:%v", err)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. return
  3309. }
  3310. }
  3311. if res.Infcode != 0 {
  3312. errlog := &models.HisOrderError{
  3313. UserOrgId: adminUser.CurrentOrgId,
  3314. Ctime: time.Now().Unix(),
  3315. Mtime: time.Now().Unix(),
  3316. Number: chrg_bchno,
  3317. ErrMsg: res.ErrMsg,
  3318. Status: 1,
  3319. PatientId: id,
  3320. RecordTime: recordDateTime,
  3321. Stage: 6,
  3322. }
  3323. service.CreateErrMsgLog(errlog)
  3324. c.ServeSuccessJSON(map[string]interface{}{
  3325. "failed_code": -10,
  3326. "msg": res.ErrMsg,
  3327. })
  3328. return
  3329. } else {
  3330. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3331. order.OrderStatus = 2
  3332. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3333. order.SetlId = res.Output.Setlinfo.SetlID
  3334. order.PsnNo = res.Output.Setlinfo.PsnNo
  3335. order.PsnName = res.Output.Setlinfo.PsnName
  3336. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3337. order.Certno = res.Output.Setlinfo.Certno
  3338. order.Gend = res.Output.Setlinfo.Gend
  3339. order.Naty = res.Output.Setlinfo.Naty
  3340. order.Age = res.Output.Setlinfo.Age
  3341. order.Insutype = res.Output.Setlinfo.Insutype
  3342. order.PsnType = res.Output.Setlinfo.PsnType
  3343. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3344. order.SetlTime = res.Output.Setlinfo.SetlTime
  3345. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3346. order.MedType = res.Output.Setlinfo.MedType
  3347. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3348. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3349. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3350. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3351. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3352. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3353. order.HifpPay = res.Output.Setlinfo.HifpPay
  3354. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3355. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3356. order.HifesPay = res.Output.Setlinfo.HifesPay
  3357. order.HifobPay = res.Output.Setlinfo.HifobPay
  3358. order.MafPay = res.Output.Setlinfo.MafPay
  3359. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3360. order.OthPay = res.Output.Setlinfo.OthPay
  3361. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3362. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3363. order.AcctPay = res.Output.Setlinfo.AcctPay
  3364. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3365. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3366. order.Balc = res.Output.Setlinfo.Balc
  3367. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3368. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3369. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3370. order.ClrWay = res.Output.Setlinfo.ClrWay
  3371. order.Creator = order.Creator
  3372. order.Modify = roles.AdminUserId
  3373. order.RequestLog = src_resquest
  3374. order.Diagnosis = diagnosis_id
  3375. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3376. detailStr := string(setlDetail)
  3377. order.SetlDetail = detailStr
  3378. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3379. err = service.UpDateOrder(order)
  3380. if err == nil {
  3381. c.ServeSuccessJSON(map[string]interface{}{
  3382. "msg": "结算成功",
  3383. })
  3384. } else {
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3386. return
  3387. }
  3388. }
  3389. }
  3390. }
  3391. }
  3392. //func (c *HisApiController) GetPreUploadInfo() {
  3393. // id, _ := c.GetInt64("id")
  3394. // record_time := c.GetString("record_time")
  3395. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3396. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3397. //
  3398. // timeLayout := "2006-01-02"
  3399. // loc, _ := time.LoadLocation("Local")
  3400. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3401. // if err != nil {
  3402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3403. // return
  3404. // }
  3405. // recordDateTime := theTime.Unix()
  3406. // adminUser := c.GetAdminUserInfo()
  3407. //
  3408. // var prescriptions []*models.HisPrescription
  3409. //
  3410. // var start_time int64
  3411. // var end_time int64
  3412. //
  3413. // data := make(map[string]interface{})
  3414. // if settle_accounts_type == 1 { //日结
  3415. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3416. // data["pre"] = prescriptions
  3417. //
  3418. // } else { //月结
  3419. // start_time_str := c.GetString("start_time")
  3420. // end_time_str := c.GetString("end_time")
  3421. // timeLayout := "2006-01-02"
  3422. // loc, _ := time.LoadLocation("Local")
  3423. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3424. // if err != nil {
  3425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3426. // return
  3427. // }
  3428. // recordStartTime := theStartTime.Unix()
  3429. // start_time = recordStartTime
  3430. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3431. // if err != nil {
  3432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3433. // return
  3434. // }
  3435. // recordEndTime := theEndTime.Unix()
  3436. // end_time = recordEndTime
  3437. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3438. // data["pre"] = prescriptions
  3439. //
  3440. // }
  3441. //
  3442. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3443. //
  3444. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3445. // timestamp := time.Now().Unix()
  3446. // tempTime := time.Unix(timestamp, 0)
  3447. // timeFormat := tempTime.Format("20060102150405")
  3448. // chrgBchno := rand.Intn(100000) + 10000
  3449. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3450. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3451. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3452. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3453. // strconv.FormatInt(his.PatientId, 10)
  3454. // client := &http.Client{}
  3455. // data["psn_no"] = his.PsnNo
  3456. // data["mdtrt_id"] = his.Number
  3457. // data["chrg_bchno"] = chrg_bchno
  3458. // data["org_name"] = miConfig.OrgName
  3459. // data["doctor"] = roles.UserName
  3460. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3461. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3462. // data["fixmedins_code"] = miConfig.Code
  3463. // data["dept_code"] = department.Number
  3464. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3465. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3466. // data["secret_key"] = miConfig.SecretKey
  3467. // var ids []int64
  3468. //
  3469. // for _, item := range prescriptions {
  3470. // ids = append(ids, item.ID)
  3471. // }
  3472. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3473. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3474. // bytesData, _ := json.Marshal(data)
  3475. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3476. // resp, _ := client.Do(req)
  3477. // defer resp.Body.Close()
  3478. // body, ioErr := ioutil.ReadAll(resp.Body)
  3479. // if ioErr != nil {
  3480. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. // return
  3483. // }
  3484. // var respJSON map[string]interface{}
  3485. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3486. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3488. // return
  3489. // }
  3490. //
  3491. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3492. // userJSONBytes, _ := json.Marshal(respJSON)
  3493. // var res ResultFour
  3494. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3495. // utils.ErrorLog("解析失败:%v", err)
  3496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3497. // return
  3498. // }
  3499. //
  3500. // if res.Infcode == 0 {
  3501. // order := &models.HisOrder{
  3502. // UserOrgId: adminUser.CurrentOrgId,
  3503. // HisPatientId: his.ID,
  3504. // PatientId: his.PatientId,
  3505. // SettleAccountsDate: recordDateTime,
  3506. // Ctime: time.Now().Unix(),
  3507. // Mtime: time.Now().Unix(),
  3508. // Status: 1,
  3509. // Number: chrg_bchno,
  3510. // Infcode: res.Infcode,
  3511. // WarnMsg: res.WarnMsg,
  3512. // Cainfo: res.Cainfo,
  3513. // ErrMsg: res.ErrMsg,
  3514. // RespondTime: res.RefmsgTime,
  3515. // InfRefmsgid: res.InfRefmsgid,
  3516. // OrderStatus: 1,
  3517. // IsMedicineInsurance: 1,
  3518. // SettleType: settle_accounts_type,
  3519. // SettleStartTime: start_time,
  3520. // SettleEndTime: end_time,
  3521. // Creator: roles.ID,
  3522. // Modify: roles.ID,
  3523. // PType: 2,
  3524. // }
  3525. // err = service.CreateOrder(order)
  3526. // if err != nil {
  3527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3528. // return
  3529. // }
  3530. //
  3531. // for _, item := range res.Output.Result {
  3532. // temp := strings.Split(item.FeedetlSn, "-")
  3533. // var advice_id int64 = 0
  3534. // var project_id int64 = 0
  3535. // var types int64 = 0
  3536. //
  3537. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3538. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3539. //
  3540. // if temp[1] == "1" {
  3541. // advice_id = id
  3542. // project_id = 0
  3543. // } else if temp[1] == "2" {
  3544. // advice_id = 0
  3545. // project_id = id
  3546. // }
  3547. //
  3548. // info := &models.HisOrderInfo{
  3549. // OrderNumber: order.Number,
  3550. // FeedetlSn: item.FeedetlSn,
  3551. // UploadDate: time.Now().Unix(),
  3552. // AdviceId: advice_id,
  3553. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3554. // Cnt: item.Cnt,
  3555. // Pric: float64(item.Pric),
  3556. // PatientId: his.PatientId,
  3557. // PricUplmtAmt: item.PricUplmtAmt,
  3558. // SelfpayProp: item.SelfpayProp,
  3559. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3560. // OverlmtAmt: item.OverlmtAmt,
  3561. // PreselfpayAmt: item.PreselfpayAmt,
  3562. // BasMednFlag: item.BasMednFlag,
  3563. // MedChrgitmType: item.MedChrgitmType,
  3564. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3565. // Status: 1,
  3566. // Memo: item.Memo,
  3567. // Mtime: time.Now().Unix(),
  3568. // InscpScpAmt: item.InscpScpAmt,
  3569. // DrtReimFlag: item.DrtReimFlag,
  3570. // Ctime: time.Now().Unix(),
  3571. // ListSpItemFlag: item.ListSpItemFlag,
  3572. // ChldMedcFlag: item.ChldMedcFlag,
  3573. // LmtUsedFlag: item.LmtUsedFlag,
  3574. // ChrgitmLv: item.ChrgitmLv,
  3575. // UserOrgId: adminUser.CurrentOrgId,
  3576. // HisPatientId: his.ID,
  3577. // OrderId: order.ID,
  3578. // ProjectId: project_id,
  3579. // Type: types,
  3580. // }
  3581. // service.CreateOrderInfo(info)
  3582. //
  3583. // }
  3584. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3585. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3586. //
  3587. // var total float64
  3588. // for _, item := range prescriptions {
  3589. // if item.Type == 1 { //药品
  3590. // for _, subItem := range item.HisDoctorAdviceInfo {
  3591. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3592. // }
  3593. // }
  3594. // if item.Type == 2 { //项目
  3595. // for _, subItem := range item.HisPrescriptionProject {
  3596. // total = total + (subItem.Price * float64(subItem.Count))
  3597. // }
  3598. // }
  3599. // }
  3600. //
  3601. // for _, item := range prescriptions {
  3602. // for _, subItem := range item.HisAdditionalCharge {
  3603. // total = total + (subItem.Price * float64(subItem.Count))
  3604. // }
  3605. // }
  3606. //
  3607. // allTotal := fmt.Sprintf("%.2f", total)
  3608. // if res.Infcode == 0 {
  3609. // var rf []*ResultFive
  3610. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3611. // psn_no := his.PsnNo
  3612. // mdtrt_id := his.Number
  3613. // chrg_bchno := chrg_bchno
  3614. // cert_no := his.Certno
  3615. // insutype := rf[0].Insutype
  3616. //
  3617. // if his.IdCardType == 1 {
  3618. // cert_no = his.MedicalInsuranceNumber
  3619. //
  3620. // } else {
  3621. //
  3622. // cert_no = his.Certno
  3623. //
  3624. // }
  3625. //
  3626. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  3627. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  3628. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  3629. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  3630. // resp, requestErr := http.Get(api)
  3631. // if requestErr != nil {
  3632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3633. // return
  3634. // }
  3635. // defer resp.Body.Close()
  3636. // body, ioErr := ioutil.ReadAll(resp.Body)
  3637. // if ioErr != nil {
  3638. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3640. // return
  3641. // }
  3642. // var respJSON map[string]interface{}
  3643. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3644. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3646. // return
  3647. // }
  3648. // fmt.Println(respJSON)
  3649. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3650. // userJSONBytes, _ := json.Marshal(respJSON)
  3651. // var res ResultSeven
  3652. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3653. // utils.ErrorLog("解析失败:%v", err)
  3654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3655. // return
  3656. // }
  3657. // if res.Infcode != 0 {
  3658. // errlog := &models.HisOrderError{
  3659. // UserOrgId: adminUser.CurrentOrgId,
  3660. // Ctime: time.Now().Unix(),
  3661. // Mtime: time.Now().Unix(),
  3662. // Number: chrg_bchno,
  3663. // ErrMsg: res.ErrMsg,
  3664. // Status: 1,
  3665. // PatientId: id,
  3666. // RecordTime: recordDateTime,
  3667. // Stage: 7,
  3668. // }
  3669. // service.CreateErrMsgLog(errlog)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3671. // return
  3672. // } else {
  3673. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3674. // order.OrderStatus = 1
  3675. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3676. // order.SetlId = res.Output.Setlinfo.SetlID
  3677. // order.PsnNo = res.Output.Setlinfo.PsnNo
  3678. // order.PsnName = res.Output.Setlinfo.PsnName
  3679. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3680. // order.Certno = res.Output.Setlinfo.Certno
  3681. // order.Gend = res.Output.Setlinfo.Gend
  3682. // order.Naty = res.Output.Setlinfo.Naty
  3683. // order.Age = res.Output.Setlinfo.Age
  3684. // order.Insutype = res.Output.Setlinfo.Insutype
  3685. // order.PsnType = res.Output.Setlinfo.PsnType
  3686. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3687. // order.SetlTime = res.Output.Setlinfo.SetlTime
  3688. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3689. // order.MedType = res.Output.Setlinfo.MedType
  3690. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3691. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3692. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3693. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3694. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3695. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3696. // order.HifpPay = res.Output.Setlinfo.HifpPay
  3697. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3698. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3699. // order.HifesPay = res.Output.Setlinfo.HifesPay
  3700. // order.HifobPay = res.Output.Setlinfo.HifobPay
  3701. // order.MafPay = res.Output.Setlinfo.MafPay
  3702. // order.OthPay = res.Output.Setlinfo.OthPay
  3703. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3704. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3705. // order.AcctPay = res.Output.Setlinfo.AcctPay
  3706. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3707. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3708. // order.Balc = res.Output.Setlinfo.Balc
  3709. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3710. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3711. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3712. // order.ClrWay = res.Output.Setlinfo.ClrWay
  3713. // order.Creator = order.Creator
  3714. // order.Modify = roles.ID
  3715. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3716. // detailStr := string(setlDetail)
  3717. // order.SetlDetail = detailStr
  3718. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3719. // err = service.UpDateOrder(order)
  3720. // if err == nil {
  3721. // c.ServeSuccessJSON(map[string]interface{}{
  3722. // "msg": "预结算成功",
  3723. // })
  3724. // } else {
  3725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3726. // return
  3727. // }
  3728. // }
  3729. // } else {
  3730. // adminUser := c.GetAdminUserInfo()
  3731. // errlog := &models.HisOrderError{
  3732. // UserOrgId: adminUser.CurrentOrgId,
  3733. // Ctime: time.Now().Unix(),
  3734. // Mtime: time.Now().Unix(),
  3735. // ErrMsg: res.ErrMsg,
  3736. // Status: 1,
  3737. // PatientId: id,
  3738. // RecordTime: recordDateTime,
  3739. // Stage: 4,
  3740. // }
  3741. // service.CreateErrMsgLog(errlog)
  3742. //
  3743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3744. // return
  3745. // }
  3746. // } else {
  3747. // adminUser := c.GetAdminUserInfo()
  3748. // errlog := &models.HisOrderError{
  3749. // UserOrgId: adminUser.CurrentOrgId,
  3750. // Ctime: time.Now().Unix(),
  3751. // Mtime: time.Now().Unix(),
  3752. // ErrMsg: res.ErrMsg,
  3753. // Status: 1,
  3754. // PatientId: id,
  3755. // RecordTime: recordDateTime,
  3756. // Stage: 4,
  3757. // }
  3758. // service.CreateErrMsgLog(errlog)
  3759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3760. // return
  3761. // }
  3762. //
  3763. // } else {
  3764. // var total float64
  3765. // for _, item := range prescriptions {
  3766. // if item.Type == 1 { //药品
  3767. // for _, subItem := range item.HisDoctorAdviceInfo {
  3768. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3769. // }
  3770. // }
  3771. // if item.Type == 2 { //项目
  3772. // for _, subItem := range item.HisPrescriptionProject {
  3773. // total = total + (subItem.Price * float64(subItem.Count))
  3774. // }
  3775. // }
  3776. //
  3777. // for _, subItem := range item.HisAdditionalCharge {
  3778. // total = total + (subItem.Price * float64(subItem.Count))
  3779. // }
  3780. // }
  3781. //
  3782. // allTotal := fmt.Sprintf("%.2f", total)
  3783. // totals, _ := strconv.ParseFloat(allTotal, 64)
  3784. // order := &models.HisOrder{
  3785. // UserOrgId: adminUser.CurrentOrgId,
  3786. // HisPatientId: his.ID,
  3787. // PatientId: id,
  3788. // SettleAccountsDate: recordDateTime,
  3789. // Ctime: time.Now().Unix(),
  3790. // Mtime: time.Now().Unix(),
  3791. // Status: 1,
  3792. // OrderStatus: 2,
  3793. // Number: chrg_bchno,
  3794. // MedfeeSumamt: totals,
  3795. // }
  3796. // err = service.CreateOrder(order)
  3797. // if err != nil {
  3798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3799. // return
  3800. // }
  3801. //
  3802. // var customs []*Custom
  3803. // for _, item := range prescriptions {
  3804. //
  3805. // if item.Type == 1 { //药品
  3806. // for _, subItem := range item.HisDoctorAdviceInfo {
  3807. // cus := &Custom{
  3808. // AdviceId: subItem.ID,
  3809. // ProjectId: 0,
  3810. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  3811. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  3812. // FeedetlSn: subItem.FeedetlSn,
  3813. // Price: fmt.Sprintf("%.2f", subItem.Price),
  3814. // MedListCodg: subItem.MedListCodg,
  3815. // Type: 1,
  3816. // }
  3817. // customs = append(customs, cus)
  3818. // }
  3819. // }
  3820. //
  3821. // if item.Type == 2 { //项目
  3822. // for _, subItem := range item.HisPrescriptionProject {
  3823. //
  3824. // cus := &Custom{
  3825. // AdviceId: 0,
  3826. // ProjectId: subItem.ID,
  3827. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  3828. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  3829. // FeedetlSn: subItem.FeedetlSn,
  3830. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  3831. // MedListCodg: subItem.MedListCodg,
  3832. // Type: 2,
  3833. // }
  3834. //
  3835. // customs = append(customs, cus)
  3836. // }
  3837. // }
  3838. //
  3839. // for _, item := range item.HisAdditionalCharge {
  3840. // cus := &Custom{
  3841. // ItemId: item.ID,
  3842. // AdviceId: 0,
  3843. // ProjectId: 0,
  3844. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  3845. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  3846. // FeedetlSn: item.FeedetlSn,
  3847. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  3848. // MedListCodg: item.XtHisAddtionConfig.Code,
  3849. // Type: 3,
  3850. // }
  3851. //
  3852. // customs = append(customs, cus)
  3853. // }
  3854. //
  3855. // }
  3856. //
  3857. // for _, item := range customs {
  3858. // var advice_id int64 = 0
  3859. // var project_id int64 = 0
  3860. // var item_id int64 = 0
  3861. //
  3862. // var types int64 = 0
  3863. //
  3864. // if item.Type == 1 {
  3865. // advice_id = item.AdviceId
  3866. // project_id = 0
  3867. // item_id = 0
  3868. // } else if item.Type == 2 {
  3869. // advice_id = 0
  3870. // item_id = 0
  3871. //
  3872. // project_id = item.ProjectId
  3873. // } else if item.Type == 3 {
  3874. // advice_id = 0
  3875. // item_id = item.ItemId
  3876. // project_id = 0
  3877. // }
  3878. //
  3879. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  3880. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  3881. // pric, _ := strconv.ParseFloat(item.Price, 32)
  3882. //
  3883. // info := &models.HisOrderInfo{
  3884. // OrderNumber: order.Number,
  3885. // UploadDate: time.Now().Unix(),
  3886. // AdviceId: advice_id,
  3887. // DetItemFeeSumamt: detItemFeeSumamt,
  3888. // Cnt: cut,
  3889. // Pric: pric,
  3890. // PatientId: id,
  3891. // Status: 1,
  3892. // Mtime: time.Now().Unix(),
  3893. // Ctime: time.Now().Unix(),
  3894. // UserOrgId: adminUser.CurrentOrgId,
  3895. // HisPatientId: his.ID,
  3896. // OrderId: order.ID,
  3897. // ProjectId: project_id,
  3898. // Type: types,
  3899. // ItemId: item_id,
  3900. // }
  3901. // service.CreateOrderInfo(info)
  3902. // }
  3903. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3904. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3905. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  3906. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3907. // if err == nil {
  3908. // c.ServeSuccessJSON(map[string]interface{}{
  3909. // "msg": "结算成功",
  3910. // })
  3911. // } else {
  3912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3913. // return
  3914. // }
  3915. // }
  3916. //}
  3917. //上传明细-预结算-
  3918. func (c *HisApiController) GetPreUploadInfo() {
  3919. id, _ := c.GetInt64("id")
  3920. record_time := c.GetString("record_time")
  3921. his_patient_id, _ := c.GetInt64("his_patient_id")
  3922. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3923. admin_user_id, _ := c.GetInt64("admin_user_id")
  3924. diagnosis_id := c.GetString("diagnosis")
  3925. sick_type, _ := c.GetInt64("sick_type")
  3926. reg_type, _ := c.GetInt64("p_type")
  3927. id_str := c.GetString("ids")
  3928. ids_arr := strings.Split(id_str, ",")
  3929. timeLayout := "2006-01-02"
  3930. loc, _ := time.LoadLocation("Local")
  3931. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3932. if err != nil {
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3934. return
  3935. }
  3936. recordDateTime := theTime.Unix()
  3937. adminUser := c.GetAdminUserInfo()
  3938. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3939. var config []*models.HisXtDiagnoseConfig
  3940. for _, item := range diagnosis_ids {
  3941. id, _ := strconv.ParseInt(item, 10, 64)
  3942. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3943. config = append(config, &diagnosisConfig)
  3944. }
  3945. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  3946. sickConfig, _ := service.FindSickById(sick_type)
  3947. var prescriptions []*models.HisPrescription
  3948. var start_time int64
  3949. var end_time int64
  3950. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3951. fmt.Println(his_patient_id)
  3952. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3953. timestamp := time.Now().Unix()
  3954. tempTime := time.Unix(timestamp, 0)
  3955. timeFormat := tempTime.Format("20060102150405")
  3956. chrgBchno := rand.Intn(100000) + 10000
  3957. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3959. var patientPrescription models.HisPrescriptionInfo
  3960. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3961. if patientPrescription.ID == 0 {
  3962. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3963. }
  3964. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3965. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3966. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3967. strconv.FormatInt(his.PatientId, 10)
  3968. var res2 ResultSix
  3969. if miConfig.InsuplcAdmdvs == "421300" {
  3970. data := make(map[string]interface{})
  3971. client := &http.Client{}
  3972. data["psn_no"] = his.PsnNo
  3973. data["mdtrt_id"] = his.Number
  3974. data["doctor"] = roles.UserName
  3975. data["department"] = department.Name
  3976. data["org_name"] = miConfig.OrgName
  3977. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3978. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3979. data["fixmedins_code"] = miConfig.Code
  3980. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3981. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3982. data["secret_key"] = miConfig.SecretKey
  3983. data["sick_code"] = sickConfig.CountryCode
  3984. data["sick_name"] = sickConfig.ClassName
  3985. data["dept"] = strconv.FormatInt(department.ID, 10)
  3986. data["config"] = config
  3987. fmt.Println(data)
  3988. bytesData, _ := json.Marshal(data)
  3989. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3990. resp, _ := client.Do(req)
  3991. defer resp.Body.Close()
  3992. body, ioErr := ioutil.ReadAll(resp.Body)
  3993. if ioErr != nil {
  3994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. return
  3997. }
  3998. var respJSON map[string]interface{}
  3999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. return
  4003. }
  4004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4005. userJSONBytes, _ := json.Marshal(respJSON)
  4006. fmt.Println("log")
  4007. fmt.Println(string(userJSONBytes))
  4008. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4009. utils.ErrorLog("解析失败:%v", err)
  4010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4011. return
  4012. }
  4013. } else {
  4014. var result string
  4015. var requestLog string
  4016. if miConfig.InsuplcAdmdvs == "440781" { //
  4017. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  4018. } else {
  4019. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  4020. saveLog(result, requestLog, "2203", "上传就诊信息")
  4021. var respJSON2 map[string]interface{}
  4022. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4025. return
  4026. }
  4027. userJSONBytes2, _ := json.Marshal(respJSON2)
  4028. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4029. utils.ErrorLog("解析失败:%v", err)
  4030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4031. return
  4032. }
  4033. }
  4034. }
  4035. if res2.Infcode != 0 {
  4036. adminUser := c.GetAdminUserInfo()
  4037. errlog := &models.HisOrderError{
  4038. UserOrgId: adminUser.CurrentOrgId,
  4039. Ctime: time.Now().Unix(),
  4040. Mtime: time.Now().Unix(),
  4041. ErrMsg: res2.ErrMsg,
  4042. Status: 1,
  4043. PatientId: id,
  4044. RecordTime: recordDateTime,
  4045. Stage: 3,
  4046. }
  4047. service.CreateErrMsgLog(errlog)
  4048. c.ServeSuccessJSON(map[string]interface{}{
  4049. "failed_code": -10,
  4050. "msg": res2.ErrMsg,
  4051. })
  4052. return
  4053. } else {
  4054. his.Diagnosis = diagnosis_id
  4055. his.SickType = sickConfig.ID
  4056. his.PType = fmt.Sprintf("%d", reg_type)
  4057. service.UpdateHisPatientThree(&his)
  4058. data := make(map[string]interface{})
  4059. if settle_accounts_type == 1 { //日结
  4060. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4061. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4062. } else {
  4063. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4064. }
  4065. data["pre"] = prescriptions
  4066. } else { //月结
  4067. start_time_str := c.GetString("start_time")
  4068. end_time_str := c.GetString("end_time")
  4069. timeLayout := "2006-01-02"
  4070. loc, _ := time.LoadLocation("Local")
  4071. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4072. if err != nil {
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4074. return
  4075. }
  4076. recordStartTime := theStartTime.Unix()
  4077. start_time = recordStartTime
  4078. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4079. if err != nil {
  4080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4081. return
  4082. }
  4083. recordEndTime := theEndTime.Unix()
  4084. end_time = recordEndTime
  4085. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4086. data["pre"] = prescriptions
  4087. }
  4088. client := &http.Client{}
  4089. data["psn_no"] = his.PsnNo
  4090. data["mdtrt_id"] = his.Number
  4091. data["chrg_bchno"] = chrg_bchno
  4092. data["org_name"] = miConfig.OrgName
  4093. data["doctor"] = roles.UserName
  4094. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4095. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4096. data["fixmedins_code"] = miConfig.Code
  4097. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4098. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4099. data["dept_code"] = "15"
  4100. } else {
  4101. data["dept_code"] = department.Number
  4102. }
  4103. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4104. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4105. data["secret_key"] = miConfig.SecretKey
  4106. var ids []int64
  4107. for _, item := range prescriptions {
  4108. ids = append(ids, item.ID)
  4109. }
  4110. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4111. if config.IsOpen == 1 { //对接了医保,走医保流程
  4112. var res ResultFour
  4113. if miConfig.MdtrtareaAdmvs == "421300" {
  4114. bytesData, _ := json.Marshal(data)
  4115. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4116. resp, _ := client.Do(req)
  4117. defer resp.Body.Close()
  4118. body, ioErr := ioutil.ReadAll(resp.Body)
  4119. if ioErr != nil {
  4120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4122. return
  4123. }
  4124. var respJSON map[string]interface{}
  4125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4128. return
  4129. }
  4130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4131. userJSONBytes, _ := json.Marshal(respJSON)
  4132. fmt.Println("log")
  4133. fmt.Println(string(userJSONBytes))
  4134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4135. utils.ErrorLog("解析失败:%v", err)
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. return
  4138. }
  4139. } else {
  4140. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string))
  4141. var dat map[string]interface{}
  4142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4143. fmt.Println(dat)
  4144. } else {
  4145. fmt.Println(err)
  4146. }
  4147. saveLog(result, request_log, "2204", "上传费用明细")
  4148. userJSONBytes, _ := json.Marshal(dat)
  4149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4150. utils.ErrorLog("解析失败:%v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. }
  4155. if res.Infcode == 0 {
  4156. order := &models.HisOrder{
  4157. UserOrgId: adminUser.CurrentOrgId,
  4158. HisPatientId: his.ID,
  4159. PatientId: his.PatientId,
  4160. SettleAccountsDate: recordDateTime,
  4161. Ctime: time.Now().Unix(),
  4162. Mtime: time.Now().Unix(),
  4163. Status: 1,
  4164. Number: chrg_bchno,
  4165. Infcode: res.Infcode,
  4166. WarnMsg: res.WarnMsg,
  4167. Cainfo: res.Cainfo,
  4168. ErrMsg: res.ErrMsg,
  4169. RespondTime: res.RefmsgTime,
  4170. InfRefmsgid: res.InfRefmsgid,
  4171. OrderStatus: 1,
  4172. IsMedicineInsurance: 1,
  4173. SettleType: settle_accounts_type,
  4174. SettleStartTime: start_time,
  4175. SettleEndTime: end_time,
  4176. Creator: roles.AdminUserId,
  4177. Modify: roles.AdminUserId,
  4178. PType: 2,
  4179. Diagnosis: diagnosis_id,
  4180. }
  4181. err = service.CreateOrder(order)
  4182. if err != nil {
  4183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4184. return
  4185. }
  4186. for _, item := range res.Output.Result {
  4187. temp := strings.Split(item.FeedetlSn, "-")
  4188. var advice_id int64 = 0
  4189. var project_id int64 = 0
  4190. var types int64 = 0
  4191. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4192. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4193. if temp[1] == "1" {
  4194. advice_id = id
  4195. project_id = 0
  4196. } else if temp[1] == "2" {
  4197. advice_id = 0
  4198. project_id = id
  4199. }
  4200. info := &models.HisOrderInfo{
  4201. OrderNumber: order.Number,
  4202. FeedetlSn: item.FeedetlSn,
  4203. UploadDate: time.Now().Unix(),
  4204. AdviceId: advice_id,
  4205. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4206. Cnt: item.Cnt,
  4207. Pric: float64(item.Pric),
  4208. PatientId: his.PatientId,
  4209. PricUplmtAmt: item.PricUplmtAmt,
  4210. SelfpayProp: item.SelfpayProp,
  4211. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4212. OverlmtAmt: item.OverlmtAmt,
  4213. PreselfpayAmt: item.PreselfpayAmt,
  4214. BasMednFlag: item.BasMednFlag,
  4215. MedChrgitmType: item.MedChrgitmType,
  4216. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4217. Status: 1,
  4218. Memo: item.Memo,
  4219. Mtime: time.Now().Unix(),
  4220. InscpScpAmt: item.InscpScpAmt,
  4221. DrtReimFlag: item.DrtReimFlag,
  4222. Ctime: time.Now().Unix(),
  4223. ListSpItemFlag: item.ListSpItemFlag,
  4224. ChldMedcFlag: item.ChldMedcFlag,
  4225. LmtUsedFlag: item.LmtUsedFlag,
  4226. ChrgitmLv: item.ChrgitmLv,
  4227. UserOrgId: adminUser.CurrentOrgId,
  4228. HisPatientId: his.ID,
  4229. OrderId: order.ID,
  4230. ProjectId: project_id,
  4231. Type: types,
  4232. }
  4233. service.CreateOrderInfo(info)
  4234. }
  4235. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4236. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4237. var total float64
  4238. for _, item := range prescriptions {
  4239. if item.Type == 1 { //药品
  4240. for _, subItem := range item.HisDoctorAdviceInfo {
  4241. total = total + (subItem.Price * subItem.PrescribingNumber)
  4242. }
  4243. }
  4244. if item.Type == 2 { //项目
  4245. for _, subItem := range item.HisPrescriptionProject {
  4246. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4247. total = total + (subItem.Price * cnt)
  4248. }
  4249. }
  4250. }
  4251. for _, item := range prescriptions {
  4252. for _, subItem := range item.HisAdditionalCharge {
  4253. total = total + (subItem.Price * float64(subItem.Count))
  4254. }
  4255. }
  4256. allTotal := fmt.Sprintf("%.4f", total)
  4257. if res.Infcode == 0 {
  4258. var rf []*ResultFive
  4259. json.Unmarshal([]byte(his.Iinfo), &rf)
  4260. chrg_bchno := chrg_bchno
  4261. cert_no := his.Certno
  4262. var insutypes []string
  4263. var insutype string
  4264. var is390 int = 0
  4265. var is310 int = 0
  4266. for _, item := range rf {
  4267. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4268. insutypes = append(insutypes, item.Insutype)
  4269. }
  4270. }
  4271. if len(insutypes) == 1 {
  4272. insutype = insutypes[0]
  4273. } else {
  4274. for _, i := range insutypes {
  4275. if i == "390" {
  4276. is390 = 1
  4277. }
  4278. if i == "310" {
  4279. is310 = 1
  4280. }
  4281. }
  4282. }
  4283. if is390 == 1 {
  4284. insutype = "390"
  4285. }
  4286. if is310 == 1 {
  4287. insutype = "310"
  4288. }
  4289. if len(insutypes) == 0 {
  4290. insutype = "310"
  4291. }
  4292. if len(insutypes) == 2 {
  4293. insutype = strconv.FormatInt(his.SocialType, 64)
  4294. }
  4295. //insutype = "390"
  4296. if his.IdCardType == 1 {
  4297. cert_no = his.MedicalInsuranceNumber
  4298. } else {
  4299. cert_no = his.Certno
  4300. }
  4301. var res ResultSeven
  4302. if miConfig.MdtrtareaAdmvs == "421300" {
  4303. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4304. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4305. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4306. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4307. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4308. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4309. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4310. resp, requestErr := http.Get(api)
  4311. if requestErr != nil {
  4312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4313. return
  4314. }
  4315. body, ioErr := ioutil.ReadAll(resp.Body)
  4316. if ioErr != nil {
  4317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4319. return
  4320. }
  4321. var respJSON map[string]interface{}
  4322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. return
  4326. }
  4327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4328. result, _ := json.Marshal(respJSON)
  4329. fmt.Println("log")
  4330. fmt.Println(string(result))
  4331. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4332. utils.ErrorLog("解析失败:%v", err)
  4333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4334. return
  4335. }
  4336. } else {
  4337. result, request_log := 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)
  4338. var dat map[string]interface{}
  4339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4340. fmt.Println(dat)
  4341. } else {
  4342. fmt.Println(err)
  4343. }
  4344. saveLog(result, request_log, "2206", "预结算")
  4345. userJSONBytes, _ := json.Marshal(dat)
  4346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4347. utils.ErrorLog("解析失败:%v", err)
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. }
  4352. if res.Infcode != 0 {
  4353. errlog := &models.HisOrderError{
  4354. UserOrgId: adminUser.CurrentOrgId,
  4355. Ctime: time.Now().Unix(),
  4356. Mtime: time.Now().Unix(),
  4357. Number: chrg_bchno,
  4358. ErrMsg: res.ErrMsg,
  4359. Status: 1,
  4360. PatientId: id,
  4361. RecordTime: recordDateTime,
  4362. Stage: 20,
  4363. }
  4364. service.CreateErrMsgLog(errlog)
  4365. c.ServeSuccessJSON(map[string]interface{}{
  4366. "failed_code": -10,
  4367. "msg": res.ErrMsg,
  4368. })
  4369. return
  4370. } else {
  4371. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4372. order.OrderStatus = 1
  4373. order.IsPre = 1
  4374. order.Status = 1
  4375. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4376. order.SetlId = res.Output.Setlinfo.SetlID
  4377. order.PsnNo = res.Output.Setlinfo.PsnNo
  4378. order.PsnName = res.Output.Setlinfo.PsnName
  4379. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4380. order.Certno = res.Output.Setlinfo.Certno
  4381. order.Gend = res.Output.Setlinfo.Gend
  4382. order.Naty = res.Output.Setlinfo.Naty
  4383. order.Age = res.Output.Setlinfo.Age
  4384. order.Insutype = res.Output.Setlinfo.Insutype
  4385. order.PsnType = res.Output.Setlinfo.PsnType
  4386. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4387. order.SetlTime = res.Output.Setlinfo.SetlTime
  4388. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4389. if res.Output.Setlinfo.MedType == "140101" {
  4390. order.MedType = "14"
  4391. } else {
  4392. order.MedType = res.Output.Setlinfo.MedType
  4393. }
  4394. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4395. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4396. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4397. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4398. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4399. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4400. order.HifpPay = res.Output.Setlinfo.HifpPay
  4401. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4402. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4403. order.HifesPay = res.Output.Setlinfo.HifesPay
  4404. order.HifobPay = res.Output.Setlinfo.HifobPay
  4405. order.MafPay = res.Output.Setlinfo.MafPay
  4406. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4407. order.OthPay = res.Output.Setlinfo.OthPay
  4408. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4409. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4410. order.AcctPay = res.Output.Setlinfo.AcctPay
  4411. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4412. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4413. order.Balc = res.Output.Setlinfo.Balc
  4414. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4415. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4416. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4417. order.ClrWay = res.Output.Setlinfo.ClrWay
  4418. order.Creator = order.Creator
  4419. order.Modify = roles.AdminUserId
  4420. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4421. detailStr := string(setlDetail)
  4422. order.SetlDetail = detailStr
  4423. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4424. err = service.UpDateOrder(order)
  4425. if err == nil {
  4426. c.ServeSuccessJSON(map[string]interface{}{
  4427. "msg": "预结算成功",
  4428. })
  4429. } else {
  4430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4431. return
  4432. }
  4433. }
  4434. } else {
  4435. adminUser := c.GetAdminUserInfo()
  4436. errlog := &models.HisOrderError{
  4437. UserOrgId: adminUser.CurrentOrgId,
  4438. Ctime: time.Now().Unix(),
  4439. Mtime: time.Now().Unix(),
  4440. ErrMsg: res.ErrMsg,
  4441. Status: 1,
  4442. PatientId: id,
  4443. RecordTime: recordDateTime,
  4444. Stage: 4,
  4445. }
  4446. service.CreateErrMsgLog(errlog)
  4447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4448. return
  4449. }
  4450. } else {
  4451. adminUser := c.GetAdminUserInfo()
  4452. errlog := &models.HisOrderError{
  4453. UserOrgId: adminUser.CurrentOrgId,
  4454. Ctime: time.Now().Unix(),
  4455. Mtime: time.Now().Unix(),
  4456. ErrMsg: res.ErrMsg,
  4457. Status: 1,
  4458. PatientId: id,
  4459. RecordTime: recordDateTime,
  4460. Stage: 4,
  4461. }
  4462. service.CreateErrMsgLog(errlog)
  4463. c.ServeSuccessJSON(map[string]interface{}{
  4464. "failed_code": -10,
  4465. "msg": res.ErrMsg,
  4466. })
  4467. return
  4468. }
  4469. }
  4470. }
  4471. }
  4472. //func (c *HisApiController) GetSettleInfo() {
  4473. // id, _ := c.GetInt64("id")
  4474. // order_id, _ := c.GetInt64("order_id")
  4475. //
  4476. // record_time := c.GetString("record_time")
  4477. // pay_way, _ := c.GetInt64("pay_way")
  4478. // pay_price, _ := c.GetFloat("pay_price")
  4479. // pay_card_no := c.GetString("pay_card_no")
  4480. // discount_price, _ := c.GetFloat("discount_price")
  4481. // preferential_price, _ := c.GetFloat("preferential_price")
  4482. // reality_price, _ := c.GetFloat("reality_price")
  4483. // found_price, _ := c.GetFloat("found_price")
  4484. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4485. // private_price, _ := c.GetFloat("private_price")
  4486. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4487. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4488. //
  4489. // timeLayout := "2006-01-02"
  4490. // loc, _ := time.LoadLocation("Local")
  4491. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4492. // if err != nil {
  4493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4494. // return
  4495. // }
  4496. // recordDateTime := theTime.Unix()
  4497. // adminUser := c.GetAdminUserInfo()
  4498. //
  4499. // var prescriptions []*models.HisPrescription
  4500. //
  4501. // data := make(map[string]interface{})
  4502. // if settle_accounts_type == 1 { //日结
  4503. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4504. // data["pre"] = prescriptions
  4505. //
  4506. // } else { //月结
  4507. // start_time_str := c.GetString("start_time")
  4508. // end_time_str := c.GetString("end_time")
  4509. // timeLayout := "2006-01-02"
  4510. // loc, _ := time.LoadLocation("Local")
  4511. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4512. // if err != nil {
  4513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4514. // return
  4515. // }
  4516. // recordStartTime := theStartTime.Unix()
  4517. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4518. // if err != nil {
  4519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4520. // return
  4521. // }
  4522. // recordEndTime := theEndTime.Unix()
  4523. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4524. // data["pre"] = prescriptions
  4525. //
  4526. // }
  4527. //
  4528. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4529. //
  4530. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4531. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4532. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4533. // strconv.FormatInt(his.PatientId, 10)
  4534. //
  4535. // order_src, _ := service.GetHisOrderByID(order_id)
  4536. //
  4537. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4538. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4539. //
  4540. // var total float64
  4541. // for _, item := range prescriptions {
  4542. // if item.Type == 1 { //药品
  4543. // for _, subItem := range item.HisDoctorAdviceInfo {
  4544. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4545. // }
  4546. // }
  4547. // if item.Type == 2 { //项目
  4548. // for _, subItem := range item.HisPrescriptionProject {
  4549. // total = total + (subItem.Price * float64(subItem.Count))
  4550. // }
  4551. // }
  4552. // }
  4553. //
  4554. // for _, item := range prescriptions {
  4555. // for _, subItem := range item.HisAdditionalCharge {
  4556. // total = total + (subItem.Price * float64(subItem.Count))
  4557. // }
  4558. // }
  4559. //
  4560. // allTotal := fmt.Sprintf("%.2f", total)
  4561. // var rf []*ResultFive
  4562. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4563. // psn_no := order_src.PsnNo
  4564. // mdtrt_id := order_src.MdtrtId
  4565. // chrg_bchno := order_src.Number
  4566. // cert_no := order_src.Certno
  4567. // insutype := rf[0].Insutype
  4568. //
  4569. // if his.IdCardType == 1 {
  4570. // cert_no = his.MedicalInsuranceNumber
  4571. // } else {
  4572. // cert_no = his.Certno
  4573. // }
  4574. //
  4575. // 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)
  4576. // var dat map[string]interface{}
  4577. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4578. // fmt.Println(dat)
  4579. // } else {
  4580. // fmt.Println(err)
  4581. // }
  4582. //
  4583. // userJSONBytes, _ := json.Marshal(dat)
  4584. //
  4585. //
  4586. //
  4587. // var res ResultSeven
  4588. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4589. // utils.ErrorLog("解析失败:%v", err)
  4590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4591. // return
  4592. // }
  4593. // if res.Infcode == -1 {
  4594. // errlog := &models.HisOrderError{
  4595. // UserOrgId: adminUser.CurrentOrgId,
  4596. // Ctime: time.Now().Unix(),
  4597. // Mtime: time.Now().Unix(),
  4598. // Number: chrg_bchno,
  4599. // ErrMsg: res.ErrMsg,
  4600. // Status: 1,
  4601. // PatientId: id,
  4602. // RecordTime: recordDateTime,
  4603. // Stage: 6,
  4604. // }
  4605. // service.CreateErrMsgLog(errlog)
  4606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4607. // return
  4608. // } else {
  4609. // order_src.OrderStatus = 2
  4610. // order_src.PayWay = pay_way
  4611. // order_src.PayPrice = pay_price
  4612. // order_src.PayCardNo = pay_card_no
  4613. // order_src.DiscountPrice = discount_price
  4614. // order_src.PreferentialPrice = preferential_price
  4615. // order_src.RealityPrice = reality_price
  4616. // order_src.FoundPrice = found_price
  4617. // order_src.MedicalInsurancePrice = medical_insurance_price
  4618. // order_src.PrivatePrice = private_price
  4619. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  4620. // order_src.SetlId = res.Output.Setlinfo.SetlID
  4621. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  4622. // order_src.PsnName = res.Output.Setlinfo.PsnName
  4623. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  4624. // order_src.Certno = res.Output.Setlinfo.Certno
  4625. // order_src.Gend = res.Output.Setlinfo.Gend
  4626. // order_src.Naty = res.Output.Setlinfo.Naty
  4627. // order_src.Age = res.Output.Setlinfo.Age
  4628. // order_src.Insutype = res.Output.Setlinfo.Insutype
  4629. // order_src.PsnType = res.Output.Setlinfo.PsnType
  4630. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4631. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  4632. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4633. // order_src.MedType = res.Output.Setlinfo.MedType
  4634. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4635. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4636. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4637. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4638. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4639. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4640. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  4641. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  4642. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4643. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  4644. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  4645. // order_src.MafPay = res.Output.Setlinfo.MafPay
  4646. // order_src.OthPay = res.Output.Setlinfo.OthPay
  4647. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4648. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4649. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  4650. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4651. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4652. // order_src.Balc = res.Output.Setlinfo.Balc
  4653. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4654. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4655. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  4656. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  4657. // order_src.Creator = order_src.Creator
  4658. // order_src.Modify = roles.ID
  4659. // order_src.RequestLog = src_resquest
  4660. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4661. // detailStr := string(setlDetail)
  4662. // order_src.SetlDetail = detailStr
  4663. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4664. // err = service.UpDateOrder(order_src)
  4665. //
  4666. // if err == nil {
  4667. // c.ServeSuccessJSON(map[string]interface{}{
  4668. // "msg": "结算成功",
  4669. // })
  4670. // } else {
  4671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4672. // return
  4673. // }
  4674. // }
  4675. // }
  4676. //}
  4677. //退款
  4678. func (c *HisApiController) Refund() {
  4679. order_id, _ := c.GetInt64("order_id")
  4680. admin_user_id, _ := c.GetInt64("admin_user_id")
  4681. //record_time := c.GetString("record_time")
  4682. //patient_id, _ := c.GetInt64("patient_id")
  4683. //timeLayout := "2006-01-02"
  4684. //loc, _ := time.LoadLocation("Local")
  4685. adminUser := c.GetAdminUserInfo()
  4686. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4687. //if err != nil {
  4688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4689. // return
  4690. //}
  4691. //recordDateTime := theTime.Unix()
  4692. var order models.HisOrder
  4693. order, _ = service.GetHisOrderByID(order_id)
  4694. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4695. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4696. if order.ID == 0 {
  4697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4698. return
  4699. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  4700. }
  4701. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4702. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4703. if config.IsOpen == 1 { //对接了医保,走医保流程
  4704. var res ResultSixteen
  4705. var src_resquest string
  4706. var result string
  4707. if miConfig.MdtrtareaAdmvs == "421300" {
  4708. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  4709. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4711. resp3, requestErr3 := http.Get(api3)
  4712. if requestErr3 != nil {
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4717. if ioErr3 != nil {
  4718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4720. return
  4721. }
  4722. var respJSON3 map[string]interface{}
  4723. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4726. return
  4727. }
  4728. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4729. userJSONBytes3, _ := json.Marshal(respJSON3)
  4730. fmt.Println("log")
  4731. fmt.Println(string(userJSONBytes3))
  4732. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4733. utils.ErrorLog("解析失败:%v", err)
  4734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4735. return
  4736. }
  4737. } else {
  4738. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  4739. var dat map[string]interface{}
  4740. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4741. fmt.Println(dat)
  4742. } else {
  4743. fmt.Println(err)
  4744. }
  4745. saveLog(result, src_resquest, "2208", "退费")
  4746. userJSONBytes, _ := json.Marshal(dat)
  4747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4748. utils.ErrorLog("解析失败:%v", err)
  4749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4750. return
  4751. }
  4752. }
  4753. if res.Infcode == 0 {
  4754. var res2 ResultSix
  4755. if miConfig.MdtrtareaAdmvs == "421300" {
  4756. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  4757. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4758. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4759. resp3, requestErr3 := http.Get(api3)
  4760. if requestErr3 != nil {
  4761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. return
  4763. }
  4764. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4765. if ioErr3 != nil {
  4766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. var respJSON3 map[string]interface{}
  4771. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. return
  4775. }
  4776. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4777. userJSONBytes3, _ := json.Marshal(respJSON3)
  4778. fmt.Println("log")
  4779. fmt.Println(string(userJSONBytes3))
  4780. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. } else {
  4786. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  4787. var dat map[string]interface{}
  4788. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4789. fmt.Println(dat)
  4790. } else {
  4791. fmt.Println(err)
  4792. }
  4793. saveLog(result2, src_request, "2205", "撤销明细")
  4794. userJSONBytes, _ := json.Marshal(dat)
  4795. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4796. utils.ErrorLog("解析失败:%v", err)
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4798. return
  4799. }
  4800. }
  4801. if res2.Infcode == 0 {
  4802. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  4803. if err == nil {
  4804. c.ServeSuccessJSON(map[string]interface{}{
  4805. "msg": "退费成功",
  4806. })
  4807. } else {
  4808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4809. return
  4810. }
  4811. } else {
  4812. c.ServeSuccessJSON(map[string]interface{}{
  4813. "code": -10,
  4814. "msg": res2.ErrMsg,
  4815. })
  4816. }
  4817. } else {
  4818. c.ServeSuccessJSON(map[string]interface{}{
  4819. "code": -10,
  4820. "msg": res.ErrMsg,
  4821. })
  4822. }
  4823. }
  4824. }
  4825. func (c *HisApiController) RefundNumber() {
  4826. record_time := c.GetString("record_time")
  4827. //patient_id, _ := c.GetInt64("patient_id")
  4828. admin_user_id, _ := c.GetInt64("admin_user_id")
  4829. his_patient_id, _ := c.GetInt64("id")
  4830. timeLayout := "2006-01-02"
  4831. loc, _ := time.LoadLocation("Local")
  4832. adminUser := c.GetAdminUserInfo()
  4833. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4834. fmt.Println(err)
  4835. if err != nil {
  4836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4837. return
  4838. }
  4839. recordDateTime := theTime.Unix()
  4840. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4841. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  4842. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4843. //order, _ := service.GetHisOrderByID(order_id)
  4844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4845. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4846. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4847. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  4848. if count > 0 {
  4849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  4850. return
  4851. }
  4852. if config.IsOpen == 1 { //对接了医保,走医保流程
  4853. var res2 ResultSix
  4854. if miConfig.MdtrtareaAdmvs == "421300" {
  4855. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  4856. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4858. resp3, requestErr3 := http.Get(api3)
  4859. if requestErr3 != nil {
  4860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4861. return
  4862. }
  4863. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4864. if ioErr3 != nil {
  4865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. var respJSON3 map[string]interface{}
  4870. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4873. return
  4874. }
  4875. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4876. userJSONBytes3, _ := json.Marshal(respJSON3)
  4877. fmt.Println("log")
  4878. fmt.Println(string(userJSONBytes3))
  4879. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4880. utils.ErrorLog("解析失败:%v", err)
  4881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4882. return
  4883. }
  4884. } else {
  4885. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  4886. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4887. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4888. resp3, requestErr3 := http.Get(api3)
  4889. if requestErr3 != nil {
  4890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. return
  4892. }
  4893. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4894. if ioErr3 != nil {
  4895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. return
  4898. }
  4899. var respJSON3 map[string]interface{}
  4900. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. return
  4904. }
  4905. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4906. userJSONBytes3, _ := json.Marshal(respJSON3)
  4907. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4908. utils.ErrorLog("解析失败:%v", err)
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. return
  4911. }
  4912. }
  4913. if res2.Infcode == 0 {
  4914. if err == nil {
  4915. c.ServeSuccessJSON(map[string]interface{}{
  4916. "msg": "退号成功",
  4917. })
  4918. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  4919. } else {
  4920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4921. return
  4922. }
  4923. } else {
  4924. c.ServeSuccessJSON(map[string]interface{}{
  4925. "code": -10,
  4926. "msg": res2.ErrMsg,
  4927. })
  4928. }
  4929. } else {
  4930. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  4931. //if err == nil {
  4932. // c.ServeSuccessJSON(map[string]interface{}{
  4933. // "msg": "退费成功",
  4934. // })
  4935. //} else {
  4936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. // return
  4938. //}
  4939. }
  4940. }
  4941. func (c *HisApiController) RefundDetail() {
  4942. order_id, _ := c.GetInt64("order_id")
  4943. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4944. number := c.GetString("number")
  4945. record_time := c.GetString("record_time")
  4946. patient_id, _ := c.GetInt64("patient_id")
  4947. timeLayout := "2006-01-02"
  4948. loc, _ := time.LoadLocation("Local")
  4949. adminUser := c.GetAdminUserInfo()
  4950. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4951. fmt.Println(err)
  4952. if err != nil {
  4953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4954. return
  4955. }
  4956. recordDateTime := theTime.Unix()
  4957. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4958. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4960. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4961. var order models.HisOrder
  4962. order, _ = service.GetHisOrderByID(order_id)
  4963. if order.ID == 0 {
  4964. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  4965. }
  4966. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4967. if config.IsOpen == 1 { //对接了医保,走医保流程
  4968. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  4969. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4970. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4971. resp2, requestErr2 := http.Get(api2)
  4972. if requestErr2 != nil {
  4973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4974. return
  4975. }
  4976. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4977. if ioErr2 != nil {
  4978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4980. return
  4981. }
  4982. var respJSON2 map[string]interface{}
  4983. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4986. return
  4987. }
  4988. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  4989. if err == nil {
  4990. c.ServeSuccessJSON(map[string]interface{}{
  4991. "msg": "退费成功",
  4992. })
  4993. } else {
  4994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4995. return
  4996. }
  4997. } else {
  4998. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  4999. if err == nil {
  5000. c.ServeSuccessJSON(map[string]interface{}{
  5001. "msg": "退费成功",
  5002. })
  5003. } else {
  5004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5005. return
  5006. }
  5007. }
  5008. }
  5009. //对账
  5010. func (c *HisApiController) GetCheckAccount() {
  5011. start_time := c.GetString("start_time")
  5012. end_time := c.GetString("end_time")
  5013. insutype := c.GetString("insutype")
  5014. clr_type := c.GetString("clr_type")
  5015. admin_user_id, _ := c.GetInt64("admin_user_id")
  5016. adminUser := c.GetAdminUserInfo()
  5017. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5018. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5019. timeLayout := "2006-01-02"
  5020. loc, _ := time.LoadLocation("Local")
  5021. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5022. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5023. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5024. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5025. fixmedins_setl_cnt := int64(len(orders))
  5026. //
  5027. ////撤销的算2条数据为一笔
  5028. //for _, item := range orders_two {
  5029. // if item.OrderStatus == 3 {
  5030. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  5031. // }
  5032. //}
  5033. var medfee_sumamt float64
  5034. var acct_pay float64
  5035. var fund_pay_sumamt float64
  5036. for _, item := range orders {
  5037. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5038. acct_pay = acct_pay + item.AcctPay
  5039. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5040. }
  5041. var user_name string
  5042. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5043. if role.ID == 0 {
  5044. user_name = "xxx"
  5045. } else {
  5046. user_name = role.UserName
  5047. }
  5048. if config.IsOpen == 1 {
  5049. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5050. "insutype=" + insutype +
  5051. "&clr_type=" + clr_type +
  5052. "&setl_optins=" + "定点医保中心" +
  5053. "&stmt_begndate=" + start_time +
  5054. "&stm_enddate=" + end_time +
  5055. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5056. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5057. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5058. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5059. "&fixmedins_code=" + miConfig.Code +
  5060. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5061. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5062. "&secret_key=" + miConfig.SecretKey +
  5063. "&org_name=" + miConfig.OrgName +
  5064. "&doctor=" + user_name
  5065. fmt.Println(api)
  5066. resp, requestErr := http.Get(api)
  5067. if requestErr != nil {
  5068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5069. return
  5070. }
  5071. body, ioErr := ioutil.ReadAll(resp.Body)
  5072. fmt.Println(body)
  5073. if ioErr != nil {
  5074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5076. return
  5077. }
  5078. var respJSON map[string]interface{}
  5079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5082. return
  5083. }
  5084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5085. userJSONBytes, _ := json.Marshal(respJSON)
  5086. var res ResultEight
  5087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5088. utils.ErrorLog("解析失败:%v", err)
  5089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5090. return
  5091. }
  5092. if res.Infcode == 0 {
  5093. if res.Output.Stmtinfo.StmtRslt == "0" {
  5094. micc := &models.MedicalInsuranceCostCompare{
  5095. StartTime: startime.Unix(),
  5096. EndTime: endtime.Unix(),
  5097. Insutype: insutype,
  5098. CheckType: 1,
  5099. Num: fixmedins_setl_cnt,
  5100. Mtime: time.Now().Unix(),
  5101. Status: 1,
  5102. UserOrgId: adminUser.CurrentOrgId,
  5103. CostTotal: medfee_sumamt,
  5104. FuncTotal: fund_pay_sumamt,
  5105. PsnPay: acct_pay,
  5106. Creator: admin_user_id,
  5107. Ctime: time.Now().Unix(),
  5108. }
  5109. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5110. if err == nil {
  5111. c.ServeSuccessJSON(map[string]interface{}{
  5112. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5113. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5114. })
  5115. } else {
  5116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5117. }
  5118. } else {
  5119. c.ServeSuccessJSON(map[string]interface{}{
  5120. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5121. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5122. })
  5123. }
  5124. } else {
  5125. c.ServeSuccessJSON(map[string]interface{}{
  5126. "code": -10,
  5127. "msg": res.ErrMsg,
  5128. })
  5129. }
  5130. }
  5131. }
  5132. func (c *HisApiController) Check310() {
  5133. adminUser := c.GetAdminUserInfo()
  5134. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5135. var user_name string
  5136. user_name = "xxx"
  5137. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5138. "insutype=" + "310" +
  5139. "&clr_type=" + "11" +
  5140. "&setl_optins=" + "定点医保中心" +
  5141. "&stmt_begndate=" + "2021-03-01" +
  5142. "&stm_enddate=" + "2021-03-31" +
  5143. "&medfee_sumamt=" + "11521" +
  5144. "&fund_pay_sumamt=" + "10166.66" +
  5145. "&acct_pay=" + "0" +
  5146. "&fixmedins_setl_cnt=" + "7" +
  5147. "&fixmedins_code=" + miConfig.Code +
  5148. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5149. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5150. "&secret_key=" + miConfig.SecretKey +
  5151. "&org_name=" + miConfig.OrgName +
  5152. "&doctor=" + user_name
  5153. fmt.Println(api)
  5154. resp, requestErr := http.Get(api)
  5155. if requestErr != nil {
  5156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5157. return
  5158. }
  5159. body, ioErr := ioutil.ReadAll(resp.Body)
  5160. fmt.Println(body)
  5161. if ioErr != nil {
  5162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5164. return
  5165. }
  5166. var respJSON map[string]interface{}
  5167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5173. userJSONBytes, _ := json.Marshal(respJSON)
  5174. var res ResultEight
  5175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5176. utils.ErrorLog("解析失败:%v", err)
  5177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. }
  5181. func (c *HisApiController) Check390() {
  5182. adminUser := c.GetAdminUserInfo()
  5183. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5184. var user_name string
  5185. user_name = "张俊杰"
  5186. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5187. "insutype=" + "390" +
  5188. "&clr_type=" + "11" +
  5189. "&setl_optins=" + "定点医保中心" +
  5190. "&stmt_begndate=" + "2021-03-01" +
  5191. "&stm_enddate=" + "2021-03-31" +
  5192. "&medfee_sumamt=" + "209318.43" +
  5193. "&fund_pay_sumamt=" + "188029.12" +
  5194. "&acct_pay=" + "0" +
  5195. "&fixmedins_setl_cnt=" + "48" +
  5196. "&fixmedins_code=" + miConfig.Code +
  5197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5198. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5199. "&secret_key=" + miConfig.SecretKey +
  5200. "&org_name=" + miConfig.OrgName +
  5201. "&doctor=" + user_name
  5202. fmt.Println(api)
  5203. resp, requestErr := http.Get(api)
  5204. if requestErr != nil {
  5205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5206. return
  5207. }
  5208. body, ioErr := ioutil.ReadAll(resp.Body)
  5209. fmt.Println(body)
  5210. if ioErr != nil {
  5211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. return
  5214. }
  5215. var respJSON map[string]interface{}
  5216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5219. return
  5220. }
  5221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5222. userJSONBytes, _ := json.Marshal(respJSON)
  5223. var res ResultEight
  5224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5225. utils.ErrorLog("解析失败:%v", err)
  5226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5227. return
  5228. }
  5229. }
  5230. //对账明细
  5231. func (c *HisApiController) GetCheckDetailAccount() {
  5232. start_time := c.GetString("start_time")
  5233. end_time := c.GetString("end_time")
  5234. admin_user_id, _ := c.GetInt64("admin_user_id")
  5235. adminUser := c.GetAdminUserInfo()
  5236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5237. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5238. timeLayout := "2006-01-02"
  5239. loc, _ := time.LoadLocation("Local")
  5240. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5241. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5242. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5243. Mkdir(miConfig.OrgName)
  5244. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5245. file_name := file + ".txt"
  5246. zip_name := file + ".zip"
  5247. zip_path := miConfig.OrgName + "/" + zip_name
  5248. file_path := miConfig.OrgName + "/" + file_name
  5249. decimal.DivisionPrecision = 2
  5250. var medfee_sumamt float64
  5251. var psn_cash_pay float64
  5252. var fund_pay_sumamt float64
  5253. fixmedins_setl_cnt := int64(len(orders))
  5254. for _, item := range orders {
  5255. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5256. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5257. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5258. }
  5259. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5260. defer f.Close()
  5261. if err != nil {
  5262. fmt.Println(err.Error())
  5263. } else {
  5264. for _, item := range orders {
  5265. var refd_setl_flag string
  5266. if item.OrderStatus == 2 {
  5267. refd_setl_flag = "0"
  5268. var str string
  5269. str = item.SetlId + " " +
  5270. item.MdtrtId + " " +
  5271. item.PsnNo + " " +
  5272. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5273. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5274. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5275. _, err = f.Write([]byte(str))
  5276. }
  5277. if item.OrderStatus == 3 {
  5278. var str string
  5279. str = item.SetlId + " " +
  5280. item.MdtrtId + " " +
  5281. item.PsnNo + " " +
  5282. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5283. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5284. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5285. _, err = f.Write([]byte(str))
  5286. var str2 string
  5287. str2 = item.SetlId + " " +
  5288. item.MdtrtId + " " +
  5289. item.PsnNo + " " +
  5290. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5291. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5292. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5293. _, err = f.Write([]byte(str2))
  5294. }
  5295. }
  5296. }
  5297. Zip(file_path, zip_path)
  5298. fmt.Println(ReadFile(zip_path))
  5299. fmt.Println(string(ReadFile(zip_path)))
  5300. if config.IsOpen == 1 {
  5301. var user_name string
  5302. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5303. if role.ID == 0 {
  5304. user_name = "管理员"
  5305. } else {
  5306. user_name = role.UserName
  5307. }
  5308. baseParams := models.BaseParams{
  5309. SecretKey: miConfig.SecretKey,
  5310. FixmedinsCode: miConfig.Code,
  5311. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5312. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5313. OrgName: miConfig.OrgName,
  5314. Doctor: user_name,
  5315. }
  5316. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5317. var dat map[string]interface{}
  5318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5319. fmt.Println(dat)
  5320. } else {
  5321. fmt.Println(err)
  5322. }
  5323. userJSONBytes, _ := json.Marshal(dat)
  5324. var res ResultNine
  5325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5326. utils.ErrorLog("解析失败:%v", err)
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. return
  5329. }
  5330. if res.Infcode == 0 {
  5331. fileNo := res.Output.FileQuryNo
  5332. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5333. "file_qury_no=" + fileNo +
  5334. "&setl_optins=" + "定点医保中心" +
  5335. "&stmt_begndate=" + start_time +
  5336. "&stm_enddate=" + end_time +
  5337. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5338. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5339. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5340. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5341. "&fixmedins_code=" + miConfig.Code +
  5342. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5343. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5344. "&secret_key=" + miConfig.SecretKey +
  5345. "&org_name=" + miConfig.OrgName +
  5346. "&doctor=" + user_name
  5347. resp, requestErr := http.Get(api)
  5348. if requestErr != nil {
  5349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5350. return
  5351. }
  5352. body, ioErr := ioutil.ReadAll(resp.Body)
  5353. if ioErr != nil {
  5354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5356. return
  5357. }
  5358. var respJSON map[string]interface{}
  5359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5362. return
  5363. }
  5364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5365. userJSONBytes, _ := json.Marshal(respJSON)
  5366. var res ResultTen
  5367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5368. utils.ErrorLog("解析失败:%v", err)
  5369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5370. return
  5371. }
  5372. if res.Infcode == 0 {
  5373. service.Gdyb9102(baseParams, zip_name, fileNo)
  5374. micc := &models.MedicalInsuranceCostCompare{
  5375. StartTime: startime.Unix(),
  5376. EndTime: endtime.Unix(),
  5377. Insutype: "0",
  5378. CheckType: 2,
  5379. Num: fixmedins_setl_cnt,
  5380. Mtime: time.Now().Unix(),
  5381. Status: 1,
  5382. UserOrgId: adminUser.CurrentOrgId,
  5383. CostTotal: medfee_sumamt,
  5384. FuncTotal: fund_pay_sumamt,
  5385. PsnPay: psn_cash_pay,
  5386. Creator: admin_user_id,
  5387. Ctime: time.Now().Unix(),
  5388. }
  5389. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5390. c.ServeSuccessJSON(map[string]interface{}{
  5391. "msg": "明细对账成功",
  5392. })
  5393. }
  5394. } else {
  5395. }
  5396. }
  5397. }
  5398. type CustomOrderInfo struct {
  5399. Name string
  5400. Spec string
  5401. Unit string
  5402. Count float64
  5403. Price float64
  5404. Total float64
  5405. }
  5406. func (c *HisApiController) GetSettleAccounts() {
  5407. //id, _ := c.GetInt64("id")
  5408. //record_time := c.GetString("record_time")
  5409. order_id, _ := c.GetInt64("order_id")
  5410. admin_user_id, _ := c.GetInt64("admin_user_id")
  5411. //timeLayout := "2006-01-02"
  5412. //loc, _ := time.LoadLocation("Local")
  5413. //
  5414. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5415. //if err != nil {
  5416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5417. // return
  5418. //}
  5419. //recordDateTime := theTime.Unix()
  5420. adminUser := c.GetAdminUserInfo()
  5421. order, _ := service.GetHisOrderByID(order_id)
  5422. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5423. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  5424. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  5425. orderInfos = append(orderInfos, orderInfos_two...)
  5426. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  5427. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5428. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  5429. //var config []*models.HisXtDiagnoseConfig
  5430. var name string
  5431. for _, item := range diagnosis_ids {
  5432. id, _ := strconv.ParseInt(item, 10, 64)
  5433. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5434. if len(name) == 0 {
  5435. name = diagnosisConfig.ClassName
  5436. } else {
  5437. name = name + "," + diagnosisConfig.ClassName
  5438. }
  5439. }
  5440. var bedCostTotal float64 = 0 //床位总费
  5441. var bedCostSelfTotal float64 = 0 //床位自费
  5442. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5443. var operationCostTotal float64 = 0 //手术费
  5444. var operationCostSelfTotal float64 = 0 //手术费
  5445. var operationCostPartSelfTotal float64 = 0 //手术费
  5446. var otherCostTotal float64 = 0 //其他费用
  5447. var otherCostSelfTotal float64 = 0 //其他费用
  5448. var otherCostPartSelfTotal float64 = 0 //其他费用
  5449. var materialCostTotal float64 = 0 //材料费
  5450. var materialCostSelfTotal float64 = 0 //材料费
  5451. var materialCostPartSelfTotal float64 = 0 //材料费
  5452. var westernMedicineCostTotal float64 = 0 //西药费
  5453. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5454. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5455. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5456. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5457. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5458. var checkCostTotal float64 = 0 //检查费
  5459. var checkCostSelfTotal float64 = 0 //检查费
  5460. var checkCostPartSelfTotal float64 = 0 //检查费
  5461. var laboratoryCostTotal float64 = 0 //化验费
  5462. var laboratoryCostSelfTotal float64 = 0 //化验费
  5463. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5464. var treatCostTotal float64 = 0 //治疗费用
  5465. var treatCostSelfTotal float64 = 0 //治疗费用
  5466. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5467. decimal.DivisionPrecision = 2
  5468. for _, item := range orderInfos {
  5469. if item.MedChrgitmType == "01" { //床位费
  5470. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5471. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5472. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5473. }
  5474. if item.MedChrgitmType == "03" { //检查费
  5475. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5476. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5477. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5478. }
  5479. if item.MedChrgitmType == "04" { //化验费
  5480. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5481. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5482. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5483. }
  5484. if item.MedChrgitmType == "05" { //治疗费
  5485. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5486. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5487. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5488. }
  5489. if item.MedChrgitmType == "06" { //手术费
  5490. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5491. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5492. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5493. }
  5494. if item.MedChrgitmType == "08" { //材料费
  5495. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5496. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5497. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5498. }
  5499. if item.MedChrgitmType == "09" { //西药费
  5500. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5501. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5502. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5503. }
  5504. if item.MedChrgitmType == "11" { //中成费
  5505. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5506. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5507. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5508. }
  5509. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  5510. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5511. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5512. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5513. }
  5514. }
  5515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5516. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5517. var user_name string
  5518. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5519. if role.ID == 0 {
  5520. user_name = "管理员"
  5521. } else {
  5522. user_name = role.UserName
  5523. }
  5524. baseParams := models.BaseParams{
  5525. SecretKey: miConfig.SecretKey,
  5526. FixmedinsCode: miConfig.Code,
  5527. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5528. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5529. OrgName: miConfig.OrgName,
  5530. Doctor: user_name,
  5531. }
  5532. businessParams := models.BusinessParams{
  5533. PsnNo: order.PsnNo,
  5534. MdtrtId: order.MdtrtId,
  5535. SetlId: order.SetlId,
  5536. }
  5537. var res ResultEleven
  5538. if config.IsOpen == 1 {
  5539. if miConfig.MdtrtareaAdmvs == "421300" {
  5540. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  5541. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  5542. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5543. resp, requestErr := http.Get(api)
  5544. if requestErr != nil {
  5545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5546. return
  5547. }
  5548. body, ioErr := ioutil.ReadAll(resp.Body)
  5549. if ioErr != nil {
  5550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5552. return
  5553. }
  5554. var respJSON map[string]interface{}
  5555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5558. return
  5559. }
  5560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5561. result, _ := json.Marshal(respJSON)
  5562. fmt.Println("log")
  5563. fmt.Println(string(result))
  5564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5565. utils.ErrorLog("解析失败:%v", err)
  5566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5567. return
  5568. }
  5569. } else {
  5570. result := service.Gdyb5203(baseParams, businessParams)
  5571. var dat map[string]interface{}
  5572. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5573. fmt.Println(dat)
  5574. } else {
  5575. fmt.Println(err)
  5576. }
  5577. userJSONBytes, _ := json.Marshal(dat)
  5578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5579. utils.ErrorLog("解析失败:%v", err)
  5580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5581. return
  5582. }
  5583. }
  5584. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5585. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  5586. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  5587. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5588. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5589. var doctor_name string
  5590. if roles.ID == 0 {
  5591. doctor_name = "管理员"
  5592. } else {
  5593. doctor_name = roles.UserName
  5594. }
  5595. yiliao_leibie := ""
  5596. switch order.MedType {
  5597. case "11":
  5598. yiliao_leibie = "普通门诊"
  5599. break
  5600. case "12":
  5601. yiliao_leibie = "门诊挂号"
  5602. break
  5603. case "13":
  5604. yiliao_leibie = "急诊"
  5605. break
  5606. case "14":
  5607. yiliao_leibie = "门诊特殊病"
  5608. break
  5609. case "15":
  5610. yiliao_leibie = "门诊统筹"
  5611. break
  5612. case "16":
  5613. yiliao_leibie = "门诊慢性病"
  5614. break
  5615. case "21":
  5616. yiliao_leibie = "普通住院"
  5617. break
  5618. }
  5619. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5620. if res.Infcode == 0 {
  5621. c.ServeSuccessJSON(map[string]interface{}{
  5622. "diagnosis": name,
  5623. "order_infos": orderInfos,
  5624. "number": order.MdtrtId,
  5625. "date": order.SettleAccountsDate,
  5626. "charge_admin": charge_admin,
  5627. "printor_admin": printor_admin,
  5628. "info": res.Output.Setlinfo,
  5629. "bedCostTotal": bedCostTotal,
  5630. "bedCostSelfTotal": bedCostSelfTotal,
  5631. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  5632. "operationCostTotal": operationCostTotal,
  5633. "operationCostSelfTotal": operationCostSelfTotal,
  5634. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  5635. "otherCostTotal": otherCostTotal,
  5636. "otherCostSelfTotal": otherCostSelfTotal,
  5637. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  5638. "materialCostTotal": materialCostTotal,
  5639. "materialCostSelfTotal": materialCostSelfTotal,
  5640. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  5641. "westernMedicineCostTotal": westernMedicineCostTotal,
  5642. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  5643. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  5644. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  5645. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  5646. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  5647. "checkCostTotal": checkCostTotal,
  5648. "checkCostSelfTotal": checkCostSelfTotal,
  5649. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  5650. "laboratoryCostTotal": laboratoryCostTotal,
  5651. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  5652. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  5653. "treatCostTotal": treatCostTotal,
  5654. "treatCostSelfTotal": treatCostSelfTotal,
  5655. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  5656. "doctor_code": adminRole_two.DoctorCode,
  5657. "doctor_name": doctor_name,
  5658. "health_card_no": order.PsnNo,
  5659. "department": departments.Name,
  5660. "yiliao_leibie": yiliao_leibie,
  5661. "after_money": order.AccountPrice,
  5662. "patient": patient,
  5663. "org_name": miConfig.OrgName,
  5664. "org_code": miConfig.Code,
  5665. "order_number": order.Number,
  5666. //"check_order_info": cus_slice,
  5667. })
  5668. }
  5669. }
  5670. }
  5671. func (c *HisApiController) CheckTreatment() {
  5672. patient_id, _ := c.GetInt64("patient_id", 0)
  5673. record_time := c.GetString("record_time")
  5674. insutype := c.GetString("insutype")
  5675. timeLayout := "2006-01-02"
  5676. loc, _ := time.LoadLocation("Local")
  5677. adminUser := c.GetAdminUserInfo()
  5678. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5679. fmt.Println(err)
  5680. if err != nil {
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5682. return
  5683. }
  5684. recordDateTime := theTime.Unix()
  5685. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5686. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5687. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5688. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5689. var user_name string
  5690. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  5691. if role.ID == 0 {
  5692. user_name = "xxx"
  5693. } else {
  5694. user_name = role.UserName
  5695. }
  5696. baseParams := models.BaseParams{
  5697. SecretKey: miConfig.SecretKey,
  5698. FixmedinsCode: miConfig.Code,
  5699. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5700. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5701. OrgName: miConfig.OrgName,
  5702. Doctor: user_name,
  5703. }
  5704. if config.IsOpen == 1 {
  5705. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  5706. var dat map[string]interface{}
  5707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5708. fmt.Println(dat)
  5709. } else {
  5710. fmt.Println(err)
  5711. }
  5712. }
  5713. }
  5714. func (c *HisApiController) PutRecord() {
  5715. id, _ := c.GetInt64("id")
  5716. record_time := c.GetString("record_time")
  5717. timeLayout := "2006-01-02"
  5718. loc, _ := time.LoadLocation("Local")
  5719. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5720. if err != nil {
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5722. return
  5723. }
  5724. recordDateTime := theTime.Unix()
  5725. adminInfo := c.GetAdminUserInfo()
  5726. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  5727. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5728. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5729. fmt.Println(miConfig.SecretKey)
  5730. if patient == nil {
  5731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  5732. return
  5733. }
  5734. if len(patient.IdCardNo) == 0 {
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  5736. return
  5737. }
  5738. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5739. if config.IsOpen == 1 {
  5740. 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
  5741. resp, requestErr := http.Get(api)
  5742. if requestErr != nil {
  5743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5744. return
  5745. }
  5746. defer resp.Body.Close()
  5747. body, ioErr := ioutil.ReadAll(resp.Body)
  5748. if ioErr != nil {
  5749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5751. return
  5752. }
  5753. var respJSON map[string]interface{}
  5754. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5757. return
  5758. }
  5759. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5760. userJSONBytes, _ := json.Marshal(userJSON)
  5761. var res ResultTwo
  5762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5763. utils.ErrorLog("解析失败:%v", err)
  5764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5765. return
  5766. }
  5767. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5768. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5769. infoStr := string(Iinfos)
  5770. idetinfoStr := string(Idetinfos)
  5771. if res.Infcode == 0 {
  5772. his := models.VMHisPatient{
  5773. Status: 1,
  5774. Ctime: time.Now().Unix(),
  5775. Mtime: time.Now().Unix(),
  5776. PsnNo: res.Output.Baseinfo.PsnNo,
  5777. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5778. Certno: res.Output.Baseinfo.Certno,
  5779. PsnName: res.Output.Baseinfo.PsnName,
  5780. Gend: res.Output.Baseinfo.Gend,
  5781. Naty: res.Output.Baseinfo.Naty,
  5782. Brdy: res.Output.Baseinfo.Brdy,
  5783. Age: res.Output.Baseinfo.Age,
  5784. Iinfo: infoStr,
  5785. Idetinfo: idetinfoStr,
  5786. PatientId: patient.ID,
  5787. RecordDate: theTime.Unix(),
  5788. UserOrgId: adminInfo.CurrentOrgId,
  5789. AdminUserId: adminInfo.AdminUser.Id,
  5790. IsReturn: 1,
  5791. }
  5792. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  5793. 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")
  5794. 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")
  5795. var dat map[string]interface{}
  5796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5797. fmt.Println(dat)
  5798. } else {
  5799. fmt.Println(err)
  5800. }
  5801. var dat2 map[string]interface{}
  5802. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  5803. fmt.Println(dat2)
  5804. } else {
  5805. fmt.Println(err)
  5806. }
  5807. } else {
  5808. adminUser := c.GetAdminUserInfo()
  5809. errlog := &models.HisOrderError{
  5810. UserOrgId: adminUser.CurrentOrgId,
  5811. Ctime: time.Now().Unix(),
  5812. Mtime: time.Now().Unix(),
  5813. ErrMsg: res.ErrMsg,
  5814. Status: 1,
  5815. PatientId: id,
  5816. RecordTime: recordDateTime,
  5817. Stage: 1,
  5818. }
  5819. service.CreateErrMsgLog(errlog)
  5820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5821. return
  5822. }
  5823. }
  5824. }
  5825. func (c *HisApiController) GetUploadDiag() {
  5826. id, _ := c.GetInt64("id")
  5827. record_time := c.GetString("record_time")
  5828. diagnosis_id, _ := c.GetInt64("diagnosis")
  5829. sick_type, _ := c.GetInt64("sick_type")
  5830. reg_type, _ := c.GetInt64("reg_type")
  5831. timeLayout := "2006-01-02"
  5832. loc, _ := time.LoadLocation("Local")
  5833. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5834. if err != nil {
  5835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5836. return
  5837. }
  5838. var patientPrescription models.HisPrescriptionInfo
  5839. recordDateTime := theTime.Unix()
  5840. adminInfo := c.GetAdminUserInfo()
  5841. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5842. if patientPrescription.ID == 0 {
  5843. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5844. }
  5845. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5846. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5847. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5848. sickConfig, _ := service.FindSickById(sick_type)
  5849. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5850. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  5851. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  5852. "&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 +
  5853. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  5854. resp2, requestErr2 := http.Get(api2)
  5855. if requestErr2 != nil {
  5856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5857. return
  5858. }
  5859. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5860. if ioErr2 != nil {
  5861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5863. return
  5864. }
  5865. var respJSON2 map[string]interface{}
  5866. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5869. return
  5870. }
  5871. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5872. userJSONBytes2, _ := json.Marshal(respJSON2)
  5873. var res2 ResultSix
  5874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5875. utils.ErrorLog("解析失败:%v", err)
  5876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5877. return
  5878. }
  5879. if res2.Infcode != 0 {
  5880. adminUser := c.GetAdminUserInfo()
  5881. errlog := &models.HisOrderError{
  5882. UserOrgId: adminUser.CurrentOrgId,
  5883. Ctime: time.Now().Unix(),
  5884. Mtime: time.Now().Unix(),
  5885. ErrMsg: res2.ErrMsg,
  5886. Status: 1,
  5887. PatientId: id,
  5888. RecordTime: recordDateTime,
  5889. Stage: 3,
  5890. }
  5891. service.CreateErrMsgLog(errlog)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  5893. return
  5894. }
  5895. c.ServeSuccessJSON(map[string]interface{}{
  5896. "msg": "上传成功",
  5897. })
  5898. }
  5899. type QueryResult struct {
  5900. ID int64
  5901. Name string
  5902. Code string
  5903. List_type_code string
  5904. }
  5905. func (c *HisApiController) GetCheckCode() {
  5906. ids_str := c.GetString("ids")
  5907. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  5908. ids_arr := strings.Split(ids_str, ",")
  5909. var queryResult []QueryResult
  5910. ids := make([]int64, 0)
  5911. for _, item := range ids_arr {
  5912. id, _ := strconv.ParseInt(item, 10, 64)
  5913. ids = append(ids, id)
  5914. }
  5915. if record_type == 1 {
  5916. drugs, _ := service.GetBatchDrugList(ids)
  5917. for _, item := range drugs {
  5918. result := QueryResult{
  5919. ID: item.ID,
  5920. Name: item.DrugName,
  5921. Code: item.MedicalInsuranceNumber,
  5922. List_type_code: "101",
  5923. }
  5924. queryResult = append(queryResult, result)
  5925. }
  5926. } else if record_type == 2 {
  5927. goods, _ := service.GetBatchGoodInformationList(ids)
  5928. for _, item := range goods {
  5929. result := QueryResult{
  5930. ID: item.ID,
  5931. Name: item.GoodName,
  5932. Code: item.MedicalInsuranceNumber,
  5933. List_type_code: "301",
  5934. }
  5935. queryResult = append(queryResult, result)
  5936. }
  5937. } else if record_type == 3 {
  5938. projects, _ := service.GetBathchMyPorjecgList(ids)
  5939. for _, item := range projects {
  5940. result := QueryResult{
  5941. ID: item.ID,
  5942. Name: item.ProjectName,
  5943. Code: item.MedicalCode,
  5944. List_type_code: "201",
  5945. }
  5946. queryResult = append(queryResult, result)
  5947. }
  5948. }
  5949. admin_user_id, _ := c.GetInt64("admin_user_id")
  5950. adminUser := c.GetAdminUserInfo()
  5951. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5952. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5953. var user_name string
  5954. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5955. if role.ID == 0 {
  5956. user_name = "xxx"
  5957. } else {
  5958. user_name = role.UserName
  5959. }
  5960. baseParams := &models.BaseParams{
  5961. SecretKey: miConfig.SecretKey,
  5962. FixmedinsCode: miConfig.Code,
  5963. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5964. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5965. OrgName: miConfig.OrgName,
  5966. Doctor: user_name,
  5967. }
  5968. if config.IsOpen == 1 {
  5969. for _, item := range queryResult {
  5970. var result string
  5971. if record_type == 1 {
  5972. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5973. } else if record_type == 2 {
  5974. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5975. } else if record_type == 3 {
  5976. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5977. }
  5978. var dat map[string]interface{}
  5979. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5980. fmt.Println(dat)
  5981. } else {
  5982. fmt.Println(err)
  5983. }
  5984. userJSONBytes, _ := json.Marshal(dat)
  5985. var res ResultSix
  5986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5987. utils.ErrorLog("解析失败:%v", err)
  5988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5989. return
  5990. }
  5991. if res.Infcode == 0 {
  5992. if record_type == 1 {
  5993. service.UpdateBaseDrugById(item.ID)
  5994. } else if record_type == 2 {
  5995. service.UpdateGoodInformaitonByDetail(item.ID)
  5996. } else if record_type == 3 {
  5997. service.UpdateProjectById(item.ID)
  5998. }
  5999. c.ServeSuccessJSON(map[string]interface{}{
  6000. "failed_code": 0,
  6001. "msg": "目录对照成功",
  6002. })
  6003. } else {
  6004. c.ServeSuccessJSON(map[string]interface{}{
  6005. "failed_code": -10,
  6006. "msg": res.ErrMsg,
  6007. })
  6008. }
  6009. }
  6010. }
  6011. }
  6012. func (c *HisApiController) UnCheckCode() {
  6013. ids_str := c.GetString("ids")
  6014. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6015. admin_user_id, _ := c.GetInt64("admin_user_id")
  6016. ids_arr := strings.Split(ids_str, ",")
  6017. var queryResult []QueryResult
  6018. ids := make([]int64, 0)
  6019. for _, item := range ids_arr {
  6020. id, _ := strconv.ParseInt(item, 10, 64)
  6021. ids = append(ids, id)
  6022. }
  6023. if record_type == 1 {
  6024. drugs, _ := service.GetBatchDrugList(ids)
  6025. for _, item := range drugs {
  6026. result := QueryResult{
  6027. ID: item.ID,
  6028. Name: item.DrugName,
  6029. Code: item.MedicalInsuranceNumber,
  6030. List_type_code: "101",
  6031. }
  6032. queryResult = append(queryResult, result)
  6033. }
  6034. } else if record_type == 2 {
  6035. goods, _ := service.GetBatchGoodInformationList(ids)
  6036. for _, item := range goods {
  6037. result := QueryResult{
  6038. ID: item.ID,
  6039. Name: item.GoodName,
  6040. Code: item.MedicalInsuranceNumber,
  6041. List_type_code: "301",
  6042. }
  6043. queryResult = append(queryResult, result)
  6044. }
  6045. } else if record_type == 3 {
  6046. projects, _ := service.GetBathchMyPorjecgList(ids)
  6047. for _, item := range projects {
  6048. result := QueryResult{
  6049. ID: item.ID,
  6050. Name: item.ProjectName,
  6051. Code: item.MedicalCode,
  6052. List_type_code: "201",
  6053. }
  6054. queryResult = append(queryResult, result)
  6055. }
  6056. }
  6057. adminUser := c.GetAdminUserInfo()
  6058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6059. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6060. var user_name string
  6061. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6062. if role.ID == 0 {
  6063. user_name = "xxx"
  6064. } else {
  6065. user_name = role.UserName
  6066. }
  6067. baseParams := &models.BaseParams{
  6068. SecretKey: miConfig.SecretKey,
  6069. FixmedinsCode: miConfig.Code,
  6070. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6071. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6072. OrgName: miConfig.OrgName,
  6073. Doctor: user_name,
  6074. }
  6075. if config.IsOpen == 1 {
  6076. for _, item := range queryResult {
  6077. var result string
  6078. if record_type == 1 {
  6079. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6080. } else if record_type == 2 {
  6081. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6082. } else if record_type == 3 {
  6083. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6084. }
  6085. var dat2 map[string]interface{}
  6086. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6087. fmt.Println(dat2)
  6088. } else {
  6089. fmt.Println(err)
  6090. }
  6091. userJSONBytes, _ := json.Marshal(dat2)
  6092. var res ResultSix
  6093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6094. utils.ErrorLog("解析失败:%v", err)
  6095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6096. return
  6097. }
  6098. if res.Infcode == 0 {
  6099. if record_type == 1 {
  6100. service.UpdateDrugByIdDetail(item.ID)
  6101. } else if record_type == 2 {
  6102. service.UpdateGoodInfoById(item.ID)
  6103. } else if record_type == 3 {
  6104. service.UpdateMyProjectById(item.ID)
  6105. }
  6106. c.ServeSuccessJSON(map[string]interface{}{
  6107. "failed_code": 0,
  6108. "msg": "撤销目录对照成功",
  6109. })
  6110. } else {
  6111. c.ServeSuccessJSON(map[string]interface{}{
  6112. "failed_code": -10,
  6113. "msg": res.ErrMsg,
  6114. })
  6115. }
  6116. }
  6117. }
  6118. }
  6119. func (c *HisApiController) GetPatientInfo() {
  6120. id_card_no := c.GetString("id_card_no")
  6121. admin_user_id, _ := c.GetInt64("admin_user_id")
  6122. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6123. if patient.ID == 0 {
  6124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6125. return
  6126. }
  6127. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6128. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6129. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6130. if config.IsOpen == 1 {
  6131. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6132. var dat map[string]interface{}
  6133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6134. fmt.Println(dat)
  6135. } else {
  6136. fmt.Println(err)
  6137. }
  6138. userJSONBytes, _ := json.Marshal(dat)
  6139. var res ResultTwo
  6140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6141. utils.ErrorLog("解析失败:%v", err)
  6142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6143. return
  6144. }
  6145. if res.Infcode != 0 {
  6146. c.ServeSuccessJSON(map[string]interface{}{
  6147. "failed_code": -10,
  6148. "msg": res.ErrMsg,
  6149. })
  6150. } else {
  6151. c.ServeSuccessJSON(map[string]interface{}{
  6152. "failed_code": 0,
  6153. "info": res,
  6154. })
  6155. }
  6156. }
  6157. }
  6158. func (c *HisApiController) PsnPutOnRecord() {
  6159. record_type, _ := c.GetInt64("type")
  6160. patient_id, _ := c.GetInt64("patient_id")
  6161. admin_user_id, _ := c.GetInt64("admin_user_id")
  6162. start_time := c.GetString("start_time")
  6163. end_time := c.GetString("end_time")
  6164. adminUser := c.GetAdminUserInfo()
  6165. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6166. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6167. var patients []*models.Patients
  6168. if record_type == 1 { //全部备案
  6169. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6170. patients = append(patients, patient...)
  6171. } else { //单个备案
  6172. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6173. patients = append(patients, patient)
  6174. }
  6175. var user_name string
  6176. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6177. if role.ID == 0 {
  6178. user_name = "xxx"
  6179. } else {
  6180. user_name = role.UserName
  6181. }
  6182. if config.IsOpen == 1 {
  6183. for _, item := range patients {
  6184. 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
  6185. resp, requestErr := http.Get(api)
  6186. if requestErr != nil {
  6187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6188. return
  6189. }
  6190. defer resp.Body.Close()
  6191. body, ioErr := ioutil.ReadAll(resp.Body)
  6192. if ioErr != nil {
  6193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6195. return
  6196. }
  6197. var respJSON map[string]interface{}
  6198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6201. return
  6202. }
  6203. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6204. userJSONBytes, _ := json.Marshal(userJSON)
  6205. var res ResultTwo
  6206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6207. utils.ErrorLog("解析失败:%v", err)
  6208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6209. return
  6210. }
  6211. if res.Infcode == 0 {
  6212. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6213. var dat map[string]interface{}
  6214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6215. fmt.Println(dat)
  6216. } else {
  6217. fmt.Println(err)
  6218. }
  6219. userJSONBytes, _ := json.Marshal(dat)
  6220. var res2 ResultThirteen
  6221. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6222. utils.ErrorLog("解析失败:%v", err)
  6223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6224. return
  6225. }
  6226. if res2.Infcode == 0 {
  6227. psnResult := &models.GdybPsnRecord{
  6228. UserOrgId: adminUser.CurrentOrgId,
  6229. PatientId: item.ID,
  6230. PsnNo: res.Output.Baseinfo.PsnNo,
  6231. Ctime: time.Now().Unix(),
  6232. Mtime: time.Now().Unix(),
  6233. Status: 1,
  6234. IsCancel: 1,
  6235. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6236. }
  6237. service.CreatePsnRecord(psnResult)
  6238. } else {
  6239. c.ServeSuccessJSON(map[string]interface{}{
  6240. "failed_code": -10,
  6241. "msg": res2.ErrMsg,
  6242. })
  6243. return
  6244. }
  6245. }
  6246. }
  6247. }
  6248. }
  6249. func (c *HisApiController) PsnUnPutOnRecord() {
  6250. id, _ := c.GetInt64("id")
  6251. //record_type, _ := c.GetInt64("type")
  6252. admin_user_id, _ := c.GetInt64("admin_user_id")
  6253. adminUser := c.GetAdminUserInfo()
  6254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6256. var user_name string
  6257. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6258. if role.ID == 0 {
  6259. user_name = "xxx"
  6260. } else {
  6261. user_name = role.UserName
  6262. }
  6263. psn_record, _ := service.GetPsnRecordById(id)
  6264. if psn_record.ID == 0 {
  6265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6266. return
  6267. }
  6268. if config.IsOpen == 1 {
  6269. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6270. var dat map[string]interface{}
  6271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6272. fmt.Println(dat)
  6273. } else {
  6274. fmt.Println(err)
  6275. }
  6276. userJSONBytes, _ := json.Marshal(dat)
  6277. var res ResultFourteen
  6278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6279. utils.ErrorLog("解析失败:%v", err)
  6280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6281. return
  6282. }
  6283. if res.Infcode == 0 {
  6284. psn_record.IsCancel = 2
  6285. service.CreatePsnRecord(&psn_record)
  6286. } else {
  6287. c.ServeSuccessJSON(map[string]interface{}{
  6288. "failed_code": -10,
  6289. "msg": res.ErrMsg,
  6290. })
  6291. return
  6292. }
  6293. }
  6294. }
  6295. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6296. patient_id, _ := c.GetInt64("patient_id")
  6297. insutype := c.GetString("insutype")
  6298. psn_no := c.GetString("psn_no")
  6299. doctor_id, _ := c.GetInt64("doctor_id")
  6300. sick_id, _ := c.GetInt64("sick_id")
  6301. department_id, _ := c.GetInt64("department_id")
  6302. adminUser := c.GetAdminUserInfo()
  6303. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6304. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6305. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6306. sick, _ := service.FindSickById(sick_id)
  6307. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6308. if config.IsOpen == 1 {
  6309. 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.ContentCode)
  6310. var dat map[string]interface{}
  6311. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6312. fmt.Println(dat)
  6313. } else {
  6314. fmt.Println(err)
  6315. }
  6316. userJSONBytes, _ := json.Marshal(dat)
  6317. var res2 ResultThirteen
  6318. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6319. utils.ErrorLog("解析失败:%v", err)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return
  6322. }
  6323. if res2.Infcode == 0 {
  6324. psnResult := &models.GdybPsnNcdsRecord{
  6325. UserOrgId: adminUser.CurrentOrgId,
  6326. PatientId: patient.ID,
  6327. PsnNo: psn_no,
  6328. DoctorId: doctor.AdminUserId,
  6329. DepartmentId: department_id,
  6330. SickType: sick_id,
  6331. Insutype: insutype,
  6332. Ctime: time.Now().Unix(),
  6333. Mtime: time.Now().Unix(),
  6334. Status: 1,
  6335. IsCancel: 1,
  6336. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6337. }
  6338. service.CreatePsnNCDSRecord(psnResult)
  6339. c.ServeSuccessJSON(map[string]interface{}{
  6340. "failed_code": 0,
  6341. "msg": "备案成功",
  6342. "result": psnResult,
  6343. })
  6344. } else {
  6345. c.ServeSuccessJSON(map[string]interface{}{
  6346. "failed_code": -10,
  6347. "msg": res2.ErrMsg,
  6348. })
  6349. return
  6350. }
  6351. }
  6352. }
  6353. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  6354. id, _ := c.GetInt64("id")
  6355. admin_user_id, _ := c.GetInt64("admin_user_id")
  6356. adminUser := c.GetAdminUserInfo()
  6357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6359. var user_name string
  6360. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6361. if role.ID == 0 {
  6362. user_name = "xxx"
  6363. } else {
  6364. user_name = role.UserName
  6365. }
  6366. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6367. if psn_record.ID == 0 {
  6368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6369. return
  6370. }
  6371. if config.IsOpen == 1 {
  6372. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6373. var dat map[string]interface{}
  6374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6375. fmt.Println(dat)
  6376. } else {
  6377. fmt.Println(err)
  6378. }
  6379. userJSONBytes, _ := json.Marshal(dat)
  6380. var res ResultFourteen
  6381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6382. utils.ErrorLog("解析失败:%v", err)
  6383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6384. return
  6385. }
  6386. if res.Infcode == 0 {
  6387. psn_record.IsCancel = 2
  6388. service.CreatePsnNCDSRecord(&psn_record)
  6389. c.ServeSuccessJSON(map[string]interface{}{
  6390. "failed_code": 0,
  6391. "msg": "撤销备案成功",
  6392. })
  6393. } else {
  6394. c.ServeSuccessJSON(map[string]interface{}{
  6395. "failed_code": -10,
  6396. "msg": res.ErrMsg,
  6397. })
  6398. return
  6399. }
  6400. }
  6401. }
  6402. func (c *HisApiController) TestTest() {
  6403. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  6404. fmt.Println(patient.Iinfo)
  6405. }
  6406. type CustomData struct {
  6407. MsgId string
  6408. PsnNo string
  6409. Info string
  6410. }
  6411. func (c *HisApiController) ReversalData() {
  6412. var customData []*CustomData
  6413. custom := &CustomData{
  6414. MsgId: "H44022900158202103301714472004",
  6415. PsnNo: "44020000001101329945",
  6416. Info: "2207",
  6417. }
  6418. customData = append(customData, custom)
  6419. custom1 := &CustomData{
  6420. MsgId: "H4402290015820210330172057803",
  6421. PsnNo: "44020000001101161813",
  6422. Info: "2207",
  6423. }
  6424. customData = append(customData, custom1)
  6425. custom2 := &CustomData{
  6426. MsgId: "H44022900158202103301705198813",
  6427. PsnNo: "44190000133097375417",
  6428. Info: "2207",
  6429. }
  6430. customData = append(customData, custom2)
  6431. custom3 := &CustomData{
  6432. MsgId: "H44022900158202103301715524756",
  6433. PsnNo: "44020000001100187221",
  6434. Info: "2207",
  6435. }
  6436. customData = append(customData, custom3)
  6437. custom4 := &CustomData{
  6438. MsgId: "H44022900158202103301730376224",
  6439. PsnNo: "44020000001101959155",
  6440. Info: "2207",
  6441. }
  6442. customData = append(customData, custom4)
  6443. custom5 := &CustomData{
  6444. MsgId: "H44022900158202103301748008725",
  6445. PsnNo: "44020000001104246641",
  6446. Info: "2207",
  6447. }
  6448. customData = append(customData, custom5)
  6449. custom6 := &CustomData{
  6450. MsgId: "H44022900158202103301718096755",
  6451. PsnNo: "44020000001102211860",
  6452. Info: "2207",
  6453. }
  6454. customData = append(customData, custom6)
  6455. custom7 := &CustomData{
  6456. MsgId: "H44022900158202103301736551640",
  6457. PsnNo: "44020000001102687718",
  6458. Info: "2207",
  6459. }
  6460. customData = append(customData, custom7)
  6461. custom8 := &CustomData{
  6462. MsgId: "H44022900158202103301743097676",
  6463. PsnNo: "44020000001102127785",
  6464. Info: "2207",
  6465. }
  6466. customData = append(customData, custom8)
  6467. custom9 := &CustomData{
  6468. MsgId: "H44022900158202103301712304203",
  6469. PsnNo: "44020000001101518097",
  6470. Info: "2207",
  6471. }
  6472. customData = append(customData, custom9)
  6473. custom10 := &CustomData{
  6474. MsgId: "H44022900158202103301738448785",
  6475. PsnNo: "44020000001100500813",
  6476. Info: "2207",
  6477. }
  6478. customData = append(customData, custom10)
  6479. custom11 := &CustomData{
  6480. MsgId: "H44022900158202103301732455843",
  6481. PsnNo: "44020000001102690557",
  6482. Info: "2207",
  6483. }
  6484. customData = append(customData, custom11)
  6485. custom12 := &CustomData{
  6486. MsgId: "H44022900158202103301745421708",
  6487. PsnNo: "44020000001102211928",
  6488. Info: "2207",
  6489. }
  6490. customData = append(customData, custom12)
  6491. custom1212 := &CustomData{
  6492. MsgId: "H440229001582021033017351627",
  6493. PsnNo: "44020000001102481733",
  6494. Info: "2207",
  6495. }
  6496. customData = append(customData, custom1212)
  6497. custom13 := &CustomData{
  6498. MsgId: "H44022900158202103301740327951",
  6499. PsnNo: "44020000001103174866",
  6500. Info: "2207",
  6501. }
  6502. customData = append(customData, custom13)
  6503. custom14 := &CustomData{
  6504. MsgId: "H4402290015820210330174922668",
  6505. PsnNo: "44020000001102927272",
  6506. Info: "2207",
  6507. }
  6508. customData = append(customData, custom14)
  6509. custom15 := &CustomData{
  6510. MsgId: "H44022900158202103301752362273",
  6511. PsnNo: "44020000001102942890",
  6512. Info: "2207",
  6513. }
  6514. customData = append(customData, custom15)
  6515. custom16 := &CustomData{
  6516. MsgId: "H44022900158202103301751082917",
  6517. PsnNo: "44020000001101662162",
  6518. Info: "2207",
  6519. }
  6520. customData = append(customData, custom16)
  6521. custom17 := &CustomData{
  6522. MsgId: "H44022900158202103301754147728",
  6523. PsnNo: "44020000000229014511",
  6524. Info: "2207",
  6525. }
  6526. customData = append(customData, custom17)
  6527. adminUser := c.GetAdminUserInfo()
  6528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6529. for _, item := range customData {
  6530. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6531. fmt.Println(result)
  6532. }
  6533. }
  6534. func (c *HisApiController) ReversalOtherData() {
  6535. var customData []*CustomData
  6536. custom := &CustomData{
  6537. MsgId: "H44022900158202103301714472004",
  6538. PsnNo: "44020000001101329945",
  6539. Info: "2208",
  6540. }
  6541. customData = append(customData, custom)
  6542. custom1 := &CustomData{
  6543. MsgId: "H4402290015820210330172057803",
  6544. PsnNo: "44020000001101161813",
  6545. Info: "2208",
  6546. }
  6547. customData = append(customData, custom1)
  6548. custom2 := &CustomData{
  6549. MsgId: "H44022900158202103301705198813",
  6550. PsnNo: "44190000133097375417",
  6551. Info: "2208",
  6552. }
  6553. customData = append(customData, custom2)
  6554. custom3 := &CustomData{
  6555. MsgId: "H44022900158202103301715524756",
  6556. PsnNo: "44020000001100187221",
  6557. Info: "2208",
  6558. }
  6559. customData = append(customData, custom3)
  6560. custom4 := &CustomData{
  6561. MsgId: "H44022900158202103301730376224",
  6562. PsnNo: "44020000001101959155",
  6563. Info: "2208",
  6564. }
  6565. customData = append(customData, custom4)
  6566. custom5 := &CustomData{
  6567. MsgId: "H44022900158202103301748008725",
  6568. PsnNo: "44020000001104246641",
  6569. Info: "2208",
  6570. }
  6571. customData = append(customData, custom5)
  6572. custom6 := &CustomData{
  6573. MsgId: "H44022900158202103301718096755",
  6574. PsnNo: "44020000001102211860",
  6575. Info: "2208",
  6576. }
  6577. customData = append(customData, custom6)
  6578. custom7 := &CustomData{
  6579. MsgId: "H44022900158202103301736551640",
  6580. PsnNo: "44020000001102687718",
  6581. Info: "2208",
  6582. }
  6583. customData = append(customData, custom7)
  6584. custom8 := &CustomData{
  6585. MsgId: "H44022900158202103301743097676",
  6586. PsnNo: "44020000001102127785",
  6587. Info: "2208",
  6588. }
  6589. customData = append(customData, custom8)
  6590. custom9 := &CustomData{
  6591. MsgId: "H44022900158202103301712304203",
  6592. PsnNo: "44020000001101518097",
  6593. Info: "2208",
  6594. }
  6595. customData = append(customData, custom9)
  6596. custom10 := &CustomData{
  6597. MsgId: "H44022900158202103301738448785",
  6598. PsnNo: "44020000001100500813",
  6599. Info: "2208",
  6600. }
  6601. customData = append(customData, custom10)
  6602. custom11 := &CustomData{
  6603. MsgId: "H44022900158202103301732455843",
  6604. PsnNo: "44020000001102690557",
  6605. Info: "2208",
  6606. }
  6607. customData = append(customData, custom11)
  6608. custom12 := &CustomData{
  6609. MsgId: "H44022900158202103301745421708",
  6610. PsnNo: "44020000001102211928",
  6611. Info: "2208",
  6612. }
  6613. customData = append(customData, custom12)
  6614. custom1212 := &CustomData{
  6615. MsgId: "H440229001582021033017351627",
  6616. PsnNo: "44020000001102481733",
  6617. Info: "2208",
  6618. }
  6619. customData = append(customData, custom1212)
  6620. custom13 := &CustomData{
  6621. MsgId: "H44022900158202103301740327951",
  6622. PsnNo: "44020000001103174866",
  6623. Info: "2208",
  6624. }
  6625. customData = append(customData, custom13)
  6626. custom14 := &CustomData{
  6627. MsgId: "H4402290015820210330174922668",
  6628. PsnNo: "44020000001102927272",
  6629. Info: "2208",
  6630. }
  6631. customData = append(customData, custom14)
  6632. custom15 := &CustomData{
  6633. MsgId: "H44022900158202103301752362273",
  6634. PsnNo: "44020000001102942890",
  6635. Info: "2208",
  6636. }
  6637. customData = append(customData, custom15)
  6638. custom16 := &CustomData{
  6639. MsgId: "H44022900158202103301751082917",
  6640. PsnNo: "44020000001101662162",
  6641. Info: "2208",
  6642. }
  6643. customData = append(customData, custom16)
  6644. custom17 := &CustomData{
  6645. MsgId: "H44022900158202103301754147728",
  6646. PsnNo: "44020000000229014511",
  6647. Info: "2208",
  6648. }
  6649. customData = append(customData, custom17)
  6650. adminUser := c.GetAdminUserInfo()
  6651. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6652. for _, item := range customData {
  6653. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6654. fmt.Println(result)
  6655. }
  6656. }
  6657. func PathExists(path string) (bool, error) {
  6658. _, err := os.Stat(path)
  6659. if err == nil {
  6660. return true, nil
  6661. }
  6662. if os.IsNotExist(err) {
  6663. return false, nil
  6664. }
  6665. return false, err
  6666. }
  6667. //创建文件夹
  6668. func Mkdir(dir string) {
  6669. // 创建文件夹
  6670. exist, err := PathExists(dir)
  6671. if err != nil {
  6672. fmt.Println(err.Error())
  6673. } else {
  6674. if exist {
  6675. fmt.Println(dir + "文件夹已存在!")
  6676. } else {
  6677. // 文件夹名称,权限
  6678. err := os.Mkdir(dir, os.ModePerm)
  6679. if err != nil {
  6680. fmt.Println(dir+"文件夹创建失败:", err.Error())
  6681. } else {
  6682. fmt.Println(dir + "文件夹创建成功!")
  6683. }
  6684. }
  6685. }
  6686. }
  6687. //压缩文件
  6688. func Zip(srcFile string, destZip string) error {
  6689. zipfile, err := os.Create(destZip)
  6690. if err != nil {
  6691. return err
  6692. }
  6693. defer zipfile.Close()
  6694. archive := zip.NewWriter(zipfile)
  6695. defer archive.Close()
  6696. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  6697. if err != nil {
  6698. return err
  6699. }
  6700. header, err := zip.FileInfoHeader(info)
  6701. if err != nil {
  6702. return err
  6703. }
  6704. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  6705. // header.Name = path
  6706. if info.IsDir() {
  6707. header.Name += "/"
  6708. } else {
  6709. header.Method = zip.Deflate
  6710. }
  6711. writer, err := archive.CreateHeader(header)
  6712. if err != nil {
  6713. return err
  6714. }
  6715. if !info.IsDir() {
  6716. file, err := os.Open(path)
  6717. if err != nil {
  6718. return err
  6719. }
  6720. defer file.Close()
  6721. _, err = io.Copy(writer, file)
  6722. }
  6723. return err
  6724. })
  6725. return err
  6726. }
  6727. func ReadFile(filePath string) []byte {
  6728. f, err := os.Open(filePath)
  6729. if err != nil {
  6730. fmt.Println("read file fail", err)
  6731. return nil
  6732. }
  6733. defer f.Close()
  6734. fd, err := ioutil.ReadAll(f)
  6735. if err != nil {
  6736. fmt.Println("read to fd fail", err)
  6737. return nil
  6738. }
  6739. return fd
  6740. }
  6741. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  6742. newArr = make([]*models.HisOrderInfo, 0)
  6743. for i := 0; i < len(arr); i++ {
  6744. repeat := false
  6745. for j := i + 1; j < len(arr); j++ {
  6746. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  6747. repeat = true
  6748. break
  6749. }
  6750. }
  6751. if !repeat {
  6752. newArr = append(newArr, arr[i])
  6753. }
  6754. }
  6755. return
  6756. }
  6757. func saveRegisterLog(result string) {
  6758. org_id, _ := beego.AppConfig.Int64("org_id")
  6759. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6760. dir := miConfig.OrgName + "日志"
  6761. utils.Mkdir(dir)
  6762. month := time.Unix(1557042972, 0).Format("1")
  6763. year := time.Now().Format("2006")
  6764. month = time.Now().Format("01")
  6765. day := time.Now().Format("02")
  6766. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6767. file_name := file + ".txt"
  6768. file_path := miConfig.OrgName + "日志" + "/" + file_name
  6769. exist, _ := utils.PathExists(file_path)
  6770. if exist { //存在
  6771. fmt.Println("存在")
  6772. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6773. if err != nil {
  6774. fmt.Println("read fail")
  6775. }
  6776. content := "\r\n" + result
  6777. n, _ := f.Seek(0, 2)
  6778. _, err = f.WriteAt([]byte(content), n)
  6779. } else { //不存在
  6780. fmt.Println("文件不存在,创建文件")
  6781. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6782. defer f.Close()
  6783. if err != nil {
  6784. } else {
  6785. _, err = f.Write([]byte("记录日志"))
  6786. }
  6787. }
  6788. }
  6789. func saveLog(result string, request string, infno string, desc string) {
  6790. org_id, _ := beego.AppConfig.Int64("org_id")
  6791. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6792. dir := miConfig.OrgName + "日志"
  6793. utils.Mkdir(dir)
  6794. month := time.Unix(1557042972, 0).Format("1")
  6795. year := time.Now().Format("2006")
  6796. month = time.Now().Format("01")
  6797. day := time.Now().Format("02")
  6798. hour := time.Now().Format("15")
  6799. min := time.Now().Format("04")
  6800. sec := time.Now().Format("05")
  6801. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  6802. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6803. file_name := file + ".txt"
  6804. file_path := miConfig.OrgName + "日志" + "/" + file_name
  6805. exist, _ := utils.PathExists(file_path)
  6806. if exist { //存在
  6807. fmt.Println("存在")
  6808. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6809. if err != nil {
  6810. fmt.Println("read fail")
  6811. }
  6812. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  6813. n, _ := f.Seek(0, 2)
  6814. _, err = f.WriteAt([]byte(content), n)
  6815. } else { //不存在
  6816. fmt.Println("文件不存在,创建文件")
  6817. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6818. defer f.Close()
  6819. if err != nil {
  6820. } else {
  6821. _, err = f.Write([]byte("记录日志"))
  6822. }
  6823. }
  6824. }
  6825. type Charset string
  6826. const (
  6827. UTF8 = Charset("UTF-8")
  6828. GB18030 = Charset("GB18030")
  6829. )
  6830. func ConvertToString(src string, srcCode string, tagCode string) string {
  6831. srcCoder := mahonia.NewDecoder(srcCode)
  6832. srcResult := srcCoder.ConvertString(src)
  6833. tagCoder := mahonia.NewDecoder(tagCode)
  6834. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  6835. result := string(cdata)
  6836. return result
  6837. }
  6838. //func (c *HisApiController)HandleCheckDetailAccount(){
  6839. // psn_no, _ := c.GetString("psn_no")
  6840. // psn_no, _ := c.GetString("psn_no")
  6841. // psn_no, _ := c.GetString("psn_no")
  6842. //
  6843. //
  6844. //
  6845. //}