his_api_controller.go 380KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433
  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. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  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. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&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)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. if status == "0" { //读卡成功
  377. var card_info string //卡信息
  378. var busi_card_info string
  379. var res ResultTwo //1101结果
  380. var res10265 ResultTwo10265 //1101结果
  381. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  383. fmt.Println(card_info)
  384. fmt.Println(busi_card_info)
  385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  386. result, _ := json.Marshal(respJSON)
  387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  388. utils.ErrorLog("解析失败:%v", err)
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  390. return
  391. }
  392. res.ErrMsg = res10265.ErrMsg
  393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  394. res.Infcode = infocode
  395. res.Output = res10265.Output
  396. res.InfRefmsgid = res10265.InfRefmsgid
  397. if res.Infcode == 0 {
  398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  399. if err == gorm.ErrRecordNotFound {
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  401. return
  402. } else if err != nil {
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  404. return
  405. } else {
  406. bas := strings.Split(card_info, "|")
  407. basNumber := bas[2]
  408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  410. infoStr := string(Iinfos)
  411. idetinfoStr := string(Idetinfos)
  412. psn := &models.HisPsn{
  413. PsnNo: res.Output.Baseinfo.PsnNo,
  414. Age: res.Output.Baseinfo.Age,
  415. PatientId: patient.ID,
  416. Certno: res.Output.Baseinfo.Certno,
  417. Brdy: res.Output.Baseinfo.Brdy,
  418. Gend: res.Output.Baseinfo.Gend,
  419. Naty: res.Output.Baseinfo.Naty,
  420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  421. PsnName: res.Output.Baseinfo.PsnName,
  422. Idetinfo: idetinfoStr,
  423. Insuinfo: infoStr,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. CardInfo: card_info,
  426. VerifyNumber: busi_card_info,
  427. }
  428. service.CreateHisPsn(psn)
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "patient": patient,
  431. "number": basNumber,
  432. })
  433. }
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  436. return
  437. }
  438. } else { //读卡失败
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  440. return
  441. }
  442. } else {
  443. if initFlag == 0 {
  444. c.TestGetBasBaseInit()
  445. }
  446. basStr := c.GetBasBaseInfo()
  447. if len(basStr) == 0 {
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  449. return
  450. }
  451. fmt.Println(basStr)
  452. bas := strings.Split(basStr, "|")
  453. basNumber := bas[1]
  454. fmt.Println(basNumber)
  455. card_sn := bas[3]
  456. fmt.Println(card_sn)
  457. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultTwo
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Infcode == 0 {
  472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  473. if err == gorm.ErrRecordNotFound {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  475. return
  476. } else if err != nil {
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. } else {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": basNumber,
  483. })
  484. }
  485. } else {
  486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  487. return
  488. }
  489. break
  490. }
  491. case 2:
  492. SFZStr := c.GetSFZBaseInfo()
  493. id_card_str := strings.Split(SFZStr, "^")
  494. id_card_number := id_card_str[0]
  495. card_sn := ""
  496. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  497. var dat map[string]interface{}
  498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  499. fmt.Println(dat)
  500. } else {
  501. fmt.Println(err)
  502. }
  503. userJSONBytes, _ := json.Marshal(dat)
  504. var res ResultTwo
  505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == 0 {
  511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  512. if err == gorm.ErrRecordNotFound {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  514. return
  515. } else if err != nil {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. } else {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "patient": patient,
  521. "number": id_card_number,
  522. })
  523. }
  524. } else {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  526. return
  527. }
  528. break
  529. case 3:
  530. break
  531. }
  532. }
  533. var initFlag int64 = 0
  534. func (c *HisApiController) TestGetBasBaseInit() {
  535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  536. Iinit := DllDef.MustFindProc("Init")
  537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  538. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  539. if ret != 0 {
  540. fmt.Println("SSCard的报错原因:", err)
  541. fmt.Println("SSCard的运算结果为:", ret)
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  543. return
  544. }
  545. result := int(ret)
  546. fmt.Println("SSCard的运算结果为1:", result)
  547. initFlag = 1
  548. return
  549. }
  550. func (c *HisApiController) GetSFZBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadSFZ")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadSFZ")
  556. }
  557. str := make([]byte, 256)
  558. str1 := make([]byte, 256)
  559. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  560. fmt.Println(r)
  561. return string(str)
  562. }
  563. func (c *HisApiController) GetBasBaseInfo() string {
  564. DllDef := syscall.MustLoadDLL("SSCard.dll")
  565. readCard := DllDef.MustFindProc("ReadCardBas")
  566. if readCard == nil {
  567. fmt.Println("readcard is nil")
  568. readCard = DllDef.MustFindProc("ReadCardBas")
  569. }
  570. str := make([]byte, 1024)
  571. str1 := make([]byte, 1024)
  572. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  573. fmt.Println(string(str1))
  574. fmt.Println(string(str))
  575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  576. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  577. if ret2 != 0 {
  578. return ""
  579. }
  580. return string(str)
  581. }
  582. type CustomFundPay struct {
  583. FundPayType string `json:"fund_pay_type"`
  584. FundPayamt float64 `json:"fund_payamt"`
  585. }
  586. func (c *HisApiController) GetSettleList() {
  587. order_id, _ := c.GetInt64("order_id")
  588. admin_user_id, _ := c.GetInt64("admin_user_id")
  589. order, _ := service.GetHisOrderByIDTwo(order_id)
  590. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  592. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  593. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. if order.ID == 0 {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  598. return
  599. }
  600. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  601. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  602. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  603. fmt.Println(count)
  604. var zero string
  605. number := count + 1
  606. if number >= 1000 {
  607. zero = "0000" + strconv.FormatInt(number, 10)
  608. } else if number >= 10000 {
  609. zero = "000" + strconv.FormatInt(number, 10)
  610. } else if number >= 100000 {
  611. zero = "00" + strconv.FormatInt(number, 10)
  612. } else if number >= 1000000 {
  613. zero = "0" + strconv.FormatInt(number, 10)
  614. } else {
  615. zero = strconv.FormatInt(number, 10)
  616. }
  617. fmt.Println(zero)
  618. struct4101 := service.Struct4101{
  619. PsnNo: order.PsnNo,
  620. MdtrtId: order.MdtrtId,
  621. SetlId: order.SetlId,
  622. PsnName: order.PsnName,
  623. Gend: order.Gend,
  624. Brdy: his.Brdy,
  625. Age: his.Age,
  626. Naty: order.Naty,
  627. PatnCertType: "01",
  628. Certno: order.Certno,
  629. Prfs: "90",
  630. ConerName: roles[0].UserName,
  631. PatnRlts: "99",
  632. ConerAddr: miConfig.OrgName,
  633. ConerTel: admin.Mobile,
  634. HiType: order.Insutype,
  635. Insuplc: miConfig.InsuplcAdmdvs,
  636. MaindiagFlag: "1",
  637. BillCode: last_order.FaPiaoCode,
  638. BillNo: zero,
  639. BizSn: order.Number,
  640. PsnSelfPay: order.PsnPartAmt,
  641. PsnOwnPay: order.PsnPartAmt,
  642. AcctPay: order.AcctPay,
  643. PsnCashpay: order.PsnCashPay,
  644. HiPaymtd: "1",
  645. Hsorg: miConfig.InsuplcAdmdvs,
  646. HsorgOpter: miConfig.InsuplcAdmdvs,
  647. MedinsFillPsn: curRoles.UserName,
  648. MedinsFillDept: depart.Name,
  649. IptMedType: "2",
  650. }
  651. struct4101.SetlBegnDate = order.SetlTime
  652. struct4101.SetlEndDate = order.SetlTime
  653. time_arr := strings.Split(order.SetlTime, " ")
  654. struct4101.AdmTime = time_arr[0]
  655. struct4101.AdmEndTime = time_arr[0]
  656. var rf []CustomFundPay
  657. json.Unmarshal([]byte(order.SetlDetail), &rf)
  658. var tempFunPays []service.CustomStruct
  659. for _, item := range rf {
  660. var tempFunPay service.CustomStruct
  661. tempFunPay.FundPayamt = item.FundPayamt
  662. tempFunPay.FundPayType = item.FundPayType
  663. tempFunPays = append(tempFunPays, tempFunPay)
  664. }
  665. struct4101.CustomStruct = tempFunPays
  666. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  669. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  670. var config []*models.HisXtDiagnoseConfig
  671. for _, item := range diagnosis_ids {
  672. id, _ := strconv.ParseInt(item, 10, 64)
  673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  674. config = append(config, &diagnosisConfig)
  675. }
  676. for _, item := range config {
  677. var tempOpspdiseinfo service.OpspdiseinfoStruct
  678. tempOpspdiseinfo.DiagCode = item.CountryCode
  679. tempOpspdiseinfo.DiagName = item.CountryContentName
  680. tempOpspdiseinfo.MaindiagFlag = "1"
  681. tempOpspdiseinfo.OprnOprtCode = ""
  682. tempOpspdiseinfo.OprnOprtName = ""
  683. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  684. }
  685. sickConfigTwo, _ := service.FindSickById(his.SickType)
  686. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  687. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  688. tempOpspdiseinfo2.MaindiagFlag = "2"
  689. tempOpspdiseinfo2.OprnOprtCode = ""
  690. tempOpspdiseinfo2.OprnOprtName = ""
  691. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  692. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  693. var iteminfo service.IteminfoStruct
  694. var bedCostTotal float64 = 0 //床位总费
  695. var bedCostSelfTotal float64 = 0 //床位自费
  696. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  697. var operationCostTotal float64 = 0 //手术费
  698. var operationCostSelfTotal float64 = 0 //手术费
  699. var operationCostPartSelfTotal float64 = 0 //手术费
  700. var otherCostTotal float64 = 0 //其他费用
  701. var otherCostSelfTotal float64 = 0 //其他费用
  702. var otherCostPartSelfTotal float64 = 0 //其他费用
  703. var materialCostTotal float64 = 0 //材料费
  704. var materialCostSelfTotal float64 = 0 //材料费
  705. var materialCostPartSelfTotal float64 = 0 //材料费
  706. var westernMedicineCostTotal float64 = 0 //西药费
  707. var westernMedicineCostSelfTotal float64 = 0 //西药费
  708. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  709. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  710. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  711. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  712. var checkCostTotal float64 = 0 //检查费
  713. var checkCostSelfTotal float64 = 0 //检查费
  714. var checkCostPartSelfTotal float64 = 0 //检查费
  715. var laboratoryCostTotal float64 = 0 //化验费
  716. var laboratoryCostSelfTotal float64 = 0 //化验费
  717. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  718. var treatCostTotal float64 = 0 //治疗费用
  719. var treatCostSelfTotal float64 = 0 //治疗费用
  720. var treatCostPartSelfTotal float64 = 0 //治疗费用
  721. decimal.DivisionPrecision = 2
  722. var bed_fulamt_ownpay_amt float64 = 0
  723. var operation_fulamt_ownpay_amt float64 = 0
  724. var other_fulamt_ownpay_amt float64 = 0
  725. var westernMedicine_fulamt_ownpay_amt float64 = 0
  726. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  727. var check_fulamt_ownpay_amt float64 = 0
  728. var material_fulamt_ownpay_amt float64 = 0
  729. var laboratory_fulamt_ownpay_amt float64 = 0
  730. var treat_fulamt_ownpay_amt float64 = 0
  731. var bed_claa_sunmfee float64 = 0
  732. var bed_clab_amt float64 = 0
  733. var bed_other_amt float64 = 0
  734. var operation_claa_sunmfee float64 = 0
  735. var operation_clab_amt float64 = 0
  736. var operation_other_amt float64 = 0
  737. var other_claa_sunmfee float64 = 0
  738. var other_clab_amt float64 = 0
  739. var other_other_amt float64 = 0
  740. var westernMedicine_claa_sunmfee float64 = 0
  741. var westernMedicine_clab_amt float64 = 0
  742. var westernMedicine_other_amt float64 = 0
  743. var chineseTraditional_claa_sunmfee float64 = 0
  744. var chineseTraditional_clab_amt float64 = 0
  745. var chineseTraditional_other_amt float64 = 0
  746. var check_claa_sunmfee float64 = 0
  747. var check_clab_amt float64 = 0
  748. var check_other_amt float64 = 0
  749. var material_claa_sunmfee float64 = 0
  750. var material_clab_amt float64 = 0
  751. var material_other_amt float64 = 0
  752. var laboratory_claa_sunmfee float64 = 0
  753. var laboratory_clab_amt float64 = 0
  754. var laboratory_other_amt float64 = 0
  755. var treat_claa_sunmfee float64 = 0
  756. var treat_clab_amt float64 = 0
  757. var treat_other_amt float64 = 0
  758. for _, item := range order.HisOrderInfo {
  759. if item.MedChrgitmType == "01" { //床位费
  760. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  761. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  762. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  763. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  764. if item.ChrgitmLv == "1" {
  765. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  766. }
  767. if item.ChrgitmLv == "2" {
  768. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  769. }
  770. if item.ChrgitmLv == "3" {
  771. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  772. }
  773. }
  774. if item.MedChrgitmType == "03" { //检查费
  775. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  776. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  777. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  778. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  779. if item.ChrgitmLv == "1" {
  780. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  781. }
  782. if item.ChrgitmLv == "2" {
  783. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  784. }
  785. if item.ChrgitmLv == "3" {
  786. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  787. }
  788. }
  789. if item.MedChrgitmType == "04" { //化验费
  790. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  791. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  792. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  793. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  794. if item.ChrgitmLv == "1" {
  795. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  796. }
  797. if item.ChrgitmLv == "2" {
  798. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  799. }
  800. if item.ChrgitmLv == "3" {
  801. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  802. }
  803. }
  804. if item.MedChrgitmType == "05" { //治疗费
  805. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  806. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  807. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  808. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  809. if item.ChrgitmLv == "1" {
  810. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  811. }
  812. if item.ChrgitmLv == "2" {
  813. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  814. }
  815. if item.ChrgitmLv == "3" {
  816. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  817. }
  818. }
  819. if item.MedChrgitmType == "06" { //手术费
  820. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  821. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  822. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  823. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  824. if item.ChrgitmLv == "1" {
  825. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  826. }
  827. if item.ChrgitmLv == "2" {
  828. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  829. }
  830. if item.ChrgitmLv == "3" {
  831. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  832. }
  833. }
  834. if item.MedChrgitmType == "08" { //材料费
  835. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  836. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  837. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  838. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  839. if item.ChrgitmLv == "1" {
  840. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  841. }
  842. if item.ChrgitmLv == "2" {
  843. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  844. }
  845. if item.ChrgitmLv == "3" {
  846. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  847. }
  848. }
  849. if item.MedChrgitmType == "09" { //西药费
  850. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  851. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  852. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  853. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  854. if item.ChrgitmLv == "1" {
  855. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  856. }
  857. if item.ChrgitmLv == "2" {
  858. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  859. }
  860. if item.ChrgitmLv == "3" {
  861. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  862. }
  863. }
  864. if item.MedChrgitmType == "11" { //中成费
  865. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  866. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  867. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  868. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  869. if item.ChrgitmLv == "1" {
  870. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  871. }
  872. if item.ChrgitmLv == "2" {
  873. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  874. }
  875. if item.ChrgitmLv == "3" {
  876. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  877. }
  878. }
  879. if item.MedChrgitmType == "14" { //其他费
  880. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  881. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  882. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  883. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  884. if item.ChrgitmLv == "1" {
  885. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  886. }
  887. if item.ChrgitmLv == "2" {
  888. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  889. }
  890. if item.ChrgitmLv == "3" {
  891. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  892. }
  893. }
  894. }
  895. var iteminfoStructs []service.IteminfoStruct
  896. if bedCostTotal != 0 {
  897. iteminfo.MedChrgitm = "01"
  898. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  899. iteminfo.Amt = bedCostTotal
  900. iteminfo.ClaaSumfee = bed_claa_sunmfee
  901. iteminfo.ClabAmt = bed_clab_amt
  902. iteminfo.OthAmt = bed_other_amt
  903. iteminfoStructs = append(iteminfoStructs, iteminfo)
  904. }
  905. if checkCostTotal != 0 {
  906. iteminfo.MedChrgitm = "03"
  907. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  908. iteminfo.Amt = checkCostTotal
  909. iteminfo.ClaaSumfee = check_claa_sunmfee
  910. iteminfo.ClabAmt = check_clab_amt
  911. iteminfo.OthAmt = check_other_amt
  912. iteminfoStructs = append(iteminfoStructs, iteminfo)
  913. }
  914. if laboratoryCostTotal != 0 {
  915. iteminfo.MedChrgitm = "04"
  916. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  917. iteminfo.Amt = laboratoryCostTotal
  918. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  919. iteminfo.ClabAmt = laboratory_clab_amt
  920. iteminfo.OthAmt = laboratory_other_amt
  921. iteminfoStructs = append(iteminfoStructs, iteminfo)
  922. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  923. }
  924. if treatCostTotal != 0 {
  925. iteminfo.MedChrgitm = "05"
  926. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  927. iteminfo.Amt = treatCostTotal
  928. iteminfo.ClaaSumfee = treat_claa_sunmfee
  929. iteminfo.ClabAmt = treat_clab_amt
  930. iteminfo.OthAmt = treat_other_amt
  931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  932. //(struct4101.IteminfoStruct, iteminfo)
  933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  934. }
  935. if operationCostTotal != 0 {
  936. iteminfo.MedChrgitm = "06"
  937. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  938. iteminfo.Amt = operationCostTotal
  939. iteminfo.ClaaSumfee = operation_claa_sunmfee
  940. iteminfo.ClabAmt = operation_clab_amt
  941. iteminfo.OthAmt = operation_other_amt
  942. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  943. iteminfoStructs = append(iteminfoStructs, iteminfo)
  944. }
  945. if materialCostTotal != 0 {
  946. iteminfo.MedChrgitm = "08"
  947. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  948. iteminfo.Amt = materialCostTotal
  949. iteminfo.ClaaSumfee = material_claa_sunmfee
  950. iteminfo.ClabAmt = material_clab_amt
  951. iteminfo.OthAmt = material_other_amt
  952. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  953. iteminfoStructs = append(iteminfoStructs, iteminfo)
  954. }
  955. if westernMedicineCostTotal != 0 {
  956. iteminfo.MedChrgitm = "09"
  957. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  958. iteminfo.Amt = westernMedicineCostTotal
  959. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  960. iteminfo.ClabAmt = westernMedicine_clab_amt
  961. iteminfo.OthAmt = westernMedicine_other_amt
  962. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  963. iteminfoStructs = append(iteminfoStructs, iteminfo)
  964. }
  965. if chineseTraditionalMedicineCostTotal != 0 {
  966. iteminfo.MedChrgitm = "11"
  967. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  968. iteminfo.Amt = westernMedicineCostTotal
  969. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  970. iteminfo.ClabAmt = westernMedicine_clab_amt
  971. iteminfo.OthAmt = westernMedicine_other_amt
  972. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  973. iteminfoStructs = append(iteminfoStructs, iteminfo)
  974. }
  975. if otherCostTotal != 0 {
  976. iteminfo.MedChrgitm = "14"
  977. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  978. iteminfo.Amt = otherCostTotal
  979. iteminfo.ClaaSumfee = other_claa_sunmfee
  980. iteminfo.ClabAmt = other_clab_amt
  981. iteminfo.OthAmt = other_other_amt
  982. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  983. iteminfoStructs = append(iteminfoStructs, iteminfo)
  984. }
  985. struct4101.IteminfoStruct = iteminfoStructs
  986. struct4101.Ntly = "中国"
  987. struct4101.AdmCaty = "A03.06"
  988. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  989. fmt.Println(result)
  990. var dat map[string]interface{}
  991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  992. fmt.Println(dat)
  993. } else {
  994. fmt.Println(err)
  995. }
  996. userJSONBytes, _ := json.Marshal(dat)
  997. var res ResultSeventeen
  998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  999. utils.ErrorLog("解析失败:%v", err)
  1000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1001. return
  1002. }
  1003. if res.Infcode != 0 {
  1004. c.ServeSuccessJSON(map[string]interface{}{
  1005. "failed_code": -10,
  1006. "msg": res.ErrMsg,
  1007. })
  1008. return
  1009. } else {
  1010. order.FaPiaoNumber = zero
  1011. order.FaPiaoCode = last_order.FaPiaoCode
  1012. service.UpdateOrder(order)
  1013. hisFundSettleListResult := &models.HisFundSettleListResult{
  1014. Number: res.Output.SetlListId,
  1015. Status: 1,
  1016. Ctime: time.Now().Unix(),
  1017. Mtime: time.Now().Unix(),
  1018. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1019. IsUpload: 1,
  1020. OrderId: order_id,
  1021. }
  1022. service.CreateUploadRecord(hisFundSettleListResult)
  1023. c.ServeSuccessJSON(map[string]interface{}{
  1024. "msg": "上传成功",
  1025. "result": hisFundSettleListResult,
  1026. })
  1027. return
  1028. }
  1029. }
  1030. func (c *HisApiController) GetSettleListHospital() {
  1031. order_id, _ := c.GetInt64("order_id")
  1032. admin_user_id, _ := c.GetInt64("admin_user_id")
  1033. order, _ := service.GetHisOrderByIDTwo(order_id)
  1034. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1035. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1036. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1038. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1040. if order.ID == 0 {
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1042. return
  1043. }
  1044. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1045. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1046. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1047. fmt.Println(count)
  1048. var zero string
  1049. number := count + 1
  1050. if number >= 1000 {
  1051. zero = "0000" + strconv.FormatInt(number, 10)
  1052. } else if number >= 10000 {
  1053. zero = "000" + strconv.FormatInt(number, 10)
  1054. } else if number >= 100000 {
  1055. zero = "00" + strconv.FormatInt(number, 10)
  1056. } else if number >= 1000000 {
  1057. zero = "0" + strconv.FormatInt(number, 10)
  1058. } else {
  1059. zero = strconv.FormatInt(number, 10)
  1060. }
  1061. fmt.Println(zero)
  1062. struct4101 := service.Struct4101{
  1063. PsnNo: order.PsnNo,
  1064. MdtrtId: order.MdtrtId,
  1065. SetlId: order.SetlId,
  1066. PsnName: order.PsnName,
  1067. Gend: order.Gend,
  1068. Brdy: his.Brdy,
  1069. Age: int64(order.Age),
  1070. Naty: order.Naty,
  1071. PatnCertType: "01",
  1072. Certno: order.Certno,
  1073. Prfs: "90",
  1074. ConerName: roles[0].UserName,
  1075. PatnRlts: "99",
  1076. ConerAddr: miConfig.OrgName,
  1077. ConerTel: admin.Mobile,
  1078. HiType: order.Insutype,
  1079. Insuplc: miConfig.InsuplcAdmdvs,
  1080. MaindiagFlag: "1",
  1081. BillCode: last_order.FaPiaoCode,
  1082. BillNo: zero,
  1083. BizSn: order.Number,
  1084. PsnSelfPay: order.PsnPartAmt,
  1085. PsnOwnPay: order.PsnPartAmt,
  1086. AcctPay: order.AcctPay,
  1087. PsnCashpay: order.PsnCashPay,
  1088. HiPaymtd: "1",
  1089. Hsorg: miConfig.InsuplcAdmdvs,
  1090. HsorgOpter: miConfig.InsuplcAdmdvs,
  1091. MedinsFillPsn: curRoles.UserName,
  1092. MedinsFillDept: depart.Name,
  1093. IptMedType: "2",
  1094. }
  1095. struct4101.SetlBegnDate = order.SetlTime
  1096. struct4101.SetlEndDate = order.SetlTime
  1097. var rf []CustomFundPay
  1098. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1099. var tempFunPays []service.CustomStruct
  1100. for _, item := range rf {
  1101. var tempFunPay service.CustomStruct
  1102. tempFunPay.FundPayamt = item.FundPayamt
  1103. tempFunPay.FundPayType = item.FundPayType
  1104. tempFunPays = append(tempFunPays, tempFunPay)
  1105. }
  1106. struct4101.CustomStruct = tempFunPays
  1107. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1108. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1109. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1110. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1111. var config []*models.HisXtDiagnoseConfig
  1112. for _, item := range diagnosis_ids {
  1113. id, _ := strconv.ParseInt(item, 10, 64)
  1114. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1115. config = append(config, &diagnosisConfig)
  1116. }
  1117. for _, item := range config {
  1118. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1119. tempOpspdiseinfo.DiagCode = item.CountryCode
  1120. tempOpspdiseinfo.DiagName = item.CountryContentName
  1121. tempOpspdiseinfo.MaindiagFlag = "1"
  1122. tempOpspdiseinfo.OprnOprtCode = ""
  1123. tempOpspdiseinfo.OprnOprtName = ""
  1124. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1125. }
  1126. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1127. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1128. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1129. tempOpspdiseinfo2.MaindiagFlag = "2"
  1130. tempOpspdiseinfo2.OprnOprtCode = ""
  1131. tempOpspdiseinfo2.OprnOprtName = ""
  1132. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1133. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1134. var iteminfo service.IteminfoStruct
  1135. var bedCostTotal float64 = 0 //床位总费
  1136. var bedCostSelfTotal float64 = 0 //床位自费
  1137. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1138. var operationCostTotal float64 = 0 //手术费
  1139. var operationCostSelfTotal float64 = 0 //手术费
  1140. var operationCostPartSelfTotal float64 = 0 //手术费
  1141. var otherCostTotal float64 = 0 //其他费用
  1142. var otherCostSelfTotal float64 = 0 //其他费用
  1143. var otherCostPartSelfTotal float64 = 0 //其他费用
  1144. var materialCostTotal float64 = 0 //材料费
  1145. var materialCostSelfTotal float64 = 0 //材料费
  1146. var materialCostPartSelfTotal float64 = 0 //材料费
  1147. var westernMedicineCostTotal float64 = 0 //西药费
  1148. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1149. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1150. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1151. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1152. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1153. var checkCostTotal float64 = 0 //检查费
  1154. var checkCostSelfTotal float64 = 0 //检查费
  1155. var checkCostPartSelfTotal float64 = 0 //检查费
  1156. var laboratoryCostTotal float64 = 0 //化验费
  1157. var laboratoryCostSelfTotal float64 = 0 //化验费
  1158. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1159. var treatCostTotal float64 = 0 //治疗费用
  1160. var treatCostSelfTotal float64 = 0 //治疗费用
  1161. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1162. decimal.DivisionPrecision = 2
  1163. var bed_fulamt_ownpay_amt float64 = 0
  1164. var operation_fulamt_ownpay_amt float64 = 0
  1165. var other_fulamt_ownpay_amt float64 = 0
  1166. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1167. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1168. var check_fulamt_ownpay_amt float64 = 0
  1169. var material_fulamt_ownpay_amt float64 = 0
  1170. var laboratory_fulamt_ownpay_amt float64 = 0
  1171. var treat_fulamt_ownpay_amt float64 = 0
  1172. var bed_claa_sunmfee float64 = 0
  1173. var bed_clab_amt float64 = 0
  1174. var bed_other_amt float64 = 0
  1175. var operation_claa_sunmfee float64 = 0
  1176. var operation_clab_amt float64 = 0
  1177. var operation_other_amt float64 = 0
  1178. var other_claa_sunmfee float64 = 0
  1179. var other_clab_amt float64 = 0
  1180. var other_other_amt float64 = 0
  1181. var westernMedicine_claa_sunmfee float64 = 0
  1182. var westernMedicine_clab_amt float64 = 0
  1183. var westernMedicine_other_amt float64 = 0
  1184. var chineseTraditional_claa_sunmfee float64 = 0
  1185. var chineseTraditional_clab_amt float64 = 0
  1186. var chineseTraditional_other_amt float64 = 0
  1187. var check_claa_sunmfee float64 = 0
  1188. var check_clab_amt float64 = 0
  1189. var check_other_amt float64 = 0
  1190. var material_claa_sunmfee float64 = 0
  1191. var material_clab_amt float64 = 0
  1192. var material_other_amt float64 = 0
  1193. var laboratory_claa_sunmfee float64 = 0
  1194. var laboratory_clab_amt float64 = 0
  1195. var laboratory_other_amt float64 = 0
  1196. var treat_claa_sunmfee float64 = 0
  1197. var treat_clab_amt float64 = 0
  1198. var treat_other_amt float64 = 0
  1199. for _, item := range order.HisOrderInfo {
  1200. if item.MedChrgitmType == "01" { //床位费
  1201. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1202. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1203. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1204. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1205. if item.ChrgitmLv == "1" {
  1206. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1207. }
  1208. if item.ChrgitmLv == "2" {
  1209. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1210. }
  1211. if item.ChrgitmLv == "3" {
  1212. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1213. }
  1214. }
  1215. if item.MedChrgitmType == "03" { //检查费
  1216. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1217. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1218. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1219. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1220. if item.ChrgitmLv == "1" {
  1221. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1222. }
  1223. if item.ChrgitmLv == "2" {
  1224. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "3" {
  1227. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1228. }
  1229. }
  1230. if item.MedChrgitmType == "04" { //化验费
  1231. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1232. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1234. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1235. if item.ChrgitmLv == "1" {
  1236. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. }
  1238. if item.ChrgitmLv == "2" {
  1239. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "3" {
  1242. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1243. }
  1244. }
  1245. if item.MedChrgitmType == "05" { //治疗费
  1246. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1247. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1249. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1250. if item.ChrgitmLv == "1" {
  1251. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. }
  1253. if item.ChrgitmLv == "2" {
  1254. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "3" {
  1257. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1258. }
  1259. }
  1260. if item.MedChrgitmType == "06" { //手术费
  1261. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1262. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1264. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1265. if item.ChrgitmLv == "1" {
  1266. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. }
  1268. if item.ChrgitmLv == "2" {
  1269. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "3" {
  1272. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1273. }
  1274. }
  1275. if item.MedChrgitmType == "08" { //材料费
  1276. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1277. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1279. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1280. if item.ChrgitmLv == "1" {
  1281. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. }
  1283. if item.ChrgitmLv == "2" {
  1284. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "3" {
  1287. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1288. }
  1289. }
  1290. if item.MedChrgitmType == "09" { //西药费
  1291. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1292. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1294. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1295. if item.ChrgitmLv == "1" {
  1296. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. }
  1298. if item.ChrgitmLv == "2" {
  1299. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "3" {
  1302. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1303. }
  1304. }
  1305. if item.MedChrgitmType == "11" { //中成费
  1306. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1307. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1309. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1310. if item.ChrgitmLv == "1" {
  1311. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. }
  1313. if item.ChrgitmLv == "2" {
  1314. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "3" {
  1317. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1318. }
  1319. }
  1320. if item.MedChrgitmType == "14" { //其他费
  1321. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1322. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1323. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1324. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1325. if item.ChrgitmLv == "1" {
  1326. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1327. }
  1328. if item.ChrgitmLv == "2" {
  1329. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1330. }
  1331. if item.ChrgitmLv == "3" {
  1332. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1333. }
  1334. }
  1335. }
  1336. var iteminfoStructs []service.IteminfoStruct
  1337. if bedCostTotal != 0 {
  1338. iteminfo.MedChrgitm = "01"
  1339. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1340. iteminfo.Amt = bedCostTotal
  1341. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1342. iteminfo.ClabAmt = bed_clab_amt
  1343. iteminfo.OthAmt = bed_other_amt
  1344. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1345. }
  1346. if checkCostTotal != 0 {
  1347. iteminfo.MedChrgitm = "03"
  1348. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1349. iteminfo.Amt = checkCostTotal
  1350. iteminfo.ClaaSumfee = check_claa_sunmfee
  1351. iteminfo.ClabAmt = check_clab_amt
  1352. iteminfo.OthAmt = check_other_amt
  1353. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1354. }
  1355. if laboratoryCostTotal != 0 {
  1356. iteminfo.MedChrgitm = "04"
  1357. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1358. iteminfo.Amt = laboratoryCostTotal
  1359. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1360. iteminfo.ClabAmt = laboratory_clab_amt
  1361. iteminfo.OthAmt = laboratory_other_amt
  1362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1363. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1364. }
  1365. if treatCostTotal != 0 {
  1366. iteminfo.MedChrgitm = "05"
  1367. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1368. iteminfo.Amt = treatCostTotal
  1369. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1370. iteminfo.ClabAmt = treat_clab_amt
  1371. iteminfo.OthAmt = treat_other_amt
  1372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1373. //(struct4101.IteminfoStruct, iteminfo)
  1374. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1375. }
  1376. if operationCostTotal != 0 {
  1377. iteminfo.MedChrgitm = "06"
  1378. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1379. iteminfo.Amt = operationCostTotal
  1380. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1381. iteminfo.ClabAmt = operation_clab_amt
  1382. iteminfo.OthAmt = operation_other_amt
  1383. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1384. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1385. }
  1386. if materialCostTotal != 0 {
  1387. iteminfo.MedChrgitm = "08"
  1388. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1389. iteminfo.Amt = materialCostTotal
  1390. iteminfo.ClaaSumfee = material_claa_sunmfee
  1391. iteminfo.ClabAmt = material_clab_amt
  1392. iteminfo.OthAmt = material_other_amt
  1393. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1394. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1395. }
  1396. if westernMedicineCostTotal != 0 {
  1397. iteminfo.MedChrgitm = "09"
  1398. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1399. iteminfo.Amt = westernMedicineCostTotal
  1400. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1401. iteminfo.ClabAmt = westernMedicine_clab_amt
  1402. iteminfo.OthAmt = westernMedicine_other_amt
  1403. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1404. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1405. }
  1406. if chineseTraditionalMedicineCostTotal != 0 {
  1407. iteminfo.MedChrgitm = "11"
  1408. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1409. iteminfo.Amt = westernMedicineCostTotal
  1410. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1411. iteminfo.ClabAmt = westernMedicine_clab_amt
  1412. iteminfo.OthAmt = westernMedicine_other_amt
  1413. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1414. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1415. }
  1416. if otherCostTotal != 0 {
  1417. iteminfo.MedChrgitm = "14"
  1418. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1419. iteminfo.Amt = otherCostTotal
  1420. iteminfo.ClaaSumfee = other_claa_sunmfee
  1421. iteminfo.ClabAmt = other_clab_amt
  1422. iteminfo.OthAmt = other_other_amt
  1423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1424. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1425. }
  1426. struct4101.IteminfoStruct = iteminfoStructs
  1427. struct4101.Ntly = "中国"
  1428. struct4101.AdmCaty = "A03.06"
  1429. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1430. fmt.Println(result)
  1431. var dat map[string]interface{}
  1432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1433. fmt.Println(dat)
  1434. } else {
  1435. fmt.Println(err)
  1436. }
  1437. userJSONBytes, _ := json.Marshal(dat)
  1438. var res ResultSeventeen
  1439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1440. utils.ErrorLog("解析失败:%v", err)
  1441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1442. return
  1443. }
  1444. if res.Infcode != 0 {
  1445. c.ServeSuccessJSON(map[string]interface{}{
  1446. "failed_code": -10,
  1447. "msg": res.ErrMsg,
  1448. })
  1449. return
  1450. } else {
  1451. order.FaPiaoNumber = zero
  1452. order.FaPiaoCode = last_order.FaPiaoCode
  1453. service.UpdateOrder(order)
  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. c.ServeSuccessJSON(map[string]interface{}{
  1465. "msg": "上传成功",
  1466. "result": hisFundSettleListResult,
  1467. })
  1468. return
  1469. }
  1470. }
  1471. func (c *HisApiController) GetBatchSettleList() {
  1472. org_id, _ := beego.AppConfig.Int64("org_id")
  1473. //stage, _ := c.GetInt64("stage")
  1474. orders, _ := service.GetAllHisOrder(org_id)
  1475. for _, item := range orders {
  1476. order_id := item.ID
  1477. order, _ := service.GetHisOrderByIDTwo(order_id)
  1478. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1479. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1480. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1481. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  1482. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1483. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1484. if order.ID == 0 {
  1485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1486. return
  1487. }
  1488. if his.BalanceAccountsType == 2 {
  1489. continue
  1490. }
  1491. struct4101 := service.Struct4101{
  1492. PsnNo: order.PsnNo,
  1493. MdtrtId: order.MdtrtId,
  1494. SetlId: order.SetlId,
  1495. PsnName: order.PsnName,
  1496. Gend: order.Gend,
  1497. Brdy: his.Brdy,
  1498. Age: his.Age,
  1499. Naty: order.Naty,
  1500. PatnCertType: "01",
  1501. Certno: order.Certno,
  1502. Prfs: "90",
  1503. ConerName: roles[0].UserName,
  1504. PatnRlts: "99",
  1505. ConerAddr: miConfig.OrgName,
  1506. ConerTel: admin.Mobile,
  1507. HiType: order.Insutype,
  1508. Insuplc: his.InsuplcAdmdvs,
  1509. MaindiagFlag: "1",
  1510. BillCode: order.FaPiaoCode,
  1511. BillNo: order.FaPiaoNumber,
  1512. BizSn: order.Number,
  1513. PsnSelfPay: order.PsnPartAmt,
  1514. PsnOwnPay: order.PsnPartAmt,
  1515. AcctPay: order.AcctPay,
  1516. PsnCashpay: order.PsnCashPay,
  1517. HiPaymtd: "1",
  1518. Hsorg: his.InsuplcAdmdvs,
  1519. HsorgOpter: his.InsuplcAdmdvs,
  1520. MedinsFillPsn: curRoles.UserName,
  1521. MedinsFillDept: depart.Name,
  1522. IptMedType: "2",
  1523. }
  1524. struct4101.SetlBegnDate = order.SetlTime
  1525. struct4101.SetlEndDate = order.SetlTime
  1526. //if order.SettleType == 1 {
  1527. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1528. // dateStr := t.Format("2006-01-02")
  1529. // struct4101.SetlBegnDate = dateStr
  1530. // struct4101.SetlEndDate = dateStr
  1531. //} else {
  1532. // t := time.Unix(int64(order.SettleStartTime), 0)
  1533. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1534. // dateStartStr := t.Format("2006-01-02")
  1535. // dateEndStr := t2.Format("2006-01-02")
  1536. // struct4101.SetlBegnDate = dateStartStr
  1537. // struct4101.SetlEndDate = dateEndStr
  1538. //}
  1539. var rf []CustomFundPay
  1540. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1541. var tempFunPays []service.CustomStruct
  1542. var tempFunPay610100 service.CustomStruct
  1543. for _, item := range rf {
  1544. if item.FundPayType == "610100" {
  1545. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1546. tempFunPay610100.FundPayType = item.FundPayType
  1547. } else {
  1548. var tempFunPay service.CustomStruct
  1549. tempFunPay.FundPayamt = item.FundPayamt
  1550. tempFunPay.FundPayType = item.FundPayType
  1551. tempFunPays = append(tempFunPays, tempFunPay)
  1552. }
  1553. }
  1554. tempFunPays = append(tempFunPays, tempFunPay610100)
  1555. struct4101.CustomStruct = tempFunPays
  1556. var tempDiaginfos []service.DiaginfoStructTwo
  1557. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1558. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1559. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1560. var config []*models.HisXtDiagnoseConfig
  1561. for _, item := range diagnosis_ids {
  1562. id, _ := strconv.ParseInt(item, 10, 64)
  1563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1564. config = append(config, &diagnosisConfig)
  1565. }
  1566. for index, item := range config {
  1567. if index == 0 {
  1568. var tempDiaginfo service.DiaginfoStructTwo
  1569. tempDiaginfo.DiagCode = item.CountryCode
  1570. tempDiaginfo.DiagName = item.CountryContentName
  1571. tempDiaginfo.DiagType = "1"
  1572. tempDiaginfo.MaindiagFlag = "1"
  1573. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1574. } else {
  1575. var tempDiaginfo service.DiaginfoStructTwo
  1576. tempDiaginfo.DiagCode = item.CountryCode
  1577. tempDiaginfo.DiagName = item.CountryContentName
  1578. tempDiaginfo.DiagType = "2"
  1579. tempDiaginfo.MaindiagFlag = "0"
  1580. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1581. }
  1582. }
  1583. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1584. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1585. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1586. tempOpspdiseinfo2.OprnOprtCode = ""
  1587. tempOpspdiseinfo2.OprnOprtName = ""
  1588. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1589. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1590. var iteminfo service.IteminfoStruct
  1591. var bedCostTotal float64 = 0 //床位总费
  1592. var bedCostSelfTotal float64 = 0 //床位自费
  1593. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1594. var examineCostTotal float64 = 0 //诊查总费
  1595. var examineCostSelfTotal float64 = 0 //诊查自费
  1596. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1597. var nursingCostTotal float64 = 0 //护理总费
  1598. var nursingCostSelfTotal float64 = 0 //护理自费
  1599. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1600. var chineseMedicineCostTotal float64 = 0 //中成药
  1601. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1602. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1603. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1604. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1605. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1606. var registerCostTotal float64 = 0 //一般诊疗费
  1607. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1608. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1609. var operationCostTotal float64 = 0 //手术费
  1610. var operationCostSelfTotal float64 = 0 //手术费
  1611. var operationCostPartSelfTotal float64 = 0 //手术费
  1612. var otherCostTotal float64 = 0 //其他费用
  1613. var otherCostSelfTotal float64 = 0 //其他费用
  1614. var otherCostPartSelfTotal float64 = 0 //其他费用
  1615. var materialCostTotal float64 = 0 //材料费
  1616. var materialCostSelfTotal float64 = 0 //材料费
  1617. var materialCostPartSelfTotal float64 = 0 //材料费
  1618. var westernMedicineCostTotal float64 = 0 //西药费
  1619. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1620. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1621. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1622. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1623. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1624. var checkCostTotal float64 = 0 //检查费
  1625. var checkCostSelfTotal float64 = 0 //检查费
  1626. var checkCostPartSelfTotal float64 = 0 //检查费
  1627. var laboratoryCostTotal float64 = 0 //化验费
  1628. var laboratoryCostSelfTotal float64 = 0 //化验费
  1629. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1630. var treatCostTotal float64 = 0 //治疗费用
  1631. var treatCostSelfTotal float64 = 0 //治疗费用
  1632. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1633. decimal.DivisionPrecision = 2
  1634. var bed_fulamt_ownpay_amt float64 = 0
  1635. var examine_fulamt_ownpay_amt float64 = 0
  1636. var nursing_fulamt_ownpay_amt float64 = 0
  1637. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1638. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1639. var register_fulamt_ownpay_amt float64 = 0
  1640. var operation_fulamt_ownpay_amt float64 = 0
  1641. var other_fulamt_ownpay_amt float64 = 0
  1642. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1643. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1644. var check_fulamt_ownpay_amt float64 = 0
  1645. var material_fulamt_ownpay_amt float64 = 0
  1646. var laboratory_fulamt_ownpay_amt float64 = 0
  1647. var treat_fulamt_ownpay_amt float64 = 0
  1648. var bed_claa_sunmfee float64 = 0
  1649. var bed_clab_amt float64 = 0
  1650. var bed_other_amt float64 = 0
  1651. var examine_claa_sunmfee float64 = 0
  1652. var examine_clab_amt float64 = 0
  1653. var examine_other_amt float64 = 0
  1654. var nursing_claa_sunmfee float64 = 0
  1655. var nursing_clab_amt float64 = 0
  1656. var nursing_other_amt float64 = 0
  1657. var chinese_medicine_claa_sunmfee float64 = 0
  1658. var chinese_medicine_clab_amt float64 = 0
  1659. var chinese_medicine_other_amt float64 = 0
  1660. var commonly_treatment_claa_sunmfee float64 = 0
  1661. var commonly_treatment_clab_amt float64 = 0
  1662. var commonly_treatment_other_amt float64 = 0
  1663. var operation_claa_sunmfee float64 = 0
  1664. var operation_clab_amt float64 = 0
  1665. var operation_other_amt float64 = 0
  1666. var other_claa_sunmfee float64 = 0
  1667. var other_clab_amt float64 = 0
  1668. var other_other_amt float64 = 0
  1669. var westernMedicine_claa_sunmfee float64 = 0
  1670. var westernMedicine_clab_amt float64 = 0
  1671. var westernMedicine_other_amt float64 = 0
  1672. var chineseTraditional_claa_sunmfee float64 = 0
  1673. var chineseTraditional_clab_amt float64 = 0
  1674. var chineseTraditional_other_amt float64 = 0
  1675. var check_claa_sunmfee float64 = 0
  1676. var check_clab_amt float64 = 0
  1677. var check_other_amt float64 = 0
  1678. var material_claa_sunmfee float64 = 0
  1679. var material_clab_amt float64 = 0
  1680. var material_other_amt float64 = 0
  1681. var laboratory_claa_sunmfee float64 = 0
  1682. var laboratory_clab_amt float64 = 0
  1683. var laboratory_other_amt float64 = 0
  1684. var treat_claa_sunmfee float64 = 0
  1685. var treat_clab_amt float64 = 0
  1686. var treat_other_amt float64 = 0
  1687. var register_claa_sunmfee float64 = 0
  1688. var register_clab_amt float64 = 0
  1689. var register_other_amt float64 = 0
  1690. for _, item := range order.HisOrderInfo {
  1691. if item.MedChrgitmType == "01" { //床位费
  1692. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1693. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1694. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1695. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1696. if item.ChrgitmLv == "1" {
  1697. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1698. }
  1699. if item.ChrgitmLv == "2" {
  1700. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1701. }
  1702. if item.ChrgitmLv == "3" {
  1703. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1704. }
  1705. }
  1706. if item.MedChrgitmType == "02" { //诊查
  1707. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1708. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1709. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1710. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1711. if item.ChrgitmLv == "1" {
  1712. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1713. }
  1714. if item.ChrgitmLv == "2" {
  1715. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1716. }
  1717. if item.ChrgitmLv == "3" {
  1718. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1719. }
  1720. }
  1721. if item.MedChrgitmType == "03" { //检查费
  1722. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1723. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1724. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1725. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1726. if item.ChrgitmLv == "1" {
  1727. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1728. }
  1729. if item.ChrgitmLv == "2" {
  1730. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1731. }
  1732. if item.ChrgitmLv == "3" {
  1733. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1734. }
  1735. }
  1736. if item.MedChrgitmType == "04" { //化验费
  1737. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1738. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1739. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1740. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1741. if item.ChrgitmLv == "1" {
  1742. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1743. }
  1744. if item.ChrgitmLv == "2" {
  1745. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1746. }
  1747. if item.ChrgitmLv == "3" {
  1748. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1749. }
  1750. }
  1751. if item.MedChrgitmType == "05" { //治疗费
  1752. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1753. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1754. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1755. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1756. if item.ChrgitmLv == "1" {
  1757. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1758. }
  1759. if item.ChrgitmLv == "2" {
  1760. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1761. }
  1762. if item.ChrgitmLv == "3" {
  1763. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1764. }
  1765. }
  1766. if item.MedChrgitmType == "06" { //手术费
  1767. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1768. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1769. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1770. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1771. if item.ChrgitmLv == "1" {
  1772. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1773. }
  1774. if item.ChrgitmLv == "2" {
  1775. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1776. }
  1777. if item.ChrgitmLv == "3" {
  1778. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1779. }
  1780. }
  1781. if item.MedChrgitmType == "07" { //手术费
  1782. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1783. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1784. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1785. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1786. if item.ChrgitmLv == "1" {
  1787. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1788. }
  1789. if item.ChrgitmLv == "2" {
  1790. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1791. }
  1792. if item.ChrgitmLv == "3" {
  1793. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1794. }
  1795. }
  1796. if item.MedChrgitmType == "08" { //材料费
  1797. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1798. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1799. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1800. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1801. if item.ChrgitmLv == "1" {
  1802. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1803. }
  1804. if item.ChrgitmLv == "2" {
  1805. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1806. }
  1807. if item.ChrgitmLv == "3" {
  1808. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1809. }
  1810. }
  1811. if item.MedChrgitmType == "09" { //西药费
  1812. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1813. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1814. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1815. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1816. if item.ChrgitmLv == "1" {
  1817. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1818. }
  1819. if item.ChrgitmLv == "2" {
  1820. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1821. }
  1822. if item.ChrgitmLv == "3" {
  1823. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1824. }
  1825. }
  1826. if item.MedChrgitmType == "10" { //中药饮片
  1827. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1828. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1829. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1830. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1831. if item.ChrgitmLv == "1" {
  1832. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1833. }
  1834. if item.ChrgitmLv == "2" {
  1835. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1836. }
  1837. if item.ChrgitmLv == "3" {
  1838. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1839. }
  1840. }
  1841. if item.MedChrgitmType == "11" { //中成费
  1842. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1843. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1844. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1845. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1846. if item.ChrgitmLv == "1" {
  1847. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1848. }
  1849. if item.ChrgitmLv == "2" {
  1850. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1851. }
  1852. if item.ChrgitmLv == "3" {
  1853. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1854. }
  1855. }
  1856. if item.MedChrgitmType == "12" { //中成费
  1857. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1858. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1859. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1860. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1861. if item.ChrgitmLv == "1" {
  1862. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1863. }
  1864. if item.ChrgitmLv == "2" {
  1865. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1866. }
  1867. if item.ChrgitmLv == "3" {
  1868. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1869. }
  1870. }
  1871. if item.MedChrgitmType == "13" { //中成费
  1872. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1873. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1874. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1875. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1876. if item.ChrgitmLv == "1" {
  1877. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1878. }
  1879. if item.ChrgitmLv == "2" {
  1880. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1881. }
  1882. if item.ChrgitmLv == "3" {
  1883. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1884. }
  1885. }
  1886. if item.MedChrgitmType == "14" { //其他费
  1887. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1888. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1889. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1890. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1891. if item.ChrgitmLv == "1" {
  1892. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1893. }
  1894. if item.ChrgitmLv == "2" {
  1895. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1896. }
  1897. if item.ChrgitmLv == "3" {
  1898. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1899. }
  1900. }
  1901. }
  1902. var iteminfoStructs []service.IteminfoStruct
  1903. if bedCostTotal != 0 {
  1904. iteminfo.MedChrgitm = "01"
  1905. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1906. iteminfo.Amt = bedCostTotal
  1907. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1908. iteminfo.ClabAmt = bed_clab_amt
  1909. iteminfo.OthAmt = bed_other_amt
  1910. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1911. }
  1912. if examineCostTotal != 0 {
  1913. iteminfo.MedChrgitm = "02"
  1914. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1915. iteminfo.Amt = examineCostTotal
  1916. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1917. iteminfo.ClabAmt = examine_clab_amt
  1918. iteminfo.OthAmt = examine_other_amt
  1919. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1920. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1921. }
  1922. if checkCostTotal != 0 {
  1923. iteminfo.MedChrgitm = "03"
  1924. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1925. iteminfo.Amt = checkCostTotal
  1926. iteminfo.ClaaSumfee = check_claa_sunmfee
  1927. iteminfo.ClabAmt = check_clab_amt
  1928. iteminfo.OthAmt = check_other_amt
  1929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1930. }
  1931. if laboratoryCostTotal != 0 {
  1932. iteminfo.MedChrgitm = "04"
  1933. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1934. iteminfo.Amt = laboratoryCostTotal
  1935. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1936. iteminfo.ClabAmt = laboratory_clab_amt
  1937. iteminfo.OthAmt = laboratory_other_amt
  1938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1939. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1940. }
  1941. if treatCostTotal != 0 {
  1942. iteminfo.MedChrgitm = "05"
  1943. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1944. iteminfo.Amt = treatCostTotal
  1945. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1946. iteminfo.ClabAmt = treat_clab_amt
  1947. iteminfo.OthAmt = treat_other_amt
  1948. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1949. //(struct4101.IteminfoStruct, iteminfo)
  1950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1951. }
  1952. if operationCostTotal != 0 {
  1953. iteminfo.MedChrgitm = "06"
  1954. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1955. iteminfo.Amt = operationCostTotal
  1956. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1957. iteminfo.ClabAmt = operation_clab_amt
  1958. iteminfo.OthAmt = operation_other_amt
  1959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1961. }
  1962. if nursingCostTotal != 0 {
  1963. iteminfo.MedChrgitm = "07"
  1964. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1965. iteminfo.Amt = nursingCostTotal
  1966. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1967. iteminfo.ClabAmt = nursing_clab_amt
  1968. iteminfo.OthAmt = nursing_other_amt
  1969. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1970. }
  1971. if materialCostTotal != 0 {
  1972. iteminfo.MedChrgitm = "08"
  1973. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1974. iteminfo.Amt = materialCostTotal
  1975. iteminfo.ClaaSumfee = material_claa_sunmfee
  1976. iteminfo.ClabAmt = material_clab_amt
  1977. iteminfo.OthAmt = material_other_amt
  1978. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1979. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1980. }
  1981. if westernMedicineCostTotal != 0 {
  1982. iteminfo.MedChrgitm = "09"
  1983. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1984. iteminfo.Amt = westernMedicineCostTotal
  1985. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1986. iteminfo.ClabAmt = westernMedicine_clab_amt
  1987. iteminfo.OthAmt = westernMedicine_other_amt
  1988. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1989. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1990. }
  1991. if chineseMedicineCostTotal != 0 {
  1992. iteminfo.MedChrgitm = "10"
  1993. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1994. iteminfo.Amt = chineseMedicineCostTotal
  1995. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1996. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1997. iteminfo.OthAmt = chinese_medicine_other_amt
  1998. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1999. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2000. }
  2001. if chineseTraditionalMedicineCostTotal != 0 {
  2002. iteminfo.MedChrgitm = "11"
  2003. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2004. iteminfo.Amt = westernMedicineCostTotal
  2005. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2006. iteminfo.ClabAmt = westernMedicine_clab_amt
  2007. iteminfo.OthAmt = westernMedicine_other_amt
  2008. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2009. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2010. }
  2011. if commonlyTreatmentCostTotal != 0 {
  2012. iteminfo.MedChrgitm = "12"
  2013. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2014. iteminfo.Amt = commonlyTreatmentCostTotal
  2015. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2016. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2017. iteminfo.OthAmt = commonly_treatment_other_amt
  2018. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2019. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2020. }
  2021. if registerCostTotal != 0 {
  2022. iteminfo.MedChrgitm = "13"
  2023. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2024. iteminfo.Amt = registerCostTotal
  2025. iteminfo.ClaaSumfee = register_claa_sunmfee
  2026. iteminfo.ClabAmt = register_clab_amt
  2027. iteminfo.OthAmt = register_other_amt
  2028. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2029. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2030. }
  2031. if otherCostTotal != 0 {
  2032. iteminfo.MedChrgitm = "14"
  2033. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2034. iteminfo.Amt = otherCostTotal
  2035. iteminfo.ClaaSumfee = other_claa_sunmfee
  2036. iteminfo.ClabAmt = other_clab_amt
  2037. iteminfo.OthAmt = other_other_amt
  2038. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2039. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2040. }
  2041. struct4101.IteminfoStruct = iteminfoStructs
  2042. struct4101.Ntly = "中国"
  2043. struct4101.AdmCaty = "A03.06"
  2044. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2045. fmt.Println(result)
  2046. var dat map[string]interface{}
  2047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2048. fmt.Println(dat)
  2049. } else {
  2050. fmt.Println(err)
  2051. }
  2052. userJSONBytes, _ := json.Marshal(dat)
  2053. var res ResultSeventeen
  2054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2055. utils.ErrorLog("解析失败:%v", err)
  2056. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2057. adminUser := c.GetAdminUserInfo()
  2058. errlog := &models.HisOrderError{
  2059. UserOrgId: adminUser.CurrentOrgId,
  2060. Ctime: time.Now().Unix(),
  2061. Mtime: time.Now().Unix(),
  2062. ErrMsg: res.ErrMsg + "解析失败",
  2063. Status: 1,
  2064. PatientId: order_id,
  2065. Stage: 1000,
  2066. }
  2067. service.CreateErrMsgLog(errlog)
  2068. continue
  2069. }
  2070. if res.Infcode != 0 {
  2071. adminUser := c.GetAdminUserInfo()
  2072. errlog := &models.HisOrderError{
  2073. UserOrgId: adminUser.CurrentOrgId,
  2074. Ctime: time.Now().Unix(),
  2075. Mtime: time.Now().Unix(),
  2076. ErrMsg: res.ErrMsg,
  2077. Status: 1,
  2078. PatientId: order_id,
  2079. Stage: 1000,
  2080. }
  2081. service.CreateErrMsgLog(errlog)
  2082. continue
  2083. } else {
  2084. hisFundSettleListResult := &models.HisFundSettleListResult{
  2085. Number: res.Output.SetlListId,
  2086. Status: 1,
  2087. Ctime: time.Now().Unix(),
  2088. Mtime: time.Now().Unix(),
  2089. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2090. IsUpload: 1,
  2091. OrderId: order_id,
  2092. }
  2093. service.CreateUploadRecord(hisFundSettleListResult)
  2094. continue
  2095. }
  2096. }
  2097. }
  2098. func (c *HisApiController) GetOrgInfo() {
  2099. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2100. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2101. }
  2102. func (c *HisApiController) GetHisPatientInfo() {
  2103. medical_insurance_card := c.GetString("medical_insurance_card")
  2104. id_card_type, _ := c.GetInt64("id_card_type")
  2105. id_card := c.GetString("id_card")
  2106. adminInfo := c.GetAdminUserInfo()
  2107. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2108. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2109. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2110. IdCardNo := ""
  2111. if id_card_type == 1 {
  2112. IdCardNo = medical_insurance_card
  2113. } else if id_card_type == 2 {
  2114. IdCardNo = id_card
  2115. }
  2116. if config.IsOpen == 1 {
  2117. 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
  2118. resp, requestErr := http.Get(api)
  2119. if requestErr != nil {
  2120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2121. return
  2122. }
  2123. defer resp.Body.Close()
  2124. body, ioErr := ioutil.ReadAll(resp.Body)
  2125. if ioErr != nil {
  2126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2128. return
  2129. }
  2130. var respJSON map[string]interface{}
  2131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. return
  2135. }
  2136. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. userJSONBytes, _ := json.Marshal(userJSON)
  2138. var res ResultTwo
  2139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2140. utils.ErrorLog("解析失败:%v", err)
  2141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2142. return
  2143. }
  2144. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2145. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2146. infoStr := string(Iinfos)
  2147. idetinfoStr := string(Idetinfos)
  2148. if res.Infcode == 0 {
  2149. his := models.VMHisPatient{
  2150. Status: 1,
  2151. Ctime: time.Now().Unix(),
  2152. Mtime: time.Now().Unix(),
  2153. PsnNo: res.Output.Baseinfo.PsnNo,
  2154. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2155. Certno: res.Output.Baseinfo.Certno,
  2156. PsnName: res.Output.Baseinfo.PsnName,
  2157. Gend: res.Output.Baseinfo.Gend,
  2158. Naty: res.Output.Baseinfo.Naty,
  2159. Brdy: res.Output.Baseinfo.Brdy,
  2160. Age: res.Output.Baseinfo.Age,
  2161. Iinfo: infoStr,
  2162. Idetinfo: idetinfoStr,
  2163. UserOrgId: adminInfo.CurrentOrgId,
  2164. IsReturn: 1,
  2165. IdCardType: id_card_type,
  2166. }
  2167. c.ServeSuccessJSON(map[string]interface{}{
  2168. "info": his,
  2169. })
  2170. } else {
  2171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2172. return
  2173. }
  2174. }
  2175. }
  2176. //func GetBasBaseInfo() (jsonStr string, err error) {
  2177. //
  2178. // handle := syscall.NewLazyDLL("SSCard.dll")
  2179. // add := handle.NewProc("ReadCardBas")
  2180. // str := make([]byte, 1024)
  2181. // str1 := make([]byte, 1024)
  2182. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2183. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2184. //
  2185. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2186. //
  2187. // fmt.Println("> Add(4,5)的结果为:", ret)
  2188. // handle.Release()
  2189. //
  2190. // return "", nil
  2191. //
  2192. //}
  2193. //func GetQRBaseInfo() (jsonStr string, err error) {
  2194. // handle := syscall.LoadDLL("SSCard.dll")
  2195. // ReadCardBas := handle.FindProc("GetQRBase")
  2196. //
  2197. // str := make([]byte, 256)
  2198. // str1 := make([]byte, 256)
  2199. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2200. //
  2201. // fmt.Println(string(str))
  2202. // fmt.Println(r)
  2203. // return string(str), nil
  2204. //}
  2205. //func CardInit() int {
  2206. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2207. // add := DllTestDef.MustFindProc("Init")
  2208. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2209. // if err != nil {
  2210. // fmt.Println("SSCard的运算结果为:", ret)
  2211. // }
  2212. // result := int(ret)
  2213. // return result
  2214. //}
  2215. //func CardInit() int {
  2216. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2217. // if err != nil {
  2218. // fmt.Println("SSCard的运算结果为:", ret)
  2219. // }
  2220. // fmt.Println(err)
  2221. // result := int(ret)
  2222. // return result
  2223. //}
  2224. func IntPtr(n int) uintptr {
  2225. return uintptr(n)
  2226. }
  2227. func StrPtr(s string) uintptr {
  2228. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2229. }
  2230. type Result2001 struct {
  2231. Cainfo interface{} `json:"cainfo"`
  2232. ErrMsg string `json:"err_msg"`
  2233. InfRefmsgid string `json:"inf_refmsgid"`
  2234. Infcode int64 `json:"infcode"`
  2235. Output struct {
  2236. Trtinfo struct {
  2237. PsnNo string `json:"psn_no"`
  2238. TrtChkType string `json:"trt_chk_type"`
  2239. FundPayType string `json:"fund_pay_type"`
  2240. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2241. Begndate string `json:"begndate"`
  2242. Enddate string `json:"enddate"`
  2243. TrtChkRslt string `json:"trt_chk_rslt"`
  2244. } `json:"trtinfo"`
  2245. } `json:"output"`
  2246. RefmsgTime string `json:"refmsg_time"`
  2247. RespondTime string `json:"respond_time"`
  2248. Signtype interface{} `json:"signtype"`
  2249. WarnMsg interface{} `json:"warn_msg"`
  2250. }
  2251. type Result2001Org10265 struct {
  2252. Cainfo interface{} `json:"cainfo"`
  2253. ErrMsg string `json:"err_msg"`
  2254. InfRefmsgid string `json:"inf_refmsgid"`
  2255. Infcode string `json:"infcode"`
  2256. Output struct {
  2257. Trtinfo struct {
  2258. PsnNo string `json:"psn_no"`
  2259. TrtChkType string `json:"trt_chk_type"`
  2260. FundPayType string `json:"fund_pay_type"`
  2261. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2262. Begndate string `json:"begndate"`
  2263. Enddate string `json:"enddate"`
  2264. TrtChkRslt string `json:"trt_chk_rslt"`
  2265. } `json:"trtinfo"`
  2266. } `json:"output"`
  2267. RefmsgTime string `json:"refmsg_time"`
  2268. RespondTime string `json:"respond_time"`
  2269. Signtype interface{} `json:"signtype"`
  2270. WarnMsg interface{} `json:"warn_msg"`
  2271. }
  2272. type ResultTwo struct {
  2273. ErrMsg string `json:"err_msg"`
  2274. InfRefmsgid string `json:"inf_refmsgid"`
  2275. Infcode int64 `json:"infcode"`
  2276. Output struct {
  2277. Baseinfo struct {
  2278. Age float64 `json:"age"`
  2279. Brdy string `json:"brdy"`
  2280. Certno string `json:"certno"`
  2281. Gend string `json:"gend"`
  2282. Naty string `json:"naty"`
  2283. PsnCertType string `json:"psn_cert_type"`
  2284. PsnName string `json:"psn_name"`
  2285. PsnNo string `json:"psn_no"`
  2286. } `json:"baseinfo"`
  2287. Idetinfo []interface{} `json:"idetinfo"`
  2288. Iinfo []struct {
  2289. Balc float64 `json:"balc"`
  2290. CvlservFlag string `json:"cvlserv_flag"`
  2291. EmpName string `json:"emp_name"`
  2292. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2293. Insutype string `json:"insutype"`
  2294. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2295. PausInsuDate string `json:"paus_insu_date"`
  2296. PsnInsuDate string `json:"psn_insu_date"`
  2297. PsnInsuStas string `json:"psn_insu_stas"`
  2298. PsnType string `json:"psn_type"`
  2299. } `json:"insuinfo"`
  2300. } `json:"output"`
  2301. RefmsgTime string `json:"refmsg_time"`
  2302. RespondTime string `json:"respond_time"`
  2303. Signtype interface{} `json:"signtype"`
  2304. WarnInfo interface{} `json:"warn_info"`
  2305. }
  2306. type ResultTwo10265 struct {
  2307. ErrMsg string `json:"err_msg"`
  2308. InfRefmsgid string `json:"inf_refmsgid"`
  2309. Infcode string `json:"infcode"`
  2310. Output struct {
  2311. Baseinfo struct {
  2312. Age float64 `json:"age"`
  2313. Brdy string `json:"brdy"`
  2314. Certno string `json:"certno"`
  2315. Gend string `json:"gend"`
  2316. Naty string `json:"naty"`
  2317. PsnCertType string `json:"psn_cert_type"`
  2318. PsnName string `json:"psn_name"`
  2319. PsnNo string `json:"psn_no"`
  2320. } `json:"baseinfo"`
  2321. Idetinfo []interface{} `json:"idetinfo"`
  2322. Iinfo []struct {
  2323. Balc float64 `json:"balc"`
  2324. CvlservFlag string `json:"cvlserv_flag"`
  2325. EmpName string `json:"emp_name"`
  2326. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2327. Insutype string `json:"insutype"`
  2328. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2329. PausInsuDate string `json:"paus_insu_date"`
  2330. PsnInsuDate string `json:"psn_insu_date"`
  2331. PsnInsuStas string `json:"psn_insu_stas"`
  2332. PsnType string `json:"psn_type"`
  2333. } `json:"insuinfo"`
  2334. } `json:"output"`
  2335. RefmsgTime string `json:"refmsg_time"`
  2336. RespondTime string `json:"respond_time"`
  2337. Signtype interface{} `json:"signtype"`
  2338. WarnInfo interface{} `json:"warn_info"`
  2339. }
  2340. type ResultThree struct {
  2341. Cainfo interface{} `json:"cainfo"`
  2342. ErrMsg string `json:"err_msg"`
  2343. InfRefmsgid string `json:"inf_refmsgid"`
  2344. Infcode int64 `json:"infcode"`
  2345. Output struct {
  2346. Data struct {
  2347. IptOtpNo string `json:"ipt_otp_no"`
  2348. MdtrtID string `json:"mdtrt_id"`
  2349. PsnNo string `json:"psn_no"`
  2350. } `json:"data"`
  2351. } `json:"output"`
  2352. RefmsgTime string `json:"refmsg_time"`
  2353. RespondTime string `json:"respond_time"`
  2354. Signtype interface{} `json:"signtype"`
  2355. WarnMsg interface{} `json:"warn_msg"`
  2356. }
  2357. type ResultThree10265 struct {
  2358. Cainfo interface{} `json:"cainfo"`
  2359. ErrMsg string `json:"err_msg"`
  2360. InfRefmsgid string `json:"inf_refmsgid"`
  2361. Infcode string `json:"infcode"`
  2362. Output struct {
  2363. Data struct {
  2364. IptOtpNo string `json:"ipt_otp_no"`
  2365. MdtrtID string `json:"mdtrt_id"`
  2366. PsnNo string `json:"psn_no"`
  2367. } `json:"data"`
  2368. } `json:"output"`
  2369. RefmsgTime string `json:"refmsg_time"`
  2370. RespondTime string `json:"respond_time"`
  2371. Signtype interface{} `json:"signtype"`
  2372. WarnMsg interface{} `json:"warn_msg"`
  2373. }
  2374. type ResultFour struct {
  2375. Cainfo string `json:"cainfo"`
  2376. ErrMsg string `json:"err_msg"`
  2377. InfRefmsgid string `json:"inf_refmsgid"`
  2378. Infcode int64 `json:"infcode"`
  2379. Output struct {
  2380. Result []struct {
  2381. BasMednFlag string `json:"bas_medn_flag"`
  2382. ChldMedcFlag string `json:"chld_medc_flag"`
  2383. ChrgitmLv string `json:"chrgitm_lv"`
  2384. Cnt float64 `json:"cnt"`
  2385. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2386. DrtReimFlag string `json:"drt_reim_flag"`
  2387. FeedetlSn string `json:"feedetl_sn"`
  2388. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2389. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2390. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2391. ListSpItemFlag string `json:"list_sp_item_flag"`
  2392. LmtUsedFlag string `json:"lmt_used_flag"`
  2393. MedChrgitmType string `json:"med_chrgitm_type"`
  2394. Memo string `json:"memo"`
  2395. OverlmtAmt float64 `json:"overlmt_amt"`
  2396. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2397. Pric float64 `json:"pric"`
  2398. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2399. SelfpayProp float64 `json:"selfpay_prop"`
  2400. } `json:"result"`
  2401. } `json:"output"`
  2402. RefmsgTime string `json:"refmsg_time"`
  2403. RespondTime string `json:"respond_time"`
  2404. Signtype string `json:"signtype"`
  2405. WarnMsg string `json:"warn_msg"`
  2406. }
  2407. type ResultFour10265 struct {
  2408. Cainfo string `json:"cainfo"`
  2409. ErrMsg string `json:"err_msg"`
  2410. InfRefmsgid string `json:"inf_refmsgid"`
  2411. Infcode string `json:"infcode"`
  2412. Output struct {
  2413. Result []struct {
  2414. BasMednFlag string `json:"bas_medn_flag"`
  2415. ChldMedcFlag string `json:"chld_medc_flag"`
  2416. ChrgitmLv string `json:"chrgitm_lv"`
  2417. Cnt float64 `json:"cnt"`
  2418. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2419. DrtReimFlag string `json:"drt_reim_flag"`
  2420. FeedetlSn string `json:"feedetl_sn"`
  2421. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2422. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2423. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2424. ListSpItemFlag string `json:"list_sp_item_flag"`
  2425. LmtUsedFlag string `json:"lmt_used_flag"`
  2426. MedChrgitmType string `json:"med_chrgitm_type"`
  2427. Memo string `json:"memo"`
  2428. OverlmtAmt float64 `json:"overlmt_amt"`
  2429. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2430. Pric float64 `json:"pric"`
  2431. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2432. SelfpayProp float64 `json:"selfpay_prop"`
  2433. } `json:"result"`
  2434. } `json:"output"`
  2435. RefmsgTime string `json:"refmsg_time"`
  2436. RespondTime string `json:"respond_time"`
  2437. Signtype string `json:"signtype"`
  2438. WarnMsg string `json:"warn_msg"`
  2439. }
  2440. type ResultFive struct {
  2441. Balc float64 `json:"balc"`
  2442. CvlservFlag string `json:"cvlserv_flag"`
  2443. EmpName string `json:"emp_name"`
  2444. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2445. Insutype string `json:"insutype"`
  2446. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2447. PausInsuDate string `json:"paus_insu_date"`
  2448. PsnInsuDate string `json:"psn_insu_date"`
  2449. PsnInsuStas string `json:"psn_insu_stas"`
  2450. PsnType string `json:"psn_type"`
  2451. }
  2452. type ResultSix struct {
  2453. Cainfo interface{} `json:"cainfo"`
  2454. ErrMsg string `json:"err_msg"`
  2455. InfRefmsgid string `json:"inf_refmsgid"`
  2456. Infcode int64 `json:"infcode"`
  2457. Output struct {
  2458. } `json:"output"`
  2459. RefmsgTime string `json:"refmsg_time"`
  2460. RespondTime string `json:"respond_time"`
  2461. Signtype interface{} `json:"signtype"`
  2462. WarnMsg interface{} `json:"warn_msg"`
  2463. }
  2464. type ResultSix10265 struct {
  2465. Cainfo interface{} `json:"cainfo"`
  2466. ErrMsg string `json:"err_msg"`
  2467. InfRefmsgid string `json:"inf_refmsgid"`
  2468. Infcode string `json:"infcode"`
  2469. Output struct {
  2470. } `json:"output"`
  2471. RefmsgTime string `json:"refmsg_time"`
  2472. RespondTime string `json:"respond_time"`
  2473. Signtype interface{} `json:"signtype"`
  2474. WarnMsg interface{} `json:"warn_msg"`
  2475. }
  2476. type ResultSeven struct {
  2477. Cainfo string `json:"cainfo"`
  2478. ErrMsg string `json:"err_msg"`
  2479. InfRefmsgid string `json:"inf_refmsgid"`
  2480. Infcode int64 `json:"infcode"`
  2481. Output struct {
  2482. Setldetail []interface{} `json:"setldetail"`
  2483. Setlinfo struct {
  2484. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2485. AcctPay float64 `json:"acct_pay"`
  2486. ActPayDedc float64 `json:"act_pay_dedc"`
  2487. Age float64 `json:"age"`
  2488. Balc float64 `json:"balc"`
  2489. Brdy string `json:"brdy"`
  2490. Certno string `json:"certno"`
  2491. ClrOptins string `json:"clr_optins"`
  2492. ClrType string `json:"clr_type"`
  2493. ClrWay string `json:"clr_way"`
  2494. CvlservFlag string `json:"cvlserv_flag"`
  2495. CvlservPay float64 `json:"cvlserv_pay"`
  2496. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2497. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2498. Gend string `json:"gend"`
  2499. HifesPay float64 `json:"hifes_pay"`
  2500. HifmiPay float64 `json:"hifmi_pay"`
  2501. HifpPay float64 `json:"hifp_pay"`
  2502. HospPartAmt float64 `json:"hosp_part_amt"`
  2503. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2504. Insutype string `json:"insutype"`
  2505. MafPay float64 `json:"maf_pay"`
  2506. MdtrtCertType string `json:"mdtrt_cert_type"`
  2507. HifobPay float64 `json:"hifob_pay"`
  2508. MdtrtID string `json:"mdtrt_id"`
  2509. MedType string `json:"med_type"`
  2510. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2511. MedinsSetlID string `json:"medins_setl_id"`
  2512. Naty string `json:"naty"`
  2513. OthPay float64 `json:"oth_pay"`
  2514. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2515. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2516. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2517. PsnCashPay float64 `json:"psn_cash_pay"`
  2518. PsnCertType string `json:"psn_cert_type"`
  2519. PsnName string `json:"psn_name"`
  2520. PsnNo string `json:"psn_no"`
  2521. PsnPartAmt float64 `json:"psn_part_amt"`
  2522. PsnType string `json:"psn_type"`
  2523. SetlID string `json:"setl_id"`
  2524. SetlTime string `json:"setl_time"`
  2525. } `json:"setlinfo"`
  2526. } `json:"output"`
  2527. RefmsgTime string `json:"refmsg_time"`
  2528. RespondTime string `json:"respond_time"`
  2529. Signtype interface{} `json:"signtype"`
  2530. WarnMsg interface{} `json:"warn_msg"`
  2531. }
  2532. type ResultSeven10265 struct {
  2533. Cainfo string `json:"cainfo"`
  2534. ErrMsg string `json:"err_msg"`
  2535. InfRefmsgid string `json:"inf_refmsgid"`
  2536. Infcode string `json:"infcode"`
  2537. Output struct {
  2538. Setldetail []interface{} `json:"setldetail"`
  2539. Setlinfo struct {
  2540. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2541. AcctPay float64 `json:"acct_pay"`
  2542. ActPayDedc float64 `json:"act_pay_dedc"`
  2543. Age float64 `json:"age"`
  2544. Balc float64 `json:"balc"`
  2545. Brdy string `json:"brdy"`
  2546. Certno string `json:"certno"`
  2547. ClrOptins string `json:"clr_optins"`
  2548. ClrType string `json:"clr_type"`
  2549. ClrWay string `json:"clr_way"`
  2550. CvlservFlag string `json:"cvlserv_flag"`
  2551. CvlservPay float64 `json:"cvlserv_pay"`
  2552. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2553. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2554. Gend string `json:"gend"`
  2555. HifesPay float64 `json:"hifes_pay"`
  2556. HifmiPay float64 `json:"hifmi_pay"`
  2557. HifpPay float64 `json:"hifp_pay"`
  2558. HospPartAmt float64 `json:"hosp_part_amt"`
  2559. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2560. Insutype string `json:"insutype"`
  2561. MafPay float64 `json:"maf_pay"`
  2562. MdtrtCertType string `json:"mdtrt_cert_type"`
  2563. HifobPay float64 `json:"hifob_pay"`
  2564. MdtrtID string `json:"mdtrt_id"`
  2565. MedType string `json:"med_type"`
  2566. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2567. MedinsSetlID string `json:"medins_setl_id"`
  2568. Naty string `json:"naty"`
  2569. OthPay float64 `json:"oth_pay"`
  2570. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2571. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2572. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2573. PsnCashPay float64 `json:"psn_cash_pay"`
  2574. PsnCertType string `json:"psn_cert_type"`
  2575. PsnName string `json:"psn_name"`
  2576. PsnNo string `json:"psn_no"`
  2577. PsnPartAmt float64 `json:"psn_part_amt"`
  2578. PsnType string `json:"psn_type"`
  2579. SetlID string `json:"setl_id"`
  2580. SetlTime string `json:"setl_time"`
  2581. } `json:"setlinfo"`
  2582. } `json:"output"`
  2583. RefmsgTime string `json:"refmsg_time"`
  2584. RespondTime string `json:"respond_time"`
  2585. Signtype interface{} `json:"signtype"`
  2586. WarnMsg interface{} `json:"warn_msg"`
  2587. }
  2588. type ResultEight struct {
  2589. Cainfo string `json:"cainfo"`
  2590. ErrMsg string `json:"err_msg"`
  2591. InfRefmsgid string `json:"inf_refmsgid"`
  2592. Infcode int64 `json:"infcode"`
  2593. Output struct {
  2594. Stmtinfo struct {
  2595. SetlOptins string `json:"setl_optins"`
  2596. StmtRslt string `json:"stmt_rslt"`
  2597. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2598. } `json:"stmtinfo"`
  2599. } `json:"output"`
  2600. RefmsgTime string `json:"refmsg_time"`
  2601. RespondTime string `json:"respond_time"`
  2602. Signtype interface{} `json:"signtype"`
  2603. WarnMsg interface{} `json:"warn_msg"`
  2604. }
  2605. type ResultEightFor10188 struct {
  2606. Cainfo string `json:"cainfo"`
  2607. ErrMsg string `json:"err_msg"`
  2608. InfRefmsgid string `json:"inf_refmsgid"`
  2609. Infcode string `json:"infcode"`
  2610. Output struct {
  2611. Stmtinfo struct {
  2612. SetlOptins string `json:"setl_optins"`
  2613. StmtRslt string `json:"stmt_rslt"`
  2614. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2615. } `json:"stmtinfo"`
  2616. } `json:"output"`
  2617. RefmsgTime string `json:"refmsg_time"`
  2618. RespondTime string `json:"respond_time"`
  2619. Signtype interface{} `json:"signtype"`
  2620. WarnMsg interface{} `json:"warn_msg"`
  2621. }
  2622. type ResultNine struct {
  2623. Cainfo string `json:"cainfo"`
  2624. ErrMsg string `json:"err_msg"`
  2625. InfRefmsgid string `json:"inf_refmsgid"`
  2626. Infcode int64 `json:"infcode"`
  2627. Output struct {
  2628. FileQuryNo string `json:"file_qury_no"`
  2629. } `json:"output"`
  2630. RefmsgTime string `json:"refmsg_time"`
  2631. RespondTime string `json:"respond_time"`
  2632. Signtype interface{} `json:"signtype"`
  2633. WarnMsg interface{} `json:"warn_msg"`
  2634. }
  2635. type ResultTen struct {
  2636. Cainfo string `json:"cainfo"`
  2637. ErrMsg string `json:"err_msg"`
  2638. InfRefmsgid string `json:"inf_refmsgid"`
  2639. Infcode int64 `json:"infcode"`
  2640. Output struct {
  2641. DldEndtime string `json:"dld_endtime"`
  2642. FileQuryNo string `json:"file_qury_no"`
  2643. Filename string `json:"filename"`
  2644. } `json:"output"`
  2645. RefmsgTime string `json:"refmsg_time"`
  2646. RespondTime string `json:"respond_time"`
  2647. Signtype interface{} `json:"signtype"`
  2648. WarnMsg interface{} `json:"warn_msg"`
  2649. }
  2650. //type Autogenerated struct {
  2651. // Output struct {
  2652. // Setlinfo struct {
  2653. // SetlTime string `json:"setl_time"`
  2654. // CvlservPay float64 `json:"cvlserv_pay"`
  2655. // Year string `json:"year"`
  2656. // MedType string `json:"med_type"`
  2657. // PsnPay float64 `json:"psn_pay"`
  2658. // OpterID string `json:"opter_id"`
  2659. // Begndate string `json:"begndate"`
  2660. // FlxempeFlag string `json:"flxempe_flag"`
  2661. // HifmiPay float64 `json:"hifmi_pay"`
  2662. // PsnNo string `json:"psn_no"`
  2663. // ActPayDedc float64 `json:"act_pay_dedc"`
  2664. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2665. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2666. // ClrWay string `json:"clr_way"`
  2667. // OthPay float64 `json:"oth_pay"`
  2668. // Gend string `json:"gend"`
  2669. // MdtrtID string `json:"mdtrt_id"`
  2670. // AcctPay float64 `json:"acct_pay"`
  2671. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2672. // Insutype string `json:"insutype"`
  2673. // Invono interface{} `json:"invono"`
  2674. // Enddate string `json:"enddate"`
  2675. // CashPayamt float64 `json:"cash_payamt"`
  2676. // PsnType string `json:"psn_type"`
  2677. // FixmedinsName string `json:"fixmedins_name"`
  2678. // HifpPay float64 `json:"hifp_pay"`
  2679. // NewFlag interface{} `json:"new_flag"`
  2680. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2681. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2682. // PayLoc string `json:"pay_loc"`
  2683. // ClrType string `json:"clr_type"`
  2684. // RefdSetlFlag string `json:"refd_setl_flag"`
  2685. // CvlservFlag string `json:"cvlserv_flag"`
  2686. // EmpName string `json:"emp_name"`
  2687. // Brdy string `json:"brdy"`
  2688. // Naty string `json:"naty"`
  2689. // Certno string `json:"certno"`
  2690. // DiseCode string `json:"dise_code"`
  2691. // FixmedinsCode string `json:"fixmedins_code"`
  2692. // DedcHospLv string `json:"dedc_hosp_lv"`
  2693. // OpterName string `json:"opter_name"`
  2694. // Balc float64 `json:"balc"`
  2695. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2696. // PsnCertType string `json:"psn_cert_type"`
  2697. // HifobPay float64 `json:"hifob_pay"`
  2698. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2699. // HifesPay float64 `json:"hifes_pay"`
  2700. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2701. // OptTime string `json:"opt_time"`
  2702. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2703. // SetlID string `json:"setl_id"`
  2704. // MafPay float64 `json:"maf_pay"`
  2705. // PsnName string `json:"psn_name"`
  2706. // InsuOptins interface{} `json:"insu_optins"`
  2707. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2708. // ClrOptins string `json:"clr_optins"`
  2709. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2710. // DiseName string `json:"dise_name"`
  2711. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2712. // Age float64 `json:"age"`
  2713. // DtrtCertType string `json:"dtrt_cert_type"`
  2714. // HospLv string `json:"hosp_lv"`
  2715. // } `json:"setlinfo"`
  2716. // Setldetail []struct {
  2717. // FundPayType string `json:"fund_pay_type"`
  2718. // FundPayamt float64 `json:"fund_payamt"`
  2719. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2720. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2721. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2722. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2723. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2724. // } `json:"setldetail"`
  2725. // } `json:"output"`
  2726. // Infcode int `json:"infcode"`
  2727. // WarnMsg interface{} `json:"warn_msg"`
  2728. // Cainfo interface{} `json:"cainfo"`
  2729. // ErrMsg interface{} `json:"err_msg"`
  2730. // RefmsgTime string `json:"refmsg_time"`
  2731. // Signtype interface{} `json:"signtype"`
  2732. // RespondTime string `json:"respond_time"`
  2733. // InfRefmsgid string `json:"inf_refmsgid"`
  2734. //}
  2735. type ResultEleven struct {
  2736. Cainfo string `json:"cainfo"`
  2737. ErrMsg string `json:"err_msg"`
  2738. InfRefmsgid string `json:"inf_refmsgid"`
  2739. Infcode int64 `json:"infcode"`
  2740. Output struct {
  2741. Setlinfo struct {
  2742. SetlTime string `json:"setl_time"`
  2743. CvlservPay float64 `json:"cvlserv_pay"`
  2744. Year string `json:"year"`
  2745. MedType string `json:"med_type"`
  2746. PsnPay float64 `json:"psn_pay"`
  2747. OpterID string `json:"opter_id"`
  2748. Begndate string `json:"begndate"`
  2749. FlxempeFlag string `json:"flxempe_flag"`
  2750. HifmiPay float64 `json:"hifmi_pay"`
  2751. PsnNo string `json:"psn_no"`
  2752. ActPayDedc float64 `json:"act_pay_dedc"`
  2753. MedinsSetlID interface{} `json:"medins_setl_id"`
  2754. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2755. ClrWay string `json:"clr_way"`
  2756. OthPay float64 `json:"oth_pay"`
  2757. Gend string `json:"gend"`
  2758. MdtrtID string `json:"mdtrt_id"`
  2759. AcctPay float64 `json:"acct_pay"`
  2760. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2761. Insutype string `json:"insutype"`
  2762. Invono interface{} `json:"invono"`
  2763. Enddate string `json:"enddate"`
  2764. CashPayamt float64 `json:"cash_payamt"`
  2765. PsnType string `json:"psn_type"`
  2766. FixmedinsName string `json:"fixmedins_name"`
  2767. HifpPay float64 `json:"hifp_pay"`
  2768. NewFlag interface{} `json:"new_flag"`
  2769. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2770. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2771. PayLoc string `json:"pay_loc"`
  2772. ClrType string `json:"clr_type"`
  2773. RefdSetlFlag string `json:"refd_setl_flag"`
  2774. CvlservFlag string `json:"cvlserv_flag"`
  2775. EmpName string `json:"emp_name"`
  2776. Brdy string `json:"brdy"`
  2777. Naty string `json:"naty"`
  2778. Certno string `json:"certno"`
  2779. DiseCode string `json:"dise_code"`
  2780. FixmedinsCode string `json:"fixmedins_code"`
  2781. DedcHospLv string `json:"dedc_hosp_lv"`
  2782. OpterName string `json:"opter_name"`
  2783. Balc float64 `json:"balc"`
  2784. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2785. PsnCertType string `json:"psn_cert_type"`
  2786. HifobPay float64 `json:"hifob_pay"`
  2787. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2788. HifesPay float64 `json:"hifes_pay"`
  2789. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2790. OptTime string `json:"opt_time"`
  2791. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2792. SetlID string `json:"setl_id"`
  2793. MafPay float64 `json:"maf_pay"`
  2794. PsnName string `json:"psn_name"`
  2795. InsuOptins interface{} `json:"insu_optins"`
  2796. PrefFundPay interface{} `json:"pref_fund_pay"`
  2797. ClrOptins string `json:"clr_optins"`
  2798. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2799. DiseName string `json:"dise_name"`
  2800. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2801. Age float64 `json:"age"`
  2802. DtrtCertType string `json:"dtrt_cert_type"`
  2803. HospLv string `json:"hosp_lv"`
  2804. } `json:"setlinfo"`
  2805. } `json:"output"`
  2806. RefmsgTime string `json:"refmsg_time"`
  2807. RespondTime string `json:"respond_time"`
  2808. Signtype interface{} `json:"signtype"`
  2809. WarnMsg interface{} `json:"warn_msg"`
  2810. }
  2811. type ResultEleven10265 struct {
  2812. Cainfo string `json:"cainfo"`
  2813. ErrMsg string `json:"err_msg"`
  2814. InfRefmsgid string `json:"inf_refmsgid"`
  2815. Infcode string `json:"infcode"`
  2816. Output struct {
  2817. Setlinfo struct {
  2818. SetlTime string `json:"setl_time"`
  2819. CvlservPay float64 `json:"cvlserv_pay"`
  2820. Year string `json:"year"`
  2821. MedType string `json:"med_type"`
  2822. PsnPay float64 `json:"psn_pay"`
  2823. OpterID string `json:"opter_id"`
  2824. Begndate string `json:"begndate"`
  2825. FlxempeFlag string `json:"flxempe_flag"`
  2826. HifmiPay float64 `json:"hifmi_pay"`
  2827. PsnNo string `json:"psn_no"`
  2828. ActPayDedc float64 `json:"act_pay_dedc"`
  2829. MedinsSetlID interface{} `json:"medins_setl_id"`
  2830. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2831. ClrWay string `json:"clr_way"`
  2832. OthPay float64 `json:"oth_pay"`
  2833. Gend string `json:"gend"`
  2834. MdtrtID string `json:"mdtrt_id"`
  2835. AcctPay float64 `json:"acct_pay"`
  2836. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2837. Insutype string `json:"insutype"`
  2838. Invono interface{} `json:"invono"`
  2839. Enddate string `json:"enddate"`
  2840. CashPayamt float64 `json:"cash_payamt"`
  2841. PsnType string `json:"psn_type"`
  2842. FixmedinsName string `json:"fixmedins_name"`
  2843. HifpPay float64 `json:"hifp_pay"`
  2844. NewFlag interface{} `json:"new_flag"`
  2845. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2846. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2847. PayLoc string `json:"pay_loc"`
  2848. ClrType string `json:"clr_type"`
  2849. RefdSetlFlag string `json:"refd_setl_flag"`
  2850. CvlservFlag string `json:"cvlserv_flag"`
  2851. EmpName string `json:"emp_name"`
  2852. Brdy string `json:"brdy"`
  2853. Naty string `json:"naty"`
  2854. Certno string `json:"certno"`
  2855. DiseCode string `json:"dise_code"`
  2856. FixmedinsCode string `json:"fixmedins_code"`
  2857. DedcHospLv string `json:"dedc_hosp_lv"`
  2858. OpterName string `json:"opter_name"`
  2859. Balc float64 `json:"balc"`
  2860. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2861. PsnCertType string `json:"psn_cert_type"`
  2862. HifobPay float64 `json:"hifob_pay"`
  2863. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2864. HifesPay float64 `json:"hifes_pay"`
  2865. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2866. OptTime string `json:"opt_time"`
  2867. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2868. SetlID string `json:"setl_id"`
  2869. MafPay float64 `json:"maf_pay"`
  2870. PsnName string `json:"psn_name"`
  2871. InsuOptins interface{} `json:"insu_optins"`
  2872. PrefFundPay interface{} `json:"pref_fund_pay"`
  2873. ClrOptins string `json:"clr_optins"`
  2874. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2875. DiseName string `json:"dise_name"`
  2876. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2877. Age float64 `json:"age"`
  2878. DtrtCertType string `json:"dtrt_cert_type"`
  2879. HospLv string `json:"hosp_lv"`
  2880. } `json:"setlinfo"`
  2881. } `json:"output"`
  2882. RefmsgTime string `json:"refmsg_time"`
  2883. RespondTime string `json:"respond_time"`
  2884. Signtype interface{} `json:"signtype"`
  2885. WarnMsg interface{} `json:"warn_msg"`
  2886. }
  2887. type ResultTwelve struct {
  2888. Cainfo string `json:"cainfo"`
  2889. ErrMsg string `json:"err_msg"`
  2890. InfRefmsgid string `json:"inf_refmsgid"`
  2891. Infcode int64 `json:"infcode"`
  2892. Output struct {
  2893. MdtrtId string `json:"mdtrt_id"`
  2894. ChrgBchno string `json:"chrg_bchno"`
  2895. PsnNo string `json:"psn_no"`
  2896. } `json:"output"`
  2897. RefmsgTime string `json:"refmsg_time"`
  2898. RespondTime string `json:"respond_time"`
  2899. Signtype interface{} `json:"signtype"`
  2900. WarnMsg interface{} `json:"warn_msg"`
  2901. }
  2902. type ResultThirteen struct {
  2903. ErrMsg string `json:"err_msg"`
  2904. InfRefmsgid string `json:"inf_refmsgid"`
  2905. Infcode int64 `json:"infcode"`
  2906. Output struct {
  2907. Result struct {
  2908. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2909. } `json:"result"`
  2910. } `json:"output"`
  2911. RefmsgTime string `json:"refmsg_time"`
  2912. RespondTime string `json:"respond_time"`
  2913. Signtype interface{} `json:"signtype"`
  2914. WarnInfo interface{} `json:"warn_info"`
  2915. }
  2916. type ResultThirteen10265 struct {
  2917. ErrMsg string `json:"err_msg"`
  2918. InfRefmsgid string `json:"inf_refmsgid"`
  2919. Infcode string `json:"infcode"`
  2920. Output struct {
  2921. Result struct {
  2922. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2923. } `json:"result"`
  2924. } `json:"output"`
  2925. RefmsgTime string `json:"refmsg_time"`
  2926. RespondTime string `json:"respond_time"`
  2927. Signtype interface{} `json:"signtype"`
  2928. WarnInfo interface{} `json:"warn_info"`
  2929. }
  2930. type ResultFourteen struct {
  2931. ErrMsg string `json:"err_msg"`
  2932. InfRefmsgid string `json:"inf_refmsgid"`
  2933. Infcode int64 `json:"infcode"`
  2934. Output struct {
  2935. } `json:"output"`
  2936. RefmsgTime string `json:"refmsg_time"`
  2937. RespondTime string `json:"respond_time"`
  2938. Signtype interface{} `json:"signtype"`
  2939. WarnInfo interface{} `json:"warn_info"`
  2940. }
  2941. type ResultFourteen10265 struct {
  2942. ErrMsg string `json:"err_msg"`
  2943. InfRefmsgid string `json:"inf_refmsgid"`
  2944. Infcode string `json:"infcode"`
  2945. Output struct {
  2946. } `json:"output"`
  2947. RefmsgTime string `json:"refmsg_time"`
  2948. RespondTime string `json:"respond_time"`
  2949. Signtype interface{} `json:"signtype"`
  2950. WarnInfo interface{} `json:"warn_info"`
  2951. }
  2952. type ResultSixteen struct {
  2953. Cainfo string `json:"cainfo"`
  2954. ErrMsg string `json:"err_msg"`
  2955. InfRefmsgid string `json:"inf_refmsgid"`
  2956. Infcode int64 `json:"infcode"`
  2957. Output struct {
  2958. Setldetail []interface{} `json:"setldetail"`
  2959. Setlinfo struct {
  2960. MdtrtID string `json:"mdtrt_id"`
  2961. SetlID string `json:"setl_id"`
  2962. ClrOptins string `json:"clr_optins"`
  2963. SetlTime string `json:"setl_time"`
  2964. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2965. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2966. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2967. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2968. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2969. ActPayDedc float64 `json:"act_pay_dedc"`
  2970. HifpPay float64 `json:"hifp_pay"`
  2971. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2972. Lfpay float64 `json:"selfpay"`
  2973. CvlservPay float64 `json:"cvlserv_pay"`
  2974. HifesPay float64 `json:"hifes_pay"`
  2975. HifmiPay float64 `json:"hifmi_pay"`
  2976. HifobPay float64 `json:"hifob_pay"`
  2977. MafPay float64 `json:"maf_pay"`
  2978. OthPay float64 `json:"oth_pay"`
  2979. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2980. PsnPartAmt float64 `json:"psn_part_amt"`
  2981. AcctPay float64 `json:"acct_pay"`
  2982. Balc float64 `json:"balc"`
  2983. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2984. HospPartAmt float64 `json:"hosp_part_amt"`
  2985. MedinsSetlID string `json:"medins_setl_id"`
  2986. PdnCashPay string `json:"pdn_cash_pay"`
  2987. } `json:"setlinfo"`
  2988. } `json:"output"`
  2989. RefmsgTime string `json:"refmsg_time"`
  2990. RespondTime string `json:"respond_time"`
  2991. Signtype interface{} `json:"signtype"`
  2992. WarnMsg interface{} `json:"warn_msg"`
  2993. }
  2994. type ResultSixteen10265 struct {
  2995. Cainfo string `json:"cainfo"`
  2996. ErrMsg string `json:"err_msg"`
  2997. InfRefmsgid string `json:"inf_refmsgid"`
  2998. Infcode string `json:"infcode"`
  2999. Output struct {
  3000. Setldetail []interface{} `json:"setldetail"`
  3001. Setlinfo struct {
  3002. MdtrtID string `json:"mdtrt_id"`
  3003. SetlID string `json:"setl_id"`
  3004. ClrOptins string `json:"clr_optins"`
  3005. SetlTime string `json:"setl_time"`
  3006. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3008. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3009. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3010. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3011. ActPayDedc float64 `json:"act_pay_dedc"`
  3012. HifpPay float64 `json:"hifp_pay"`
  3013. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3014. Lfpay float64 `json:"selfpay"`
  3015. CvlservPay float64 `json:"cvlserv_pay"`
  3016. HifesPay float64 `json:"hifes_pay"`
  3017. HifmiPay float64 `json:"hifmi_pay"`
  3018. HifobPay float64 `json:"hifob_pay"`
  3019. MafPay float64 `json:"maf_pay"`
  3020. OthPay float64 `json:"oth_pay"`
  3021. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3022. PsnPartAmt float64 `json:"psn_part_amt"`
  3023. AcctPay float64 `json:"acct_pay"`
  3024. Balc float64 `json:"balc"`
  3025. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3026. HospPartAmt float64 `json:"hosp_part_amt"`
  3027. MedinsSetlID string `json:"medins_setl_id"`
  3028. PdnCashPay string `json:"pdn_cash_pay"`
  3029. } `json:"setlinfo"`
  3030. } `json:"output"`
  3031. RefmsgTime string `json:"refmsg_time"`
  3032. RespondTime string `json:"respond_time"`
  3033. Signtype interface{} `json:"signtype"`
  3034. WarnMsg interface{} `json:"warn_msg"`
  3035. }
  3036. type ResultSeventeen struct {
  3037. ErrMsg string `json:"err_msg"`
  3038. InfRefmsgid string `json:"inf_refmsgid"`
  3039. Infcode int64 `json:"infcode"`
  3040. Output struct {
  3041. SetlListId string `json:"setl_list_id"`
  3042. } `json:"output"`
  3043. RefmsgTime string `json:"refmsg_time"`
  3044. RespondTime string `json:"respond_time"`
  3045. Signtype string `json:"signtype"`
  3046. WarnInfo string `json:"warn_info"`
  3047. }
  3048. type Result90991 struct {
  3049. ErrMsg string `json:"err_msg"`
  3050. InfRefmsgid string `json:"inf_refmsgid"`
  3051. Infcode int64 `json:"infcode"`
  3052. Output struct {
  3053. Result struct {
  3054. PsnNo string `json:"psn_no"`
  3055. CardStat string `json:"card_stat"`
  3056. Certno string `json:"certno"`
  3057. PsnName string `json:"psn_name"`
  3058. CheckStat string `json:"check_stat"`
  3059. } `json:"result"`
  3060. } `json:"output"`
  3061. RefmsgTime string `json:"refmsg_time"`
  3062. RespondTime string `json:"respond_time"`
  3063. Signtype interface{} `json:"signtype"`
  3064. WarnInfo interface{} `json:"warn_info"`
  3065. }
  3066. type Result90100 struct {
  3067. ErrMsg string `json:"err_msg"`
  3068. InfRefmsgid string `json:"inf_refmsgid"`
  3069. Infcode int64 `json:"infcode"`
  3070. Output struct {
  3071. PoolareaNo string `json:"poolarea_no"`
  3072. PoolareaNoName string `json:"poolarea_no_name"`
  3073. Insutype string `json:"insutype"`
  3074. InsutypeName string `json:"insutype_name"`
  3075. ClctType string `json:"clct_type"`
  3076. ClctTypeName string `json:"clct_type_name"`
  3077. ClctFlag string `json:"clct_flag"`
  3078. ClctFlagName string `json:"clct_flag_name"`
  3079. AccrymBegn string `json:"accrym_begn"`
  3080. AccrymEnd string `json:"accrym_end"`
  3081. ClctTime string `json:"clct_time"`
  3082. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3083. } `json:"output"`
  3084. RefmsgTime string `json:"refmsg_time"`
  3085. RespondTime string `json:"respond_time"`
  3086. Signtype interface{} `json:"signtype"`
  3087. WarnInfo interface{} `json:"warn_info"`
  3088. }
  3089. type Custom struct {
  3090. DetItemFeeSumamt string
  3091. Cut string
  3092. FeedetlSn string
  3093. Price string
  3094. MedListCodg string
  3095. Type int64
  3096. AdviceId int64
  3097. ProjectId int64
  3098. ItemId int64
  3099. }
  3100. type Result5301 struct {
  3101. ErrMsg string `json:"err_msg"`
  3102. InfRefmsgid string `json:"inf_refmsgid"`
  3103. Infcode int64 `json:"infcode"`
  3104. Output struct {
  3105. Result []struct {
  3106. OpspDiseCode string `json:"opsp_dise_code"`
  3107. OpspDiseName string `json:"opsp_dise_name"`
  3108. Begndate string `json:"begndate"`
  3109. Enddate string `json:"enddate"`
  3110. } `json:"feedetail"`
  3111. } `json:"output"`
  3112. RefmsgTime string `json:"refmsg_time"`
  3113. RespondTime string `json:"respond_time"`
  3114. Signtype interface{} `json:"signtype"`
  3115. WarnInfo interface{} `json:"warn_info"`
  3116. }
  3117. type Result5301For10265 struct {
  3118. ErrMsg string `json:"err_msg"`
  3119. InfRefmsgid string `json:"inf_refmsgid"`
  3120. Infcode string `json:"infcode"`
  3121. Output struct {
  3122. Result []struct {
  3123. OpspDiseCode string `json:"opsp_dise_code"`
  3124. OpspDiseName string `json:"opsp_dise_name"`
  3125. Begndate string `json:"begndate"`
  3126. Enddate string `json:"enddate"`
  3127. } `json:"feedetail"`
  3128. } `json:"output"`
  3129. RefmsgTime string `json:"refmsg_time"`
  3130. RespondTime string `json:"respond_time"`
  3131. Signtype interface{} `json:"signtype"`
  3132. WarnInfo interface{} `json:"warn_info"`
  3133. }
  3134. //获取个人信息----挂号-----上传就诊信息
  3135. func (c *HisApiController) GetRegisterInfo() {
  3136. id, _ := c.GetInt64("id")
  3137. record_time := c.GetString("record_time")
  3138. settlementValue, _ := c.GetInt64("settlement_value")
  3139. medical_insurance_card := c.GetString("medical_insurance_card")
  3140. name := c.GetString("name")
  3141. id_card_type, _ := c.GetInt64("id_card_type")
  3142. certificates, _ := c.GetInt64("certificates")
  3143. medical_care, _ := c.GetInt64("medical_care")
  3144. birthday := c.GetString("birthday")
  3145. id_card := c.GetString("id_card")
  3146. register_type, _ := c.GetInt64("register")
  3147. doctor, _ := c.GetInt64("doctor")
  3148. department, _ := c.GetInt64("department")
  3149. gender, _ := c.GetInt64("sex")
  3150. registration_fee, _ := c.GetFloat("registration_fee")
  3151. medical_expenses, _ := c.GetFloat("medical_expenses")
  3152. social_type, _ := c.GetInt64("social_type")
  3153. med_type := c.GetString("social_type")
  3154. admin_user_id, _ := c.GetInt64("admin_user_id")
  3155. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3156. timeLayout := "2006-01-02"
  3157. loc, _ := time.LoadLocation("Local")
  3158. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3159. birthUnix := birthdays.Unix()
  3160. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3161. if err != nil {
  3162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3163. return
  3164. }
  3165. recordDateTime := theTime.Unix()
  3166. adminInfo := c.GetAdminUserInfo()
  3167. var patient service.Patients
  3168. if id == 0 {
  3169. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3170. } else {
  3171. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3172. }
  3173. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3174. if patientPrescription.ID == 0 {
  3175. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3176. }
  3177. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3178. if patient.ID == 0 {
  3179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3180. return
  3181. }
  3182. if len(patient.IdCardNo) == 0 {
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3184. return
  3185. }
  3186. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3187. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3188. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3189. //就诊结算未完成,不能进行二次挂号
  3190. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3191. if len(his) >= 1 {
  3192. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3193. if len(his) >= 1 && order.ID == 0 {
  3194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3195. return
  3196. }
  3197. }
  3198. //var register_log string
  3199. if config.IsOpen == 1 {
  3200. var res ResultTwo
  3201. var res10265 ResultTwo10265
  3202. var PsnNo string
  3203. var PsnCertType string
  3204. var Certno string
  3205. var PsnName string
  3206. var Gend string
  3207. var Naty string
  3208. var Brdy string
  3209. var Age float64
  3210. var infoStr string
  3211. var idetinfoStr string
  3212. var infocode int64
  3213. var verify_number string
  3214. fmt.Println(verify_number)
  3215. if miConfig.MdtrtareaAdmvs == "421300" {
  3216. psn_info, _ := service.GetPsnByPatientId(id)
  3217. PsnNo = psn_info.PsnNo
  3218. PsnCertType = psn_info.PsnCertType
  3219. Certno = psn_info.Certno
  3220. PsnName = psn_info.PsnName
  3221. Gend = psn_info.Gend
  3222. Naty = psn_info.Naty
  3223. Brdy = psn_info.Brdy
  3224. Age = psn_info.Age
  3225. infoStr = psn_info.Insuinfo
  3226. idetinfoStr = psn_info.Idetinfo
  3227. infocode = 0
  3228. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3229. psn_info, _ := service.GetPsnByPatientId(id)
  3230. PsnNo = psn_info.PsnNo
  3231. PsnCertType = psn_info.PsnCertType
  3232. Certno = psn_info.Certno
  3233. PsnName = psn_info.PsnName
  3234. Gend = psn_info.Gend
  3235. Naty = psn_info.Naty
  3236. Brdy = psn_info.Brdy
  3237. Age = psn_info.Age
  3238. infoStr = psn_info.Insuinfo
  3239. idetinfoStr = psn_info.Idetinfo
  3240. infocode = 0
  3241. verify_number = psn_info.VerifyNumber
  3242. } else {
  3243. var result string
  3244. var requestLog string
  3245. if miConfig.UserOrgId == 10138 {
  3246. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3247. } else {
  3248. 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)
  3249. }
  3250. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3251. if miConfig.Code == "H15049901371" {
  3252. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3253. utils.ErrorLog("解析失败:%v", err)
  3254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3255. return
  3256. }
  3257. res.ErrMsg = res10265.ErrMsg
  3258. res.Output = res10265.Output
  3259. res.InfRefmsgid = res10265.InfRefmsgid
  3260. } else {
  3261. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3262. utils.ErrorLog("解析失败:%v", err)
  3263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3264. return
  3265. }
  3266. }
  3267. PsnNo = res.Output.Baseinfo.PsnNo
  3268. PsnCertType = res.Output.Baseinfo.PsnCertType
  3269. Certno = res.Output.Baseinfo.Certno
  3270. PsnName = res.Output.Baseinfo.PsnName
  3271. Gend = res.Output.Baseinfo.Gend
  3272. Naty = res.Output.Baseinfo.Naty
  3273. Brdy = res.Output.Baseinfo.Brdy
  3274. Age = res.Output.Baseinfo.Age
  3275. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3276. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3277. infoStr = string(Iinfos)
  3278. idetinfoStr = string(Idetinfos)
  3279. if miConfig.Code == "H15049901371" {
  3280. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3281. } else {
  3282. infocode = res.Infcode
  3283. }
  3284. }
  3285. if infocode == 0 {
  3286. his := models.VMHisPatient{
  3287. Name: name,
  3288. Gender: gender,
  3289. Birthday: birthUnix,
  3290. MedicalTreatmentType: medical_care,
  3291. IdType: certificates,
  3292. IdCardNo: id_card,
  3293. BalanceAccountsType: settlementValue,
  3294. SocialType: social_type,
  3295. MedicalInsuranceNumber: medical_insurance_card,
  3296. RegisterType: register_type,
  3297. RegisterCost: registration_fee,
  3298. TreatmentCost: medical_expenses,
  3299. Status: 1,
  3300. Ctime: time.Now().Unix(),
  3301. Mtime: time.Now().Unix(),
  3302. PsnNo: PsnNo,
  3303. PsnCertType: PsnCertType,
  3304. Certno: Certno,
  3305. PsnName: PsnName,
  3306. Gend: Gend,
  3307. Naty: Naty,
  3308. Brdy: Brdy,
  3309. Age: Age,
  3310. Iinfo: infoStr,
  3311. Idetinfo: idetinfoStr,
  3312. PatientId: patient.ID,
  3313. RecordDate: theTime.Unix(),
  3314. UserOrgId: adminInfo.CurrentOrgId,
  3315. AdminUserId: admin_user_id,
  3316. IsReturn: 1,
  3317. IdCardType: id_card_type,
  3318. Doctor: doctor,
  3319. Departments: department,
  3320. }
  3321. timestamp := time.Now().Unix()
  3322. tempTime := time.Unix(timestamp, 0)
  3323. timeFormat := tempTime.Format("20060102150405")
  3324. chrgBchno := rand.Intn(100000) + 10000
  3325. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3326. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3327. department, _ := service.GetDepartMentDetail(department)
  3328. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3329. IdCardNo := ""
  3330. if id_card_type == 1 {
  3331. // IdCardNo = medical_insurance_card
  3332. IdCardNo = patient.IdCardNo
  3333. } else {
  3334. IdCardNo = patient.IdCardNo
  3335. }
  3336. var rf []*ResultFive
  3337. json.Unmarshal([]byte(his.Iinfo), &rf)
  3338. var insutypes []*ResultFive
  3339. var insutype string
  3340. var insuplc_admdvs_temp string
  3341. var is390 int = 0
  3342. var is310 int = 0
  3343. for _, item := range rf {
  3344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3345. insutypes = append(insutypes, item)
  3346. }
  3347. }
  3348. if len(insutypes) == 1 {
  3349. insutype = insutypes[0].Insutype
  3350. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3351. } else {
  3352. for _, i := range insutypes {
  3353. if i.Insutype == "390" {
  3354. is390 = 1
  3355. }
  3356. if i.Insutype == "310" {
  3357. is310 = 1
  3358. }
  3359. }
  3360. }
  3361. if is390 == 1 {
  3362. insutype = "390"
  3363. }
  3364. if is310 == 1 {
  3365. insutype = "310"
  3366. }
  3367. if len(insutypes) == 0 {
  3368. insutype = "310"
  3369. }
  3370. if len(insutypes) == 2 {
  3371. insutype = med_type
  3372. }
  3373. if len(med_type) > 0 {
  3374. insutype = med_type
  3375. }
  3376. //for _, item := range rf {
  3377. // if item.Insutype == insutype {
  3378. // insuplc_admdvs = item.InsuplcAdmdvs
  3379. // }
  3380. //}
  3381. var infocode int64
  3382. var resThree ResultThree
  3383. var resThree10265 ResultThree10265
  3384. if len(insuplc_admdvs) == 0 {
  3385. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3386. } else {
  3387. insuplc_admdvs_temp = insuplc_admdvs
  3388. }
  3389. if miConfig.MdtrtareaAdmvs == "421300" {
  3390. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3391. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3392. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&doctor_name=" + doctor_info.UserName
  3393. resp, requestErr := http.Get(api)
  3394. if requestErr != nil {
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3396. return
  3397. }
  3398. body, ioErr := ioutil.ReadAll(resp.Body)
  3399. if ioErr != nil {
  3400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3402. return
  3403. }
  3404. var respJSON map[string]interface{}
  3405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3411. result, _ := json.Marshal(respJSON)
  3412. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3413. utils.ErrorLog("解析失败:%v", err)
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3415. return
  3416. }
  3417. infocode = resThree.Infcode
  3418. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3419. psn_info, _ := service.GetPsnByPatientId(id)
  3420. bas := strings.Split(psn_info.CardInfo, "|")
  3421. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3422. var api string
  3423. if miConfig.MdtrtareaAdmvs == "320921" {
  3424. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3425. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3426. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3427. } else {
  3428. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3429. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3430. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3431. }
  3432. resp, requestErr := http.Get(api)
  3433. if requestErr != nil {
  3434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3435. return
  3436. }
  3437. body, ioErr := ioutil.ReadAll(resp.Body)
  3438. if ioErr != nil {
  3439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3441. return
  3442. }
  3443. var respJSON map[string]interface{}
  3444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3447. return
  3448. }
  3449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3450. result, _ := json.Marshal(respJSON)
  3451. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3452. utils.ErrorLog("解析失败:%v", err)
  3453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3454. return
  3455. }
  3456. resThree.ErrMsg = resThree10265.ErrMsg
  3457. resThree.Output = resThree10265.Output
  3458. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3459. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3460. } else {
  3461. 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_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3462. saveLog(result, requestLog, "2201", "挂号")
  3463. if miConfig.Code == "H15049901371" {
  3464. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3465. utils.ErrorLog("解析失败:%v", err)
  3466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3467. return
  3468. }
  3469. resThree.ErrMsg = resThree10265.ErrMsg
  3470. resThree.Output = resThree10265.Output
  3471. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3472. } else {
  3473. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3474. utils.ErrorLog("解析失败:%v", err)
  3475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3476. return
  3477. }
  3478. }
  3479. if miConfig.Code == "H15049901371" {
  3480. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3481. } else {
  3482. infocode = resThree.Infcode
  3483. }
  3484. }
  3485. if infocode != 0 {
  3486. adminUser := c.GetAdminUserInfo()
  3487. errlog := &models.HisOrderError{
  3488. UserOrgId: adminUser.CurrentOrgId,
  3489. Ctime: time.Now().Unix(),
  3490. Mtime: time.Now().Unix(),
  3491. ErrMsg: resThree.ErrMsg,
  3492. Status: 1,
  3493. PatientId: id,
  3494. RecordTime: recordDateTime,
  3495. Stage: 2,
  3496. }
  3497. service.CreateErrMsgLog(errlog)
  3498. c.ServeSuccessJSON(map[string]interface{}{
  3499. "failed_code": -10,
  3500. "msg": resThree.ErrMsg,
  3501. })
  3502. return
  3503. }
  3504. his.Number = resThree.Output.Data.MdtrtID
  3505. his.PsnNo = resThree.Output.Data.PsnNo
  3506. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3507. his.IdCardNo = patient.IdCardNo
  3508. his.PhoneNumber = patient.Phone
  3509. his.UserOrgId = adminInfo.CurrentOrgId
  3510. his.Insutype = insutype
  3511. his.Ctime = time.Now().Unix()
  3512. his.Mtime = time.Now().Unix()
  3513. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3514. his.Status = 1
  3515. service.UpdateHisPatientStatus(&his)
  3516. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3517. c.ServeSuccessJSON(map[string]interface{}{
  3518. "his_info": his,
  3519. })
  3520. } else {
  3521. adminUser := c.GetAdminUserInfo()
  3522. errlog := &models.HisOrderError{
  3523. UserOrgId: adminUser.CurrentOrgId,
  3524. Ctime: time.Now().Unix(),
  3525. Mtime: time.Now().Unix(),
  3526. ErrMsg: res.ErrMsg,
  3527. Status: 1,
  3528. PatientId: id,
  3529. RecordTime: recordDateTime,
  3530. Stage: 1,
  3531. }
  3532. service.CreateErrMsgLog(errlog)
  3533. c.ServeSuccessJSON(map[string]interface{}{
  3534. "failed_code": -10,
  3535. "msg": res.ErrMsg,
  3536. })
  3537. return
  3538. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3539. }
  3540. }
  3541. }
  3542. //上传明细----预结算----确认订单
  3543. func (c *HisApiController) GetUploadInfo() {
  3544. id, _ := c.GetInt64("id")
  3545. record_time := c.GetString("record_time")
  3546. his_patient_id, _ := c.GetInt64("his_patient_id")
  3547. order_id, _ := c.GetInt64("order_id")
  3548. pay_way, _ := c.GetInt64("pay_way")
  3549. pay_price, _ := c.GetFloat("pay_price")
  3550. pay_card_no := c.GetString("pay_card_no")
  3551. discount_price, _ := c.GetFloat("discount_price")
  3552. preferential_price, _ := c.GetFloat("preferential_price")
  3553. reality_price, _ := c.GetFloat("reality_price")
  3554. found_price, _ := c.GetFloat("found_price")
  3555. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3556. private_price, _ := c.GetFloat("private_price")
  3557. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3558. admin_user_id, _ := c.GetInt64("admin_user_id")
  3559. fapiao_code := c.GetString("fapiao_code")
  3560. fapiao_number := c.GetString("fapiao_number")
  3561. diagnosis_id := c.GetString("diagnosis")
  3562. sick_type, _ := c.GetInt64("sick_type")
  3563. reg_type, _ := c.GetInt64("p_type")
  3564. begin_time := c.GetString("begin_time")
  3565. id_str := c.GetString("ids")
  3566. ids_arr := strings.Split(id_str, ",")
  3567. timeLayout := "2006-01-02"
  3568. loc, _ := time.LoadLocation("Local")
  3569. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3570. if err != nil {
  3571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3572. return
  3573. }
  3574. recordDateTime := theTime.Unix()
  3575. adminUser := c.GetAdminUserInfo()
  3576. var tempOrder models.HisOrder
  3577. tempOrder, _ = service.GetHisOrderByID(order_id)
  3578. var prescriptions []*models.HisPrescription
  3579. var start_time int64
  3580. var end_time int64
  3581. //if adminUser.CurrentOrgId == 10106{
  3582. // if len(fapiao_code) == 0{
  3583. // fapiao_code = "144072080589"
  3584. // }
  3585. // if len(fapiao_number) == 0{
  3586. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3587. // if order.ID == 0{
  3588. // fapiao_number = "00001520"
  3589. // }else{
  3590. // //fapiao_code = "00001520"
  3591. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3592. // var zero string
  3593. // if fpNumber >= 1000{
  3594. // zero = "0000" + strconv.Itoa(fpNumber)
  3595. // }else if fpNumber >= 10000{
  3596. // zero = "000" + strconv.Itoa(fpNumber)
  3597. // } else if fpNumber >= 100000{
  3598. // zero = "00" + strconv.Itoa(fpNumber)
  3599. // } else if fpNumber >= 1000000{
  3600. // zero = "0" + strconv.Itoa(fpNumber)
  3601. // }else {
  3602. // zero = strconv.Itoa(fpNumber)
  3603. // }
  3604. // fapiao_number = zero
  3605. // }
  3606. // }
  3607. //}
  3608. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3609. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3610. var patientPrescription models.HisPrescriptionInfo
  3611. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3612. if patientPrescription.ID == 0 {
  3613. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3614. }
  3615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3616. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3617. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3618. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3619. var config []*models.HisXtDiagnoseConfig
  3620. for _, item := range diagnosis_ids {
  3621. id, _ := strconv.ParseInt(item, 10, 64)
  3622. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3623. config = append(config, &diagnosisConfig)
  3624. }
  3625. sickConfig, _ := service.FindSickById(sick_type)
  3626. //if tempOrder.ID == 0 {
  3627. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3628. //}
  3629. if tempOrder.ID == 0 {
  3630. var result string
  3631. var requestLog string
  3632. var res2 ResultSix
  3633. var ressix10265 ResultSix10265
  3634. if miConfig.MdtrtareaAdmvs == "421300" {
  3635. data := make(map[string]interface{})
  3636. client := &http.Client{}
  3637. data["psn_no"] = his.PsnNo
  3638. data["mdtrt_id"] = his.Number
  3639. data["doctor"] = roles.UserName
  3640. data["department"] = department.Name
  3641. data["org_name"] = miConfig.OrgName
  3642. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3643. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3644. data["fixmedins_code"] = miConfig.Code
  3645. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3646. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3647. data["secret_key"] = miConfig.SecretKey
  3648. data["sick_code"] = sickConfig.CountryCode
  3649. data["sick_name"] = sickConfig.ClassName
  3650. data["dept"] = strconv.FormatInt(department.ID, 10)
  3651. data["config"] = config
  3652. data["begin_time"] = begin_time
  3653. bytesData, _ := json.Marshal(data)
  3654. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3655. resp, _ := client.Do(req)
  3656. defer resp.Body.Close()
  3657. body, ioErr := ioutil.ReadAll(resp.Body)
  3658. if ioErr != nil {
  3659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3661. return
  3662. }
  3663. var respJSON map[string]interface{}
  3664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3667. return
  3668. }
  3669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3670. userJSONBytes, _ := json.Marshal(respJSON)
  3671. fmt.Println("log")
  3672. fmt.Println(string(userJSONBytes))
  3673. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3674. utils.ErrorLog("解析失败:%v", err)
  3675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3676. return
  3677. }
  3678. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3679. //江苏地区国家医保医疗类别
  3680. //职工透析:医疗类别选特殊情况门诊9933
  3681. //居民血透门慢: 医疗类别选门诊慢病1402
  3682. //var med_type string
  3683. //if his.Insutype == "310" {
  3684. // if reg_type == 14 {
  3685. // med_type = "9933"
  3686. // } else if reg_type == 11 {
  3687. // med_type = "11"
  3688. //
  3689. // }
  3690. //} else if his.Insutype == "390" {
  3691. // if reg_type == 14 {
  3692. // med_type = "1402"
  3693. // } else if reg_type == 11 {
  3694. // med_type = "11"
  3695. // }
  3696. //}
  3697. data := make(map[string]interface{})
  3698. client := &http.Client{}
  3699. data["psn_no"] = his.PsnNo
  3700. data["mdtrt_id"] = his.Number
  3701. data["doctor"] = roles.UserName
  3702. data["department"] = department.Name
  3703. data["org_name"] = miConfig.OrgName
  3704. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3705. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3706. data["fixmedins_code"] = miConfig.Code
  3707. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3708. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3709. data["secret_key"] = miConfig.SecretKey
  3710. data["sick_code"] = sickConfig.CountryCode
  3711. data["sick_name"] = sickConfig.ClassName
  3712. data["url"] = miConfig.Url
  3713. data["ak"] = miConfig.AccessKey
  3714. data["begin_time"] = begin_time
  3715. data["cainfo"] = miConfig.Cainfo
  3716. data["dept"] = strconv.FormatInt(department.ID, 10)
  3717. data["config"] = config
  3718. bytesData, _ := json.Marshal(data)
  3719. var req *http.Request
  3720. if miConfig.MdtrtareaAdmvs == "320921" {
  3721. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3722. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3723. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3724. } else {
  3725. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3726. }
  3727. resp, _ := client.Do(req)
  3728. defer resp.Body.Close()
  3729. body, ioErr := ioutil.ReadAll(resp.Body)
  3730. if ioErr != nil {
  3731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. return
  3734. }
  3735. var respJSON map[string]interface{}
  3736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. return
  3740. }
  3741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3742. userJSONBytes, _ := json.Marshal(respJSON)
  3743. fmt.Println("log")
  3744. fmt.Println(string(userJSONBytes))
  3745. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3746. utils.ErrorLog("解析失败:%v", err)
  3747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. return
  3749. }
  3750. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3751. res2.Output = ressix10265.Output
  3752. res2.ErrMsg = ressix10265.ErrMsg
  3753. res2.Cainfo = ressix10265.Cainfo
  3754. res2.WarnMsg = ressix10265.WarnMsg
  3755. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3756. res2.Infcode = infocode
  3757. } else {
  3758. if miConfig.MdtrtareaAdmvs == "440781" { //
  3759. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3760. } else {
  3761. if miConfig.Code == "H15049901371" {
  3762. //赤峰地区国家医保医疗类别
  3763. //职工透析:医疗类别选特殊情况门诊990502
  3764. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3765. var med_type string
  3766. if his.Insutype == "390" {
  3767. if reg_type == 14 {
  3768. med_type = "9933"
  3769. } else if reg_type == 11 {
  3770. med_type = "11"
  3771. }
  3772. } else if his.Insutype == "310" {
  3773. if reg_type == 14 {
  3774. med_type = "990502"
  3775. } else if reg_type == 11 {
  3776. med_type = "11"
  3777. }
  3778. }
  3779. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3780. } else {
  3781. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3782. }
  3783. }
  3784. saveLog(result, requestLog, "2203", "上传就诊信息")
  3785. var respJSON2 map[string]interface{}
  3786. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. userJSONBytes2, _ := json.Marshal(respJSON2)
  3792. if miConfig.Code == "H15049901371" {
  3793. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3794. utils.ErrorLog("解析失败:%v", err)
  3795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. return
  3797. }
  3798. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3799. res2.Output = ressix10265.Output
  3800. res2.ErrMsg = ressix10265.ErrMsg
  3801. res2.Cainfo = ressix10265.Cainfo
  3802. res2.WarnMsg = ressix10265.WarnMsg
  3803. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3804. res2.Infcode = infocode
  3805. } else {
  3806. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3807. utils.ErrorLog("解析失败:%v", err)
  3808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3809. return
  3810. }
  3811. }
  3812. }
  3813. if res2.Infcode != 0 {
  3814. adminUser := c.GetAdminUserInfo()
  3815. errlog := &models.HisOrderError{
  3816. UserOrgId: adminUser.CurrentOrgId,
  3817. Ctime: time.Now().Unix(),
  3818. Mtime: time.Now().Unix(),
  3819. ErrMsg: res2.ErrMsg,
  3820. Status: 1,
  3821. PatientId: id,
  3822. RecordTime: recordDateTime,
  3823. Stage: 3,
  3824. }
  3825. service.CreateErrMsgLog(errlog)
  3826. c.ServeSuccessJSON(map[string]interface{}{
  3827. "failed_code": -10,
  3828. "msg": res2.ErrMsg,
  3829. })
  3830. return
  3831. } else {
  3832. his.Diagnosis = diagnosis_id
  3833. his.SickType = sickConfig.ID
  3834. var p_type int64
  3835. if reg_type == 1111 || reg_type == 1112 {
  3836. p_type = 11
  3837. }
  3838. his.PType = fmt.Sprintf("%d", p_type)
  3839. service.UpdateHisPatientThree(&his)
  3840. data := make(map[string]interface{})
  3841. if settle_accounts_type == 1 { //日结
  3842. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3843. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3844. } else {
  3845. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3846. }
  3847. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3848. data["pre"] = prescriptions
  3849. } else { //月结
  3850. start_time_str := c.GetString("start_time")
  3851. end_time_str := c.GetString("end_time")
  3852. timeLayout := "2006-01-02"
  3853. loc, _ := time.LoadLocation("Local")
  3854. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3855. if err != nil {
  3856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3857. return
  3858. }
  3859. recordStartTime := theStartTime.Unix()
  3860. start_time = recordStartTime
  3861. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3862. if err != nil {
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3864. return
  3865. }
  3866. recordEndTime := theEndTime.Unix()
  3867. end_time = recordEndTime
  3868. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3869. data["pre"] = prescriptions
  3870. }
  3871. timestamp := time.Now().Unix()
  3872. tempTime := time.Unix(timestamp, 0)
  3873. timeFormat := tempTime.Format("20060102150405")
  3874. chrgBchno := rand.Intn(100000) + 10000
  3875. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3876. strconv.FormatInt(his.PatientId, 10)
  3877. client := &http.Client{}
  3878. data["psn_no"] = his.PsnNo
  3879. data["mdtrt_id"] = his.Number
  3880. data["chrg_bchno"] = chrg_bchno
  3881. data["org_name"] = miConfig.OrgName
  3882. data["doctor"] = roles.UserName
  3883. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3884. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3885. data["fixmedins_code"] = miConfig.Code
  3886. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3887. // data["dept_code"] = "15"
  3888. //} else {
  3889. data["dept_code"] = department.Number
  3890. //}
  3891. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3893. data["secret_key"] = miConfig.SecretKey
  3894. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3895. data["url"] = miConfig.Url
  3896. data["ak"] = miConfig.AccessKey
  3897. data["new_doctor_name"] = patientPrescription.Doctor
  3898. data["diag_code"] = sickConfig.CountryCode
  3899. data["cainfo"] = miConfig.Cainfo
  3900. var ids []int64
  3901. for _, item := range prescriptions {
  3902. ids = append(ids, item.ID)
  3903. }
  3904. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3905. if config.IsOpen == 1 { //对接了医保,走医保流程
  3906. var res ResultFour
  3907. var resFour10265 ResultFour10265
  3908. if miConfig.MdtrtareaAdmvs == "421300" {
  3909. bytesData, _ := json.Marshal(data)
  3910. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3911. resp, _ := client.Do(req)
  3912. defer resp.Body.Close()
  3913. body, ioErr := ioutil.ReadAll(resp.Body)
  3914. if ioErr != nil {
  3915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3917. return
  3918. }
  3919. var respJSON map[string]interface{}
  3920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3923. return
  3924. }
  3925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3926. userJSONBytes, _ := json.Marshal(respJSON)
  3927. fmt.Println("log")
  3928. fmt.Println(string(userJSONBytes))
  3929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3930. utils.ErrorLog("解析失败:%v", err)
  3931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3932. return
  3933. }
  3934. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3935. bytesData, _ := json.Marshal(data)
  3936. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3937. resp, _ := client.Do(req)
  3938. defer resp.Body.Close()
  3939. body, ioErr := ioutil.ReadAll(resp.Body)
  3940. if ioErr != nil {
  3941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3943. return
  3944. }
  3945. var respJSON map[string]interface{}
  3946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3949. return
  3950. }
  3951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3952. userJSONBytes, _ := json.Marshal(respJSON)
  3953. fmt.Println("log")
  3954. fmt.Println(string(userJSONBytes))
  3955. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3956. utils.ErrorLog("解析失败:%v", err)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. res.InfRefmsgid = resFour10265.InfRefmsgid
  3961. res.Output = resFour10265.Output
  3962. res.ErrMsg = resFour10265.ErrMsg
  3963. res.Cainfo = resFour10265.Cainfo
  3964. res.WarnMsg = resFour10265.WarnMsg
  3965. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3966. res.Infcode = infocode
  3967. } else {
  3968. if miConfig.Code == "H15049901371" {
  3969. 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), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3970. var dat map[string]interface{}
  3971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3972. fmt.Println(dat)
  3973. } else {
  3974. fmt.Println(err)
  3975. }
  3976. saveLog(result, request_log, "2204", "上传费用明细")
  3977. userJSONBytes, _ := json.Marshal(dat)
  3978. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3979. utils.ErrorLog("解析失败:%v", err)
  3980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3981. return
  3982. }
  3983. res.InfRefmsgid = resFour10265.InfRefmsgid
  3984. res.Output = resFour10265.Output
  3985. res.ErrMsg = resFour10265.ErrMsg
  3986. res.Cainfo = resFour10265.Cainfo
  3987. res.WarnMsg = resFour10265.WarnMsg
  3988. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3989. res.Infcode = infocode
  3990. } else {
  3991. 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), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3992. var dat map[string]interface{}
  3993. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3994. fmt.Println(dat)
  3995. } else {
  3996. fmt.Println(err)
  3997. }
  3998. saveLog(result, request_log, "2204", "上传费用明细")
  3999. userJSONBytes, _ := json.Marshal(dat)
  4000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4001. utils.ErrorLog("解析失败:%v", err)
  4002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4003. return
  4004. }
  4005. }
  4006. }
  4007. if res.Infcode == 0 {
  4008. order := &models.HisOrder{
  4009. UserOrgId: adminUser.CurrentOrgId,
  4010. HisPatientId: his.ID,
  4011. PatientId: his.PatientId,
  4012. SettleAccountsDate: recordDateTime,
  4013. MdtrtId: his.Number,
  4014. PsnNo: his.PsnNo,
  4015. MedType: strconv.FormatInt(reg_type, 10),
  4016. Ctime: time.Now().Unix(),
  4017. Mtime: time.Now().Unix(),
  4018. Status: 1,
  4019. Number: chrg_bchno,
  4020. Infcode: res.Infcode,
  4021. WarnMsg: res.WarnMsg,
  4022. Cainfo: res.Cainfo,
  4023. ErrMsg: res.ErrMsg,
  4024. RespondTime: res.RefmsgTime,
  4025. InfRefmsgid: res.InfRefmsgid,
  4026. OrderStatus: 1,
  4027. PayWay: pay_way,
  4028. PayPrice: pay_price,
  4029. PayCardNo: pay_card_no,
  4030. DiscountPrice: discount_price,
  4031. PreferentialPrice: preferential_price,
  4032. RealityPrice: reality_price,
  4033. FoundPrice: found_price,
  4034. MedicalInsurancePrice: medical_insurance_price,
  4035. PrivatePrice: private_price,
  4036. IsMedicineInsurance: 1,
  4037. SettleType: settle_accounts_type,
  4038. SettleStartTime: start_time,
  4039. SettleEndTime: end_time,
  4040. Creator: roles.AdminUserId,
  4041. Modify: roles.AdminUserId,
  4042. FaPiaoNumber: fapiao_number,
  4043. FaPiaoCode: fapiao_code,
  4044. PType: 2,
  4045. Diagnosis: diagnosis_id,
  4046. }
  4047. err = service.CreateOrder(order)
  4048. if err != nil {
  4049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4050. return
  4051. }
  4052. for _, item := range res.Output.Result {
  4053. temp := strings.Split(item.FeedetlSn, "-")
  4054. var advice_id int64 = 0
  4055. var project_id int64 = 0
  4056. var types int64 = 0
  4057. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4058. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4059. if temp[1] == "1" {
  4060. advice_id = id
  4061. project_id = 0
  4062. } else if temp[1] == "2" {
  4063. advice_id = 0
  4064. project_id = id
  4065. }
  4066. info := &models.HisOrderInfo{
  4067. OrderNumber: order.Number,
  4068. FeedetlSn: item.FeedetlSn,
  4069. UploadDate: time.Now().Unix(),
  4070. AdviceId: advice_id,
  4071. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4072. Cnt: item.Cnt,
  4073. Pric: float64(item.Pric),
  4074. PatientId: his.PatientId,
  4075. PricUplmtAmt: item.PricUplmtAmt,
  4076. SelfpayProp: item.SelfpayProp,
  4077. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4078. OverlmtAmt: item.OverlmtAmt,
  4079. PreselfpayAmt: item.PreselfpayAmt,
  4080. BasMednFlag: item.BasMednFlag,
  4081. MedChrgitmType: item.MedChrgitmType,
  4082. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4083. Status: 1,
  4084. Memo: item.Memo,
  4085. Mtime: time.Now().Unix(),
  4086. InscpScpAmt: item.InscpScpAmt,
  4087. DrtReimFlag: item.DrtReimFlag,
  4088. Ctime: time.Now().Unix(),
  4089. ListSpItemFlag: item.ListSpItemFlag,
  4090. ChldMedcFlag: item.ChldMedcFlag,
  4091. LmtUsedFlag: item.LmtUsedFlag,
  4092. ChrgitmLv: item.ChrgitmLv,
  4093. UserOrgId: adminUser.CurrentOrgId,
  4094. HisPatientId: his.ID,
  4095. OrderId: order.ID,
  4096. ProjectId: project_id,
  4097. Type: types,
  4098. }
  4099. service.CreateOrderInfo(info)
  4100. }
  4101. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4102. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4103. var total float64
  4104. for _, item := range prescriptions {
  4105. if item.Type == 1 { //药品
  4106. for _, subItem := range item.HisDoctorAdviceInfo {
  4107. total = total + (subItem.Price * subItem.PrescribingNumber)
  4108. }
  4109. }
  4110. if item.Type == 2 { //项目
  4111. for _, subItem := range item.HisPrescriptionProject {
  4112. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4113. total = total + (subItem.Price * cnt)
  4114. }
  4115. }
  4116. }
  4117. for _, item := range prescriptions {
  4118. for _, subItem := range item.HisAdditionalCharge {
  4119. total = total + (subItem.Price * float64(subItem.Count))
  4120. }
  4121. }
  4122. var allTotal string
  4123. if adminUser.CurrentOrgId == 9919 {
  4124. allTotal = fmt.Sprintf("%.4f", total)
  4125. } else {
  4126. allTotal = fmt.Sprintf("%.4f", total)
  4127. }
  4128. if res.Infcode == 0 {
  4129. var rf []*ResultFive
  4130. json.Unmarshal([]byte(his.Iinfo), &rf)
  4131. chrg_bchno := chrg_bchno
  4132. cert_no := his.Certno
  4133. var insutypes []string
  4134. var insutype string
  4135. var is390 int = 0
  4136. var is310 int = 0
  4137. for _, item := range rf {
  4138. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4139. insutypes = append(insutypes, item.Insutype)
  4140. }
  4141. }
  4142. if len(insutypes) == 1 {
  4143. insutype = insutypes[0]
  4144. } else {
  4145. for _, i := range insutypes {
  4146. if i == "390" {
  4147. is390 = 1
  4148. }
  4149. if i == "310" {
  4150. is310 = 1
  4151. }
  4152. }
  4153. }
  4154. if is390 == 1 {
  4155. insutype = "390"
  4156. }
  4157. if is310 == 1 {
  4158. insutype = "310"
  4159. }
  4160. if len(insutypes) == 0 {
  4161. insutype = "310"
  4162. }
  4163. if len(insutypes) == 2 {
  4164. insutype = strconv.FormatInt(his.SocialType, 10)
  4165. }
  4166. insutype = strconv.FormatInt(his.SocialType, 10)
  4167. //insutype = "390"
  4168. if his.IdCardType == 1 {
  4169. // cert_no = his.MedicalInsuranceNumber
  4170. cert_no = his.Certno
  4171. } else {
  4172. cert_no = his.Certno
  4173. }
  4174. var res ResultSeven
  4175. var resSeven10265 ResultSeven10265
  4176. var src_resquest string
  4177. var result2 string
  4178. var acct_used_flag string
  4179. fmt.Println("pay_way")
  4180. fmt.Println(pay_way)
  4181. fmt.Println("pay_way")
  4182. if pay_way == 4 {
  4183. acct_used_flag = "1"
  4184. } else {
  4185. acct_used_flag = "0"
  4186. }
  4187. if miConfig.MdtrtareaAdmvs == "421300" {
  4188. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4189. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4190. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4191. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4192. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4193. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4194. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4195. resp, requestErr := http.Get(api)
  4196. if requestErr != nil {
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. body, ioErr := ioutil.ReadAll(resp.Body)
  4201. if ioErr != nil {
  4202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. return
  4205. }
  4206. var respJSON map[string]interface{}
  4207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4210. return
  4211. }
  4212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4213. result, _ := json.Marshal(respJSON)
  4214. if miConfig.Code == "H15049901371" {
  4215. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4216. utils.ErrorLog("解析失败:%v", err)
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. return
  4219. }
  4220. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4221. res.Output = resSeven10265.Output
  4222. res.ErrMsg = resSeven10265.ErrMsg
  4223. res.Cainfo = resSeven10265.Cainfo
  4224. res.WarnMsg = resSeven10265.WarnMsg
  4225. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4226. res.Infcode = infocode
  4227. } else {
  4228. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4229. utils.ErrorLog("解析失败:%v", err)
  4230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4231. return
  4232. }
  4233. }
  4234. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4235. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4236. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4237. //psn_info, _ := service.GetPsnByPatientId(id)
  4238. bas := strings.Split(psn_info.CardInfo, "|")
  4239. if his.IdCardType == 1 {
  4240. cert_no = bas[2]
  4241. } else {
  4242. cert_no = bas[1]
  4243. }
  4244. //江苏地区国家医保医疗类别
  4245. //职工透析:医疗类别选特殊情况门诊9933
  4246. //居民血透门慢: 医疗类别选门诊慢病1402
  4247. //var med_type string
  4248. //if his.Insutype == "310" {
  4249. // if reg_type == 14 {
  4250. // med_type = "9933"
  4251. // } else if reg_type == 11 {
  4252. // med_type = "11"
  4253. //
  4254. // }
  4255. //} else if his.Insutype == "390" {
  4256. // if reg_type == 14 {
  4257. // med_type = "1402"
  4258. // } else if reg_type == 11 {
  4259. // med_type = "11"
  4260. // }
  4261. //}
  4262. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4263. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4264. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4265. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4266. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4267. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4268. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4269. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4270. resp, requestErr := http.Get(api)
  4271. if requestErr != nil {
  4272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4273. return
  4274. }
  4275. body, ioErr := ioutil.ReadAll(resp.Body)
  4276. if ioErr != nil {
  4277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4279. return
  4280. }
  4281. var respJSON map[string]interface{}
  4282. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4285. return
  4286. }
  4287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4288. result, _ := json.Marshal(respJSON)
  4289. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4290. utils.ErrorLog("解析失败:%v", err)
  4291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4292. return
  4293. }
  4294. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4295. res.Output = resSeven10265.Output
  4296. res.ErrMsg = resSeven10265.ErrMsg
  4297. res.Cainfo = resSeven10265.Cainfo
  4298. res.WarnMsg = resSeven10265.WarnMsg
  4299. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4300. res.Infcode = infocode
  4301. } else {
  4302. if miConfig.Code == "H15049901371" {
  4303. //赤峰地区国家医保医疗类别
  4304. //职工透析:医疗类别选特殊情况门诊990502
  4305. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4306. var med_type string
  4307. if his.Insutype == "390" {
  4308. if reg_type == 14 {
  4309. med_type = "9933"
  4310. } else if reg_type == 11 {
  4311. med_type = "11"
  4312. }
  4313. } else if his.Insutype == "310" {
  4314. if reg_type == 14 {
  4315. med_type = "990502"
  4316. } else if reg_type == 11 {
  4317. med_type = "11"
  4318. }
  4319. }
  4320. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4321. } else {
  4322. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.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)
  4323. }
  4324. //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)
  4325. var dat map[string]interface{}
  4326. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4327. fmt.Println(dat)
  4328. } else {
  4329. fmt.Println(err)
  4330. }
  4331. saveLog(result2, src_resquest, "2207", "结算")
  4332. userJSONBytes, _ := json.Marshal(dat)
  4333. if miConfig.Code == "H15049901371" {
  4334. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4335. utils.ErrorLog("解析失败:%v", err)
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. return
  4338. }
  4339. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4340. res.Output = resSeven10265.Output
  4341. res.ErrMsg = resSeven10265.ErrMsg
  4342. res.Cainfo = resSeven10265.Cainfo
  4343. res.WarnMsg = resSeven10265.WarnMsg
  4344. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4345. res.Infcode = infocode
  4346. } else {
  4347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. }
  4353. }
  4354. if res.Infcode != 0 {
  4355. errlog := &models.HisOrderError{
  4356. UserOrgId: adminUser.CurrentOrgId,
  4357. Ctime: time.Now().Unix(),
  4358. Mtime: time.Now().Unix(),
  4359. Number: chrg_bchno,
  4360. ErrMsg: res.ErrMsg,
  4361. Status: 1,
  4362. PatientId: id,
  4363. RecordTime: recordDateTime,
  4364. Stage: 6,
  4365. }
  4366. service.CreateErrMsgLog(errlog)
  4367. c.ServeSuccessJSON(map[string]interface{}{
  4368. "failed_code": -10,
  4369. "msg": res.ErrMsg,
  4370. })
  4371. return
  4372. } else {
  4373. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4374. order.OrderStatus = 2
  4375. order.Status = 1
  4376. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4377. order.SetlId = res.Output.Setlinfo.SetlID
  4378. order.PsnNo = res.Output.Setlinfo.PsnNo
  4379. order.PsnName = res.Output.Setlinfo.PsnName
  4380. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4381. order.Certno = res.Output.Setlinfo.Certno
  4382. order.Gend = res.Output.Setlinfo.Gend
  4383. order.Naty = res.Output.Setlinfo.Naty
  4384. order.Age = res.Output.Setlinfo.Age
  4385. order.Insutype = res.Output.Setlinfo.Insutype
  4386. order.PsnType = res.Output.Setlinfo.PsnType
  4387. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4388. order.SetlTime = res.Output.Setlinfo.SetlTime
  4389. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4390. if res.Output.Setlinfo.MedType == "140101" {
  4391. order.MedType = "14"
  4392. } else {
  4393. order.MedType = res.Output.Setlinfo.MedType
  4394. }
  4395. if reg_type == 1112 {
  4396. order.MedType = "1112"
  4397. }
  4398. if reg_type == 1111 {
  4399. order.MedType = "1111"
  4400. }
  4401. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4402. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4403. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4404. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4405. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4406. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4407. order.HifpPay = res.Output.Setlinfo.HifpPay
  4408. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4409. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4410. order.HifesPay = res.Output.Setlinfo.HifesPay
  4411. order.HifobPay = res.Output.Setlinfo.HifobPay
  4412. order.MafPay = res.Output.Setlinfo.MafPay
  4413. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4414. order.OthPay = res.Output.Setlinfo.OthPay
  4415. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4416. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4417. order.AcctPay = res.Output.Setlinfo.AcctPay
  4418. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4419. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4420. order.Balc = res.Output.Setlinfo.Balc
  4421. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4422. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4423. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4424. order.ClrType = res.Output.Setlinfo.ClrType
  4425. order.ClrWay = res.Output.Setlinfo.ClrWay
  4426. order.Creator = order.Creator
  4427. order.Modify = roles.AdminUserId
  4428. order.RequestLog = src_resquest
  4429. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4430. detailStr := string(setlDetail)
  4431. order.SetlDetail = detailStr
  4432. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4433. err = service.UpDateOrder(order)
  4434. if err == nil {
  4435. c.ServeSuccessJSON(map[string]interface{}{
  4436. "msg": "结算成功",
  4437. })
  4438. } else {
  4439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4440. return
  4441. }
  4442. }
  4443. } else {
  4444. adminUser := c.GetAdminUserInfo()
  4445. errlog := &models.HisOrderError{
  4446. UserOrgId: adminUser.CurrentOrgId,
  4447. Ctime: time.Now().Unix(),
  4448. Mtime: time.Now().Unix(),
  4449. ErrMsg: res.ErrMsg,
  4450. Status: 1,
  4451. PatientId: id,
  4452. RecordTime: recordDateTime,
  4453. Stage: 4,
  4454. }
  4455. service.CreateErrMsgLog(errlog)
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4457. return
  4458. }
  4459. } else {
  4460. adminUser := c.GetAdminUserInfo()
  4461. errlog := &models.HisOrderError{
  4462. UserOrgId: adminUser.CurrentOrgId,
  4463. Ctime: time.Now().Unix(),
  4464. Mtime: time.Now().Unix(),
  4465. ErrMsg: res.ErrMsg,
  4466. Status: 1,
  4467. PatientId: id,
  4468. RecordTime: recordDateTime,
  4469. Stage: 4,
  4470. }
  4471. service.CreateErrMsgLog(errlog)
  4472. c.ServeSuccessJSON(map[string]interface{}{
  4473. "failed_code": -10,
  4474. "msg": res.ErrMsg,
  4475. })
  4476. return
  4477. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4478. //return
  4479. }
  4480. }
  4481. }
  4482. } else if tempOrder.ID > 0 {
  4483. if tempOrder.IsPre == 1 {
  4484. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4485. var rf []*ResultFive
  4486. json.Unmarshal([]byte(his.Iinfo), &rf)
  4487. chrg_bchno := tempOrder.Number
  4488. cert_no := his.Certno
  4489. var insutypes []string
  4490. var insutype string
  4491. var is390 int = 0
  4492. var is310 int = 0
  4493. for _, item := range rf {
  4494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4495. insutypes = append(insutypes, item.Insutype)
  4496. }
  4497. }
  4498. if len(insutypes) == 1 {
  4499. insutype = insutypes[0]
  4500. } else {
  4501. for _, i := range insutypes {
  4502. if i == "390" {
  4503. is390 = 1
  4504. }
  4505. if i == "310" {
  4506. is310 = 1
  4507. }
  4508. }
  4509. }
  4510. if is390 == 1 {
  4511. insutype = "390"
  4512. }
  4513. if is310 == 1 {
  4514. insutype = "310"
  4515. }
  4516. if len(insutypes) == 0 {
  4517. insutype = "310"
  4518. }
  4519. if len(insutypes) == 2 {
  4520. insutype = strconv.FormatInt(his.SocialType, 64)
  4521. }
  4522. //insutype = "390"
  4523. if his.IdCardType == 1 {
  4524. // cert_no = his.MedicalInsuranceNumber
  4525. cert_no = his.Certno
  4526. } else {
  4527. cert_no = his.Certno
  4528. }
  4529. var res ResultSeven
  4530. var resSeven10265 ResultSeven10265
  4531. var src_resquest string
  4532. var result2 string
  4533. var acct_used_flag string
  4534. fmt.Println("pay_way")
  4535. fmt.Println(pay_way)
  4536. fmt.Println("pay_way")
  4537. if pay_way == 4 {
  4538. acct_used_flag = "1"
  4539. } else {
  4540. acct_used_flag = "0"
  4541. }
  4542. if miConfig.MdtrtareaAdmvs == "421300" {
  4543. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4544. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4545. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4547. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4548. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4549. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4550. resp, requestErr := http.Get(api)
  4551. if requestErr != nil {
  4552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4553. return
  4554. }
  4555. body, ioErr := ioutil.ReadAll(resp.Body)
  4556. if ioErr != nil {
  4557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4559. return
  4560. }
  4561. var respJSON map[string]interface{}
  4562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4565. return
  4566. }
  4567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4568. result, _ := json.Marshal(respJSON)
  4569. fmt.Println("log")
  4570. fmt.Println(string(result))
  4571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4572. utils.ErrorLog("解析失败:%v", err)
  4573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4574. return
  4575. }
  4576. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4577. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4578. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4579. //psn_info, _ := service.GetPsnByPatientId(id)
  4580. bas := strings.Split(psn_info.CardInfo, "|")
  4581. if his.IdCardType == 1 {
  4582. cert_no = bas[2]
  4583. } else {
  4584. cert_no = bas[1]
  4585. }
  4586. //江苏地区国家医保医疗类别
  4587. //职工透析:医疗类别选特殊情况门诊9933
  4588. //居民血透门慢: 医疗类别选门诊慢病1402
  4589. //var med_type string
  4590. //if his.Insutype == "310" {
  4591. // if reg_type == 14 {
  4592. // med_type = "9933"
  4593. // } else if reg_type == 11 {
  4594. // med_type = "11"
  4595. //
  4596. // }
  4597. //} else if his.Insutype == "390" {
  4598. // if reg_type == 14 {
  4599. // med_type = "1402"
  4600. // } else if reg_type == 11 {
  4601. // med_type = "11"
  4602. // }
  4603. //}
  4604. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4605. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4606. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4607. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4608. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4609. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4610. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4611. resp, requestErr := http.Get(api)
  4612. if requestErr != nil {
  4613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4614. return
  4615. }
  4616. body, ioErr := ioutil.ReadAll(resp.Body)
  4617. if ioErr != nil {
  4618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4620. return
  4621. }
  4622. var respJSON map[string]interface{}
  4623. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4626. return
  4627. }
  4628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4629. result, _ := json.Marshal(respJSON)
  4630. fmt.Println("log")
  4631. fmt.Println(string(result))
  4632. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4633. utils.ErrorLog("解析失败:%v", err)
  4634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4635. return
  4636. }
  4637. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4638. res.Output = resSeven10265.Output
  4639. res.ErrMsg = resSeven10265.ErrMsg
  4640. res.Cainfo = resSeven10265.Cainfo
  4641. res.WarnMsg = resSeven10265.WarnMsg
  4642. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4643. res.Infcode = infocode
  4644. } else {
  4645. var src_resquest string
  4646. if miConfig.Code == "H15049901371" {
  4647. //赤峰地区国家医保医疗类别
  4648. //职工透析:医疗类别选特殊情况门诊990502
  4649. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4650. var med_type string
  4651. if his.Insutype == "390" {
  4652. if reg_type == 14 {
  4653. med_type = "9933"
  4654. } else if reg_type == 11 {
  4655. med_type = "11"
  4656. }
  4657. } else if his.Insutype == "310" {
  4658. if reg_type == 14 {
  4659. med_type = "990502"
  4660. } else if reg_type == 11 {
  4661. med_type = "11"
  4662. }
  4663. }
  4664. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4665. } else {
  4666. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.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)
  4667. }
  4668. var dat map[string]interface{}
  4669. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4670. fmt.Println(dat)
  4671. } else {
  4672. fmt.Println(err)
  4673. }
  4674. saveLog(result2, src_resquest, "2207", "结算")
  4675. userJSONBytes, _ := json.Marshal(dat)
  4676. if miConfig.Code == "H15049901371" {
  4677. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4678. utils.ErrorLog("解析失败:%v", err)
  4679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. return
  4681. }
  4682. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4683. res.Output = resSeven10265.Output
  4684. res.ErrMsg = resSeven10265.ErrMsg
  4685. res.Cainfo = resSeven10265.Cainfo
  4686. res.WarnMsg = resSeven10265.WarnMsg
  4687. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4688. res.Infcode = infocode
  4689. } else {
  4690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4691. utils.ErrorLog("解析失败:%v", err)
  4692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4693. return
  4694. }
  4695. }
  4696. }
  4697. if res.Infcode != 0 {
  4698. errlog := &models.HisOrderError{
  4699. UserOrgId: adminUser.CurrentOrgId,
  4700. Ctime: time.Now().Unix(),
  4701. Mtime: time.Now().Unix(),
  4702. Number: chrg_bchno,
  4703. ErrMsg: res.ErrMsg,
  4704. Status: 1,
  4705. PatientId: id,
  4706. RecordTime: recordDateTime,
  4707. Stage: 6,
  4708. }
  4709. service.CreateErrMsgLog(errlog)
  4710. c.ServeSuccessJSON(map[string]interface{}{
  4711. "failed_code": -10,
  4712. "msg": res.ErrMsg,
  4713. })
  4714. return
  4715. } else {
  4716. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4717. order.OrderStatus = 2
  4718. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4719. order.SetlId = res.Output.Setlinfo.SetlID
  4720. order.PsnNo = res.Output.Setlinfo.PsnNo
  4721. order.PsnName = res.Output.Setlinfo.PsnName
  4722. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4723. order.Certno = res.Output.Setlinfo.Certno
  4724. order.Gend = res.Output.Setlinfo.Gend
  4725. order.Naty = res.Output.Setlinfo.Naty
  4726. order.Age = res.Output.Setlinfo.Age
  4727. order.Insutype = res.Output.Setlinfo.Insutype
  4728. order.PsnType = res.Output.Setlinfo.PsnType
  4729. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4730. order.SetlTime = res.Output.Setlinfo.SetlTime
  4731. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4732. //order.MedType = res.Output.Setlinfo.MedType
  4733. if reg_type == 1112 {
  4734. order.MedType = "1112"
  4735. }
  4736. if reg_type == 1111 {
  4737. order.MedType = "1111"
  4738. }
  4739. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4740. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4741. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4742. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4743. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4744. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4745. order.HifpPay = res.Output.Setlinfo.HifpPay
  4746. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4747. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4748. order.HifesPay = res.Output.Setlinfo.HifesPay
  4749. order.HifobPay = res.Output.Setlinfo.HifobPay
  4750. order.MafPay = res.Output.Setlinfo.MafPay
  4751. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4752. order.OthPay = res.Output.Setlinfo.OthPay
  4753. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4754. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4755. order.AcctPay = res.Output.Setlinfo.AcctPay
  4756. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4757. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4758. order.Balc = res.Output.Setlinfo.Balc
  4759. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4760. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4761. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4762. order.ClrWay = res.Output.Setlinfo.ClrWay
  4763. order.Creator = order.Creator
  4764. order.Modify = roles.AdminUserId
  4765. order.RequestLog = src_resquest
  4766. order.Diagnosis = diagnosis_id
  4767. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4768. detailStr := string(setlDetail)
  4769. order.SetlDetail = detailStr
  4770. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4771. err = service.UpDateOrder(order)
  4772. if err == nil {
  4773. c.ServeSuccessJSON(map[string]interface{}{
  4774. "msg": "结算成功",
  4775. })
  4776. } else {
  4777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4778. return
  4779. }
  4780. }
  4781. }
  4782. }
  4783. }
  4784. //func (c *HisApiController) GetPreUploadInfo() {
  4785. // id, _ := c.GetInt64("id")
  4786. // record_time := c.GetString("record_time")
  4787. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4788. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4789. //
  4790. // timeLayout := "2006-01-02"
  4791. // loc, _ := time.LoadLocation("Local")
  4792. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4793. // if err != nil {
  4794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4795. // return
  4796. // }
  4797. // recordDateTime := theTime.Unix()
  4798. // adminUser := c.GetAdminUserInfo()
  4799. //
  4800. // var prescriptions []*models.HisPrescription
  4801. //
  4802. // var start_time int64
  4803. // var end_time int64
  4804. //
  4805. // data := make(map[string]interface{})
  4806. // if settle_accounts_type == 1 { //日结
  4807. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4808. // data["pre"] = prescriptions
  4809. //
  4810. // } else { //月结
  4811. // start_time_str := c.GetString("start_time")
  4812. // end_time_str := c.GetString("end_time")
  4813. // timeLayout := "2006-01-02"
  4814. // loc, _ := time.LoadLocation("Local")
  4815. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4816. // if err != nil {
  4817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4818. // return
  4819. // }
  4820. // recordStartTime := theStartTime.Unix()
  4821. // start_time = recordStartTime
  4822. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4823. // if err != nil {
  4824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4825. // return
  4826. // }
  4827. // recordEndTime := theEndTime.Unix()
  4828. // end_time = recordEndTime
  4829. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4830. // data["pre"] = prescriptions
  4831. //
  4832. // }
  4833. //
  4834. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4835. //
  4836. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4837. // timestamp := time.Now().Unix()
  4838. // tempTime := time.Unix(timestamp, 0)
  4839. // timeFormat := tempTime.Format("20060102150405")
  4840. // chrgBchno := rand.Intn(100000) + 10000
  4841. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4842. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4843. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4844. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4845. // strconv.FormatInt(his.PatientId, 10)
  4846. // client := &http.Client{}
  4847. // data["psn_no"] = his.PsnNo
  4848. // data["mdtrt_id"] = his.Number
  4849. // data["chrg_bchno"] = chrg_bchno
  4850. // data["org_name"] = miConfig.OrgName
  4851. // data["doctor"] = roles.UserName
  4852. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4853. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4854. // data["fixmedins_code"] = miConfig.Code
  4855. // data["dept_code"] = department.Number
  4856. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4857. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4858. // data["secret_key"] = miConfig.SecretKey
  4859. // var ids []int64
  4860. //
  4861. // for _, item := range prescriptions {
  4862. // ids = append(ids, item.ID)
  4863. // }
  4864. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4865. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4866. // bytesData, _ := json.Marshal(data)
  4867. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4868. // resp, _ := client.Do(req)
  4869. // defer resp.Body.Close()
  4870. // body, ioErr := ioutil.ReadAll(resp.Body)
  4871. // if ioErr != nil {
  4872. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4874. // return
  4875. // }
  4876. // var respJSON map[string]interface{}
  4877. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4878. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4880. // return
  4881. // }
  4882. //
  4883. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4884. // userJSONBytes, _ := json.Marshal(respJSON)
  4885. // var res ResultFour
  4886. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4887. // utils.ErrorLog("解析失败:%v", err)
  4888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4889. // return
  4890. // }
  4891. //
  4892. // if res.Infcode == 0 {
  4893. // order := &models.HisOrder{
  4894. // UserOrgId: adminUser.CurrentOrgId,
  4895. // HisPatientId: his.ID,
  4896. // PatientId: his.PatientId,
  4897. // SettleAccountsDate: recordDateTime,
  4898. // Ctime: time.Now().Unix(),
  4899. // Mtime: time.Now().Unix(),
  4900. // Status: 1,
  4901. // Number: chrg_bchno,
  4902. // Infcode: res.Infcode,
  4903. // WarnMsg: res.WarnMsg,
  4904. // Cainfo: res.Cainfo,
  4905. // ErrMsg: res.ErrMsg,
  4906. // RespondTime: res.RefmsgTime,
  4907. // InfRefmsgid: res.InfRefmsgid,
  4908. // OrderStatus: 1,
  4909. // IsMedicineInsurance: 1,
  4910. // SettleType: settle_accounts_type,
  4911. // SettleStartTime: start_time,
  4912. // SettleEndTime: end_time,
  4913. // Creator: roles.ID,
  4914. // Modify: roles.ID,
  4915. // PType: 2,
  4916. // }
  4917. // err = service.CreateOrder(order)
  4918. // if err != nil {
  4919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4920. // return
  4921. // }
  4922. //
  4923. // for _, item := range res.Output.Result {
  4924. // temp := strings.Split(item.FeedetlSn, "-")
  4925. // var advice_id int64 = 0
  4926. // var project_id int64 = 0
  4927. // var types int64 = 0
  4928. //
  4929. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4930. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4931. //
  4932. // if temp[1] == "1" {
  4933. // advice_id = id
  4934. // project_id = 0
  4935. // } else if temp[1] == "2" {
  4936. // advice_id = 0
  4937. // project_id = id
  4938. // }
  4939. //
  4940. // info := &models.HisOrderInfo{
  4941. // OrderNumber: order.Number,
  4942. // FeedetlSn: item.FeedetlSn,
  4943. // UploadDate: time.Now().Unix(),
  4944. // AdviceId: advice_id,
  4945. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4946. // Cnt: item.Cnt,
  4947. // Pric: float64(item.Pric),
  4948. // PatientId: his.PatientId,
  4949. // PricUplmtAmt: item.PricUplmtAmt,
  4950. // SelfpayProp: item.SelfpayProp,
  4951. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4952. // OverlmtAmt: item.OverlmtAmt,
  4953. // PreselfpayAmt: item.PreselfpayAmt,
  4954. // BasMednFlag: item.BasMednFlag,
  4955. // MedChrgitmType: item.MedChrgitmType,
  4956. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4957. // Status: 1,
  4958. // Memo: item.Memo,
  4959. // Mtime: time.Now().Unix(),
  4960. // InscpScpAmt: item.InscpScpAmt,
  4961. // DrtReimFlag: item.DrtReimFlag,
  4962. // Ctime: time.Now().Unix(),
  4963. // ListSpItemFlag: item.ListSpItemFlag,
  4964. // ChldMedcFlag: item.ChldMedcFlag,
  4965. // LmtUsedFlag: item.LmtUsedFlag,
  4966. // ChrgitmLv: item.ChrgitmLv,
  4967. // UserOrgId: adminUser.CurrentOrgId,
  4968. // HisPatientId: his.ID,
  4969. // OrderId: order.ID,
  4970. // ProjectId: project_id,
  4971. // Type: types,
  4972. // }
  4973. // service.CreateOrderInfo(info)
  4974. //
  4975. // }
  4976. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4977. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4978. //
  4979. // var total float64
  4980. // for _, item := range prescriptions {
  4981. // if item.Type == 1 { //药品
  4982. // for _, subItem := range item.HisDoctorAdviceInfo {
  4983. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4984. // }
  4985. // }
  4986. // if item.Type == 2 { //项目
  4987. // for _, subItem := range item.HisPrescriptionProject {
  4988. // total = total + (subItem.Price * float64(subItem.Count))
  4989. // }
  4990. // }
  4991. // }
  4992. //
  4993. // for _, item := range prescriptions {
  4994. // for _, subItem := range item.HisAdditionalCharge {
  4995. // total = total + (subItem.Price * float64(subItem.Count))
  4996. // }
  4997. // }
  4998. //
  4999. // allTotal := fmt.Sprintf("%.2f", total)
  5000. // if res.Infcode == 0 {
  5001. // var rf []*ResultFive
  5002. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5003. // psn_no := his.PsnNo
  5004. // mdtrt_id := his.Number
  5005. // chrg_bchno := chrg_bchno
  5006. // cert_no := his.Certno
  5007. // insutype := rf[0].Insutype
  5008. //
  5009. // if his.IdCardType == 1 {
  5010. // cert_no = his.MedicalInsuranceNumber
  5011. //
  5012. // } else {
  5013. //
  5014. // cert_no = his.Certno
  5015. //
  5016. // }
  5017. //
  5018. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5019. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5020. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5021. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5022. // resp, requestErr := http.Get(api)
  5023. // if requestErr != nil {
  5024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. // return
  5026. // }
  5027. // defer resp.Body.Close()
  5028. // body, ioErr := ioutil.ReadAll(resp.Body)
  5029. // if ioErr != nil {
  5030. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5032. // return
  5033. // }
  5034. // var respJSON map[string]interface{}
  5035. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5036. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5037. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5038. // return
  5039. // }
  5040. // fmt.Println(respJSON)
  5041. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5042. // userJSONBytes, _ := json.Marshal(respJSON)
  5043. // var res ResultSeven
  5044. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5045. // utils.ErrorLog("解析失败:%v", err)
  5046. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5047. // return
  5048. // }
  5049. // if res.Infcode != 0 {
  5050. // errlog := &models.HisOrderError{
  5051. // UserOrgId: adminUser.CurrentOrgId,
  5052. // Ctime: time.Now().Unix(),
  5053. // Mtime: time.Now().Unix(),
  5054. // Number: chrg_bchno,
  5055. // ErrMsg: res.ErrMsg,
  5056. // Status: 1,
  5057. // PatientId: id,
  5058. // RecordTime: recordDateTime,
  5059. // Stage: 7,
  5060. // }
  5061. // service.CreateErrMsgLog(errlog)
  5062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5063. // return
  5064. // } else {
  5065. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5066. // order.OrderStatus = 1
  5067. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5068. // order.SetlId = res.Output.Setlinfo.SetlID
  5069. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5070. // order.PsnName = res.Output.Setlinfo.PsnName
  5071. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5072. // order.Certno = res.Output.Setlinfo.Certno
  5073. // order.Gend = res.Output.Setlinfo.Gend
  5074. // order.Naty = res.Output.Setlinfo.Naty
  5075. // order.Age = res.Output.Setlinfo.Age
  5076. // order.Insutype = res.Output.Setlinfo.Insutype
  5077. // order.PsnType = res.Output.Setlinfo.PsnType
  5078. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5079. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5080. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5081. // order.MedType = res.Output.Setlinfo.MedType
  5082. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5083. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5084. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5085. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5086. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5087. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5088. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5089. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5090. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5091. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5092. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5093. // order.MafPay = res.Output.Setlinfo.MafPay
  5094. // order.OthPay = res.Output.Setlinfo.OthPay
  5095. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5096. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5097. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5098. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5099. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5100. // order.Balc = res.Output.Setlinfo.Balc
  5101. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5102. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5103. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5104. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5105. // order.Creator = order.Creator
  5106. // order.Modify = roles.ID
  5107. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5108. // detailStr := string(setlDetail)
  5109. // order.SetlDetail = detailStr
  5110. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5111. // err = service.UpDateOrder(order)
  5112. // if err == nil {
  5113. // c.ServeSuccessJSON(map[string]interface{}{
  5114. // "msg": "预结算成功",
  5115. // })
  5116. // } else {
  5117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5118. // return
  5119. // }
  5120. // }
  5121. // } else {
  5122. // adminUser := c.GetAdminUserInfo()
  5123. // errlog := &models.HisOrderError{
  5124. // UserOrgId: adminUser.CurrentOrgId,
  5125. // Ctime: time.Now().Unix(),
  5126. // Mtime: time.Now().Unix(),
  5127. // ErrMsg: res.ErrMsg,
  5128. // Status: 1,
  5129. // PatientId: id,
  5130. // RecordTime: recordDateTime,
  5131. // Stage: 4,
  5132. // }
  5133. // service.CreateErrMsgLog(errlog)
  5134. //
  5135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5136. // return
  5137. // }
  5138. // } else {
  5139. // adminUser := c.GetAdminUserInfo()
  5140. // errlog := &models.HisOrderError{
  5141. // UserOrgId: adminUser.CurrentOrgId,
  5142. // Ctime: time.Now().Unix(),
  5143. // Mtime: time.Now().Unix(),
  5144. // ErrMsg: res.ErrMsg,
  5145. // Status: 1,
  5146. // PatientId: id,
  5147. // RecordTime: recordDateTime,
  5148. // Stage: 4,
  5149. // }
  5150. // service.CreateErrMsgLog(errlog)
  5151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5152. // return
  5153. // }
  5154. //
  5155. // } else {
  5156. // var total float64
  5157. // for _, item := range prescriptions {
  5158. // if item.Type == 1 { //药品
  5159. // for _, subItem := range item.HisDoctorAdviceInfo {
  5160. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5161. // }
  5162. // }
  5163. // if item.Type == 2 { //项目
  5164. // for _, subItem := range item.HisPrescriptionProject {
  5165. // total = total + (subItem.Price * float64(subItem.Count))
  5166. // }
  5167. // }
  5168. //
  5169. // for _, subItem := range item.HisAdditionalCharge {
  5170. // total = total + (subItem.Price * float64(subItem.Count))
  5171. // }
  5172. // }
  5173. //
  5174. // allTotal := fmt.Sprintf("%.2f", total)
  5175. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5176. // order := &models.HisOrder{
  5177. // UserOrgId: adminUser.CurrentOrgId,
  5178. // HisPatientId: his.ID,
  5179. // PatientId: id,
  5180. // SettleAccountsDate: recordDateTime,
  5181. // Ctime: time.Now().Unix(),
  5182. // Mtime: time.Now().Unix(),
  5183. // Status: 1,
  5184. // OrderStatus: 2,
  5185. // Number: chrg_bchno,
  5186. // MedfeeSumamt: totals,
  5187. // }
  5188. // err = service.CreateOrder(order)
  5189. // if err != nil {
  5190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5191. // return
  5192. // }
  5193. //
  5194. // var customs []*Custom
  5195. // for _, item := range prescriptions {
  5196. //
  5197. // if item.Type == 1 { //药品
  5198. // for _, subItem := range item.HisDoctorAdviceInfo {
  5199. // cus := &Custom{
  5200. // AdviceId: subItem.ID,
  5201. // ProjectId: 0,
  5202. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5203. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5204. // FeedetlSn: subItem.FeedetlSn,
  5205. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5206. // MedListCodg: subItem.MedListCodg,
  5207. // Type: 1,
  5208. // }
  5209. // customs = append(customs, cus)
  5210. // }
  5211. // }
  5212. //
  5213. // if item.Type == 2 { //项目
  5214. // for _, subItem := range item.HisPrescriptionProject {
  5215. //
  5216. // cus := &Custom{
  5217. // AdviceId: 0,
  5218. // ProjectId: subItem.ID,
  5219. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5220. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5221. // FeedetlSn: subItem.FeedetlSn,
  5222. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5223. // MedListCodg: subItem.MedListCodg,
  5224. // Type: 2,
  5225. // }
  5226. //
  5227. // customs = append(customs, cus)
  5228. // }
  5229. // }
  5230. //
  5231. // for _, item := range item.HisAdditionalCharge {
  5232. // cus := &Custom{
  5233. // ItemId: item.ID,
  5234. // AdviceId: 0,
  5235. // ProjectId: 0,
  5236. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5237. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5238. // FeedetlSn: item.FeedetlSn,
  5239. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5240. // MedListCodg: item.XtHisAddtionConfig.Code,
  5241. // Type: 3,
  5242. // }
  5243. //
  5244. // customs = append(customs, cus)
  5245. // }
  5246. //
  5247. // }
  5248. //
  5249. // for _, item := range customs {
  5250. // var advice_id int64 = 0
  5251. // var project_id int64 = 0
  5252. // var item_id int64 = 0
  5253. //
  5254. // var types int64 = 0
  5255. //
  5256. // if item.Type == 1 {
  5257. // advice_id = item.AdviceId
  5258. // project_id = 0
  5259. // item_id = 0
  5260. // } else if item.Type == 2 {
  5261. // advice_id = 0
  5262. // item_id = 0
  5263. //
  5264. // project_id = item.ProjectId
  5265. // } else if item.Type == 3 {
  5266. // advice_id = 0
  5267. // item_id = item.ItemId
  5268. // project_id = 0
  5269. // }
  5270. //
  5271. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5272. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5273. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5274. //
  5275. // info := &models.HisOrderInfo{
  5276. // OrderNumber: order.Number,
  5277. // UploadDate: time.Now().Unix(),
  5278. // AdviceId: advice_id,
  5279. // DetItemFeeSumamt: detItemFeeSumamt,
  5280. // Cnt: cut,
  5281. // Pric: pric,
  5282. // PatientId: id,
  5283. // Status: 1,
  5284. // Mtime: time.Now().Unix(),
  5285. // Ctime: time.Now().Unix(),
  5286. // UserOrgId: adminUser.CurrentOrgId,
  5287. // HisPatientId: his.ID,
  5288. // OrderId: order.ID,
  5289. // ProjectId: project_id,
  5290. // Type: types,
  5291. // ItemId: item_id,
  5292. // }
  5293. // service.CreateOrderInfo(info)
  5294. // }
  5295. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5296. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5297. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5298. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5299. // if err == nil {
  5300. // c.ServeSuccessJSON(map[string]interface{}{
  5301. // "msg": "结算成功",
  5302. // })
  5303. // } else {
  5304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5305. // return
  5306. // }
  5307. // }
  5308. //}
  5309. //上传明细-预结算-
  5310. func (c *HisApiController) GetPreUploadInfo() {
  5311. id, _ := c.GetInt64("id")
  5312. record_time := c.GetString("record_time")
  5313. his_patient_id, _ := c.GetInt64("his_patient_id")
  5314. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5315. admin_user_id, _ := c.GetInt64("admin_user_id")
  5316. diagnosis_id := c.GetString("diagnosis")
  5317. sick_type, _ := c.GetInt64("sick_type")
  5318. reg_type, _ := c.GetInt64("p_type")
  5319. begin_time := c.GetString("begin_time")
  5320. id_str := c.GetString("ids")
  5321. ids_arr := strings.Split(id_str, ",")
  5322. timeLayout := "2006-01-02"
  5323. loc, _ := time.LoadLocation("Local")
  5324. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5325. if err != nil {
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5327. return
  5328. }
  5329. recordDateTime := theTime.Unix()
  5330. adminUser := c.GetAdminUserInfo()
  5331. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5332. var config []*models.HisXtDiagnoseConfig
  5333. for _, item := range diagnosis_ids {
  5334. id, _ := strconv.ParseInt(item, 10, 64)
  5335. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5336. config = append(config, &diagnosisConfig)
  5337. }
  5338. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5339. sickConfig, _ := service.FindSickById(sick_type)
  5340. var prescriptions []*models.HisPrescription
  5341. var start_time int64
  5342. var end_time int64
  5343. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5344. fmt.Println(his_patient_id)
  5345. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5346. timestamp := time.Now().Unix()
  5347. tempTime := time.Unix(timestamp, 0)
  5348. timeFormat := tempTime.Format("20060102150405")
  5349. chrgBchno := rand.Intn(100000) + 10000
  5350. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5351. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5352. var patientPrescription models.HisPrescriptionInfo
  5353. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5354. if patientPrescription.ID == 0 {
  5355. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5356. }
  5357. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5358. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5359. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5360. strconv.FormatInt(his.PatientId, 10)
  5361. var res2 ResultSix
  5362. var resSix10265 ResultSix10265
  5363. var time_stamp string
  5364. if miConfig.MdtrtareaAdmvs == "421300" {
  5365. data := make(map[string]interface{})
  5366. client := &http.Client{}
  5367. data["psn_no"] = his.PsnNo
  5368. data["mdtrt_id"] = his.Number
  5369. data["doctor"] = roles.UserName
  5370. data["department"] = department.Name
  5371. data["org_name"] = miConfig.OrgName
  5372. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5373. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5374. data["fixmedins_code"] = miConfig.Code
  5375. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5376. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5377. data["secret_key"] = miConfig.SecretKey
  5378. data["sick_code"] = sickConfig.CountryCode
  5379. data["sick_name"] = sickConfig.ClassName
  5380. data["begin_time"] = begin_time
  5381. data["dept"] = strconv.FormatInt(department.ID, 10)
  5382. data["config"] = config
  5383. fmt.Println(data)
  5384. bytesData, _ := json.Marshal(data)
  5385. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5386. resp, _ := client.Do(req)
  5387. defer resp.Body.Close()
  5388. body, ioErr := ioutil.ReadAll(resp.Body)
  5389. if ioErr != nil {
  5390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5392. return
  5393. }
  5394. var respJSON map[string]interface{}
  5395. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5398. return
  5399. }
  5400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5401. userJSONBytes, _ := json.Marshal(respJSON)
  5402. fmt.Println("log")
  5403. fmt.Println(string(userJSONBytes))
  5404. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5405. utils.ErrorLog("解析失败:%v", err)
  5406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5407. return
  5408. }
  5409. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5410. //江苏地区国家医保医疗类别
  5411. //职工透析:医疗类别选特殊情况门诊9933
  5412. //居民血透门慢: 医疗类别选门诊慢病1402
  5413. //var med_type string
  5414. //if his.Insutype == "310" {
  5415. // if reg_type == 14 {
  5416. // med_type = "9933"
  5417. // } else if reg_type == 11 {
  5418. // med_type = "11"
  5419. //
  5420. // }
  5421. //} else if his.Insutype == "390" {
  5422. // if reg_type == 14 {
  5423. // med_type = "1402"
  5424. // } else if reg_type == 11 {
  5425. // med_type = "11"
  5426. // }
  5427. //}
  5428. data := make(map[string]interface{})
  5429. client := &http.Client{}
  5430. data["psn_no"] = his.PsnNo
  5431. data["mdtrt_id"] = his.Number
  5432. data["doctor"] = roles.UserName
  5433. data["department"] = department.Name
  5434. data["org_name"] = miConfig.OrgName
  5435. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5436. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5437. data["fixmedins_code"] = miConfig.Code
  5438. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5439. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5440. data["secret_key"] = miConfig.SecretKey
  5441. data["sick_code"] = sickConfig.CountryCode
  5442. data["sick_name"] = sickConfig.ClassName
  5443. data["begin_time"] = begin_time
  5444. data["dept"] = strconv.FormatInt(department.ID, 10)
  5445. data["config"] = config
  5446. data["url"] = miConfig.Url
  5447. data["ak"] = miConfig.AccessKey
  5448. data["cainfo"] = miConfig.Cainfo
  5449. bytesData, _ := json.Marshal(data)
  5450. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5451. resp, _ := client.Do(req)
  5452. defer resp.Body.Close()
  5453. body, ioErr := ioutil.ReadAll(resp.Body)
  5454. if ioErr != nil {
  5455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5457. return
  5458. }
  5459. var respJSON map[string]interface{}
  5460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5463. return
  5464. }
  5465. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5466. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5467. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5469. userJSONBytes, _ := json.Marshal(respJSON)
  5470. fmt.Println("log")
  5471. fmt.Println(string(userJSONBytes))
  5472. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5473. utils.ErrorLog("解析失败:%v", err)
  5474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5475. return
  5476. }
  5477. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5478. res2.Output = resSix10265.Output
  5479. res2.ErrMsg = resSix10265.ErrMsg
  5480. res2.Cainfo = resSix10265.Cainfo
  5481. res2.WarnMsg = resSix10265.WarnMsg
  5482. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5483. res2.Infcode = infocode
  5484. } else {
  5485. var result string
  5486. var requestLog string
  5487. if miConfig.MdtrtareaAdmvs == "440781" { //
  5488. 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, begin_time)
  5489. } else {
  5490. if miConfig.Code == "H15049901371" {
  5491. //赤峰地区国家医保医疗类别
  5492. //职工透析:医疗类别选特殊情况门诊990502
  5493. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5494. var med_type string
  5495. if his.Insutype == "390" {
  5496. if reg_type == 14 {
  5497. med_type = "9933"
  5498. } else if reg_type == 11 {
  5499. med_type = "11"
  5500. }
  5501. } else if his.Insutype == "310" {
  5502. if reg_type == 14 {
  5503. med_type = "990502"
  5504. } else if reg_type == 11 {
  5505. med_type = "11"
  5506. }
  5507. }
  5508. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5509. } else {
  5510. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5511. }
  5512. saveLog(result, requestLog, "2203", "上传就诊信息")
  5513. var respJSON2 map[string]interface{}
  5514. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5517. return
  5518. }
  5519. userJSONBytes2, _ := json.Marshal(respJSON2)
  5520. if miConfig.Code == "H15049901371" {
  5521. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5522. utils.ErrorLog("解析失败:%v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5527. res2.Output = resSix10265.Output
  5528. res2.ErrMsg = resSix10265.ErrMsg
  5529. res2.Cainfo = resSix10265.Cainfo
  5530. res2.WarnMsg = resSix10265.WarnMsg
  5531. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5532. res2.Infcode = infocode
  5533. } else {
  5534. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5535. utils.ErrorLog("解析失败:%v", err)
  5536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5537. return
  5538. }
  5539. }
  5540. }
  5541. }
  5542. if res2.Infcode != 0 {
  5543. adminUser := c.GetAdminUserInfo()
  5544. errlog := &models.HisOrderError{
  5545. UserOrgId: adminUser.CurrentOrgId,
  5546. Ctime: time.Now().Unix(),
  5547. Mtime: time.Now().Unix(),
  5548. ErrMsg: res2.ErrMsg,
  5549. Status: 1,
  5550. PatientId: id,
  5551. RecordTime: recordDateTime,
  5552. Stage: 3,
  5553. }
  5554. service.CreateErrMsgLog(errlog)
  5555. c.ServeSuccessJSON(map[string]interface{}{
  5556. "failed_code": -10,
  5557. "msg": res2.ErrMsg,
  5558. })
  5559. return
  5560. } else {
  5561. his.Diagnosis = diagnosis_id
  5562. his.SickType = sickConfig.ID
  5563. his.PType = fmt.Sprintf("%d", reg_type)
  5564. service.UpdateHisPatientThree(&his)
  5565. data := make(map[string]interface{})
  5566. if settle_accounts_type == 1 { //日结
  5567. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5568. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5569. } else {
  5570. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5571. }
  5572. data["pre"] = prescriptions
  5573. } else { //月结
  5574. start_time_str := c.GetString("start_time")
  5575. end_time_str := c.GetString("end_time")
  5576. timeLayout := "2006-01-02"
  5577. loc, _ := time.LoadLocation("Local")
  5578. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5579. if err != nil {
  5580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5581. return
  5582. }
  5583. recordStartTime := theStartTime.Unix()
  5584. start_time = recordStartTime
  5585. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5586. if err != nil {
  5587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5588. return
  5589. }
  5590. recordEndTime := theEndTime.Unix()
  5591. end_time = recordEndTime
  5592. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5593. data["pre"] = prescriptions
  5594. }
  5595. client := &http.Client{}
  5596. data["psn_no"] = his.PsnNo
  5597. data["mdtrt_id"] = his.Number
  5598. data["chrg_bchno"] = chrg_bchno
  5599. data["org_name"] = miConfig.OrgName
  5600. data["doctor"] = roles.UserName
  5601. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5602. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5603. data["fixmedins_code"] = miConfig.Code
  5604. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5605. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5606. data["dept_code"] = "15"
  5607. } else {
  5608. data["dept_code"] = department.Number
  5609. }
  5610. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5611. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5612. data["secret_key"] = miConfig.SecretKey
  5613. data["url"] = miConfig.Url
  5614. data["ak"] = miConfig.AccessKey
  5615. data["new_doctor_name"] = patientPrescription.Doctor
  5616. data["diag_code"] = sickConfig.CountryCode
  5617. data["time_stamp"] = time_stamp
  5618. data["cainfo"] = miConfig.Cainfo
  5619. var ids []int64
  5620. for _, item := range prescriptions {
  5621. ids = append(ids, item.ID)
  5622. }
  5623. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5624. if config.IsOpen == 1 { //对接了医保,走医保流程
  5625. var res ResultFour
  5626. var resFour10265 ResultFour10265
  5627. if miConfig.MdtrtareaAdmvs == "421300" {
  5628. bytesData, _ := json.Marshal(data)
  5629. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5630. resp, _ := client.Do(req)
  5631. defer resp.Body.Close()
  5632. body, ioErr := ioutil.ReadAll(resp.Body)
  5633. if ioErr != nil {
  5634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5636. return
  5637. }
  5638. var respJSON map[string]interface{}
  5639. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5642. return
  5643. }
  5644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5645. userJSONBytes, _ := json.Marshal(respJSON)
  5646. fmt.Println("log")
  5647. fmt.Println(string(userJSONBytes))
  5648. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5649. utils.ErrorLog("解析失败:%v", err)
  5650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5651. return
  5652. }
  5653. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5654. bytesData, _ := json.Marshal(data)
  5655. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5656. resp, _ := client.Do(req)
  5657. defer resp.Body.Close()
  5658. body, ioErr := ioutil.ReadAll(resp.Body)
  5659. if ioErr != nil {
  5660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5662. return
  5663. }
  5664. var respJSON map[string]interface{}
  5665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5668. return
  5669. }
  5670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5671. userJSONBytes, _ := json.Marshal(respJSON)
  5672. fmt.Println("log")
  5673. fmt.Println(string(userJSONBytes))
  5674. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5675. utils.ErrorLog("解析失败:%v", err)
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. return
  5678. }
  5679. res.InfRefmsgid = resFour10265.InfRefmsgid
  5680. res.Output = resFour10265.Output
  5681. res.ErrMsg = resFour10265.ErrMsg
  5682. res.Cainfo = resFour10265.Cainfo
  5683. res.WarnMsg = resFour10265.WarnMsg
  5684. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5685. res.Infcode = infocode
  5686. } else {
  5687. if miConfig.Code == "H15049901371" {
  5688. 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), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5689. var dat map[string]interface{}
  5690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5691. fmt.Println(dat)
  5692. } else {
  5693. fmt.Println(err)
  5694. }
  5695. saveLog(result, request_log, "2204", "上传费用明细")
  5696. userJSONBytes, _ := json.Marshal(dat)
  5697. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5698. utils.ErrorLog("解析失败:%v", err)
  5699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5700. return
  5701. }
  5702. res.InfRefmsgid = resFour10265.InfRefmsgid
  5703. res.Output = resFour10265.Output
  5704. res.ErrMsg = resFour10265.ErrMsg
  5705. res.Cainfo = resFour10265.Cainfo
  5706. res.WarnMsg = resFour10265.WarnMsg
  5707. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5708. res.Infcode = infocode
  5709. } else {
  5710. 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), patientPrescription.DoctorId, sickConfig.CountryCode)
  5711. var dat map[string]interface{}
  5712. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5713. fmt.Println(dat)
  5714. } else {
  5715. fmt.Println(err)
  5716. }
  5717. saveLog(result, request_log, "2204", "上传费用明细")
  5718. userJSONBytes, _ := json.Marshal(dat)
  5719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5720. utils.ErrorLog("解析失败:%v", err)
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5722. return
  5723. }
  5724. }
  5725. }
  5726. if res.Infcode == 0 {
  5727. order := &models.HisOrder{
  5728. UserOrgId: adminUser.CurrentOrgId,
  5729. HisPatientId: his.ID,
  5730. PatientId: his.PatientId,
  5731. SettleAccountsDate: recordDateTime,
  5732. Ctime: time.Now().Unix(),
  5733. Mtime: time.Now().Unix(),
  5734. MdtrtId: his.Number,
  5735. PsnNo: his.PsnNo,
  5736. MedType: strconv.FormatInt(reg_type, 10),
  5737. Status: 1,
  5738. Number: chrg_bchno,
  5739. Infcode: res.Infcode,
  5740. WarnMsg: res.WarnMsg,
  5741. Cainfo: res.Cainfo,
  5742. ErrMsg: res.ErrMsg,
  5743. RespondTime: res.RefmsgTime,
  5744. InfRefmsgid: res.InfRefmsgid,
  5745. OrderStatus: 1,
  5746. IsMedicineInsurance: 1,
  5747. SettleType: settle_accounts_type,
  5748. SettleStartTime: start_time,
  5749. SettleEndTime: end_time,
  5750. Creator: roles.AdminUserId,
  5751. Modify: roles.AdminUserId,
  5752. PType: 2,
  5753. Diagnosis: diagnosis_id,
  5754. }
  5755. err = service.CreateOrder(order)
  5756. if err != nil {
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5758. return
  5759. }
  5760. for _, item := range res.Output.Result {
  5761. temp := strings.Split(item.FeedetlSn, "-")
  5762. var advice_id int64 = 0
  5763. var project_id int64 = 0
  5764. var types int64 = 0
  5765. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5766. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5767. if temp[1] == "1" {
  5768. advice_id = id
  5769. project_id = 0
  5770. } else if temp[1] == "2" {
  5771. advice_id = 0
  5772. project_id = id
  5773. }
  5774. info := &models.HisOrderInfo{
  5775. OrderNumber: order.Number,
  5776. FeedetlSn: item.FeedetlSn,
  5777. UploadDate: time.Now().Unix(),
  5778. AdviceId: advice_id,
  5779. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5780. Cnt: item.Cnt,
  5781. Pric: float64(item.Pric),
  5782. PatientId: his.PatientId,
  5783. PricUplmtAmt: item.PricUplmtAmt,
  5784. SelfpayProp: item.SelfpayProp,
  5785. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5786. OverlmtAmt: item.OverlmtAmt,
  5787. PreselfpayAmt: item.PreselfpayAmt,
  5788. BasMednFlag: item.BasMednFlag,
  5789. MedChrgitmType: item.MedChrgitmType,
  5790. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5791. Status: 1,
  5792. Memo: item.Memo,
  5793. Mtime: time.Now().Unix(),
  5794. InscpScpAmt: item.InscpScpAmt,
  5795. DrtReimFlag: item.DrtReimFlag,
  5796. Ctime: time.Now().Unix(),
  5797. ListSpItemFlag: item.ListSpItemFlag,
  5798. ChldMedcFlag: item.ChldMedcFlag,
  5799. LmtUsedFlag: item.LmtUsedFlag,
  5800. ChrgitmLv: item.ChrgitmLv,
  5801. UserOrgId: adminUser.CurrentOrgId,
  5802. HisPatientId: his.ID,
  5803. OrderId: order.ID,
  5804. ProjectId: project_id,
  5805. Type: types,
  5806. }
  5807. service.CreateOrderInfo(info)
  5808. }
  5809. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5810. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5811. var total float64
  5812. for _, item := range prescriptions {
  5813. if item.Type == 1 { //药品
  5814. for _, subItem := range item.HisDoctorAdviceInfo {
  5815. total = total + (subItem.Price * subItem.PrescribingNumber)
  5816. }
  5817. }
  5818. if item.Type == 2 { //项目
  5819. for _, subItem := range item.HisPrescriptionProject {
  5820. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5821. total = total + (subItem.Price * cnt)
  5822. }
  5823. }
  5824. }
  5825. for _, item := range prescriptions {
  5826. for _, subItem := range item.HisAdditionalCharge {
  5827. total = total + (subItem.Price * float64(subItem.Count))
  5828. }
  5829. }
  5830. allTotal := fmt.Sprintf("%.4f", total)
  5831. if res.Infcode == 0 {
  5832. var rf []*ResultFive
  5833. json.Unmarshal([]byte(his.Iinfo), &rf)
  5834. chrg_bchno := chrg_bchno
  5835. cert_no := his.Certno
  5836. var insutypes []string
  5837. var insutype string
  5838. var is390 int = 0
  5839. var is310 int = 0
  5840. for _, item := range rf {
  5841. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5842. insutypes = append(insutypes, item.Insutype)
  5843. }
  5844. }
  5845. if len(insutypes) == 1 {
  5846. insutype = insutypes[0]
  5847. } else {
  5848. for _, i := range insutypes {
  5849. if i == "390" {
  5850. is390 = 1
  5851. }
  5852. if i == "310" {
  5853. is310 = 1
  5854. }
  5855. }
  5856. }
  5857. if is390 == 1 {
  5858. insutype = "390"
  5859. }
  5860. if is310 == 1 {
  5861. insutype = "310"
  5862. }
  5863. if len(insutypes) == 0 {
  5864. insutype = "310"
  5865. }
  5866. if len(insutypes) == 2 {
  5867. insutype = strconv.FormatInt(his.SocialType, 64)
  5868. }
  5869. //insutype = "390"
  5870. if his.IdCardType == 1 {
  5871. cert_no = his.MedicalInsuranceNumber
  5872. } else {
  5873. cert_no = his.Certno
  5874. }
  5875. var res ResultSeven
  5876. var resSeven10265 ResultSeven10265
  5877. if miConfig.MdtrtareaAdmvs == "421300" {
  5878. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5879. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5880. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5881. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5882. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5883. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5884. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5885. resp, requestErr := http.Get(api)
  5886. if requestErr != nil {
  5887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5888. return
  5889. }
  5890. body, ioErr := ioutil.ReadAll(resp.Body)
  5891. if ioErr != nil {
  5892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5894. return
  5895. }
  5896. var respJSON map[string]interface{}
  5897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. return
  5901. }
  5902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5903. result, _ := json.Marshal(respJSON)
  5904. fmt.Println("log")
  5905. fmt.Println(string(result))
  5906. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5907. utils.ErrorLog("解析失败:%v", err)
  5908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5909. return
  5910. }
  5911. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5912. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5913. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5914. bas := strings.Split(psn_info.CardInfo, "|")
  5915. if his.IdCardType == 1 {
  5916. cert_no = bas[2]
  5917. } else {
  5918. cert_no = bas[1]
  5919. }
  5920. //江苏地区国家医保医疗类别
  5921. //职工透析:医疗类别选特殊情况门诊9933
  5922. //居民血透门慢: 医疗类别选门诊慢病1402
  5923. //var med_type string
  5924. //if his.Insutype == "310" {
  5925. // if reg_type == 14 {
  5926. // med_type = "9933"
  5927. // } else if reg_type == 11 {
  5928. // med_type = "11"
  5929. //
  5930. // }
  5931. //} else if his.Insutype == "390" {
  5932. // if reg_type == 14 {
  5933. // med_type = "1402"
  5934. // } else if reg_type == 11 {
  5935. // med_type = "11"
  5936. // }
  5937. //}
  5938. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5939. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5940. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5941. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5942. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5943. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5944. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5945. resp, requestErr := http.Get(api)
  5946. if requestErr != nil {
  5947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5948. return
  5949. }
  5950. body, ioErr := ioutil.ReadAll(resp.Body)
  5951. if ioErr != nil {
  5952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5954. return
  5955. }
  5956. var respJSON map[string]interface{}
  5957. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. return
  5961. }
  5962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5963. result, _ := json.Marshal(respJSON)
  5964. fmt.Println("log")
  5965. fmt.Println(string(result))
  5966. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5967. utils.ErrorLog("解析失败:%v", err)
  5968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5969. return
  5970. }
  5971. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5972. res.Output = resSeven10265.Output
  5973. res.ErrMsg = resSeven10265.ErrMsg
  5974. res.Cainfo = resSeven10265.Cainfo
  5975. res.WarnMsg = resSeven10265.WarnMsg
  5976. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5977. res.Infcode = infocode
  5978. } else {
  5979. var result string
  5980. var request_log string
  5981. if miConfig.Code == "H15049901371" {
  5982. //赤峰地区国家医保医疗类别
  5983. //职工透析:医疗类别选特殊情况门诊990502
  5984. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5985. var med_type string
  5986. if his.Insutype == "390" {
  5987. if reg_type == 14 {
  5988. med_type = "9933"
  5989. } else if reg_type == 11 {
  5990. med_type = "11"
  5991. }
  5992. } else if his.Insutype == "310" {
  5993. if reg_type == 14 {
  5994. med_type = "990502"
  5995. } else if reg_type == 11 {
  5996. med_type = "11"
  5997. }
  5998. }
  5999. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  6000. } else {
  6001. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  6002. }
  6003. var dat map[string]interface{}
  6004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6005. fmt.Println(dat)
  6006. } else {
  6007. fmt.Println(err)
  6008. }
  6009. saveLog(result, request_log, "2206", "预结算")
  6010. //userJSONBytes, _ := json.Marshal(dat)
  6011. //
  6012. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6013. // utils.ErrorLog("解析失败:%v", err)
  6014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. // return
  6016. //}
  6017. userJSONBytes, _ := json.Marshal(dat)
  6018. if miConfig.Code == "H15049901371" {
  6019. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6020. utils.ErrorLog("解析失败:%v", err)
  6021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6022. return
  6023. }
  6024. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6025. res.Output = resSeven10265.Output
  6026. res.ErrMsg = resSeven10265.ErrMsg
  6027. res.Cainfo = resSeven10265.Cainfo
  6028. res.WarnMsg = resSeven10265.WarnMsg
  6029. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6030. res.Infcode = infocode
  6031. } else {
  6032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6033. utils.ErrorLog("解析失败:%v", err)
  6034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6035. return
  6036. }
  6037. }
  6038. }
  6039. if res.Infcode != 0 {
  6040. errlog := &models.HisOrderError{
  6041. UserOrgId: adminUser.CurrentOrgId,
  6042. Ctime: time.Now().Unix(),
  6043. Mtime: time.Now().Unix(),
  6044. Number: chrg_bchno,
  6045. ErrMsg: res.ErrMsg,
  6046. Status: 1,
  6047. PatientId: id,
  6048. RecordTime: recordDateTime,
  6049. Stage: 20,
  6050. }
  6051. service.CreateErrMsgLog(errlog)
  6052. c.ServeSuccessJSON(map[string]interface{}{
  6053. "failed_code": -10,
  6054. "msg": res.ErrMsg,
  6055. })
  6056. return
  6057. } else {
  6058. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6059. order.OrderStatus = 1
  6060. order.IsPre = 1
  6061. order.Status = 1
  6062. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6063. order.SetlId = res.Output.Setlinfo.SetlID
  6064. order.PsnNo = res.Output.Setlinfo.PsnNo
  6065. order.PsnName = res.Output.Setlinfo.PsnName
  6066. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6067. order.Certno = res.Output.Setlinfo.Certno
  6068. order.Gend = res.Output.Setlinfo.Gend
  6069. order.Naty = res.Output.Setlinfo.Naty
  6070. order.Age = res.Output.Setlinfo.Age
  6071. order.Insutype = res.Output.Setlinfo.Insutype
  6072. order.PsnType = res.Output.Setlinfo.PsnType
  6073. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6074. order.SetlTime = res.Output.Setlinfo.SetlTime
  6075. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6076. if res.Output.Setlinfo.MedType == "140101" {
  6077. order.MedType = "14"
  6078. } else {
  6079. order.MedType = res.Output.Setlinfo.MedType
  6080. }
  6081. if reg_type == 1112 {
  6082. order.MedType = "1112"
  6083. }
  6084. if reg_type == 1111 {
  6085. order.MedType = "1111"
  6086. }
  6087. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6088. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6089. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6090. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6091. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6092. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6093. order.HifpPay = res.Output.Setlinfo.HifpPay
  6094. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6095. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6096. order.HifesPay = res.Output.Setlinfo.HifesPay
  6097. order.HifobPay = res.Output.Setlinfo.HifobPay
  6098. order.MafPay = res.Output.Setlinfo.MafPay
  6099. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6100. order.OthPay = res.Output.Setlinfo.OthPay
  6101. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6102. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6103. order.AcctPay = res.Output.Setlinfo.AcctPay
  6104. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6105. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6106. order.Balc = res.Output.Setlinfo.Balc
  6107. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6108. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6109. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6110. order.ClrWay = res.Output.Setlinfo.ClrWay
  6111. order.Creator = order.Creator
  6112. order.Modify = roles.AdminUserId
  6113. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6114. detailStr := string(setlDetail)
  6115. order.SetlDetail = detailStr
  6116. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6117. err = service.UpDateOrder(order)
  6118. if err == nil {
  6119. c.ServeSuccessJSON(map[string]interface{}{
  6120. "msg": "预结算成功",
  6121. })
  6122. } else {
  6123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6124. return
  6125. }
  6126. }
  6127. } else {
  6128. adminUser := c.GetAdminUserInfo()
  6129. errlog := &models.HisOrderError{
  6130. UserOrgId: adminUser.CurrentOrgId,
  6131. Ctime: time.Now().Unix(),
  6132. Mtime: time.Now().Unix(),
  6133. ErrMsg: res.ErrMsg,
  6134. Status: 1,
  6135. PatientId: id,
  6136. RecordTime: recordDateTime,
  6137. Stage: 4,
  6138. }
  6139. service.CreateErrMsgLog(errlog)
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6141. return
  6142. }
  6143. } else {
  6144. adminUser := c.GetAdminUserInfo()
  6145. errlog := &models.HisOrderError{
  6146. UserOrgId: adminUser.CurrentOrgId,
  6147. Ctime: time.Now().Unix(),
  6148. Mtime: time.Now().Unix(),
  6149. ErrMsg: res.ErrMsg,
  6150. Status: 1,
  6151. PatientId: id,
  6152. RecordTime: recordDateTime,
  6153. Stage: 4,
  6154. }
  6155. service.CreateErrMsgLog(errlog)
  6156. c.ServeSuccessJSON(map[string]interface{}{
  6157. "failed_code": -10,
  6158. "msg": res.ErrMsg,
  6159. })
  6160. return
  6161. }
  6162. }
  6163. }
  6164. }
  6165. //func (c *HisApiController) GetSettleInfo() {
  6166. // id, _ := c.GetInt64("id")
  6167. // order_id, _ := c.GetInt64("order_id")
  6168. //
  6169. // record_time := c.GetString("record_time")
  6170. // pay_way, _ := c.GetInt64("pay_way")
  6171. // pay_price, _ := c.GetFloat("pay_price")
  6172. // pay_card_no := c.GetString("pay_card_no")
  6173. // discount_price, _ := c.GetFloat("discount_price")
  6174. // preferential_price, _ := c.GetFloat("preferential_price")
  6175. // reality_price, _ := c.GetFloat("reality_price")
  6176. // found_price, _ := c.GetFloat("found_price")
  6177. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6178. // private_price, _ := c.GetFloat("private_price")
  6179. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6180. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6181. //
  6182. // timeLayout := "2006-01-02"
  6183. // loc, _ := time.LoadLocation("Local")
  6184. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6185. // if err != nil {
  6186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6187. // return
  6188. // }
  6189. // recordDateTime := theTime.Unix()
  6190. // adminUser := c.GetAdminUserInfo()
  6191. //
  6192. // var prescriptions []*models.HisPrescription
  6193. //
  6194. // data := make(map[string]interface{})
  6195. // if settle_accounts_type == 1 { //日结
  6196. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6197. // data["pre"] = prescriptions
  6198. //
  6199. // } else { //月结
  6200. // start_time_str := c.GetString("start_time")
  6201. // end_time_str := c.GetString("end_time")
  6202. // timeLayout := "2006-01-02"
  6203. // loc, _ := time.LoadLocation("Local")
  6204. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6205. // if err != nil {
  6206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6207. // return
  6208. // }
  6209. // recordStartTime := theStartTime.Unix()
  6210. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6211. // if err != nil {
  6212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6213. // return
  6214. // }
  6215. // recordEndTime := theEndTime.Unix()
  6216. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6217. // data["pre"] = prescriptions
  6218. //
  6219. // }
  6220. //
  6221. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6222. //
  6223. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6224. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6225. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6226. // strconv.FormatInt(his.PatientId, 10)
  6227. //
  6228. // order_src, _ := service.GetHisOrderByID(order_id)
  6229. //
  6230. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6231. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6232. //
  6233. // var total float64
  6234. // for _, item := range prescriptions {
  6235. // if item.Type == 1 { //药品
  6236. // for _, subItem := range item.HisDoctorAdviceInfo {
  6237. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6238. // }
  6239. // }
  6240. // if item.Type == 2 { //项目
  6241. // for _, subItem := range item.HisPrescriptionProject {
  6242. // total = total + (subItem.Price * float64(subItem.Count))
  6243. // }
  6244. // }
  6245. // }
  6246. //
  6247. // for _, item := range prescriptions {
  6248. // for _, subItem := range item.HisAdditionalCharge {
  6249. // total = total + (subItem.Price * float64(subItem.Count))
  6250. // }
  6251. // }
  6252. //
  6253. // allTotal := fmt.Sprintf("%.2f", total)
  6254. // var rf []*ResultFive
  6255. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6256. // psn_no := order_src.PsnNo
  6257. // mdtrt_id := order_src.MdtrtId
  6258. // chrg_bchno := order_src.Number
  6259. // cert_no := order_src.Certno
  6260. // insutype := rf[0].Insutype
  6261. //
  6262. // if his.IdCardType == 1 {
  6263. // cert_no = his.MedicalInsuranceNumber
  6264. // } else {
  6265. // cert_no = his.Certno
  6266. // }
  6267. //
  6268. // 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)
  6269. // var dat map[string]interface{}
  6270. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6271. // fmt.Println(dat)
  6272. // } else {
  6273. // fmt.Println(err)
  6274. // }
  6275. //
  6276. // userJSONBytes, _ := json.Marshal(dat)
  6277. //
  6278. //
  6279. //
  6280. // var res ResultSeven
  6281. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6282. // utils.ErrorLog("解析失败:%v", err)
  6283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6284. // return
  6285. // }
  6286. // if res.Infcode == -1 {
  6287. // errlog := &models.HisOrderError{
  6288. // UserOrgId: adminUser.CurrentOrgId,
  6289. // Ctime: time.Now().Unix(),
  6290. // Mtime: time.Now().Unix(),
  6291. // Number: chrg_bchno,
  6292. // ErrMsg: res.ErrMsg,
  6293. // Status: 1,
  6294. // PatientId: id,
  6295. // RecordTime: recordDateTime,
  6296. // Stage: 6,
  6297. // }
  6298. // service.CreateErrMsgLog(errlog)
  6299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6300. // return
  6301. // } else {
  6302. // order_src.OrderStatus = 2
  6303. // order_src.PayWay = pay_way
  6304. // order_src.PayPrice = pay_price
  6305. // order_src.PayCardNo = pay_card_no
  6306. // order_src.DiscountPrice = discount_price
  6307. // order_src.PreferentialPrice = preferential_price
  6308. // order_src.RealityPrice = reality_price
  6309. // order_src.FoundPrice = found_price
  6310. // order_src.MedicalInsurancePrice = medical_insurance_price
  6311. // order_src.PrivatePrice = private_price
  6312. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6313. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6314. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6315. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6316. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6317. // order_src.Certno = res.Output.Setlinfo.Certno
  6318. // order_src.Gend = res.Output.Setlinfo.Gend
  6319. // order_src.Naty = res.Output.Setlinfo.Naty
  6320. // order_src.Age = res.Output.Setlinfo.Age
  6321. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6322. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6323. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6324. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6325. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6326. // order_src.MedType = res.Output.Setlinfo.MedType
  6327. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6328. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6329. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6330. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6331. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6332. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6333. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6334. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6335. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6336. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6337. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6338. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6339. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6340. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6341. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6342. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6343. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6344. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6345. // order_src.Balc = res.Output.Setlinfo.Balc
  6346. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6347. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6348. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6349. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6350. // order_src.Creator = order_src.Creator
  6351. // order_src.Modify = roles.ID
  6352. // order_src.RequestLog = src_resquest
  6353. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6354. // detailStr := string(setlDetail)
  6355. // order_src.SetlDetail = detailStr
  6356. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6357. // err = service.UpDateOrder(order_src)
  6358. //
  6359. // if err == nil {
  6360. // c.ServeSuccessJSON(map[string]interface{}{
  6361. // "msg": "结算成功",
  6362. // })
  6363. // } else {
  6364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6365. // return
  6366. // }
  6367. // }
  6368. // }
  6369. //}
  6370. //退款
  6371. func (c *HisApiController) Refund() {
  6372. order_id, _ := c.GetInt64("order_id")
  6373. admin_user_id, _ := c.GetInt64("admin_user_id")
  6374. adminUser := c.GetAdminUserInfo()
  6375. var order models.HisOrder
  6376. order, _ = service.GetHisOrderByID(order_id)
  6377. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6378. if order.ID == 0 {
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6380. return
  6381. }
  6382. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6384. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6385. if config.IsOpen == 1 { //对接了医保,走医保流程
  6386. var res ResultSixteen
  6387. var resSixteen10265 ResultSixteen10265
  6388. var src_resquest string
  6389. var result string
  6390. if miConfig.MdtrtareaAdmvs == "421300" {
  6391. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6392. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6394. resp3, requestErr3 := http.Get(api3)
  6395. if requestErr3 != nil {
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. return
  6398. }
  6399. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6400. if ioErr3 != nil {
  6401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6403. return
  6404. }
  6405. var respJSON3 map[string]interface{}
  6406. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6409. return
  6410. }
  6411. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6412. userJSONBytes3, _ := json.Marshal(respJSON3)
  6413. fmt.Println("log")
  6414. fmt.Println(string(userJSONBytes3))
  6415. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6416. utils.ErrorLog("解析失败:%v", err)
  6417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. return
  6419. }
  6420. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6421. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6422. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6423. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6424. resp3, requestErr3 := http.Get(api3)
  6425. if requestErr3 != nil {
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. return
  6428. }
  6429. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6430. if ioErr3 != nil {
  6431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. return
  6434. }
  6435. var respJSON3 map[string]interface{}
  6436. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6439. return
  6440. }
  6441. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6442. userJSONBytes3, _ := json.Marshal(respJSON3)
  6443. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6444. utils.ErrorLog("解析失败:%v", err)
  6445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6446. return
  6447. }
  6448. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6449. res.Output = resSixteen10265.Output
  6450. res.ErrMsg = resSixteen10265.ErrMsg
  6451. res.Cainfo = resSixteen10265.Cainfo
  6452. res.WarnMsg = resSixteen10265.WarnMsg
  6453. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6454. res.Infcode = infocode
  6455. } else {
  6456. if miConfig.Code == "H15049901371" {
  6457. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6458. var dat map[string]interface{}
  6459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6460. fmt.Println(dat)
  6461. } else {
  6462. fmt.Println(err)
  6463. }
  6464. saveLog(result, src_resquest, "2208", "退费")
  6465. userJSONBytes, _ := json.Marshal(dat)
  6466. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6467. utils.ErrorLog("解析失败:%v", err)
  6468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6469. return
  6470. }
  6471. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6472. res.Output = resSixteen10265.Output
  6473. res.ErrMsg = resSixteen10265.ErrMsg
  6474. res.Cainfo = resSixteen10265.Cainfo
  6475. res.WarnMsg = resSixteen10265.WarnMsg
  6476. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6477. res.Infcode = infocode
  6478. } else {
  6479. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6480. var dat map[string]interface{}
  6481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6482. fmt.Println(dat)
  6483. } else {
  6484. fmt.Println(err)
  6485. }
  6486. saveLog(result, src_resquest, "2208", "退费")
  6487. userJSONBytes, _ := json.Marshal(dat)
  6488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6489. utils.ErrorLog("解析失败:%v", err)
  6490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6491. return
  6492. }
  6493. }
  6494. }
  6495. if res.Infcode == 0 {
  6496. var res2 ResultSix
  6497. var resSix10265 ResultSix10265
  6498. if miConfig.MdtrtareaAdmvs == "421300" {
  6499. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6500. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6502. resp3, requestErr3 := http.Get(api3)
  6503. if requestErr3 != nil {
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6508. if ioErr3 != nil {
  6509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. return
  6512. }
  6513. var respJSON3 map[string]interface{}
  6514. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6517. return
  6518. }
  6519. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6520. userJSONBytes3, _ := json.Marshal(respJSON3)
  6521. fmt.Println("log")
  6522. fmt.Println(string(userJSONBytes3))
  6523. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6524. utils.ErrorLog("解析失败:%v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. return
  6527. }
  6528. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6529. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6530. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6532. resp3, requestErr3 := http.Get(api3)
  6533. if requestErr3 != nil {
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. return
  6536. }
  6537. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6538. if ioErr3 != nil {
  6539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6541. return
  6542. }
  6543. var respJSON3 map[string]interface{}
  6544. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6547. return
  6548. }
  6549. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6550. userJSONBytes3, _ := json.Marshal(respJSON3)
  6551. fmt.Println("log")
  6552. fmt.Println(string(userJSONBytes3))
  6553. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6554. utils.ErrorLog("解析失败:%v", err)
  6555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. return
  6557. }
  6558. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6559. res2.Output = resSix10265.Output
  6560. res2.ErrMsg = resSix10265.ErrMsg
  6561. res2.Cainfo = resSix10265.Cainfo
  6562. res2.WarnMsg = resSix10265.WarnMsg
  6563. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6564. res2.Infcode = infocode
  6565. } else {
  6566. if miConfig.Code == "H15049901371" {
  6567. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6568. var dat map[string]interface{}
  6569. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6570. fmt.Println(dat)
  6571. } else {
  6572. fmt.Println(err)
  6573. }
  6574. saveLog(result2, src_request, "2205", "撤销明细")
  6575. userJSONBytes, _ := json.Marshal(dat)
  6576. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6577. utils.ErrorLog("解析失败:%v", err)
  6578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6579. return
  6580. }
  6581. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6582. res2.Output = resSix10265.Output
  6583. res2.ErrMsg = resSix10265.ErrMsg
  6584. res2.Cainfo = resSix10265.Cainfo
  6585. res2.WarnMsg = resSix10265.WarnMsg
  6586. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6587. res2.Infcode = infocode
  6588. } else {
  6589. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6590. var dat map[string]interface{}
  6591. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6592. fmt.Println(dat)
  6593. } else {
  6594. fmt.Println(err)
  6595. }
  6596. saveLog(result2, src_request, "2205", "撤销明细")
  6597. userJSONBytes, _ := json.Marshal(dat)
  6598. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6599. utils.ErrorLog("解析失败:%v", err)
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. }
  6604. }
  6605. if res2.Infcode == 0 {
  6606. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6607. if err == nil {
  6608. c.ServeSuccessJSON(map[string]interface{}{
  6609. "msg": "退费成功",
  6610. })
  6611. } else {
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6613. return
  6614. }
  6615. } else {
  6616. c.ServeSuccessJSON(map[string]interface{}{
  6617. "code": -10,
  6618. "msg": res2.ErrMsg,
  6619. })
  6620. }
  6621. } else {
  6622. c.ServeSuccessJSON(map[string]interface{}{
  6623. "code": -10,
  6624. "msg": res.ErrMsg,
  6625. })
  6626. }
  6627. }
  6628. }
  6629. func (c *HisApiController) RefundNumber() {
  6630. record_time := c.GetString("record_time")
  6631. //patient_id, _ := c.GetInt64("patient_id")
  6632. admin_user_id, _ := c.GetInt64("admin_user_id")
  6633. his_patient_id, _ := c.GetInt64("id")
  6634. timeLayout := "2006-01-02"
  6635. loc, _ := time.LoadLocation("Local")
  6636. adminUser := c.GetAdminUserInfo()
  6637. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6638. fmt.Println(err)
  6639. if err != nil {
  6640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6641. return
  6642. }
  6643. recordDateTime := theTime.Unix()
  6644. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6645. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6646. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6647. //order, _ := service.GetHisOrderByID(order_id)
  6648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6649. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6650. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6651. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6652. if count > 0 {
  6653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6654. return
  6655. }
  6656. if config.IsOpen == 1 { //对接了医保,走医保流程
  6657. var res2 ResultSix
  6658. var resSix10265 ResultSix10265
  6659. if miConfig.MdtrtareaAdmvs == "421300" {
  6660. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6661. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6662. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6663. resp3, requestErr3 := http.Get(api3)
  6664. if requestErr3 != nil {
  6665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6666. return
  6667. }
  6668. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6669. if ioErr3 != nil {
  6670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6672. return
  6673. }
  6674. var respJSON3 map[string]interface{}
  6675. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6678. return
  6679. }
  6680. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6681. userJSONBytes3, _ := json.Marshal(respJSON3)
  6682. fmt.Println("log")
  6683. fmt.Println(string(userJSONBytes3))
  6684. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6685. utils.ErrorLog("解析失败:%v", err)
  6686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6687. return
  6688. }
  6689. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6690. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6691. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6693. resp3, requestErr3 := http.Get(api3)
  6694. if requestErr3 != nil {
  6695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6696. return
  6697. }
  6698. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6699. if ioErr3 != nil {
  6700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6702. return
  6703. }
  6704. var respJSON3 map[string]interface{}
  6705. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. return
  6709. }
  6710. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6711. userJSONBytes3, _ := json.Marshal(respJSON3)
  6712. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6713. utils.ErrorLog("解析失败:%v", err)
  6714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6715. return
  6716. }
  6717. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6718. res2.Output = resSix10265.Output
  6719. res2.ErrMsg = resSix10265.ErrMsg
  6720. res2.Cainfo = resSix10265.Cainfo
  6721. res2.WarnMsg = resSix10265.WarnMsg
  6722. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6723. res2.Infcode = infocode
  6724. } else {
  6725. var api3 string
  6726. if miConfig.Code == "H15049901371" {
  6727. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6728. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6729. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6730. } else {
  6731. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6732. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6734. }
  6735. resp3, requestErr3 := http.Get(api3)
  6736. if requestErr3 != nil {
  6737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6738. return
  6739. }
  6740. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6741. if ioErr3 != nil {
  6742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6744. return
  6745. }
  6746. var respJSON3 map[string]interface{}
  6747. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6750. return
  6751. }
  6752. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6753. userJSONBytes3, _ := json.Marshal(respJSON3)
  6754. if miConfig.Code == "H15049901371" {
  6755. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6756. utils.ErrorLog("解析失败:%v", err)
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6758. return
  6759. }
  6760. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6761. res2.Output = resSix10265.Output
  6762. res2.ErrMsg = resSix10265.ErrMsg
  6763. res2.Cainfo = resSix10265.Cainfo
  6764. res2.WarnMsg = resSix10265.WarnMsg
  6765. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6766. res2.Infcode = infocode
  6767. } else {
  6768. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6769. utils.ErrorLog("解析失败:%v", err)
  6770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6771. return
  6772. }
  6773. }
  6774. }
  6775. if res2.Infcode == 0 {
  6776. if err == nil {
  6777. c.ServeSuccessJSON(map[string]interface{}{
  6778. "msg": "退号成功",
  6779. })
  6780. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6781. } else {
  6782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6783. return
  6784. }
  6785. } else {
  6786. c.ServeSuccessJSON(map[string]interface{}{
  6787. "code": -10,
  6788. "msg": res2.ErrMsg,
  6789. })
  6790. }
  6791. } else {
  6792. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6793. //if err == nil {
  6794. // c.ServeSuccessJSON(map[string]interface{}{
  6795. // "msg": "退费成功",
  6796. // })
  6797. //} else {
  6798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6799. // return
  6800. //}
  6801. }
  6802. }
  6803. func (c *HisApiController) RefundDetail() {
  6804. order_id, _ := c.GetInt64("order_id")
  6805. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6806. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6807. number := c.GetString("number")
  6808. record_time := c.GetString("record_time")
  6809. patient_id, _ := c.GetInt64("patient_id")
  6810. timeLayout := "2006-01-02"
  6811. loc, _ := time.LoadLocation("Local")
  6812. adminUser := c.GetAdminUserInfo()
  6813. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6814. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6815. fmt.Println(err)
  6816. if err != nil {
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6818. return
  6819. }
  6820. recordDateTime := theTime.Unix()
  6821. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6822. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6823. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6824. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6825. var order models.HisOrder
  6826. order, _ = service.GetHisOrderByID(order_id)
  6827. if order.ID == 0 {
  6828. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6829. }
  6830. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6831. if config.IsOpen == 1 { //对接了医保,走医保流程
  6832. var res2 ResultSix
  6833. if miConfig.MdtrtareaAdmvs == "421300" {
  6834. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6835. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6837. resp3, requestErr3 := http.Get(api3)
  6838. if requestErr3 != nil {
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. return
  6841. }
  6842. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6843. if ioErr3 != nil {
  6844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. var respJSON3 map[string]interface{}
  6849. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. return
  6853. }
  6854. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6855. userJSONBytes3, _ := json.Marshal(respJSON3)
  6856. fmt.Println("log")
  6857. fmt.Println(string(userJSONBytes3))
  6858. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6859. utils.ErrorLog("解析失败:%v", err)
  6860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6861. return
  6862. }
  6863. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6864. if err == nil {
  6865. c.ServeSuccessJSON(map[string]interface{}{
  6866. "msg": "撤销明细成功",
  6867. })
  6868. return
  6869. } else {
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return
  6872. }
  6873. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6874. var resSix10265 ResultSix10265
  6875. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6876. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6878. resp3, requestErr3 := http.Get(api3)
  6879. if requestErr3 != nil {
  6880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6881. return
  6882. }
  6883. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6884. if ioErr3 != nil {
  6885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6887. return
  6888. }
  6889. var respJSON3 map[string]interface{}
  6890. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6893. return
  6894. }
  6895. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6896. userJSONBytes3, _ := json.Marshal(respJSON3)
  6897. fmt.Println("log")
  6898. fmt.Println(string(userJSONBytes3))
  6899. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6900. utils.ErrorLog("解析失败:%v", err)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. return
  6903. }
  6904. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6905. res2.Output = resSix10265.Output
  6906. res2.ErrMsg = resSix10265.ErrMsg
  6907. res2.Cainfo = resSix10265.Cainfo
  6908. res2.WarnMsg = resSix10265.WarnMsg
  6909. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6910. res2.Infcode = infocode
  6911. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6912. if err == nil {
  6913. c.ServeSuccessJSON(map[string]interface{}{
  6914. "msg": "撤销明细成功",
  6915. })
  6916. return
  6917. } else {
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. } else {
  6922. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6923. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6924. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6925. resp2, requestErr2 := http.Get(api2)
  6926. if requestErr2 != nil {
  6927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6928. return
  6929. }
  6930. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6931. if ioErr2 != nil {
  6932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. var respJSON2 map[string]interface{}
  6937. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6940. return
  6941. }
  6942. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6943. if err == nil {
  6944. c.ServeSuccessJSON(map[string]interface{}{
  6945. "msg": "撤销明细成功",
  6946. })
  6947. return
  6948. } else {
  6949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. return
  6951. }
  6952. }
  6953. } else {
  6954. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6955. if err == nil {
  6956. c.ServeSuccessJSON(map[string]interface{}{
  6957. "msg": "退费成功",
  6958. })
  6959. } else {
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. return
  6962. }
  6963. }
  6964. }
  6965. //对账
  6966. func (c *HisApiController) GetCheckAccount() {
  6967. start_time := c.GetString("start_time")
  6968. end_time := c.GetString("end_time")
  6969. insutype := c.GetString("insutype")
  6970. clr_type := c.GetString("clr_type")
  6971. clr_org := c.GetString("clr_optins")
  6972. admin_user_id, _ := c.GetInt64("admin_user_id")
  6973. adminUser := c.GetAdminUserInfo()
  6974. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6975. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6976. if len(clr_org) == 0 {
  6977. clr_org = miConfig.MdtrtareaAdmvs
  6978. }
  6979. timeLayout := "2006-01-02"
  6980. loc, _ := time.LoadLocation("Local")
  6981. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6982. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6983. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6984. fixmedins_setl_cnt := int64(len(orders))
  6985. var medfee_sumamt float64
  6986. var acct_pay float64
  6987. var fund_pay_sumamt float64
  6988. for _, item := range orders {
  6989. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6990. acct_pay = acct_pay + item.AcctPay
  6991. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6992. }
  6993. var user_name string
  6994. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6995. if role.ID == 0 {
  6996. user_name = "xxx"
  6997. } else {
  6998. user_name = role.UserName
  6999. }
  7000. var res ResultEight
  7001. var res10188 ResultEightFor10188
  7002. if config.IsOpen == 1 {
  7003. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7004. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  7005. "insutype=" + insutype +
  7006. "&clr_type=" + clr_type +
  7007. "&setl_optins=" + clr_org +
  7008. "&stmt_begndate=" + start_time +
  7009. "&stm_enddate=" + end_time +
  7010. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7011. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7012. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7013. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7014. "&fixmedins_code=" + miConfig.Code +
  7015. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7016. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7017. "&secret_key=" + miConfig.SecretKey +
  7018. "&org_name=" + miConfig.OrgName +
  7019. "&doctor=" + user_name +
  7020. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7021. fmt.Println(api)
  7022. resp, requestErr := http.Get(api)
  7023. if requestErr != nil {
  7024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7025. return
  7026. }
  7027. body, ioErr := ioutil.ReadAll(resp.Body)
  7028. fmt.Println(body)
  7029. if ioErr != nil {
  7030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. var respJSON map[string]interface{}
  7035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7041. userJSONBytes, _ := json.Marshal(respJSON)
  7042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7043. utils.ErrorLog("解析失败:%v", err)
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7045. return
  7046. }
  7047. res.InfRefmsgid = res10188.InfRefmsgid
  7048. res.Output = res10188.Output
  7049. res.ErrMsg = res10188.ErrMsg
  7050. res.Cainfo = res10188.Cainfo
  7051. res.WarnMsg = res10188.WarnMsg
  7052. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7053. res.Infcode = infocode
  7054. } else {
  7055. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7056. "insutype=" + insutype +
  7057. "&clr_type=" + clr_type +
  7058. "&setl_optins=" + clr_org +
  7059. "&stmt_begndate=" + start_time +
  7060. "&stm_enddate=" + end_time +
  7061. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7062. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7063. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7064. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7065. "&fixmedins_code=" + miConfig.Code +
  7066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7067. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7068. "&secret_key=" + miConfig.SecretKey +
  7069. "&org_name=" + miConfig.OrgName +
  7070. "&doctor=" + user_name
  7071. fmt.Println(api)
  7072. resp, requestErr := http.Get(api)
  7073. if requestErr != nil {
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. body, ioErr := ioutil.ReadAll(resp.Body)
  7078. fmt.Println(body)
  7079. if ioErr != nil {
  7080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. return
  7083. }
  7084. var respJSON map[string]interface{}
  7085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7088. return
  7089. }
  7090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7091. userJSONBytes, _ := json.Marshal(respJSON)
  7092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7093. utils.ErrorLog("解析失败:%v", err)
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. return
  7096. }
  7097. }
  7098. if res.Infcode == 0 {
  7099. if res.Output.Stmtinfo.StmtRslt == "0" {
  7100. micc := &models.MedicalInsuranceCostCompare{
  7101. StartTime: startime.Unix(),
  7102. EndTime: endtime.Unix(),
  7103. Insutype: insutype,
  7104. CheckType: 1,
  7105. Num: fixmedins_setl_cnt,
  7106. Mtime: time.Now().Unix(),
  7107. Status: 1,
  7108. UserOrgId: adminUser.CurrentOrgId,
  7109. CostTotal: medfee_sumamt,
  7110. FuncTotal: fund_pay_sumamt,
  7111. PsnPay: acct_pay,
  7112. Creator: admin_user_id,
  7113. Ctime: time.Now().Unix(),
  7114. }
  7115. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7116. if err == nil {
  7117. c.ServeSuccessJSON(map[string]interface{}{
  7118. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7119. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7120. })
  7121. } else {
  7122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. }
  7124. } else {
  7125. c.ServeSuccessJSON(map[string]interface{}{
  7126. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7127. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7128. })
  7129. }
  7130. } else {
  7131. c.ServeSuccessJSON(map[string]interface{}{
  7132. "code": -10,
  7133. "msg": res.ErrMsg,
  7134. })
  7135. }
  7136. }
  7137. }
  7138. func (c *HisApiController) Check310() {
  7139. adminUser := c.GetAdminUserInfo()
  7140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7141. var user_name string
  7142. user_name = "高慧裕"
  7143. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7144. "insutype=" + "310" +
  7145. "&clr_type=" + "11" +
  7146. "&setl_optins=" + "441202" +
  7147. "&stmt_begndate=" + "2022-03-01" +
  7148. "&stm_enddate=" + "2022-03-31" +
  7149. "&medfee_sumamt=" + "194930.12" +
  7150. "&fund_pay_sumamt=" + "188741.46" +
  7151. "&acct_pay=" + "0" +
  7152. "&fixmedins_setl_cnt=" + "452" +
  7153. "&fixmedins_code=" + miConfig.Code +
  7154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7155. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7156. "&secret_key=" + miConfig.SecretKey +
  7157. "&org_name=" + miConfig.OrgName +
  7158. "&doctor=" + user_name
  7159. fmt.Println(api)
  7160. resp, requestErr := http.Get(api)
  7161. if requestErr != nil {
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7163. return
  7164. }
  7165. body, ioErr := ioutil.ReadAll(resp.Body)
  7166. fmt.Println(body)
  7167. if ioErr != nil {
  7168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7170. return
  7171. }
  7172. var respJSON map[string]interface{}
  7173. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7179. userJSONBytes, _ := json.Marshal(respJSON)
  7180. var res ResultEight
  7181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7182. utils.ErrorLog("解析失败:%v", err)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. return
  7185. }
  7186. }
  7187. func (c *HisApiController) Check390() {
  7188. adminUser := c.GetAdminUserInfo()
  7189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7190. var user_name string
  7191. user_name = "高慧裕"
  7192. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7193. "insutype=" + "390" +
  7194. "&clr_type=" + "11" +
  7195. "&setl_optins=" + "441202" +
  7196. "&stmt_begndate=" + "2022-03-01" +
  7197. "&stm_enddate=" + "2022-03-31" +
  7198. "&medfee_sumamt=" + "1068448.89" +
  7199. "&fund_pay_sumamt=" + "1014677.62" +
  7200. "&acct_pay=" + "0" +
  7201. "&fixmedins_setl_cnt=" + "1950" +
  7202. "&fixmedins_code=" + miConfig.Code +
  7203. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7204. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7205. "&secret_key=" + miConfig.SecretKey +
  7206. "&org_name=" + miConfig.OrgName +
  7207. "&doctor=" + user_name
  7208. fmt.Println(api)
  7209. resp, requestErr := http.Get(api)
  7210. if requestErr != nil {
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. body, ioErr := ioutil.ReadAll(resp.Body)
  7215. fmt.Println(body)
  7216. if ioErr != nil {
  7217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. return
  7220. }
  7221. var respJSON map[string]interface{}
  7222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7225. return
  7226. }
  7227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7228. userJSONBytes, _ := json.Marshal(respJSON)
  7229. var res ResultEight
  7230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7231. utils.ErrorLog("解析失败:%v", err)
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. }
  7236. //对账明细
  7237. func (c *HisApiController) GetCheckDetailAccount() {
  7238. start_time := c.GetString("start_time")
  7239. end_time := c.GetString("end_time")
  7240. admin_user_id, _ := c.GetInt64("admin_user_id")
  7241. adminUser := c.GetAdminUserInfo()
  7242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7243. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7244. timeLayout := "2006-01-02"
  7245. loc, _ := time.LoadLocation("Local")
  7246. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7247. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7248. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7249. Mkdir(miConfig.OrgName)
  7250. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7251. file_name := file + ".txt"
  7252. zip_name := file + ".zip"
  7253. zip_path := miConfig.OrgName + "/" + zip_name
  7254. file_path := miConfig.OrgName + "/" + file_name
  7255. decimal.DivisionPrecision = 2
  7256. var medfee_sumamt float64
  7257. var psn_cash_pay float64
  7258. var fund_pay_sumamt float64
  7259. fixmedins_setl_cnt := int64(len(orders))
  7260. for _, item := range orders {
  7261. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7262. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7263. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7264. }
  7265. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7266. defer f.Close()
  7267. if err != nil {
  7268. fmt.Println(err.Error())
  7269. } else {
  7270. for _, item := range orders {
  7271. var refd_setl_flag string
  7272. if item.OrderStatus == 2 {
  7273. refd_setl_flag = "0"
  7274. var str string
  7275. str = item.SetlId + " " +
  7276. item.MdtrtId + " " +
  7277. item.PsnNo + " " +
  7278. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7279. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7280. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7281. _, err = f.Write([]byte(str))
  7282. }
  7283. if item.OrderStatus == 3 {
  7284. var str string
  7285. str = item.SetlId + " " +
  7286. item.MdtrtId + " " +
  7287. item.PsnNo + " " +
  7288. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7289. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7290. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7291. _, err = f.Write([]byte(str))
  7292. var str2 string
  7293. str2 = item.SetlId + " " +
  7294. item.MdtrtId + " " +
  7295. item.PsnNo + " " +
  7296. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7297. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7298. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7299. _, err = f.Write([]byte(str2))
  7300. }
  7301. }
  7302. }
  7303. Zip(file_path, zip_path)
  7304. fmt.Println(ReadFile(zip_path))
  7305. fmt.Println(string(ReadFile(zip_path)))
  7306. if config.IsOpen == 1 {
  7307. var user_name string
  7308. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7309. if role.ID == 0 {
  7310. user_name = "管理员"
  7311. } else {
  7312. user_name = role.UserName
  7313. }
  7314. baseParams := models.BaseParams{
  7315. SecretKey: miConfig.SecretKey,
  7316. FixmedinsCode: miConfig.Code,
  7317. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7318. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7319. OrgName: miConfig.OrgName,
  7320. Doctor: user_name,
  7321. }
  7322. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7323. var dat map[string]interface{}
  7324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7325. fmt.Println(dat)
  7326. } else {
  7327. fmt.Println(err)
  7328. }
  7329. userJSONBytes, _ := json.Marshal(dat)
  7330. var res ResultNine
  7331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7332. utils.ErrorLog("解析失败:%v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. if res.Infcode == 0 {
  7337. fileNo := res.Output.FileQuryNo
  7338. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7339. "file_qury_no=" + fileNo +
  7340. "&setl_optins=" + "定点医保中心" +
  7341. "&stmt_begndate=" + start_time +
  7342. "&stm_enddate=" + end_time +
  7343. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7344. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7345. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7346. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7347. "&fixmedins_code=" + miConfig.Code +
  7348. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7349. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7350. "&secret_key=" + miConfig.SecretKey +
  7351. "&org_name=" + miConfig.OrgName +
  7352. "&doctor=" + user_name
  7353. resp, requestErr := http.Get(api)
  7354. if requestErr != nil {
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. body, ioErr := ioutil.ReadAll(resp.Body)
  7359. if ioErr != nil {
  7360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. return
  7363. }
  7364. var respJSON map[string]interface{}
  7365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7368. return
  7369. }
  7370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7371. userJSONBytes, _ := json.Marshal(respJSON)
  7372. var res ResultTen
  7373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7374. utils.ErrorLog("解析失败:%v", err)
  7375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7376. return
  7377. }
  7378. if res.Infcode == 0 {
  7379. service.Gdyb9102(baseParams, zip_name, fileNo)
  7380. micc := &models.MedicalInsuranceCostCompare{
  7381. StartTime: startime.Unix(),
  7382. EndTime: endtime.Unix(),
  7383. Insutype: "0",
  7384. CheckType: 2,
  7385. Num: fixmedins_setl_cnt,
  7386. Mtime: time.Now().Unix(),
  7387. Status: 1,
  7388. UserOrgId: adminUser.CurrentOrgId,
  7389. CostTotal: medfee_sumamt,
  7390. FuncTotal: fund_pay_sumamt,
  7391. PsnPay: psn_cash_pay,
  7392. Creator: admin_user_id,
  7393. Ctime: time.Now().Unix(),
  7394. }
  7395. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7396. c.ServeSuccessJSON(map[string]interface{}{
  7397. "msg": "明细对账成功",
  7398. })
  7399. }
  7400. } else {
  7401. }
  7402. }
  7403. }
  7404. type CustomOrderInfo struct {
  7405. Name string
  7406. Spec string
  7407. Unit string
  7408. Count float64
  7409. Price float64
  7410. Total float64
  7411. }
  7412. func (c *HisApiController) GetSettleAccounts() {
  7413. //id, _ := c.GetInt64("id")
  7414. //record_time := c.GetString("record_time")
  7415. order_id, _ := c.GetInt64("order_id")
  7416. admin_user_id, _ := c.GetInt64("admin_user_id")
  7417. //timeLayout := "2006-01-02"
  7418. //loc, _ := time.LoadLocation("Local")
  7419. //
  7420. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7421. //if err != nil {
  7422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7423. // return
  7424. //}
  7425. //recordDateTime := theTime.Unix()
  7426. adminUser := c.GetAdminUserInfo()
  7427. order, _ := service.GetHisOrderByID(order_id)
  7428. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7429. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7430. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7431. orderInfos = append(orderInfos, orderInfos_two...)
  7432. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7433. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7434. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7435. //var config []*models.HisXtDiagnoseConfig
  7436. var name string
  7437. for _, item := range diagnosis_ids {
  7438. id, _ := strconv.ParseInt(item, 10, 64)
  7439. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7440. if len(name) == 0 {
  7441. name = diagnosisConfig.ClassName
  7442. } else {
  7443. name = name + "," + diagnosisConfig.ClassName
  7444. }
  7445. }
  7446. var bedCostTotal float64 = 0 //床位总费
  7447. var bedCostSelfTotal float64 = 0 //床位自费
  7448. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7449. var operationCostTotal float64 = 0 //手术费
  7450. var operationCostSelfTotal float64 = 0 //手术费
  7451. var operationCostPartSelfTotal float64 = 0 //手术费
  7452. var otherCostTotal float64 = 0 //其他费用
  7453. var otherCostSelfTotal float64 = 0 //其他费用
  7454. var otherCostPartSelfTotal float64 = 0 //其他费用
  7455. var materialCostTotal float64 = 0 //材料费
  7456. var materialCostSelfTotal float64 = 0 //材料费
  7457. var materialCostPartSelfTotal float64 = 0 //材料费
  7458. var westernMedicineCostTotal float64 = 0 //西药费
  7459. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7460. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7461. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7462. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7463. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7464. var checkCostTotal float64 = 0 //检查费
  7465. var checkCostSelfTotal float64 = 0 //检查费
  7466. var checkCostPartSelfTotal float64 = 0 //检查费
  7467. var laboratoryCostTotal float64 = 0 //化验费
  7468. var laboratoryCostSelfTotal float64 = 0 //化验费
  7469. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7470. var treatCostTotal float64 = 0 //治疗费用
  7471. var treatCostSelfTotal float64 = 0 //治疗费用
  7472. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7473. decimal.DivisionPrecision = 2
  7474. for _, item := range orderInfos {
  7475. if item.MedChrgitmType == "01" { //床位费
  7476. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7477. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7478. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7479. }
  7480. if item.MedChrgitmType == "03" { //检查费
  7481. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7482. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7483. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7484. }
  7485. if item.MedChrgitmType == "04" { //化验费
  7486. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7487. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7488. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7489. }
  7490. if item.MedChrgitmType == "05" || item.MedChrgitmType == "05" || item.MedChrgitmType == "05" { //治疗费
  7491. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7492. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7493. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7494. }
  7495. if item.MedChrgitmType == "06" { //手术费
  7496. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7497. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7498. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7499. }
  7500. if item.MedChrgitmType == "08" { //材料费
  7501. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7502. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7503. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7504. }
  7505. if item.MedChrgitmType == "09" { //西药费
  7506. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7507. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7508. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7509. }
  7510. if item.MedChrgitmType == "11" { //中成费
  7511. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7512. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7513. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7514. }
  7515. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7516. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7517. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7518. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7519. }
  7520. }
  7521. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7522. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7523. var user_name string
  7524. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7525. if role.ID == 0 {
  7526. user_name = "管理员"
  7527. } else {
  7528. user_name = role.UserName
  7529. }
  7530. baseParams := models.BaseParams{
  7531. SecretKey: miConfig.SecretKey,
  7532. FixmedinsCode: miConfig.Code,
  7533. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7534. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7535. OrgName: miConfig.OrgName,
  7536. Doctor: user_name,
  7537. }
  7538. businessParams := models.BusinessParams{
  7539. PsnNo: order.PsnNo,
  7540. MdtrtId: order.MdtrtId,
  7541. SetlId: order.SetlId,
  7542. }
  7543. var res ResultEleven
  7544. var resEleven10265 ResultEleven10265
  7545. if config.IsOpen == 1 {
  7546. if miConfig.MdtrtareaAdmvs == "421300" {
  7547. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7548. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7549. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7550. resp, requestErr := http.Get(api)
  7551. if requestErr != nil {
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. body, ioErr := ioutil.ReadAll(resp.Body)
  7556. if ioErr != nil {
  7557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7559. return
  7560. }
  7561. var respJSON map[string]interface{}
  7562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7568. result, _ := json.Marshal(respJSON)
  7569. fmt.Println("log")
  7570. fmt.Println(string(result))
  7571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7572. utils.ErrorLog("解析失败:%v", err)
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7577. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7578. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7579. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7580. resp, requestErr := http.Get(api)
  7581. if requestErr != nil {
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7583. return
  7584. }
  7585. body, ioErr := ioutil.ReadAll(resp.Body)
  7586. if ioErr != nil {
  7587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7589. return
  7590. }
  7591. var respJSON map[string]interface{}
  7592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7595. return
  7596. }
  7597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7598. result, _ := json.Marshal(respJSON)
  7599. fmt.Println("log")
  7600. fmt.Println(string(result))
  7601. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7602. utils.ErrorLog("解析失败:%v", err)
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7604. return
  7605. }
  7606. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7607. res.Output = resEleven10265.Output
  7608. res.ErrMsg = resEleven10265.ErrMsg
  7609. res.Cainfo = resEleven10265.Cainfo
  7610. res.WarnMsg = resEleven10265.WarnMsg
  7611. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7612. res.Infcode = infocode
  7613. } else {
  7614. result2 := service.Gdyb5204(baseParams, businessParams)
  7615. saveLog(result2, "", "5204", "查询")
  7616. result := service.Gdyb5203(baseParams, businessParams)
  7617. var dat map[string]interface{}
  7618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7619. fmt.Println(dat)
  7620. } else {
  7621. fmt.Println(err)
  7622. }
  7623. userJSONBytes, _ := json.Marshal(dat)
  7624. if miConfig.Code == "H15049901371" {
  7625. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7626. utils.ErrorLog("解析失败:%v", err)
  7627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7628. return
  7629. }
  7630. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7631. res.Output = resEleven10265.Output
  7632. res.ErrMsg = resEleven10265.ErrMsg
  7633. res.Cainfo = resEleven10265.Cainfo
  7634. res.WarnMsg = resEleven10265.WarnMsg
  7635. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7636. res.Infcode = infocode
  7637. } else {
  7638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7639. utils.ErrorLog("解析失败:%v", err)
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. return
  7642. }
  7643. }
  7644. }
  7645. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7646. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7647. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7648. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7649. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7650. var doctor_name string
  7651. if roles.ID == 0 {
  7652. doctor_name = "管理员"
  7653. } else {
  7654. doctor_name = roles.UserName
  7655. }
  7656. yiliao_leibie := ""
  7657. switch order.MedType {
  7658. case "11":
  7659. yiliao_leibie = "普通门诊"
  7660. break
  7661. case "12":
  7662. yiliao_leibie = "门诊挂号"
  7663. break
  7664. case "13":
  7665. yiliao_leibie = "急诊"
  7666. break
  7667. case "14":
  7668. yiliao_leibie = "门诊特殊病"
  7669. break
  7670. case "15":
  7671. yiliao_leibie = "门诊统筹"
  7672. break
  7673. case "16":
  7674. yiliao_leibie = "门诊慢性病"
  7675. break
  7676. case "21":
  7677. yiliao_leibie = "普通住院"
  7678. break
  7679. }
  7680. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7681. if res.Infcode == 0 {
  7682. c.ServeSuccessJSON(map[string]interface{}{
  7683. "diagnosis": name,
  7684. "order_infos": orderInfos,
  7685. "number": order.MdtrtId,
  7686. "date": order.SettleAccountsDate,
  7687. "charge_admin": charge_admin,
  7688. "printor_admin": printor_admin,
  7689. "info": res.Output.Setlinfo,
  7690. "bedCostTotal": bedCostTotal,
  7691. "bedCostSelfTotal": bedCostSelfTotal,
  7692. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7693. "operationCostTotal": operationCostTotal,
  7694. "operationCostSelfTotal": operationCostSelfTotal,
  7695. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7696. "otherCostTotal": otherCostTotal,
  7697. "otherCostSelfTotal": otherCostSelfTotal,
  7698. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7699. "materialCostTotal": materialCostTotal,
  7700. "materialCostSelfTotal": materialCostSelfTotal,
  7701. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7702. "westernMedicineCostTotal": westernMedicineCostTotal,
  7703. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7704. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7705. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7706. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7707. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7708. "checkCostTotal": checkCostTotal,
  7709. "checkCostSelfTotal": checkCostSelfTotal,
  7710. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7711. "laboratoryCostTotal": laboratoryCostTotal,
  7712. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7713. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7714. "treatCostTotal": treatCostTotal,
  7715. "treatCostSelfTotal": treatCostSelfTotal,
  7716. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7717. "doctor_code": adminRole_two.DoctorCode,
  7718. "doctor_name": doctor_name,
  7719. "health_card_no": order.PsnNo,
  7720. "department": departments.Name,
  7721. "yiliao_leibie": yiliao_leibie,
  7722. "after_money": order.AccountPrice,
  7723. "patient": patient,
  7724. "org_name": miConfig.OrgName,
  7725. "org_code": miConfig.Code,
  7726. "order_number": order.Number,
  7727. //"check_order_info": cus_slice,
  7728. })
  7729. }
  7730. }
  7731. }
  7732. func (c *HisApiController) CheckTreatment() {
  7733. patient_id, _ := c.GetInt64("patient_id")
  7734. id_card_no := c.GetString("id_card_no")
  7735. insutype := c.GetString("insutype")
  7736. med_type := c.GetString("med_type")
  7737. admin_user_id, _ := c.GetInt64("admin_user_id")
  7738. adminUser := c.GetAdminUserInfo()
  7739. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7741. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7742. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7743. if miConfig.MdtrtareaAdmvs == "421300" {
  7744. var res ResultTwo
  7745. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7746. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  7748. resp, requestErr := http.Get(api)
  7749. if requestErr != nil {
  7750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7751. return
  7752. }
  7753. body, ioErr := ioutil.ReadAll(resp.Body)
  7754. if ioErr != nil {
  7755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. var respJSON map[string]interface{}
  7760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7766. result, _ := json.Marshal(respJSON)
  7767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7768. utils.ErrorLog("解析失败:%v", err)
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7770. return
  7771. }
  7772. if res.Infcode == 0 {
  7773. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7774. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7775. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7776. resp, requestErr := http.Get(api)
  7777. if requestErr != nil {
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7779. return
  7780. }
  7781. body, ioErr := ioutil.ReadAll(resp.Body)
  7782. if ioErr != nil {
  7783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. var respJSON map[string]interface{}
  7788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. var res Result2001
  7794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7795. result2, _ := json.Marshal(respJSON)
  7796. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7797. utils.ErrorLog("解析失败:%v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. if res.Infcode == 0 {
  7802. c.ServeSuccessJSON(map[string]interface{}{
  7803. "msg": res.Output.Trtinfo,
  7804. })
  7805. }
  7806. } else {
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7808. return
  7809. }
  7810. } else {
  7811. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7812. var dat map[string]interface{}
  7813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7814. fmt.Println(dat)
  7815. } else {
  7816. fmt.Println(err)
  7817. }
  7818. userJSONBytes, _ := json.Marshal(dat)
  7819. var res ResultTwo
  7820. var res10265 ResultTwo10265
  7821. if miConfig.Code == "H15049901371" {
  7822. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7823. utils.ErrorLog("解析失败:%v", err)
  7824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7825. return
  7826. }
  7827. res.ErrMsg = res10265.ErrMsg
  7828. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7829. res.Infcode = infocode
  7830. res.Output = res10265.Output
  7831. res.InfRefmsgid = res10265.InfRefmsgid
  7832. } else {
  7833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7834. utils.ErrorLog("解析失败:%v", err)
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. }
  7839. var user_name string
  7840. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7841. if role.ID == 0 {
  7842. user_name = "xxx"
  7843. } else {
  7844. user_name = role.UserName
  7845. }
  7846. baseParams := models.BaseParams{
  7847. SecretKey: miConfig.SecretKey,
  7848. FixmedinsCode: miConfig.Code,
  7849. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7850. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7851. OrgName: miConfig.OrgName,
  7852. Doctor: user_name,
  7853. }
  7854. if config.IsOpen == 1 {
  7855. if miConfig.Code == "H15049901371" {
  7856. if med_type == "14" {
  7857. if insutype == "390" {
  7858. med_type = "9933"
  7859. } else if insutype == "310" {
  7860. med_type = "990502"
  7861. }
  7862. } else if med_type == "11" {
  7863. med_type = "11"
  7864. }
  7865. }
  7866. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7867. var dat map[string]interface{}
  7868. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7869. fmt.Println(dat)
  7870. } else {
  7871. fmt.Println(err)
  7872. }
  7873. var res Result2001
  7874. var res10265 Result2001Org10265
  7875. if miConfig.Code == "H15049901371" {
  7876. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7877. utils.ErrorLog("解析失败:%v", err)
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. return
  7880. }
  7881. res.ErrMsg = res10265.ErrMsg
  7882. res.Output = res10265.Output
  7883. res.InfRefmsgid = res10265.InfRefmsgid
  7884. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7885. res.Infcode = infocode
  7886. } else {
  7887. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7888. utils.ErrorLog("解析失败:%v", err)
  7889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7890. return
  7891. }
  7892. }
  7893. if res.Infcode == 0 {
  7894. c.ServeSuccessJSON(map[string]interface{}{
  7895. "msg": res.Output.Trtinfo,
  7896. })
  7897. }
  7898. }
  7899. }
  7900. }
  7901. //func (c *HisApiController) PutRecord() {
  7902. // id, _ := c.GetInt64("id")
  7903. // record_time := c.GetString("record_time")
  7904. // timeLayout := "2006-01-02"
  7905. // loc, _ := time.LoadLocation("Local")
  7906. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7907. // if err != nil {
  7908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7909. // return
  7910. // }
  7911. // recordDateTime := theTime.Unix()
  7912. //
  7913. // adminInfo := c.GetAdminUserInfo()
  7914. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7915. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7916. //
  7917. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7918. //
  7919. // fmt.Println(miConfig.SecretKey)
  7920. //
  7921. // if patient == nil {
  7922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7923. // return
  7924. // }
  7925. // if len(patient.IdCardNo) == 0 {
  7926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7927. // return
  7928. // }
  7929. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7930. // if config.IsOpen == 1 {
  7931. // 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
  7932. // resp, requestErr := http.Get(api)
  7933. // if requestErr != nil {
  7934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. // return
  7936. // }
  7937. // defer resp.Body.Close()
  7938. // body, ioErr := ioutil.ReadAll(resp.Body)
  7939. // if ioErr != nil {
  7940. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. // return
  7943. // }
  7944. // var respJSON map[string]interface{}
  7945. //
  7946. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7947. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7949. // return
  7950. // }
  7951. //
  7952. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7953. // userJSONBytes, _ := json.Marshal(userJSON)
  7954. // var res ResultTwo
  7955. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7956. // utils.ErrorLog("解析失败:%v", err)
  7957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. // return
  7959. // }
  7960. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7961. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7962. // infoStr := string(Iinfos)
  7963. // idetinfoStr := string(Idetinfos)
  7964. //
  7965. // if res.Infcode == 0 {
  7966. // his := models.VMHisPatient{
  7967. // Status: 1,
  7968. // Ctime: time.Now().Unix(),
  7969. // Mtime: time.Now().Unix(),
  7970. // PsnNo: res.Output.Baseinfo.PsnNo,
  7971. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7972. // Certno: res.Output.Baseinfo.Certno,
  7973. // PsnName: res.Output.Baseinfo.PsnName,
  7974. // Gend: res.Output.Baseinfo.Gend,
  7975. // Naty: res.Output.Baseinfo.Naty,
  7976. // Brdy: res.Output.Baseinfo.Brdy,
  7977. // Age: res.Output.Baseinfo.Age,
  7978. // Iinfo: infoStr,
  7979. // Idetinfo: idetinfoStr,
  7980. // PatientId: patient.ID,
  7981. // RecordDate: theTime.Unix(),
  7982. // UserOrgId: adminInfo.CurrentOrgId,
  7983. // AdminUserId: adminInfo.AdminUser.Id,
  7984. // IsReturn: 1,
  7985. // }
  7986. //
  7987. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7988. // //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")
  7989. // //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")
  7990. //
  7991. // //var dat map[string]interface{}
  7992. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7993. // // fmt.Println(dat)
  7994. // //} else {
  7995. // // fmt.Println(err)
  7996. // //}
  7997. //
  7998. // var dat2 map[string]interface{}
  7999. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8000. // fmt.Println(dat2)
  8001. // } else {
  8002. // fmt.Println(err)
  8003. // }
  8004. //
  8005. // } else {
  8006. // adminUser := c.GetAdminUserInfo()
  8007. // errlog := &models.HisOrderError{
  8008. // UserOrgId: adminUser.CurrentOrgId,
  8009. // Ctime: time.Now().Unix(),
  8010. // Mtime: time.Now().Unix(),
  8011. // ErrMsg: res.ErrMsg,
  8012. // Status: 1,
  8013. // PatientId: id,
  8014. // RecordTime: recordDateTime,
  8015. // Stage: 1,
  8016. // }
  8017. // service.CreateErrMsgLog(errlog)
  8018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8019. // return
  8020. // }
  8021. // }
  8022. //
  8023. //}
  8024. //func (c *HisApiController) GetUploadDiag() {
  8025. // id, _ := c.GetInt64("id")
  8026. // record_time := c.GetString("record_time")
  8027. //
  8028. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8029. // sick_type, _ := c.GetInt64("sick_type")
  8030. // reg_type, _ := c.GetInt64("reg_type")
  8031. //
  8032. // timeLayout := "2006-01-02"
  8033. // loc, _ := time.LoadLocation("Local")
  8034. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8035. // if err != nil {
  8036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8037. // return
  8038. // }
  8039. //
  8040. // var patientPrescription models.HisPrescriptionInfo
  8041. // recordDateTime := theTime.Unix()
  8042. // adminInfo := c.GetAdminUserInfo()
  8043. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8044. //
  8045. // if patientPrescription.ID == 0 {
  8046. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8047. // }
  8048. //
  8049. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8050. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8051. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8052. // sickConfig, _ := service.FindSickById(sick_type)
  8053. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8054. //
  8055. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8056. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8057. // "&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 +
  8058. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8059. // resp2, requestErr2 := http.Get(api2)
  8060. // if requestErr2 != nil {
  8061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. // return
  8063. // }
  8064. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8065. // if ioErr2 != nil {
  8066. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8068. // return
  8069. // }
  8070. // var respJSON2 map[string]interface{}
  8071. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8072. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8074. // return
  8075. // }
  8076. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8077. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8078. //
  8079. // var res2 ResultSix
  8080. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8081. // utils.ErrorLog("解析失败:%v", err)
  8082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8083. // return
  8084. // }
  8085. // if res2.Infcode != 0 {
  8086. // adminUser := c.GetAdminUserInfo()
  8087. // errlog := &models.HisOrderError{
  8088. // UserOrgId: adminUser.CurrentOrgId,
  8089. // Ctime: time.Now().Unix(),
  8090. // Mtime: time.Now().Unix(),
  8091. // ErrMsg: res2.ErrMsg,
  8092. // Status: 1,
  8093. // PatientId: id,
  8094. // RecordTime: recordDateTime,
  8095. // Stage: 3,
  8096. // }
  8097. // service.CreateErrMsgLog(errlog)
  8098. //
  8099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8100. // return
  8101. // }
  8102. //
  8103. // c.ServeSuccessJSON(map[string]interface{}{
  8104. // "msg": "上传成功",
  8105. // })
  8106. //
  8107. //}
  8108. type QueryResult struct {
  8109. ID int64
  8110. Name string
  8111. Code string
  8112. List_type_code string
  8113. }
  8114. func (c *HisApiController) GetCheckCode() {
  8115. ids_str := c.GetString("ids")
  8116. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8117. ids_arr := strings.Split(ids_str, ",")
  8118. var queryResult []QueryResult
  8119. ids := make([]int64, 0)
  8120. for _, item := range ids_arr {
  8121. id, _ := strconv.ParseInt(item, 10, 64)
  8122. ids = append(ids, id)
  8123. }
  8124. if record_type == 1 {
  8125. drugs, _ := service.GetBatchDrugList(ids)
  8126. for _, item := range drugs {
  8127. result := QueryResult{
  8128. ID: item.ID,
  8129. Name: item.DrugName,
  8130. Code: item.MedicalInsuranceNumber,
  8131. List_type_code: "101",
  8132. }
  8133. queryResult = append(queryResult, result)
  8134. }
  8135. } else if record_type == 2 {
  8136. goods, _ := service.GetBatchGoodInformationList(ids)
  8137. for _, item := range goods {
  8138. result := QueryResult{
  8139. ID: item.ID,
  8140. Name: item.GoodName,
  8141. Code: item.MedicalInsuranceNumber,
  8142. List_type_code: "301",
  8143. }
  8144. queryResult = append(queryResult, result)
  8145. }
  8146. } else if record_type == 3 {
  8147. projects, _ := service.GetBathchMyPorjecgList(ids)
  8148. for _, item := range projects {
  8149. result := QueryResult{
  8150. ID: item.ID,
  8151. Name: item.ProjectName,
  8152. Code: item.MedicalCode,
  8153. List_type_code: "201",
  8154. }
  8155. queryResult = append(queryResult, result)
  8156. }
  8157. }
  8158. admin_user_id, _ := c.GetInt64("admin_user_id")
  8159. adminUser := c.GetAdminUserInfo()
  8160. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8161. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8162. var user_name string
  8163. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8164. if role.ID == 0 {
  8165. user_name = "xxx"
  8166. } else {
  8167. user_name = role.UserName
  8168. }
  8169. baseParams := &models.BaseParams{
  8170. SecretKey: miConfig.SecretKey,
  8171. FixmedinsCode: miConfig.Code,
  8172. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8173. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8174. OrgName: miConfig.OrgName,
  8175. Doctor: user_name,
  8176. }
  8177. if config.IsOpen == 1 {
  8178. for _, item := range queryResult {
  8179. var result string
  8180. if record_type == 1 {
  8181. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8182. } else if record_type == 2 {
  8183. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8184. } else if record_type == 3 {
  8185. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8186. }
  8187. var dat map[string]interface{}
  8188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8189. fmt.Println(dat)
  8190. } else {
  8191. fmt.Println(err)
  8192. }
  8193. userJSONBytes, _ := json.Marshal(dat)
  8194. var res ResultSix
  8195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8196. utils.ErrorLog("解析失败:%v", err)
  8197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8198. return
  8199. }
  8200. if res.Infcode == 0 {
  8201. if record_type == 1 {
  8202. service.UpdateBaseDrugById(item.ID)
  8203. } else if record_type == 2 {
  8204. service.UpdateGoodInformaitonByDetail(item.ID)
  8205. } else if record_type == 3 {
  8206. service.UpdateProjectById(item.ID)
  8207. }
  8208. c.ServeSuccessJSON(map[string]interface{}{
  8209. "failed_code": 0,
  8210. "msg": "目录对照成功",
  8211. })
  8212. } else {
  8213. c.ServeSuccessJSON(map[string]interface{}{
  8214. "failed_code": -10,
  8215. "msg": res.ErrMsg,
  8216. })
  8217. }
  8218. }
  8219. }
  8220. }
  8221. func (c *HisApiController) UnCheckCode() {
  8222. ids_str := c.GetString("ids")
  8223. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8224. admin_user_id, _ := c.GetInt64("admin_user_id")
  8225. ids_arr := strings.Split(ids_str, ",")
  8226. var queryResult []QueryResult
  8227. ids := make([]int64, 0)
  8228. for _, item := range ids_arr {
  8229. id, _ := strconv.ParseInt(item, 10, 64)
  8230. ids = append(ids, id)
  8231. }
  8232. if record_type == 1 {
  8233. drugs, _ := service.GetBatchDrugList(ids)
  8234. for _, item := range drugs {
  8235. result := QueryResult{
  8236. ID: item.ID,
  8237. Name: item.DrugName,
  8238. Code: item.MedicalInsuranceNumber,
  8239. List_type_code: "101",
  8240. }
  8241. queryResult = append(queryResult, result)
  8242. }
  8243. } else if record_type == 2 {
  8244. goods, _ := service.GetBatchGoodInformationList(ids)
  8245. for _, item := range goods {
  8246. result := QueryResult{
  8247. ID: item.ID,
  8248. Name: item.GoodName,
  8249. Code: item.MedicalInsuranceNumber,
  8250. List_type_code: "301",
  8251. }
  8252. queryResult = append(queryResult, result)
  8253. }
  8254. } else if record_type == 3 {
  8255. projects, _ := service.GetBathchMyPorjecgList(ids)
  8256. for _, item := range projects {
  8257. result := QueryResult{
  8258. ID: item.ID,
  8259. Name: item.ProjectName,
  8260. Code: item.MedicalCode,
  8261. List_type_code: "201",
  8262. }
  8263. queryResult = append(queryResult, result)
  8264. }
  8265. }
  8266. adminUser := c.GetAdminUserInfo()
  8267. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8268. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8269. var user_name string
  8270. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8271. if role.ID == 0 {
  8272. user_name = "xxx"
  8273. } else {
  8274. user_name = role.UserName
  8275. }
  8276. baseParams := &models.BaseParams{
  8277. SecretKey: miConfig.SecretKey,
  8278. FixmedinsCode: miConfig.Code,
  8279. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8280. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8281. OrgName: miConfig.OrgName,
  8282. Doctor: user_name,
  8283. }
  8284. if config.IsOpen == 1 {
  8285. for _, item := range queryResult {
  8286. var result string
  8287. if record_type == 1 {
  8288. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8289. } else if record_type == 2 {
  8290. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8291. } else if record_type == 3 {
  8292. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8293. }
  8294. var dat2 map[string]interface{}
  8295. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8296. fmt.Println(dat2)
  8297. } else {
  8298. fmt.Println(err)
  8299. }
  8300. userJSONBytes, _ := json.Marshal(dat2)
  8301. var res ResultSix
  8302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8303. utils.ErrorLog("解析失败:%v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. if res.Infcode == 0 {
  8308. if record_type == 1 {
  8309. service.UpdateDrugByIdDetail(item.ID)
  8310. } else if record_type == 2 {
  8311. service.UpdateGoodInfoById(item.ID)
  8312. } else if record_type == 3 {
  8313. service.UpdateMyProjectById(item.ID)
  8314. }
  8315. c.ServeSuccessJSON(map[string]interface{}{
  8316. "failed_code": 0,
  8317. "msg": "撤销目录对照成功",
  8318. })
  8319. } else {
  8320. c.ServeSuccessJSON(map[string]interface{}{
  8321. "failed_code": -10,
  8322. "msg": res.ErrMsg,
  8323. })
  8324. }
  8325. }
  8326. }
  8327. }
  8328. func (c *HisApiController) GetPatientInfo() {
  8329. id_card_no := c.GetString("id_card_no")
  8330. admin_user_id, _ := c.GetInt64("admin_user_id")
  8331. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8332. if patient.ID == 0 {
  8333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8334. return
  8335. }
  8336. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8338. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8339. if config.IsOpen == 1 {
  8340. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8341. var dat map[string]interface{}
  8342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8343. fmt.Println(dat)
  8344. } else {
  8345. fmt.Println(err)
  8346. }
  8347. userJSONBytes, _ := json.Marshal(dat)
  8348. var res ResultTwo
  8349. var res10265 ResultTwo10265
  8350. if miConfig.Code == "H15049901371" {
  8351. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8352. utils.ErrorLog("解析失败:%v", err)
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. res.ErrMsg = res10265.ErrMsg
  8357. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8358. res.Infcode = infocode
  8359. res.Output = res10265.Output
  8360. res.InfRefmsgid = res10265.InfRefmsgid
  8361. } else {
  8362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8363. utils.ErrorLog("解析失败:%v", err)
  8364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8365. return
  8366. }
  8367. }
  8368. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8369. // utils.ErrorLog("解析失败:%v", err)
  8370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8371. // return
  8372. //}
  8373. if res.Infcode != 0 {
  8374. c.ServeSuccessJSON(map[string]interface{}{
  8375. "failed_code": -10,
  8376. "msg": res.ErrMsg,
  8377. })
  8378. } else {
  8379. c.ServeSuccessJSON(map[string]interface{}{
  8380. "failed_code": 0,
  8381. "info": res,
  8382. })
  8383. }
  8384. }
  8385. }
  8386. func (c *HisApiController) PsnPutOnRecord() {
  8387. record_type, _ := c.GetInt64("type")
  8388. patient_id, _ := c.GetInt64("patient_id")
  8389. admin_user_id, _ := c.GetInt64("admin_user_id")
  8390. start_time := c.GetString("start_time")
  8391. end_time := c.GetString("end_time")
  8392. adminUser := c.GetAdminUserInfo()
  8393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8394. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8395. var patients []*models.Patients
  8396. if record_type == 1 { //全部备案
  8397. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8398. patients = append(patients, patient...)
  8399. } else { //单个备案
  8400. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8401. patients = append(patients, patient)
  8402. }
  8403. var user_name string
  8404. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8405. if role.ID == 0 {
  8406. user_name = "xxx"
  8407. } else {
  8408. user_name = role.UserName
  8409. }
  8410. if config.IsOpen == 1 {
  8411. for _, item := range patients {
  8412. 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
  8413. resp, requestErr := http.Get(api)
  8414. if requestErr != nil {
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. defer resp.Body.Close()
  8419. body, ioErr := ioutil.ReadAll(resp.Body)
  8420. if ioErr != nil {
  8421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. var respJSON map[string]interface{}
  8426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8432. userJSONBytes, _ := json.Marshal(userJSON)
  8433. var res ResultTwo
  8434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8435. utils.ErrorLog("解析失败:%v", err)
  8436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8437. return
  8438. }
  8439. if res.Infcode == 0 {
  8440. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8441. var dat map[string]interface{}
  8442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8443. fmt.Println(dat)
  8444. } else {
  8445. fmt.Println(err)
  8446. }
  8447. userJSONBytes, _ := json.Marshal(dat)
  8448. var res2 ResultThirteen
  8449. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8450. utils.ErrorLog("解析失败:%v", err)
  8451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8452. return
  8453. }
  8454. if res2.Infcode == 0 {
  8455. psnResult := &models.GdybPsnRecord{
  8456. UserOrgId: adminUser.CurrentOrgId,
  8457. PatientId: item.ID,
  8458. PsnNo: res.Output.Baseinfo.PsnNo,
  8459. Ctime: time.Now().Unix(),
  8460. Mtime: time.Now().Unix(),
  8461. Status: 1,
  8462. IsCancel: 1,
  8463. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8464. }
  8465. service.CreatePsnRecord(psnResult)
  8466. } else {
  8467. c.ServeSuccessJSON(map[string]interface{}{
  8468. "failed_code": -10,
  8469. "msg": res2.ErrMsg,
  8470. })
  8471. return
  8472. }
  8473. }
  8474. }
  8475. }
  8476. }
  8477. func (c *HisApiController) PsnUnPutOnRecord() {
  8478. id, _ := c.GetInt64("id")
  8479. //record_type, _ := c.GetInt64("type")
  8480. admin_user_id, _ := c.GetInt64("admin_user_id")
  8481. adminUser := c.GetAdminUserInfo()
  8482. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8483. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8484. var user_name string
  8485. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8486. if role.ID == 0 {
  8487. user_name = "xxx"
  8488. } else {
  8489. user_name = role.UserName
  8490. }
  8491. psn_record, _ := service.GetPsnRecordById(id)
  8492. if psn_record.ID == 0 {
  8493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8494. return
  8495. }
  8496. if config.IsOpen == 1 {
  8497. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8498. var dat map[string]interface{}
  8499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8500. fmt.Println(dat)
  8501. } else {
  8502. fmt.Println(err)
  8503. }
  8504. userJSONBytes, _ := json.Marshal(dat)
  8505. var res ResultFourteen
  8506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8507. utils.ErrorLog("解析失败:%v", err)
  8508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8509. return
  8510. }
  8511. if res.Infcode == 0 {
  8512. psn_record.IsCancel = 2
  8513. service.CreatePsnRecord(&psn_record)
  8514. } else {
  8515. c.ServeSuccessJSON(map[string]interface{}{
  8516. "failed_code": -10,
  8517. "msg": res.ErrMsg,
  8518. })
  8519. return
  8520. }
  8521. }
  8522. }
  8523. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8524. patient_id, _ := c.GetInt64("patient_id")
  8525. insutype_two := c.GetString("insutype")
  8526. psn_no := c.GetString("psn_no")
  8527. doctor_id, _ := c.GetInt64("doctor_id")
  8528. sick_id, _ := c.GetInt64("sick_id")
  8529. department_id, _ := c.GetInt64("department_id")
  8530. start_time := c.GetString("start_time")
  8531. end_time := c.GetString("end_time")
  8532. check_time := c.GetString("check_time")
  8533. adminUser := c.GetAdminUserInfo()
  8534. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8535. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8536. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8537. sick, _ := service.FindSickById(sick_id)
  8538. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8539. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8540. var res ResultTwo
  8541. var res10265 ResultTwo10265
  8542. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8543. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8544. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8545. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8547. resp, requestErr := http.Get(api)
  8548. if requestErr != nil {
  8549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8550. return
  8551. }
  8552. body, ioErr := ioutil.ReadAll(resp.Body)
  8553. if ioErr != nil {
  8554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8556. return
  8557. }
  8558. var respJSON map[string]interface{}
  8559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8565. result, _ := json.Marshal(respJSON)
  8566. fmt.Println("log")
  8567. fmt.Println(string(result))
  8568. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8569. utils.ErrorLog("解析失败:%v", err)
  8570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8571. return
  8572. }
  8573. res.ErrMsg = res10265.ErrMsg
  8574. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8575. res.Infcode = infocode
  8576. res.Output = res10265.Output
  8577. res.InfRefmsgid = res10265.InfRefmsgid
  8578. } else {
  8579. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8580. if miConfig.Code == "H15049901371" {
  8581. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8582. utils.ErrorLog("解析失败:%v", err)
  8583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8584. return
  8585. }
  8586. res.ErrMsg = res10265.ErrMsg
  8587. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8588. res.Infcode = infocode
  8589. res.Output = res10265.Output
  8590. res.InfRefmsgid = res10265.InfRefmsgid
  8591. } else {
  8592. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8593. utils.ErrorLog("解析失败:%v", err)
  8594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8595. return
  8596. }
  8597. }
  8598. }
  8599. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8600. infoStr := string(Iinfos)
  8601. var rf []*ResultFive
  8602. json.Unmarshal([]byte(infoStr), &rf)
  8603. var insuplc_admdvs string
  8604. var insutype string
  8605. var is390 int = 0
  8606. var is310 int = 0
  8607. var insutypes []*ResultFive
  8608. for _, item := range rf {
  8609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8610. insutypes = append(insutypes, item)
  8611. }
  8612. }
  8613. if len(insutypes) == 1 {
  8614. insutype = insutypes[0].Insutype
  8615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8616. } else {
  8617. for _, i := range insutypes {
  8618. if i.Insutype == "390" {
  8619. is390 = 1
  8620. }
  8621. if i.Insutype == "310" {
  8622. is310 = 1
  8623. }
  8624. }
  8625. }
  8626. if is390 == 1 {
  8627. insutype = "390"
  8628. }
  8629. if is310 == 1 {
  8630. insutype = "310"
  8631. }
  8632. if len(insutypes) == 2 {
  8633. insutype = insutype_two
  8634. }
  8635. if len(insutypes) == 0 {
  8636. insutype = "310"
  8637. }
  8638. insutype = insutype_two
  8639. fmt.Println(insutype)
  8640. for _, item := range rf {
  8641. fmt.Println(item.Insutype)
  8642. fmt.Println(insutype)
  8643. if item.Insutype == insutype {
  8644. fmt.Println(item.Insutype)
  8645. fmt.Println(insutype)
  8646. insuplc_admdvs = item.InsuplcAdmdvs
  8647. }
  8648. }
  8649. fmt.Println(insuplc_admdvs)
  8650. var res2 ResultThirteen
  8651. var res10265_2 ResultThirteen10265
  8652. if config.IsOpen == 1 {
  8653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8654. } else {
  8655. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  8656. var dat map[string]interface{}
  8657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8658. fmt.Println(dat)
  8659. } else {
  8660. fmt.Println(err)
  8661. }
  8662. userJSONBytes, _ := json.Marshal(dat)
  8663. if miConfig.Code == "H15049901371" {
  8664. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8665. utils.ErrorLog("解析失败:%v", err)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. res2.ErrMsg = res10265_2.ErrMsg
  8670. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8671. res2.Infcode = infocode
  8672. res2.Output = res10265_2.Output
  8673. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8674. } else {
  8675. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8676. utils.ErrorLog("解析失败:%v", err)
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8678. return
  8679. }
  8680. }
  8681. }
  8682. if res2.Infcode == 0 {
  8683. psnResult := &models.GdybPsnNcdsRecord{
  8684. UserOrgId: adminUser.CurrentOrgId,
  8685. PatientId: patient.ID,
  8686. PsnNo: psn_no,
  8687. DoctorId: doctor.AdminUserId,
  8688. DepartmentId: department_id,
  8689. SickType: sick_id,
  8690. Insutype: insutype,
  8691. Ctime: time.Now().Unix(),
  8692. Mtime: time.Now().Unix(),
  8693. Status: 1,
  8694. IsCancel: 1,
  8695. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8696. }
  8697. service.CreatePsnNCDSRecord(psnResult)
  8698. c.ServeSuccessJSON(map[string]interface{}{
  8699. "failed_code": 0,
  8700. "msg": "备案成功",
  8701. "result": psnResult,
  8702. })
  8703. } else {
  8704. c.ServeSuccessJSON(map[string]interface{}{
  8705. "failed_code": -10,
  8706. "msg": res2.ErrMsg,
  8707. })
  8708. return
  8709. }
  8710. }
  8711. }
  8712. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8713. id, _ := c.GetInt64("id")
  8714. admin_user_id, _ := c.GetInt64("admin_user_id")
  8715. adminUser := c.GetAdminUserInfo()
  8716. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8717. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8718. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8719. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8720. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8721. //var user_name string
  8722. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8723. //if role.ID == 0 {
  8724. // user_name = "xxx"
  8725. //} else {
  8726. // user_name = role.UserName
  8727. //}
  8728. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8729. if psn_record.ID == 0 {
  8730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8731. return
  8732. }
  8733. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8734. var res ResultTwo
  8735. var res10265 ResultTwo10265
  8736. if miConfig.Code == "H15049901371" {
  8737. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8738. utils.ErrorLog("解析失败:%v", err)
  8739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8740. return
  8741. }
  8742. res.ErrMsg = res10265.ErrMsg
  8743. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8744. res.Infcode = infocode
  8745. res.Output = res10265.Output
  8746. res.InfRefmsgid = res10265.InfRefmsgid
  8747. } else {
  8748. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8749. utils.ErrorLog("解析失败:%v", err)
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. }
  8754. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8755. infoStr := string(Iinfos)
  8756. var rf []*ResultFive
  8757. json.Unmarshal([]byte(infoStr), &rf)
  8758. var insuplc_admdvs string
  8759. var insutype string
  8760. var is390 int = 0
  8761. var is310 int = 0
  8762. var insutypes []*ResultFive
  8763. for _, item := range rf {
  8764. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8765. insutypes = append(insutypes, item)
  8766. }
  8767. }
  8768. if len(insutypes) == 1 {
  8769. insutype = insutypes[0].Insutype
  8770. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8771. } else {
  8772. for _, i := range insutypes {
  8773. if i.Insutype == "390" {
  8774. is390 = 1
  8775. }
  8776. if i.Insutype == "310" {
  8777. is310 = 1
  8778. }
  8779. }
  8780. }
  8781. if is390 == 1 {
  8782. insutype = "390"
  8783. }
  8784. if is310 == 1 {
  8785. insutype = "310"
  8786. }
  8787. if len(insutypes) == 0 {
  8788. insutype = "310"
  8789. }
  8790. insutype = psn_record.Insutype
  8791. for _, item := range rf {
  8792. if item.Insutype == insutype {
  8793. insuplc_admdvs = item.InsuplcAdmdvs
  8794. }
  8795. }
  8796. if config.IsOpen == 1 {
  8797. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8798. var dat map[string]interface{}
  8799. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8800. fmt.Println(dat)
  8801. } else {
  8802. fmt.Println(err)
  8803. }
  8804. userJSONBytes, _ := json.Marshal(dat)
  8805. var res ResultFourteen
  8806. var res10265 ResultFourteen10265
  8807. if miConfig.Code == "H15049901371" {
  8808. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8809. utils.ErrorLog("解析失败:%v", err)
  8810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8811. return
  8812. }
  8813. res.ErrMsg = res10265.ErrMsg
  8814. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8815. res.Infcode = infocode
  8816. res.Output = res10265.Output
  8817. res.InfRefmsgid = res10265.InfRefmsgid
  8818. } else {
  8819. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8820. utils.ErrorLog("解析失败:%v", err)
  8821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8822. return
  8823. }
  8824. }
  8825. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8826. // utils.ErrorLog("解析失败:%v", err)
  8827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8828. // return
  8829. //}
  8830. if res.Infcode == 0 {
  8831. psn_record.IsCancel = 2
  8832. service.CreatePsnNCDSRecord(&psn_record)
  8833. c.ServeSuccessJSON(map[string]interface{}{
  8834. "failed_code": 0,
  8835. "msg": "撤销备案成功",
  8836. })
  8837. } else {
  8838. c.ServeSuccessJSON(map[string]interface{}{
  8839. "failed_code": -10,
  8840. "msg": res.ErrMsg,
  8841. })
  8842. return
  8843. }
  8844. }
  8845. }
  8846. func (c *HisApiController) TestTest() {
  8847. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8848. fmt.Println(patient.Iinfo)
  8849. }
  8850. type CustomData struct {
  8851. MsgId string
  8852. PsnNo string
  8853. Info string
  8854. }
  8855. func (c *HisApiController) ReversalData() {
  8856. var customData []*CustomData
  8857. custom := &CustomData{
  8858. MsgId: "H44022900158202103301714472004",
  8859. PsnNo: "44020000001101329945",
  8860. Info: "2207",
  8861. }
  8862. customData = append(customData, custom)
  8863. custom1 := &CustomData{
  8864. MsgId: "H4402290015820210330172057803",
  8865. PsnNo: "44020000001101161813",
  8866. Info: "2207",
  8867. }
  8868. customData = append(customData, custom1)
  8869. custom2 := &CustomData{
  8870. MsgId: "H44022900158202103301705198813",
  8871. PsnNo: "44190000133097375417",
  8872. Info: "2207",
  8873. }
  8874. customData = append(customData, custom2)
  8875. custom3 := &CustomData{
  8876. MsgId: "H44022900158202103301715524756",
  8877. PsnNo: "44020000001100187221",
  8878. Info: "2207",
  8879. }
  8880. customData = append(customData, custom3)
  8881. custom4 := &CustomData{
  8882. MsgId: "H44022900158202103301730376224",
  8883. PsnNo: "44020000001101959155",
  8884. Info: "2207",
  8885. }
  8886. customData = append(customData, custom4)
  8887. custom5 := &CustomData{
  8888. MsgId: "H44022900158202103301748008725",
  8889. PsnNo: "44020000001104246641",
  8890. Info: "2207",
  8891. }
  8892. customData = append(customData, custom5)
  8893. custom6 := &CustomData{
  8894. MsgId: "H44022900158202103301718096755",
  8895. PsnNo: "44020000001102211860",
  8896. Info: "2207",
  8897. }
  8898. customData = append(customData, custom6)
  8899. custom7 := &CustomData{
  8900. MsgId: "H44022900158202103301736551640",
  8901. PsnNo: "44020000001102687718",
  8902. Info: "2207",
  8903. }
  8904. customData = append(customData, custom7)
  8905. custom8 := &CustomData{
  8906. MsgId: "H44022900158202103301743097676",
  8907. PsnNo: "44020000001102127785",
  8908. Info: "2207",
  8909. }
  8910. customData = append(customData, custom8)
  8911. custom9 := &CustomData{
  8912. MsgId: "H44022900158202103301712304203",
  8913. PsnNo: "44020000001101518097",
  8914. Info: "2207",
  8915. }
  8916. customData = append(customData, custom9)
  8917. custom10 := &CustomData{
  8918. MsgId: "H44022900158202103301738448785",
  8919. PsnNo: "44020000001100500813",
  8920. Info: "2207",
  8921. }
  8922. customData = append(customData, custom10)
  8923. custom11 := &CustomData{
  8924. MsgId: "H44022900158202103301732455843",
  8925. PsnNo: "44020000001102690557",
  8926. Info: "2207",
  8927. }
  8928. customData = append(customData, custom11)
  8929. custom12 := &CustomData{
  8930. MsgId: "H44022900158202103301745421708",
  8931. PsnNo: "44020000001102211928",
  8932. Info: "2207",
  8933. }
  8934. customData = append(customData, custom12)
  8935. custom1212 := &CustomData{
  8936. MsgId: "H440229001582021033017351627",
  8937. PsnNo: "44020000001102481733",
  8938. Info: "2207",
  8939. }
  8940. customData = append(customData, custom1212)
  8941. custom13 := &CustomData{
  8942. MsgId: "H44022900158202103301740327951",
  8943. PsnNo: "44020000001103174866",
  8944. Info: "2207",
  8945. }
  8946. customData = append(customData, custom13)
  8947. custom14 := &CustomData{
  8948. MsgId: "H4402290015820210330174922668",
  8949. PsnNo: "44020000001102927272",
  8950. Info: "2207",
  8951. }
  8952. customData = append(customData, custom14)
  8953. custom15 := &CustomData{
  8954. MsgId: "H44022900158202103301752362273",
  8955. PsnNo: "44020000001102942890",
  8956. Info: "2207",
  8957. }
  8958. customData = append(customData, custom15)
  8959. custom16 := &CustomData{
  8960. MsgId: "H44022900158202103301751082917",
  8961. PsnNo: "44020000001101662162",
  8962. Info: "2207",
  8963. }
  8964. customData = append(customData, custom16)
  8965. custom17 := &CustomData{
  8966. MsgId: "H44022900158202103301754147728",
  8967. PsnNo: "44020000000229014511",
  8968. Info: "2207",
  8969. }
  8970. customData = append(customData, custom17)
  8971. adminUser := c.GetAdminUserInfo()
  8972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8973. for _, item := range customData {
  8974. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8975. fmt.Println(result)
  8976. }
  8977. }
  8978. func (c *HisApiController) GetAllopatry() {
  8979. year := c.GetString("year")
  8980. month := c.GetString("month")
  8981. admin_user_id, _ := c.GetInt64("admin_user_id")
  8982. adminUser := c.GetAdminUserInfo()
  8983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8984. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8985. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8986. var dat map[string]interface{}
  8987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8988. fmt.Println(dat)
  8989. } else {
  8990. fmt.Println(err)
  8991. }
  8992. userJSONBytes, _ := json.Marshal(dat)
  8993. var res models.Result9001
  8994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8995. utils.ErrorLog("解析失败:%v", err)
  8996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8997. return
  8998. }
  8999. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9000. var dat2 map[string]interface{}
  9001. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9002. fmt.Println(dat)
  9003. } else {
  9004. fmt.Println(err)
  9005. }
  9006. userJSONBytes2, _ := json.Marshal(dat2)
  9007. var res2 models.Result3260
  9008. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9009. utils.ErrorLog("解析失败:%v", err)
  9010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. return
  9012. }
  9013. if res2.Infcode == 0 {
  9014. c.ServeSuccessJSON(map[string]interface{}{
  9015. "list": res2.Output.Data,
  9016. })
  9017. return
  9018. } else {
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9020. return
  9021. }
  9022. }
  9023. func (c *HisApiController) ComfirmAllopatry() {
  9024. year := c.GetString("year")
  9025. month := c.GetString("month")
  9026. admin_user_id, _ := c.GetInt64("admin_user_id")
  9027. adminUser := c.GetAdminUserInfo()
  9028. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9029. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9030. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9031. var dat map[string]interface{}
  9032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9033. fmt.Println(dat)
  9034. } else {
  9035. fmt.Println(err)
  9036. }
  9037. userJSONBytes, _ := json.Marshal(dat)
  9038. var res models.Result9001
  9039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9040. utils.ErrorLog("解析失败:%v", err)
  9041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9042. return
  9043. }
  9044. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9045. var dat2 map[string]interface{}
  9046. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9047. fmt.Println(dat)
  9048. } else {
  9049. fmt.Println(err)
  9050. }
  9051. userJSONBytes2, _ := json.Marshal(dat2)
  9052. var res2 models.Result3260
  9053. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9054. utils.ErrorLog("解析失败:%v", err)
  9055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9056. return
  9057. }
  9058. if res2.Infcode == 0 {
  9059. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9060. var dat map[string]interface{}
  9061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9062. fmt.Println(dat)
  9063. } else {
  9064. fmt.Println(err)
  9065. }
  9066. userJSONBytes, _ := json.Marshal(dat)
  9067. var res3 models.Result3261
  9068. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9069. utils.ErrorLog("解析失败:%v", err)
  9070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9071. return
  9072. }
  9073. if res3.Infcode == 0 {
  9074. record := &models.HisYidiClearRecord{
  9075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9076. Ctime: time.Now().Unix(),
  9077. Mtime: time.Now().Unix(),
  9078. Status: 1,
  9079. MsgId: msgId,
  9080. }
  9081. service.SaveClearRecord(record)
  9082. c.ServeSuccessJSON(map[string]interface{}{
  9083. "msg": "提取成功",
  9084. })
  9085. }
  9086. }
  9087. }
  9088. func (c *HisApiController) RefundAllopatry() {
  9089. year := c.GetString("year")
  9090. month := c.GetString("month")
  9091. id, _ := c.GetInt64("id")
  9092. admin_user_id, _ := c.GetInt64("admin_user_id")
  9093. adminUser := c.GetAdminUserInfo()
  9094. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9095. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9096. record, _ := service.GetClearRecordById(id)
  9097. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9098. var dat map[string]interface{}
  9099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9100. fmt.Println(dat)
  9101. } else {
  9102. fmt.Println(err)
  9103. }
  9104. userJSONBytes, _ := json.Marshal(dat)
  9105. var empty ResultFourteen
  9106. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9107. utils.ErrorLog("解析失败:%v", err)
  9108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9109. return
  9110. }
  9111. if empty.Infcode == 0 {
  9112. c.ServeSuccessJSON(map[string]interface{}{
  9113. "msg": "撤销成功",
  9114. })
  9115. return
  9116. }
  9117. }
  9118. func (c *HisApiController) ReversalOtherData() {
  9119. var customData []*CustomData
  9120. custom := &CustomData{
  9121. MsgId: "H44022900158202103301714472004",
  9122. PsnNo: "44020000001101329945",
  9123. Info: "2208",
  9124. }
  9125. customData = append(customData, custom)
  9126. custom1 := &CustomData{
  9127. MsgId: "H4402290015820210330172057803",
  9128. PsnNo: "44020000001101161813",
  9129. Info: "2208",
  9130. }
  9131. customData = append(customData, custom1)
  9132. custom2 := &CustomData{
  9133. MsgId: "H44022900158202103301705198813",
  9134. PsnNo: "44190000133097375417",
  9135. Info: "2208",
  9136. }
  9137. customData = append(customData, custom2)
  9138. custom3 := &CustomData{
  9139. MsgId: "H44022900158202103301715524756",
  9140. PsnNo: "44020000001100187221",
  9141. Info: "2208",
  9142. }
  9143. customData = append(customData, custom3)
  9144. custom4 := &CustomData{
  9145. MsgId: "H44022900158202103301730376224",
  9146. PsnNo: "44020000001101959155",
  9147. Info: "2208",
  9148. }
  9149. customData = append(customData, custom4)
  9150. custom5 := &CustomData{
  9151. MsgId: "H44022900158202103301748008725",
  9152. PsnNo: "44020000001104246641",
  9153. Info: "2208",
  9154. }
  9155. customData = append(customData, custom5)
  9156. custom6 := &CustomData{
  9157. MsgId: "H44022900158202103301718096755",
  9158. PsnNo: "44020000001102211860",
  9159. Info: "2208",
  9160. }
  9161. customData = append(customData, custom6)
  9162. custom7 := &CustomData{
  9163. MsgId: "H44022900158202103301736551640",
  9164. PsnNo: "44020000001102687718",
  9165. Info: "2208",
  9166. }
  9167. customData = append(customData, custom7)
  9168. custom8 := &CustomData{
  9169. MsgId: "H44022900158202103301743097676",
  9170. PsnNo: "44020000001102127785",
  9171. Info: "2208",
  9172. }
  9173. customData = append(customData, custom8)
  9174. custom9 := &CustomData{
  9175. MsgId: "H44022900158202103301712304203",
  9176. PsnNo: "44020000001101518097",
  9177. Info: "2208",
  9178. }
  9179. customData = append(customData, custom9)
  9180. custom10 := &CustomData{
  9181. MsgId: "H44022900158202103301738448785",
  9182. PsnNo: "44020000001100500813",
  9183. Info: "2208",
  9184. }
  9185. customData = append(customData, custom10)
  9186. custom11 := &CustomData{
  9187. MsgId: "H44022900158202103301732455843",
  9188. PsnNo: "44020000001102690557",
  9189. Info: "2208",
  9190. }
  9191. customData = append(customData, custom11)
  9192. custom12 := &CustomData{
  9193. MsgId: "H44022900158202103301745421708",
  9194. PsnNo: "44020000001102211928",
  9195. Info: "2208",
  9196. }
  9197. customData = append(customData, custom12)
  9198. custom1212 := &CustomData{
  9199. MsgId: "H440229001582021033017351627",
  9200. PsnNo: "44020000001102481733",
  9201. Info: "2208",
  9202. }
  9203. customData = append(customData, custom1212)
  9204. custom13 := &CustomData{
  9205. MsgId: "H44022900158202103301740327951",
  9206. PsnNo: "44020000001103174866",
  9207. Info: "2208",
  9208. }
  9209. customData = append(customData, custom13)
  9210. custom14 := &CustomData{
  9211. MsgId: "H4402290015820210330174922668",
  9212. PsnNo: "44020000001102927272",
  9213. Info: "2208",
  9214. }
  9215. customData = append(customData, custom14)
  9216. custom15 := &CustomData{
  9217. MsgId: "H44022900158202103301752362273",
  9218. PsnNo: "44020000001102942890",
  9219. Info: "2208",
  9220. }
  9221. customData = append(customData, custom15)
  9222. custom16 := &CustomData{
  9223. MsgId: "H44022900158202103301751082917",
  9224. PsnNo: "44020000001101662162",
  9225. Info: "2208",
  9226. }
  9227. customData = append(customData, custom16)
  9228. custom17 := &CustomData{
  9229. MsgId: "H44022900158202103301754147728",
  9230. PsnNo: "44020000000229014511",
  9231. Info: "2208",
  9232. }
  9233. customData = append(customData, custom17)
  9234. adminUser := c.GetAdminUserInfo()
  9235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9236. for _, item := range customData {
  9237. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9238. fmt.Println(result)
  9239. }
  9240. }
  9241. func PathExists(path string) (bool, error) {
  9242. _, err := os.Stat(path)
  9243. if err == nil {
  9244. return true, nil
  9245. }
  9246. if os.IsNotExist(err) {
  9247. return false, nil
  9248. }
  9249. return false, err
  9250. }
  9251. //创建文件夹
  9252. func Mkdir(dir string) {
  9253. // 创建文件夹
  9254. exist, err := PathExists(dir)
  9255. if err != nil {
  9256. fmt.Println(err.Error())
  9257. } else {
  9258. if exist {
  9259. fmt.Println(dir + "文件夹已存在!")
  9260. } else {
  9261. // 文件夹名称,权限
  9262. err := os.Mkdir(dir, os.ModePerm)
  9263. if err != nil {
  9264. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9265. } else {
  9266. fmt.Println(dir + "文件夹创建成功!")
  9267. }
  9268. }
  9269. }
  9270. }
  9271. //压缩文件
  9272. func Zip(srcFile string, destZip string) error {
  9273. zipfile, err := os.Create(destZip)
  9274. if err != nil {
  9275. return err
  9276. }
  9277. defer zipfile.Close()
  9278. archive := zip.NewWriter(zipfile)
  9279. defer archive.Close()
  9280. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9281. if err != nil {
  9282. return err
  9283. }
  9284. header, err := zip.FileInfoHeader(info)
  9285. if err != nil {
  9286. return err
  9287. }
  9288. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9289. // header.Name = path
  9290. if info.IsDir() {
  9291. header.Name += "/"
  9292. } else {
  9293. header.Method = zip.Deflate
  9294. }
  9295. writer, err := archive.CreateHeader(header)
  9296. if err != nil {
  9297. return err
  9298. }
  9299. if !info.IsDir() {
  9300. file, err := os.Open(path)
  9301. if err != nil {
  9302. return err
  9303. }
  9304. defer file.Close()
  9305. _, err = io.Copy(writer, file)
  9306. }
  9307. return err
  9308. })
  9309. return err
  9310. }
  9311. func ReadFile(filePath string) []byte {
  9312. f, err := os.Open(filePath)
  9313. if err != nil {
  9314. fmt.Println("read file fail", err)
  9315. return nil
  9316. }
  9317. defer f.Close()
  9318. fd, err := ioutil.ReadAll(f)
  9319. if err != nil {
  9320. fmt.Println("read to fd fail", err)
  9321. return nil
  9322. }
  9323. return fd
  9324. }
  9325. func saveLog(result string, request string, infno string, desc string) {
  9326. org_id, _ := beego.AppConfig.Int64("org_id")
  9327. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9328. dir := miConfig.OrgName + "日志"
  9329. utils.Mkdir(dir)
  9330. month := time.Unix(1557042972, 0).Format("1")
  9331. year := time.Now().Format("2006")
  9332. month = time.Now().Format("01")
  9333. day := time.Now().Format("02")
  9334. hour := time.Now().Format("15")
  9335. min := time.Now().Format("04")
  9336. sec := time.Now().Format("05")
  9337. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9338. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9339. file_name := file + ".txt"
  9340. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9341. exist, _ := utils.PathExists(file_path)
  9342. if exist { //存在
  9343. fmt.Println("存在")
  9344. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9345. if err != nil {
  9346. fmt.Println("read fail")
  9347. }
  9348. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9349. n, _ := f.Seek(0, 2)
  9350. _, err = f.WriteAt([]byte(content), n)
  9351. } else { //不存在
  9352. fmt.Println("文件不存在,创建文件")
  9353. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9354. defer f.Close()
  9355. if err != nil {
  9356. } else {
  9357. _, err = f.Write([]byte("记录日志"))
  9358. }
  9359. }
  9360. }
  9361. type Charset string
  9362. const (
  9363. UTF8 = Charset("UTF-8")
  9364. GB18030 = Charset("GB18030")
  9365. )
  9366. func ConvertToString(src string, srcCode string, tagCode string) string {
  9367. srcCoder := mahonia.NewDecoder(srcCode)
  9368. srcResult := srcCoder.ConvertString(src)
  9369. tagCoder := mahonia.NewDecoder(tagCode)
  9370. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9371. result := string(cdata)
  9372. return result
  9373. }