his_api_controller.go 381KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454
  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 tempDiaginfos []service.DiaginfoStructTwo
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  669. diagnosis_ids := strings.Split(order.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 index, item := range config {
  677. if index == 0 {
  678. var tempDiaginfo service.DiaginfoStructTwo
  679. tempDiaginfo.DiagCode = item.CountryCode
  680. tempDiaginfo.DiagName = item.CountryContentName
  681. tempDiaginfo.DiagType = "1"
  682. tempDiaginfo.MaindiagFlag = "1"
  683. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  684. } else {
  685. var tempDiaginfo service.DiaginfoStructTwo
  686. tempDiaginfo.DiagCode = item.CountryCode
  687. tempDiaginfo.DiagName = item.CountryContentName
  688. tempDiaginfo.DiagType = "2"
  689. tempDiaginfo.MaindiagFlag = "0"
  690. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  691. }
  692. }
  693. sickConfigTwo, _ := service.FindSickById(his.SickType)
  694. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  695. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  696. tempOpspdiseinfo2.OprnOprtCode = ""
  697. tempOpspdiseinfo2.OprnOprtName = ""
  698. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  699. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  700. var iteminfo service.IteminfoStruct
  701. var bedCostTotal float64 = 0 //床位总费
  702. var bedCostSelfTotal float64 = 0 //床位自费
  703. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  704. var operationCostTotal float64 = 0 //手术费
  705. var operationCostSelfTotal float64 = 0 //手术费
  706. var operationCostPartSelfTotal float64 = 0 //手术费
  707. var otherCostTotal float64 = 0 //其他费用
  708. var otherCostSelfTotal float64 = 0 //其他费用
  709. var otherCostPartSelfTotal float64 = 0 //其他费用
  710. var materialCostTotal float64 = 0 //材料费
  711. var materialCostSelfTotal float64 = 0 //材料费
  712. var materialCostPartSelfTotal float64 = 0 //材料费
  713. var westernMedicineCostTotal float64 = 0 //西药费
  714. var westernMedicineCostSelfTotal float64 = 0 //西药费
  715. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  716. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  717. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  718. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  719. var checkCostTotal float64 = 0 //检查费
  720. var checkCostSelfTotal float64 = 0 //检查费
  721. var checkCostPartSelfTotal float64 = 0 //检查费
  722. var laboratoryCostTotal float64 = 0 //化验费
  723. var laboratoryCostSelfTotal float64 = 0 //化验费
  724. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  725. var treatCostTotal float64 = 0 //治疗费用
  726. var treatCostSelfTotal float64 = 0 //治疗费用
  727. var treatCostPartSelfTotal float64 = 0 //治疗费用
  728. decimal.DivisionPrecision = 2
  729. var bed_fulamt_ownpay_amt float64 = 0
  730. var operation_fulamt_ownpay_amt float64 = 0
  731. var other_fulamt_ownpay_amt float64 = 0
  732. var westernMedicine_fulamt_ownpay_amt float64 = 0
  733. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  734. var check_fulamt_ownpay_amt float64 = 0
  735. var material_fulamt_ownpay_amt float64 = 0
  736. var laboratory_fulamt_ownpay_amt float64 = 0
  737. var treat_fulamt_ownpay_amt float64 = 0
  738. var bed_claa_sunmfee float64 = 0
  739. var bed_clab_amt float64 = 0
  740. var bed_other_amt float64 = 0
  741. var operation_claa_sunmfee float64 = 0
  742. var operation_clab_amt float64 = 0
  743. var operation_other_amt float64 = 0
  744. var other_claa_sunmfee float64 = 0
  745. var other_clab_amt float64 = 0
  746. var other_other_amt float64 = 0
  747. var westernMedicine_claa_sunmfee float64 = 0
  748. var westernMedicine_clab_amt float64 = 0
  749. var westernMedicine_other_amt float64 = 0
  750. var chineseTraditional_claa_sunmfee float64 = 0
  751. var chineseTraditional_clab_amt float64 = 0
  752. var chineseTraditional_other_amt float64 = 0
  753. var check_claa_sunmfee float64 = 0
  754. var check_clab_amt float64 = 0
  755. var check_other_amt float64 = 0
  756. var material_claa_sunmfee float64 = 0
  757. var material_clab_amt float64 = 0
  758. var material_other_amt float64 = 0
  759. var laboratory_claa_sunmfee float64 = 0
  760. var laboratory_clab_amt float64 = 0
  761. var laboratory_other_amt float64 = 0
  762. var treat_claa_sunmfee float64 = 0
  763. var treat_clab_amt float64 = 0
  764. var treat_other_amt float64 = 0
  765. for _, item := range order.HisOrderInfo {
  766. if item.MedChrgitmType == "01" { //床位费
  767. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  768. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  769. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  770. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  771. if item.ChrgitmLv == "1" {
  772. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  773. }
  774. if item.ChrgitmLv == "2" {
  775. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  776. }
  777. if item.ChrgitmLv == "3" {
  778. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  779. }
  780. }
  781. if item.MedChrgitmType == "03" { //检查费
  782. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  783. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  784. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  785. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  786. if item.ChrgitmLv == "1" {
  787. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  788. }
  789. if item.ChrgitmLv == "2" {
  790. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  791. }
  792. if item.ChrgitmLv == "3" {
  793. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  794. }
  795. }
  796. if item.MedChrgitmType == "04" { //化验费
  797. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  798. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  799. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  800. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  801. if item.ChrgitmLv == "1" {
  802. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  803. }
  804. if item.ChrgitmLv == "2" {
  805. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  806. }
  807. if item.ChrgitmLv == "3" {
  808. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  809. }
  810. }
  811. if item.MedChrgitmType == "05" { //治疗费
  812. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  813. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  814. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  815. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  816. if item.ChrgitmLv == "1" {
  817. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  818. }
  819. if item.ChrgitmLv == "2" {
  820. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  821. }
  822. if item.ChrgitmLv == "3" {
  823. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  824. }
  825. }
  826. if item.MedChrgitmType == "06" { //手术费
  827. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  828. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  829. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  830. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  831. if item.ChrgitmLv == "1" {
  832. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  833. }
  834. if item.ChrgitmLv == "2" {
  835. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  836. }
  837. if item.ChrgitmLv == "3" {
  838. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  839. }
  840. }
  841. if item.MedChrgitmType == "08" { //材料费
  842. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  843. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  844. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  845. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  846. if item.ChrgitmLv == "1" {
  847. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  848. }
  849. if item.ChrgitmLv == "2" {
  850. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  851. }
  852. if item.ChrgitmLv == "3" {
  853. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  854. }
  855. }
  856. if item.MedChrgitmType == "09" { //西药费
  857. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  858. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  859. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  860. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  861. if item.ChrgitmLv == "1" {
  862. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  863. }
  864. if item.ChrgitmLv == "2" {
  865. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  866. }
  867. if item.ChrgitmLv == "3" {
  868. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  869. }
  870. }
  871. if item.MedChrgitmType == "11" { //中成费
  872. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  873. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  874. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  875. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  876. if item.ChrgitmLv == "1" {
  877. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  878. }
  879. if item.ChrgitmLv == "2" {
  880. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  881. }
  882. if item.ChrgitmLv == "3" {
  883. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  884. }
  885. }
  886. if item.MedChrgitmType == "14" { //其他费
  887. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  888. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  889. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  890. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  891. if item.ChrgitmLv == "1" {
  892. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  893. }
  894. if item.ChrgitmLv == "2" {
  895. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  896. }
  897. if item.ChrgitmLv == "3" {
  898. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  899. }
  900. }
  901. }
  902. var iteminfoStructs []service.IteminfoStruct
  903. if bedCostTotal != 0 {
  904. iteminfo.MedChrgitm = "01"
  905. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  906. iteminfo.Amt = bedCostTotal
  907. iteminfo.ClaaSumfee = bed_claa_sunmfee
  908. iteminfo.ClabAmt = bed_clab_amt
  909. iteminfo.OthAmt = bed_other_amt
  910. iteminfoStructs = append(iteminfoStructs, iteminfo)
  911. }
  912. if checkCostTotal != 0 {
  913. iteminfo.MedChrgitm = "03"
  914. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  915. iteminfo.Amt = checkCostTotal
  916. iteminfo.ClaaSumfee = check_claa_sunmfee
  917. iteminfo.ClabAmt = check_clab_amt
  918. iteminfo.OthAmt = check_other_amt
  919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  920. }
  921. if laboratoryCostTotal != 0 {
  922. iteminfo.MedChrgitm = "04"
  923. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  924. iteminfo.Amt = laboratoryCostTotal
  925. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  926. iteminfo.ClabAmt = laboratory_clab_amt
  927. iteminfo.OthAmt = laboratory_other_amt
  928. iteminfoStructs = append(iteminfoStructs, iteminfo)
  929. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  930. }
  931. if treatCostTotal != 0 {
  932. iteminfo.MedChrgitm = "05"
  933. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  934. iteminfo.Amt = treatCostTotal
  935. iteminfo.ClaaSumfee = treat_claa_sunmfee
  936. iteminfo.ClabAmt = treat_clab_amt
  937. iteminfo.OthAmt = treat_other_amt
  938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  939. //(struct4101.IteminfoStruct, iteminfo)
  940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  941. }
  942. if operationCostTotal != 0 {
  943. iteminfo.MedChrgitm = "06"
  944. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  945. iteminfo.Amt = operationCostTotal
  946. iteminfo.ClaaSumfee = operation_claa_sunmfee
  947. iteminfo.ClabAmt = operation_clab_amt
  948. iteminfo.OthAmt = operation_other_amt
  949. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  951. }
  952. if materialCostTotal != 0 {
  953. iteminfo.MedChrgitm = "08"
  954. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  955. iteminfo.Amt = materialCostTotal
  956. iteminfo.ClaaSumfee = material_claa_sunmfee
  957. iteminfo.ClabAmt = material_clab_amt
  958. iteminfo.OthAmt = material_other_amt
  959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  961. }
  962. if westernMedicineCostTotal != 0 {
  963. iteminfo.MedChrgitm = "09"
  964. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  965. iteminfo.Amt = westernMedicineCostTotal
  966. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  967. iteminfo.ClabAmt = westernMedicine_clab_amt
  968. iteminfo.OthAmt = westernMedicine_other_amt
  969. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  970. iteminfoStructs = append(iteminfoStructs, iteminfo)
  971. }
  972. if chineseTraditionalMedicineCostTotal != 0 {
  973. iteminfo.MedChrgitm = "11"
  974. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  975. iteminfo.Amt = westernMedicineCostTotal
  976. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  977. iteminfo.ClabAmt = westernMedicine_clab_amt
  978. iteminfo.OthAmt = westernMedicine_other_amt
  979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  981. }
  982. if otherCostTotal != 0 {
  983. iteminfo.MedChrgitm = "14"
  984. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  985. iteminfo.Amt = otherCostTotal
  986. iteminfo.ClaaSumfee = other_claa_sunmfee
  987. iteminfo.ClabAmt = other_clab_amt
  988. iteminfo.OthAmt = other_other_amt
  989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  991. }
  992. struct4101.IteminfoStruct = iteminfoStructs
  993. struct4101.Ntly = "中国"
  994. struct4101.AdmCaty = "A03.06"
  995. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  996. fmt.Println(result)
  997. var dat map[string]interface{}
  998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  999. fmt.Println(dat)
  1000. } else {
  1001. fmt.Println(err)
  1002. }
  1003. userJSONBytes, _ := json.Marshal(dat)
  1004. var res ResultSeventeen
  1005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1006. utils.ErrorLog("解析失败:%v", err)
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1008. return
  1009. }
  1010. if res.Infcode != 0 {
  1011. c.ServeSuccessJSON(map[string]interface{}{
  1012. "failed_code": -10,
  1013. "msg": res.ErrMsg,
  1014. })
  1015. return
  1016. } else {
  1017. order.FaPiaoNumber = zero
  1018. order.FaPiaoCode = last_order.FaPiaoCode
  1019. service.UpdateOrder(order)
  1020. hisFundSettleListResult := &models.HisFundSettleListResult{
  1021. Number: res.Output.SetlListId,
  1022. Status: 1,
  1023. Ctime: time.Now().Unix(),
  1024. Mtime: time.Now().Unix(),
  1025. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1026. IsUpload: 1,
  1027. OrderId: order_id,
  1028. }
  1029. service.CreateUploadRecord(hisFundSettleListResult)
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "msg": "上传成功",
  1032. "result": hisFundSettleListResult,
  1033. })
  1034. return
  1035. }
  1036. }
  1037. func (c *HisApiController) GetSettleListHospital() {
  1038. order_id, _ := c.GetInt64("order_id")
  1039. admin_user_id, _ := c.GetInt64("admin_user_id")
  1040. order, _ := service.GetHisOrderByIDTwo(order_id)
  1041. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1042. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1043. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1045. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1047. if order.ID == 0 {
  1048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1049. return
  1050. }
  1051. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1052. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1053. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1054. fmt.Println(count)
  1055. var zero string
  1056. number := count + 1
  1057. if number >= 1000 {
  1058. zero = "0000" + strconv.FormatInt(number, 10)
  1059. } else if number >= 10000 {
  1060. zero = "000" + strconv.FormatInt(number, 10)
  1061. } else if number >= 100000 {
  1062. zero = "00" + strconv.FormatInt(number, 10)
  1063. } else if number >= 1000000 {
  1064. zero = "0" + strconv.FormatInt(number, 10)
  1065. } else {
  1066. zero = strconv.FormatInt(number, 10)
  1067. }
  1068. fmt.Println(zero)
  1069. struct4101 := service.Struct4101{
  1070. PsnNo: order.PsnNo,
  1071. MdtrtId: order.MdtrtId,
  1072. SetlId: order.SetlId,
  1073. PsnName: order.PsnName,
  1074. Gend: order.Gend,
  1075. Brdy: his.Brdy,
  1076. Age: int64(order.Age),
  1077. Naty: order.Naty,
  1078. PatnCertType: "01",
  1079. Certno: order.Certno,
  1080. Prfs: "90",
  1081. ConerName: roles[0].UserName,
  1082. PatnRlts: "99",
  1083. ConerAddr: miConfig.OrgName,
  1084. ConerTel: admin.Mobile,
  1085. HiType: order.Insutype,
  1086. Insuplc: miConfig.InsuplcAdmdvs,
  1087. MaindiagFlag: "1",
  1088. BillCode: last_order.FaPiaoCode,
  1089. BillNo: zero,
  1090. BizSn: order.Number,
  1091. PsnSelfPay: order.PsnPartAmt,
  1092. PsnOwnPay: order.PsnPartAmt,
  1093. AcctPay: order.AcctPay,
  1094. PsnCashpay: order.PsnCashPay,
  1095. HiPaymtd: "1",
  1096. Hsorg: miConfig.InsuplcAdmdvs,
  1097. HsorgOpter: miConfig.InsuplcAdmdvs,
  1098. MedinsFillPsn: curRoles.UserName,
  1099. MedinsFillDept: depart.Name,
  1100. IptMedType: "2",
  1101. }
  1102. struct4101.SetlBegnDate = order.SetlTime
  1103. struct4101.SetlEndDate = order.SetlTime
  1104. var rf []CustomFundPay
  1105. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1106. var tempFunPays []service.CustomStruct
  1107. for _, item := range rf {
  1108. var tempFunPay service.CustomStruct
  1109. tempFunPay.FundPayamt = item.FundPayamt
  1110. tempFunPay.FundPayType = item.FundPayType
  1111. tempFunPays = append(tempFunPays, tempFunPay)
  1112. }
  1113. struct4101.CustomStruct = tempFunPays
  1114. var tempDiaginfos []service.DiaginfoStructTwo
  1115. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1116. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1117. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1118. var config []*models.HisXtDiagnoseConfig
  1119. for _, item := range diagnosis_ids {
  1120. id, _ := strconv.ParseInt(item, 10, 64)
  1121. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1122. config = append(config, &diagnosisConfig)
  1123. }
  1124. for index, item := range config {
  1125. if index == 0 {
  1126. var tempDiaginfo service.DiaginfoStructTwo
  1127. tempDiaginfo.DiagCode = item.CountryCode
  1128. tempDiaginfo.DiagName = item.CountryContentName
  1129. tempDiaginfo.DiagType = "1"
  1130. tempDiaginfo.MaindiagFlag = "1"
  1131. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1132. } else {
  1133. var tempDiaginfo service.DiaginfoStructTwo
  1134. tempDiaginfo.DiagCode = item.CountryCode
  1135. tempDiaginfo.DiagName = item.CountryContentName
  1136. tempDiaginfo.DiagType = "2"
  1137. tempDiaginfo.MaindiagFlag = "0"
  1138. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1139. }
  1140. }
  1141. struct4101.Diseinfo = tempDiaginfos
  1142. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1143. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1144. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1145. tempOpspdiseinfo2.OprnOprtCode = ""
  1146. tempOpspdiseinfo2.OprnOprtName = ""
  1147. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1148. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1149. var iteminfo service.IteminfoStruct
  1150. var bedCostTotal float64 = 0 //床位总费
  1151. var bedCostSelfTotal float64 = 0 //床位自费
  1152. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1153. var operationCostTotal float64 = 0 //手术费
  1154. var operationCostSelfTotal float64 = 0 //手术费
  1155. var operationCostPartSelfTotal float64 = 0 //手术费
  1156. var otherCostTotal float64 = 0 //其他费用
  1157. var otherCostSelfTotal float64 = 0 //其他费用
  1158. var otherCostPartSelfTotal float64 = 0 //其他费用
  1159. var materialCostTotal float64 = 0 //材料费
  1160. var materialCostSelfTotal float64 = 0 //材料费
  1161. var materialCostPartSelfTotal float64 = 0 //材料费
  1162. var westernMedicineCostTotal float64 = 0 //西药费
  1163. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1164. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1165. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1166. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1167. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1168. var checkCostTotal float64 = 0 //检查费
  1169. var checkCostSelfTotal float64 = 0 //检查费
  1170. var checkCostPartSelfTotal float64 = 0 //检查费
  1171. var laboratoryCostTotal float64 = 0 //化验费
  1172. var laboratoryCostSelfTotal float64 = 0 //化验费
  1173. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1174. var treatCostTotal float64 = 0 //治疗费用
  1175. var treatCostSelfTotal float64 = 0 //治疗费用
  1176. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1177. decimal.DivisionPrecision = 2
  1178. var bed_fulamt_ownpay_amt float64 = 0
  1179. var operation_fulamt_ownpay_amt float64 = 0
  1180. var other_fulamt_ownpay_amt float64 = 0
  1181. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1182. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1183. var check_fulamt_ownpay_amt float64 = 0
  1184. var material_fulamt_ownpay_amt float64 = 0
  1185. var laboratory_fulamt_ownpay_amt float64 = 0
  1186. var treat_fulamt_ownpay_amt float64 = 0
  1187. var bed_claa_sunmfee float64 = 0
  1188. var bed_clab_amt float64 = 0
  1189. var bed_other_amt float64 = 0
  1190. var operation_claa_sunmfee float64 = 0
  1191. var operation_clab_amt float64 = 0
  1192. var operation_other_amt float64 = 0
  1193. var other_claa_sunmfee float64 = 0
  1194. var other_clab_amt float64 = 0
  1195. var other_other_amt float64 = 0
  1196. var westernMedicine_claa_sunmfee float64 = 0
  1197. var westernMedicine_clab_amt float64 = 0
  1198. var westernMedicine_other_amt float64 = 0
  1199. var chineseTraditional_claa_sunmfee float64 = 0
  1200. var chineseTraditional_clab_amt float64 = 0
  1201. var chineseTraditional_other_amt float64 = 0
  1202. var check_claa_sunmfee float64 = 0
  1203. var check_clab_amt float64 = 0
  1204. var check_other_amt float64 = 0
  1205. var material_claa_sunmfee float64 = 0
  1206. var material_clab_amt float64 = 0
  1207. var material_other_amt float64 = 0
  1208. var laboratory_claa_sunmfee float64 = 0
  1209. var laboratory_clab_amt float64 = 0
  1210. var laboratory_other_amt float64 = 0
  1211. var treat_claa_sunmfee float64 = 0
  1212. var treat_clab_amt float64 = 0
  1213. var treat_other_amt float64 = 0
  1214. for _, item := range order.HisOrderInfo {
  1215. if item.MedChrgitmType == "01" { //床位费
  1216. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1217. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1218. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1219. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1220. if item.ChrgitmLv == "1" {
  1221. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1222. }
  1223. if item.ChrgitmLv == "2" {
  1224. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "3" {
  1227. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1228. }
  1229. }
  1230. if item.MedChrgitmType == "03" { //检查费
  1231. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1232. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1234. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1235. if item.ChrgitmLv == "1" {
  1236. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. }
  1238. if item.ChrgitmLv == "2" {
  1239. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "3" {
  1242. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1243. }
  1244. }
  1245. if item.MedChrgitmType == "04" { //化验费
  1246. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1247. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1249. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1250. if item.ChrgitmLv == "1" {
  1251. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. }
  1253. if item.ChrgitmLv == "2" {
  1254. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "3" {
  1257. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1258. }
  1259. }
  1260. if item.MedChrgitmType == "05" { //治疗费
  1261. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1262. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1264. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1265. if item.ChrgitmLv == "1" {
  1266. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. }
  1268. if item.ChrgitmLv == "2" {
  1269. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "3" {
  1272. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1273. }
  1274. }
  1275. if item.MedChrgitmType == "06" { //手术费
  1276. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1277. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1279. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1280. if item.ChrgitmLv == "1" {
  1281. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. }
  1283. if item.ChrgitmLv == "2" {
  1284. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "3" {
  1287. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1288. }
  1289. }
  1290. if item.MedChrgitmType == "08" { //材料费
  1291. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1292. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1294. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1295. if item.ChrgitmLv == "1" {
  1296. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. }
  1298. if item.ChrgitmLv == "2" {
  1299. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "3" {
  1302. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1303. }
  1304. }
  1305. if item.MedChrgitmType == "09" { //西药费
  1306. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1307. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1309. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1310. if item.ChrgitmLv == "1" {
  1311. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. }
  1313. if item.ChrgitmLv == "2" {
  1314. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "3" {
  1317. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1318. }
  1319. }
  1320. if item.MedChrgitmType == "11" { //中成费
  1321. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1322. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1323. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1324. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1325. if item.ChrgitmLv == "1" {
  1326. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1327. }
  1328. if item.ChrgitmLv == "2" {
  1329. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1330. }
  1331. if item.ChrgitmLv == "3" {
  1332. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1333. }
  1334. }
  1335. if item.MedChrgitmType == "14" { //其他费
  1336. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1337. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1338. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1339. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1340. if item.ChrgitmLv == "1" {
  1341. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1342. }
  1343. if item.ChrgitmLv == "2" {
  1344. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1345. }
  1346. if item.ChrgitmLv == "3" {
  1347. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1348. }
  1349. }
  1350. }
  1351. var iteminfoStructs []service.IteminfoStruct
  1352. if bedCostTotal != 0 {
  1353. iteminfo.MedChrgitm = "01"
  1354. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1355. iteminfo.Amt = bedCostTotal
  1356. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1357. iteminfo.ClabAmt = bed_clab_amt
  1358. iteminfo.OthAmt = bed_other_amt
  1359. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1360. }
  1361. if checkCostTotal != 0 {
  1362. iteminfo.MedChrgitm = "03"
  1363. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1364. iteminfo.Amt = checkCostTotal
  1365. iteminfo.ClaaSumfee = check_claa_sunmfee
  1366. iteminfo.ClabAmt = check_clab_amt
  1367. iteminfo.OthAmt = check_other_amt
  1368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1369. }
  1370. if laboratoryCostTotal != 0 {
  1371. iteminfo.MedChrgitm = "04"
  1372. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1373. iteminfo.Amt = laboratoryCostTotal
  1374. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1375. iteminfo.ClabAmt = laboratory_clab_amt
  1376. iteminfo.OthAmt = laboratory_other_amt
  1377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. }
  1380. if treatCostTotal != 0 {
  1381. iteminfo.MedChrgitm = "05"
  1382. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1383. iteminfo.Amt = treatCostTotal
  1384. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1385. iteminfo.ClabAmt = treat_clab_amt
  1386. iteminfo.OthAmt = treat_other_amt
  1387. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1388. //(struct4101.IteminfoStruct, iteminfo)
  1389. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1390. }
  1391. if operationCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "06"
  1393. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1394. iteminfo.Amt = operationCostTotal
  1395. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1396. iteminfo.ClabAmt = operation_clab_amt
  1397. iteminfo.OthAmt = operation_other_amt
  1398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1400. }
  1401. if materialCostTotal != 0 {
  1402. iteminfo.MedChrgitm = "08"
  1403. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1404. iteminfo.Amt = materialCostTotal
  1405. iteminfo.ClaaSumfee = material_claa_sunmfee
  1406. iteminfo.ClabAmt = material_clab_amt
  1407. iteminfo.OthAmt = material_other_amt
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1410. }
  1411. if westernMedicineCostTotal != 0 {
  1412. iteminfo.MedChrgitm = "09"
  1413. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1414. iteminfo.Amt = westernMedicineCostTotal
  1415. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1416. iteminfo.ClabAmt = westernMedicine_clab_amt
  1417. iteminfo.OthAmt = westernMedicine_other_amt
  1418. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1419. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1420. }
  1421. if chineseTraditionalMedicineCostTotal != 0 {
  1422. iteminfo.MedChrgitm = "11"
  1423. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1424. iteminfo.Amt = westernMedicineCostTotal
  1425. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1426. iteminfo.ClabAmt = westernMedicine_clab_amt
  1427. iteminfo.OthAmt = westernMedicine_other_amt
  1428. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1430. }
  1431. if otherCostTotal != 0 {
  1432. iteminfo.MedChrgitm = "14"
  1433. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1434. iteminfo.Amt = otherCostTotal
  1435. iteminfo.ClaaSumfee = other_claa_sunmfee
  1436. iteminfo.ClabAmt = other_clab_amt
  1437. iteminfo.OthAmt = other_other_amt
  1438. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1439. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1440. }
  1441. struct4101.IteminfoStruct = iteminfoStructs
  1442. struct4101.Ntly = "中国"
  1443. struct4101.AdmCaty = "A03.06"
  1444. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1445. fmt.Println(result)
  1446. var dat map[string]interface{}
  1447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1448. fmt.Println(dat)
  1449. } else {
  1450. fmt.Println(err)
  1451. }
  1452. userJSONBytes, _ := json.Marshal(dat)
  1453. var res ResultSeventeen
  1454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1455. utils.ErrorLog("解析失败:%v", err)
  1456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. return
  1458. }
  1459. if res.Infcode != 0 {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "failed_code": -10,
  1462. "msg": res.ErrMsg,
  1463. })
  1464. return
  1465. } else {
  1466. order.FaPiaoNumber = zero
  1467. order.FaPiaoCode = last_order.FaPiaoCode
  1468. service.UpdateOrder(order)
  1469. hisFundSettleListResult := &models.HisFundSettleListResult{
  1470. Number: res.Output.SetlListId,
  1471. Status: 1,
  1472. Ctime: time.Now().Unix(),
  1473. Mtime: time.Now().Unix(),
  1474. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1475. IsUpload: 1,
  1476. OrderId: order_id,
  1477. }
  1478. service.CreateUploadRecord(hisFundSettleListResult)
  1479. c.ServeSuccessJSON(map[string]interface{}{
  1480. "msg": "上传成功",
  1481. "result": hisFundSettleListResult,
  1482. })
  1483. return
  1484. }
  1485. }
  1486. func (c *HisApiController) GetBatchSettleList() {
  1487. orders, _ := service.GetAllHisOrder(10106)
  1488. for _, item := range orders {
  1489. order_id := item.ID
  1490. order, _ := service.GetHisOrderByIDTwo(order_id)
  1491. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1492. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1493. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1494. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1495. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1497. if order.ID == 0 {
  1498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1499. return
  1500. }
  1501. if his.BalanceAccountsType == 2 {
  1502. continue
  1503. }
  1504. struct4101 := service.Struct4101{
  1505. PsnNo: order.PsnNo,
  1506. MdtrtId: order.MdtrtId,
  1507. SetlId: order.SetlId,
  1508. PsnName: order.PsnName,
  1509. Gend: order.Gend,
  1510. Brdy: his.Brdy,
  1511. Age: his.Age,
  1512. Naty: order.Naty,
  1513. PatnCertType: "01",
  1514. Certno: order.Certno,
  1515. Prfs: "90",
  1516. ConerName: roles[0].UserName,
  1517. PatnRlts: "99",
  1518. ConerAddr: miConfig.OrgName,
  1519. ConerTel: admin.Mobile,
  1520. HiType: order.Insutype,
  1521. Insuplc: his.InsuplcAdmdvs,
  1522. MaindiagFlag: "1",
  1523. BillCode: order.FaPiaoCode,
  1524. BillNo: order.FaPiaoNumber,
  1525. BizSn: order.Number,
  1526. PsnSelfPay: order.PsnPartAmt,
  1527. PsnOwnPay: order.PsnPartAmt,
  1528. AcctPay: order.AcctPay,
  1529. PsnCashpay: order.PsnCashPay,
  1530. HiPaymtd: "1",
  1531. Hsorg: his.InsuplcAdmdvs,
  1532. HsorgOpter: his.InsuplcAdmdvs,
  1533. MedinsFillPsn: curRoles.UserName,
  1534. MedinsFillDept: depart.Name,
  1535. IptMedType: "2",
  1536. }
  1537. struct4101.SetlBegnDate = order.SetlTime
  1538. struct4101.SetlEndDate = order.SetlTime
  1539. //if order.SettleType == 1 {
  1540. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1541. // dateStr := t.Format("2006-01-02")
  1542. // struct4101.SetlBegnDate = dateStr
  1543. // struct4101.SetlEndDate = dateStr
  1544. //} else {
  1545. // t := time.Unix(int64(order.SettleStartTime), 0)
  1546. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1547. // dateStartStr := t.Format("2006-01-02")
  1548. // dateEndStr := t2.Format("2006-01-02")
  1549. // struct4101.SetlBegnDate = dateStartStr
  1550. // struct4101.SetlEndDate = dateEndStr
  1551. //}
  1552. var rf []CustomFundPay
  1553. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1554. var tempFunPays []service.CustomStruct
  1555. var tempFunPay610100 service.CustomStruct
  1556. for _, item := range rf {
  1557. if item.FundPayType == "610100" {
  1558. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1559. tempFunPay610100.FundPayType = item.FundPayType
  1560. } else {
  1561. var tempFunPay service.CustomStruct
  1562. tempFunPay.FundPayamt = item.FundPayamt
  1563. tempFunPay.FundPayType = item.FundPayType
  1564. tempFunPays = append(tempFunPays, tempFunPay)
  1565. }
  1566. }
  1567. tempFunPays = append(tempFunPays, tempFunPay610100)
  1568. struct4101.CustomStruct = tempFunPays
  1569. var tempDiaginfos []service.DiaginfoStructTwo
  1570. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1571. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1572. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1573. var config []*models.HisXtDiagnoseConfig
  1574. for _, item := range diagnosis_ids {
  1575. id, _ := strconv.ParseInt(item, 10, 64)
  1576. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1577. config = append(config, &diagnosisConfig)
  1578. }
  1579. for index, item := range config {
  1580. if index == 0 {
  1581. var tempDiaginfo service.DiaginfoStructTwo
  1582. tempDiaginfo.DiagCode = item.CountryCode
  1583. tempDiaginfo.DiagName = item.CountryContentName
  1584. tempDiaginfo.DiagType = "1"
  1585. tempDiaginfo.MaindiagFlag = "1"
  1586. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1587. } else {
  1588. var tempDiaginfo service.DiaginfoStructTwo
  1589. tempDiaginfo.DiagCode = item.CountryCode
  1590. tempDiaginfo.DiagName = item.CountryContentName
  1591. tempDiaginfo.DiagType = "2"
  1592. tempDiaginfo.MaindiagFlag = "0"
  1593. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1594. }
  1595. }
  1596. struct4101.Diseinfo = tempDiaginfos
  1597. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1598. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1599. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1600. tempOpspdiseinfo2.OprnOprtCode = ""
  1601. tempOpspdiseinfo2.OprnOprtName = ""
  1602. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1603. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1604. var iteminfo service.IteminfoStruct
  1605. var bedCostTotal float64 = 0 //床位总费
  1606. var bedCostSelfTotal float64 = 0 //床位自费
  1607. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1608. var examineCostTotal float64 = 0 //诊查总费
  1609. var examineCostSelfTotal float64 = 0 //诊查自费
  1610. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1611. var nursingCostTotal float64 = 0 //护理总费
  1612. var nursingCostSelfTotal float64 = 0 //护理自费
  1613. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1614. var chineseMedicineCostTotal float64 = 0 //中成药
  1615. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1616. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1617. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1618. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1619. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1620. var registerCostTotal float64 = 0 //一般诊疗费
  1621. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1622. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1623. var operationCostTotal float64 = 0 //手术费
  1624. var operationCostSelfTotal float64 = 0 //手术费
  1625. var operationCostPartSelfTotal float64 = 0 //手术费
  1626. var otherCostTotal float64 = 0 //其他费用
  1627. var otherCostSelfTotal float64 = 0 //其他费用
  1628. var otherCostPartSelfTotal float64 = 0 //其他费用
  1629. var materialCostTotal float64 = 0 //材料费
  1630. var materialCostSelfTotal float64 = 0 //材料费
  1631. var materialCostPartSelfTotal float64 = 0 //材料费
  1632. var westernMedicineCostTotal float64 = 0 //西药费
  1633. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1634. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1635. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1636. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1637. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1638. var checkCostTotal float64 = 0 //检查费
  1639. var checkCostSelfTotal float64 = 0 //检查费
  1640. var checkCostPartSelfTotal float64 = 0 //检查费
  1641. var laboratoryCostTotal float64 = 0 //化验费
  1642. var laboratoryCostSelfTotal float64 = 0 //化验费
  1643. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1644. var treatCostTotal float64 = 0 //治疗费用
  1645. var treatCostSelfTotal float64 = 0 //治疗费用
  1646. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1647. decimal.DivisionPrecision = 2
  1648. var bed_fulamt_ownpay_amt float64 = 0
  1649. var examine_fulamt_ownpay_amt float64 = 0
  1650. var nursing_fulamt_ownpay_amt float64 = 0
  1651. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1652. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1653. var register_fulamt_ownpay_amt float64 = 0
  1654. var operation_fulamt_ownpay_amt float64 = 0
  1655. var other_fulamt_ownpay_amt float64 = 0
  1656. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1657. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1658. var check_fulamt_ownpay_amt float64 = 0
  1659. var material_fulamt_ownpay_amt float64 = 0
  1660. var laboratory_fulamt_ownpay_amt float64 = 0
  1661. var treat_fulamt_ownpay_amt float64 = 0
  1662. var bed_claa_sunmfee float64 = 0
  1663. var bed_clab_amt float64 = 0
  1664. var bed_other_amt float64 = 0
  1665. var examine_claa_sunmfee float64 = 0
  1666. var examine_clab_amt float64 = 0
  1667. var examine_other_amt float64 = 0
  1668. var nursing_claa_sunmfee float64 = 0
  1669. var nursing_clab_amt float64 = 0
  1670. var nursing_other_amt float64 = 0
  1671. var chinese_medicine_claa_sunmfee float64 = 0
  1672. var chinese_medicine_clab_amt float64 = 0
  1673. var chinese_medicine_other_amt float64 = 0
  1674. var commonly_treatment_claa_sunmfee float64 = 0
  1675. var commonly_treatment_clab_amt float64 = 0
  1676. var commonly_treatment_other_amt float64 = 0
  1677. var operation_claa_sunmfee float64 = 0
  1678. var operation_clab_amt float64 = 0
  1679. var operation_other_amt float64 = 0
  1680. var other_claa_sunmfee float64 = 0
  1681. var other_clab_amt float64 = 0
  1682. var other_other_amt float64 = 0
  1683. var westernMedicine_claa_sunmfee float64 = 0
  1684. var westernMedicine_clab_amt float64 = 0
  1685. var westernMedicine_other_amt float64 = 0
  1686. var chineseTraditional_claa_sunmfee float64 = 0
  1687. var chineseTraditional_clab_amt float64 = 0
  1688. var chineseTraditional_other_amt float64 = 0
  1689. var check_claa_sunmfee float64 = 0
  1690. var check_clab_amt float64 = 0
  1691. var check_other_amt float64 = 0
  1692. var material_claa_sunmfee float64 = 0
  1693. var material_clab_amt float64 = 0
  1694. var material_other_amt float64 = 0
  1695. var laboratory_claa_sunmfee float64 = 0
  1696. var laboratory_clab_amt float64 = 0
  1697. var laboratory_other_amt float64 = 0
  1698. var treat_claa_sunmfee float64 = 0
  1699. var treat_clab_amt float64 = 0
  1700. var treat_other_amt float64 = 0
  1701. var register_claa_sunmfee float64 = 0
  1702. var register_clab_amt float64 = 0
  1703. var register_other_amt float64 = 0
  1704. for _, item := range order.HisOrderInfo {
  1705. if item.MedChrgitmType == "01" { //床位费
  1706. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1707. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1708. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1709. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1710. if item.ChrgitmLv == "1" {
  1711. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1712. }
  1713. if item.ChrgitmLv == "2" {
  1714. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1715. }
  1716. if item.ChrgitmLv == "3" {
  1717. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1718. }
  1719. }
  1720. if item.MedChrgitmType == "02" { //诊查
  1721. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1722. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1723. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1724. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1725. if item.ChrgitmLv == "1" {
  1726. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1727. }
  1728. if item.ChrgitmLv == "2" {
  1729. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1730. }
  1731. if item.ChrgitmLv == "3" {
  1732. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1733. }
  1734. }
  1735. if item.MedChrgitmType == "03" { //检查费
  1736. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1737. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1738. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1739. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1740. if item.ChrgitmLv == "1" {
  1741. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1742. }
  1743. if item.ChrgitmLv == "2" {
  1744. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1745. }
  1746. if item.ChrgitmLv == "3" {
  1747. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1748. }
  1749. }
  1750. if item.MedChrgitmType == "04" { //化验费
  1751. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1752. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1753. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1754. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1755. if item.ChrgitmLv == "1" {
  1756. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1757. }
  1758. if item.ChrgitmLv == "2" {
  1759. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1760. }
  1761. if item.ChrgitmLv == "3" {
  1762. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1763. }
  1764. }
  1765. if item.MedChrgitmType == "05" { //治疗费
  1766. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1767. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1768. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1769. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1770. if item.ChrgitmLv == "1" {
  1771. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1772. }
  1773. if item.ChrgitmLv == "2" {
  1774. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1775. }
  1776. if item.ChrgitmLv == "3" {
  1777. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1778. }
  1779. }
  1780. if item.MedChrgitmType == "06" { //手术费
  1781. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1782. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1783. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1784. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1785. if item.ChrgitmLv == "1" {
  1786. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1787. }
  1788. if item.ChrgitmLv == "2" {
  1789. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1790. }
  1791. if item.ChrgitmLv == "3" {
  1792. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1793. }
  1794. }
  1795. if item.MedChrgitmType == "07" { //手术费
  1796. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1797. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1798. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1799. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1800. if item.ChrgitmLv == "1" {
  1801. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1802. }
  1803. if item.ChrgitmLv == "2" {
  1804. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1805. }
  1806. if item.ChrgitmLv == "3" {
  1807. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1808. }
  1809. }
  1810. if item.MedChrgitmType == "08" { //材料费
  1811. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1812. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1813. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1814. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1815. if item.ChrgitmLv == "1" {
  1816. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1817. }
  1818. if item.ChrgitmLv == "2" {
  1819. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1820. }
  1821. if item.ChrgitmLv == "3" {
  1822. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1823. }
  1824. }
  1825. if item.MedChrgitmType == "09" { //西药费
  1826. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1827. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1828. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1829. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1830. if item.ChrgitmLv == "1" {
  1831. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1832. }
  1833. if item.ChrgitmLv == "2" {
  1834. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1835. }
  1836. if item.ChrgitmLv == "3" {
  1837. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1838. }
  1839. }
  1840. if item.MedChrgitmType == "10" { //中药饮片
  1841. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1842. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1843. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1844. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1845. if item.ChrgitmLv == "1" {
  1846. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1847. }
  1848. if item.ChrgitmLv == "2" {
  1849. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1850. }
  1851. if item.ChrgitmLv == "3" {
  1852. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1853. }
  1854. }
  1855. if item.MedChrgitmType == "11" { //中成费
  1856. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1857. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1858. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1859. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1860. if item.ChrgitmLv == "1" {
  1861. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1862. }
  1863. if item.ChrgitmLv == "2" {
  1864. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1865. }
  1866. if item.ChrgitmLv == "3" {
  1867. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1868. }
  1869. }
  1870. if item.MedChrgitmType == "12" { //中成费
  1871. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1872. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1873. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1874. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1875. if item.ChrgitmLv == "1" {
  1876. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1877. }
  1878. if item.ChrgitmLv == "2" {
  1879. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1880. }
  1881. if item.ChrgitmLv == "3" {
  1882. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1883. }
  1884. }
  1885. if item.MedChrgitmType == "13" { //中成费
  1886. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1887. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1888. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1889. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1890. if item.ChrgitmLv == "1" {
  1891. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1892. }
  1893. if item.ChrgitmLv == "2" {
  1894. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1895. }
  1896. if item.ChrgitmLv == "3" {
  1897. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1898. }
  1899. }
  1900. if item.MedChrgitmType == "14" { //其他费
  1901. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1902. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1903. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1904. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1905. if item.ChrgitmLv == "1" {
  1906. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1907. }
  1908. if item.ChrgitmLv == "2" {
  1909. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1910. }
  1911. if item.ChrgitmLv == "3" {
  1912. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1913. }
  1914. }
  1915. }
  1916. var iteminfoStructs []service.IteminfoStruct
  1917. if bedCostTotal != 0 {
  1918. iteminfo.MedChrgitm = "01"
  1919. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1920. iteminfo.Amt = bedCostTotal
  1921. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1922. iteminfo.ClabAmt = bed_clab_amt
  1923. iteminfo.OthAmt = bed_other_amt
  1924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1925. }
  1926. if examineCostTotal != 0 {
  1927. iteminfo.MedChrgitm = "02"
  1928. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1929. iteminfo.Amt = examineCostTotal
  1930. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1931. iteminfo.ClabAmt = examine_clab_amt
  1932. iteminfo.OthAmt = examine_other_amt
  1933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1935. }
  1936. if checkCostTotal != 0 {
  1937. iteminfo.MedChrgitm = "03"
  1938. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1939. iteminfo.Amt = checkCostTotal
  1940. iteminfo.ClaaSumfee = check_claa_sunmfee
  1941. iteminfo.ClabAmt = check_clab_amt
  1942. iteminfo.OthAmt = check_other_amt
  1943. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1944. }
  1945. if laboratoryCostTotal != 0 {
  1946. iteminfo.MedChrgitm = "04"
  1947. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1948. iteminfo.Amt = laboratoryCostTotal
  1949. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1950. iteminfo.ClabAmt = laboratory_clab_amt
  1951. iteminfo.OthAmt = laboratory_other_amt
  1952. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1953. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1954. }
  1955. if treatCostTotal != 0 {
  1956. iteminfo.MedChrgitm = "05"
  1957. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1958. iteminfo.Amt = treatCostTotal
  1959. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1960. iteminfo.ClabAmt = treat_clab_amt
  1961. iteminfo.OthAmt = treat_other_amt
  1962. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1963. //(struct4101.IteminfoStruct, iteminfo)
  1964. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1965. }
  1966. if operationCostTotal != 0 {
  1967. iteminfo.MedChrgitm = "06"
  1968. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1969. iteminfo.Amt = operationCostTotal
  1970. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1971. iteminfo.ClabAmt = operation_clab_amt
  1972. iteminfo.OthAmt = operation_other_amt
  1973. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1975. }
  1976. if nursingCostTotal != 0 {
  1977. iteminfo.MedChrgitm = "07"
  1978. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1979. iteminfo.Amt = nursingCostTotal
  1980. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1981. iteminfo.ClabAmt = nursing_clab_amt
  1982. iteminfo.OthAmt = nursing_other_amt
  1983. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1984. }
  1985. if materialCostTotal != 0 {
  1986. iteminfo.MedChrgitm = "08"
  1987. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1988. iteminfo.Amt = materialCostTotal
  1989. iteminfo.ClaaSumfee = material_claa_sunmfee
  1990. iteminfo.ClabAmt = material_clab_amt
  1991. iteminfo.OthAmt = material_other_amt
  1992. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1993. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1994. }
  1995. if westernMedicineCostTotal != 0 {
  1996. iteminfo.MedChrgitm = "09"
  1997. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1998. iteminfo.Amt = westernMedicineCostTotal
  1999. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2000. iteminfo.ClabAmt = westernMedicine_clab_amt
  2001. iteminfo.OthAmt = westernMedicine_other_amt
  2002. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2003. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2004. }
  2005. if chineseMedicineCostTotal != 0 {
  2006. iteminfo.MedChrgitm = "10"
  2007. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2008. iteminfo.Amt = chineseMedicineCostTotal
  2009. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2010. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2011. iteminfo.OthAmt = chinese_medicine_other_amt
  2012. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2013. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2014. }
  2015. if chineseTraditionalMedicineCostTotal != 0 {
  2016. iteminfo.MedChrgitm = "11"
  2017. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2018. iteminfo.Amt = westernMedicineCostTotal
  2019. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2020. iteminfo.ClabAmt = westernMedicine_clab_amt
  2021. iteminfo.OthAmt = westernMedicine_other_amt
  2022. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2023. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2024. }
  2025. if commonlyTreatmentCostTotal != 0 {
  2026. iteminfo.MedChrgitm = "12"
  2027. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2028. iteminfo.Amt = commonlyTreatmentCostTotal
  2029. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2030. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2031. iteminfo.OthAmt = commonly_treatment_other_amt
  2032. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2033. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2034. }
  2035. if registerCostTotal != 0 {
  2036. iteminfo.MedChrgitm = "13"
  2037. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2038. iteminfo.Amt = registerCostTotal
  2039. iteminfo.ClaaSumfee = register_claa_sunmfee
  2040. iteminfo.ClabAmt = register_clab_amt
  2041. iteminfo.OthAmt = register_other_amt
  2042. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2043. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2044. }
  2045. if otherCostTotal != 0 {
  2046. iteminfo.MedChrgitm = "14"
  2047. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2048. iteminfo.Amt = otherCostTotal
  2049. iteminfo.ClaaSumfee = other_claa_sunmfee
  2050. iteminfo.ClabAmt = other_clab_amt
  2051. iteminfo.OthAmt = other_other_amt
  2052. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2053. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2054. }
  2055. struct4101.IteminfoStruct = iteminfoStructs
  2056. struct4101.Ntly = "中国"
  2057. struct4101.AdmCaty = "A03.06"
  2058. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2059. fmt.Println(result)
  2060. var dat map[string]interface{}
  2061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2062. fmt.Println(dat)
  2063. } else {
  2064. fmt.Println(err)
  2065. }
  2066. userJSONBytes, _ := json.Marshal(dat)
  2067. var res ResultSeventeen
  2068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2069. utils.ErrorLog("解析失败:%v", err)
  2070. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  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: 2000,
  2080. }
  2081. service.CreateErrMsgLog(errlog)
  2082. continue
  2083. }
  2084. if res.Infcode != 0 {
  2085. adminUser := c.GetAdminUserInfo()
  2086. errlog := &models.HisOrderError{
  2087. UserOrgId: adminUser.CurrentOrgId,
  2088. Ctime: time.Now().Unix(),
  2089. Mtime: time.Now().Unix(),
  2090. ErrMsg: res.ErrMsg,
  2091. Status: 1,
  2092. PatientId: order_id,
  2093. Stage: 2000,
  2094. }
  2095. service.CreateErrMsgLog(errlog)
  2096. continue
  2097. } else {
  2098. hisFundSettleListResult := &models.HisFundSettleListResult{
  2099. Number: res.Output.SetlListId,
  2100. Status: 1,
  2101. Ctime: time.Now().Unix(),
  2102. Mtime: time.Now().Unix(),
  2103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2104. IsUpload: 1,
  2105. OrderId: order_id,
  2106. }
  2107. service.CreateUploadRecord(hisFundSettleListResult)
  2108. continue
  2109. }
  2110. }
  2111. }
  2112. func (c *HisApiController) GetOrgInfo() {
  2113. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2114. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2115. }
  2116. func (c *HisApiController) GetHisPatientInfo() {
  2117. medical_insurance_card := c.GetString("medical_insurance_card")
  2118. id_card_type, _ := c.GetInt64("id_card_type")
  2119. id_card := c.GetString("id_card")
  2120. adminInfo := c.GetAdminUserInfo()
  2121. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2122. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2123. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2124. IdCardNo := ""
  2125. if id_card_type == 1 {
  2126. IdCardNo = medical_insurance_card
  2127. } else if id_card_type == 2 {
  2128. IdCardNo = id_card
  2129. }
  2130. if config.IsOpen == 1 {
  2131. 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
  2132. resp, requestErr := http.Get(api)
  2133. if requestErr != nil {
  2134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2135. return
  2136. }
  2137. defer resp.Body.Close()
  2138. body, ioErr := ioutil.ReadAll(resp.Body)
  2139. if ioErr != nil {
  2140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2142. return
  2143. }
  2144. var respJSON map[string]interface{}
  2145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2148. return
  2149. }
  2150. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2151. userJSONBytes, _ := json.Marshal(userJSON)
  2152. var res ResultTwo
  2153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2154. utils.ErrorLog("解析失败:%v", err)
  2155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2156. return
  2157. }
  2158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2160. infoStr := string(Iinfos)
  2161. idetinfoStr := string(Idetinfos)
  2162. if res.Infcode == 0 {
  2163. his := models.VMHisPatient{
  2164. Status: 1,
  2165. Ctime: time.Now().Unix(),
  2166. Mtime: time.Now().Unix(),
  2167. PsnNo: res.Output.Baseinfo.PsnNo,
  2168. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2169. Certno: res.Output.Baseinfo.Certno,
  2170. PsnName: res.Output.Baseinfo.PsnName,
  2171. Gend: res.Output.Baseinfo.Gend,
  2172. Naty: res.Output.Baseinfo.Naty,
  2173. Brdy: res.Output.Baseinfo.Brdy,
  2174. Age: res.Output.Baseinfo.Age,
  2175. Iinfo: infoStr,
  2176. Idetinfo: idetinfoStr,
  2177. UserOrgId: adminInfo.CurrentOrgId,
  2178. IsReturn: 1,
  2179. IdCardType: id_card_type,
  2180. }
  2181. c.ServeSuccessJSON(map[string]interface{}{
  2182. "info": his,
  2183. })
  2184. } else {
  2185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2186. return
  2187. }
  2188. }
  2189. }
  2190. //func GetBasBaseInfo() (jsonStr string, err error) {
  2191. //
  2192. // handle := syscall.NewLazyDLL("SSCard.dll")
  2193. // add := handle.NewProc("ReadCardBas")
  2194. // str := make([]byte, 1024)
  2195. // str1 := make([]byte, 1024)
  2196. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2197. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2198. //
  2199. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2200. //
  2201. // fmt.Println("> Add(4,5)的结果为:", ret)
  2202. // handle.Release()
  2203. //
  2204. // return "", nil
  2205. //
  2206. //}
  2207. //func GetQRBaseInfo() (jsonStr string, err error) {
  2208. // handle := syscall.LoadDLL("SSCard.dll")
  2209. // ReadCardBas := handle.FindProc("GetQRBase")
  2210. //
  2211. // str := make([]byte, 256)
  2212. // str1 := make([]byte, 256)
  2213. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2214. //
  2215. // fmt.Println(string(str))
  2216. // fmt.Println(r)
  2217. // return string(str), nil
  2218. //}
  2219. //func CardInit() int {
  2220. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2221. // add := DllTestDef.MustFindProc("Init")
  2222. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2223. // if err != nil {
  2224. // fmt.Println("SSCard的运算结果为:", ret)
  2225. // }
  2226. // result := int(ret)
  2227. // return result
  2228. //}
  2229. //func CardInit() int {
  2230. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2231. // if err != nil {
  2232. // fmt.Println("SSCard的运算结果为:", ret)
  2233. // }
  2234. // fmt.Println(err)
  2235. // result := int(ret)
  2236. // return result
  2237. //}
  2238. func IntPtr(n int) uintptr {
  2239. return uintptr(n)
  2240. }
  2241. func StrPtr(s string) uintptr {
  2242. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2243. }
  2244. type Result2001 struct {
  2245. Cainfo interface{} `json:"cainfo"`
  2246. ErrMsg string `json:"err_msg"`
  2247. InfRefmsgid string `json:"inf_refmsgid"`
  2248. Infcode int64 `json:"infcode"`
  2249. Output struct {
  2250. Trtinfo struct {
  2251. PsnNo string `json:"psn_no"`
  2252. TrtChkType string `json:"trt_chk_type"`
  2253. FundPayType string `json:"fund_pay_type"`
  2254. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2255. Begndate string `json:"begndate"`
  2256. Enddate string `json:"enddate"`
  2257. TrtChkRslt string `json:"trt_chk_rslt"`
  2258. } `json:"trtinfo"`
  2259. } `json:"output"`
  2260. RefmsgTime string `json:"refmsg_time"`
  2261. RespondTime string `json:"respond_time"`
  2262. Signtype interface{} `json:"signtype"`
  2263. WarnMsg interface{} `json:"warn_msg"`
  2264. }
  2265. type Result2001Org10265 struct {
  2266. Cainfo interface{} `json:"cainfo"`
  2267. ErrMsg string `json:"err_msg"`
  2268. InfRefmsgid string `json:"inf_refmsgid"`
  2269. Infcode string `json:"infcode"`
  2270. Output struct {
  2271. Trtinfo struct {
  2272. PsnNo string `json:"psn_no"`
  2273. TrtChkType string `json:"trt_chk_type"`
  2274. FundPayType string `json:"fund_pay_type"`
  2275. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2276. Begndate string `json:"begndate"`
  2277. Enddate string `json:"enddate"`
  2278. TrtChkRslt string `json:"trt_chk_rslt"`
  2279. } `json:"trtinfo"`
  2280. } `json:"output"`
  2281. RefmsgTime string `json:"refmsg_time"`
  2282. RespondTime string `json:"respond_time"`
  2283. Signtype interface{} `json:"signtype"`
  2284. WarnMsg interface{} `json:"warn_msg"`
  2285. }
  2286. type ResultTwo struct {
  2287. ErrMsg string `json:"err_msg"`
  2288. InfRefmsgid string `json:"inf_refmsgid"`
  2289. Infcode int64 `json:"infcode"`
  2290. Output struct {
  2291. Baseinfo struct {
  2292. Age float64 `json:"age"`
  2293. Brdy string `json:"brdy"`
  2294. Certno string `json:"certno"`
  2295. Gend string `json:"gend"`
  2296. Naty string `json:"naty"`
  2297. PsnCertType string `json:"psn_cert_type"`
  2298. PsnName string `json:"psn_name"`
  2299. PsnNo string `json:"psn_no"`
  2300. } `json:"baseinfo"`
  2301. Idetinfo []interface{} `json:"idetinfo"`
  2302. Iinfo []struct {
  2303. Balc float64 `json:"balc"`
  2304. CvlservFlag string `json:"cvlserv_flag"`
  2305. EmpName string `json:"emp_name"`
  2306. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2307. Insutype string `json:"insutype"`
  2308. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2309. PausInsuDate string `json:"paus_insu_date"`
  2310. PsnInsuDate string `json:"psn_insu_date"`
  2311. PsnInsuStas string `json:"psn_insu_stas"`
  2312. PsnType string `json:"psn_type"`
  2313. } `json:"insuinfo"`
  2314. } `json:"output"`
  2315. RefmsgTime string `json:"refmsg_time"`
  2316. RespondTime string `json:"respond_time"`
  2317. Signtype interface{} `json:"signtype"`
  2318. WarnInfo interface{} `json:"warn_info"`
  2319. }
  2320. type ResultTwo10265 struct {
  2321. ErrMsg string `json:"err_msg"`
  2322. InfRefmsgid string `json:"inf_refmsgid"`
  2323. Infcode string `json:"infcode"`
  2324. Output struct {
  2325. Baseinfo struct {
  2326. Age float64 `json:"age"`
  2327. Brdy string `json:"brdy"`
  2328. Certno string `json:"certno"`
  2329. Gend string `json:"gend"`
  2330. Naty string `json:"naty"`
  2331. PsnCertType string `json:"psn_cert_type"`
  2332. PsnName string `json:"psn_name"`
  2333. PsnNo string `json:"psn_no"`
  2334. } `json:"baseinfo"`
  2335. Idetinfo []interface{} `json:"idetinfo"`
  2336. Iinfo []struct {
  2337. Balc float64 `json:"balc"`
  2338. CvlservFlag string `json:"cvlserv_flag"`
  2339. EmpName string `json:"emp_name"`
  2340. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2341. Insutype string `json:"insutype"`
  2342. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2343. PausInsuDate string `json:"paus_insu_date"`
  2344. PsnInsuDate string `json:"psn_insu_date"`
  2345. PsnInsuStas string `json:"psn_insu_stas"`
  2346. PsnType string `json:"psn_type"`
  2347. } `json:"insuinfo"`
  2348. } `json:"output"`
  2349. RefmsgTime string `json:"refmsg_time"`
  2350. RespondTime string `json:"respond_time"`
  2351. Signtype interface{} `json:"signtype"`
  2352. WarnInfo interface{} `json:"warn_info"`
  2353. }
  2354. type ResultThree struct {
  2355. Cainfo interface{} `json:"cainfo"`
  2356. ErrMsg string `json:"err_msg"`
  2357. InfRefmsgid string `json:"inf_refmsgid"`
  2358. Infcode int64 `json:"infcode"`
  2359. Output struct {
  2360. Data struct {
  2361. IptOtpNo string `json:"ipt_otp_no"`
  2362. MdtrtID string `json:"mdtrt_id"`
  2363. PsnNo string `json:"psn_no"`
  2364. } `json:"data"`
  2365. } `json:"output"`
  2366. RefmsgTime string `json:"refmsg_time"`
  2367. RespondTime string `json:"respond_time"`
  2368. Signtype interface{} `json:"signtype"`
  2369. WarnMsg interface{} `json:"warn_msg"`
  2370. }
  2371. type ResultThree10265 struct {
  2372. Cainfo interface{} `json:"cainfo"`
  2373. ErrMsg string `json:"err_msg"`
  2374. InfRefmsgid string `json:"inf_refmsgid"`
  2375. Infcode string `json:"infcode"`
  2376. Output struct {
  2377. Data struct {
  2378. IptOtpNo string `json:"ipt_otp_no"`
  2379. MdtrtID string `json:"mdtrt_id"`
  2380. PsnNo string `json:"psn_no"`
  2381. } `json:"data"`
  2382. } `json:"output"`
  2383. RefmsgTime string `json:"refmsg_time"`
  2384. RespondTime string `json:"respond_time"`
  2385. Signtype interface{} `json:"signtype"`
  2386. WarnMsg interface{} `json:"warn_msg"`
  2387. }
  2388. type ResultFour struct {
  2389. Cainfo string `json:"cainfo"`
  2390. ErrMsg string `json:"err_msg"`
  2391. InfRefmsgid string `json:"inf_refmsgid"`
  2392. Infcode int64 `json:"infcode"`
  2393. Output struct {
  2394. Result []struct {
  2395. BasMednFlag string `json:"bas_medn_flag"`
  2396. ChldMedcFlag string `json:"chld_medc_flag"`
  2397. ChrgitmLv string `json:"chrgitm_lv"`
  2398. Cnt float64 `json:"cnt"`
  2399. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2400. DrtReimFlag string `json:"drt_reim_flag"`
  2401. FeedetlSn string `json:"feedetl_sn"`
  2402. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2403. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2404. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2405. ListSpItemFlag string `json:"list_sp_item_flag"`
  2406. LmtUsedFlag string `json:"lmt_used_flag"`
  2407. MedChrgitmType string `json:"med_chrgitm_type"`
  2408. Memo string `json:"memo"`
  2409. OverlmtAmt float64 `json:"overlmt_amt"`
  2410. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2411. Pric float64 `json:"pric"`
  2412. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2413. SelfpayProp float64 `json:"selfpay_prop"`
  2414. } `json:"result"`
  2415. } `json:"output"`
  2416. RefmsgTime string `json:"refmsg_time"`
  2417. RespondTime string `json:"respond_time"`
  2418. Signtype string `json:"signtype"`
  2419. WarnMsg string `json:"warn_msg"`
  2420. }
  2421. type ResultFour10265 struct {
  2422. Cainfo string `json:"cainfo"`
  2423. ErrMsg string `json:"err_msg"`
  2424. InfRefmsgid string `json:"inf_refmsgid"`
  2425. Infcode string `json:"infcode"`
  2426. Output struct {
  2427. Result []struct {
  2428. BasMednFlag string `json:"bas_medn_flag"`
  2429. ChldMedcFlag string `json:"chld_medc_flag"`
  2430. ChrgitmLv string `json:"chrgitm_lv"`
  2431. Cnt float64 `json:"cnt"`
  2432. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2433. DrtReimFlag string `json:"drt_reim_flag"`
  2434. FeedetlSn string `json:"feedetl_sn"`
  2435. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2436. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2437. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2438. ListSpItemFlag string `json:"list_sp_item_flag"`
  2439. LmtUsedFlag string `json:"lmt_used_flag"`
  2440. MedChrgitmType string `json:"med_chrgitm_type"`
  2441. Memo string `json:"memo"`
  2442. OverlmtAmt float64 `json:"overlmt_amt"`
  2443. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2444. Pric float64 `json:"pric"`
  2445. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2446. SelfpayProp float64 `json:"selfpay_prop"`
  2447. } `json:"result"`
  2448. } `json:"output"`
  2449. RefmsgTime string `json:"refmsg_time"`
  2450. RespondTime string `json:"respond_time"`
  2451. Signtype string `json:"signtype"`
  2452. WarnMsg string `json:"warn_msg"`
  2453. }
  2454. type ResultFive struct {
  2455. Balc float64 `json:"balc"`
  2456. CvlservFlag string `json:"cvlserv_flag"`
  2457. EmpName string `json:"emp_name"`
  2458. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2459. Insutype string `json:"insutype"`
  2460. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2461. PausInsuDate string `json:"paus_insu_date"`
  2462. PsnInsuDate string `json:"psn_insu_date"`
  2463. PsnInsuStas string `json:"psn_insu_stas"`
  2464. PsnType string `json:"psn_type"`
  2465. }
  2466. type ResultSix struct {
  2467. Cainfo interface{} `json:"cainfo"`
  2468. ErrMsg string `json:"err_msg"`
  2469. InfRefmsgid string `json:"inf_refmsgid"`
  2470. Infcode int64 `json:"infcode"`
  2471. Output struct {
  2472. } `json:"output"`
  2473. RefmsgTime string `json:"refmsg_time"`
  2474. RespondTime string `json:"respond_time"`
  2475. Signtype interface{} `json:"signtype"`
  2476. WarnMsg interface{} `json:"warn_msg"`
  2477. }
  2478. type ResultSix10265 struct {
  2479. Cainfo interface{} `json:"cainfo"`
  2480. ErrMsg string `json:"err_msg"`
  2481. InfRefmsgid string `json:"inf_refmsgid"`
  2482. Infcode string `json:"infcode"`
  2483. Output struct {
  2484. } `json:"output"`
  2485. RefmsgTime string `json:"refmsg_time"`
  2486. RespondTime string `json:"respond_time"`
  2487. Signtype interface{} `json:"signtype"`
  2488. WarnMsg interface{} `json:"warn_msg"`
  2489. }
  2490. type ResultSeven struct {
  2491. Cainfo string `json:"cainfo"`
  2492. ErrMsg string `json:"err_msg"`
  2493. InfRefmsgid string `json:"inf_refmsgid"`
  2494. Infcode int64 `json:"infcode"`
  2495. Output struct {
  2496. Setldetail []interface{} `json:"setldetail"`
  2497. Setlinfo struct {
  2498. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2499. AcctPay float64 `json:"acct_pay"`
  2500. ActPayDedc float64 `json:"act_pay_dedc"`
  2501. Age float64 `json:"age"`
  2502. Balc float64 `json:"balc"`
  2503. Brdy string `json:"brdy"`
  2504. Certno string `json:"certno"`
  2505. ClrOptins string `json:"clr_optins"`
  2506. ClrType string `json:"clr_type"`
  2507. ClrWay string `json:"clr_way"`
  2508. CvlservFlag string `json:"cvlserv_flag"`
  2509. CvlservPay float64 `json:"cvlserv_pay"`
  2510. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2511. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2512. Gend string `json:"gend"`
  2513. HifesPay float64 `json:"hifes_pay"`
  2514. HifmiPay float64 `json:"hifmi_pay"`
  2515. HifpPay float64 `json:"hifp_pay"`
  2516. HospPartAmt float64 `json:"hosp_part_amt"`
  2517. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2518. Insutype string `json:"insutype"`
  2519. MafPay float64 `json:"maf_pay"`
  2520. MdtrtCertType string `json:"mdtrt_cert_type"`
  2521. HifobPay float64 `json:"hifob_pay"`
  2522. MdtrtID string `json:"mdtrt_id"`
  2523. MedType string `json:"med_type"`
  2524. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2525. MedinsSetlID string `json:"medins_setl_id"`
  2526. Naty string `json:"naty"`
  2527. OthPay float64 `json:"oth_pay"`
  2528. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2529. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2530. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2531. PsnCashPay float64 `json:"psn_cash_pay"`
  2532. PsnCertType string `json:"psn_cert_type"`
  2533. PsnName string `json:"psn_name"`
  2534. PsnNo string `json:"psn_no"`
  2535. PsnPartAmt float64 `json:"psn_part_amt"`
  2536. PsnType string `json:"psn_type"`
  2537. SetlID string `json:"setl_id"`
  2538. SetlTime string `json:"setl_time"`
  2539. } `json:"setlinfo"`
  2540. } `json:"output"`
  2541. RefmsgTime string `json:"refmsg_time"`
  2542. RespondTime string `json:"respond_time"`
  2543. Signtype interface{} `json:"signtype"`
  2544. WarnMsg interface{} `json:"warn_msg"`
  2545. }
  2546. type ResultSeven10265 struct {
  2547. Cainfo string `json:"cainfo"`
  2548. ErrMsg string `json:"err_msg"`
  2549. InfRefmsgid string `json:"inf_refmsgid"`
  2550. Infcode string `json:"infcode"`
  2551. Output struct {
  2552. Setldetail []interface{} `json:"setldetail"`
  2553. Setlinfo struct {
  2554. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2555. AcctPay float64 `json:"acct_pay"`
  2556. ActPayDedc float64 `json:"act_pay_dedc"`
  2557. Age float64 `json:"age"`
  2558. Balc float64 `json:"balc"`
  2559. Brdy string `json:"brdy"`
  2560. Certno string `json:"certno"`
  2561. ClrOptins string `json:"clr_optins"`
  2562. ClrType string `json:"clr_type"`
  2563. ClrWay string `json:"clr_way"`
  2564. CvlservFlag string `json:"cvlserv_flag"`
  2565. CvlservPay float64 `json:"cvlserv_pay"`
  2566. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2567. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2568. Gend string `json:"gend"`
  2569. HifesPay float64 `json:"hifes_pay"`
  2570. HifmiPay float64 `json:"hifmi_pay"`
  2571. HifpPay float64 `json:"hifp_pay"`
  2572. HospPartAmt float64 `json:"hosp_part_amt"`
  2573. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2574. Insutype string `json:"insutype"`
  2575. MafPay float64 `json:"maf_pay"`
  2576. MdtrtCertType string `json:"mdtrt_cert_type"`
  2577. HifobPay float64 `json:"hifob_pay"`
  2578. MdtrtID string `json:"mdtrt_id"`
  2579. MedType string `json:"med_type"`
  2580. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2581. MedinsSetlID string `json:"medins_setl_id"`
  2582. Naty string `json:"naty"`
  2583. OthPay float64 `json:"oth_pay"`
  2584. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2585. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2586. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2587. PsnCashPay float64 `json:"psn_cash_pay"`
  2588. PsnCertType string `json:"psn_cert_type"`
  2589. PsnName string `json:"psn_name"`
  2590. PsnNo string `json:"psn_no"`
  2591. PsnPartAmt float64 `json:"psn_part_amt"`
  2592. PsnType string `json:"psn_type"`
  2593. SetlID string `json:"setl_id"`
  2594. SetlTime string `json:"setl_time"`
  2595. } `json:"setlinfo"`
  2596. } `json:"output"`
  2597. RefmsgTime string `json:"refmsg_time"`
  2598. RespondTime string `json:"respond_time"`
  2599. Signtype interface{} `json:"signtype"`
  2600. WarnMsg interface{} `json:"warn_msg"`
  2601. }
  2602. type ResultEight struct {
  2603. Cainfo string `json:"cainfo"`
  2604. ErrMsg string `json:"err_msg"`
  2605. InfRefmsgid string `json:"inf_refmsgid"`
  2606. Infcode int64 `json:"infcode"`
  2607. Output struct {
  2608. Stmtinfo struct {
  2609. SetlOptins string `json:"setl_optins"`
  2610. StmtRslt string `json:"stmt_rslt"`
  2611. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2612. } `json:"stmtinfo"`
  2613. } `json:"output"`
  2614. RefmsgTime string `json:"refmsg_time"`
  2615. RespondTime string `json:"respond_time"`
  2616. Signtype interface{} `json:"signtype"`
  2617. WarnMsg interface{} `json:"warn_msg"`
  2618. }
  2619. type ResultEightFor10188 struct {
  2620. Cainfo string `json:"cainfo"`
  2621. ErrMsg string `json:"err_msg"`
  2622. InfRefmsgid string `json:"inf_refmsgid"`
  2623. Infcode string `json:"infcode"`
  2624. Output struct {
  2625. Stmtinfo struct {
  2626. SetlOptins string `json:"setl_optins"`
  2627. StmtRslt string `json:"stmt_rslt"`
  2628. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2629. } `json:"stmtinfo"`
  2630. } `json:"output"`
  2631. RefmsgTime string `json:"refmsg_time"`
  2632. RespondTime string `json:"respond_time"`
  2633. Signtype interface{} `json:"signtype"`
  2634. WarnMsg interface{} `json:"warn_msg"`
  2635. }
  2636. type ResultNine struct {
  2637. Cainfo string `json:"cainfo"`
  2638. ErrMsg string `json:"err_msg"`
  2639. InfRefmsgid string `json:"inf_refmsgid"`
  2640. Infcode int64 `json:"infcode"`
  2641. Output struct {
  2642. FileQuryNo string `json:"file_qury_no"`
  2643. } `json:"output"`
  2644. RefmsgTime string `json:"refmsg_time"`
  2645. RespondTime string `json:"respond_time"`
  2646. Signtype interface{} `json:"signtype"`
  2647. WarnMsg interface{} `json:"warn_msg"`
  2648. }
  2649. type ResultTen struct {
  2650. Cainfo string `json:"cainfo"`
  2651. ErrMsg string `json:"err_msg"`
  2652. InfRefmsgid string `json:"inf_refmsgid"`
  2653. Infcode int64 `json:"infcode"`
  2654. Output struct {
  2655. DldEndtime string `json:"dld_endtime"`
  2656. FileQuryNo string `json:"file_qury_no"`
  2657. Filename string `json:"filename"`
  2658. } `json:"output"`
  2659. RefmsgTime string `json:"refmsg_time"`
  2660. RespondTime string `json:"respond_time"`
  2661. Signtype interface{} `json:"signtype"`
  2662. WarnMsg interface{} `json:"warn_msg"`
  2663. }
  2664. //type Autogenerated struct {
  2665. // Output struct {
  2666. // Setlinfo struct {
  2667. // SetlTime string `json:"setl_time"`
  2668. // CvlservPay float64 `json:"cvlserv_pay"`
  2669. // Year string `json:"year"`
  2670. // MedType string `json:"med_type"`
  2671. // PsnPay float64 `json:"psn_pay"`
  2672. // OpterID string `json:"opter_id"`
  2673. // Begndate string `json:"begndate"`
  2674. // FlxempeFlag string `json:"flxempe_flag"`
  2675. // HifmiPay float64 `json:"hifmi_pay"`
  2676. // PsnNo string `json:"psn_no"`
  2677. // ActPayDedc float64 `json:"act_pay_dedc"`
  2678. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2679. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2680. // ClrWay string `json:"clr_way"`
  2681. // OthPay float64 `json:"oth_pay"`
  2682. // Gend string `json:"gend"`
  2683. // MdtrtID string `json:"mdtrt_id"`
  2684. // AcctPay float64 `json:"acct_pay"`
  2685. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2686. // Insutype string `json:"insutype"`
  2687. // Invono interface{} `json:"invono"`
  2688. // Enddate string `json:"enddate"`
  2689. // CashPayamt float64 `json:"cash_payamt"`
  2690. // PsnType string `json:"psn_type"`
  2691. // FixmedinsName string `json:"fixmedins_name"`
  2692. // HifpPay float64 `json:"hifp_pay"`
  2693. // NewFlag interface{} `json:"new_flag"`
  2694. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2695. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2696. // PayLoc string `json:"pay_loc"`
  2697. // ClrType string `json:"clr_type"`
  2698. // RefdSetlFlag string `json:"refd_setl_flag"`
  2699. // CvlservFlag string `json:"cvlserv_flag"`
  2700. // EmpName string `json:"emp_name"`
  2701. // Brdy string `json:"brdy"`
  2702. // Naty string `json:"naty"`
  2703. // Certno string `json:"certno"`
  2704. // DiseCode string `json:"dise_code"`
  2705. // FixmedinsCode string `json:"fixmedins_code"`
  2706. // DedcHospLv string `json:"dedc_hosp_lv"`
  2707. // OpterName string `json:"opter_name"`
  2708. // Balc float64 `json:"balc"`
  2709. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2710. // PsnCertType string `json:"psn_cert_type"`
  2711. // HifobPay float64 `json:"hifob_pay"`
  2712. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2713. // HifesPay float64 `json:"hifes_pay"`
  2714. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2715. // OptTime string `json:"opt_time"`
  2716. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2717. // SetlID string `json:"setl_id"`
  2718. // MafPay float64 `json:"maf_pay"`
  2719. // PsnName string `json:"psn_name"`
  2720. // InsuOptins interface{} `json:"insu_optins"`
  2721. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2722. // ClrOptins string `json:"clr_optins"`
  2723. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2724. // DiseName string `json:"dise_name"`
  2725. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2726. // Age float64 `json:"age"`
  2727. // DtrtCertType string `json:"dtrt_cert_type"`
  2728. // HospLv string `json:"hosp_lv"`
  2729. // } `json:"setlinfo"`
  2730. // Setldetail []struct {
  2731. // FundPayType string `json:"fund_pay_type"`
  2732. // FundPayamt float64 `json:"fund_payamt"`
  2733. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2734. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2735. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2736. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2737. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2738. // } `json:"setldetail"`
  2739. // } `json:"output"`
  2740. // Infcode int `json:"infcode"`
  2741. // WarnMsg interface{} `json:"warn_msg"`
  2742. // Cainfo interface{} `json:"cainfo"`
  2743. // ErrMsg interface{} `json:"err_msg"`
  2744. // RefmsgTime string `json:"refmsg_time"`
  2745. // Signtype interface{} `json:"signtype"`
  2746. // RespondTime string `json:"respond_time"`
  2747. // InfRefmsgid string `json:"inf_refmsgid"`
  2748. //}
  2749. type ResultEleven struct {
  2750. Cainfo string `json:"cainfo"`
  2751. ErrMsg string `json:"err_msg"`
  2752. InfRefmsgid string `json:"inf_refmsgid"`
  2753. Infcode int64 `json:"infcode"`
  2754. Output struct {
  2755. Setlinfo struct {
  2756. SetlTime string `json:"setl_time"`
  2757. CvlservPay float64 `json:"cvlserv_pay"`
  2758. Year string `json:"year"`
  2759. MedType string `json:"med_type"`
  2760. PsnPay float64 `json:"psn_pay"`
  2761. OpterID string `json:"opter_id"`
  2762. Begndate string `json:"begndate"`
  2763. FlxempeFlag string `json:"flxempe_flag"`
  2764. HifmiPay float64 `json:"hifmi_pay"`
  2765. PsnNo string `json:"psn_no"`
  2766. ActPayDedc float64 `json:"act_pay_dedc"`
  2767. MedinsSetlID interface{} `json:"medins_setl_id"`
  2768. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2769. ClrWay string `json:"clr_way"`
  2770. OthPay float64 `json:"oth_pay"`
  2771. Gend string `json:"gend"`
  2772. MdtrtID string `json:"mdtrt_id"`
  2773. AcctPay float64 `json:"acct_pay"`
  2774. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2775. Insutype string `json:"insutype"`
  2776. Invono interface{} `json:"invono"`
  2777. Enddate string `json:"enddate"`
  2778. CashPayamt float64 `json:"cash_payamt"`
  2779. PsnType string `json:"psn_type"`
  2780. FixmedinsName string `json:"fixmedins_name"`
  2781. HifpPay float64 `json:"hifp_pay"`
  2782. NewFlag interface{} `json:"new_flag"`
  2783. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2784. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2785. PayLoc string `json:"pay_loc"`
  2786. ClrType string `json:"clr_type"`
  2787. RefdSetlFlag string `json:"refd_setl_flag"`
  2788. CvlservFlag string `json:"cvlserv_flag"`
  2789. EmpName string `json:"emp_name"`
  2790. Brdy string `json:"brdy"`
  2791. Naty string `json:"naty"`
  2792. Certno string `json:"certno"`
  2793. DiseCode string `json:"dise_code"`
  2794. FixmedinsCode string `json:"fixmedins_code"`
  2795. DedcHospLv string `json:"dedc_hosp_lv"`
  2796. OpterName string `json:"opter_name"`
  2797. Balc float64 `json:"balc"`
  2798. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2799. PsnCertType string `json:"psn_cert_type"`
  2800. HifobPay float64 `json:"hifob_pay"`
  2801. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2802. HifesPay float64 `json:"hifes_pay"`
  2803. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2804. OptTime string `json:"opt_time"`
  2805. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2806. SetlID string `json:"setl_id"`
  2807. MafPay float64 `json:"maf_pay"`
  2808. PsnName string `json:"psn_name"`
  2809. InsuOptins interface{} `json:"insu_optins"`
  2810. PrefFundPay interface{} `json:"pref_fund_pay"`
  2811. ClrOptins string `json:"clr_optins"`
  2812. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2813. DiseName string `json:"dise_name"`
  2814. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2815. Age float64 `json:"age"`
  2816. DtrtCertType string `json:"dtrt_cert_type"`
  2817. HospLv string `json:"hosp_lv"`
  2818. } `json:"setlinfo"`
  2819. } `json:"output"`
  2820. RefmsgTime string `json:"refmsg_time"`
  2821. RespondTime string `json:"respond_time"`
  2822. Signtype interface{} `json:"signtype"`
  2823. WarnMsg interface{} `json:"warn_msg"`
  2824. }
  2825. type ResultEleven10265 struct {
  2826. Cainfo string `json:"cainfo"`
  2827. ErrMsg string `json:"err_msg"`
  2828. InfRefmsgid string `json:"inf_refmsgid"`
  2829. Infcode string `json:"infcode"`
  2830. Output struct {
  2831. Setlinfo struct {
  2832. SetlTime string `json:"setl_time"`
  2833. CvlservPay float64 `json:"cvlserv_pay"`
  2834. Year string `json:"year"`
  2835. MedType string `json:"med_type"`
  2836. PsnPay float64 `json:"psn_pay"`
  2837. OpterID string `json:"opter_id"`
  2838. Begndate string `json:"begndate"`
  2839. FlxempeFlag string `json:"flxempe_flag"`
  2840. HifmiPay float64 `json:"hifmi_pay"`
  2841. PsnNo string `json:"psn_no"`
  2842. ActPayDedc float64 `json:"act_pay_dedc"`
  2843. MedinsSetlID interface{} `json:"medins_setl_id"`
  2844. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2845. ClrWay string `json:"clr_way"`
  2846. OthPay float64 `json:"oth_pay"`
  2847. Gend string `json:"gend"`
  2848. MdtrtID string `json:"mdtrt_id"`
  2849. AcctPay float64 `json:"acct_pay"`
  2850. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2851. Insutype string `json:"insutype"`
  2852. Invono interface{} `json:"invono"`
  2853. Enddate string `json:"enddate"`
  2854. CashPayamt float64 `json:"cash_payamt"`
  2855. PsnType string `json:"psn_type"`
  2856. FixmedinsName string `json:"fixmedins_name"`
  2857. HifpPay float64 `json:"hifp_pay"`
  2858. NewFlag interface{} `json:"new_flag"`
  2859. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2860. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2861. PayLoc string `json:"pay_loc"`
  2862. ClrType string `json:"clr_type"`
  2863. RefdSetlFlag string `json:"refd_setl_flag"`
  2864. CvlservFlag string `json:"cvlserv_flag"`
  2865. EmpName string `json:"emp_name"`
  2866. Brdy string `json:"brdy"`
  2867. Naty string `json:"naty"`
  2868. Certno string `json:"certno"`
  2869. DiseCode string `json:"dise_code"`
  2870. FixmedinsCode string `json:"fixmedins_code"`
  2871. DedcHospLv string `json:"dedc_hosp_lv"`
  2872. OpterName string `json:"opter_name"`
  2873. Balc float64 `json:"balc"`
  2874. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2875. PsnCertType string `json:"psn_cert_type"`
  2876. HifobPay float64 `json:"hifob_pay"`
  2877. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2878. HifesPay float64 `json:"hifes_pay"`
  2879. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2880. OptTime string `json:"opt_time"`
  2881. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2882. SetlID string `json:"setl_id"`
  2883. MafPay float64 `json:"maf_pay"`
  2884. PsnName string `json:"psn_name"`
  2885. InsuOptins interface{} `json:"insu_optins"`
  2886. PrefFundPay interface{} `json:"pref_fund_pay"`
  2887. ClrOptins string `json:"clr_optins"`
  2888. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2889. DiseName string `json:"dise_name"`
  2890. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2891. Age float64 `json:"age"`
  2892. DtrtCertType string `json:"dtrt_cert_type"`
  2893. HospLv string `json:"hosp_lv"`
  2894. } `json:"setlinfo"`
  2895. } `json:"output"`
  2896. RefmsgTime string `json:"refmsg_time"`
  2897. RespondTime string `json:"respond_time"`
  2898. Signtype interface{} `json:"signtype"`
  2899. WarnMsg interface{} `json:"warn_msg"`
  2900. }
  2901. type ResultTwelve struct {
  2902. Cainfo string `json:"cainfo"`
  2903. ErrMsg string `json:"err_msg"`
  2904. InfRefmsgid string `json:"inf_refmsgid"`
  2905. Infcode int64 `json:"infcode"`
  2906. Output struct {
  2907. MdtrtId string `json:"mdtrt_id"`
  2908. ChrgBchno string `json:"chrg_bchno"`
  2909. PsnNo string `json:"psn_no"`
  2910. } `json:"output"`
  2911. RefmsgTime string `json:"refmsg_time"`
  2912. RespondTime string `json:"respond_time"`
  2913. Signtype interface{} `json:"signtype"`
  2914. WarnMsg interface{} `json:"warn_msg"`
  2915. }
  2916. type ResultThirteen struct {
  2917. ErrMsg string `json:"err_msg"`
  2918. InfRefmsgid string `json:"inf_refmsgid"`
  2919. Infcode int64 `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 ResultThirteen10265 struct {
  2931. ErrMsg string `json:"err_msg"`
  2932. InfRefmsgid string `json:"inf_refmsgid"`
  2933. Infcode string `json:"infcode"`
  2934. Output struct {
  2935. Result struct {
  2936. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2937. } `json:"result"`
  2938. } `json:"output"`
  2939. RefmsgTime string `json:"refmsg_time"`
  2940. RespondTime string `json:"respond_time"`
  2941. Signtype interface{} `json:"signtype"`
  2942. WarnInfo interface{} `json:"warn_info"`
  2943. }
  2944. type ResultFourteen struct {
  2945. ErrMsg string `json:"err_msg"`
  2946. InfRefmsgid string `json:"inf_refmsgid"`
  2947. Infcode int64 `json:"infcode"`
  2948. Output struct {
  2949. } `json:"output"`
  2950. RefmsgTime string `json:"refmsg_time"`
  2951. RespondTime string `json:"respond_time"`
  2952. Signtype interface{} `json:"signtype"`
  2953. WarnInfo interface{} `json:"warn_info"`
  2954. }
  2955. type ResultFourteen10265 struct {
  2956. ErrMsg string `json:"err_msg"`
  2957. InfRefmsgid string `json:"inf_refmsgid"`
  2958. Infcode string `json:"infcode"`
  2959. Output struct {
  2960. } `json:"output"`
  2961. RefmsgTime string `json:"refmsg_time"`
  2962. RespondTime string `json:"respond_time"`
  2963. Signtype interface{} `json:"signtype"`
  2964. WarnInfo interface{} `json:"warn_info"`
  2965. }
  2966. type ResultSixteen struct {
  2967. Cainfo string `json:"cainfo"`
  2968. ErrMsg string `json:"err_msg"`
  2969. InfRefmsgid string `json:"inf_refmsgid"`
  2970. Infcode int64 `json:"infcode"`
  2971. Output struct {
  2972. Setldetail []interface{} `json:"setldetail"`
  2973. Setlinfo struct {
  2974. MdtrtID string `json:"mdtrt_id"`
  2975. SetlID string `json:"setl_id"`
  2976. ClrOptins string `json:"clr_optins"`
  2977. SetlTime string `json:"setl_time"`
  2978. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2979. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2980. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2981. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2982. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2983. ActPayDedc float64 `json:"act_pay_dedc"`
  2984. HifpPay float64 `json:"hifp_pay"`
  2985. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2986. Lfpay float64 `json:"selfpay"`
  2987. CvlservPay float64 `json:"cvlserv_pay"`
  2988. HifesPay float64 `json:"hifes_pay"`
  2989. HifmiPay float64 `json:"hifmi_pay"`
  2990. HifobPay float64 `json:"hifob_pay"`
  2991. MafPay float64 `json:"maf_pay"`
  2992. OthPay float64 `json:"oth_pay"`
  2993. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2994. PsnPartAmt float64 `json:"psn_part_amt"`
  2995. AcctPay float64 `json:"acct_pay"`
  2996. Balc float64 `json:"balc"`
  2997. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2998. HospPartAmt float64 `json:"hosp_part_amt"`
  2999. MedinsSetlID string `json:"medins_setl_id"`
  3000. PdnCashPay string `json:"pdn_cash_pay"`
  3001. } `json:"setlinfo"`
  3002. } `json:"output"`
  3003. RefmsgTime string `json:"refmsg_time"`
  3004. RespondTime string `json:"respond_time"`
  3005. Signtype interface{} `json:"signtype"`
  3006. WarnMsg interface{} `json:"warn_msg"`
  3007. }
  3008. type ResultSixteen10265 struct {
  3009. Cainfo string `json:"cainfo"`
  3010. ErrMsg string `json:"err_msg"`
  3011. InfRefmsgid string `json:"inf_refmsgid"`
  3012. Infcode string `json:"infcode"`
  3013. Output struct {
  3014. Setldetail []interface{} `json:"setldetail"`
  3015. Setlinfo struct {
  3016. MdtrtID string `json:"mdtrt_id"`
  3017. SetlID string `json:"setl_id"`
  3018. ClrOptins string `json:"clr_optins"`
  3019. SetlTime string `json:"setl_time"`
  3020. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3021. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3022. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3023. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3024. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3025. ActPayDedc float64 `json:"act_pay_dedc"`
  3026. HifpPay float64 `json:"hifp_pay"`
  3027. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3028. Lfpay float64 `json:"selfpay"`
  3029. CvlservPay float64 `json:"cvlserv_pay"`
  3030. HifesPay float64 `json:"hifes_pay"`
  3031. HifmiPay float64 `json:"hifmi_pay"`
  3032. HifobPay float64 `json:"hifob_pay"`
  3033. MafPay float64 `json:"maf_pay"`
  3034. OthPay float64 `json:"oth_pay"`
  3035. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3036. PsnPartAmt float64 `json:"psn_part_amt"`
  3037. AcctPay float64 `json:"acct_pay"`
  3038. Balc float64 `json:"balc"`
  3039. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3040. HospPartAmt float64 `json:"hosp_part_amt"`
  3041. MedinsSetlID string `json:"medins_setl_id"`
  3042. PdnCashPay string `json:"pdn_cash_pay"`
  3043. } `json:"setlinfo"`
  3044. } `json:"output"`
  3045. RefmsgTime string `json:"refmsg_time"`
  3046. RespondTime string `json:"respond_time"`
  3047. Signtype interface{} `json:"signtype"`
  3048. WarnMsg interface{} `json:"warn_msg"`
  3049. }
  3050. type ResultSeventeen struct {
  3051. ErrMsg string `json:"err_msg"`
  3052. InfRefmsgid string `json:"inf_refmsgid"`
  3053. Infcode int64 `json:"infcode"`
  3054. Output struct {
  3055. SetlListId string `json:"setl_list_id"`
  3056. } `json:"output"`
  3057. RefmsgTime string `json:"refmsg_time"`
  3058. RespondTime string `json:"respond_time"`
  3059. Signtype string `json:"signtype"`
  3060. WarnInfo string `json:"warn_info"`
  3061. }
  3062. type Result90991 struct {
  3063. ErrMsg string `json:"err_msg"`
  3064. InfRefmsgid string `json:"inf_refmsgid"`
  3065. Infcode int64 `json:"infcode"`
  3066. Output struct {
  3067. Result struct {
  3068. PsnNo string `json:"psn_no"`
  3069. CardStat string `json:"card_stat"`
  3070. Certno string `json:"certno"`
  3071. PsnName string `json:"psn_name"`
  3072. CheckStat string `json:"check_stat"`
  3073. } `json:"result"`
  3074. } `json:"output"`
  3075. RefmsgTime string `json:"refmsg_time"`
  3076. RespondTime string `json:"respond_time"`
  3077. Signtype interface{} `json:"signtype"`
  3078. WarnInfo interface{} `json:"warn_info"`
  3079. }
  3080. type Result90100 struct {
  3081. ErrMsg string `json:"err_msg"`
  3082. InfRefmsgid string `json:"inf_refmsgid"`
  3083. Infcode int64 `json:"infcode"`
  3084. Output struct {
  3085. PoolareaNo string `json:"poolarea_no"`
  3086. PoolareaNoName string `json:"poolarea_no_name"`
  3087. Insutype string `json:"insutype"`
  3088. InsutypeName string `json:"insutype_name"`
  3089. ClctType string `json:"clct_type"`
  3090. ClctTypeName string `json:"clct_type_name"`
  3091. ClctFlag string `json:"clct_flag"`
  3092. ClctFlagName string `json:"clct_flag_name"`
  3093. AccrymBegn string `json:"accrym_begn"`
  3094. AccrymEnd string `json:"accrym_end"`
  3095. ClctTime string `json:"clct_time"`
  3096. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3097. } `json:"output"`
  3098. RefmsgTime string `json:"refmsg_time"`
  3099. RespondTime string `json:"respond_time"`
  3100. Signtype interface{} `json:"signtype"`
  3101. WarnInfo interface{} `json:"warn_info"`
  3102. }
  3103. type Custom struct {
  3104. DetItemFeeSumamt string
  3105. Cut string
  3106. FeedetlSn string
  3107. Price string
  3108. MedListCodg string
  3109. Type int64
  3110. AdviceId int64
  3111. ProjectId int64
  3112. ItemId int64
  3113. }
  3114. type Result5301 struct {
  3115. ErrMsg string `json:"err_msg"`
  3116. InfRefmsgid string `json:"inf_refmsgid"`
  3117. Infcode int64 `json:"infcode"`
  3118. Output struct {
  3119. Result []struct {
  3120. OpspDiseCode string `json:"opsp_dise_code"`
  3121. OpspDiseName string `json:"opsp_dise_name"`
  3122. Begndate string `json:"begndate"`
  3123. Enddate string `json:"enddate"`
  3124. } `json:"feedetail"`
  3125. } `json:"output"`
  3126. RefmsgTime string `json:"refmsg_time"`
  3127. RespondTime string `json:"respond_time"`
  3128. Signtype interface{} `json:"signtype"`
  3129. WarnInfo interface{} `json:"warn_info"`
  3130. }
  3131. type Result5301For10265 struct {
  3132. ErrMsg string `json:"err_msg"`
  3133. InfRefmsgid string `json:"inf_refmsgid"`
  3134. Infcode string `json:"infcode"`
  3135. Output struct {
  3136. Result []struct {
  3137. OpspDiseCode string `json:"opsp_dise_code"`
  3138. OpspDiseName string `json:"opsp_dise_name"`
  3139. Begndate string `json:"begndate"`
  3140. Enddate string `json:"enddate"`
  3141. } `json:"feedetail"`
  3142. } `json:"output"`
  3143. RefmsgTime string `json:"refmsg_time"`
  3144. RespondTime string `json:"respond_time"`
  3145. Signtype interface{} `json:"signtype"`
  3146. WarnInfo interface{} `json:"warn_info"`
  3147. }
  3148. //获取个人信息----挂号-----上传就诊信息
  3149. func (c *HisApiController) GetRegisterInfo() {
  3150. id, _ := c.GetInt64("id")
  3151. record_time := c.GetString("record_time")
  3152. settlementValue, _ := c.GetInt64("settlement_value")
  3153. medical_insurance_card := c.GetString("medical_insurance_card")
  3154. name := c.GetString("name")
  3155. id_card_type, _ := c.GetInt64("id_card_type")
  3156. certificates, _ := c.GetInt64("certificates")
  3157. medical_care, _ := c.GetInt64("medical_care")
  3158. birthday := c.GetString("birthday")
  3159. id_card := c.GetString("id_card")
  3160. register_type, _ := c.GetInt64("register")
  3161. doctor, _ := c.GetInt64("doctor")
  3162. department, _ := c.GetInt64("department")
  3163. gender, _ := c.GetInt64("sex")
  3164. registration_fee, _ := c.GetFloat("registration_fee")
  3165. medical_expenses, _ := c.GetFloat("medical_expenses")
  3166. social_type, _ := c.GetInt64("social_type")
  3167. med_type := c.GetString("social_type")
  3168. admin_user_id, _ := c.GetInt64("admin_user_id")
  3169. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3170. timeLayout := "2006-01-02"
  3171. loc, _ := time.LoadLocation("Local")
  3172. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3173. birthUnix := birthdays.Unix()
  3174. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3175. if err != nil {
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3177. return
  3178. }
  3179. recordDateTime := theTime.Unix()
  3180. adminInfo := c.GetAdminUserInfo()
  3181. var patient service.Patients
  3182. if id == 0 {
  3183. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3184. } else {
  3185. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3186. }
  3187. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3188. if patientPrescription.ID == 0 {
  3189. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3190. }
  3191. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3192. if patient.ID == 0 {
  3193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3194. return
  3195. }
  3196. if len(patient.IdCardNo) == 0 {
  3197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3198. return
  3199. }
  3200. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3201. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3202. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3203. //就诊结算未完成,不能进行二次挂号
  3204. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3205. if len(his) >= 1 {
  3206. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3207. if len(his) >= 1 && order.ID == 0 {
  3208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3209. return
  3210. }
  3211. }
  3212. //var register_log string
  3213. if config.IsOpen == 1 {
  3214. var res ResultTwo
  3215. var res10265 ResultTwo10265
  3216. var PsnNo string
  3217. var PsnCertType string
  3218. var Certno string
  3219. var PsnName string
  3220. var Gend string
  3221. var Naty string
  3222. var Brdy string
  3223. var Age float64
  3224. var infoStr string
  3225. var idetinfoStr string
  3226. var infocode int64
  3227. var verify_number string
  3228. fmt.Println(verify_number)
  3229. if miConfig.MdtrtareaAdmvs == "421300" {
  3230. psn_info, _ := service.GetPsnByPatientId(id)
  3231. PsnNo = psn_info.PsnNo
  3232. PsnCertType = psn_info.PsnCertType
  3233. Certno = psn_info.Certno
  3234. PsnName = psn_info.PsnName
  3235. Gend = psn_info.Gend
  3236. Naty = psn_info.Naty
  3237. Brdy = psn_info.Brdy
  3238. Age = psn_info.Age
  3239. infoStr = psn_info.Insuinfo
  3240. idetinfoStr = psn_info.Idetinfo
  3241. infocode = 0
  3242. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3243. psn_info, _ := service.GetPsnByPatientId(id)
  3244. PsnNo = psn_info.PsnNo
  3245. PsnCertType = psn_info.PsnCertType
  3246. Certno = psn_info.Certno
  3247. PsnName = psn_info.PsnName
  3248. Gend = psn_info.Gend
  3249. Naty = psn_info.Naty
  3250. Brdy = psn_info.Brdy
  3251. Age = psn_info.Age
  3252. infoStr = psn_info.Insuinfo
  3253. idetinfoStr = psn_info.Idetinfo
  3254. infocode = 0
  3255. verify_number = psn_info.VerifyNumber
  3256. } else {
  3257. var result string
  3258. var requestLog string
  3259. if miConfig.UserOrgId == 10138 {
  3260. 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)
  3261. } else {
  3262. 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)
  3263. }
  3264. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3265. if miConfig.Code == "H15049901371" {
  3266. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3267. utils.ErrorLog("解析失败:%v", err)
  3268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3269. return
  3270. }
  3271. res.ErrMsg = res10265.ErrMsg
  3272. res.Output = res10265.Output
  3273. res.InfRefmsgid = res10265.InfRefmsgid
  3274. } else {
  3275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3276. utils.ErrorLog("解析失败:%v", err)
  3277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3278. return
  3279. }
  3280. }
  3281. PsnNo = res.Output.Baseinfo.PsnNo
  3282. PsnCertType = res.Output.Baseinfo.PsnCertType
  3283. Certno = res.Output.Baseinfo.Certno
  3284. PsnName = res.Output.Baseinfo.PsnName
  3285. Gend = res.Output.Baseinfo.Gend
  3286. Naty = res.Output.Baseinfo.Naty
  3287. Brdy = res.Output.Baseinfo.Brdy
  3288. Age = res.Output.Baseinfo.Age
  3289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3291. infoStr = string(Iinfos)
  3292. idetinfoStr = string(Idetinfos)
  3293. if miConfig.Code == "H15049901371" {
  3294. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3295. } else {
  3296. infocode = res.Infcode
  3297. }
  3298. }
  3299. if infocode == 0 {
  3300. his := models.VMHisPatient{
  3301. Name: name,
  3302. Gender: gender,
  3303. Birthday: birthUnix,
  3304. MedicalTreatmentType: medical_care,
  3305. IdType: certificates,
  3306. IdCardNo: id_card,
  3307. BalanceAccountsType: settlementValue,
  3308. SocialType: social_type,
  3309. MedicalInsuranceNumber: medical_insurance_card,
  3310. RegisterType: register_type,
  3311. RegisterCost: registration_fee,
  3312. TreatmentCost: medical_expenses,
  3313. Status: 1,
  3314. Ctime: time.Now().Unix(),
  3315. Mtime: time.Now().Unix(),
  3316. PsnNo: PsnNo,
  3317. PsnCertType: PsnCertType,
  3318. Certno: Certno,
  3319. PsnName: PsnName,
  3320. Gend: Gend,
  3321. Naty: Naty,
  3322. Brdy: Brdy,
  3323. Age: Age,
  3324. Iinfo: infoStr,
  3325. Idetinfo: idetinfoStr,
  3326. PatientId: patient.ID,
  3327. RecordDate: theTime.Unix(),
  3328. UserOrgId: adminInfo.CurrentOrgId,
  3329. AdminUserId: admin_user_id,
  3330. IsReturn: 1,
  3331. IdCardType: id_card_type,
  3332. Doctor: doctor,
  3333. Departments: department,
  3334. }
  3335. timestamp := time.Now().Unix()
  3336. tempTime := time.Unix(timestamp, 0)
  3337. timeFormat := tempTime.Format("20060102150405")
  3338. chrgBchno := rand.Intn(100000) + 10000
  3339. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3340. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3341. department, _ := service.GetDepartMentDetail(department)
  3342. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3343. IdCardNo := ""
  3344. if id_card_type == 1 {
  3345. // IdCardNo = medical_insurance_card
  3346. IdCardNo = patient.IdCardNo
  3347. } else {
  3348. IdCardNo = patient.IdCardNo
  3349. }
  3350. var rf []*ResultFive
  3351. json.Unmarshal([]byte(his.Iinfo), &rf)
  3352. var insutypes []*ResultFive
  3353. var insutype string
  3354. var insuplc_admdvs_temp string
  3355. var is390 int = 0
  3356. var is310 int = 0
  3357. for _, item := range rf {
  3358. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3359. insutypes = append(insutypes, item)
  3360. }
  3361. }
  3362. if len(insutypes) == 1 {
  3363. insutype = insutypes[0].Insutype
  3364. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3365. } else {
  3366. for _, i := range insutypes {
  3367. if i.Insutype == "390" {
  3368. is390 = 1
  3369. }
  3370. if i.Insutype == "310" {
  3371. is310 = 1
  3372. }
  3373. }
  3374. }
  3375. if is390 == 1 {
  3376. insutype = "390"
  3377. }
  3378. if is310 == 1 {
  3379. insutype = "310"
  3380. }
  3381. if len(insutypes) == 0 {
  3382. insutype = "310"
  3383. }
  3384. if len(insutypes) == 2 {
  3385. insutype = med_type
  3386. }
  3387. if len(med_type) > 0 {
  3388. insutype = med_type
  3389. }
  3390. //for _, item := range rf {
  3391. // if item.Insutype == insutype {
  3392. // insuplc_admdvs = item.InsuplcAdmdvs
  3393. // }
  3394. //}
  3395. var infocode int64
  3396. var resThree ResultThree
  3397. var resThree10265 ResultThree10265
  3398. if len(insuplc_admdvs) == 0 {
  3399. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3400. } else {
  3401. insuplc_admdvs_temp = insuplc_admdvs
  3402. }
  3403. if miConfig.MdtrtareaAdmvs == "421300" {
  3404. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3405. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3406. "&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
  3407. resp, requestErr := http.Get(api)
  3408. if requestErr != nil {
  3409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3410. return
  3411. }
  3412. body, ioErr := ioutil.ReadAll(resp.Body)
  3413. if ioErr != nil {
  3414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3416. return
  3417. }
  3418. var respJSON map[string]interface{}
  3419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3425. result, _ := json.Marshal(respJSON)
  3426. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3427. utils.ErrorLog("解析失败:%v", err)
  3428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3429. return
  3430. }
  3431. infocode = resThree.Infcode
  3432. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3433. psn_info, _ := service.GetPsnByPatientId(id)
  3434. bas := strings.Split(psn_info.CardInfo, "|")
  3435. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3436. var api string
  3437. if miConfig.MdtrtareaAdmvs == "320921" {
  3438. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3439. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3440. "&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
  3441. } else {
  3442. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3443. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3444. "&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
  3445. }
  3446. resp, requestErr := http.Get(api)
  3447. if requestErr != nil {
  3448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3449. return
  3450. }
  3451. body, ioErr := ioutil.ReadAll(resp.Body)
  3452. if ioErr != nil {
  3453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3455. return
  3456. }
  3457. var respJSON map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3464. result, _ := json.Marshal(respJSON)
  3465. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3466. utils.ErrorLog("解析失败:%v", err)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. resThree.ErrMsg = resThree10265.ErrMsg
  3471. resThree.Output = resThree10265.Output
  3472. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3473. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3474. } else {
  3475. 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)
  3476. saveLog(result, requestLog, "2201", "挂号")
  3477. if miConfig.Code == "H15049901371" {
  3478. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3479. utils.ErrorLog("解析失败:%v", err)
  3480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. return
  3482. }
  3483. resThree.ErrMsg = resThree10265.ErrMsg
  3484. resThree.Output = resThree10265.Output
  3485. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3486. } else {
  3487. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3488. utils.ErrorLog("解析失败:%v", err)
  3489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3490. return
  3491. }
  3492. }
  3493. if miConfig.Code == "H15049901371" {
  3494. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3495. } else {
  3496. infocode = resThree.Infcode
  3497. }
  3498. }
  3499. if infocode != 0 {
  3500. adminUser := c.GetAdminUserInfo()
  3501. errlog := &models.HisOrderError{
  3502. UserOrgId: adminUser.CurrentOrgId,
  3503. Ctime: time.Now().Unix(),
  3504. Mtime: time.Now().Unix(),
  3505. ErrMsg: resThree.ErrMsg,
  3506. Status: 1,
  3507. PatientId: id,
  3508. RecordTime: recordDateTime,
  3509. Stage: 2,
  3510. }
  3511. service.CreateErrMsgLog(errlog)
  3512. c.ServeSuccessJSON(map[string]interface{}{
  3513. "failed_code": -10,
  3514. "msg": resThree.ErrMsg,
  3515. })
  3516. return
  3517. }
  3518. his.Number = resThree.Output.Data.MdtrtID
  3519. his.PsnNo = resThree.Output.Data.PsnNo
  3520. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3521. his.IdCardNo = patient.IdCardNo
  3522. his.PhoneNumber = patient.Phone
  3523. his.UserOrgId = adminInfo.CurrentOrgId
  3524. his.Insutype = insutype
  3525. his.Ctime = time.Now().Unix()
  3526. his.Mtime = time.Now().Unix()
  3527. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3528. his.Status = 1
  3529. service.UpdateHisPatientStatus(&his)
  3530. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3531. c.ServeSuccessJSON(map[string]interface{}{
  3532. "his_info": his,
  3533. })
  3534. } else {
  3535. adminUser := c.GetAdminUserInfo()
  3536. errlog := &models.HisOrderError{
  3537. UserOrgId: adminUser.CurrentOrgId,
  3538. Ctime: time.Now().Unix(),
  3539. Mtime: time.Now().Unix(),
  3540. ErrMsg: res.ErrMsg,
  3541. Status: 1,
  3542. PatientId: id,
  3543. RecordTime: recordDateTime,
  3544. Stage: 1,
  3545. }
  3546. service.CreateErrMsgLog(errlog)
  3547. c.ServeSuccessJSON(map[string]interface{}{
  3548. "failed_code": -10,
  3549. "msg": res.ErrMsg,
  3550. })
  3551. return
  3552. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3553. }
  3554. }
  3555. }
  3556. //上传明细----预结算----确认订单
  3557. func (c *HisApiController) GetUploadInfo() {
  3558. id, _ := c.GetInt64("id")
  3559. record_time := c.GetString("record_time")
  3560. his_patient_id, _ := c.GetInt64("his_patient_id")
  3561. order_id, _ := c.GetInt64("order_id")
  3562. pay_way, _ := c.GetInt64("pay_way")
  3563. pay_price, _ := c.GetFloat("pay_price")
  3564. pay_card_no := c.GetString("pay_card_no")
  3565. discount_price, _ := c.GetFloat("discount_price")
  3566. preferential_price, _ := c.GetFloat("preferential_price")
  3567. reality_price, _ := c.GetFloat("reality_price")
  3568. found_price, _ := c.GetFloat("found_price")
  3569. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3570. private_price, _ := c.GetFloat("private_price")
  3571. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3572. admin_user_id, _ := c.GetInt64("admin_user_id")
  3573. fapiao_code := c.GetString("fapiao_code")
  3574. fapiao_number := c.GetString("fapiao_number")
  3575. diagnosis_id := c.GetString("diagnosis")
  3576. sick_type, _ := c.GetInt64("sick_type")
  3577. reg_type, _ := c.GetInt64("p_type")
  3578. begin_time := c.GetString("begin_time")
  3579. id_str := c.GetString("ids")
  3580. ids_arr := strings.Split(id_str, ",")
  3581. timeLayout := "2006-01-02"
  3582. loc, _ := time.LoadLocation("Local")
  3583. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3584. if err != nil {
  3585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3586. return
  3587. }
  3588. recordDateTime := theTime.Unix()
  3589. adminUser := c.GetAdminUserInfo()
  3590. var tempOrder models.HisOrder
  3591. tempOrder, _ = service.GetHisOrderByID(order_id)
  3592. var prescriptions []*models.HisPrescription
  3593. var start_time int64
  3594. var end_time int64
  3595. //if adminUser.CurrentOrgId == 10106{
  3596. // if len(fapiao_code) == 0{
  3597. // fapiao_code = "144072080589"
  3598. // }
  3599. // if len(fapiao_number) == 0{
  3600. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3601. // if order.ID == 0{
  3602. // fapiao_number = "00001520"
  3603. // }else{
  3604. // //fapiao_code = "00001520"
  3605. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3606. // var zero string
  3607. // if fpNumber >= 1000{
  3608. // zero = "0000" + strconv.Itoa(fpNumber)
  3609. // }else if fpNumber >= 10000{
  3610. // zero = "000" + strconv.Itoa(fpNumber)
  3611. // } else if fpNumber >= 100000{
  3612. // zero = "00" + strconv.Itoa(fpNumber)
  3613. // } else if fpNumber >= 1000000{
  3614. // zero = "0" + strconv.Itoa(fpNumber)
  3615. // }else {
  3616. // zero = strconv.Itoa(fpNumber)
  3617. // }
  3618. // fapiao_number = zero
  3619. // }
  3620. // }
  3621. //}
  3622. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3623. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3624. var patientPrescription models.HisPrescriptionInfo
  3625. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3626. if patientPrescription.ID == 0 {
  3627. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3628. }
  3629. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3630. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3631. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3632. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3633. var config []*models.HisXtDiagnoseConfig
  3634. for _, item := range diagnosis_ids {
  3635. id, _ := strconv.ParseInt(item, 10, 64)
  3636. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3637. config = append(config, &diagnosisConfig)
  3638. }
  3639. sickConfig, _ := service.FindSickById(sick_type)
  3640. //if tempOrder.ID == 0 {
  3641. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3642. //}
  3643. if tempOrder.ID == 0 {
  3644. var result string
  3645. var requestLog string
  3646. var res2 ResultSix
  3647. var ressix10265 ResultSix10265
  3648. if miConfig.MdtrtareaAdmvs == "421300" {
  3649. data := make(map[string]interface{})
  3650. client := &http.Client{}
  3651. data["psn_no"] = his.PsnNo
  3652. data["mdtrt_id"] = his.Number
  3653. data["doctor"] = roles.UserName
  3654. data["department"] = department.Name
  3655. data["org_name"] = miConfig.OrgName
  3656. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3657. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3658. data["fixmedins_code"] = miConfig.Code
  3659. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3660. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3661. data["secret_key"] = miConfig.SecretKey
  3662. data["sick_code"] = sickConfig.CountryCode
  3663. data["sick_name"] = sickConfig.ClassName
  3664. data["dept"] = strconv.FormatInt(department.ID, 10)
  3665. data["config"] = config
  3666. data["begin_time"] = begin_time
  3667. bytesData, _ := json.Marshal(data)
  3668. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3669. resp, _ := client.Do(req)
  3670. defer resp.Body.Close()
  3671. body, ioErr := ioutil.ReadAll(resp.Body)
  3672. if ioErr != nil {
  3673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3675. return
  3676. }
  3677. var respJSON map[string]interface{}
  3678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. return
  3682. }
  3683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3684. userJSONBytes, _ := json.Marshal(respJSON)
  3685. fmt.Println("log")
  3686. fmt.Println(string(userJSONBytes))
  3687. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3688. utils.ErrorLog("解析失败:%v", err)
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3690. return
  3691. }
  3692. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3693. //江苏地区国家医保医疗类别
  3694. //职工透析:医疗类别选特殊情况门诊9933
  3695. //居民血透门慢: 医疗类别选门诊慢病1402
  3696. //var med_type string
  3697. //if his.Insutype == "310" {
  3698. // if reg_type == 14 {
  3699. // med_type = "9933"
  3700. // } else if reg_type == 11 {
  3701. // med_type = "11"
  3702. //
  3703. // }
  3704. //} else if his.Insutype == "390" {
  3705. // if reg_type == 14 {
  3706. // med_type = "1402"
  3707. // } else if reg_type == 11 {
  3708. // med_type = "11"
  3709. // }
  3710. //}
  3711. data := make(map[string]interface{})
  3712. client := &http.Client{}
  3713. data["psn_no"] = his.PsnNo
  3714. data["mdtrt_id"] = his.Number
  3715. data["doctor"] = roles.UserName
  3716. data["department"] = department.Name
  3717. data["org_name"] = miConfig.OrgName
  3718. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3719. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3720. data["fixmedins_code"] = miConfig.Code
  3721. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3722. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3723. data["secret_key"] = miConfig.SecretKey
  3724. data["sick_code"] = sickConfig.CountryCode
  3725. data["sick_name"] = sickConfig.ClassName
  3726. data["url"] = miConfig.Url
  3727. data["ak"] = miConfig.AccessKey
  3728. data["begin_time"] = begin_time
  3729. data["cainfo"] = miConfig.Cainfo
  3730. data["dept"] = strconv.FormatInt(department.ID, 10)
  3731. data["config"] = config
  3732. bytesData, _ := json.Marshal(data)
  3733. var req *http.Request
  3734. if miConfig.MdtrtareaAdmvs == "320921" {
  3735. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3736. //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 +
  3737. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3738. } else {
  3739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3740. }
  3741. resp, _ := client.Do(req)
  3742. defer resp.Body.Close()
  3743. body, ioErr := ioutil.ReadAll(resp.Body)
  3744. if ioErr != nil {
  3745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. return
  3748. }
  3749. var respJSON map[string]interface{}
  3750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. return
  3754. }
  3755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3756. userJSONBytes, _ := json.Marshal(respJSON)
  3757. fmt.Println("log")
  3758. fmt.Println(string(userJSONBytes))
  3759. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3760. utils.ErrorLog("解析失败:%v", err)
  3761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. return
  3763. }
  3764. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3765. res2.Output = ressix10265.Output
  3766. res2.ErrMsg = ressix10265.ErrMsg
  3767. res2.Cainfo = ressix10265.Cainfo
  3768. res2.WarnMsg = ressix10265.WarnMsg
  3769. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3770. res2.Infcode = infocode
  3771. } else {
  3772. if miConfig.MdtrtareaAdmvs == "440781" { //
  3773. 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)
  3774. } else {
  3775. if miConfig.Code == "H15049901371" {
  3776. //赤峰地区国家医保医疗类别
  3777. //职工透析:医疗类别选特殊情况门诊990502
  3778. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3779. var med_type string
  3780. if his.Insutype == "390" {
  3781. if reg_type == 14 {
  3782. med_type = "9933"
  3783. } else if reg_type == 11 {
  3784. med_type = "11"
  3785. }
  3786. } else if his.Insutype == "310" {
  3787. if reg_type == 14 {
  3788. med_type = "990502"
  3789. } else if reg_type == 11 {
  3790. med_type = "11"
  3791. }
  3792. }
  3793. 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)
  3794. } else {
  3795. 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)
  3796. }
  3797. }
  3798. saveLog(result, requestLog, "2203", "上传就诊信息")
  3799. var respJSON2 map[string]interface{}
  3800. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. userJSONBytes2, _ := json.Marshal(respJSON2)
  3806. if miConfig.Code == "H15049901371" {
  3807. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3808. utils.ErrorLog("解析失败:%v", err)
  3809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. return
  3811. }
  3812. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3813. res2.Output = ressix10265.Output
  3814. res2.ErrMsg = ressix10265.ErrMsg
  3815. res2.Cainfo = ressix10265.Cainfo
  3816. res2.WarnMsg = ressix10265.WarnMsg
  3817. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3818. res2.Infcode = infocode
  3819. } else {
  3820. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3821. utils.ErrorLog("解析失败:%v", err)
  3822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3823. return
  3824. }
  3825. }
  3826. }
  3827. if res2.Infcode != 0 {
  3828. adminUser := c.GetAdminUserInfo()
  3829. errlog := &models.HisOrderError{
  3830. UserOrgId: adminUser.CurrentOrgId,
  3831. Ctime: time.Now().Unix(),
  3832. Mtime: time.Now().Unix(),
  3833. ErrMsg: res2.ErrMsg,
  3834. Status: 1,
  3835. PatientId: id,
  3836. RecordTime: recordDateTime,
  3837. Stage: 3,
  3838. }
  3839. service.CreateErrMsgLog(errlog)
  3840. c.ServeSuccessJSON(map[string]interface{}{
  3841. "failed_code": -10,
  3842. "msg": res2.ErrMsg,
  3843. })
  3844. return
  3845. } else {
  3846. his.Diagnosis = diagnosis_id
  3847. his.SickType = sickConfig.ID
  3848. var p_type int64
  3849. if reg_type == 1111 || reg_type == 1112 {
  3850. p_type = 11
  3851. }
  3852. his.PType = fmt.Sprintf("%d", p_type)
  3853. service.UpdateHisPatientThree(&his)
  3854. data := make(map[string]interface{})
  3855. if settle_accounts_type == 1 { //日结
  3856. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3857. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3858. } else {
  3859. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3860. }
  3861. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3862. data["pre"] = prescriptions
  3863. } else { //月结
  3864. start_time_str := c.GetString("start_time")
  3865. end_time_str := c.GetString("end_time")
  3866. timeLayout := "2006-01-02"
  3867. loc, _ := time.LoadLocation("Local")
  3868. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3869. if err != nil {
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3871. return
  3872. }
  3873. recordStartTime := theStartTime.Unix()
  3874. start_time = recordStartTime
  3875. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3876. if err != nil {
  3877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3878. return
  3879. }
  3880. recordEndTime := theEndTime.Unix()
  3881. end_time = recordEndTime
  3882. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3883. data["pre"] = prescriptions
  3884. }
  3885. timestamp := time.Now().Unix()
  3886. tempTime := time.Unix(timestamp, 0)
  3887. timeFormat := tempTime.Format("20060102150405")
  3888. chrgBchno := rand.Intn(100000) + 10000
  3889. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3890. strconv.FormatInt(his.PatientId, 10)
  3891. client := &http.Client{}
  3892. data["psn_no"] = his.PsnNo
  3893. data["mdtrt_id"] = his.Number
  3894. data["chrg_bchno"] = chrg_bchno
  3895. data["org_name"] = miConfig.OrgName
  3896. data["doctor"] = roles.UserName
  3897. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3898. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3899. data["fixmedins_code"] = miConfig.Code
  3900. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3901. // data["dept_code"] = "15"
  3902. //} else {
  3903. data["dept_code"] = department.Number
  3904. //}
  3905. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3906. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3907. data["secret_key"] = miConfig.SecretKey
  3908. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3909. data["url"] = miConfig.Url
  3910. data["ak"] = miConfig.AccessKey
  3911. data["new_doctor_name"] = patientPrescription.Doctor
  3912. data["diag_code"] = sickConfig.CountryCode
  3913. data["cainfo"] = miConfig.Cainfo
  3914. var ids []int64
  3915. for _, item := range prescriptions {
  3916. ids = append(ids, item.ID)
  3917. }
  3918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3919. if config.IsOpen == 1 { //对接了医保,走医保流程
  3920. var res ResultFour
  3921. var resFour10265 ResultFour10265
  3922. if miConfig.MdtrtareaAdmvs == "421300" {
  3923. bytesData, _ := json.Marshal(data)
  3924. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3925. resp, _ := client.Do(req)
  3926. defer resp.Body.Close()
  3927. body, ioErr := ioutil.ReadAll(resp.Body)
  3928. if ioErr != nil {
  3929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3931. return
  3932. }
  3933. var respJSON map[string]interface{}
  3934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3937. return
  3938. }
  3939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3940. userJSONBytes, _ := json.Marshal(respJSON)
  3941. fmt.Println("log")
  3942. fmt.Println(string(userJSONBytes))
  3943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3944. utils.ErrorLog("解析失败:%v", err)
  3945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3946. return
  3947. }
  3948. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3949. bytesData, _ := json.Marshal(data)
  3950. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3951. resp, _ := client.Do(req)
  3952. defer resp.Body.Close()
  3953. body, ioErr := ioutil.ReadAll(resp.Body)
  3954. if ioErr != nil {
  3955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. return
  3958. }
  3959. var respJSON map[string]interface{}
  3960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. return
  3964. }
  3965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3966. userJSONBytes, _ := json.Marshal(respJSON)
  3967. fmt.Println("log")
  3968. fmt.Println(string(userJSONBytes))
  3969. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3970. utils.ErrorLog("解析失败:%v", err)
  3971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3972. return
  3973. }
  3974. res.InfRefmsgid = resFour10265.InfRefmsgid
  3975. res.Output = resFour10265.Output
  3976. res.ErrMsg = resFour10265.ErrMsg
  3977. res.Cainfo = resFour10265.Cainfo
  3978. res.WarnMsg = resFour10265.WarnMsg
  3979. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3980. res.Infcode = infocode
  3981. } else {
  3982. if miConfig.Code == "H15049901371" {
  3983. 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)
  3984. var dat map[string]interface{}
  3985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3986. fmt.Println(dat)
  3987. } else {
  3988. fmt.Println(err)
  3989. }
  3990. saveLog(result, request_log, "2204", "上传费用明细")
  3991. userJSONBytes, _ := json.Marshal(dat)
  3992. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3993. utils.ErrorLog("解析失败:%v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. res.InfRefmsgid = resFour10265.InfRefmsgid
  3998. res.Output = resFour10265.Output
  3999. res.ErrMsg = resFour10265.ErrMsg
  4000. res.Cainfo = resFour10265.Cainfo
  4001. res.WarnMsg = resFour10265.WarnMsg
  4002. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4003. res.Infcode = infocode
  4004. } else {
  4005. 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)
  4006. var dat map[string]interface{}
  4007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4008. fmt.Println(dat)
  4009. } else {
  4010. fmt.Println(err)
  4011. }
  4012. saveLog(result, request_log, "2204", "上传费用明细")
  4013. userJSONBytes, _ := json.Marshal(dat)
  4014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4015. utils.ErrorLog("解析失败:%v", err)
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. return
  4018. }
  4019. }
  4020. }
  4021. if res.Infcode == 0 {
  4022. order := &models.HisOrder{
  4023. UserOrgId: adminUser.CurrentOrgId,
  4024. HisPatientId: his.ID,
  4025. PatientId: his.PatientId,
  4026. SettleAccountsDate: recordDateTime,
  4027. MdtrtId: his.Number,
  4028. PsnNo: his.PsnNo,
  4029. MedType: strconv.FormatInt(reg_type, 10),
  4030. Ctime: time.Now().Unix(),
  4031. Mtime: time.Now().Unix(),
  4032. Status: 1,
  4033. Number: chrg_bchno,
  4034. Infcode: res.Infcode,
  4035. WarnMsg: res.WarnMsg,
  4036. Cainfo: res.Cainfo,
  4037. ErrMsg: res.ErrMsg,
  4038. RespondTime: res.RefmsgTime,
  4039. InfRefmsgid: res.InfRefmsgid,
  4040. OrderStatus: 1,
  4041. PayWay: pay_way,
  4042. PayPrice: pay_price,
  4043. PayCardNo: pay_card_no,
  4044. DiscountPrice: discount_price,
  4045. PreferentialPrice: preferential_price,
  4046. RealityPrice: reality_price,
  4047. FoundPrice: found_price,
  4048. MedicalInsurancePrice: medical_insurance_price,
  4049. PrivatePrice: private_price,
  4050. IsMedicineInsurance: 1,
  4051. SettleType: settle_accounts_type,
  4052. SettleStartTime: start_time,
  4053. SettleEndTime: end_time,
  4054. Creator: roles.AdminUserId,
  4055. Modify: roles.AdminUserId,
  4056. FaPiaoNumber: fapiao_number,
  4057. FaPiaoCode: fapiao_code,
  4058. PType: 2,
  4059. Diagnosis: diagnosis_id,
  4060. }
  4061. err = service.CreateOrder(order)
  4062. if err != nil {
  4063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4064. return
  4065. }
  4066. for _, item := range res.Output.Result {
  4067. temp := strings.Split(item.FeedetlSn, "-")
  4068. var advice_id int64 = 0
  4069. var project_id int64 = 0
  4070. var types int64 = 0
  4071. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4072. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4073. if temp[1] == "1" {
  4074. advice_id = id
  4075. project_id = 0
  4076. } else if temp[1] == "2" {
  4077. advice_id = 0
  4078. project_id = id
  4079. }
  4080. info := &models.HisOrderInfo{
  4081. OrderNumber: order.Number,
  4082. FeedetlSn: item.FeedetlSn,
  4083. UploadDate: time.Now().Unix(),
  4084. AdviceId: advice_id,
  4085. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4086. Cnt: item.Cnt,
  4087. Pric: float64(item.Pric),
  4088. PatientId: his.PatientId,
  4089. PricUplmtAmt: item.PricUplmtAmt,
  4090. SelfpayProp: item.SelfpayProp,
  4091. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4092. OverlmtAmt: item.OverlmtAmt,
  4093. PreselfpayAmt: item.PreselfpayAmt,
  4094. BasMednFlag: item.BasMednFlag,
  4095. MedChrgitmType: item.MedChrgitmType,
  4096. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4097. Status: 1,
  4098. Memo: item.Memo,
  4099. Mtime: time.Now().Unix(),
  4100. InscpScpAmt: item.InscpScpAmt,
  4101. DrtReimFlag: item.DrtReimFlag,
  4102. Ctime: time.Now().Unix(),
  4103. ListSpItemFlag: item.ListSpItemFlag,
  4104. ChldMedcFlag: item.ChldMedcFlag,
  4105. LmtUsedFlag: item.LmtUsedFlag,
  4106. ChrgitmLv: item.ChrgitmLv,
  4107. UserOrgId: adminUser.CurrentOrgId,
  4108. HisPatientId: his.ID,
  4109. OrderId: order.ID,
  4110. ProjectId: project_id,
  4111. Type: types,
  4112. }
  4113. service.CreateOrderInfo(info)
  4114. }
  4115. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4116. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4117. var total float64
  4118. for _, item := range prescriptions {
  4119. if item.Type == 1 { //药品
  4120. for _, subItem := range item.HisDoctorAdviceInfo {
  4121. total = total + (subItem.Price * subItem.PrescribingNumber)
  4122. }
  4123. }
  4124. if item.Type == 2 { //项目
  4125. for _, subItem := range item.HisPrescriptionProject {
  4126. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4127. total = total + (subItem.Price * cnt)
  4128. }
  4129. }
  4130. }
  4131. for _, item := range prescriptions {
  4132. for _, subItem := range item.HisAdditionalCharge {
  4133. total = total + (subItem.Price * float64(subItem.Count))
  4134. }
  4135. }
  4136. var allTotal string
  4137. if adminUser.CurrentOrgId == 9919 {
  4138. allTotal = fmt.Sprintf("%.4f", total)
  4139. } else {
  4140. allTotal = fmt.Sprintf("%.4f", total)
  4141. }
  4142. if res.Infcode == 0 {
  4143. var rf []*ResultFive
  4144. json.Unmarshal([]byte(his.Iinfo), &rf)
  4145. chrg_bchno := chrg_bchno
  4146. cert_no := his.Certno
  4147. var insutypes []string
  4148. var insutype string
  4149. var is390 int = 0
  4150. var is310 int = 0
  4151. for _, item := range rf {
  4152. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4153. insutypes = append(insutypes, item.Insutype)
  4154. }
  4155. }
  4156. if len(insutypes) == 1 {
  4157. insutype = insutypes[0]
  4158. } else {
  4159. for _, i := range insutypes {
  4160. if i == "390" {
  4161. is390 = 1
  4162. }
  4163. if i == "310" {
  4164. is310 = 1
  4165. }
  4166. }
  4167. }
  4168. if is390 == 1 {
  4169. insutype = "390"
  4170. }
  4171. if is310 == 1 {
  4172. insutype = "310"
  4173. }
  4174. if len(insutypes) == 0 {
  4175. insutype = "310"
  4176. }
  4177. if len(insutypes) == 2 {
  4178. insutype = strconv.FormatInt(his.SocialType, 10)
  4179. }
  4180. insutype = strconv.FormatInt(his.SocialType, 10)
  4181. //insutype = "390"
  4182. if his.IdCardType == 1 {
  4183. // cert_no = his.MedicalInsuranceNumber
  4184. cert_no = his.Certno
  4185. } else {
  4186. cert_no = his.Certno
  4187. }
  4188. var res ResultSeven
  4189. var resSeven10265 ResultSeven10265
  4190. var src_resquest string
  4191. var result2 string
  4192. var acct_used_flag string
  4193. fmt.Println("pay_way")
  4194. fmt.Println(pay_way)
  4195. fmt.Println("pay_way")
  4196. if pay_way == 4 {
  4197. acct_used_flag = "1"
  4198. } else {
  4199. acct_used_flag = "0"
  4200. }
  4201. if miConfig.MdtrtareaAdmvs == "421300" {
  4202. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4203. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4204. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4206. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4207. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4208. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4209. resp, requestErr := http.Get(api)
  4210. if requestErr != nil {
  4211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4212. return
  4213. }
  4214. body, ioErr := ioutil.ReadAll(resp.Body)
  4215. if ioErr != nil {
  4216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. return
  4219. }
  4220. var respJSON map[string]interface{}
  4221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4227. result, _ := json.Marshal(respJSON)
  4228. if miConfig.Code == "H15049901371" {
  4229. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4230. utils.ErrorLog("解析失败:%v", err)
  4231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4232. return
  4233. }
  4234. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4235. res.Output = resSeven10265.Output
  4236. res.ErrMsg = resSeven10265.ErrMsg
  4237. res.Cainfo = resSeven10265.Cainfo
  4238. res.WarnMsg = resSeven10265.WarnMsg
  4239. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4240. res.Infcode = infocode
  4241. } else {
  4242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4243. utils.ErrorLog("解析失败:%v", err)
  4244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4245. return
  4246. }
  4247. }
  4248. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4249. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4250. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4251. //psn_info, _ := service.GetPsnByPatientId(id)
  4252. bas := strings.Split(psn_info.CardInfo, "|")
  4253. if his.IdCardType == 1 {
  4254. cert_no = bas[2]
  4255. } else {
  4256. cert_no = bas[1]
  4257. }
  4258. //江苏地区国家医保医疗类别
  4259. //职工透析:医疗类别选特殊情况门诊9933
  4260. //居民血透门慢: 医疗类别选门诊慢病1402
  4261. //var med_type string
  4262. //if his.Insutype == "310" {
  4263. // if reg_type == 14 {
  4264. // med_type = "9933"
  4265. // } else if reg_type == 11 {
  4266. // med_type = "11"
  4267. //
  4268. // }
  4269. //} else if his.Insutype == "390" {
  4270. // if reg_type == 14 {
  4271. // med_type = "1402"
  4272. // } else if reg_type == 11 {
  4273. // med_type = "11"
  4274. // }
  4275. //}
  4276. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4277. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4278. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4279. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4280. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4281. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4282. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4283. "&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
  4284. resp, requestErr := http.Get(api)
  4285. if requestErr != nil {
  4286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4287. return
  4288. }
  4289. body, ioErr := ioutil.ReadAll(resp.Body)
  4290. if ioErr != nil {
  4291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4293. return
  4294. }
  4295. var respJSON map[string]interface{}
  4296. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4299. return
  4300. }
  4301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4302. result, _ := json.Marshal(respJSON)
  4303. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4304. utils.ErrorLog("解析失败:%v", err)
  4305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4306. return
  4307. }
  4308. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4309. res.Output = resSeven10265.Output
  4310. res.ErrMsg = resSeven10265.ErrMsg
  4311. res.Cainfo = resSeven10265.Cainfo
  4312. res.WarnMsg = resSeven10265.WarnMsg
  4313. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4314. res.Infcode = infocode
  4315. } else {
  4316. if miConfig.Code == "H15049901371" {
  4317. //赤峰地区国家医保医疗类别
  4318. //职工透析:医疗类别选特殊情况门诊990502
  4319. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4320. var med_type string
  4321. if his.Insutype == "390" {
  4322. if reg_type == 14 {
  4323. med_type = "9933"
  4324. } else if reg_type == 11 {
  4325. med_type = "11"
  4326. }
  4327. } else if his.Insutype == "310" {
  4328. if reg_type == 14 {
  4329. med_type = "990502"
  4330. } else if reg_type == 11 {
  4331. med_type = "11"
  4332. }
  4333. }
  4334. 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)
  4335. } else {
  4336. 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)
  4337. }
  4338. //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)
  4339. var dat map[string]interface{}
  4340. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4341. fmt.Println(dat)
  4342. } else {
  4343. fmt.Println(err)
  4344. }
  4345. saveLog(result2, src_resquest, "2207", "结算")
  4346. userJSONBytes, _ := json.Marshal(dat)
  4347. if miConfig.Code == "H15049901371" {
  4348. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4349. utils.ErrorLog("解析失败:%v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4354. res.Output = resSeven10265.Output
  4355. res.ErrMsg = resSeven10265.ErrMsg
  4356. res.Cainfo = resSeven10265.Cainfo
  4357. res.WarnMsg = resSeven10265.WarnMsg
  4358. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4359. res.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. }
  4368. if res.Infcode != 0 {
  4369. errlog := &models.HisOrderError{
  4370. UserOrgId: adminUser.CurrentOrgId,
  4371. Ctime: time.Now().Unix(),
  4372. Mtime: time.Now().Unix(),
  4373. Number: chrg_bchno,
  4374. ErrMsg: res.ErrMsg,
  4375. Status: 1,
  4376. PatientId: id,
  4377. RecordTime: recordDateTime,
  4378. Stage: 6,
  4379. }
  4380. service.CreateErrMsgLog(errlog)
  4381. c.ServeSuccessJSON(map[string]interface{}{
  4382. "failed_code": -10,
  4383. "msg": res.ErrMsg,
  4384. })
  4385. return
  4386. } else {
  4387. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4388. order.OrderStatus = 2
  4389. order.Status = 1
  4390. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4391. order.SetlId = res.Output.Setlinfo.SetlID
  4392. order.PsnNo = res.Output.Setlinfo.PsnNo
  4393. order.PsnName = res.Output.Setlinfo.PsnName
  4394. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4395. order.Certno = res.Output.Setlinfo.Certno
  4396. order.Gend = res.Output.Setlinfo.Gend
  4397. order.Naty = res.Output.Setlinfo.Naty
  4398. order.Age = res.Output.Setlinfo.Age
  4399. order.Insutype = res.Output.Setlinfo.Insutype
  4400. order.PsnType = res.Output.Setlinfo.PsnType
  4401. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4402. order.SetlTime = res.Output.Setlinfo.SetlTime
  4403. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4404. if res.Output.Setlinfo.MedType == "140101" {
  4405. order.MedType = "14"
  4406. } else {
  4407. order.MedType = res.Output.Setlinfo.MedType
  4408. }
  4409. if reg_type == 1112 {
  4410. order.MedType = "1112"
  4411. }
  4412. if reg_type == 1111 {
  4413. order.MedType = "1111"
  4414. }
  4415. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4416. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4417. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4418. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4419. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4420. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4421. order.HifpPay = res.Output.Setlinfo.HifpPay
  4422. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4423. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4424. order.HifesPay = res.Output.Setlinfo.HifesPay
  4425. order.HifobPay = res.Output.Setlinfo.HifobPay
  4426. order.MafPay = res.Output.Setlinfo.MafPay
  4427. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4428. order.OthPay = res.Output.Setlinfo.OthPay
  4429. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4430. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4431. order.AcctPay = res.Output.Setlinfo.AcctPay
  4432. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4433. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4434. order.Balc = res.Output.Setlinfo.Balc
  4435. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4436. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4437. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4438. order.ClrType = res.Output.Setlinfo.ClrType
  4439. order.ClrWay = res.Output.Setlinfo.ClrWay
  4440. order.Creator = order.Creator
  4441. order.Modify = roles.AdminUserId
  4442. order.RequestLog = src_resquest
  4443. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4444. detailStr := string(setlDetail)
  4445. order.SetlDetail = detailStr
  4446. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4447. err = service.UpDateOrder(order)
  4448. if err == nil {
  4449. c.ServeSuccessJSON(map[string]interface{}{
  4450. "msg": "结算成功",
  4451. })
  4452. } else {
  4453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4454. return
  4455. }
  4456. }
  4457. } else {
  4458. adminUser := c.GetAdminUserInfo()
  4459. errlog := &models.HisOrderError{
  4460. UserOrgId: adminUser.CurrentOrgId,
  4461. Ctime: time.Now().Unix(),
  4462. Mtime: time.Now().Unix(),
  4463. ErrMsg: res.ErrMsg,
  4464. Status: 1,
  4465. PatientId: id,
  4466. RecordTime: recordDateTime,
  4467. Stage: 4,
  4468. }
  4469. service.CreateErrMsgLog(errlog)
  4470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4471. return
  4472. }
  4473. } else {
  4474. adminUser := c.GetAdminUserInfo()
  4475. errlog := &models.HisOrderError{
  4476. UserOrgId: adminUser.CurrentOrgId,
  4477. Ctime: time.Now().Unix(),
  4478. Mtime: time.Now().Unix(),
  4479. ErrMsg: res.ErrMsg,
  4480. Status: 1,
  4481. PatientId: id,
  4482. RecordTime: recordDateTime,
  4483. Stage: 4,
  4484. }
  4485. service.CreateErrMsgLog(errlog)
  4486. c.ServeSuccessJSON(map[string]interface{}{
  4487. "failed_code": -10,
  4488. "msg": res.ErrMsg,
  4489. })
  4490. return
  4491. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4492. //return
  4493. }
  4494. }
  4495. }
  4496. } else if tempOrder.ID > 0 {
  4497. if tempOrder.IsPre == 1 {
  4498. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4499. var rf []*ResultFive
  4500. json.Unmarshal([]byte(his.Iinfo), &rf)
  4501. chrg_bchno := tempOrder.Number
  4502. cert_no := his.Certno
  4503. var insutypes []string
  4504. var insutype string
  4505. var is390 int = 0
  4506. var is310 int = 0
  4507. for _, item := range rf {
  4508. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4509. insutypes = append(insutypes, item.Insutype)
  4510. }
  4511. }
  4512. if len(insutypes) == 1 {
  4513. insutype = insutypes[0]
  4514. } else {
  4515. for _, i := range insutypes {
  4516. if i == "390" {
  4517. is390 = 1
  4518. }
  4519. if i == "310" {
  4520. is310 = 1
  4521. }
  4522. }
  4523. }
  4524. if is390 == 1 {
  4525. insutype = "390"
  4526. }
  4527. if is310 == 1 {
  4528. insutype = "310"
  4529. }
  4530. if len(insutypes) == 0 {
  4531. insutype = "310"
  4532. }
  4533. if len(insutypes) == 2 {
  4534. insutype = strconv.FormatInt(his.SocialType, 64)
  4535. }
  4536. //insutype = "390"
  4537. if his.IdCardType == 1 {
  4538. // cert_no = his.MedicalInsuranceNumber
  4539. cert_no = his.Certno
  4540. } else {
  4541. cert_no = his.Certno
  4542. }
  4543. var res ResultSeven
  4544. var resSeven10265 ResultSeven10265
  4545. var src_resquest string
  4546. var result2 string
  4547. var acct_used_flag string
  4548. fmt.Println("pay_way")
  4549. fmt.Println(pay_way)
  4550. fmt.Println("pay_way")
  4551. if pay_way == 4 {
  4552. acct_used_flag = "1"
  4553. } else {
  4554. acct_used_flag = "0"
  4555. }
  4556. if miConfig.MdtrtareaAdmvs == "421300" {
  4557. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4558. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4559. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4560. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4561. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4562. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4563. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4564. resp, requestErr := http.Get(api)
  4565. if requestErr != nil {
  4566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4567. return
  4568. }
  4569. body, ioErr := ioutil.ReadAll(resp.Body)
  4570. if ioErr != nil {
  4571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. return
  4574. }
  4575. var respJSON map[string]interface{}
  4576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4579. return
  4580. }
  4581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4582. result, _ := json.Marshal(respJSON)
  4583. fmt.Println("log")
  4584. fmt.Println(string(result))
  4585. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4586. utils.ErrorLog("解析失败:%v", err)
  4587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. return
  4589. }
  4590. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4591. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4592. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4593. //psn_info, _ := service.GetPsnByPatientId(id)
  4594. bas := strings.Split(psn_info.CardInfo, "|")
  4595. if his.IdCardType == 1 {
  4596. cert_no = bas[2]
  4597. } else {
  4598. cert_no = bas[1]
  4599. }
  4600. //江苏地区国家医保医疗类别
  4601. //职工透析:医疗类别选特殊情况门诊9933
  4602. //居民血透门慢: 医疗类别选门诊慢病1402
  4603. //var med_type string
  4604. //if his.Insutype == "310" {
  4605. // if reg_type == 14 {
  4606. // med_type = "9933"
  4607. // } else if reg_type == 11 {
  4608. // med_type = "11"
  4609. //
  4610. // }
  4611. //} else if his.Insutype == "390" {
  4612. // if reg_type == 14 {
  4613. // med_type = "1402"
  4614. // } else if reg_type == 11 {
  4615. // med_type = "11"
  4616. // }
  4617. //}
  4618. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4619. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4620. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4621. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4622. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4623. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4624. "&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
  4625. resp, requestErr := http.Get(api)
  4626. if requestErr != nil {
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4628. return
  4629. }
  4630. body, ioErr := ioutil.ReadAll(resp.Body)
  4631. if ioErr != nil {
  4632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4634. return
  4635. }
  4636. var respJSON map[string]interface{}
  4637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4640. return
  4641. }
  4642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4643. result, _ := json.Marshal(respJSON)
  4644. fmt.Println("log")
  4645. fmt.Println(string(result))
  4646. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4647. utils.ErrorLog("解析失败:%v", err)
  4648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4649. return
  4650. }
  4651. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4652. res.Output = resSeven10265.Output
  4653. res.ErrMsg = resSeven10265.ErrMsg
  4654. res.Cainfo = resSeven10265.Cainfo
  4655. res.WarnMsg = resSeven10265.WarnMsg
  4656. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4657. res.Infcode = infocode
  4658. } else {
  4659. var src_resquest string
  4660. if miConfig.Code == "H15049901371" {
  4661. //赤峰地区国家医保医疗类别
  4662. //职工透析:医疗类别选特殊情况门诊990502
  4663. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4664. var med_type string
  4665. if his.Insutype == "390" {
  4666. if reg_type == 14 {
  4667. med_type = "9933"
  4668. } else if reg_type == 11 {
  4669. med_type = "11"
  4670. }
  4671. } else if his.Insutype == "310" {
  4672. if reg_type == 14 {
  4673. med_type = "990502"
  4674. } else if reg_type == 11 {
  4675. med_type = "11"
  4676. }
  4677. }
  4678. 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)
  4679. } else {
  4680. 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)
  4681. }
  4682. var dat map[string]interface{}
  4683. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4684. fmt.Println(dat)
  4685. } else {
  4686. fmt.Println(err)
  4687. }
  4688. saveLog(result2, src_resquest, "2207", "结算")
  4689. userJSONBytes, _ := json.Marshal(dat)
  4690. if miConfig.Code == "H15049901371" {
  4691. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4692. utils.ErrorLog("解析失败:%v", err)
  4693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4694. return
  4695. }
  4696. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4697. res.Output = resSeven10265.Output
  4698. res.ErrMsg = resSeven10265.ErrMsg
  4699. res.Cainfo = resSeven10265.Cainfo
  4700. res.WarnMsg = resSeven10265.WarnMsg
  4701. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4702. res.Infcode = infocode
  4703. } else {
  4704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4705. utils.ErrorLog("解析失败:%v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. }
  4710. }
  4711. if res.Infcode != 0 {
  4712. errlog := &models.HisOrderError{
  4713. UserOrgId: adminUser.CurrentOrgId,
  4714. Ctime: time.Now().Unix(),
  4715. Mtime: time.Now().Unix(),
  4716. Number: chrg_bchno,
  4717. ErrMsg: res.ErrMsg,
  4718. Status: 1,
  4719. PatientId: id,
  4720. RecordTime: recordDateTime,
  4721. Stage: 6,
  4722. }
  4723. service.CreateErrMsgLog(errlog)
  4724. c.ServeSuccessJSON(map[string]interface{}{
  4725. "failed_code": -10,
  4726. "msg": res.ErrMsg,
  4727. })
  4728. return
  4729. } else {
  4730. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4731. order.OrderStatus = 2
  4732. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4733. order.SetlId = res.Output.Setlinfo.SetlID
  4734. order.PsnNo = res.Output.Setlinfo.PsnNo
  4735. order.PsnName = res.Output.Setlinfo.PsnName
  4736. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4737. order.Certno = res.Output.Setlinfo.Certno
  4738. order.Gend = res.Output.Setlinfo.Gend
  4739. order.Naty = res.Output.Setlinfo.Naty
  4740. order.Age = res.Output.Setlinfo.Age
  4741. order.Insutype = res.Output.Setlinfo.Insutype
  4742. order.PsnType = res.Output.Setlinfo.PsnType
  4743. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4744. order.SetlTime = res.Output.Setlinfo.SetlTime
  4745. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4746. //order.MedType = res.Output.Setlinfo.MedType
  4747. if reg_type == 1112 {
  4748. order.MedType = "1112"
  4749. }
  4750. if reg_type == 1111 {
  4751. order.MedType = "1111"
  4752. }
  4753. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4754. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4755. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4756. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4757. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4758. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4759. order.HifpPay = res.Output.Setlinfo.HifpPay
  4760. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4761. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4762. order.HifesPay = res.Output.Setlinfo.HifesPay
  4763. order.HifobPay = res.Output.Setlinfo.HifobPay
  4764. order.MafPay = res.Output.Setlinfo.MafPay
  4765. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4766. order.OthPay = res.Output.Setlinfo.OthPay
  4767. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4768. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4769. order.AcctPay = res.Output.Setlinfo.AcctPay
  4770. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4771. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4772. order.Balc = res.Output.Setlinfo.Balc
  4773. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4774. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4775. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4776. order.ClrWay = res.Output.Setlinfo.ClrWay
  4777. order.Creator = order.Creator
  4778. order.Modify = roles.AdminUserId
  4779. order.RequestLog = src_resquest
  4780. order.Diagnosis = diagnosis_id
  4781. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4782. detailStr := string(setlDetail)
  4783. order.SetlDetail = detailStr
  4784. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4785. err = service.UpDateOrder(order)
  4786. if err == nil {
  4787. c.ServeSuccessJSON(map[string]interface{}{
  4788. "msg": "结算成功",
  4789. })
  4790. } else {
  4791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4792. return
  4793. }
  4794. }
  4795. }
  4796. }
  4797. }
  4798. //func (c *HisApiController) GetPreUploadInfo() {
  4799. // id, _ := c.GetInt64("id")
  4800. // record_time := c.GetString("record_time")
  4801. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4802. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4803. //
  4804. // timeLayout := "2006-01-02"
  4805. // loc, _ := time.LoadLocation("Local")
  4806. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4807. // if err != nil {
  4808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4809. // return
  4810. // }
  4811. // recordDateTime := theTime.Unix()
  4812. // adminUser := c.GetAdminUserInfo()
  4813. //
  4814. // var prescriptions []*models.HisPrescription
  4815. //
  4816. // var start_time int64
  4817. // var end_time int64
  4818. //
  4819. // data := make(map[string]interface{})
  4820. // if settle_accounts_type == 1 { //日结
  4821. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4822. // data["pre"] = prescriptions
  4823. //
  4824. // } else { //月结
  4825. // start_time_str := c.GetString("start_time")
  4826. // end_time_str := c.GetString("end_time")
  4827. // timeLayout := "2006-01-02"
  4828. // loc, _ := time.LoadLocation("Local")
  4829. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4830. // if err != nil {
  4831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4832. // return
  4833. // }
  4834. // recordStartTime := theStartTime.Unix()
  4835. // start_time = recordStartTime
  4836. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4837. // if err != nil {
  4838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4839. // return
  4840. // }
  4841. // recordEndTime := theEndTime.Unix()
  4842. // end_time = recordEndTime
  4843. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4844. // data["pre"] = prescriptions
  4845. //
  4846. // }
  4847. //
  4848. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4849. //
  4850. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4851. // timestamp := time.Now().Unix()
  4852. // tempTime := time.Unix(timestamp, 0)
  4853. // timeFormat := tempTime.Format("20060102150405")
  4854. // chrgBchno := rand.Intn(100000) + 10000
  4855. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4856. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4857. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4858. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4859. // strconv.FormatInt(his.PatientId, 10)
  4860. // client := &http.Client{}
  4861. // data["psn_no"] = his.PsnNo
  4862. // data["mdtrt_id"] = his.Number
  4863. // data["chrg_bchno"] = chrg_bchno
  4864. // data["org_name"] = miConfig.OrgName
  4865. // data["doctor"] = roles.UserName
  4866. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4867. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4868. // data["fixmedins_code"] = miConfig.Code
  4869. // data["dept_code"] = department.Number
  4870. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4871. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4872. // data["secret_key"] = miConfig.SecretKey
  4873. // var ids []int64
  4874. //
  4875. // for _, item := range prescriptions {
  4876. // ids = append(ids, item.ID)
  4877. // }
  4878. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4879. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4880. // bytesData, _ := json.Marshal(data)
  4881. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4882. // resp, _ := client.Do(req)
  4883. // defer resp.Body.Close()
  4884. // body, ioErr := ioutil.ReadAll(resp.Body)
  4885. // if ioErr != nil {
  4886. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. // return
  4889. // }
  4890. // var respJSON map[string]interface{}
  4891. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4892. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4894. // return
  4895. // }
  4896. //
  4897. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4898. // userJSONBytes, _ := json.Marshal(respJSON)
  4899. // var res ResultFour
  4900. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4901. // utils.ErrorLog("解析失败:%v", err)
  4902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4903. // return
  4904. // }
  4905. //
  4906. // if res.Infcode == 0 {
  4907. // order := &models.HisOrder{
  4908. // UserOrgId: adminUser.CurrentOrgId,
  4909. // HisPatientId: his.ID,
  4910. // PatientId: his.PatientId,
  4911. // SettleAccountsDate: recordDateTime,
  4912. // Ctime: time.Now().Unix(),
  4913. // Mtime: time.Now().Unix(),
  4914. // Status: 1,
  4915. // Number: chrg_bchno,
  4916. // Infcode: res.Infcode,
  4917. // WarnMsg: res.WarnMsg,
  4918. // Cainfo: res.Cainfo,
  4919. // ErrMsg: res.ErrMsg,
  4920. // RespondTime: res.RefmsgTime,
  4921. // InfRefmsgid: res.InfRefmsgid,
  4922. // OrderStatus: 1,
  4923. // IsMedicineInsurance: 1,
  4924. // SettleType: settle_accounts_type,
  4925. // SettleStartTime: start_time,
  4926. // SettleEndTime: end_time,
  4927. // Creator: roles.ID,
  4928. // Modify: roles.ID,
  4929. // PType: 2,
  4930. // }
  4931. // err = service.CreateOrder(order)
  4932. // if err != nil {
  4933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4934. // return
  4935. // }
  4936. //
  4937. // for _, item := range res.Output.Result {
  4938. // temp := strings.Split(item.FeedetlSn, "-")
  4939. // var advice_id int64 = 0
  4940. // var project_id int64 = 0
  4941. // var types int64 = 0
  4942. //
  4943. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4944. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4945. //
  4946. // if temp[1] == "1" {
  4947. // advice_id = id
  4948. // project_id = 0
  4949. // } else if temp[1] == "2" {
  4950. // advice_id = 0
  4951. // project_id = id
  4952. // }
  4953. //
  4954. // info := &models.HisOrderInfo{
  4955. // OrderNumber: order.Number,
  4956. // FeedetlSn: item.FeedetlSn,
  4957. // UploadDate: time.Now().Unix(),
  4958. // AdviceId: advice_id,
  4959. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4960. // Cnt: item.Cnt,
  4961. // Pric: float64(item.Pric),
  4962. // PatientId: his.PatientId,
  4963. // PricUplmtAmt: item.PricUplmtAmt,
  4964. // SelfpayProp: item.SelfpayProp,
  4965. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4966. // OverlmtAmt: item.OverlmtAmt,
  4967. // PreselfpayAmt: item.PreselfpayAmt,
  4968. // BasMednFlag: item.BasMednFlag,
  4969. // MedChrgitmType: item.MedChrgitmType,
  4970. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4971. // Status: 1,
  4972. // Memo: item.Memo,
  4973. // Mtime: time.Now().Unix(),
  4974. // InscpScpAmt: item.InscpScpAmt,
  4975. // DrtReimFlag: item.DrtReimFlag,
  4976. // Ctime: time.Now().Unix(),
  4977. // ListSpItemFlag: item.ListSpItemFlag,
  4978. // ChldMedcFlag: item.ChldMedcFlag,
  4979. // LmtUsedFlag: item.LmtUsedFlag,
  4980. // ChrgitmLv: item.ChrgitmLv,
  4981. // UserOrgId: adminUser.CurrentOrgId,
  4982. // HisPatientId: his.ID,
  4983. // OrderId: order.ID,
  4984. // ProjectId: project_id,
  4985. // Type: types,
  4986. // }
  4987. // service.CreateOrderInfo(info)
  4988. //
  4989. // }
  4990. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4991. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4992. //
  4993. // var total float64
  4994. // for _, item := range prescriptions {
  4995. // if item.Type == 1 { //药品
  4996. // for _, subItem := range item.HisDoctorAdviceInfo {
  4997. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4998. // }
  4999. // }
  5000. // if item.Type == 2 { //项目
  5001. // for _, subItem := range item.HisPrescriptionProject {
  5002. // total = total + (subItem.Price * float64(subItem.Count))
  5003. // }
  5004. // }
  5005. // }
  5006. //
  5007. // for _, item := range prescriptions {
  5008. // for _, subItem := range item.HisAdditionalCharge {
  5009. // total = total + (subItem.Price * float64(subItem.Count))
  5010. // }
  5011. // }
  5012. //
  5013. // allTotal := fmt.Sprintf("%.2f", total)
  5014. // if res.Infcode == 0 {
  5015. // var rf []*ResultFive
  5016. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5017. // psn_no := his.PsnNo
  5018. // mdtrt_id := his.Number
  5019. // chrg_bchno := chrg_bchno
  5020. // cert_no := his.Certno
  5021. // insutype := rf[0].Insutype
  5022. //
  5023. // if his.IdCardType == 1 {
  5024. // cert_no = his.MedicalInsuranceNumber
  5025. //
  5026. // } else {
  5027. //
  5028. // cert_no = his.Certno
  5029. //
  5030. // }
  5031. //
  5032. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5033. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5034. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5035. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5036. // resp, requestErr := http.Get(api)
  5037. // if requestErr != nil {
  5038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5039. // return
  5040. // }
  5041. // defer resp.Body.Close()
  5042. // body, ioErr := ioutil.ReadAll(resp.Body)
  5043. // if ioErr != nil {
  5044. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5046. // return
  5047. // }
  5048. // var respJSON map[string]interface{}
  5049. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5050. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5052. // return
  5053. // }
  5054. // fmt.Println(respJSON)
  5055. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5056. // userJSONBytes, _ := json.Marshal(respJSON)
  5057. // var res ResultSeven
  5058. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5059. // utils.ErrorLog("解析失败:%v", err)
  5060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5061. // return
  5062. // }
  5063. // if res.Infcode != 0 {
  5064. // errlog := &models.HisOrderError{
  5065. // UserOrgId: adminUser.CurrentOrgId,
  5066. // Ctime: time.Now().Unix(),
  5067. // Mtime: time.Now().Unix(),
  5068. // Number: chrg_bchno,
  5069. // ErrMsg: res.ErrMsg,
  5070. // Status: 1,
  5071. // PatientId: id,
  5072. // RecordTime: recordDateTime,
  5073. // Stage: 7,
  5074. // }
  5075. // service.CreateErrMsgLog(errlog)
  5076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5077. // return
  5078. // } else {
  5079. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5080. // order.OrderStatus = 1
  5081. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5082. // order.SetlId = res.Output.Setlinfo.SetlID
  5083. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5084. // order.PsnName = res.Output.Setlinfo.PsnName
  5085. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5086. // order.Certno = res.Output.Setlinfo.Certno
  5087. // order.Gend = res.Output.Setlinfo.Gend
  5088. // order.Naty = res.Output.Setlinfo.Naty
  5089. // order.Age = res.Output.Setlinfo.Age
  5090. // order.Insutype = res.Output.Setlinfo.Insutype
  5091. // order.PsnType = res.Output.Setlinfo.PsnType
  5092. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5093. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5094. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5095. // order.MedType = res.Output.Setlinfo.MedType
  5096. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5097. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5098. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5099. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5100. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5101. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5102. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5103. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5104. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5105. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5106. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5107. // order.MafPay = res.Output.Setlinfo.MafPay
  5108. // order.OthPay = res.Output.Setlinfo.OthPay
  5109. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5110. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5111. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5112. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5113. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5114. // order.Balc = res.Output.Setlinfo.Balc
  5115. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5116. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5117. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5118. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5119. // order.Creator = order.Creator
  5120. // order.Modify = roles.ID
  5121. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5122. // detailStr := string(setlDetail)
  5123. // order.SetlDetail = detailStr
  5124. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5125. // err = service.UpDateOrder(order)
  5126. // if err == nil {
  5127. // c.ServeSuccessJSON(map[string]interface{}{
  5128. // "msg": "预结算成功",
  5129. // })
  5130. // } else {
  5131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5132. // return
  5133. // }
  5134. // }
  5135. // } else {
  5136. // adminUser := c.GetAdminUserInfo()
  5137. // errlog := &models.HisOrderError{
  5138. // UserOrgId: adminUser.CurrentOrgId,
  5139. // Ctime: time.Now().Unix(),
  5140. // Mtime: time.Now().Unix(),
  5141. // ErrMsg: res.ErrMsg,
  5142. // Status: 1,
  5143. // PatientId: id,
  5144. // RecordTime: recordDateTime,
  5145. // Stage: 4,
  5146. // }
  5147. // service.CreateErrMsgLog(errlog)
  5148. //
  5149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5150. // return
  5151. // }
  5152. // } else {
  5153. // adminUser := c.GetAdminUserInfo()
  5154. // errlog := &models.HisOrderError{
  5155. // UserOrgId: adminUser.CurrentOrgId,
  5156. // Ctime: time.Now().Unix(),
  5157. // Mtime: time.Now().Unix(),
  5158. // ErrMsg: res.ErrMsg,
  5159. // Status: 1,
  5160. // PatientId: id,
  5161. // RecordTime: recordDateTime,
  5162. // Stage: 4,
  5163. // }
  5164. // service.CreateErrMsgLog(errlog)
  5165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5166. // return
  5167. // }
  5168. //
  5169. // } else {
  5170. // var total float64
  5171. // for _, item := range prescriptions {
  5172. // if item.Type == 1 { //药品
  5173. // for _, subItem := range item.HisDoctorAdviceInfo {
  5174. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5175. // }
  5176. // }
  5177. // if item.Type == 2 { //项目
  5178. // for _, subItem := range item.HisPrescriptionProject {
  5179. // total = total + (subItem.Price * float64(subItem.Count))
  5180. // }
  5181. // }
  5182. //
  5183. // for _, subItem := range item.HisAdditionalCharge {
  5184. // total = total + (subItem.Price * float64(subItem.Count))
  5185. // }
  5186. // }
  5187. //
  5188. // allTotal := fmt.Sprintf("%.2f", total)
  5189. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5190. // order := &models.HisOrder{
  5191. // UserOrgId: adminUser.CurrentOrgId,
  5192. // HisPatientId: his.ID,
  5193. // PatientId: id,
  5194. // SettleAccountsDate: recordDateTime,
  5195. // Ctime: time.Now().Unix(),
  5196. // Mtime: time.Now().Unix(),
  5197. // Status: 1,
  5198. // OrderStatus: 2,
  5199. // Number: chrg_bchno,
  5200. // MedfeeSumamt: totals,
  5201. // }
  5202. // err = service.CreateOrder(order)
  5203. // if err != nil {
  5204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5205. // return
  5206. // }
  5207. //
  5208. // var customs []*Custom
  5209. // for _, item := range prescriptions {
  5210. //
  5211. // if item.Type == 1 { //药品
  5212. // for _, subItem := range item.HisDoctorAdviceInfo {
  5213. // cus := &Custom{
  5214. // AdviceId: subItem.ID,
  5215. // ProjectId: 0,
  5216. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5217. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5218. // FeedetlSn: subItem.FeedetlSn,
  5219. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5220. // MedListCodg: subItem.MedListCodg,
  5221. // Type: 1,
  5222. // }
  5223. // customs = append(customs, cus)
  5224. // }
  5225. // }
  5226. //
  5227. // if item.Type == 2 { //项目
  5228. // for _, subItem := range item.HisPrescriptionProject {
  5229. //
  5230. // cus := &Custom{
  5231. // AdviceId: 0,
  5232. // ProjectId: subItem.ID,
  5233. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5234. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5235. // FeedetlSn: subItem.FeedetlSn,
  5236. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5237. // MedListCodg: subItem.MedListCodg,
  5238. // Type: 2,
  5239. // }
  5240. //
  5241. // customs = append(customs, cus)
  5242. // }
  5243. // }
  5244. //
  5245. // for _, item := range item.HisAdditionalCharge {
  5246. // cus := &Custom{
  5247. // ItemId: item.ID,
  5248. // AdviceId: 0,
  5249. // ProjectId: 0,
  5250. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5251. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5252. // FeedetlSn: item.FeedetlSn,
  5253. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5254. // MedListCodg: item.XtHisAddtionConfig.Code,
  5255. // Type: 3,
  5256. // }
  5257. //
  5258. // customs = append(customs, cus)
  5259. // }
  5260. //
  5261. // }
  5262. //
  5263. // for _, item := range customs {
  5264. // var advice_id int64 = 0
  5265. // var project_id int64 = 0
  5266. // var item_id int64 = 0
  5267. //
  5268. // var types int64 = 0
  5269. //
  5270. // if item.Type == 1 {
  5271. // advice_id = item.AdviceId
  5272. // project_id = 0
  5273. // item_id = 0
  5274. // } else if item.Type == 2 {
  5275. // advice_id = 0
  5276. // item_id = 0
  5277. //
  5278. // project_id = item.ProjectId
  5279. // } else if item.Type == 3 {
  5280. // advice_id = 0
  5281. // item_id = item.ItemId
  5282. // project_id = 0
  5283. // }
  5284. //
  5285. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5286. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5287. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5288. //
  5289. // info := &models.HisOrderInfo{
  5290. // OrderNumber: order.Number,
  5291. // UploadDate: time.Now().Unix(),
  5292. // AdviceId: advice_id,
  5293. // DetItemFeeSumamt: detItemFeeSumamt,
  5294. // Cnt: cut,
  5295. // Pric: pric,
  5296. // PatientId: id,
  5297. // Status: 1,
  5298. // Mtime: time.Now().Unix(),
  5299. // Ctime: time.Now().Unix(),
  5300. // UserOrgId: adminUser.CurrentOrgId,
  5301. // HisPatientId: his.ID,
  5302. // OrderId: order.ID,
  5303. // ProjectId: project_id,
  5304. // Type: types,
  5305. // ItemId: item_id,
  5306. // }
  5307. // service.CreateOrderInfo(info)
  5308. // }
  5309. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5310. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5311. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5312. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5313. // if err == nil {
  5314. // c.ServeSuccessJSON(map[string]interface{}{
  5315. // "msg": "结算成功",
  5316. // })
  5317. // } else {
  5318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5319. // return
  5320. // }
  5321. // }
  5322. //}
  5323. //上传明细-预结算-
  5324. func (c *HisApiController) GetPreUploadInfo() {
  5325. id, _ := c.GetInt64("id")
  5326. record_time := c.GetString("record_time")
  5327. his_patient_id, _ := c.GetInt64("his_patient_id")
  5328. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5329. admin_user_id, _ := c.GetInt64("admin_user_id")
  5330. diagnosis_id := c.GetString("diagnosis")
  5331. sick_type, _ := c.GetInt64("sick_type")
  5332. reg_type, _ := c.GetInt64("p_type")
  5333. begin_time := c.GetString("begin_time")
  5334. id_str := c.GetString("ids")
  5335. ids_arr := strings.Split(id_str, ",")
  5336. timeLayout := "2006-01-02"
  5337. loc, _ := time.LoadLocation("Local")
  5338. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5339. if err != nil {
  5340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5341. return
  5342. }
  5343. recordDateTime := theTime.Unix()
  5344. adminUser := c.GetAdminUserInfo()
  5345. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5346. var config []*models.HisXtDiagnoseConfig
  5347. for _, item := range diagnosis_ids {
  5348. id, _ := strconv.ParseInt(item, 10, 64)
  5349. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5350. config = append(config, &diagnosisConfig)
  5351. }
  5352. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5353. sickConfig, _ := service.FindSickById(sick_type)
  5354. var prescriptions []*models.HisPrescription
  5355. var start_time int64
  5356. var end_time int64
  5357. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5358. fmt.Println(his_patient_id)
  5359. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5360. timestamp := time.Now().Unix()
  5361. tempTime := time.Unix(timestamp, 0)
  5362. timeFormat := tempTime.Format("20060102150405")
  5363. chrgBchno := rand.Intn(100000) + 10000
  5364. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5365. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5366. var patientPrescription models.HisPrescriptionInfo
  5367. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5368. if patientPrescription.ID == 0 {
  5369. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5370. }
  5371. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5372. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5373. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5374. strconv.FormatInt(his.PatientId, 10)
  5375. var res2 ResultSix
  5376. var resSix10265 ResultSix10265
  5377. var time_stamp string
  5378. if miConfig.MdtrtareaAdmvs == "421300" {
  5379. data := make(map[string]interface{})
  5380. client := &http.Client{}
  5381. data["psn_no"] = his.PsnNo
  5382. data["mdtrt_id"] = his.Number
  5383. data["doctor"] = roles.UserName
  5384. data["department"] = department.Name
  5385. data["org_name"] = miConfig.OrgName
  5386. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5387. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5388. data["fixmedins_code"] = miConfig.Code
  5389. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5391. data["secret_key"] = miConfig.SecretKey
  5392. data["sick_code"] = sickConfig.CountryCode
  5393. data["sick_name"] = sickConfig.ClassName
  5394. data["begin_time"] = begin_time
  5395. data["dept"] = strconv.FormatInt(department.ID, 10)
  5396. data["config"] = config
  5397. fmt.Println(data)
  5398. bytesData, _ := json.Marshal(data)
  5399. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5400. resp, _ := client.Do(req)
  5401. defer resp.Body.Close()
  5402. body, ioErr := ioutil.ReadAll(resp.Body)
  5403. if ioErr != nil {
  5404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. var respJSON map[string]interface{}
  5409. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5412. return
  5413. }
  5414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5415. userJSONBytes, _ := json.Marshal(respJSON)
  5416. fmt.Println("log")
  5417. fmt.Println(string(userJSONBytes))
  5418. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5419. utils.ErrorLog("解析失败:%v", err)
  5420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5421. return
  5422. }
  5423. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5424. //江苏地区国家医保医疗类别
  5425. //职工透析:医疗类别选特殊情况门诊9933
  5426. //居民血透门慢: 医疗类别选门诊慢病1402
  5427. //var med_type string
  5428. //if his.Insutype == "310" {
  5429. // if reg_type == 14 {
  5430. // med_type = "9933"
  5431. // } else if reg_type == 11 {
  5432. // med_type = "11"
  5433. //
  5434. // }
  5435. //} else if his.Insutype == "390" {
  5436. // if reg_type == 14 {
  5437. // med_type = "1402"
  5438. // } else if reg_type == 11 {
  5439. // med_type = "11"
  5440. // }
  5441. //}
  5442. data := make(map[string]interface{})
  5443. client := &http.Client{}
  5444. data["psn_no"] = his.PsnNo
  5445. data["mdtrt_id"] = his.Number
  5446. data["doctor"] = roles.UserName
  5447. data["department"] = department.Name
  5448. data["org_name"] = miConfig.OrgName
  5449. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5450. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5451. data["fixmedins_code"] = miConfig.Code
  5452. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5453. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5454. data["secret_key"] = miConfig.SecretKey
  5455. data["sick_code"] = sickConfig.CountryCode
  5456. data["sick_name"] = sickConfig.ClassName
  5457. data["begin_time"] = begin_time
  5458. data["dept"] = strconv.FormatInt(department.ID, 10)
  5459. data["config"] = config
  5460. data["url"] = miConfig.Url
  5461. data["ak"] = miConfig.AccessKey
  5462. data["cainfo"] = miConfig.Cainfo
  5463. bytesData, _ := json.Marshal(data)
  5464. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5465. resp, _ := client.Do(req)
  5466. defer resp.Body.Close()
  5467. body, ioErr := ioutil.ReadAll(resp.Body)
  5468. if ioErr != nil {
  5469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5471. return
  5472. }
  5473. var respJSON map[string]interface{}
  5474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5477. return
  5478. }
  5479. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5480. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5481. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5483. userJSONBytes, _ := json.Marshal(respJSON)
  5484. fmt.Println("log")
  5485. fmt.Println(string(userJSONBytes))
  5486. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5487. utils.ErrorLog("解析失败:%v", err)
  5488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5489. return
  5490. }
  5491. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5492. res2.Output = resSix10265.Output
  5493. res2.ErrMsg = resSix10265.ErrMsg
  5494. res2.Cainfo = resSix10265.Cainfo
  5495. res2.WarnMsg = resSix10265.WarnMsg
  5496. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5497. res2.Infcode = infocode
  5498. } else {
  5499. var result string
  5500. var requestLog string
  5501. if miConfig.MdtrtareaAdmvs == "440781" { //
  5502. 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)
  5503. } else {
  5504. if miConfig.Code == "H15049901371" {
  5505. //赤峰地区国家医保医疗类别
  5506. //职工透析:医疗类别选特殊情况门诊990502
  5507. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5508. var med_type string
  5509. if his.Insutype == "390" {
  5510. if reg_type == 14 {
  5511. med_type = "9933"
  5512. } else if reg_type == 11 {
  5513. med_type = "11"
  5514. }
  5515. } else if his.Insutype == "310" {
  5516. if reg_type == 14 {
  5517. med_type = "990502"
  5518. } else if reg_type == 11 {
  5519. med_type = "11"
  5520. }
  5521. }
  5522. 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)
  5523. } else {
  5524. 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)
  5525. }
  5526. saveLog(result, requestLog, "2203", "上传就诊信息")
  5527. var respJSON2 map[string]interface{}
  5528. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. userJSONBytes2, _ := json.Marshal(respJSON2)
  5534. if miConfig.Code == "H15049901371" {
  5535. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5536. utils.ErrorLog("解析失败:%v", err)
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5538. return
  5539. }
  5540. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5541. res2.Output = resSix10265.Output
  5542. res2.ErrMsg = resSix10265.ErrMsg
  5543. res2.Cainfo = resSix10265.Cainfo
  5544. res2.WarnMsg = resSix10265.WarnMsg
  5545. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5546. res2.Infcode = infocode
  5547. } else {
  5548. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5549. utils.ErrorLog("解析失败:%v", err)
  5550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5551. return
  5552. }
  5553. }
  5554. }
  5555. }
  5556. if res2.Infcode != 0 {
  5557. adminUser := c.GetAdminUserInfo()
  5558. errlog := &models.HisOrderError{
  5559. UserOrgId: adminUser.CurrentOrgId,
  5560. Ctime: time.Now().Unix(),
  5561. Mtime: time.Now().Unix(),
  5562. ErrMsg: res2.ErrMsg,
  5563. Status: 1,
  5564. PatientId: id,
  5565. RecordTime: recordDateTime,
  5566. Stage: 3,
  5567. }
  5568. service.CreateErrMsgLog(errlog)
  5569. c.ServeSuccessJSON(map[string]interface{}{
  5570. "failed_code": -10,
  5571. "msg": res2.ErrMsg,
  5572. })
  5573. return
  5574. } else {
  5575. his.Diagnosis = diagnosis_id
  5576. his.SickType = sickConfig.ID
  5577. his.PType = fmt.Sprintf("%d", reg_type)
  5578. service.UpdateHisPatientThree(&his)
  5579. data := make(map[string]interface{})
  5580. if settle_accounts_type == 1 { //日结
  5581. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5582. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5583. } else {
  5584. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5585. }
  5586. data["pre"] = prescriptions
  5587. } else { //月结
  5588. start_time_str := c.GetString("start_time")
  5589. end_time_str := c.GetString("end_time")
  5590. timeLayout := "2006-01-02"
  5591. loc, _ := time.LoadLocation("Local")
  5592. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5593. if err != nil {
  5594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5595. return
  5596. }
  5597. recordStartTime := theStartTime.Unix()
  5598. start_time = recordStartTime
  5599. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5600. if err != nil {
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5602. return
  5603. }
  5604. recordEndTime := theEndTime.Unix()
  5605. end_time = recordEndTime
  5606. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5607. data["pre"] = prescriptions
  5608. }
  5609. client := &http.Client{}
  5610. data["psn_no"] = his.PsnNo
  5611. data["mdtrt_id"] = his.Number
  5612. data["chrg_bchno"] = chrg_bchno
  5613. data["org_name"] = miConfig.OrgName
  5614. data["doctor"] = roles.UserName
  5615. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5616. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5617. data["fixmedins_code"] = miConfig.Code
  5618. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5619. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5620. data["dept_code"] = "15"
  5621. } else {
  5622. data["dept_code"] = department.Number
  5623. }
  5624. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5625. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5626. data["secret_key"] = miConfig.SecretKey
  5627. data["url"] = miConfig.Url
  5628. data["ak"] = miConfig.AccessKey
  5629. data["new_doctor_name"] = patientPrescription.Doctor
  5630. data["diag_code"] = sickConfig.CountryCode
  5631. data["time_stamp"] = time_stamp
  5632. data["cainfo"] = miConfig.Cainfo
  5633. var ids []int64
  5634. for _, item := range prescriptions {
  5635. ids = append(ids, item.ID)
  5636. }
  5637. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5638. if config.IsOpen == 1 { //对接了医保,走医保流程
  5639. var res ResultFour
  5640. var resFour10265 ResultFour10265
  5641. if miConfig.MdtrtareaAdmvs == "421300" {
  5642. bytesData, _ := json.Marshal(data)
  5643. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5644. resp, _ := client.Do(req)
  5645. defer resp.Body.Close()
  5646. body, ioErr := ioutil.ReadAll(resp.Body)
  5647. if ioErr != nil {
  5648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5650. return
  5651. }
  5652. var respJSON map[string]interface{}
  5653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5656. return
  5657. }
  5658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5659. userJSONBytes, _ := json.Marshal(respJSON)
  5660. fmt.Println("log")
  5661. fmt.Println(string(userJSONBytes))
  5662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5663. utils.ErrorLog("解析失败:%v", err)
  5664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5665. return
  5666. }
  5667. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5668. bytesData, _ := json.Marshal(data)
  5669. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5670. resp, _ := client.Do(req)
  5671. defer resp.Body.Close()
  5672. body, ioErr := ioutil.ReadAll(resp.Body)
  5673. if ioErr != nil {
  5674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5676. return
  5677. }
  5678. var respJSON map[string]interface{}
  5679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5682. return
  5683. }
  5684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5685. userJSONBytes, _ := json.Marshal(respJSON)
  5686. fmt.Println("log")
  5687. fmt.Println(string(userJSONBytes))
  5688. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5689. utils.ErrorLog("解析失败:%v", err)
  5690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5691. return
  5692. }
  5693. res.InfRefmsgid = resFour10265.InfRefmsgid
  5694. res.Output = resFour10265.Output
  5695. res.ErrMsg = resFour10265.ErrMsg
  5696. res.Cainfo = resFour10265.Cainfo
  5697. res.WarnMsg = resFour10265.WarnMsg
  5698. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5699. res.Infcode = infocode
  5700. } else {
  5701. if miConfig.Code == "H15049901371" {
  5702. 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)
  5703. var dat map[string]interface{}
  5704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5705. fmt.Println(dat)
  5706. } else {
  5707. fmt.Println(err)
  5708. }
  5709. saveLog(result, request_log, "2204", "上传费用明细")
  5710. userJSONBytes, _ := json.Marshal(dat)
  5711. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5712. utils.ErrorLog("解析失败:%v", err)
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. return
  5715. }
  5716. res.InfRefmsgid = resFour10265.InfRefmsgid
  5717. res.Output = resFour10265.Output
  5718. res.ErrMsg = resFour10265.ErrMsg
  5719. res.Cainfo = resFour10265.Cainfo
  5720. res.WarnMsg = resFour10265.WarnMsg
  5721. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5722. res.Infcode = infocode
  5723. } else {
  5724. 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)
  5725. var dat map[string]interface{}
  5726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5727. fmt.Println(dat)
  5728. } else {
  5729. fmt.Println(err)
  5730. }
  5731. saveLog(result, request_log, "2204", "上传费用明细")
  5732. userJSONBytes, _ := json.Marshal(dat)
  5733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5734. utils.ErrorLog("解析失败:%v", err)
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5736. return
  5737. }
  5738. }
  5739. }
  5740. if res.Infcode == 0 {
  5741. order := &models.HisOrder{
  5742. UserOrgId: adminUser.CurrentOrgId,
  5743. HisPatientId: his.ID,
  5744. PatientId: his.PatientId,
  5745. SettleAccountsDate: recordDateTime,
  5746. Ctime: time.Now().Unix(),
  5747. Mtime: time.Now().Unix(),
  5748. MdtrtId: his.Number,
  5749. PsnNo: his.PsnNo,
  5750. MedType: strconv.FormatInt(reg_type, 10),
  5751. Status: 1,
  5752. Number: chrg_bchno,
  5753. Infcode: res.Infcode,
  5754. WarnMsg: res.WarnMsg,
  5755. Cainfo: res.Cainfo,
  5756. ErrMsg: res.ErrMsg,
  5757. RespondTime: res.RefmsgTime,
  5758. InfRefmsgid: res.InfRefmsgid,
  5759. OrderStatus: 1,
  5760. IsMedicineInsurance: 1,
  5761. SettleType: settle_accounts_type,
  5762. SettleStartTime: start_time,
  5763. SettleEndTime: end_time,
  5764. Creator: roles.AdminUserId,
  5765. Modify: roles.AdminUserId,
  5766. PType: 2,
  5767. Diagnosis: diagnosis_id,
  5768. }
  5769. err = service.CreateOrder(order)
  5770. if err != nil {
  5771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5772. return
  5773. }
  5774. for _, item := range res.Output.Result {
  5775. temp := strings.Split(item.FeedetlSn, "-")
  5776. var advice_id int64 = 0
  5777. var project_id int64 = 0
  5778. var types int64 = 0
  5779. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5780. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5781. if temp[1] == "1" {
  5782. advice_id = id
  5783. project_id = 0
  5784. } else if temp[1] == "2" {
  5785. advice_id = 0
  5786. project_id = id
  5787. }
  5788. info := &models.HisOrderInfo{
  5789. OrderNumber: order.Number,
  5790. FeedetlSn: item.FeedetlSn,
  5791. UploadDate: time.Now().Unix(),
  5792. AdviceId: advice_id,
  5793. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5794. Cnt: item.Cnt,
  5795. Pric: float64(item.Pric),
  5796. PatientId: his.PatientId,
  5797. PricUplmtAmt: item.PricUplmtAmt,
  5798. SelfpayProp: item.SelfpayProp,
  5799. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5800. OverlmtAmt: item.OverlmtAmt,
  5801. PreselfpayAmt: item.PreselfpayAmt,
  5802. BasMednFlag: item.BasMednFlag,
  5803. MedChrgitmType: item.MedChrgitmType,
  5804. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5805. Status: 1,
  5806. Memo: item.Memo,
  5807. Mtime: time.Now().Unix(),
  5808. InscpScpAmt: item.InscpScpAmt,
  5809. DrtReimFlag: item.DrtReimFlag,
  5810. Ctime: time.Now().Unix(),
  5811. ListSpItemFlag: item.ListSpItemFlag,
  5812. ChldMedcFlag: item.ChldMedcFlag,
  5813. LmtUsedFlag: item.LmtUsedFlag,
  5814. ChrgitmLv: item.ChrgitmLv,
  5815. UserOrgId: adminUser.CurrentOrgId,
  5816. HisPatientId: his.ID,
  5817. OrderId: order.ID,
  5818. ProjectId: project_id,
  5819. Type: types,
  5820. }
  5821. service.CreateOrderInfo(info)
  5822. }
  5823. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5824. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5825. var total float64
  5826. for _, item := range prescriptions {
  5827. if item.Type == 1 { //药品
  5828. for _, subItem := range item.HisDoctorAdviceInfo {
  5829. total = total + (subItem.Price * subItem.PrescribingNumber)
  5830. }
  5831. }
  5832. if item.Type == 2 { //项目
  5833. for _, subItem := range item.HisPrescriptionProject {
  5834. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5835. total = total + (subItem.Price * cnt)
  5836. }
  5837. }
  5838. }
  5839. for _, item := range prescriptions {
  5840. for _, subItem := range item.HisAdditionalCharge {
  5841. total = total + (subItem.Price * float64(subItem.Count))
  5842. }
  5843. }
  5844. allTotal := fmt.Sprintf("%.4f", total)
  5845. if res.Infcode == 0 {
  5846. var rf []*ResultFive
  5847. json.Unmarshal([]byte(his.Iinfo), &rf)
  5848. chrg_bchno := chrg_bchno
  5849. cert_no := his.Certno
  5850. var insutypes []string
  5851. var insutype string
  5852. var is390 int = 0
  5853. var is310 int = 0
  5854. for _, item := range rf {
  5855. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5856. insutypes = append(insutypes, item.Insutype)
  5857. }
  5858. }
  5859. if len(insutypes) == 1 {
  5860. insutype = insutypes[0]
  5861. } else {
  5862. for _, i := range insutypes {
  5863. if i == "390" {
  5864. is390 = 1
  5865. }
  5866. if i == "310" {
  5867. is310 = 1
  5868. }
  5869. }
  5870. }
  5871. if is390 == 1 {
  5872. insutype = "390"
  5873. }
  5874. if is310 == 1 {
  5875. insutype = "310"
  5876. }
  5877. if len(insutypes) == 0 {
  5878. insutype = "310"
  5879. }
  5880. if len(insutypes) == 2 {
  5881. insutype = strconv.FormatInt(his.SocialType, 64)
  5882. }
  5883. //insutype = "390"
  5884. if his.IdCardType == 1 {
  5885. cert_no = his.MedicalInsuranceNumber
  5886. } else {
  5887. cert_no = his.Certno
  5888. }
  5889. var res ResultSeven
  5890. var resSeven10265 ResultSeven10265
  5891. if miConfig.MdtrtareaAdmvs == "421300" {
  5892. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5893. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5894. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5895. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5896. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5897. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5898. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5899. resp, requestErr := http.Get(api)
  5900. if requestErr != nil {
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. return
  5903. }
  5904. body, ioErr := ioutil.ReadAll(resp.Body)
  5905. if ioErr != nil {
  5906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5908. return
  5909. }
  5910. var respJSON map[string]interface{}
  5911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5914. return
  5915. }
  5916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5917. result, _ := json.Marshal(respJSON)
  5918. fmt.Println("log")
  5919. fmt.Println(string(result))
  5920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5921. utils.ErrorLog("解析失败:%v", err)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return
  5924. }
  5925. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5926. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5927. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5928. bas := strings.Split(psn_info.CardInfo, "|")
  5929. if his.IdCardType == 1 {
  5930. cert_no = bas[2]
  5931. } else {
  5932. cert_no = bas[1]
  5933. }
  5934. //江苏地区国家医保医疗类别
  5935. //职工透析:医疗类别选特殊情况门诊9933
  5936. //居民血透门慢: 医疗类别选门诊慢病1402
  5937. //var med_type string
  5938. //if his.Insutype == "310" {
  5939. // if reg_type == 14 {
  5940. // med_type = "9933"
  5941. // } else if reg_type == 11 {
  5942. // med_type = "11"
  5943. //
  5944. // }
  5945. //} else if his.Insutype == "390" {
  5946. // if reg_type == 14 {
  5947. // med_type = "1402"
  5948. // } else if reg_type == 11 {
  5949. // med_type = "11"
  5950. // }
  5951. //}
  5952. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5953. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5954. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5956. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5957. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5958. "&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
  5959. resp, requestErr := http.Get(api)
  5960. if requestErr != nil {
  5961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5962. return
  5963. }
  5964. body, ioErr := ioutil.ReadAll(resp.Body)
  5965. if ioErr != nil {
  5966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5968. return
  5969. }
  5970. var respJSON map[string]interface{}
  5971. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5974. return
  5975. }
  5976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5977. result, _ := json.Marshal(respJSON)
  5978. fmt.Println("log")
  5979. fmt.Println(string(result))
  5980. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5981. utils.ErrorLog("解析失败:%v", err)
  5982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5983. return
  5984. }
  5985. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5986. res.Output = resSeven10265.Output
  5987. res.ErrMsg = resSeven10265.ErrMsg
  5988. res.Cainfo = resSeven10265.Cainfo
  5989. res.WarnMsg = resSeven10265.WarnMsg
  5990. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5991. res.Infcode = infocode
  5992. } else {
  5993. var result string
  5994. var request_log string
  5995. if miConfig.Code == "H15049901371" {
  5996. //赤峰地区国家医保医疗类别
  5997. //职工透析:医疗类别选特殊情况门诊990502
  5998. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5999. var med_type string
  6000. if his.Insutype == "390" {
  6001. if reg_type == 14 {
  6002. med_type = "9933"
  6003. } else if reg_type == 11 {
  6004. med_type = "11"
  6005. }
  6006. } else if his.Insutype == "310" {
  6007. if reg_type == 14 {
  6008. med_type = "990502"
  6009. } else if reg_type == 11 {
  6010. med_type = "11"
  6011. }
  6012. }
  6013. 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)
  6014. } else {
  6015. 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)
  6016. }
  6017. var dat map[string]interface{}
  6018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6019. fmt.Println(dat)
  6020. } else {
  6021. fmt.Println(err)
  6022. }
  6023. saveLog(result, request_log, "2206", "预结算")
  6024. //userJSONBytes, _ := json.Marshal(dat)
  6025. //
  6026. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6027. // utils.ErrorLog("解析失败:%v", err)
  6028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. // return
  6030. //}
  6031. userJSONBytes, _ := json.Marshal(dat)
  6032. if miConfig.Code == "H15049901371" {
  6033. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6034. utils.ErrorLog("解析失败:%v", err)
  6035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6036. return
  6037. }
  6038. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6039. res.Output = resSeven10265.Output
  6040. res.ErrMsg = resSeven10265.ErrMsg
  6041. res.Cainfo = resSeven10265.Cainfo
  6042. res.WarnMsg = resSeven10265.WarnMsg
  6043. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6044. res.Infcode = infocode
  6045. } else {
  6046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6047. utils.ErrorLog("解析失败:%v", err)
  6048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6049. return
  6050. }
  6051. }
  6052. }
  6053. if res.Infcode != 0 {
  6054. errlog := &models.HisOrderError{
  6055. UserOrgId: adminUser.CurrentOrgId,
  6056. Ctime: time.Now().Unix(),
  6057. Mtime: time.Now().Unix(),
  6058. Number: chrg_bchno,
  6059. ErrMsg: res.ErrMsg,
  6060. Status: 1,
  6061. PatientId: id,
  6062. RecordTime: recordDateTime,
  6063. Stage: 20,
  6064. }
  6065. service.CreateErrMsgLog(errlog)
  6066. c.ServeSuccessJSON(map[string]interface{}{
  6067. "failed_code": -10,
  6068. "msg": res.ErrMsg,
  6069. })
  6070. return
  6071. } else {
  6072. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6073. order.OrderStatus = 1
  6074. order.IsPre = 1
  6075. order.Status = 1
  6076. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6077. order.SetlId = res.Output.Setlinfo.SetlID
  6078. order.PsnNo = res.Output.Setlinfo.PsnNo
  6079. order.PsnName = res.Output.Setlinfo.PsnName
  6080. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6081. order.Certno = res.Output.Setlinfo.Certno
  6082. order.Gend = res.Output.Setlinfo.Gend
  6083. order.Naty = res.Output.Setlinfo.Naty
  6084. order.Age = res.Output.Setlinfo.Age
  6085. order.Insutype = res.Output.Setlinfo.Insutype
  6086. order.PsnType = res.Output.Setlinfo.PsnType
  6087. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6088. order.SetlTime = res.Output.Setlinfo.SetlTime
  6089. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6090. if res.Output.Setlinfo.MedType == "140101" {
  6091. order.MedType = "14"
  6092. } else {
  6093. order.MedType = res.Output.Setlinfo.MedType
  6094. }
  6095. if reg_type == 1112 {
  6096. order.MedType = "1112"
  6097. }
  6098. if reg_type == 1111 {
  6099. order.MedType = "1111"
  6100. }
  6101. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6102. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6103. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6104. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6105. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6106. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6107. order.HifpPay = res.Output.Setlinfo.HifpPay
  6108. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6109. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6110. order.HifesPay = res.Output.Setlinfo.HifesPay
  6111. order.HifobPay = res.Output.Setlinfo.HifobPay
  6112. order.MafPay = res.Output.Setlinfo.MafPay
  6113. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6114. order.OthPay = res.Output.Setlinfo.OthPay
  6115. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6116. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6117. order.AcctPay = res.Output.Setlinfo.AcctPay
  6118. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6119. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6120. order.Balc = res.Output.Setlinfo.Balc
  6121. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6122. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6123. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6124. order.ClrWay = res.Output.Setlinfo.ClrWay
  6125. order.Creator = order.Creator
  6126. order.Modify = roles.AdminUserId
  6127. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6128. detailStr := string(setlDetail)
  6129. order.SetlDetail = detailStr
  6130. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6131. err = service.UpDateOrder(order)
  6132. if err == nil {
  6133. c.ServeSuccessJSON(map[string]interface{}{
  6134. "msg": "预结算成功",
  6135. })
  6136. } else {
  6137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6138. return
  6139. }
  6140. }
  6141. } else {
  6142. adminUser := c.GetAdminUserInfo()
  6143. errlog := &models.HisOrderError{
  6144. UserOrgId: adminUser.CurrentOrgId,
  6145. Ctime: time.Now().Unix(),
  6146. Mtime: time.Now().Unix(),
  6147. ErrMsg: res.ErrMsg,
  6148. Status: 1,
  6149. PatientId: id,
  6150. RecordTime: recordDateTime,
  6151. Stage: 4,
  6152. }
  6153. service.CreateErrMsgLog(errlog)
  6154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6155. return
  6156. }
  6157. } else {
  6158. adminUser := c.GetAdminUserInfo()
  6159. errlog := &models.HisOrderError{
  6160. UserOrgId: adminUser.CurrentOrgId,
  6161. Ctime: time.Now().Unix(),
  6162. Mtime: time.Now().Unix(),
  6163. ErrMsg: res.ErrMsg,
  6164. Status: 1,
  6165. PatientId: id,
  6166. RecordTime: recordDateTime,
  6167. Stage: 4,
  6168. }
  6169. service.CreateErrMsgLog(errlog)
  6170. c.ServeSuccessJSON(map[string]interface{}{
  6171. "failed_code": -10,
  6172. "msg": res.ErrMsg,
  6173. })
  6174. return
  6175. }
  6176. }
  6177. }
  6178. }
  6179. //func (c *HisApiController) GetSettleInfo() {
  6180. // id, _ := c.GetInt64("id")
  6181. // order_id, _ := c.GetInt64("order_id")
  6182. //
  6183. // record_time := c.GetString("record_time")
  6184. // pay_way, _ := c.GetInt64("pay_way")
  6185. // pay_price, _ := c.GetFloat("pay_price")
  6186. // pay_card_no := c.GetString("pay_card_no")
  6187. // discount_price, _ := c.GetFloat("discount_price")
  6188. // preferential_price, _ := c.GetFloat("preferential_price")
  6189. // reality_price, _ := c.GetFloat("reality_price")
  6190. // found_price, _ := c.GetFloat("found_price")
  6191. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6192. // private_price, _ := c.GetFloat("private_price")
  6193. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6194. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6195. //
  6196. // timeLayout := "2006-01-02"
  6197. // loc, _ := time.LoadLocation("Local")
  6198. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6199. // if err != nil {
  6200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6201. // return
  6202. // }
  6203. // recordDateTime := theTime.Unix()
  6204. // adminUser := c.GetAdminUserInfo()
  6205. //
  6206. // var prescriptions []*models.HisPrescription
  6207. //
  6208. // data := make(map[string]interface{})
  6209. // if settle_accounts_type == 1 { //日结
  6210. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6211. // data["pre"] = prescriptions
  6212. //
  6213. // } else { //月结
  6214. // start_time_str := c.GetString("start_time")
  6215. // end_time_str := c.GetString("end_time")
  6216. // timeLayout := "2006-01-02"
  6217. // loc, _ := time.LoadLocation("Local")
  6218. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6219. // if err != nil {
  6220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6221. // return
  6222. // }
  6223. // recordStartTime := theStartTime.Unix()
  6224. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6225. // if err != nil {
  6226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6227. // return
  6228. // }
  6229. // recordEndTime := theEndTime.Unix()
  6230. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6231. // data["pre"] = prescriptions
  6232. //
  6233. // }
  6234. //
  6235. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6236. //
  6237. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6238. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6239. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6240. // strconv.FormatInt(his.PatientId, 10)
  6241. //
  6242. // order_src, _ := service.GetHisOrderByID(order_id)
  6243. //
  6244. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6245. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6246. //
  6247. // var total float64
  6248. // for _, item := range prescriptions {
  6249. // if item.Type == 1 { //药品
  6250. // for _, subItem := range item.HisDoctorAdviceInfo {
  6251. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6252. // }
  6253. // }
  6254. // if item.Type == 2 { //项目
  6255. // for _, subItem := range item.HisPrescriptionProject {
  6256. // total = total + (subItem.Price * float64(subItem.Count))
  6257. // }
  6258. // }
  6259. // }
  6260. //
  6261. // for _, item := range prescriptions {
  6262. // for _, subItem := range item.HisAdditionalCharge {
  6263. // total = total + (subItem.Price * float64(subItem.Count))
  6264. // }
  6265. // }
  6266. //
  6267. // allTotal := fmt.Sprintf("%.2f", total)
  6268. // var rf []*ResultFive
  6269. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6270. // psn_no := order_src.PsnNo
  6271. // mdtrt_id := order_src.MdtrtId
  6272. // chrg_bchno := order_src.Number
  6273. // cert_no := order_src.Certno
  6274. // insutype := rf[0].Insutype
  6275. //
  6276. // if his.IdCardType == 1 {
  6277. // cert_no = his.MedicalInsuranceNumber
  6278. // } else {
  6279. // cert_no = his.Certno
  6280. // }
  6281. //
  6282. // 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)
  6283. // var dat map[string]interface{}
  6284. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6285. // fmt.Println(dat)
  6286. // } else {
  6287. // fmt.Println(err)
  6288. // }
  6289. //
  6290. // userJSONBytes, _ := json.Marshal(dat)
  6291. //
  6292. //
  6293. //
  6294. // var res ResultSeven
  6295. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6296. // utils.ErrorLog("解析失败:%v", err)
  6297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6298. // return
  6299. // }
  6300. // if res.Infcode == -1 {
  6301. // errlog := &models.HisOrderError{
  6302. // UserOrgId: adminUser.CurrentOrgId,
  6303. // Ctime: time.Now().Unix(),
  6304. // Mtime: time.Now().Unix(),
  6305. // Number: chrg_bchno,
  6306. // ErrMsg: res.ErrMsg,
  6307. // Status: 1,
  6308. // PatientId: id,
  6309. // RecordTime: recordDateTime,
  6310. // Stage: 6,
  6311. // }
  6312. // service.CreateErrMsgLog(errlog)
  6313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6314. // return
  6315. // } else {
  6316. // order_src.OrderStatus = 2
  6317. // order_src.PayWay = pay_way
  6318. // order_src.PayPrice = pay_price
  6319. // order_src.PayCardNo = pay_card_no
  6320. // order_src.DiscountPrice = discount_price
  6321. // order_src.PreferentialPrice = preferential_price
  6322. // order_src.RealityPrice = reality_price
  6323. // order_src.FoundPrice = found_price
  6324. // order_src.MedicalInsurancePrice = medical_insurance_price
  6325. // order_src.PrivatePrice = private_price
  6326. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6327. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6328. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6329. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6330. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6331. // order_src.Certno = res.Output.Setlinfo.Certno
  6332. // order_src.Gend = res.Output.Setlinfo.Gend
  6333. // order_src.Naty = res.Output.Setlinfo.Naty
  6334. // order_src.Age = res.Output.Setlinfo.Age
  6335. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6336. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6337. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6338. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6339. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6340. // order_src.MedType = res.Output.Setlinfo.MedType
  6341. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6342. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6343. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6344. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6345. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6346. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6347. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6348. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6349. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6350. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6351. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6352. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6353. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6354. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6355. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6356. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6357. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6358. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6359. // order_src.Balc = res.Output.Setlinfo.Balc
  6360. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6361. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6362. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6363. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6364. // order_src.Creator = order_src.Creator
  6365. // order_src.Modify = roles.ID
  6366. // order_src.RequestLog = src_resquest
  6367. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6368. // detailStr := string(setlDetail)
  6369. // order_src.SetlDetail = detailStr
  6370. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6371. // err = service.UpDateOrder(order_src)
  6372. //
  6373. // if err == nil {
  6374. // c.ServeSuccessJSON(map[string]interface{}{
  6375. // "msg": "结算成功",
  6376. // })
  6377. // } else {
  6378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6379. // return
  6380. // }
  6381. // }
  6382. // }
  6383. //}
  6384. //退款
  6385. func (c *HisApiController) Refund() {
  6386. order_id, _ := c.GetInt64("order_id")
  6387. admin_user_id, _ := c.GetInt64("admin_user_id")
  6388. adminUser := c.GetAdminUserInfo()
  6389. var order models.HisOrder
  6390. order, _ = service.GetHisOrderByID(order_id)
  6391. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6392. if order.ID == 0 {
  6393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6394. return
  6395. }
  6396. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6398. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6399. if config.IsOpen == 1 { //对接了医保,走医保流程
  6400. var res ResultSixteen
  6401. var resSixteen10265 ResultSixteen10265
  6402. var src_resquest string
  6403. var result string
  6404. if miConfig.MdtrtareaAdmvs == "421300" {
  6405. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6406. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6408. resp3, requestErr3 := http.Get(api3)
  6409. if requestErr3 != nil {
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. return
  6412. }
  6413. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6414. if ioErr3 != nil {
  6415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6417. return
  6418. }
  6419. var respJSON3 map[string]interface{}
  6420. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6423. return
  6424. }
  6425. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6426. userJSONBytes3, _ := json.Marshal(respJSON3)
  6427. fmt.Println("log")
  6428. fmt.Println(string(userJSONBytes3))
  6429. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6430. utils.ErrorLog("解析失败:%v", err)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. return
  6433. }
  6434. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6435. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6436. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6437. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6438. resp3, requestErr3 := http.Get(api3)
  6439. if requestErr3 != nil {
  6440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6441. return
  6442. }
  6443. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6444. if ioErr3 != nil {
  6445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6447. return
  6448. }
  6449. var respJSON3 map[string]interface{}
  6450. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6453. return
  6454. }
  6455. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6456. userJSONBytes3, _ := json.Marshal(respJSON3)
  6457. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6458. utils.ErrorLog("解析失败:%v", err)
  6459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6460. return
  6461. }
  6462. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6463. res.Output = resSixteen10265.Output
  6464. res.ErrMsg = resSixteen10265.ErrMsg
  6465. res.Cainfo = resSixteen10265.Cainfo
  6466. res.WarnMsg = resSixteen10265.WarnMsg
  6467. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6468. res.Infcode = infocode
  6469. } else {
  6470. if miConfig.Code == "H15049901371" {
  6471. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6472. var dat map[string]interface{}
  6473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6474. fmt.Println(dat)
  6475. } else {
  6476. fmt.Println(err)
  6477. }
  6478. saveLog(result, src_resquest, "2208", "退费")
  6479. userJSONBytes, _ := json.Marshal(dat)
  6480. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6481. utils.ErrorLog("解析失败:%v", err)
  6482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6483. return
  6484. }
  6485. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6486. res.Output = resSixteen10265.Output
  6487. res.ErrMsg = resSixteen10265.ErrMsg
  6488. res.Cainfo = resSixteen10265.Cainfo
  6489. res.WarnMsg = resSixteen10265.WarnMsg
  6490. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6491. res.Infcode = infocode
  6492. } else {
  6493. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6494. var dat map[string]interface{}
  6495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6496. fmt.Println(dat)
  6497. } else {
  6498. fmt.Println(err)
  6499. }
  6500. saveLog(result, src_resquest, "2208", "退费")
  6501. userJSONBytes, _ := json.Marshal(dat)
  6502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6503. utils.ErrorLog("解析失败:%v", err)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. }
  6508. }
  6509. if res.Infcode == 0 {
  6510. var res2 ResultSix
  6511. var resSix10265 ResultSix10265
  6512. if miConfig.MdtrtareaAdmvs == "421300" {
  6513. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6514. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6516. resp3, requestErr3 := http.Get(api3)
  6517. if requestErr3 != nil {
  6518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6519. return
  6520. }
  6521. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6522. if ioErr3 != nil {
  6523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. return
  6526. }
  6527. var respJSON3 map[string]interface{}
  6528. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6531. return
  6532. }
  6533. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6534. userJSONBytes3, _ := json.Marshal(respJSON3)
  6535. fmt.Println("log")
  6536. fmt.Println(string(userJSONBytes3))
  6537. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6538. utils.ErrorLog("解析失败:%v", err)
  6539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6540. return
  6541. }
  6542. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6543. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6544. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6545. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6546. resp3, requestErr3 := http.Get(api3)
  6547. if requestErr3 != nil {
  6548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6549. return
  6550. }
  6551. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6552. if ioErr3 != nil {
  6553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6555. return
  6556. }
  6557. var respJSON3 map[string]interface{}
  6558. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6561. return
  6562. }
  6563. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6564. userJSONBytes3, _ := json.Marshal(respJSON3)
  6565. fmt.Println("log")
  6566. fmt.Println(string(userJSONBytes3))
  6567. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6568. utils.ErrorLog("解析失败:%v", err)
  6569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6570. return
  6571. }
  6572. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6573. res2.Output = resSix10265.Output
  6574. res2.ErrMsg = resSix10265.ErrMsg
  6575. res2.Cainfo = resSix10265.Cainfo
  6576. res2.WarnMsg = resSix10265.WarnMsg
  6577. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6578. res2.Infcode = infocode
  6579. } else {
  6580. if miConfig.Code == "H15049901371" {
  6581. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6582. var dat map[string]interface{}
  6583. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6584. fmt.Println(dat)
  6585. } else {
  6586. fmt.Println(err)
  6587. }
  6588. saveLog(result2, src_request, "2205", "撤销明细")
  6589. userJSONBytes, _ := json.Marshal(dat)
  6590. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6591. utils.ErrorLog("解析失败:%v", err)
  6592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6593. return
  6594. }
  6595. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6596. res2.Output = resSix10265.Output
  6597. res2.ErrMsg = resSix10265.ErrMsg
  6598. res2.Cainfo = resSix10265.Cainfo
  6599. res2.WarnMsg = resSix10265.WarnMsg
  6600. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6601. res2.Infcode = infocode
  6602. } else {
  6603. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6604. var dat map[string]interface{}
  6605. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6606. fmt.Println(dat)
  6607. } else {
  6608. fmt.Println(err)
  6609. }
  6610. saveLog(result2, src_request, "2205", "撤销明细")
  6611. userJSONBytes, _ := json.Marshal(dat)
  6612. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6613. utils.ErrorLog("解析失败:%v", err)
  6614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6615. return
  6616. }
  6617. }
  6618. }
  6619. if res2.Infcode == 0 {
  6620. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6621. if err == nil {
  6622. c.ServeSuccessJSON(map[string]interface{}{
  6623. "msg": "退费成功",
  6624. })
  6625. } else {
  6626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6627. return
  6628. }
  6629. } else {
  6630. c.ServeSuccessJSON(map[string]interface{}{
  6631. "code": -10,
  6632. "msg": res2.ErrMsg,
  6633. })
  6634. }
  6635. } else {
  6636. c.ServeSuccessJSON(map[string]interface{}{
  6637. "code": -10,
  6638. "msg": res.ErrMsg,
  6639. })
  6640. }
  6641. }
  6642. }
  6643. func (c *HisApiController) RefundNumber() {
  6644. record_time := c.GetString("record_time")
  6645. //patient_id, _ := c.GetInt64("patient_id")
  6646. admin_user_id, _ := c.GetInt64("admin_user_id")
  6647. his_patient_id, _ := c.GetInt64("id")
  6648. timeLayout := "2006-01-02"
  6649. loc, _ := time.LoadLocation("Local")
  6650. adminUser := c.GetAdminUserInfo()
  6651. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6652. fmt.Println(err)
  6653. if err != nil {
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6655. return
  6656. }
  6657. recordDateTime := theTime.Unix()
  6658. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6659. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6660. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6661. //order, _ := service.GetHisOrderByID(order_id)
  6662. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6663. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6664. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6665. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6666. if count > 0 {
  6667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6668. return
  6669. }
  6670. if config.IsOpen == 1 { //对接了医保,走医保流程
  6671. var res2 ResultSix
  6672. var resSix10265 ResultSix10265
  6673. if miConfig.MdtrtareaAdmvs == "421300" {
  6674. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6675. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6677. resp3, requestErr3 := http.Get(api3)
  6678. if requestErr3 != nil {
  6679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6680. return
  6681. }
  6682. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6683. if ioErr3 != nil {
  6684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6686. return
  6687. }
  6688. var respJSON3 map[string]interface{}
  6689. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6692. return
  6693. }
  6694. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6695. userJSONBytes3, _ := json.Marshal(respJSON3)
  6696. fmt.Println("log")
  6697. fmt.Println(string(userJSONBytes3))
  6698. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6699. utils.ErrorLog("解析失败:%v", err)
  6700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. return
  6702. }
  6703. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6704. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6705. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6707. resp3, requestErr3 := http.Get(api3)
  6708. if requestErr3 != nil {
  6709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6710. return
  6711. }
  6712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6713. if ioErr3 != nil {
  6714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6716. return
  6717. }
  6718. var respJSON3 map[string]interface{}
  6719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6722. return
  6723. }
  6724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6725. userJSONBytes3, _ := json.Marshal(respJSON3)
  6726. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6727. utils.ErrorLog("解析失败:%v", err)
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6729. return
  6730. }
  6731. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6732. res2.Output = resSix10265.Output
  6733. res2.ErrMsg = resSix10265.ErrMsg
  6734. res2.Cainfo = resSix10265.Cainfo
  6735. res2.WarnMsg = resSix10265.WarnMsg
  6736. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6737. res2.Infcode = infocode
  6738. } else {
  6739. var api3 string
  6740. if miConfig.Code == "H15049901371" {
  6741. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6742. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6743. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6744. } else {
  6745. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6746. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6747. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6748. }
  6749. resp3, requestErr3 := http.Get(api3)
  6750. if requestErr3 != nil {
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. return
  6753. }
  6754. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6755. if ioErr3 != nil {
  6756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6758. return
  6759. }
  6760. var respJSON3 map[string]interface{}
  6761. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6764. return
  6765. }
  6766. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6767. userJSONBytes3, _ := json.Marshal(respJSON3)
  6768. if miConfig.Code == "H15049901371" {
  6769. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6770. utils.ErrorLog("解析失败:%v", err)
  6771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6772. return
  6773. }
  6774. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6775. res2.Output = resSix10265.Output
  6776. res2.ErrMsg = resSix10265.ErrMsg
  6777. res2.Cainfo = resSix10265.Cainfo
  6778. res2.WarnMsg = resSix10265.WarnMsg
  6779. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6780. res2.Infcode = infocode
  6781. } else {
  6782. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6783. utils.ErrorLog("解析失败:%v", err)
  6784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6785. return
  6786. }
  6787. }
  6788. }
  6789. if res2.Infcode == 0 {
  6790. if err == nil {
  6791. c.ServeSuccessJSON(map[string]interface{}{
  6792. "msg": "退号成功",
  6793. })
  6794. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6795. } else {
  6796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6797. return
  6798. }
  6799. } else {
  6800. c.ServeSuccessJSON(map[string]interface{}{
  6801. "code": -10,
  6802. "msg": res2.ErrMsg,
  6803. })
  6804. }
  6805. } else {
  6806. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6807. //if err == nil {
  6808. // c.ServeSuccessJSON(map[string]interface{}{
  6809. // "msg": "退费成功",
  6810. // })
  6811. //} else {
  6812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6813. // return
  6814. //}
  6815. }
  6816. }
  6817. func (c *HisApiController) RefundDetail() {
  6818. order_id, _ := c.GetInt64("order_id")
  6819. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6820. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6821. number := c.GetString("number")
  6822. record_time := c.GetString("record_time")
  6823. patient_id, _ := c.GetInt64("patient_id")
  6824. timeLayout := "2006-01-02"
  6825. loc, _ := time.LoadLocation("Local")
  6826. adminUser := c.GetAdminUserInfo()
  6827. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6828. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6829. fmt.Println(err)
  6830. if err != nil {
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6832. return
  6833. }
  6834. recordDateTime := theTime.Unix()
  6835. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6836. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6837. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6838. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6839. var order models.HisOrder
  6840. order, _ = service.GetHisOrderByID(order_id)
  6841. if order.ID == 0 {
  6842. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6843. }
  6844. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6845. if config.IsOpen == 1 { //对接了医保,走医保流程
  6846. var res2 ResultSix
  6847. if miConfig.MdtrtareaAdmvs == "421300" {
  6848. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6849. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6850. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6851. resp3, requestErr3 := http.Get(api3)
  6852. if requestErr3 != nil {
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. return
  6855. }
  6856. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6857. if ioErr3 != nil {
  6858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6860. return
  6861. }
  6862. var respJSON3 map[string]interface{}
  6863. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6866. return
  6867. }
  6868. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6869. userJSONBytes3, _ := json.Marshal(respJSON3)
  6870. fmt.Println("log")
  6871. fmt.Println(string(userJSONBytes3))
  6872. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6873. utils.ErrorLog("解析失败:%v", err)
  6874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6875. return
  6876. }
  6877. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6878. if err == nil {
  6879. c.ServeSuccessJSON(map[string]interface{}{
  6880. "msg": "撤销明细成功",
  6881. })
  6882. return
  6883. } else {
  6884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6885. return
  6886. }
  6887. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6888. var resSix10265 ResultSix10265
  6889. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6890. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6891. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6892. resp3, requestErr3 := http.Get(api3)
  6893. if requestErr3 != nil {
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6898. if ioErr3 != nil {
  6899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. var respJSON3 map[string]interface{}
  6904. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6910. userJSONBytes3, _ := json.Marshal(respJSON3)
  6911. fmt.Println("log")
  6912. fmt.Println(string(userJSONBytes3))
  6913. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6919. res2.Output = resSix10265.Output
  6920. res2.ErrMsg = resSix10265.ErrMsg
  6921. res2.Cainfo = resSix10265.Cainfo
  6922. res2.WarnMsg = resSix10265.WarnMsg
  6923. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6924. res2.Infcode = infocode
  6925. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6926. if err == nil {
  6927. c.ServeSuccessJSON(map[string]interface{}{
  6928. "msg": "撤销明细成功",
  6929. })
  6930. return
  6931. } else {
  6932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6933. return
  6934. }
  6935. } else {
  6936. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6937. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6939. resp2, requestErr2 := http.Get(api2)
  6940. if requestErr2 != nil {
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. return
  6943. }
  6944. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6945. if ioErr2 != nil {
  6946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. return
  6949. }
  6950. var respJSON2 map[string]interface{}
  6951. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6957. if err == nil {
  6958. c.ServeSuccessJSON(map[string]interface{}{
  6959. "msg": "撤销明细成功",
  6960. })
  6961. return
  6962. } else {
  6963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6964. return
  6965. }
  6966. }
  6967. } else {
  6968. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6969. if err == nil {
  6970. c.ServeSuccessJSON(map[string]interface{}{
  6971. "msg": "退费成功",
  6972. })
  6973. } else {
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. }
  6978. }
  6979. //对账
  6980. func (c *HisApiController) GetCheckAccount() {
  6981. start_time := c.GetString("start_time")
  6982. end_time := c.GetString("end_time")
  6983. insutype := c.GetString("insutype")
  6984. clr_type := c.GetString("clr_type")
  6985. clr_org := c.GetString("clr_optins")
  6986. admin_user_id, _ := c.GetInt64("admin_user_id")
  6987. adminUser := c.GetAdminUserInfo()
  6988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6989. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6990. if len(clr_org) == 0 {
  6991. clr_org = miConfig.MdtrtareaAdmvs
  6992. }
  6993. timeLayout := "2006-01-02"
  6994. loc, _ := time.LoadLocation("Local")
  6995. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6996. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6997. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6998. fixmedins_setl_cnt := int64(len(orders))
  6999. var medfee_sumamt float64
  7000. var acct_pay float64
  7001. var fund_pay_sumamt float64
  7002. for _, item := range orders {
  7003. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7004. acct_pay = acct_pay + item.AcctPay
  7005. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7006. }
  7007. var user_name string
  7008. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7009. if role.ID == 0 {
  7010. user_name = "xxx"
  7011. } else {
  7012. user_name = role.UserName
  7013. }
  7014. var res ResultEight
  7015. var res10188 ResultEightFor10188
  7016. if config.IsOpen == 1 {
  7017. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7018. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  7019. "insutype=" + insutype +
  7020. "&clr_type=" + "11" +
  7021. "&setl_optins=" + clr_org +
  7022. "&stmt_begndate=" + start_time +
  7023. "&stm_enddate=" + end_time +
  7024. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7025. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7026. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7027. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7028. "&fixmedins_code=" + miConfig.Code +
  7029. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7030. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7031. "&secret_key=" + miConfig.SecretKey +
  7032. "&org_name=" + miConfig.OrgName +
  7033. "&doctor=" + user_name +
  7034. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7035. fmt.Println(api)
  7036. resp, requestErr := http.Get(api)
  7037. if requestErr != nil {
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. body, ioErr := ioutil.ReadAll(resp.Body)
  7042. fmt.Println(body)
  7043. if ioErr != nil {
  7044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. var respJSON map[string]interface{}
  7049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7055. userJSONBytes, _ := json.Marshal(respJSON)
  7056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7057. utils.ErrorLog("解析失败:%v", err)
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. return
  7060. }
  7061. res.InfRefmsgid = res10188.InfRefmsgid
  7062. res.Output = res10188.Output
  7063. res.ErrMsg = res10188.ErrMsg
  7064. res.Cainfo = res10188.Cainfo
  7065. res.WarnMsg = res10188.WarnMsg
  7066. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7067. res.Infcode = infocode
  7068. } else {
  7069. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7070. "insutype=" + insutype +
  7071. "&clr_type=" + clr_type +
  7072. "&setl_optins=" + clr_org +
  7073. "&stmt_begndate=" + start_time +
  7074. "&stm_enddate=" + end_time +
  7075. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7076. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7077. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7078. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7079. "&fixmedins_code=" + miConfig.Code +
  7080. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7081. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7082. "&secret_key=" + miConfig.SecretKey +
  7083. "&org_name=" + miConfig.OrgName +
  7084. "&doctor=" + user_name
  7085. fmt.Println(api)
  7086. resp, requestErr := http.Get(api)
  7087. if requestErr != nil {
  7088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7089. return
  7090. }
  7091. body, ioErr := ioutil.ReadAll(resp.Body)
  7092. fmt.Println(body)
  7093. if ioErr != nil {
  7094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. return
  7097. }
  7098. var respJSON map[string]interface{}
  7099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7105. userJSONBytes, _ := json.Marshal(respJSON)
  7106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7107. utils.ErrorLog("解析失败:%v", err)
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. return
  7110. }
  7111. }
  7112. if res.Infcode == 0 {
  7113. if res.Output.Stmtinfo.StmtRslt == "0" {
  7114. micc := &models.MedicalInsuranceCostCompare{
  7115. StartTime: startime.Unix(),
  7116. EndTime: endtime.Unix(),
  7117. Insutype: insutype,
  7118. CheckType: 1,
  7119. Num: fixmedins_setl_cnt,
  7120. Mtime: time.Now().Unix(),
  7121. Status: 1,
  7122. UserOrgId: adminUser.CurrentOrgId,
  7123. CostTotal: medfee_sumamt,
  7124. FuncTotal: fund_pay_sumamt,
  7125. PsnPay: acct_pay,
  7126. Creator: admin_user_id,
  7127. Ctime: time.Now().Unix(),
  7128. }
  7129. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7130. if err == nil {
  7131. c.ServeSuccessJSON(map[string]interface{}{
  7132. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7133. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7134. })
  7135. } else {
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. }
  7138. } else {
  7139. c.ServeSuccessJSON(map[string]interface{}{
  7140. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7141. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7142. })
  7143. }
  7144. } else {
  7145. c.ServeSuccessJSON(map[string]interface{}{
  7146. "code": -10,
  7147. "msg": res.ErrMsg,
  7148. })
  7149. }
  7150. }
  7151. }
  7152. func (c *HisApiController) Check310() {
  7153. adminUser := c.GetAdminUserInfo()
  7154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7155. var user_name string
  7156. user_name = "高慧裕"
  7157. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7158. "insutype=" + "310" +
  7159. "&clr_type=" + "" +
  7160. "&setl_optins=" + "441202" +
  7161. "&stmt_begndate=" + "2022-03-01" +
  7162. "&stm_enddate=" + "2022-03-31" +
  7163. "&medfee_sumamt=" + "194930.12" +
  7164. "&fund_pay_sumamt=" + "188741.46" +
  7165. "&acct_pay=" + "0" +
  7166. "&fixmedins_setl_cnt=" + "452" +
  7167. "&fixmedins_code=" + miConfig.Code +
  7168. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7169. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7170. "&secret_key=" + miConfig.SecretKey +
  7171. "&org_name=" + miConfig.OrgName +
  7172. "&doctor=" + user_name
  7173. fmt.Println(api)
  7174. resp, requestErr := http.Get(api)
  7175. if requestErr != nil {
  7176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. return
  7178. }
  7179. body, ioErr := ioutil.ReadAll(resp.Body)
  7180. fmt.Println(body)
  7181. if ioErr != nil {
  7182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. return
  7185. }
  7186. var respJSON map[string]interface{}
  7187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7190. return
  7191. }
  7192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7193. userJSONBytes, _ := json.Marshal(respJSON)
  7194. var res ResultEight
  7195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7196. utils.ErrorLog("解析失败:%v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. }
  7201. func (c *HisApiController) Check390() {
  7202. adminUser := c.GetAdminUserInfo()
  7203. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7204. var user_name string
  7205. user_name = "高慧裕"
  7206. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7207. "insutype=" + "390" +
  7208. "&clr_type=" + "" +
  7209. "&setl_optins=" + "441202" +
  7210. "&stmt_begndate=" + "2022-03-01" +
  7211. "&stm_enddate=" + "2022-03-31" +
  7212. "&medfee_sumamt=" + "1068448.89" +
  7213. "&fund_pay_sumamt=" + "1014677.62" +
  7214. "&acct_pay=" + "0" +
  7215. "&fixmedins_setl_cnt=" + "1950" +
  7216. "&fixmedins_code=" + miConfig.Code +
  7217. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7218. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7219. "&secret_key=" + miConfig.SecretKey +
  7220. "&org_name=" + miConfig.OrgName +
  7221. "&doctor=" + user_name
  7222. fmt.Println(api)
  7223. resp, requestErr := http.Get(api)
  7224. if requestErr != nil {
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. return
  7227. }
  7228. body, ioErr := ioutil.ReadAll(resp.Body)
  7229. fmt.Println(body)
  7230. if ioErr != nil {
  7231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7233. return
  7234. }
  7235. var respJSON map[string]interface{}
  7236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7239. return
  7240. }
  7241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7242. userJSONBytes, _ := json.Marshal(respJSON)
  7243. var res ResultEight
  7244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7245. utils.ErrorLog("解析失败:%v", err)
  7246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7247. return
  7248. }
  7249. }
  7250. //对账明细
  7251. func (c *HisApiController) GetCheckDetailAccount() {
  7252. start_time := c.GetString("start_time")
  7253. end_time := c.GetString("end_time")
  7254. admin_user_id, _ := c.GetInt64("admin_user_id")
  7255. adminUser := c.GetAdminUserInfo()
  7256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7257. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7258. timeLayout := "2006-01-02"
  7259. loc, _ := time.LoadLocation("Local")
  7260. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7261. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7262. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7263. Mkdir(miConfig.OrgName)
  7264. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7265. file_name := file + ".txt"
  7266. zip_name := file + ".zip"
  7267. zip_path := miConfig.OrgName + "/" + zip_name
  7268. file_path := miConfig.OrgName + "/" + file_name
  7269. decimal.DivisionPrecision = 2
  7270. var medfee_sumamt float64
  7271. var psn_cash_pay float64
  7272. var fund_pay_sumamt float64
  7273. fixmedins_setl_cnt := int64(len(orders))
  7274. for _, item := range orders {
  7275. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7276. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7277. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7278. }
  7279. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7280. defer f.Close()
  7281. if err != nil {
  7282. fmt.Println(err.Error())
  7283. } else {
  7284. for _, item := range orders {
  7285. var refd_setl_flag string
  7286. if item.OrderStatus == 2 {
  7287. refd_setl_flag = "0"
  7288. var str string
  7289. str = item.SetlId + " " +
  7290. item.MdtrtId + " " +
  7291. item.PsnNo + " " +
  7292. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7293. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7294. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7295. _, err = f.Write([]byte(str))
  7296. }
  7297. if item.OrderStatus == 3 {
  7298. var str string
  7299. str = item.SetlId + " " +
  7300. item.MdtrtId + " " +
  7301. item.PsnNo + " " +
  7302. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7303. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7304. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7305. _, err = f.Write([]byte(str))
  7306. var str2 string
  7307. str2 = item.SetlId + " " +
  7308. item.MdtrtId + " " +
  7309. item.PsnNo + " " +
  7310. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7311. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7312. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7313. _, err = f.Write([]byte(str2))
  7314. }
  7315. }
  7316. }
  7317. Zip(file_path, zip_path)
  7318. fmt.Println(ReadFile(zip_path))
  7319. fmt.Println(string(ReadFile(zip_path)))
  7320. if config.IsOpen == 1 {
  7321. var user_name string
  7322. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7323. if role.ID == 0 {
  7324. user_name = "管理员"
  7325. } else {
  7326. user_name = role.UserName
  7327. }
  7328. baseParams := models.BaseParams{
  7329. SecretKey: miConfig.SecretKey,
  7330. FixmedinsCode: miConfig.Code,
  7331. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7332. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7333. OrgName: miConfig.OrgName,
  7334. Doctor: user_name,
  7335. }
  7336. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7337. var dat map[string]interface{}
  7338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7339. fmt.Println(dat)
  7340. } else {
  7341. fmt.Println(err)
  7342. }
  7343. userJSONBytes, _ := json.Marshal(dat)
  7344. var res ResultNine
  7345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7346. utils.ErrorLog("解析失败:%v", err)
  7347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7348. return
  7349. }
  7350. if res.Infcode == 0 {
  7351. fileNo := res.Output.FileQuryNo
  7352. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7353. "file_qury_no=" + fileNo +
  7354. "&setl_optins=" + "定点医保中心" +
  7355. "&stmt_begndate=" + start_time +
  7356. "&stm_enddate=" + end_time +
  7357. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7358. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7359. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7360. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7361. "&fixmedins_code=" + miConfig.Code +
  7362. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7363. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7364. "&secret_key=" + miConfig.SecretKey +
  7365. "&org_name=" + miConfig.OrgName +
  7366. "&doctor=" + user_name
  7367. resp, requestErr := http.Get(api)
  7368. if requestErr != nil {
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. return
  7371. }
  7372. body, ioErr := ioutil.ReadAll(resp.Body)
  7373. if ioErr != nil {
  7374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7376. return
  7377. }
  7378. var respJSON map[string]interface{}
  7379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7382. return
  7383. }
  7384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7385. userJSONBytes, _ := json.Marshal(respJSON)
  7386. var res ResultTen
  7387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7388. utils.ErrorLog("解析失败:%v", err)
  7389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7390. return
  7391. }
  7392. if res.Infcode == 0 {
  7393. service.Gdyb9102(baseParams, zip_name, fileNo)
  7394. micc := &models.MedicalInsuranceCostCompare{
  7395. StartTime: startime.Unix(),
  7396. EndTime: endtime.Unix(),
  7397. Insutype: "0",
  7398. CheckType: 2,
  7399. Num: fixmedins_setl_cnt,
  7400. Mtime: time.Now().Unix(),
  7401. Status: 1,
  7402. UserOrgId: adminUser.CurrentOrgId,
  7403. CostTotal: medfee_sumamt,
  7404. FuncTotal: fund_pay_sumamt,
  7405. PsnPay: psn_cash_pay,
  7406. Creator: admin_user_id,
  7407. Ctime: time.Now().Unix(),
  7408. }
  7409. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7410. c.ServeSuccessJSON(map[string]interface{}{
  7411. "msg": "明细对账成功",
  7412. })
  7413. }
  7414. } else {
  7415. }
  7416. }
  7417. }
  7418. type CustomOrderInfo struct {
  7419. Name string
  7420. Spec string
  7421. Unit string
  7422. Count float64
  7423. Price float64
  7424. Total float64
  7425. }
  7426. func (c *HisApiController) GetSettleAccounts() {
  7427. //id, _ := c.GetInt64("id")
  7428. //record_time := c.GetString("record_time")
  7429. order_id, _ := c.GetInt64("order_id")
  7430. admin_user_id, _ := c.GetInt64("admin_user_id")
  7431. //timeLayout := "2006-01-02"
  7432. //loc, _ := time.LoadLocation("Local")
  7433. //
  7434. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7435. //if err != nil {
  7436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7437. // return
  7438. //}
  7439. //recordDateTime := theTime.Unix()
  7440. adminUser := c.GetAdminUserInfo()
  7441. order, _ := service.GetHisOrderByID(order_id)
  7442. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7443. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7444. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7445. orderInfos = append(orderInfos, orderInfos_two...)
  7446. //his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7447. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7448. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7449. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7450. //var config []*models.HisXtDiagnoseConfig
  7451. var name string
  7452. for _, item := range diagnosis_ids {
  7453. id, _ := strconv.ParseInt(item, 10, 64)
  7454. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7455. if len(name) == 0 {
  7456. name = diagnosisConfig.ClassName
  7457. } else {
  7458. name = name + "," + diagnosisConfig.ClassName
  7459. }
  7460. }
  7461. var bedCostTotal float64 = 0 //床位总费
  7462. var bedCostSelfTotal float64 = 0 //床位自费
  7463. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7464. var operationCostTotal float64 = 0 //手术费
  7465. var operationCostSelfTotal float64 = 0 //手术费
  7466. var operationCostPartSelfTotal float64 = 0 //手术费
  7467. var otherCostTotal float64 = 0 //其他费用
  7468. var otherCostSelfTotal float64 = 0 //其他费用
  7469. var otherCostPartSelfTotal float64 = 0 //其他费用
  7470. var materialCostTotal float64 = 0 //材料费
  7471. var materialCostSelfTotal float64 = 0 //材料费
  7472. var materialCostPartSelfTotal float64 = 0 //材料费
  7473. var westernMedicineCostTotal float64 = 0 //西药费
  7474. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7475. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7476. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7477. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7478. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7479. var checkCostTotal float64 = 0 //检查费
  7480. var checkCostSelfTotal float64 = 0 //检查费
  7481. var checkCostPartSelfTotal float64 = 0 //检查费
  7482. var laboratoryCostTotal float64 = 0 //化验费
  7483. var laboratoryCostSelfTotal float64 = 0 //化验费
  7484. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7485. var treatCostTotal float64 = 0 //治疗费用
  7486. var treatCostSelfTotal float64 = 0 //治疗费用
  7487. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7488. decimal.DivisionPrecision = 2
  7489. for _, item := range orderInfos {
  7490. if item.MedChrgitmType == "01" { //床位费
  7491. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7492. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7493. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7494. }
  7495. if item.MedChrgitmType == "03" { //检查费
  7496. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7497. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7498. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7499. }
  7500. if item.MedChrgitmType == "04" { //化验费
  7501. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7502. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7503. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7504. }
  7505. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7506. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7507. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7508. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7509. }
  7510. if item.MedChrgitmType == "06" { //手术费
  7511. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7512. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7513. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7514. }
  7515. if item.MedChrgitmType == "08" { //材料费
  7516. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7517. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7518. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7519. }
  7520. if item.MedChrgitmType == "09" { //西药费
  7521. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7522. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7523. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7524. }
  7525. if item.MedChrgitmType == "11" { //中成费
  7526. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7527. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7528. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7529. }
  7530. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7531. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7532. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7533. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7534. }
  7535. }
  7536. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7537. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7538. var user_name string
  7539. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7540. if role.ID == 0 {
  7541. user_name = "管理员"
  7542. } else {
  7543. user_name = role.UserName
  7544. }
  7545. baseParams := models.BaseParams{
  7546. SecretKey: miConfig.SecretKey,
  7547. FixmedinsCode: miConfig.Code,
  7548. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7549. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7550. OrgName: miConfig.OrgName,
  7551. Doctor: user_name,
  7552. }
  7553. businessParams := models.BusinessParams{
  7554. PsnNo: order.PsnNo,
  7555. MdtrtId: order.MdtrtId,
  7556. SetlId: order.SetlId,
  7557. }
  7558. var res ResultEleven
  7559. var resEleven10265 ResultEleven10265
  7560. if config.IsOpen == 1 {
  7561. if miConfig.MdtrtareaAdmvs == "421300" {
  7562. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7563. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7564. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7565. resp, requestErr := http.Get(api)
  7566. if requestErr != nil {
  7567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7568. return
  7569. }
  7570. body, ioErr := ioutil.ReadAll(resp.Body)
  7571. if ioErr != nil {
  7572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. var respJSON map[string]interface{}
  7577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. return
  7581. }
  7582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7583. result, _ := json.Marshal(respJSON)
  7584. fmt.Println("log")
  7585. fmt.Println(string(result))
  7586. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7587. utils.ErrorLog("解析失败:%v", err)
  7588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7589. return
  7590. }
  7591. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7592. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7593. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7594. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7595. resp, requestErr := http.Get(api)
  7596. if requestErr != nil {
  7597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7598. return
  7599. }
  7600. body, ioErr := ioutil.ReadAll(resp.Body)
  7601. if ioErr != nil {
  7602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7604. return
  7605. }
  7606. var respJSON map[string]interface{}
  7607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7610. return
  7611. }
  7612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7613. result, _ := json.Marshal(respJSON)
  7614. fmt.Println("log")
  7615. fmt.Println(string(result))
  7616. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7617. utils.ErrorLog("解析失败:%v", err)
  7618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7619. return
  7620. }
  7621. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7622. res.Output = resEleven10265.Output
  7623. res.ErrMsg = resEleven10265.ErrMsg
  7624. res.Cainfo = resEleven10265.Cainfo
  7625. res.WarnMsg = resEleven10265.WarnMsg
  7626. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7627. res.Infcode = infocode
  7628. } else {
  7629. result2 := service.Gdyb5204(baseParams, businessParams)
  7630. saveLog(result2, "", "5204", "查询")
  7631. result := service.Gdyb5203(baseParams, businessParams)
  7632. var dat map[string]interface{}
  7633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7634. fmt.Println(dat)
  7635. } else {
  7636. fmt.Println(err)
  7637. }
  7638. userJSONBytes, _ := json.Marshal(dat)
  7639. if miConfig.Code == "H15049901371" {
  7640. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7641. utils.ErrorLog("解析失败:%v", err)
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. return
  7644. }
  7645. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7646. res.Output = resEleven10265.Output
  7647. res.ErrMsg = resEleven10265.ErrMsg
  7648. res.Cainfo = resEleven10265.Cainfo
  7649. res.WarnMsg = resEleven10265.WarnMsg
  7650. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7651. res.Infcode = infocode
  7652. } else {
  7653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7654. utils.ErrorLog("解析失败:%v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. }
  7659. }
  7660. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7661. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7662. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7663. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7664. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7665. var doctor_name string
  7666. if roles.ID == 0 {
  7667. doctor_name = "管理员"
  7668. } else {
  7669. doctor_name = roles.UserName
  7670. }
  7671. yiliao_leibie := ""
  7672. switch order.MedType {
  7673. case "11":
  7674. yiliao_leibie = "普通门诊"
  7675. break
  7676. case "12":
  7677. yiliao_leibie = "门诊挂号"
  7678. break
  7679. case "13":
  7680. yiliao_leibie = "急诊"
  7681. break
  7682. case "14":
  7683. yiliao_leibie = "门诊特殊病"
  7684. break
  7685. case "15":
  7686. yiliao_leibie = "门诊统筹"
  7687. break
  7688. case "16":
  7689. yiliao_leibie = "门诊慢性病"
  7690. break
  7691. case "21":
  7692. yiliao_leibie = "普通住院"
  7693. break
  7694. }
  7695. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7696. if res.Infcode == 0 {
  7697. c.ServeSuccessJSON(map[string]interface{}{
  7698. "diagnosis": name,
  7699. "order_infos": orderInfos,
  7700. "number": order.MdtrtId,
  7701. "date": order.SettleAccountsDate,
  7702. "charge_admin": charge_admin,
  7703. "printor_admin": printor_admin,
  7704. "info": res.Output.Setlinfo,
  7705. "bedCostTotal": bedCostTotal,
  7706. "bedCostSelfTotal": bedCostSelfTotal,
  7707. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7708. "operationCostTotal": operationCostTotal,
  7709. "operationCostSelfTotal": operationCostSelfTotal,
  7710. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7711. "otherCostTotal": otherCostTotal,
  7712. "otherCostSelfTotal": otherCostSelfTotal,
  7713. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7714. "materialCostTotal": materialCostTotal,
  7715. "materialCostSelfTotal": materialCostSelfTotal,
  7716. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7717. "westernMedicineCostTotal": westernMedicineCostTotal,
  7718. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7719. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7720. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7721. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7722. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7723. "checkCostTotal": checkCostTotal,
  7724. "checkCostSelfTotal": checkCostSelfTotal,
  7725. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7726. "laboratoryCostTotal": laboratoryCostTotal,
  7727. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7728. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7729. "treatCostTotal": treatCostTotal,
  7730. "treatCostSelfTotal": treatCostSelfTotal,
  7731. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7732. "doctor_code": adminRole_two.DoctorCode,
  7733. "doctor_name": doctor_name,
  7734. "health_card_no": order.PsnNo,
  7735. "department": departments.Name,
  7736. "yiliao_leibie": yiliao_leibie,
  7737. "after_money": order.AccountPrice,
  7738. "patient": patient,
  7739. "org_name": miConfig.OrgName,
  7740. "org_code": miConfig.Code,
  7741. "order_number": order.Number,
  7742. //"his": his_hospital,
  7743. //"check_order_info": cus_slice,
  7744. })
  7745. }
  7746. }
  7747. }
  7748. func (c *HisApiController) CheckTreatment() {
  7749. patient_id, _ := c.GetInt64("patient_id")
  7750. id_card_no := c.GetString("id_card_no")
  7751. insutype := c.GetString("insutype")
  7752. med_type := c.GetString("med_type")
  7753. admin_user_id, _ := c.GetInt64("admin_user_id")
  7754. adminUser := c.GetAdminUserInfo()
  7755. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7756. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7757. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7758. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7759. if miConfig.MdtrtareaAdmvs == "421300" {
  7760. var res ResultTwo
  7761. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7762. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7763. "&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)
  7764. resp, requestErr := http.Get(api)
  7765. if requestErr != nil {
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. return
  7768. }
  7769. body, ioErr := ioutil.ReadAll(resp.Body)
  7770. if ioErr != nil {
  7771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7773. return
  7774. }
  7775. var respJSON map[string]interface{}
  7776. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7779. return
  7780. }
  7781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7782. result, _ := json.Marshal(respJSON)
  7783. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7784. utils.ErrorLog("解析失败:%v", err)
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. if res.Infcode == 0 {
  7789. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7790. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7791. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7792. resp, requestErr := http.Get(api)
  7793. if requestErr != nil {
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7795. return
  7796. }
  7797. body, ioErr := ioutil.ReadAll(resp.Body)
  7798. if ioErr != nil {
  7799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. var respJSON map[string]interface{}
  7804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. var res Result2001
  7810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7811. result2, _ := json.Marshal(respJSON)
  7812. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7813. utils.ErrorLog("解析失败:%v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. return
  7816. }
  7817. if res.Infcode == 0 {
  7818. c.ServeSuccessJSON(map[string]interface{}{
  7819. "msg": res.Output.Trtinfo,
  7820. })
  7821. }
  7822. } else {
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7824. return
  7825. }
  7826. } else {
  7827. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7828. var dat map[string]interface{}
  7829. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7830. fmt.Println(dat)
  7831. } else {
  7832. fmt.Println(err)
  7833. }
  7834. userJSONBytes, _ := json.Marshal(dat)
  7835. var res ResultTwo
  7836. var res10265 ResultTwo10265
  7837. if miConfig.Code == "H15049901371" {
  7838. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7839. utils.ErrorLog("解析失败:%v", err)
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7841. return
  7842. }
  7843. res.ErrMsg = res10265.ErrMsg
  7844. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7845. res.Infcode = infocode
  7846. res.Output = res10265.Output
  7847. res.InfRefmsgid = res10265.InfRefmsgid
  7848. } else {
  7849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7850. utils.ErrorLog("解析失败:%v", err)
  7851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7852. return
  7853. }
  7854. }
  7855. var user_name string
  7856. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7857. if role.ID == 0 {
  7858. user_name = "xxx"
  7859. } else {
  7860. user_name = role.UserName
  7861. }
  7862. baseParams := models.BaseParams{
  7863. SecretKey: miConfig.SecretKey,
  7864. FixmedinsCode: miConfig.Code,
  7865. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7866. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7867. OrgName: miConfig.OrgName,
  7868. Doctor: user_name,
  7869. }
  7870. if config.IsOpen == 1 {
  7871. if miConfig.Code == "H15049901371" {
  7872. if med_type == "14" {
  7873. if insutype == "390" {
  7874. med_type = "9933"
  7875. } else if insutype == "310" {
  7876. med_type = "990502"
  7877. }
  7878. } else if med_type == "11" {
  7879. med_type = "11"
  7880. }
  7881. }
  7882. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7883. var dat map[string]interface{}
  7884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7885. fmt.Println(dat)
  7886. } else {
  7887. fmt.Println(err)
  7888. }
  7889. var res Result2001
  7890. var res10265 Result2001Org10265
  7891. if miConfig.Code == "H15049901371" {
  7892. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7893. utils.ErrorLog("解析失败:%v", err)
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7895. return
  7896. }
  7897. res.ErrMsg = res10265.ErrMsg
  7898. res.Output = res10265.Output
  7899. res.InfRefmsgid = res10265.InfRefmsgid
  7900. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7901. res.Infcode = infocode
  7902. } else {
  7903. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7904. utils.ErrorLog("解析失败:%v", err)
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. }
  7909. if res.Infcode == 0 {
  7910. c.ServeSuccessJSON(map[string]interface{}{
  7911. "msg": res.Output.Trtinfo,
  7912. })
  7913. }
  7914. }
  7915. }
  7916. }
  7917. //func (c *HisApiController) PutRecord() {
  7918. // id, _ := c.GetInt64("id")
  7919. // record_time := c.GetString("record_time")
  7920. // timeLayout := "2006-01-02"
  7921. // loc, _ := time.LoadLocation("Local")
  7922. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7923. // if err != nil {
  7924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7925. // return
  7926. // }
  7927. // recordDateTime := theTime.Unix()
  7928. //
  7929. // adminInfo := c.GetAdminUserInfo()
  7930. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7931. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7932. //
  7933. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7934. //
  7935. // fmt.Println(miConfig.SecretKey)
  7936. //
  7937. // if patient == nil {
  7938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7939. // return
  7940. // }
  7941. // if len(patient.IdCardNo) == 0 {
  7942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7943. // return
  7944. // }
  7945. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7946. // if config.IsOpen == 1 {
  7947. // 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
  7948. // resp, requestErr := http.Get(api)
  7949. // if requestErr != nil {
  7950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7951. // return
  7952. // }
  7953. // defer resp.Body.Close()
  7954. // body, ioErr := ioutil.ReadAll(resp.Body)
  7955. // if ioErr != nil {
  7956. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. // return
  7959. // }
  7960. // var respJSON map[string]interface{}
  7961. //
  7962. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7963. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. // return
  7966. // }
  7967. //
  7968. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7969. // userJSONBytes, _ := json.Marshal(userJSON)
  7970. // var res ResultTwo
  7971. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7972. // utils.ErrorLog("解析失败:%v", err)
  7973. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7974. // return
  7975. // }
  7976. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7977. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7978. // infoStr := string(Iinfos)
  7979. // idetinfoStr := string(Idetinfos)
  7980. //
  7981. // if res.Infcode == 0 {
  7982. // his := models.VMHisPatient{
  7983. // Status: 1,
  7984. // Ctime: time.Now().Unix(),
  7985. // Mtime: time.Now().Unix(),
  7986. // PsnNo: res.Output.Baseinfo.PsnNo,
  7987. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7988. // Certno: res.Output.Baseinfo.Certno,
  7989. // PsnName: res.Output.Baseinfo.PsnName,
  7990. // Gend: res.Output.Baseinfo.Gend,
  7991. // Naty: res.Output.Baseinfo.Naty,
  7992. // Brdy: res.Output.Baseinfo.Brdy,
  7993. // Age: res.Output.Baseinfo.Age,
  7994. // Iinfo: infoStr,
  7995. // Idetinfo: idetinfoStr,
  7996. // PatientId: patient.ID,
  7997. // RecordDate: theTime.Unix(),
  7998. // UserOrgId: adminInfo.CurrentOrgId,
  7999. // AdminUserId: adminInfo.AdminUser.Id,
  8000. // IsReturn: 1,
  8001. // }
  8002. //
  8003. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8004. // //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")
  8005. // //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")
  8006. //
  8007. // //var dat map[string]interface{}
  8008. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8009. // // fmt.Println(dat)
  8010. // //} else {
  8011. // // fmt.Println(err)
  8012. // //}
  8013. //
  8014. // var dat2 map[string]interface{}
  8015. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8016. // fmt.Println(dat2)
  8017. // } else {
  8018. // fmt.Println(err)
  8019. // }
  8020. //
  8021. // } else {
  8022. // adminUser := c.GetAdminUserInfo()
  8023. // errlog := &models.HisOrderError{
  8024. // UserOrgId: adminUser.CurrentOrgId,
  8025. // Ctime: time.Now().Unix(),
  8026. // Mtime: time.Now().Unix(),
  8027. // ErrMsg: res.ErrMsg,
  8028. // Status: 1,
  8029. // PatientId: id,
  8030. // RecordTime: recordDateTime,
  8031. // Stage: 1,
  8032. // }
  8033. // service.CreateErrMsgLog(errlog)
  8034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8035. // return
  8036. // }
  8037. // }
  8038. //
  8039. //}
  8040. //func (c *HisApiController) GetUploadDiag() {
  8041. // id, _ := c.GetInt64("id")
  8042. // record_time := c.GetString("record_time")
  8043. //
  8044. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8045. // sick_type, _ := c.GetInt64("sick_type")
  8046. // reg_type, _ := c.GetInt64("reg_type")
  8047. //
  8048. // timeLayout := "2006-01-02"
  8049. // loc, _ := time.LoadLocation("Local")
  8050. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8051. // if err != nil {
  8052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8053. // return
  8054. // }
  8055. //
  8056. // var patientPrescription models.HisPrescriptionInfo
  8057. // recordDateTime := theTime.Unix()
  8058. // adminInfo := c.GetAdminUserInfo()
  8059. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8060. //
  8061. // if patientPrescription.ID == 0 {
  8062. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8063. // }
  8064. //
  8065. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8066. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8067. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8068. // sickConfig, _ := service.FindSickById(sick_type)
  8069. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8070. //
  8071. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8072. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8073. // "&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 +
  8074. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8075. // resp2, requestErr2 := http.Get(api2)
  8076. // if requestErr2 != nil {
  8077. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. // return
  8079. // }
  8080. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8081. // if ioErr2 != nil {
  8082. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8084. // return
  8085. // }
  8086. // var respJSON2 map[string]interface{}
  8087. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8088. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. // return
  8091. // }
  8092. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8093. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8094. //
  8095. // var res2 ResultSix
  8096. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8097. // utils.ErrorLog("解析失败:%v", err)
  8098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. // return
  8100. // }
  8101. // if res2.Infcode != 0 {
  8102. // adminUser := c.GetAdminUserInfo()
  8103. // errlog := &models.HisOrderError{
  8104. // UserOrgId: adminUser.CurrentOrgId,
  8105. // Ctime: time.Now().Unix(),
  8106. // Mtime: time.Now().Unix(),
  8107. // ErrMsg: res2.ErrMsg,
  8108. // Status: 1,
  8109. // PatientId: id,
  8110. // RecordTime: recordDateTime,
  8111. // Stage: 3,
  8112. // }
  8113. // service.CreateErrMsgLog(errlog)
  8114. //
  8115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8116. // return
  8117. // }
  8118. //
  8119. // c.ServeSuccessJSON(map[string]interface{}{
  8120. // "msg": "上传成功",
  8121. // })
  8122. //
  8123. //}
  8124. type QueryResult struct {
  8125. ID int64
  8126. Name string
  8127. Code string
  8128. List_type_code string
  8129. }
  8130. func (c *HisApiController) GetCheckCode() {
  8131. ids_str := c.GetString("ids")
  8132. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8133. ids_arr := strings.Split(ids_str, ",")
  8134. var queryResult []QueryResult
  8135. ids := make([]int64, 0)
  8136. for _, item := range ids_arr {
  8137. id, _ := strconv.ParseInt(item, 10, 64)
  8138. ids = append(ids, id)
  8139. }
  8140. if record_type == 1 {
  8141. drugs, _ := service.GetBatchDrugList(ids)
  8142. for _, item := range drugs {
  8143. result := QueryResult{
  8144. ID: item.ID,
  8145. Name: item.DrugName,
  8146. Code: item.MedicalInsuranceNumber,
  8147. List_type_code: "101",
  8148. }
  8149. queryResult = append(queryResult, result)
  8150. }
  8151. } else if record_type == 2 {
  8152. goods, _ := service.GetBatchGoodInformationList(ids)
  8153. for _, item := range goods {
  8154. result := QueryResult{
  8155. ID: item.ID,
  8156. Name: item.GoodName,
  8157. Code: item.MedicalInsuranceNumber,
  8158. List_type_code: "301",
  8159. }
  8160. queryResult = append(queryResult, result)
  8161. }
  8162. } else if record_type == 3 {
  8163. projects, _ := service.GetBathchMyPorjecgList(ids)
  8164. for _, item := range projects {
  8165. result := QueryResult{
  8166. ID: item.ID,
  8167. Name: item.ProjectName,
  8168. Code: item.MedicalCode,
  8169. List_type_code: "201",
  8170. }
  8171. queryResult = append(queryResult, result)
  8172. }
  8173. }
  8174. admin_user_id, _ := c.GetInt64("admin_user_id")
  8175. adminUser := c.GetAdminUserInfo()
  8176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8177. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8178. var user_name string
  8179. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8180. if role.ID == 0 {
  8181. user_name = "xxx"
  8182. } else {
  8183. user_name = role.UserName
  8184. }
  8185. baseParams := &models.BaseParams{
  8186. SecretKey: miConfig.SecretKey,
  8187. FixmedinsCode: miConfig.Code,
  8188. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8189. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8190. OrgName: miConfig.OrgName,
  8191. Doctor: user_name,
  8192. }
  8193. if config.IsOpen == 1 {
  8194. for _, item := range queryResult {
  8195. var result string
  8196. if record_type == 1 {
  8197. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8198. } else if record_type == 2 {
  8199. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8200. } else if record_type == 3 {
  8201. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8202. }
  8203. var dat map[string]interface{}
  8204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8205. fmt.Println(dat)
  8206. } else {
  8207. fmt.Println(err)
  8208. }
  8209. userJSONBytes, _ := json.Marshal(dat)
  8210. var res ResultSix
  8211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8212. utils.ErrorLog("解析失败:%v", err)
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8214. return
  8215. }
  8216. if res.Infcode == 0 {
  8217. if record_type == 1 {
  8218. service.UpdateBaseDrugById(item.ID)
  8219. } else if record_type == 2 {
  8220. service.UpdateGoodInformaitonByDetail(item.ID)
  8221. } else if record_type == 3 {
  8222. service.UpdateProjectById(item.ID)
  8223. }
  8224. c.ServeSuccessJSON(map[string]interface{}{
  8225. "failed_code": 0,
  8226. "msg": "目录对照成功",
  8227. })
  8228. } else {
  8229. c.ServeSuccessJSON(map[string]interface{}{
  8230. "failed_code": -10,
  8231. "msg": res.ErrMsg,
  8232. })
  8233. }
  8234. }
  8235. }
  8236. }
  8237. func (c *HisApiController) UnCheckCode() {
  8238. ids_str := c.GetString("ids")
  8239. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8240. admin_user_id, _ := c.GetInt64("admin_user_id")
  8241. ids_arr := strings.Split(ids_str, ",")
  8242. var queryResult []QueryResult
  8243. ids := make([]int64, 0)
  8244. for _, item := range ids_arr {
  8245. id, _ := strconv.ParseInt(item, 10, 64)
  8246. ids = append(ids, id)
  8247. }
  8248. if record_type == 1 {
  8249. drugs, _ := service.GetBatchDrugList(ids)
  8250. for _, item := range drugs {
  8251. result := QueryResult{
  8252. ID: item.ID,
  8253. Name: item.DrugName,
  8254. Code: item.MedicalInsuranceNumber,
  8255. List_type_code: "101",
  8256. }
  8257. queryResult = append(queryResult, result)
  8258. }
  8259. } else if record_type == 2 {
  8260. goods, _ := service.GetBatchGoodInformationList(ids)
  8261. for _, item := range goods {
  8262. result := QueryResult{
  8263. ID: item.ID,
  8264. Name: item.GoodName,
  8265. Code: item.MedicalInsuranceNumber,
  8266. List_type_code: "301",
  8267. }
  8268. queryResult = append(queryResult, result)
  8269. }
  8270. } else if record_type == 3 {
  8271. projects, _ := service.GetBathchMyPorjecgList(ids)
  8272. for _, item := range projects {
  8273. result := QueryResult{
  8274. ID: item.ID,
  8275. Name: item.ProjectName,
  8276. Code: item.MedicalCode,
  8277. List_type_code: "201",
  8278. }
  8279. queryResult = append(queryResult, result)
  8280. }
  8281. }
  8282. adminUser := c.GetAdminUserInfo()
  8283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8285. var user_name string
  8286. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8287. if role.ID == 0 {
  8288. user_name = "xxx"
  8289. } else {
  8290. user_name = role.UserName
  8291. }
  8292. baseParams := &models.BaseParams{
  8293. SecretKey: miConfig.SecretKey,
  8294. FixmedinsCode: miConfig.Code,
  8295. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8296. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8297. OrgName: miConfig.OrgName,
  8298. Doctor: user_name,
  8299. }
  8300. if config.IsOpen == 1 {
  8301. for _, item := range queryResult {
  8302. var result string
  8303. if record_type == 1 {
  8304. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8305. } else if record_type == 2 {
  8306. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8307. } else if record_type == 3 {
  8308. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8309. }
  8310. var dat2 map[string]interface{}
  8311. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8312. fmt.Println(dat2)
  8313. } else {
  8314. fmt.Println(err)
  8315. }
  8316. userJSONBytes, _ := json.Marshal(dat2)
  8317. var res ResultSix
  8318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8319. utils.ErrorLog("解析失败:%v", err)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. if res.Infcode == 0 {
  8324. if record_type == 1 {
  8325. service.UpdateDrugByIdDetail(item.ID)
  8326. } else if record_type == 2 {
  8327. service.UpdateGoodInfoById(item.ID)
  8328. } else if record_type == 3 {
  8329. service.UpdateMyProjectById(item.ID)
  8330. }
  8331. c.ServeSuccessJSON(map[string]interface{}{
  8332. "failed_code": 0,
  8333. "msg": "撤销目录对照成功",
  8334. })
  8335. } else {
  8336. c.ServeSuccessJSON(map[string]interface{}{
  8337. "failed_code": -10,
  8338. "msg": res.ErrMsg,
  8339. })
  8340. }
  8341. }
  8342. }
  8343. }
  8344. func (c *HisApiController) GetPatientInfo() {
  8345. id_card_no := c.GetString("id_card_no")
  8346. admin_user_id, _ := c.GetInt64("admin_user_id")
  8347. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8348. if patient.ID == 0 {
  8349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8350. return
  8351. }
  8352. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8353. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8354. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8355. if config.IsOpen == 1 {
  8356. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8357. var dat map[string]interface{}
  8358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8359. fmt.Println(dat)
  8360. } else {
  8361. fmt.Println(err)
  8362. }
  8363. userJSONBytes, _ := json.Marshal(dat)
  8364. var res ResultTwo
  8365. var res10265 ResultTwo10265
  8366. if miConfig.Code == "H15049901371" {
  8367. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8368. utils.ErrorLog("解析失败:%v", err)
  8369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8370. return
  8371. }
  8372. res.ErrMsg = res10265.ErrMsg
  8373. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8374. res.Infcode = infocode
  8375. res.Output = res10265.Output
  8376. res.InfRefmsgid = res10265.InfRefmsgid
  8377. } else {
  8378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8379. utils.ErrorLog("解析失败:%v", err)
  8380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8381. return
  8382. }
  8383. }
  8384. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8385. // utils.ErrorLog("解析失败:%v", err)
  8386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8387. // return
  8388. //}
  8389. if res.Infcode != 0 {
  8390. c.ServeSuccessJSON(map[string]interface{}{
  8391. "failed_code": -10,
  8392. "msg": res.ErrMsg,
  8393. })
  8394. } else {
  8395. c.ServeSuccessJSON(map[string]interface{}{
  8396. "failed_code": 0,
  8397. "info": res,
  8398. })
  8399. }
  8400. }
  8401. }
  8402. func (c *HisApiController) PsnPutOnRecord() {
  8403. record_type, _ := c.GetInt64("type")
  8404. patient_id, _ := c.GetInt64("patient_id")
  8405. admin_user_id, _ := c.GetInt64("admin_user_id")
  8406. start_time := c.GetString("start_time")
  8407. end_time := c.GetString("end_time")
  8408. adminUser := c.GetAdminUserInfo()
  8409. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8410. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8411. var patients []*models.Patients
  8412. if record_type == 1 { //全部备案
  8413. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8414. patients = append(patients, patient...)
  8415. } else { //单个备案
  8416. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8417. patients = append(patients, patient)
  8418. }
  8419. var user_name string
  8420. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8421. if role.ID == 0 {
  8422. user_name = "xxx"
  8423. } else {
  8424. user_name = role.UserName
  8425. }
  8426. if config.IsOpen == 1 {
  8427. for _, item := range patients {
  8428. 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
  8429. resp, requestErr := http.Get(api)
  8430. if requestErr != nil {
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. defer resp.Body.Close()
  8435. body, ioErr := ioutil.ReadAll(resp.Body)
  8436. if ioErr != nil {
  8437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8439. return
  8440. }
  8441. var respJSON map[string]interface{}
  8442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8445. return
  8446. }
  8447. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8448. userJSONBytes, _ := json.Marshal(userJSON)
  8449. var res ResultTwo
  8450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8451. utils.ErrorLog("解析失败:%v", err)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. if res.Infcode == 0 {
  8456. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8457. var dat map[string]interface{}
  8458. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8459. fmt.Println(dat)
  8460. } else {
  8461. fmt.Println(err)
  8462. }
  8463. userJSONBytes, _ := json.Marshal(dat)
  8464. var res2 ResultThirteen
  8465. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8466. utils.ErrorLog("解析失败:%v", err)
  8467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8468. return
  8469. }
  8470. if res2.Infcode == 0 {
  8471. psnResult := &models.GdybPsnRecord{
  8472. UserOrgId: adminUser.CurrentOrgId,
  8473. PatientId: item.ID,
  8474. PsnNo: res.Output.Baseinfo.PsnNo,
  8475. Ctime: time.Now().Unix(),
  8476. Mtime: time.Now().Unix(),
  8477. Status: 1,
  8478. IsCancel: 1,
  8479. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8480. }
  8481. service.CreatePsnRecord(psnResult)
  8482. } else {
  8483. c.ServeSuccessJSON(map[string]interface{}{
  8484. "failed_code": -10,
  8485. "msg": res2.ErrMsg,
  8486. })
  8487. return
  8488. }
  8489. }
  8490. }
  8491. }
  8492. }
  8493. func (c *HisApiController) PsnUnPutOnRecord() {
  8494. id, _ := c.GetInt64("id")
  8495. //record_type, _ := c.GetInt64("type")
  8496. admin_user_id, _ := c.GetInt64("admin_user_id")
  8497. adminUser := c.GetAdminUserInfo()
  8498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8499. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8500. var user_name string
  8501. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8502. if role.ID == 0 {
  8503. user_name = "xxx"
  8504. } else {
  8505. user_name = role.UserName
  8506. }
  8507. psn_record, _ := service.GetPsnRecordById(id)
  8508. if psn_record.ID == 0 {
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8510. return
  8511. }
  8512. if config.IsOpen == 1 {
  8513. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8514. var dat map[string]interface{}
  8515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8516. fmt.Println(dat)
  8517. } else {
  8518. fmt.Println(err)
  8519. }
  8520. userJSONBytes, _ := json.Marshal(dat)
  8521. var res ResultFourteen
  8522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8523. utils.ErrorLog("解析失败:%v", err)
  8524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8525. return
  8526. }
  8527. if res.Infcode == 0 {
  8528. psn_record.IsCancel = 2
  8529. service.CreatePsnRecord(&psn_record)
  8530. } else {
  8531. c.ServeSuccessJSON(map[string]interface{}{
  8532. "failed_code": -10,
  8533. "msg": res.ErrMsg,
  8534. })
  8535. return
  8536. }
  8537. }
  8538. }
  8539. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8540. patient_id, _ := c.GetInt64("patient_id")
  8541. insutype_two := c.GetString("insutype")
  8542. psn_no := c.GetString("psn_no")
  8543. doctor_id, _ := c.GetInt64("doctor_id")
  8544. sick_id, _ := c.GetInt64("sick_id")
  8545. department_id, _ := c.GetInt64("department_id")
  8546. start_time := c.GetString("start_time")
  8547. end_time := c.GetString("end_time")
  8548. check_time := c.GetString("check_time")
  8549. adminUser := c.GetAdminUserInfo()
  8550. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8551. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8552. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8553. sick, _ := service.FindSickById(sick_id)
  8554. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8555. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8556. var res ResultTwo
  8557. var res10265 ResultTwo10265
  8558. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8559. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8560. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8561. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8562. "&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
  8563. resp, requestErr := http.Get(api)
  8564. if requestErr != nil {
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. body, ioErr := ioutil.ReadAll(resp.Body)
  8569. if ioErr != nil {
  8570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8572. return
  8573. }
  8574. var respJSON map[string]interface{}
  8575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8578. return
  8579. }
  8580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8581. result, _ := json.Marshal(respJSON)
  8582. fmt.Println("log")
  8583. fmt.Println(string(result))
  8584. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8585. utils.ErrorLog("解析失败:%v", err)
  8586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8587. return
  8588. }
  8589. res.ErrMsg = res10265.ErrMsg
  8590. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8591. res.Infcode = infocode
  8592. res.Output = res10265.Output
  8593. res.InfRefmsgid = res10265.InfRefmsgid
  8594. } else {
  8595. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8596. if miConfig.Code == "H15049901371" {
  8597. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8598. utils.ErrorLog("解析失败:%v", err)
  8599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8600. return
  8601. }
  8602. res.ErrMsg = res10265.ErrMsg
  8603. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8604. res.Infcode = infocode
  8605. res.Output = res10265.Output
  8606. res.InfRefmsgid = res10265.InfRefmsgid
  8607. } else {
  8608. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8609. utils.ErrorLog("解析失败:%v", err)
  8610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8611. return
  8612. }
  8613. }
  8614. }
  8615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8616. infoStr := string(Iinfos)
  8617. var rf []*ResultFive
  8618. json.Unmarshal([]byte(infoStr), &rf)
  8619. var insuplc_admdvs string
  8620. var insutype string
  8621. var is390 int = 0
  8622. var is310 int = 0
  8623. var insutypes []*ResultFive
  8624. for _, item := range rf {
  8625. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8626. insutypes = append(insutypes, item)
  8627. }
  8628. }
  8629. if len(insutypes) == 1 {
  8630. insutype = insutypes[0].Insutype
  8631. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8632. } else {
  8633. for _, i := range insutypes {
  8634. if i.Insutype == "390" {
  8635. is390 = 1
  8636. }
  8637. if i.Insutype == "310" {
  8638. is310 = 1
  8639. }
  8640. }
  8641. }
  8642. if is390 == 1 {
  8643. insutype = "390"
  8644. }
  8645. if is310 == 1 {
  8646. insutype = "310"
  8647. }
  8648. if len(insutypes) == 2 {
  8649. insutype = insutype_two
  8650. }
  8651. if len(insutypes) == 0 {
  8652. insutype = "310"
  8653. }
  8654. insutype = insutype_two
  8655. fmt.Println(insutype)
  8656. for _, item := range rf {
  8657. fmt.Println(item.Insutype)
  8658. fmt.Println(insutype)
  8659. if item.Insutype == insutype {
  8660. fmt.Println(item.Insutype)
  8661. fmt.Println(insutype)
  8662. insuplc_admdvs = item.InsuplcAdmdvs
  8663. }
  8664. }
  8665. fmt.Println(insuplc_admdvs)
  8666. var res2 ResultThirteen
  8667. var res10265_2 ResultThirteen10265
  8668. if config.IsOpen == 1 {
  8669. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8670. } else {
  8671. 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)
  8672. var dat map[string]interface{}
  8673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8674. fmt.Println(dat)
  8675. } else {
  8676. fmt.Println(err)
  8677. }
  8678. userJSONBytes, _ := json.Marshal(dat)
  8679. if miConfig.Code == "H15049901371" {
  8680. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8681. utils.ErrorLog("解析失败:%v", err)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. res2.ErrMsg = res10265_2.ErrMsg
  8686. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8687. res2.Infcode = infocode
  8688. res2.Output = res10265_2.Output
  8689. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8690. } else {
  8691. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8692. utils.ErrorLog("解析失败:%v", err)
  8693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8694. return
  8695. }
  8696. }
  8697. }
  8698. if res2.Infcode == 0 {
  8699. psnResult := &models.GdybPsnNcdsRecord{
  8700. UserOrgId: adminUser.CurrentOrgId,
  8701. PatientId: patient.ID,
  8702. PsnNo: psn_no,
  8703. DoctorId: doctor.AdminUserId,
  8704. DepartmentId: department_id,
  8705. SickType: sick_id,
  8706. Insutype: insutype,
  8707. Ctime: time.Now().Unix(),
  8708. Mtime: time.Now().Unix(),
  8709. Status: 1,
  8710. IsCancel: 1,
  8711. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8712. }
  8713. service.CreatePsnNCDSRecord(psnResult)
  8714. c.ServeSuccessJSON(map[string]interface{}{
  8715. "failed_code": 0,
  8716. "msg": "备案成功",
  8717. "result": psnResult,
  8718. })
  8719. } else {
  8720. c.ServeSuccessJSON(map[string]interface{}{
  8721. "failed_code": -10,
  8722. "msg": res2.ErrMsg,
  8723. })
  8724. return
  8725. }
  8726. }
  8727. }
  8728. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8729. id, _ := c.GetInt64("id")
  8730. admin_user_id, _ := c.GetInt64("admin_user_id")
  8731. adminUser := c.GetAdminUserInfo()
  8732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8733. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8734. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8735. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8736. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8737. //var user_name string
  8738. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8739. //if role.ID == 0 {
  8740. // user_name = "xxx"
  8741. //} else {
  8742. // user_name = role.UserName
  8743. //}
  8744. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8745. if psn_record.ID == 0 {
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8747. return
  8748. }
  8749. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8750. var res ResultTwo
  8751. var res10265 ResultTwo10265
  8752. if miConfig.Code == "H15049901371" {
  8753. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8754. utils.ErrorLog("解析失败:%v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. res.ErrMsg = res10265.ErrMsg
  8759. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8760. res.Infcode = infocode
  8761. res.Output = res10265.Output
  8762. res.InfRefmsgid = res10265.InfRefmsgid
  8763. } else {
  8764. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8765. utils.ErrorLog("解析失败:%v", err)
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. }
  8770. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8771. infoStr := string(Iinfos)
  8772. var rf []*ResultFive
  8773. json.Unmarshal([]byte(infoStr), &rf)
  8774. var insuplc_admdvs string
  8775. var insutype string
  8776. var is390 int = 0
  8777. var is310 int = 0
  8778. var insutypes []*ResultFive
  8779. for _, item := range rf {
  8780. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8781. insutypes = append(insutypes, item)
  8782. }
  8783. }
  8784. if len(insutypes) == 1 {
  8785. insutype = insutypes[0].Insutype
  8786. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8787. } else {
  8788. for _, i := range insutypes {
  8789. if i.Insutype == "390" {
  8790. is390 = 1
  8791. }
  8792. if i.Insutype == "310" {
  8793. is310 = 1
  8794. }
  8795. }
  8796. }
  8797. if is390 == 1 {
  8798. insutype = "390"
  8799. }
  8800. if is310 == 1 {
  8801. insutype = "310"
  8802. }
  8803. if len(insutypes) == 0 {
  8804. insutype = "310"
  8805. }
  8806. insutype = psn_record.Insutype
  8807. for _, item := range rf {
  8808. if item.Insutype == insutype {
  8809. insuplc_admdvs = item.InsuplcAdmdvs
  8810. }
  8811. }
  8812. if config.IsOpen == 1 {
  8813. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8814. var dat map[string]interface{}
  8815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8816. fmt.Println(dat)
  8817. } else {
  8818. fmt.Println(err)
  8819. }
  8820. userJSONBytes, _ := json.Marshal(dat)
  8821. var res ResultFourteen
  8822. var res10265 ResultFourteen10265
  8823. if miConfig.Code == "H15049901371" {
  8824. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. res.ErrMsg = res10265.ErrMsg
  8830. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8831. res.Infcode = infocode
  8832. res.Output = res10265.Output
  8833. res.InfRefmsgid = res10265.InfRefmsgid
  8834. } else {
  8835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8836. utils.ErrorLog("解析失败:%v", err)
  8837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8838. return
  8839. }
  8840. }
  8841. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8842. // utils.ErrorLog("解析失败:%v", err)
  8843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. // return
  8845. //}
  8846. if res.Infcode == 0 {
  8847. psn_record.IsCancel = 2
  8848. service.CreatePsnNCDSRecord(&psn_record)
  8849. c.ServeSuccessJSON(map[string]interface{}{
  8850. "failed_code": 0,
  8851. "msg": "撤销备案成功",
  8852. })
  8853. } else {
  8854. c.ServeSuccessJSON(map[string]interface{}{
  8855. "failed_code": -10,
  8856. "msg": res.ErrMsg,
  8857. })
  8858. return
  8859. }
  8860. }
  8861. }
  8862. func (c *HisApiController) TestTest() {
  8863. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8864. fmt.Println(patient.Iinfo)
  8865. }
  8866. type CustomData struct {
  8867. MsgId string
  8868. PsnNo string
  8869. Info string
  8870. }
  8871. func (c *HisApiController) ReversalData() {
  8872. var customData []*CustomData
  8873. custom := &CustomData{
  8874. MsgId: "H44022900158202103301714472004",
  8875. PsnNo: "44020000001101329945",
  8876. Info: "2207",
  8877. }
  8878. customData = append(customData, custom)
  8879. custom1 := &CustomData{
  8880. MsgId: "H4402290015820210330172057803",
  8881. PsnNo: "44020000001101161813",
  8882. Info: "2207",
  8883. }
  8884. customData = append(customData, custom1)
  8885. custom2 := &CustomData{
  8886. MsgId: "H44022900158202103301705198813",
  8887. PsnNo: "44190000133097375417",
  8888. Info: "2207",
  8889. }
  8890. customData = append(customData, custom2)
  8891. custom3 := &CustomData{
  8892. MsgId: "H44022900158202103301715524756",
  8893. PsnNo: "44020000001100187221",
  8894. Info: "2207",
  8895. }
  8896. customData = append(customData, custom3)
  8897. custom4 := &CustomData{
  8898. MsgId: "H44022900158202103301730376224",
  8899. PsnNo: "44020000001101959155",
  8900. Info: "2207",
  8901. }
  8902. customData = append(customData, custom4)
  8903. custom5 := &CustomData{
  8904. MsgId: "H44022900158202103301748008725",
  8905. PsnNo: "44020000001104246641",
  8906. Info: "2207",
  8907. }
  8908. customData = append(customData, custom5)
  8909. custom6 := &CustomData{
  8910. MsgId: "H44022900158202103301718096755",
  8911. PsnNo: "44020000001102211860",
  8912. Info: "2207",
  8913. }
  8914. customData = append(customData, custom6)
  8915. custom7 := &CustomData{
  8916. MsgId: "H44022900158202103301736551640",
  8917. PsnNo: "44020000001102687718",
  8918. Info: "2207",
  8919. }
  8920. customData = append(customData, custom7)
  8921. custom8 := &CustomData{
  8922. MsgId: "H44022900158202103301743097676",
  8923. PsnNo: "44020000001102127785",
  8924. Info: "2207",
  8925. }
  8926. customData = append(customData, custom8)
  8927. custom9 := &CustomData{
  8928. MsgId: "H44022900158202103301712304203",
  8929. PsnNo: "44020000001101518097",
  8930. Info: "2207",
  8931. }
  8932. customData = append(customData, custom9)
  8933. custom10 := &CustomData{
  8934. MsgId: "H44022900158202103301738448785",
  8935. PsnNo: "44020000001100500813",
  8936. Info: "2207",
  8937. }
  8938. customData = append(customData, custom10)
  8939. custom11 := &CustomData{
  8940. MsgId: "H44022900158202103301732455843",
  8941. PsnNo: "44020000001102690557",
  8942. Info: "2207",
  8943. }
  8944. customData = append(customData, custom11)
  8945. custom12 := &CustomData{
  8946. MsgId: "H44022900158202103301745421708",
  8947. PsnNo: "44020000001102211928",
  8948. Info: "2207",
  8949. }
  8950. customData = append(customData, custom12)
  8951. custom1212 := &CustomData{
  8952. MsgId: "H440229001582021033017351627",
  8953. PsnNo: "44020000001102481733",
  8954. Info: "2207",
  8955. }
  8956. customData = append(customData, custom1212)
  8957. custom13 := &CustomData{
  8958. MsgId: "H44022900158202103301740327951",
  8959. PsnNo: "44020000001103174866",
  8960. Info: "2207",
  8961. }
  8962. customData = append(customData, custom13)
  8963. custom14 := &CustomData{
  8964. MsgId: "H4402290015820210330174922668",
  8965. PsnNo: "44020000001102927272",
  8966. Info: "2207",
  8967. }
  8968. customData = append(customData, custom14)
  8969. custom15 := &CustomData{
  8970. MsgId: "H44022900158202103301752362273",
  8971. PsnNo: "44020000001102942890",
  8972. Info: "2207",
  8973. }
  8974. customData = append(customData, custom15)
  8975. custom16 := &CustomData{
  8976. MsgId: "H44022900158202103301751082917",
  8977. PsnNo: "44020000001101662162",
  8978. Info: "2207",
  8979. }
  8980. customData = append(customData, custom16)
  8981. custom17 := &CustomData{
  8982. MsgId: "H44022900158202103301754147728",
  8983. PsnNo: "44020000000229014511",
  8984. Info: "2207",
  8985. }
  8986. customData = append(customData, custom17)
  8987. adminUser := c.GetAdminUserInfo()
  8988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8989. for _, item := range customData {
  8990. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8991. fmt.Println(result)
  8992. }
  8993. }
  8994. func (c *HisApiController) GetAllopatry() {
  8995. year := c.GetString("year")
  8996. month := c.GetString("month")
  8997. admin_user_id, _ := c.GetInt64("admin_user_id")
  8998. adminUser := c.GetAdminUserInfo()
  8999. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9000. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9001. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9002. var dat map[string]interface{}
  9003. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9004. fmt.Println(dat)
  9005. } else {
  9006. fmt.Println(err)
  9007. }
  9008. userJSONBytes, _ := json.Marshal(dat)
  9009. var res models.Result9001
  9010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9011. utils.ErrorLog("解析失败:%v", err)
  9012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9013. return
  9014. }
  9015. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9016. var dat2 map[string]interface{}
  9017. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9018. fmt.Println(dat)
  9019. } else {
  9020. fmt.Println(err)
  9021. }
  9022. userJSONBytes2, _ := json.Marshal(dat2)
  9023. var res2 models.Result3260
  9024. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9025. utils.ErrorLog("解析失败:%v", err)
  9026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9027. return
  9028. }
  9029. if res2.Infcode == 0 {
  9030. c.ServeSuccessJSON(map[string]interface{}{
  9031. "list": res2.Output.Data,
  9032. })
  9033. return
  9034. } else {
  9035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9036. return
  9037. }
  9038. }
  9039. func (c *HisApiController) ComfirmAllopatry() {
  9040. year := c.GetString("year")
  9041. month := c.GetString("month")
  9042. admin_user_id, _ := c.GetInt64("admin_user_id")
  9043. adminUser := c.GetAdminUserInfo()
  9044. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9045. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9046. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9047. var dat map[string]interface{}
  9048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9049. fmt.Println(dat)
  9050. } else {
  9051. fmt.Println(err)
  9052. }
  9053. userJSONBytes, _ := json.Marshal(dat)
  9054. var res models.Result9001
  9055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9056. utils.ErrorLog("解析失败:%v", err)
  9057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9058. return
  9059. }
  9060. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9061. var dat2 map[string]interface{}
  9062. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9063. fmt.Println(dat)
  9064. } else {
  9065. fmt.Println(err)
  9066. }
  9067. userJSONBytes2, _ := json.Marshal(dat2)
  9068. var res2 models.Result3260
  9069. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9070. utils.ErrorLog("解析失败:%v", err)
  9071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9072. return
  9073. }
  9074. if res2.Infcode == 0 {
  9075. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9076. var dat map[string]interface{}
  9077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9078. fmt.Println(dat)
  9079. } else {
  9080. fmt.Println(err)
  9081. }
  9082. userJSONBytes, _ := json.Marshal(dat)
  9083. var res3 models.Result3261
  9084. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9085. utils.ErrorLog("解析失败:%v", err)
  9086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9087. return
  9088. }
  9089. if res3.Infcode == 0 {
  9090. record := &models.HisYidiClearRecord{
  9091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9092. Ctime: time.Now().Unix(),
  9093. Mtime: time.Now().Unix(),
  9094. Status: 1,
  9095. MsgId: msgId,
  9096. }
  9097. service.SaveClearRecord(record)
  9098. c.ServeSuccessJSON(map[string]interface{}{
  9099. "msg": "提取成功",
  9100. })
  9101. }
  9102. }
  9103. }
  9104. func (c *HisApiController) RefundAllopatry() {
  9105. year := c.GetString("year")
  9106. month := c.GetString("month")
  9107. id, _ := c.GetInt64("id")
  9108. admin_user_id, _ := c.GetInt64("admin_user_id")
  9109. adminUser := c.GetAdminUserInfo()
  9110. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9111. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9112. record, _ := service.GetClearRecordById(id)
  9113. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9114. var dat map[string]interface{}
  9115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9116. fmt.Println(dat)
  9117. } else {
  9118. fmt.Println(err)
  9119. }
  9120. userJSONBytes, _ := json.Marshal(dat)
  9121. var empty ResultFourteen
  9122. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9123. utils.ErrorLog("解析失败:%v", err)
  9124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9125. return
  9126. }
  9127. if empty.Infcode == 0 {
  9128. c.ServeSuccessJSON(map[string]interface{}{
  9129. "msg": "撤销成功",
  9130. })
  9131. return
  9132. }
  9133. }
  9134. func (c *HisApiController) ReversalOtherData() {
  9135. var customData []*CustomData
  9136. custom := &CustomData{
  9137. MsgId: "H44022900158202103301714472004",
  9138. PsnNo: "44020000001101329945",
  9139. Info: "2208",
  9140. }
  9141. customData = append(customData, custom)
  9142. custom1 := &CustomData{
  9143. MsgId: "H4402290015820210330172057803",
  9144. PsnNo: "44020000001101161813",
  9145. Info: "2208",
  9146. }
  9147. customData = append(customData, custom1)
  9148. custom2 := &CustomData{
  9149. MsgId: "H44022900158202103301705198813",
  9150. PsnNo: "44190000133097375417",
  9151. Info: "2208",
  9152. }
  9153. customData = append(customData, custom2)
  9154. custom3 := &CustomData{
  9155. MsgId: "H44022900158202103301715524756",
  9156. PsnNo: "44020000001100187221",
  9157. Info: "2208",
  9158. }
  9159. customData = append(customData, custom3)
  9160. custom4 := &CustomData{
  9161. MsgId: "H44022900158202103301730376224",
  9162. PsnNo: "44020000001101959155",
  9163. Info: "2208",
  9164. }
  9165. customData = append(customData, custom4)
  9166. custom5 := &CustomData{
  9167. MsgId: "H44022900158202103301748008725",
  9168. PsnNo: "44020000001104246641",
  9169. Info: "2208",
  9170. }
  9171. customData = append(customData, custom5)
  9172. custom6 := &CustomData{
  9173. MsgId: "H44022900158202103301718096755",
  9174. PsnNo: "44020000001102211860",
  9175. Info: "2208",
  9176. }
  9177. customData = append(customData, custom6)
  9178. custom7 := &CustomData{
  9179. MsgId: "H44022900158202103301736551640",
  9180. PsnNo: "44020000001102687718",
  9181. Info: "2208",
  9182. }
  9183. customData = append(customData, custom7)
  9184. custom8 := &CustomData{
  9185. MsgId: "H44022900158202103301743097676",
  9186. PsnNo: "44020000001102127785",
  9187. Info: "2208",
  9188. }
  9189. customData = append(customData, custom8)
  9190. custom9 := &CustomData{
  9191. MsgId: "H44022900158202103301712304203",
  9192. PsnNo: "44020000001101518097",
  9193. Info: "2208",
  9194. }
  9195. customData = append(customData, custom9)
  9196. custom10 := &CustomData{
  9197. MsgId: "H44022900158202103301738448785",
  9198. PsnNo: "44020000001100500813",
  9199. Info: "2208",
  9200. }
  9201. customData = append(customData, custom10)
  9202. custom11 := &CustomData{
  9203. MsgId: "H44022900158202103301732455843",
  9204. PsnNo: "44020000001102690557",
  9205. Info: "2208",
  9206. }
  9207. customData = append(customData, custom11)
  9208. custom12 := &CustomData{
  9209. MsgId: "H44022900158202103301745421708",
  9210. PsnNo: "44020000001102211928",
  9211. Info: "2208",
  9212. }
  9213. customData = append(customData, custom12)
  9214. custom1212 := &CustomData{
  9215. MsgId: "H440229001582021033017351627",
  9216. PsnNo: "44020000001102481733",
  9217. Info: "2208",
  9218. }
  9219. customData = append(customData, custom1212)
  9220. custom13 := &CustomData{
  9221. MsgId: "H44022900158202103301740327951",
  9222. PsnNo: "44020000001103174866",
  9223. Info: "2208",
  9224. }
  9225. customData = append(customData, custom13)
  9226. custom14 := &CustomData{
  9227. MsgId: "H4402290015820210330174922668",
  9228. PsnNo: "44020000001102927272",
  9229. Info: "2208",
  9230. }
  9231. customData = append(customData, custom14)
  9232. custom15 := &CustomData{
  9233. MsgId: "H44022900158202103301752362273",
  9234. PsnNo: "44020000001102942890",
  9235. Info: "2208",
  9236. }
  9237. customData = append(customData, custom15)
  9238. custom16 := &CustomData{
  9239. MsgId: "H44022900158202103301751082917",
  9240. PsnNo: "44020000001101662162",
  9241. Info: "2208",
  9242. }
  9243. customData = append(customData, custom16)
  9244. custom17 := &CustomData{
  9245. MsgId: "H44022900158202103301754147728",
  9246. PsnNo: "44020000000229014511",
  9247. Info: "2208",
  9248. }
  9249. customData = append(customData, custom17)
  9250. adminUser := c.GetAdminUserInfo()
  9251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9252. for _, item := range customData {
  9253. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9254. fmt.Println(result)
  9255. }
  9256. }
  9257. func PathExists(path string) (bool, error) {
  9258. _, err := os.Stat(path)
  9259. if err == nil {
  9260. return true, nil
  9261. }
  9262. if os.IsNotExist(err) {
  9263. return false, nil
  9264. }
  9265. return false, err
  9266. }
  9267. //创建文件夹
  9268. func Mkdir(dir string) {
  9269. // 创建文件夹
  9270. exist, err := PathExists(dir)
  9271. if err != nil {
  9272. fmt.Println(err.Error())
  9273. } else {
  9274. if exist {
  9275. fmt.Println(dir + "文件夹已存在!")
  9276. } else {
  9277. // 文件夹名称,权限
  9278. err := os.Mkdir(dir, os.ModePerm)
  9279. if err != nil {
  9280. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9281. } else {
  9282. fmt.Println(dir + "文件夹创建成功!")
  9283. }
  9284. }
  9285. }
  9286. }
  9287. //压缩文件
  9288. func Zip(srcFile string, destZip string) error {
  9289. zipfile, err := os.Create(destZip)
  9290. if err != nil {
  9291. return err
  9292. }
  9293. defer zipfile.Close()
  9294. archive := zip.NewWriter(zipfile)
  9295. defer archive.Close()
  9296. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9297. if err != nil {
  9298. return err
  9299. }
  9300. header, err := zip.FileInfoHeader(info)
  9301. if err != nil {
  9302. return err
  9303. }
  9304. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9305. // header.Name = path
  9306. if info.IsDir() {
  9307. header.Name += "/"
  9308. } else {
  9309. header.Method = zip.Deflate
  9310. }
  9311. writer, err := archive.CreateHeader(header)
  9312. if err != nil {
  9313. return err
  9314. }
  9315. if !info.IsDir() {
  9316. file, err := os.Open(path)
  9317. if err != nil {
  9318. return err
  9319. }
  9320. defer file.Close()
  9321. _, err = io.Copy(writer, file)
  9322. }
  9323. return err
  9324. })
  9325. return err
  9326. }
  9327. func ReadFile(filePath string) []byte {
  9328. f, err := os.Open(filePath)
  9329. if err != nil {
  9330. fmt.Println("read file fail", err)
  9331. return nil
  9332. }
  9333. defer f.Close()
  9334. fd, err := ioutil.ReadAll(f)
  9335. if err != nil {
  9336. fmt.Println("read to fd fail", err)
  9337. return nil
  9338. }
  9339. return fd
  9340. }
  9341. func saveLog(result string, request string, infno string, desc string) {
  9342. org_id, _ := beego.AppConfig.Int64("org_id")
  9343. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9344. dir := miConfig.OrgName + "日志"
  9345. utils.Mkdir(dir)
  9346. month := time.Unix(1557042972, 0).Format("1")
  9347. year := time.Now().Format("2006")
  9348. month = time.Now().Format("01")
  9349. day := time.Now().Format("02")
  9350. hour := time.Now().Format("15")
  9351. min := time.Now().Format("04")
  9352. sec := time.Now().Format("05")
  9353. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9354. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9355. file_name := file + ".txt"
  9356. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9357. exist, _ := utils.PathExists(file_path)
  9358. if exist { //存在
  9359. fmt.Println("存在")
  9360. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9361. if err != nil {
  9362. fmt.Println("read fail")
  9363. }
  9364. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9365. n, _ := f.Seek(0, 2)
  9366. _, err = f.WriteAt([]byte(content), n)
  9367. } else { //不存在
  9368. fmt.Println("文件不存在,创建文件")
  9369. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9370. defer f.Close()
  9371. if err != nil {
  9372. } else {
  9373. _, err = f.Write([]byte("记录日志"))
  9374. }
  9375. }
  9376. }
  9377. type Charset string
  9378. const (
  9379. UTF8 = Charset("UTF-8")
  9380. GB18030 = Charset("GB18030")
  9381. )
  9382. func ConvertToString(src string, srcCode string, tagCode string) string {
  9383. srcCoder := mahonia.NewDecoder(srcCode)
  9384. srcResult := srcCoder.ConvertString(src)
  9385. tagCoder := mahonia.NewDecoder(tagCode)
  9386. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9387. result := string(cdata)
  9388. return result
  9389. }