his_api_controller.go 397KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820
  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 + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  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 + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  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. fmt.Println(respJSON["data"])
  377. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  378. //console.log()
  379. fmt.Println("type===")
  380. fmt.Println(card_type)
  381. var token string
  382. var res ResultTwo //1101结果
  383. var res10265 ResultTwo10265 //1101结果
  384. var card_info string //卡信息
  385. var busi_card_info string
  386. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  387. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  388. if status == "0" { //读卡成功
  389. if card_type == "1" {
  390. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  391. result, _ := json.Marshal(respJSON)
  392. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  393. utils.ErrorLog("解析失败:%v", err)
  394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  395. return
  396. }
  397. res.ErrMsg = res10265.ErrMsg
  398. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  399. res.Infcode = infocode
  400. res.Output = res10265.Output
  401. res.InfRefmsgid = res10265.InfRefmsgid
  402. } else {
  403. //var card_info string //卡信息
  404. //var busi_card_info string
  405. token = respJSON["data"].(map[string]interface{})["token"].(string)
  406. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  407. //fmt.Println(card_info)
  408. //fmt.Println(busi_card_info)
  409. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  410. result, _ := json.Marshal(respJSON)
  411. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  412. utils.ErrorLog("解析失败:%v", err)
  413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  414. return
  415. }
  416. res.ErrMsg = res10265.ErrMsg
  417. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  418. res.Infcode = infocode
  419. res.Output = res10265.Output
  420. res.InfRefmsgid = res10265.InfRefmsgid
  421. }
  422. if res.Infcode == 0 {
  423. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  424. if err == gorm.ErrRecordNotFound {
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  426. return
  427. } else if err != nil {
  428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  429. return
  430. } else {
  431. if card_type == "1" {
  432. bas := strings.Split(card_info, "|")
  433. basNumber := bas[2]
  434. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  435. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  436. infoStr := string(Iinfos)
  437. idetinfoStr := string(Idetinfos)
  438. psn := &models.HisPsn{
  439. PsnNo: res.Output.Baseinfo.PsnNo,
  440. Age: res.Output.Baseinfo.Age,
  441. PatientId: patient.ID,
  442. Certno: res.Output.Baseinfo.Certno,
  443. Brdy: res.Output.Baseinfo.Brdy,
  444. Gend: res.Output.Baseinfo.Gend,
  445. Naty: res.Output.Baseinfo.Naty,
  446. PsnCertType: res.Output.Baseinfo.PsnCertType,
  447. PsnName: res.Output.Baseinfo.PsnName,
  448. Idetinfo: idetinfoStr,
  449. Insuinfo: infoStr,
  450. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  451. CardInfo: card_info,
  452. VerifyNumber: busi_card_info,
  453. }
  454. service.CreateHisPsn(psn)
  455. c.ServeSuccessJSON(map[string]interface{}{
  456. "patient": patient,
  457. "number": basNumber,
  458. })
  459. } else {
  460. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  461. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  462. infoStr := string(Iinfos)
  463. idetinfoStr := string(Idetinfos)
  464. psn := &models.HisPsn{
  465. PsnNo: res.Output.Baseinfo.PsnNo,
  466. Age: res.Output.Baseinfo.Age,
  467. PatientId: patient.ID,
  468. Certno: res.Output.Baseinfo.Certno,
  469. Brdy: res.Output.Baseinfo.Brdy,
  470. Gend: res.Output.Baseinfo.Gend,
  471. Naty: res.Output.Baseinfo.Naty,
  472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  473. PsnName: res.Output.Baseinfo.PsnName,
  474. Idetinfo: idetinfoStr,
  475. Insuinfo: infoStr,
  476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  477. CardInfo: card_info,
  478. VerifyNumber: token,
  479. }
  480. service.CreateHisPsn(psn)
  481. c.ServeSuccessJSON(map[string]interface{}{
  482. "patient": patient,
  483. "number": token,
  484. })
  485. }
  486. }
  487. } else {
  488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  489. return
  490. }
  491. } else { //读卡失败
  492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  493. return
  494. }
  495. } else {
  496. if initFlag == 0 {
  497. c.TestGetBasBaseInit()
  498. }
  499. basStr := c.GetBasBaseInfo()
  500. if len(basStr) == 0 {
  501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  502. return
  503. }
  504. fmt.Println(basStr)
  505. bas := strings.Split(basStr, "|")
  506. basNumber := bas[1]
  507. fmt.Println(basNumber)
  508. card_sn := bas[3]
  509. fmt.Println(card_sn)
  510. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  511. var dat map[string]interface{}
  512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  513. fmt.Println(dat)
  514. } else {
  515. fmt.Println(err)
  516. }
  517. userJSONBytes, _ := json.Marshal(dat)
  518. var res ResultTwo
  519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  520. utils.ErrorLog("解析失败:%v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. if res.Infcode == 0 {
  525. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  526. if err == gorm.ErrRecordNotFound {
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  528. return
  529. } else if err != nil {
  530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  531. return
  532. } else {
  533. c.ServeSuccessJSON(map[string]interface{}{
  534. "patient": patient,
  535. "number": basNumber,
  536. })
  537. }
  538. } else {
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  540. return
  541. }
  542. break
  543. }
  544. case 2:
  545. SFZStr := c.GetSFZBaseInfo()
  546. id_card_str := strings.Split(SFZStr, "^")
  547. id_card_number := id_card_str[0]
  548. card_sn := ""
  549. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  550. var dat map[string]interface{}
  551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  552. fmt.Println(dat)
  553. } else {
  554. fmt.Println(err)
  555. }
  556. userJSONBytes, _ := json.Marshal(dat)
  557. var res ResultTwo
  558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  559. utils.ErrorLog("解析失败:%v", err)
  560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  561. return
  562. }
  563. if res.Infcode == 0 {
  564. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  565. if err == gorm.ErrRecordNotFound {
  566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  567. return
  568. } else if err != nil {
  569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  570. return
  571. } else {
  572. c.ServeSuccessJSON(map[string]interface{}{
  573. "patient": patient,
  574. "number": id_card_number,
  575. })
  576. }
  577. } else {
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  579. return
  580. }
  581. break
  582. case 3:
  583. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  584. var api string
  585. if miConfig.MdtrtareaAdmvs == "320921" {
  586. 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 +
  587. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  588. } else {
  589. 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 +
  590. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  591. }
  592. resp, requestErr := http.Get(api)
  593. if requestErr != nil {
  594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  595. return
  596. }
  597. body, ioErr := ioutil.ReadAll(resp.Body)
  598. if ioErr != nil {
  599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  601. return
  602. }
  603. var respJSON map[string]interface{}
  604. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  607. return
  608. }
  609. var status string
  610. status = respJSON["data"].(map[string]interface{})["status"].(string)
  611. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  612. var token string
  613. var res ResultTwo //1101结果
  614. var res10265 ResultTwo10265 //1101结果
  615. var card_info string //卡信息
  616. var busi_card_info string
  617. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  618. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  619. if status == "0" { //读卡成功
  620. if card_type == "1" {
  621. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  622. result, _ := json.Marshal(respJSON)
  623. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  624. utils.ErrorLog("解析失败:%v", err)
  625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  626. return
  627. }
  628. res.ErrMsg = res10265.ErrMsg
  629. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  630. res.Infcode = infocode
  631. res.Output = res10265.Output
  632. res.InfRefmsgid = res10265.InfRefmsgid
  633. } else {
  634. //var card_info string //卡信息
  635. //var busi_card_info string
  636. token = respJSON["data"].(map[string]interface{})["token"].(string)
  637. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  638. //fmt.Println(card_info)
  639. //fmt.Println(busi_card_info)
  640. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  641. result, _ := json.Marshal(respJSON)
  642. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  643. utils.ErrorLog("解析失败:%v", err)
  644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  645. return
  646. }
  647. res.ErrMsg = res10265.ErrMsg
  648. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  649. res.Infcode = infocode
  650. res.Output = res10265.Output
  651. res.InfRefmsgid = res10265.InfRefmsgid
  652. }
  653. if res.Infcode == 0 {
  654. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  655. if err == gorm.ErrRecordNotFound {
  656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  657. return
  658. } else if err != nil {
  659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  660. return
  661. } else {
  662. if card_type == "1" {
  663. bas := strings.Split(card_info, "|")
  664. basNumber := bas[2]
  665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  667. infoStr := string(Iinfos)
  668. idetinfoStr := string(Idetinfos)
  669. psn := &models.HisPsn{
  670. PsnNo: res.Output.Baseinfo.PsnNo,
  671. Age: res.Output.Baseinfo.Age,
  672. PatientId: patient.ID,
  673. Certno: res.Output.Baseinfo.Certno,
  674. Brdy: res.Output.Baseinfo.Brdy,
  675. Gend: res.Output.Baseinfo.Gend,
  676. Naty: res.Output.Baseinfo.Naty,
  677. PsnCertType: res.Output.Baseinfo.PsnCertType,
  678. PsnName: res.Output.Baseinfo.PsnName,
  679. Idetinfo: idetinfoStr,
  680. Insuinfo: infoStr,
  681. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  682. CardInfo: card_info,
  683. VerifyNumber: busi_card_info,
  684. }
  685. service.CreateHisPsn(psn)
  686. c.ServeSuccessJSON(map[string]interface{}{
  687. "patient": patient,
  688. "number": basNumber,
  689. })
  690. } else {
  691. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  692. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  693. infoStr := string(Iinfos)
  694. idetinfoStr := string(Idetinfos)
  695. psn := &models.HisPsn{
  696. PsnNo: res.Output.Baseinfo.PsnNo,
  697. Age: res.Output.Baseinfo.Age,
  698. PatientId: patient.ID,
  699. Certno: res.Output.Baseinfo.Certno,
  700. Brdy: res.Output.Baseinfo.Brdy,
  701. Gend: res.Output.Baseinfo.Gend,
  702. Naty: res.Output.Baseinfo.Naty,
  703. PsnCertType: res.Output.Baseinfo.PsnCertType,
  704. PsnName: res.Output.Baseinfo.PsnName,
  705. Idetinfo: idetinfoStr,
  706. Insuinfo: infoStr,
  707. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  708. CardInfo: card_info,
  709. VerifyNumber: token,
  710. }
  711. service.CreateHisPsn(psn)
  712. c.ServeSuccessJSON(map[string]interface{}{
  713. "patient": patient,
  714. "number": token,
  715. })
  716. }
  717. }
  718. } else {
  719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  720. return
  721. }
  722. } else { //读卡失败
  723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  724. return
  725. }
  726. }
  727. break
  728. }
  729. }
  730. var initFlag int64 = 0
  731. func (c *HisApiController) TestGetBasBaseInit() {
  732. DllDef := syscall.MustLoadDLL("SSCard.dll")
  733. Iinit := DllDef.MustFindProc("Init")
  734. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  735. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  736. if ret != 0 {
  737. fmt.Println("SSCard的报错原因:", err)
  738. fmt.Println("SSCard的运算结果为:", ret)
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  740. return
  741. }
  742. result := int(ret)
  743. fmt.Println("SSCard的运算结果为1:", result)
  744. initFlag = 1
  745. return
  746. }
  747. func (c *HisApiController) GetSFZBaseInfo() string {
  748. DllDef := syscall.MustLoadDLL("SSCard.dll")
  749. readCard := DllDef.MustFindProc("ReadSFZ")
  750. if readCard == nil {
  751. fmt.Println("readcard is nil")
  752. readCard = DllDef.MustFindProc("ReadSFZ")
  753. }
  754. str := make([]byte, 256)
  755. str1 := make([]byte, 256)
  756. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  757. fmt.Println(r)
  758. return string(str)
  759. }
  760. func (c *HisApiController) GetBasBaseInfo() string {
  761. DllDef := syscall.MustLoadDLL("SSCard.dll")
  762. readCard := DllDef.MustFindProc("ReadCardBas")
  763. if readCard == nil {
  764. fmt.Println("readcard is nil")
  765. readCard = DllDef.MustFindProc("ReadCardBas")
  766. }
  767. str := make([]byte, 1024)
  768. str1 := make([]byte, 1024)
  769. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  770. fmt.Println(string(str1))
  771. fmt.Println(string(str))
  772. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  773. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  774. if ret2 != 0 {
  775. return ""
  776. }
  777. return string(str)
  778. }
  779. type CustomFundPay struct {
  780. FundPayType string `json:"fund_pay_type"`
  781. FundPayamt float64 `json:"fund_payamt"`
  782. }
  783. func (c *HisApiController) GetSettleList() {
  784. order_id, _ := c.GetInt64("order_id")
  785. admin_user_id, _ := c.GetInt64("admin_user_id")
  786. order, _ := service.GetHisOrderByIDTwo(order_id)
  787. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  788. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  789. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  790. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  791. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  792. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  793. if order.ID == 0 {
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  795. return
  796. }
  797. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  798. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  799. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  800. fmt.Println(count)
  801. var zero string
  802. number := count + 1
  803. if number >= 1000 {
  804. zero = "0000" + strconv.FormatInt(number, 10)
  805. } else if number >= 10000 {
  806. zero = "000" + strconv.FormatInt(number, 10)
  807. } else if number >= 100000 {
  808. zero = "00" + strconv.FormatInt(number, 10)
  809. } else if number >= 1000000 {
  810. zero = "0" + strconv.FormatInt(number, 10)
  811. } else {
  812. zero = strconv.FormatInt(number, 10)
  813. }
  814. fmt.Println(zero)
  815. struct4101 := service.Struct4101{
  816. PsnNo: order.PsnNo,
  817. MdtrtId: order.MdtrtId,
  818. SetlId: order.SetlId,
  819. PsnName: order.PsnName,
  820. Gend: order.Gend,
  821. Brdy: his.Brdy,
  822. Age: his.Age,
  823. Naty: order.Naty,
  824. PatnCertType: "01",
  825. Certno: order.Certno,
  826. Prfs: "90",
  827. ConerName: roles[0].UserName,
  828. PatnRlts: "99",
  829. ConerAddr: miConfig.OrgName,
  830. ConerTel: admin.Mobile,
  831. HiType: order.Insutype,
  832. Insuplc: miConfig.InsuplcAdmdvs,
  833. MaindiagFlag: "1",
  834. BillCode: last_order.FaPiaoCode,
  835. BillNo: zero,
  836. BizSn: order.Number,
  837. PsnSelfPay: order.PsnPartAmt,
  838. PsnOwnPay: order.PsnPartAmt,
  839. AcctPay: order.AcctPay,
  840. PsnCashpay: order.PsnCashPay,
  841. HiPaymtd: "1",
  842. Hsorg: miConfig.InsuplcAdmdvs,
  843. HsorgOpter: miConfig.InsuplcAdmdvs,
  844. MedinsFillPsn: curRoles.UserName,
  845. MedinsFillDept: depart.Name,
  846. IptMedType: "2",
  847. }
  848. struct4101.SetlBegnDate = order.SetlTime
  849. struct4101.SetlEndDate = order.SetlTime
  850. time_arr := strings.Split(order.SetlTime, " ")
  851. struct4101.AdmTime = time_arr[0]
  852. struct4101.AdmEndTime = time_arr[0]
  853. var rf []CustomFundPay
  854. json.Unmarshal([]byte(order.SetlDetail), &rf)
  855. var tempFunPays []service.CustomStruct
  856. for _, item := range rf {
  857. var tempFunPay service.CustomStruct
  858. tempFunPay.FundPayamt = item.FundPayamt
  859. tempFunPay.FundPayType = item.FundPayType
  860. tempFunPays = append(tempFunPays, tempFunPay)
  861. }
  862. struct4101.CustomStruct = tempFunPays
  863. var tempDiaginfos []service.DiaginfoStructTwo
  864. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  865. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  866. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  867. var config []*models.HisXtDiagnoseConfig
  868. for _, item := range diagnosis_ids {
  869. id, _ := strconv.ParseInt(item, 10, 64)
  870. diagnosisConfig, _ := service.FindDiagnoseById(id)
  871. config = append(config, &diagnosisConfig)
  872. }
  873. for index, item := range config {
  874. if index == 0 {
  875. var tempDiaginfo service.DiaginfoStructTwo
  876. tempDiaginfo.DiagCode = item.CountryCode
  877. tempDiaginfo.DiagName = item.CountryContentName
  878. tempDiaginfo.DiagType = "1"
  879. tempDiaginfo.MaindiagFlag = "1"
  880. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  881. } else {
  882. var tempDiaginfo service.DiaginfoStructTwo
  883. tempDiaginfo.DiagCode = item.CountryCode
  884. tempDiaginfo.DiagName = item.CountryContentName
  885. tempDiaginfo.DiagType = "2"
  886. tempDiaginfo.MaindiagFlag = "0"
  887. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  888. }
  889. }
  890. struct4101.Diseinfo = tempDiaginfos
  891. sickConfigTwo, _ := service.FindSickById(his.SickType)
  892. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  893. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  894. tempOpspdiseinfo2.OprnOprtCode = ""
  895. tempOpspdiseinfo2.OprnOprtName = ""
  896. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  897. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  898. var iteminfo service.IteminfoStruct
  899. var bedCostTotal float64 = 0 //床位总费
  900. var bedCostSelfTotal float64 = 0 //床位自费
  901. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  902. var operationCostTotal float64 = 0 //手术费
  903. var operationCostSelfTotal float64 = 0 //手术费
  904. var operationCostPartSelfTotal float64 = 0 //手术费
  905. var otherCostTotal float64 = 0 //其他费用
  906. var otherCostSelfTotal float64 = 0 //其他费用
  907. var otherCostPartSelfTotal float64 = 0 //其他费用
  908. var materialCostTotal float64 = 0 //材料费
  909. var materialCostSelfTotal float64 = 0 //材料费
  910. var materialCostPartSelfTotal float64 = 0 //材料费
  911. var westernMedicineCostTotal float64 = 0 //西药费
  912. var westernMedicineCostSelfTotal float64 = 0 //西药费
  913. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  914. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  915. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  916. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  917. var checkCostTotal float64 = 0 //检查费
  918. var checkCostSelfTotal float64 = 0 //检查费
  919. var checkCostPartSelfTotal float64 = 0 //检查费
  920. var laboratoryCostTotal float64 = 0 //化验费
  921. var laboratoryCostSelfTotal float64 = 0 //化验费
  922. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  923. var treatCostTotal float64 = 0 //治疗费用
  924. var treatCostSelfTotal float64 = 0 //治疗费用
  925. var treatCostPartSelfTotal float64 = 0 //治疗费用
  926. decimal.DivisionPrecision = 2
  927. var bed_fulamt_ownpay_amt float64 = 0
  928. var operation_fulamt_ownpay_amt float64 = 0
  929. var other_fulamt_ownpay_amt float64 = 0
  930. var westernMedicine_fulamt_ownpay_amt float64 = 0
  931. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  932. var check_fulamt_ownpay_amt float64 = 0
  933. var material_fulamt_ownpay_amt float64 = 0
  934. var laboratory_fulamt_ownpay_amt float64 = 0
  935. var treat_fulamt_ownpay_amt float64 = 0
  936. var bed_claa_sunmfee float64 = 0
  937. var bed_clab_amt float64 = 0
  938. var bed_other_amt float64 = 0
  939. var operation_claa_sunmfee float64 = 0
  940. var operation_clab_amt float64 = 0
  941. var operation_other_amt float64 = 0
  942. var other_claa_sunmfee float64 = 0
  943. var other_clab_amt float64 = 0
  944. var other_other_amt float64 = 0
  945. var westernMedicine_claa_sunmfee float64 = 0
  946. var westernMedicine_clab_amt float64 = 0
  947. var westernMedicine_other_amt float64 = 0
  948. var chineseTraditional_claa_sunmfee float64 = 0
  949. var chineseTraditional_clab_amt float64 = 0
  950. var chineseTraditional_other_amt float64 = 0
  951. var check_claa_sunmfee float64 = 0
  952. var check_clab_amt float64 = 0
  953. var check_other_amt float64 = 0
  954. var material_claa_sunmfee float64 = 0
  955. var material_clab_amt float64 = 0
  956. var material_other_amt float64 = 0
  957. var laboratory_claa_sunmfee float64 = 0
  958. var laboratory_clab_amt float64 = 0
  959. var laboratory_other_amt float64 = 0
  960. var treat_claa_sunmfee float64 = 0
  961. var treat_clab_amt float64 = 0
  962. var treat_other_amt float64 = 0
  963. for _, item := range order.HisOrderInfo {
  964. if item.MedChrgitmType == "01" { //床位费
  965. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  966. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  967. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  968. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  969. if item.ChrgitmLv == "1" {
  970. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  971. }
  972. if item.ChrgitmLv == "2" {
  973. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  974. }
  975. if item.ChrgitmLv == "3" {
  976. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  977. }
  978. }
  979. if item.MedChrgitmType == "03" { //检查费
  980. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  981. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  982. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  983. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  984. if item.ChrgitmLv == "1" {
  985. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  986. }
  987. if item.ChrgitmLv == "2" {
  988. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  989. }
  990. if item.ChrgitmLv == "3" {
  991. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  992. }
  993. }
  994. if item.MedChrgitmType == "04" { //化验费
  995. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  996. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  997. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  998. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  999. if item.ChrgitmLv == "1" {
  1000. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1001. }
  1002. if item.ChrgitmLv == "2" {
  1003. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1004. }
  1005. if item.ChrgitmLv == "3" {
  1006. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1007. }
  1008. }
  1009. if item.MedChrgitmType == "05" { //治疗费
  1010. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1011. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1012. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1013. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1014. if item.ChrgitmLv == "1" {
  1015. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1016. }
  1017. if item.ChrgitmLv == "2" {
  1018. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1019. }
  1020. if item.ChrgitmLv == "3" {
  1021. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1022. }
  1023. }
  1024. if item.MedChrgitmType == "06" { //手术费
  1025. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1026. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1027. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1028. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1029. if item.ChrgitmLv == "1" {
  1030. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1031. }
  1032. if item.ChrgitmLv == "2" {
  1033. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1034. }
  1035. if item.ChrgitmLv == "3" {
  1036. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1037. }
  1038. }
  1039. if item.MedChrgitmType == "08" { //材料费
  1040. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1041. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1042. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1043. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1044. if item.ChrgitmLv == "1" {
  1045. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1046. }
  1047. if item.ChrgitmLv == "2" {
  1048. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1049. }
  1050. if item.ChrgitmLv == "3" {
  1051. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1052. }
  1053. }
  1054. if item.MedChrgitmType == "09" { //西药费
  1055. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1056. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1057. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1058. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1059. if item.ChrgitmLv == "1" {
  1060. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1061. }
  1062. if item.ChrgitmLv == "2" {
  1063. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1064. }
  1065. if item.ChrgitmLv == "3" {
  1066. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1067. }
  1068. }
  1069. if item.MedChrgitmType == "11" { //中成费
  1070. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1071. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1072. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1073. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1074. if item.ChrgitmLv == "1" {
  1075. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1076. }
  1077. if item.ChrgitmLv == "2" {
  1078. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1079. }
  1080. if item.ChrgitmLv == "3" {
  1081. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1082. }
  1083. }
  1084. if item.MedChrgitmType == "14" { //其他费
  1085. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1086. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1087. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1088. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1089. if item.ChrgitmLv == "1" {
  1090. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1091. }
  1092. if item.ChrgitmLv == "2" {
  1093. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1094. }
  1095. if item.ChrgitmLv == "3" {
  1096. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1097. }
  1098. }
  1099. }
  1100. var iteminfoStructs []service.IteminfoStruct
  1101. if bedCostTotal != 0 {
  1102. iteminfo.MedChrgitm = "01"
  1103. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1104. iteminfo.Amt = bedCostTotal
  1105. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1106. iteminfo.ClabAmt = bed_clab_amt
  1107. iteminfo.OthAmt = bed_other_amt
  1108. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1109. }
  1110. if checkCostTotal != 0 {
  1111. iteminfo.MedChrgitm = "03"
  1112. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1113. iteminfo.Amt = checkCostTotal
  1114. iteminfo.ClaaSumfee = check_claa_sunmfee
  1115. iteminfo.ClabAmt = check_clab_amt
  1116. iteminfo.OthAmt = check_other_amt
  1117. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1118. }
  1119. if laboratoryCostTotal != 0 {
  1120. iteminfo.MedChrgitm = "04"
  1121. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1122. iteminfo.Amt = laboratoryCostTotal
  1123. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1124. iteminfo.ClabAmt = laboratory_clab_amt
  1125. iteminfo.OthAmt = laboratory_other_amt
  1126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1127. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1128. }
  1129. if treatCostTotal != 0 {
  1130. iteminfo.MedChrgitm = "05"
  1131. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1132. iteminfo.Amt = treatCostTotal
  1133. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1134. iteminfo.ClabAmt = treat_clab_amt
  1135. iteminfo.OthAmt = treat_other_amt
  1136. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1137. //(struct4101.IteminfoStruct, iteminfo)
  1138. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1139. }
  1140. if operationCostTotal != 0 {
  1141. iteminfo.MedChrgitm = "06"
  1142. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1143. iteminfo.Amt = operationCostTotal
  1144. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1145. iteminfo.ClabAmt = operation_clab_amt
  1146. iteminfo.OthAmt = operation_other_amt
  1147. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1149. }
  1150. if materialCostTotal != 0 {
  1151. iteminfo.MedChrgitm = "08"
  1152. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1153. iteminfo.Amt = materialCostTotal
  1154. iteminfo.ClaaSumfee = material_claa_sunmfee
  1155. iteminfo.ClabAmt = material_clab_amt
  1156. iteminfo.OthAmt = material_other_amt
  1157. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1159. }
  1160. if westernMedicineCostTotal != 0 {
  1161. iteminfo.MedChrgitm = "09"
  1162. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1163. iteminfo.Amt = westernMedicineCostTotal
  1164. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1165. iteminfo.ClabAmt = westernMedicine_clab_amt
  1166. iteminfo.OthAmt = westernMedicine_other_amt
  1167. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1169. }
  1170. if chineseTraditionalMedicineCostTotal != 0 {
  1171. iteminfo.MedChrgitm = "11"
  1172. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1173. iteminfo.Amt = westernMedicineCostTotal
  1174. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1175. iteminfo.ClabAmt = westernMedicine_clab_amt
  1176. iteminfo.OthAmt = westernMedicine_other_amt
  1177. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1179. }
  1180. if otherCostTotal != 0 {
  1181. iteminfo.MedChrgitm = "14"
  1182. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1183. iteminfo.Amt = otherCostTotal
  1184. iteminfo.ClaaSumfee = other_claa_sunmfee
  1185. iteminfo.ClabAmt = other_clab_amt
  1186. iteminfo.OthAmt = other_other_amt
  1187. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1188. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1189. }
  1190. struct4101.IteminfoStruct = iteminfoStructs
  1191. struct4101.Ntly = "中国"
  1192. struct4101.AdmCaty = "A03.06"
  1193. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1194. fmt.Println(result)
  1195. var dat map[string]interface{}
  1196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1197. fmt.Println(dat)
  1198. } else {
  1199. fmt.Println(err)
  1200. }
  1201. userJSONBytes, _ := json.Marshal(dat)
  1202. var res ResultSeventeen
  1203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1204. utils.ErrorLog("解析失败:%v", err)
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. return
  1207. }
  1208. if res.Infcode != 0 {
  1209. c.ServeSuccessJSON(map[string]interface{}{
  1210. "failed_code": -10,
  1211. "msg": res.ErrMsg,
  1212. })
  1213. return
  1214. } else {
  1215. order.FaPiaoNumber = zero
  1216. order.FaPiaoCode = last_order.FaPiaoCode
  1217. service.UpdateOrder(order)
  1218. hisFundSettleListResult := &models.HisFundSettleListResult{
  1219. Number: res.Output.SetlListId,
  1220. Status: 1,
  1221. Ctime: time.Now().Unix(),
  1222. Mtime: time.Now().Unix(),
  1223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1224. IsUpload: 1,
  1225. OrderId: order_id,
  1226. }
  1227. service.CreateUploadRecord(hisFundSettleListResult)
  1228. c.ServeSuccessJSON(map[string]interface{}{
  1229. "msg": "上传成功",
  1230. "result": hisFundSettleListResult,
  1231. })
  1232. return
  1233. }
  1234. }
  1235. func (c *HisApiController) GetSettleListHospital() {
  1236. order_id, _ := c.GetInt64("order_id")
  1237. admin_user_id, _ := c.GetInt64("admin_user_id")
  1238. order, _ := service.GetHisOrderByIDTwo(order_id)
  1239. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1240. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1241. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1242. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1243. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1245. if order.ID == 0 {
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1247. return
  1248. }
  1249. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1250. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1251. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1252. fmt.Println(count)
  1253. var zero string
  1254. number := count + 1
  1255. if number >= 1000 {
  1256. zero = "0000" + strconv.FormatInt(number, 10)
  1257. } else if number >= 10000 {
  1258. zero = "000" + strconv.FormatInt(number, 10)
  1259. } else if number >= 100000 {
  1260. zero = "00" + strconv.FormatInt(number, 10)
  1261. } else if number >= 1000000 {
  1262. zero = "0" + strconv.FormatInt(number, 10)
  1263. } else {
  1264. zero = strconv.FormatInt(number, 10)
  1265. }
  1266. fmt.Println(zero)
  1267. struct4101 := service.Struct4101{
  1268. PsnNo: order.PsnNo,
  1269. MdtrtId: order.MdtrtId,
  1270. SetlId: order.SetlId,
  1271. PsnName: order.PsnName,
  1272. Gend: order.Gend,
  1273. Brdy: his.Brdy,
  1274. Age: int64(order.Age),
  1275. Naty: order.Naty,
  1276. PatnCertType: "01",
  1277. Certno: order.Certno,
  1278. Prfs: "90",
  1279. ConerName: roles[0].UserName,
  1280. PatnRlts: "99",
  1281. ConerAddr: miConfig.OrgName,
  1282. ConerTel: admin.Mobile,
  1283. HiType: order.Insutype,
  1284. Insuplc: miConfig.InsuplcAdmdvs,
  1285. MaindiagFlag: "1",
  1286. BillCode: last_order.FaPiaoCode,
  1287. BillNo: zero,
  1288. BizSn: order.Number,
  1289. PsnSelfPay: order.PsnPartAmt,
  1290. PsnOwnPay: order.PsnPartAmt,
  1291. AcctPay: order.AcctPay,
  1292. PsnCashpay: order.PsnCashPay,
  1293. HiPaymtd: "1",
  1294. Hsorg: miConfig.InsuplcAdmdvs,
  1295. HsorgOpter: miConfig.InsuplcAdmdvs,
  1296. MedinsFillPsn: curRoles.UserName,
  1297. MedinsFillDept: depart.Name,
  1298. IptMedType: "2",
  1299. AdmTime: his.InHosptialTime,
  1300. AdmEndTime: his.OutHosptialTime,
  1301. }
  1302. struct4101.SetlBegnDate = order.SetlTime
  1303. struct4101.SetlEndDate = order.SetlTime
  1304. var rf []CustomFundPay
  1305. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1306. var tempFunPays []service.CustomStruct
  1307. for _, item := range rf {
  1308. var tempFunPay service.CustomStruct
  1309. tempFunPay.FundPayamt = item.FundPayamt
  1310. tempFunPay.FundPayType = item.FundPayType
  1311. tempFunPays = append(tempFunPays, tempFunPay)
  1312. }
  1313. struct4101.CustomStruct = tempFunPays
  1314. var tempDiaginfos []service.DiaginfoStructTwo
  1315. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1316. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1317. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1318. var config []*models.HisXtDiagnoseConfig
  1319. for _, item := range diagnosis_ids {
  1320. id, _ := strconv.ParseInt(item, 10, 64)
  1321. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1322. config = append(config, &diagnosisConfig)
  1323. }
  1324. for index, item := range config {
  1325. if index == 0 {
  1326. var tempDiaginfo service.DiaginfoStructTwo
  1327. tempDiaginfo.DiagCode = item.CountryCode
  1328. tempDiaginfo.DiagName = item.CountryContentName
  1329. tempDiaginfo.DiagType = "1"
  1330. tempDiaginfo.MaindiagFlag = "1"
  1331. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1332. } else {
  1333. var tempDiaginfo service.DiaginfoStructTwo
  1334. tempDiaginfo.DiagCode = item.CountryCode
  1335. tempDiaginfo.DiagName = item.CountryContentName
  1336. tempDiaginfo.DiagType = "2"
  1337. tempDiaginfo.MaindiagFlag = "0"
  1338. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1339. }
  1340. }
  1341. struct4101.Diseinfo = tempDiaginfos
  1342. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1343. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1344. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1345. tempOpspdiseinfo2.OprnOprtCode = ""
  1346. tempOpspdiseinfo2.OprnOprtName = ""
  1347. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1348. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1349. var iteminfo service.IteminfoStruct
  1350. var bedCostTotal float64 = 0 //床位总费
  1351. var bedCostSelfTotal float64 = 0 //床位自费
  1352. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1353. var operationCostTotal float64 = 0 //手术费
  1354. var operationCostSelfTotal float64 = 0 //手术费
  1355. var operationCostPartSelfTotal float64 = 0 //手术费
  1356. var otherCostTotal float64 = 0 //其他费用
  1357. var otherCostSelfTotal float64 = 0 //其他费用
  1358. var otherCostPartSelfTotal float64 = 0 //其他费用
  1359. var materialCostTotal float64 = 0 //材料费
  1360. var materialCostSelfTotal float64 = 0 //材料费
  1361. var materialCostPartSelfTotal float64 = 0 //材料费
  1362. var westernMedicineCostTotal float64 = 0 //西药费
  1363. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1364. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1365. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1366. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1367. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1368. var checkCostTotal float64 = 0 //检查费
  1369. var checkCostSelfTotal float64 = 0 //检查费
  1370. var checkCostPartSelfTotal float64 = 0 //检查费
  1371. var laboratoryCostTotal float64 = 0 //化验费
  1372. var laboratoryCostSelfTotal float64 = 0 //化验费
  1373. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1374. var treatCostTotal float64 = 0 //治疗费用
  1375. var treatCostSelfTotal float64 = 0 //治疗费用
  1376. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1377. decimal.DivisionPrecision = 2
  1378. var bed_fulamt_ownpay_amt float64 = 0
  1379. var operation_fulamt_ownpay_amt float64 = 0
  1380. var other_fulamt_ownpay_amt float64 = 0
  1381. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1382. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1383. var check_fulamt_ownpay_amt float64 = 0
  1384. var material_fulamt_ownpay_amt float64 = 0
  1385. var laboratory_fulamt_ownpay_amt float64 = 0
  1386. var treat_fulamt_ownpay_amt float64 = 0
  1387. var bed_claa_sunmfee float64 = 0
  1388. var bed_clab_amt float64 = 0
  1389. var bed_other_amt float64 = 0
  1390. var operation_claa_sunmfee float64 = 0
  1391. var operation_clab_amt float64 = 0
  1392. var operation_other_amt float64 = 0
  1393. var other_claa_sunmfee float64 = 0
  1394. var other_clab_amt float64 = 0
  1395. var other_other_amt float64 = 0
  1396. var westernMedicine_claa_sunmfee float64 = 0
  1397. var westernMedicine_clab_amt float64 = 0
  1398. var westernMedicine_other_amt float64 = 0
  1399. var chineseTraditional_claa_sunmfee float64 = 0
  1400. var chineseTraditional_clab_amt float64 = 0
  1401. var chineseTraditional_other_amt float64 = 0
  1402. var check_claa_sunmfee float64 = 0
  1403. var check_clab_amt float64 = 0
  1404. var check_other_amt float64 = 0
  1405. var material_claa_sunmfee float64 = 0
  1406. var material_clab_amt float64 = 0
  1407. var material_other_amt float64 = 0
  1408. var laboratory_claa_sunmfee float64 = 0
  1409. var laboratory_clab_amt float64 = 0
  1410. var laboratory_other_amt float64 = 0
  1411. var treat_claa_sunmfee float64 = 0
  1412. var treat_clab_amt float64 = 0
  1413. var treat_other_amt float64 = 0
  1414. for _, item := range order.HisOrderInfo {
  1415. if item.MedChrgitmType == "01" { //床位费
  1416. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1417. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1418. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1419. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1420. if item.ChrgitmLv == "1" {
  1421. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1422. }
  1423. if item.ChrgitmLv == "2" {
  1424. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1425. }
  1426. if item.ChrgitmLv == "3" {
  1427. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1428. }
  1429. }
  1430. if item.MedChrgitmType == "03" { //检查费
  1431. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1432. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1433. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1434. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1435. if item.ChrgitmLv == "1" {
  1436. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1437. }
  1438. if item.ChrgitmLv == "2" {
  1439. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1440. }
  1441. if item.ChrgitmLv == "3" {
  1442. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1443. }
  1444. }
  1445. if item.MedChrgitmType == "04" { //化验费
  1446. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1447. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1448. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1449. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1450. if item.ChrgitmLv == "1" {
  1451. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1452. }
  1453. if item.ChrgitmLv == "2" {
  1454. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1455. }
  1456. if item.ChrgitmLv == "3" {
  1457. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1458. }
  1459. }
  1460. if item.MedChrgitmType == "05" { //治疗费
  1461. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1462. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1463. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1464. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1465. if item.ChrgitmLv == "1" {
  1466. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1467. }
  1468. if item.ChrgitmLv == "2" {
  1469. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1470. }
  1471. if item.ChrgitmLv == "3" {
  1472. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1473. }
  1474. }
  1475. if item.MedChrgitmType == "06" { //手术费
  1476. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1477. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1478. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1479. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1480. if item.ChrgitmLv == "1" {
  1481. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1482. }
  1483. if item.ChrgitmLv == "2" {
  1484. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1485. }
  1486. if item.ChrgitmLv == "3" {
  1487. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1488. }
  1489. }
  1490. if item.MedChrgitmType == "08" { //材料费
  1491. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1492. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1493. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1494. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1495. if item.ChrgitmLv == "1" {
  1496. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1497. }
  1498. if item.ChrgitmLv == "2" {
  1499. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1500. }
  1501. if item.ChrgitmLv == "3" {
  1502. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1503. }
  1504. }
  1505. if item.MedChrgitmType == "09" { //西药费
  1506. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1507. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1508. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1509. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1510. if item.ChrgitmLv == "1" {
  1511. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1512. }
  1513. if item.ChrgitmLv == "2" {
  1514. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1515. }
  1516. if item.ChrgitmLv == "3" {
  1517. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1518. }
  1519. }
  1520. if item.MedChrgitmType == "11" { //中成费
  1521. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1522. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1523. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1524. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1525. if item.ChrgitmLv == "1" {
  1526. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1527. }
  1528. if item.ChrgitmLv == "2" {
  1529. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1530. }
  1531. if item.ChrgitmLv == "3" {
  1532. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1533. }
  1534. }
  1535. if item.MedChrgitmType == "14" { //其他费
  1536. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1537. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1538. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1539. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1540. if item.ChrgitmLv == "1" {
  1541. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1542. }
  1543. if item.ChrgitmLv == "2" {
  1544. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1545. }
  1546. if item.ChrgitmLv == "3" {
  1547. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1548. }
  1549. }
  1550. }
  1551. var iteminfoStructs []service.IteminfoStruct
  1552. if bedCostTotal != 0 {
  1553. iteminfo.MedChrgitm = "01"
  1554. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1555. iteminfo.Amt = bedCostTotal
  1556. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1557. iteminfo.ClabAmt = bed_clab_amt
  1558. iteminfo.OthAmt = bed_other_amt
  1559. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1560. }
  1561. if checkCostTotal != 0 {
  1562. iteminfo.MedChrgitm = "03"
  1563. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1564. iteminfo.Amt = checkCostTotal
  1565. iteminfo.ClaaSumfee = check_claa_sunmfee
  1566. iteminfo.ClabAmt = check_clab_amt
  1567. iteminfo.OthAmt = check_other_amt
  1568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1569. }
  1570. if laboratoryCostTotal != 0 {
  1571. iteminfo.MedChrgitm = "04"
  1572. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1573. iteminfo.Amt = laboratoryCostTotal
  1574. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1575. iteminfo.ClabAmt = laboratory_clab_amt
  1576. iteminfo.OthAmt = laboratory_other_amt
  1577. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1578. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1579. }
  1580. if treatCostTotal != 0 {
  1581. iteminfo.MedChrgitm = "05"
  1582. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1583. iteminfo.Amt = treatCostTotal
  1584. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1585. iteminfo.ClabAmt = treat_clab_amt
  1586. iteminfo.OthAmt = treat_other_amt
  1587. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1588. //(struct4101.IteminfoStruct, iteminfo)
  1589. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1590. }
  1591. if operationCostTotal != 0 {
  1592. iteminfo.MedChrgitm = "06"
  1593. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1594. iteminfo.Amt = operationCostTotal
  1595. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1596. iteminfo.ClabAmt = operation_clab_amt
  1597. iteminfo.OthAmt = operation_other_amt
  1598. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1599. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1600. }
  1601. if materialCostTotal != 0 {
  1602. iteminfo.MedChrgitm = "08"
  1603. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1604. iteminfo.Amt = materialCostTotal
  1605. iteminfo.ClaaSumfee = material_claa_sunmfee
  1606. iteminfo.ClabAmt = material_clab_amt
  1607. iteminfo.OthAmt = material_other_amt
  1608. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1609. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1610. }
  1611. if westernMedicineCostTotal != 0 {
  1612. iteminfo.MedChrgitm = "09"
  1613. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1614. iteminfo.Amt = westernMedicineCostTotal
  1615. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1616. iteminfo.ClabAmt = westernMedicine_clab_amt
  1617. iteminfo.OthAmt = westernMedicine_other_amt
  1618. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1619. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1620. }
  1621. if chineseTraditionalMedicineCostTotal != 0 {
  1622. iteminfo.MedChrgitm = "11"
  1623. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1624. iteminfo.Amt = westernMedicineCostTotal
  1625. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1626. iteminfo.ClabAmt = westernMedicine_clab_amt
  1627. iteminfo.OthAmt = westernMedicine_other_amt
  1628. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1629. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1630. }
  1631. if otherCostTotal != 0 {
  1632. iteminfo.MedChrgitm = "14"
  1633. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1634. iteminfo.Amt = otherCostTotal
  1635. iteminfo.ClaaSumfee = other_claa_sunmfee
  1636. iteminfo.ClabAmt = other_clab_amt
  1637. iteminfo.OthAmt = other_other_amt
  1638. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1639. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1640. }
  1641. struct4101.IteminfoStruct = iteminfoStructs
  1642. struct4101.Ntly = "中国"
  1643. struct4101.AdmCaty = "A03.06"
  1644. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1645. fmt.Println(result)
  1646. var dat map[string]interface{}
  1647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1648. fmt.Println(dat)
  1649. } else {
  1650. fmt.Println(err)
  1651. }
  1652. userJSONBytes, _ := json.Marshal(dat)
  1653. var res ResultSeventeen
  1654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1655. utils.ErrorLog("解析失败:%v", err)
  1656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1657. return
  1658. }
  1659. if res.Infcode != 0 {
  1660. c.ServeSuccessJSON(map[string]interface{}{
  1661. "failed_code": -10,
  1662. "msg": res.ErrMsg,
  1663. })
  1664. return
  1665. } else {
  1666. order.FaPiaoNumber = zero
  1667. order.FaPiaoCode = last_order.FaPiaoCode
  1668. service.UpdateOrder(order)
  1669. hisFundSettleListResult := &models.HisFundSettleListResult{
  1670. Number: res.Output.SetlListId,
  1671. Status: 1,
  1672. Ctime: time.Now().Unix(),
  1673. Mtime: time.Now().Unix(),
  1674. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1675. IsUpload: 1,
  1676. OrderId: order_id,
  1677. }
  1678. service.CreateUploadRecord(hisFundSettleListResult)
  1679. c.ServeSuccessJSON(map[string]interface{}{
  1680. "msg": "上传成功",
  1681. "result": hisFundSettleListResult,
  1682. })
  1683. return
  1684. }
  1685. }
  1686. func (c *HisApiController) GetBatchSettleList() {
  1687. orders, _ := service.GetAllHisOrder(10106)
  1688. for _, item := range orders {
  1689. order_id := item.ID
  1690. order, _ := service.GetHisOrderByIDTwo(order_id)
  1691. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1692. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1693. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1694. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1695. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1696. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1697. if order.ID == 0 {
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1699. return
  1700. }
  1701. if his.BalanceAccountsType == 2 {
  1702. continue
  1703. }
  1704. struct4101 := service.Struct4101{
  1705. PsnNo: order.PsnNo,
  1706. MdtrtId: order.MdtrtId,
  1707. SetlId: order.SetlId,
  1708. PsnName: order.PsnName,
  1709. Gend: order.Gend,
  1710. Brdy: his.Brdy,
  1711. Age: his.Age,
  1712. Naty: order.Naty,
  1713. PatnCertType: "01",
  1714. Certno: order.Certno,
  1715. Prfs: "90",
  1716. ConerName: roles[0].UserName,
  1717. PatnRlts: "99",
  1718. ConerAddr: miConfig.OrgName,
  1719. ConerTel: admin.Mobile,
  1720. HiType: order.Insutype,
  1721. Insuplc: his.InsuplcAdmdvs,
  1722. MaindiagFlag: "1",
  1723. BillCode: order.FaPiaoCode,
  1724. BillNo: order.FaPiaoNumber,
  1725. BizSn: order.Number,
  1726. PsnSelfPay: order.PsnPartAmt,
  1727. PsnOwnPay: order.PsnPartAmt,
  1728. AcctPay: order.AcctPay,
  1729. PsnCashpay: order.PsnCashPay,
  1730. HiPaymtd: "1",
  1731. Hsorg: his.InsuplcAdmdvs,
  1732. HsorgOpter: his.InsuplcAdmdvs,
  1733. MedinsFillPsn: curRoles.UserName,
  1734. MedinsFillDept: depart.Name,
  1735. IptMedType: "2",
  1736. }
  1737. struct4101.SetlBegnDate = order.SetlTime
  1738. struct4101.SetlEndDate = order.SetlTime
  1739. //if order.SettleType == 1 {
  1740. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1741. // dateStr := t.Format("2006-01-02")
  1742. // struct4101.SetlBegnDate = dateStr
  1743. // struct4101.SetlEndDate = dateStr
  1744. //} else {
  1745. // t := time.Unix(int64(order.SettleStartTime), 0)
  1746. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1747. // dateStartStr := t.Format("2006-01-02")
  1748. // dateEndStr := t2.Format("2006-01-02")
  1749. // struct4101.SetlBegnDate = dateStartStr
  1750. // struct4101.SetlEndDate = dateEndStr
  1751. //}
  1752. var rf []CustomFundPay
  1753. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1754. var tempFunPays []service.CustomStruct
  1755. var tempFunPay610100 service.CustomStruct
  1756. for _, item := range rf {
  1757. if item.FundPayType == "610100" {
  1758. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1759. tempFunPay610100.FundPayType = item.FundPayType
  1760. } else {
  1761. var tempFunPay service.CustomStruct
  1762. tempFunPay.FundPayamt = item.FundPayamt
  1763. tempFunPay.FundPayType = item.FundPayType
  1764. tempFunPays = append(tempFunPays, tempFunPay)
  1765. }
  1766. }
  1767. tempFunPays = append(tempFunPays, tempFunPay610100)
  1768. struct4101.CustomStruct = tempFunPays
  1769. var tempDiaginfos []service.DiaginfoStructTwo
  1770. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1771. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1772. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1773. var config []*models.HisXtDiagnoseConfig
  1774. for _, item := range diagnosis_ids {
  1775. id, _ := strconv.ParseInt(item, 10, 64)
  1776. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1777. config = append(config, &diagnosisConfig)
  1778. }
  1779. for index, item := range config {
  1780. if index == 0 {
  1781. var tempDiaginfo service.DiaginfoStructTwo
  1782. tempDiaginfo.DiagCode = item.CountryCode
  1783. tempDiaginfo.DiagName = item.CountryContentName
  1784. tempDiaginfo.DiagType = "1"
  1785. tempDiaginfo.MaindiagFlag = "1"
  1786. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1787. } else {
  1788. var tempDiaginfo service.DiaginfoStructTwo
  1789. tempDiaginfo.DiagCode = item.CountryCode
  1790. tempDiaginfo.DiagName = item.CountryContentName
  1791. tempDiaginfo.DiagType = "2"
  1792. tempDiaginfo.MaindiagFlag = "0"
  1793. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1794. }
  1795. }
  1796. struct4101.Diseinfo = tempDiaginfos
  1797. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1798. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1799. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1800. tempOpspdiseinfo2.OprnOprtCode = ""
  1801. tempOpspdiseinfo2.OprnOprtName = ""
  1802. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1803. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1804. var iteminfo service.IteminfoStruct
  1805. var bedCostTotal float64 = 0 //床位总费
  1806. var bedCostSelfTotal float64 = 0 //床位自费
  1807. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1808. var examineCostTotal float64 = 0 //诊查总费
  1809. var examineCostSelfTotal float64 = 0 //诊查自费
  1810. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1811. var nursingCostTotal float64 = 0 //护理总费
  1812. var nursingCostSelfTotal float64 = 0 //护理自费
  1813. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1814. var chineseMedicineCostTotal float64 = 0 //中成药
  1815. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1816. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1817. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1818. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1819. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1820. var registerCostTotal float64 = 0 //一般诊疗费
  1821. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1822. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1823. var operationCostTotal float64 = 0 //手术费
  1824. var operationCostSelfTotal float64 = 0 //手术费
  1825. var operationCostPartSelfTotal float64 = 0 //手术费
  1826. var otherCostTotal float64 = 0 //其他费用
  1827. var otherCostSelfTotal float64 = 0 //其他费用
  1828. var otherCostPartSelfTotal float64 = 0 //其他费用
  1829. var materialCostTotal float64 = 0 //材料费
  1830. var materialCostSelfTotal float64 = 0 //材料费
  1831. var materialCostPartSelfTotal float64 = 0 //材料费
  1832. var westernMedicineCostTotal float64 = 0 //西药费
  1833. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1834. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1835. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1836. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1837. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1838. var checkCostTotal float64 = 0 //检查费
  1839. var checkCostSelfTotal float64 = 0 //检查费
  1840. var checkCostPartSelfTotal float64 = 0 //检查费
  1841. var laboratoryCostTotal float64 = 0 //化验费
  1842. var laboratoryCostSelfTotal float64 = 0 //化验费
  1843. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1844. var treatCostTotal float64 = 0 //治疗费用
  1845. var treatCostSelfTotal float64 = 0 //治疗费用
  1846. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1847. decimal.DivisionPrecision = 2
  1848. var bed_fulamt_ownpay_amt float64 = 0
  1849. var examine_fulamt_ownpay_amt float64 = 0
  1850. var nursing_fulamt_ownpay_amt float64 = 0
  1851. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1852. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1853. var register_fulamt_ownpay_amt float64 = 0
  1854. var operation_fulamt_ownpay_amt float64 = 0
  1855. var other_fulamt_ownpay_amt float64 = 0
  1856. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1857. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1858. var check_fulamt_ownpay_amt float64 = 0
  1859. var material_fulamt_ownpay_amt float64 = 0
  1860. var laboratory_fulamt_ownpay_amt float64 = 0
  1861. var treat_fulamt_ownpay_amt float64 = 0
  1862. var bed_claa_sunmfee float64 = 0
  1863. var bed_clab_amt float64 = 0
  1864. var bed_other_amt float64 = 0
  1865. var examine_claa_sunmfee float64 = 0
  1866. var examine_clab_amt float64 = 0
  1867. var examine_other_amt float64 = 0
  1868. var nursing_claa_sunmfee float64 = 0
  1869. var nursing_clab_amt float64 = 0
  1870. var nursing_other_amt float64 = 0
  1871. var chinese_medicine_claa_sunmfee float64 = 0
  1872. var chinese_medicine_clab_amt float64 = 0
  1873. var chinese_medicine_other_amt float64 = 0
  1874. var commonly_treatment_claa_sunmfee float64 = 0
  1875. var commonly_treatment_clab_amt float64 = 0
  1876. var commonly_treatment_other_amt float64 = 0
  1877. var operation_claa_sunmfee float64 = 0
  1878. var operation_clab_amt float64 = 0
  1879. var operation_other_amt float64 = 0
  1880. var other_claa_sunmfee float64 = 0
  1881. var other_clab_amt float64 = 0
  1882. var other_other_amt float64 = 0
  1883. var westernMedicine_claa_sunmfee float64 = 0
  1884. var westernMedicine_clab_amt float64 = 0
  1885. var westernMedicine_other_amt float64 = 0
  1886. var chineseTraditional_claa_sunmfee float64 = 0
  1887. var chineseTraditional_clab_amt float64 = 0
  1888. var chineseTraditional_other_amt float64 = 0
  1889. var check_claa_sunmfee float64 = 0
  1890. var check_clab_amt float64 = 0
  1891. var check_other_amt float64 = 0
  1892. var material_claa_sunmfee float64 = 0
  1893. var material_clab_amt float64 = 0
  1894. var material_other_amt float64 = 0
  1895. var laboratory_claa_sunmfee float64 = 0
  1896. var laboratory_clab_amt float64 = 0
  1897. var laboratory_other_amt float64 = 0
  1898. var treat_claa_sunmfee float64 = 0
  1899. var treat_clab_amt float64 = 0
  1900. var treat_other_amt float64 = 0
  1901. var register_claa_sunmfee float64 = 0
  1902. var register_clab_amt float64 = 0
  1903. var register_other_amt float64 = 0
  1904. for _, item := range order.HisOrderInfo {
  1905. if item.MedChrgitmType == "01" { //床位费
  1906. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1907. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1908. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1909. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1910. if item.ChrgitmLv == "1" {
  1911. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1912. }
  1913. if item.ChrgitmLv == "2" {
  1914. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1915. }
  1916. if item.ChrgitmLv == "3" {
  1917. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1918. }
  1919. }
  1920. if item.MedChrgitmType == "02" { //诊查
  1921. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1922. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1923. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1924. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1925. if item.ChrgitmLv == "1" {
  1926. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1927. }
  1928. if item.ChrgitmLv == "2" {
  1929. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1930. }
  1931. if item.ChrgitmLv == "3" {
  1932. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1933. }
  1934. }
  1935. if item.MedChrgitmType == "03" { //检查费
  1936. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1937. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1938. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1939. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1940. if item.ChrgitmLv == "1" {
  1941. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1942. }
  1943. if item.ChrgitmLv == "2" {
  1944. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1945. }
  1946. if item.ChrgitmLv == "3" {
  1947. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1948. }
  1949. }
  1950. if item.MedChrgitmType == "04" { //化验费
  1951. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1952. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1953. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1954. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1955. if item.ChrgitmLv == "1" {
  1956. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1957. }
  1958. if item.ChrgitmLv == "2" {
  1959. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1960. }
  1961. if item.ChrgitmLv == "3" {
  1962. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1963. }
  1964. }
  1965. if item.MedChrgitmType == "05" { //治疗费
  1966. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1967. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1968. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1969. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1970. if item.ChrgitmLv == "1" {
  1971. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1972. }
  1973. if item.ChrgitmLv == "2" {
  1974. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1975. }
  1976. if item.ChrgitmLv == "3" {
  1977. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1978. }
  1979. }
  1980. if item.MedChrgitmType == "06" { //手术费
  1981. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1982. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1983. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1984. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1985. if item.ChrgitmLv == "1" {
  1986. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1987. }
  1988. if item.ChrgitmLv == "2" {
  1989. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1990. }
  1991. if item.ChrgitmLv == "3" {
  1992. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1993. }
  1994. }
  1995. if item.MedChrgitmType == "07" { //手术费
  1996. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1997. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1998. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1999. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2000. if item.ChrgitmLv == "1" {
  2001. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2002. }
  2003. if item.ChrgitmLv == "2" {
  2004. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2005. }
  2006. if item.ChrgitmLv == "3" {
  2007. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2008. }
  2009. }
  2010. if item.MedChrgitmType == "08" { //材料费
  2011. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2012. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2013. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2014. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2015. if item.ChrgitmLv == "1" {
  2016. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2017. }
  2018. if item.ChrgitmLv == "2" {
  2019. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2020. }
  2021. if item.ChrgitmLv == "3" {
  2022. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2023. }
  2024. }
  2025. if item.MedChrgitmType == "09" { //西药费
  2026. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2027. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2028. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2029. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2030. if item.ChrgitmLv == "1" {
  2031. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2032. }
  2033. if item.ChrgitmLv == "2" {
  2034. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2035. }
  2036. if item.ChrgitmLv == "3" {
  2037. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2038. }
  2039. }
  2040. if item.MedChrgitmType == "10" { //中药饮片
  2041. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2042. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2043. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2044. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2045. if item.ChrgitmLv == "1" {
  2046. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2047. }
  2048. if item.ChrgitmLv == "2" {
  2049. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2050. }
  2051. if item.ChrgitmLv == "3" {
  2052. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2053. }
  2054. }
  2055. if item.MedChrgitmType == "11" { //中成费
  2056. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2057. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2058. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2059. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2060. if item.ChrgitmLv == "1" {
  2061. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2062. }
  2063. if item.ChrgitmLv == "2" {
  2064. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2065. }
  2066. if item.ChrgitmLv == "3" {
  2067. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2068. }
  2069. }
  2070. if item.MedChrgitmType == "12" { //中成费
  2071. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2072. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2073. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2074. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2075. if item.ChrgitmLv == "1" {
  2076. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2077. }
  2078. if item.ChrgitmLv == "2" {
  2079. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2080. }
  2081. if item.ChrgitmLv == "3" {
  2082. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2083. }
  2084. }
  2085. if item.MedChrgitmType == "13" { //中成费
  2086. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2087. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2088. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2089. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2090. if item.ChrgitmLv == "1" {
  2091. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2092. }
  2093. if item.ChrgitmLv == "2" {
  2094. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2095. }
  2096. if item.ChrgitmLv == "3" {
  2097. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2098. }
  2099. }
  2100. if item.MedChrgitmType == "14" { //其他费
  2101. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2102. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2103. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2104. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2105. if item.ChrgitmLv == "1" {
  2106. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2107. }
  2108. if item.ChrgitmLv == "2" {
  2109. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2110. }
  2111. if item.ChrgitmLv == "3" {
  2112. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2113. }
  2114. }
  2115. }
  2116. var iteminfoStructs []service.IteminfoStruct
  2117. if bedCostTotal != 0 {
  2118. iteminfo.MedChrgitm = "01"
  2119. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2120. iteminfo.Amt = bedCostTotal
  2121. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2122. iteminfo.ClabAmt = bed_clab_amt
  2123. iteminfo.OthAmt = bed_other_amt
  2124. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2125. }
  2126. if examineCostTotal != 0 {
  2127. iteminfo.MedChrgitm = "02"
  2128. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2129. iteminfo.Amt = examineCostTotal
  2130. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2131. iteminfo.ClabAmt = examine_clab_amt
  2132. iteminfo.OthAmt = examine_other_amt
  2133. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2134. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2135. }
  2136. if checkCostTotal != 0 {
  2137. iteminfo.MedChrgitm = "03"
  2138. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2139. iteminfo.Amt = checkCostTotal
  2140. iteminfo.ClaaSumfee = check_claa_sunmfee
  2141. iteminfo.ClabAmt = check_clab_amt
  2142. iteminfo.OthAmt = check_other_amt
  2143. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2144. }
  2145. if laboratoryCostTotal != 0 {
  2146. iteminfo.MedChrgitm = "04"
  2147. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2148. iteminfo.Amt = laboratoryCostTotal
  2149. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2150. iteminfo.ClabAmt = laboratory_clab_amt
  2151. iteminfo.OthAmt = laboratory_other_amt
  2152. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2153. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2154. }
  2155. if treatCostTotal != 0 {
  2156. iteminfo.MedChrgitm = "05"
  2157. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2158. iteminfo.Amt = treatCostTotal
  2159. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2160. iteminfo.ClabAmt = treat_clab_amt
  2161. iteminfo.OthAmt = treat_other_amt
  2162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2163. //(struct4101.IteminfoStruct, iteminfo)
  2164. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2165. }
  2166. if operationCostTotal != 0 {
  2167. iteminfo.MedChrgitm = "06"
  2168. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2169. iteminfo.Amt = operationCostTotal
  2170. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2171. iteminfo.ClabAmt = operation_clab_amt
  2172. iteminfo.OthAmt = operation_other_amt
  2173. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2174. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2175. }
  2176. if nursingCostTotal != 0 {
  2177. iteminfo.MedChrgitm = "07"
  2178. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2179. iteminfo.Amt = nursingCostTotal
  2180. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2181. iteminfo.ClabAmt = nursing_clab_amt
  2182. iteminfo.OthAmt = nursing_other_amt
  2183. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2184. }
  2185. if materialCostTotal != 0 {
  2186. iteminfo.MedChrgitm = "08"
  2187. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2188. iteminfo.Amt = materialCostTotal
  2189. iteminfo.ClaaSumfee = material_claa_sunmfee
  2190. iteminfo.ClabAmt = material_clab_amt
  2191. iteminfo.OthAmt = material_other_amt
  2192. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2193. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2194. }
  2195. if westernMedicineCostTotal != 0 {
  2196. iteminfo.MedChrgitm = "09"
  2197. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2198. iteminfo.Amt = westernMedicineCostTotal
  2199. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2200. iteminfo.ClabAmt = westernMedicine_clab_amt
  2201. iteminfo.OthAmt = westernMedicine_other_amt
  2202. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2203. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2204. }
  2205. if chineseMedicineCostTotal != 0 {
  2206. iteminfo.MedChrgitm = "10"
  2207. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2208. iteminfo.Amt = chineseMedicineCostTotal
  2209. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2210. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2211. iteminfo.OthAmt = chinese_medicine_other_amt
  2212. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2214. }
  2215. if chineseTraditionalMedicineCostTotal != 0 {
  2216. iteminfo.MedChrgitm = "11"
  2217. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2218. iteminfo.Amt = westernMedicineCostTotal
  2219. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2220. iteminfo.ClabAmt = westernMedicine_clab_amt
  2221. iteminfo.OthAmt = westernMedicine_other_amt
  2222. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2224. }
  2225. if commonlyTreatmentCostTotal != 0 {
  2226. iteminfo.MedChrgitm = "12"
  2227. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2228. iteminfo.Amt = commonlyTreatmentCostTotal
  2229. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2230. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2231. iteminfo.OthAmt = commonly_treatment_other_amt
  2232. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2233. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2234. }
  2235. if registerCostTotal != 0 {
  2236. iteminfo.MedChrgitm = "13"
  2237. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2238. iteminfo.Amt = registerCostTotal
  2239. iteminfo.ClaaSumfee = register_claa_sunmfee
  2240. iteminfo.ClabAmt = register_clab_amt
  2241. iteminfo.OthAmt = register_other_amt
  2242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2243. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2244. }
  2245. if otherCostTotal != 0 {
  2246. iteminfo.MedChrgitm = "14"
  2247. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2248. iteminfo.Amt = otherCostTotal
  2249. iteminfo.ClaaSumfee = other_claa_sunmfee
  2250. iteminfo.ClabAmt = other_clab_amt
  2251. iteminfo.OthAmt = other_other_amt
  2252. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2254. }
  2255. struct4101.IteminfoStruct = iteminfoStructs
  2256. struct4101.Ntly = "中国"
  2257. struct4101.AdmCaty = "A03.06"
  2258. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2259. fmt.Println(result)
  2260. var dat map[string]interface{}
  2261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2262. fmt.Println(dat)
  2263. } else {
  2264. fmt.Println(err)
  2265. }
  2266. userJSONBytes, _ := json.Marshal(dat)
  2267. var res ResultSeventeen
  2268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2269. utils.ErrorLog("解析失败:%v", err)
  2270. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2271. adminUser := c.GetAdminUserInfo()
  2272. errlog := &models.HisOrderError{
  2273. UserOrgId: adminUser.CurrentOrgId,
  2274. Ctime: time.Now().Unix(),
  2275. Mtime: time.Now().Unix(),
  2276. ErrMsg: res.ErrMsg + "解析失败",
  2277. Status: 1,
  2278. PatientId: order_id,
  2279. Stage: 10106,
  2280. }
  2281. service.CreateErrMsgLog(errlog)
  2282. continue
  2283. }
  2284. if res.Infcode != 0 {
  2285. adminUser := c.GetAdminUserInfo()
  2286. errlog := &models.HisOrderError{
  2287. UserOrgId: adminUser.CurrentOrgId,
  2288. Ctime: time.Now().Unix(),
  2289. Mtime: time.Now().Unix(),
  2290. ErrMsg: res.ErrMsg,
  2291. Status: 1,
  2292. PatientId: order_id,
  2293. Stage: 10106,
  2294. }
  2295. service.CreateErrMsgLog(errlog)
  2296. continue
  2297. } else {
  2298. hisFundSettleListResult := &models.HisFundSettleListResult{
  2299. Number: res.Output.SetlListId,
  2300. Status: 1,
  2301. Ctime: time.Now().Unix(),
  2302. Mtime: time.Now().Unix(),
  2303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2304. IsUpload: 1,
  2305. OrderId: order_id,
  2306. }
  2307. service.CreateUploadRecord(hisFundSettleListResult)
  2308. continue
  2309. }
  2310. }
  2311. }
  2312. func (c *HisApiController) GetOrgInfo() {
  2313. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2314. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2315. }
  2316. func (c *HisApiController) GetHisPatientInfo() {
  2317. medical_insurance_card := c.GetString("medical_insurance_card")
  2318. id_card_type, _ := c.GetInt64("id_card_type")
  2319. id_card := c.GetString("id_card")
  2320. adminInfo := c.GetAdminUserInfo()
  2321. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2322. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2323. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2324. IdCardNo := ""
  2325. if id_card_type == 1 {
  2326. IdCardNo = medical_insurance_card
  2327. } else if id_card_type == 2 {
  2328. IdCardNo = id_card
  2329. }
  2330. if config.IsOpen == 1 {
  2331. 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
  2332. resp, requestErr := http.Get(api)
  2333. if requestErr != nil {
  2334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2335. return
  2336. }
  2337. defer resp.Body.Close()
  2338. body, ioErr := ioutil.ReadAll(resp.Body)
  2339. if ioErr != nil {
  2340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2342. return
  2343. }
  2344. var respJSON map[string]interface{}
  2345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2348. return
  2349. }
  2350. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2351. userJSONBytes, _ := json.Marshal(userJSON)
  2352. var res ResultTwo
  2353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2354. utils.ErrorLog("解析失败:%v", err)
  2355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2356. return
  2357. }
  2358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2360. infoStr := string(Iinfos)
  2361. idetinfoStr := string(Idetinfos)
  2362. if res.Infcode == 0 {
  2363. his := models.VMHisPatient{
  2364. Status: 1,
  2365. Ctime: time.Now().Unix(),
  2366. Mtime: time.Now().Unix(),
  2367. PsnNo: res.Output.Baseinfo.PsnNo,
  2368. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2369. Certno: res.Output.Baseinfo.Certno,
  2370. PsnName: res.Output.Baseinfo.PsnName,
  2371. Gend: res.Output.Baseinfo.Gend,
  2372. Naty: res.Output.Baseinfo.Naty,
  2373. Brdy: res.Output.Baseinfo.Brdy,
  2374. Age: res.Output.Baseinfo.Age,
  2375. Iinfo: infoStr,
  2376. Idetinfo: idetinfoStr,
  2377. UserOrgId: adminInfo.CurrentOrgId,
  2378. IsReturn: 1,
  2379. IdCardType: id_card_type,
  2380. }
  2381. c.ServeSuccessJSON(map[string]interface{}{
  2382. "info": his,
  2383. })
  2384. } else {
  2385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2386. return
  2387. }
  2388. }
  2389. }
  2390. //func GetBasBaseInfo() (jsonStr string, err error) {
  2391. //
  2392. // handle := syscall.NewLazyDLL("SSCard.dll")
  2393. // add := handle.NewProc("ReadCardBas")
  2394. // str := make([]byte, 1024)
  2395. // str1 := make([]byte, 1024)
  2396. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2397. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2398. //
  2399. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2400. //
  2401. // fmt.Println("> Add(4,5)的结果为:", ret)
  2402. // handle.Release()
  2403. //
  2404. // return "", nil
  2405. //
  2406. //}
  2407. //func GetQRBaseInfo() (jsonStr string, err error) {
  2408. // handle := syscall.LoadDLL("SSCard.dll")
  2409. // ReadCardBas := handle.FindProc("GetQRBase")
  2410. //
  2411. // str := make([]byte, 256)
  2412. // str1 := make([]byte, 256)
  2413. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2414. //
  2415. // fmt.Println(string(str))
  2416. // fmt.Println(r)
  2417. // return string(str), nil
  2418. //}
  2419. //func CardInit() int {
  2420. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2421. // add := DllTestDef.MustFindProc("Init")
  2422. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2423. // if err != nil {
  2424. // fmt.Println("SSCard的运算结果为:", ret)
  2425. // }
  2426. // result := int(ret)
  2427. // return result
  2428. //}
  2429. //func CardInit() int {
  2430. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2431. // if err != nil {
  2432. // fmt.Println("SSCard的运算结果为:", ret)
  2433. // }
  2434. // fmt.Println(err)
  2435. // result := int(ret)
  2436. // return result
  2437. //}
  2438. func IntPtr(n int) uintptr {
  2439. return uintptr(n)
  2440. }
  2441. func StrPtr(s string) uintptr {
  2442. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2443. }
  2444. type Result2001 struct {
  2445. Cainfo interface{} `json:"cainfo"`
  2446. ErrMsg string `json:"err_msg"`
  2447. InfRefmsgid string `json:"inf_refmsgid"`
  2448. Infcode int64 `json:"infcode"`
  2449. Output struct {
  2450. Trtinfo struct {
  2451. PsnNo string `json:"psn_no"`
  2452. TrtChkType string `json:"trt_chk_type"`
  2453. FundPayType string `json:"fund_pay_type"`
  2454. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2455. Begndate string `json:"begndate"`
  2456. Enddate string `json:"enddate"`
  2457. TrtChkRslt string `json:"trt_chk_rslt"`
  2458. } `json:"trtinfo"`
  2459. } `json:"output"`
  2460. RefmsgTime string `json:"refmsg_time"`
  2461. RespondTime string `json:"respond_time"`
  2462. Signtype interface{} `json:"signtype"`
  2463. WarnMsg interface{} `json:"warn_msg"`
  2464. }
  2465. type Result2001Org10265 struct {
  2466. Cainfo interface{} `json:"cainfo"`
  2467. ErrMsg string `json:"err_msg"`
  2468. InfRefmsgid string `json:"inf_refmsgid"`
  2469. Infcode string `json:"infcode"`
  2470. Output struct {
  2471. Trtinfo struct {
  2472. PsnNo string `json:"psn_no"`
  2473. TrtChkType string `json:"trt_chk_type"`
  2474. FundPayType string `json:"fund_pay_type"`
  2475. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2476. Begndate string `json:"begndate"`
  2477. Enddate string `json:"enddate"`
  2478. TrtChkRslt string `json:"trt_chk_rslt"`
  2479. } `json:"trtinfo"`
  2480. } `json:"output"`
  2481. RefmsgTime string `json:"refmsg_time"`
  2482. RespondTime string `json:"respond_time"`
  2483. Signtype interface{} `json:"signtype"`
  2484. WarnMsg interface{} `json:"warn_msg"`
  2485. }
  2486. type ResultTwo struct {
  2487. ErrMsg string `json:"err_msg"`
  2488. InfRefmsgid string `json:"inf_refmsgid"`
  2489. Infcode int64 `json:"infcode"`
  2490. Output struct {
  2491. Baseinfo struct {
  2492. Age float64 `json:"age"`
  2493. Brdy string `json:"brdy"`
  2494. Certno string `json:"certno"`
  2495. Gend string `json:"gend"`
  2496. Naty string `json:"naty"`
  2497. PsnCertType string `json:"psn_cert_type"`
  2498. PsnName string `json:"psn_name"`
  2499. PsnNo string `json:"psn_no"`
  2500. } `json:"baseinfo"`
  2501. Idetinfo []interface{} `json:"idetinfo"`
  2502. Iinfo []struct {
  2503. Balc float64 `json:"balc"`
  2504. CvlservFlag string `json:"cvlserv_flag"`
  2505. EmpName string `json:"emp_name"`
  2506. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2507. Insutype string `json:"insutype"`
  2508. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2509. PausInsuDate string `json:"paus_insu_date"`
  2510. PsnInsuDate string `json:"psn_insu_date"`
  2511. PsnInsuStas string `json:"psn_insu_stas"`
  2512. PsnType string `json:"psn_type"`
  2513. } `json:"insuinfo"`
  2514. } `json:"output"`
  2515. RefmsgTime string `json:"refmsg_time"`
  2516. RespondTime string `json:"respond_time"`
  2517. Signtype interface{} `json:"signtype"`
  2518. WarnInfo interface{} `json:"warn_info"`
  2519. }
  2520. type ResultTwo10265 struct {
  2521. ErrMsg string `json:"err_msg"`
  2522. InfRefmsgid string `json:"inf_refmsgid"`
  2523. Infcode string `json:"infcode"`
  2524. Output struct {
  2525. Baseinfo struct {
  2526. Age float64 `json:"age"`
  2527. Brdy string `json:"brdy"`
  2528. Certno string `json:"certno"`
  2529. Gend string `json:"gend"`
  2530. Naty string `json:"naty"`
  2531. PsnCertType string `json:"psn_cert_type"`
  2532. PsnName string `json:"psn_name"`
  2533. PsnNo string `json:"psn_no"`
  2534. } `json:"baseinfo"`
  2535. Idetinfo []interface{} `json:"idetinfo"`
  2536. Iinfo []struct {
  2537. Balc float64 `json:"balc"`
  2538. CvlservFlag string `json:"cvlserv_flag"`
  2539. EmpName string `json:"emp_name"`
  2540. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2541. Insutype string `json:"insutype"`
  2542. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2543. PausInsuDate string `json:"paus_insu_date"`
  2544. PsnInsuDate string `json:"psn_insu_date"`
  2545. PsnInsuStas string `json:"psn_insu_stas"`
  2546. PsnType string `json:"psn_type"`
  2547. } `json:"insuinfo"`
  2548. } `json:"output"`
  2549. RefmsgTime string `json:"refmsg_time"`
  2550. RespondTime string `json:"respond_time"`
  2551. Signtype interface{} `json:"signtype"`
  2552. WarnInfo interface{} `json:"warn_info"`
  2553. }
  2554. type ResultThree struct {
  2555. Cainfo interface{} `json:"cainfo"`
  2556. ErrMsg string `json:"err_msg"`
  2557. InfRefmsgid string `json:"inf_refmsgid"`
  2558. Infcode int64 `json:"infcode"`
  2559. Output struct {
  2560. Data struct {
  2561. IptOtpNo string `json:"ipt_otp_no"`
  2562. MdtrtID string `json:"mdtrt_id"`
  2563. PsnNo string `json:"psn_no"`
  2564. } `json:"data"`
  2565. } `json:"output"`
  2566. RefmsgTime string `json:"refmsg_time"`
  2567. RespondTime string `json:"respond_time"`
  2568. Signtype interface{} `json:"signtype"`
  2569. WarnMsg interface{} `json:"warn_msg"`
  2570. }
  2571. type ResultThree10265 struct {
  2572. Cainfo interface{} `json:"cainfo"`
  2573. ErrMsg string `json:"err_msg"`
  2574. InfRefmsgid string `json:"inf_refmsgid"`
  2575. Infcode string `json:"infcode"`
  2576. Output struct {
  2577. Data struct {
  2578. IptOtpNo string `json:"ipt_otp_no"`
  2579. MdtrtID string `json:"mdtrt_id"`
  2580. PsnNo string `json:"psn_no"`
  2581. } `json:"data"`
  2582. } `json:"output"`
  2583. RefmsgTime string `json:"refmsg_time"`
  2584. RespondTime string `json:"respond_time"`
  2585. Signtype interface{} `json:"signtype"`
  2586. WarnMsg interface{} `json:"warn_msg"`
  2587. }
  2588. type ResultFour struct {
  2589. Cainfo string `json:"cainfo"`
  2590. ErrMsg string `json:"err_msg"`
  2591. InfRefmsgid string `json:"inf_refmsgid"`
  2592. Infcode int64 `json:"infcode"`
  2593. Output struct {
  2594. Result []struct {
  2595. BasMednFlag string `json:"bas_medn_flag"`
  2596. ChldMedcFlag string `json:"chld_medc_flag"`
  2597. ChrgitmLv string `json:"chrgitm_lv"`
  2598. Cnt float64 `json:"cnt"`
  2599. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2600. DrtReimFlag string `json:"drt_reim_flag"`
  2601. FeedetlSn string `json:"feedetl_sn"`
  2602. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2603. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2604. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2605. ListSpItemFlag string `json:"list_sp_item_flag"`
  2606. LmtUsedFlag string `json:"lmt_used_flag"`
  2607. MedChrgitmType string `json:"med_chrgitm_type"`
  2608. Memo string `json:"memo"`
  2609. OverlmtAmt float64 `json:"overlmt_amt"`
  2610. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2611. Pric float64 `json:"pric"`
  2612. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2613. SelfpayProp float64 `json:"selfpay_prop"`
  2614. } `json:"result"`
  2615. } `json:"output"`
  2616. RefmsgTime string `json:"refmsg_time"`
  2617. RespondTime string `json:"respond_time"`
  2618. Signtype string `json:"signtype"`
  2619. WarnMsg string `json:"warn_msg"`
  2620. }
  2621. type ResultFour10265 struct {
  2622. Cainfo string `json:"cainfo"`
  2623. ErrMsg string `json:"err_msg"`
  2624. InfRefmsgid string `json:"inf_refmsgid"`
  2625. Infcode string `json:"infcode"`
  2626. Output struct {
  2627. Result []struct {
  2628. BasMednFlag string `json:"bas_medn_flag"`
  2629. ChldMedcFlag string `json:"chld_medc_flag"`
  2630. ChrgitmLv string `json:"chrgitm_lv"`
  2631. Cnt float64 `json:"cnt"`
  2632. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2633. DrtReimFlag string `json:"drt_reim_flag"`
  2634. FeedetlSn string `json:"feedetl_sn"`
  2635. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2636. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2637. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2638. ListSpItemFlag string `json:"list_sp_item_flag"`
  2639. LmtUsedFlag string `json:"lmt_used_flag"`
  2640. MedChrgitmType string `json:"med_chrgitm_type"`
  2641. Memo string `json:"memo"`
  2642. OverlmtAmt float64 `json:"overlmt_amt"`
  2643. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2644. Pric float64 `json:"pric"`
  2645. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2646. SelfpayProp float64 `json:"selfpay_prop"`
  2647. } `json:"result"`
  2648. } `json:"output"`
  2649. RefmsgTime string `json:"refmsg_time"`
  2650. RespondTime string `json:"respond_time"`
  2651. Signtype string `json:"signtype"`
  2652. WarnMsg string `json:"warn_msg"`
  2653. }
  2654. type ResultFive struct {
  2655. Balc float64 `json:"balc"`
  2656. CvlservFlag string `json:"cvlserv_flag"`
  2657. EmpName string `json:"emp_name"`
  2658. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2659. Insutype string `json:"insutype"`
  2660. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2661. PausInsuDate string `json:"paus_insu_date"`
  2662. PsnInsuDate string `json:"psn_insu_date"`
  2663. PsnInsuStas string `json:"psn_insu_stas"`
  2664. PsnType string `json:"psn_type"`
  2665. }
  2666. type ResultSix struct {
  2667. Cainfo interface{} `json:"cainfo"`
  2668. ErrMsg string `json:"err_msg"`
  2669. InfRefmsgid string `json:"inf_refmsgid"`
  2670. Infcode int64 `json:"infcode"`
  2671. Output struct {
  2672. } `json:"output"`
  2673. RefmsgTime string `json:"refmsg_time"`
  2674. RespondTime string `json:"respond_time"`
  2675. Signtype interface{} `json:"signtype"`
  2676. WarnMsg interface{} `json:"warn_msg"`
  2677. }
  2678. type ResultSix10265 struct {
  2679. Cainfo interface{} `json:"cainfo"`
  2680. ErrMsg string `json:"err_msg"`
  2681. InfRefmsgid string `json:"inf_refmsgid"`
  2682. Infcode string `json:"infcode"`
  2683. Output struct {
  2684. } `json:"output"`
  2685. RefmsgTime string `json:"refmsg_time"`
  2686. RespondTime string `json:"respond_time"`
  2687. Signtype interface{} `json:"signtype"`
  2688. WarnMsg interface{} `json:"warn_msg"`
  2689. }
  2690. type ResultSeven struct {
  2691. Cainfo string `json:"cainfo"`
  2692. ErrMsg string `json:"err_msg"`
  2693. InfRefmsgid string `json:"inf_refmsgid"`
  2694. Infcode int64 `json:"infcode"`
  2695. Output struct {
  2696. Setldetail []interface{} `json:"setldetail"`
  2697. Setlinfo struct {
  2698. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2699. AcctPay float64 `json:"acct_pay"`
  2700. ActPayDedc float64 `json:"act_pay_dedc"`
  2701. Age float64 `json:"age"`
  2702. Balc float64 `json:"balc"`
  2703. Brdy string `json:"brdy"`
  2704. Certno string `json:"certno"`
  2705. ClrOptins string `json:"clr_optins"`
  2706. ClrType string `json:"clr_type"`
  2707. ClrWay string `json:"clr_way"`
  2708. CvlservFlag string `json:"cvlserv_flag"`
  2709. CvlservPay float64 `json:"cvlserv_pay"`
  2710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2711. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2712. Gend string `json:"gend"`
  2713. HifesPay float64 `json:"hifes_pay"`
  2714. HifmiPay float64 `json:"hifmi_pay"`
  2715. HifpPay float64 `json:"hifp_pay"`
  2716. HospPartAmt float64 `json:"hosp_part_amt"`
  2717. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2718. Insutype string `json:"insutype"`
  2719. MafPay float64 `json:"maf_pay"`
  2720. MdtrtCertType string `json:"mdtrt_cert_type"`
  2721. HifobPay float64 `json:"hifob_pay"`
  2722. MdtrtID string `json:"mdtrt_id"`
  2723. MedType string `json:"med_type"`
  2724. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2725. MedinsSetlID string `json:"medins_setl_id"`
  2726. Naty string `json:"naty"`
  2727. OthPay float64 `json:"oth_pay"`
  2728. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2729. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2730. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2731. PsnCashPay float64 `json:"psn_cash_pay"`
  2732. PsnCertType string `json:"psn_cert_type"`
  2733. PsnName string `json:"psn_name"`
  2734. PsnNo string `json:"psn_no"`
  2735. PsnPartAmt float64 `json:"psn_part_amt"`
  2736. PsnType string `json:"psn_type"`
  2737. SetlID string `json:"setl_id"`
  2738. SetlTime string `json:"setl_time"`
  2739. } `json:"setlinfo"`
  2740. } `json:"output"`
  2741. RefmsgTime string `json:"refmsg_time"`
  2742. RespondTime string `json:"respond_time"`
  2743. Signtype interface{} `json:"signtype"`
  2744. WarnMsg interface{} `json:"warn_msg"`
  2745. }
  2746. type ResultSeven10265 struct {
  2747. Cainfo string `json:"cainfo"`
  2748. ErrMsg string `json:"err_msg"`
  2749. InfRefmsgid string `json:"inf_refmsgid"`
  2750. Infcode string `json:"infcode"`
  2751. Output struct {
  2752. Setldetail []interface{} `json:"setldetail"`
  2753. Setlinfo struct {
  2754. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2755. AcctPay float64 `json:"acct_pay"`
  2756. ActPayDedc float64 `json:"act_pay_dedc"`
  2757. Age float64 `json:"age"`
  2758. Balc float64 `json:"balc"`
  2759. Brdy string `json:"brdy"`
  2760. Certno string `json:"certno"`
  2761. ClrOptins string `json:"clr_optins"`
  2762. ClrType string `json:"clr_type"`
  2763. ClrWay string `json:"clr_way"`
  2764. CvlservFlag string `json:"cvlserv_flag"`
  2765. CvlservPay float64 `json:"cvlserv_pay"`
  2766. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2767. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2768. Gend string `json:"gend"`
  2769. HifesPay float64 `json:"hifes_pay"`
  2770. HifmiPay float64 `json:"hifmi_pay"`
  2771. HifpPay float64 `json:"hifp_pay"`
  2772. HospPartAmt float64 `json:"hosp_part_amt"`
  2773. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2774. Insutype string `json:"insutype"`
  2775. MafPay float64 `json:"maf_pay"`
  2776. MdtrtCertType string `json:"mdtrt_cert_type"`
  2777. HifobPay float64 `json:"hifob_pay"`
  2778. MdtrtID string `json:"mdtrt_id"`
  2779. MedType string `json:"med_type"`
  2780. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2781. MedinsSetlID string `json:"medins_setl_id"`
  2782. Naty string `json:"naty"`
  2783. OthPay float64 `json:"oth_pay"`
  2784. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2785. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2786. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2787. PsnCashPay float64 `json:"psn_cash_pay"`
  2788. PsnCertType string `json:"psn_cert_type"`
  2789. PsnName string `json:"psn_name"`
  2790. PsnNo string `json:"psn_no"`
  2791. PsnPartAmt float64 `json:"psn_part_amt"`
  2792. PsnType string `json:"psn_type"`
  2793. SetlID string `json:"setl_id"`
  2794. SetlTime string `json:"setl_time"`
  2795. } `json:"setlinfo"`
  2796. } `json:"output"`
  2797. RefmsgTime string `json:"refmsg_time"`
  2798. RespondTime string `json:"respond_time"`
  2799. Signtype interface{} `json:"signtype"`
  2800. WarnMsg interface{} `json:"warn_msg"`
  2801. }
  2802. type ResultEight struct {
  2803. Cainfo string `json:"cainfo"`
  2804. ErrMsg string `json:"err_msg"`
  2805. InfRefmsgid string `json:"inf_refmsgid"`
  2806. Infcode int64 `json:"infcode"`
  2807. Output struct {
  2808. Stmtinfo struct {
  2809. SetlOptins string `json:"setl_optins"`
  2810. StmtRslt string `json:"stmt_rslt"`
  2811. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2812. } `json:"stmtinfo"`
  2813. } `json:"output"`
  2814. RefmsgTime string `json:"refmsg_time"`
  2815. RespondTime string `json:"respond_time"`
  2816. Signtype interface{} `json:"signtype"`
  2817. WarnMsg interface{} `json:"warn_msg"`
  2818. }
  2819. type ResultEightFor10188 struct {
  2820. Cainfo string `json:"cainfo"`
  2821. ErrMsg string `json:"err_msg"`
  2822. InfRefmsgid string `json:"inf_refmsgid"`
  2823. Infcode string `json:"infcode"`
  2824. Output struct {
  2825. Stmtinfo struct {
  2826. SetlOptins string `json:"setl_optins"`
  2827. StmtRslt string `json:"stmt_rslt"`
  2828. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2829. } `json:"stmtinfo"`
  2830. } `json:"output"`
  2831. RefmsgTime string `json:"refmsg_time"`
  2832. RespondTime string `json:"respond_time"`
  2833. Signtype interface{} `json:"signtype"`
  2834. WarnMsg interface{} `json:"warn_msg"`
  2835. }
  2836. type ResultNine struct {
  2837. Cainfo string `json:"cainfo"`
  2838. ErrMsg string `json:"err_msg"`
  2839. InfRefmsgid string `json:"inf_refmsgid"`
  2840. Infcode int64 `json:"infcode"`
  2841. Output struct {
  2842. FileQuryNo string `json:"file_qury_no"`
  2843. } `json:"output"`
  2844. RefmsgTime string `json:"refmsg_time"`
  2845. RespondTime string `json:"respond_time"`
  2846. Signtype interface{} `json:"signtype"`
  2847. WarnMsg interface{} `json:"warn_msg"`
  2848. }
  2849. type ResultTen struct {
  2850. Cainfo string `json:"cainfo"`
  2851. ErrMsg string `json:"err_msg"`
  2852. InfRefmsgid string `json:"inf_refmsgid"`
  2853. Infcode int64 `json:"infcode"`
  2854. Output struct {
  2855. DldEndtime string `json:"dld_endtime"`
  2856. FileQuryNo string `json:"file_qury_no"`
  2857. Filename string `json:"filename"`
  2858. } `json:"output"`
  2859. RefmsgTime string `json:"refmsg_time"`
  2860. RespondTime string `json:"respond_time"`
  2861. Signtype interface{} `json:"signtype"`
  2862. WarnMsg interface{} `json:"warn_msg"`
  2863. }
  2864. //type Autogenerated struct {
  2865. // Output struct {
  2866. // Setlinfo struct {
  2867. // SetlTime string `json:"setl_time"`
  2868. // CvlservPay float64 `json:"cvlserv_pay"`
  2869. // Year string `json:"year"`
  2870. // MedType string `json:"med_type"`
  2871. // PsnPay float64 `json:"psn_pay"`
  2872. // OpterID string `json:"opter_id"`
  2873. // Begndate string `json:"begndate"`
  2874. // FlxempeFlag string `json:"flxempe_flag"`
  2875. // HifmiPay float64 `json:"hifmi_pay"`
  2876. // PsnNo string `json:"psn_no"`
  2877. // ActPayDedc float64 `json:"act_pay_dedc"`
  2878. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2879. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2880. // ClrWay string `json:"clr_way"`
  2881. // OthPay float64 `json:"oth_pay"`
  2882. // Gend string `json:"gend"`
  2883. // MdtrtID string `json:"mdtrt_id"`
  2884. // AcctPay float64 `json:"acct_pay"`
  2885. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2886. // Insutype string `json:"insutype"`
  2887. // Invono interface{} `json:"invono"`
  2888. // Enddate string `json:"enddate"`
  2889. // CashPayamt float64 `json:"cash_payamt"`
  2890. // PsnType string `json:"psn_type"`
  2891. // FixmedinsName string `json:"fixmedins_name"`
  2892. // HifpPay float64 `json:"hifp_pay"`
  2893. // NewFlag interface{} `json:"new_flag"`
  2894. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2895. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2896. // PayLoc string `json:"pay_loc"`
  2897. // ClrType string `json:"clr_type"`
  2898. // RefdSetlFlag string `json:"refd_setl_flag"`
  2899. // CvlservFlag string `json:"cvlserv_flag"`
  2900. // EmpName string `json:"emp_name"`
  2901. // Brdy string `json:"brdy"`
  2902. // Naty string `json:"naty"`
  2903. // Certno string `json:"certno"`
  2904. // DiseCode string `json:"dise_code"`
  2905. // FixmedinsCode string `json:"fixmedins_code"`
  2906. // DedcHospLv string `json:"dedc_hosp_lv"`
  2907. // OpterName string `json:"opter_name"`
  2908. // Balc float64 `json:"balc"`
  2909. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2910. // PsnCertType string `json:"psn_cert_type"`
  2911. // HifobPay float64 `json:"hifob_pay"`
  2912. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2913. // HifesPay float64 `json:"hifes_pay"`
  2914. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2915. // OptTime string `json:"opt_time"`
  2916. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2917. // SetlID string `json:"setl_id"`
  2918. // MafPay float64 `json:"maf_pay"`
  2919. // PsnName string `json:"psn_name"`
  2920. // InsuOptins interface{} `json:"insu_optins"`
  2921. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2922. // ClrOptins string `json:"clr_optins"`
  2923. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2924. // DiseName string `json:"dise_name"`
  2925. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2926. // Age float64 `json:"age"`
  2927. // DtrtCertType string `json:"dtrt_cert_type"`
  2928. // HospLv string `json:"hosp_lv"`
  2929. // } `json:"setlinfo"`
  2930. // Setldetail []struct {
  2931. // FundPayType string `json:"fund_pay_type"`
  2932. // FundPayamt float64 `json:"fund_payamt"`
  2933. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2934. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2935. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2936. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2937. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2938. // } `json:"setldetail"`
  2939. // } `json:"output"`
  2940. // Infcode int `json:"infcode"`
  2941. // WarnMsg interface{} `json:"warn_msg"`
  2942. // Cainfo interface{} `json:"cainfo"`
  2943. // ErrMsg interface{} `json:"err_msg"`
  2944. // RefmsgTime string `json:"refmsg_time"`
  2945. // Signtype interface{} `json:"signtype"`
  2946. // RespondTime string `json:"respond_time"`
  2947. // InfRefmsgid string `json:"inf_refmsgid"`
  2948. //}
  2949. type ResultEleven struct {
  2950. Cainfo string `json:"cainfo"`
  2951. ErrMsg string `json:"err_msg"`
  2952. InfRefmsgid string `json:"inf_refmsgid"`
  2953. Infcode int64 `json:"infcode"`
  2954. Output struct {
  2955. Setlinfo struct {
  2956. SetlTime string `json:"setl_time"`
  2957. CvlservPay float64 `json:"cvlserv_pay"`
  2958. Year string `json:"year"`
  2959. MedType string `json:"med_type"`
  2960. PsnPay float64 `json:"psn_pay"`
  2961. OpterID string `json:"opter_id"`
  2962. Begndate string `json:"begndate"`
  2963. FlxempeFlag string `json:"flxempe_flag"`
  2964. HifmiPay float64 `json:"hifmi_pay"`
  2965. PsnNo string `json:"psn_no"`
  2966. ActPayDedc float64 `json:"act_pay_dedc"`
  2967. MedinsSetlID interface{} `json:"medins_setl_id"`
  2968. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2969. ClrWay string `json:"clr_way"`
  2970. OthPay float64 `json:"oth_pay"`
  2971. Gend string `json:"gend"`
  2972. MdtrtID string `json:"mdtrt_id"`
  2973. AcctPay float64 `json:"acct_pay"`
  2974. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2975. Insutype string `json:"insutype"`
  2976. Invono interface{} `json:"invono"`
  2977. Enddate string `json:"enddate"`
  2978. CashPayamt float64 `json:"cash_payamt"`
  2979. PsnType string `json:"psn_type"`
  2980. FixmedinsName string `json:"fixmedins_name"`
  2981. HifpPay float64 `json:"hifp_pay"`
  2982. NewFlag interface{} `json:"new_flag"`
  2983. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2984. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2985. PayLoc string `json:"pay_loc"`
  2986. ClrType string `json:"clr_type"`
  2987. RefdSetlFlag string `json:"refd_setl_flag"`
  2988. CvlservFlag string `json:"cvlserv_flag"`
  2989. EmpName string `json:"emp_name"`
  2990. Brdy string `json:"brdy"`
  2991. Naty string `json:"naty"`
  2992. Certno string `json:"certno"`
  2993. DiseCode string `json:"dise_code"`
  2994. FixmedinsCode string `json:"fixmedins_code"`
  2995. DedcHospLv string `json:"dedc_hosp_lv"`
  2996. OpterName string `json:"opter_name"`
  2997. Balc float64 `json:"balc"`
  2998. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2999. PsnCertType string `json:"psn_cert_type"`
  3000. HifobPay float64 `json:"hifob_pay"`
  3001. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3002. HifesPay float64 `json:"hifes_pay"`
  3003. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3004. OptTime string `json:"opt_time"`
  3005. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3006. SetlID string `json:"setl_id"`
  3007. MafPay float64 `json:"maf_pay"`
  3008. PsnName string `json:"psn_name"`
  3009. InsuOptins interface{} `json:"insu_optins"`
  3010. PrefFundPay interface{} `json:"pref_fund_pay"`
  3011. ClrOptins string `json:"clr_optins"`
  3012. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3013. DiseName string `json:"dise_name"`
  3014. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3015. Age float64 `json:"age"`
  3016. DtrtCertType string `json:"dtrt_cert_type"`
  3017. HospLv string `json:"hosp_lv"`
  3018. } `json:"setlinfo"`
  3019. } `json:"output"`
  3020. RefmsgTime string `json:"refmsg_time"`
  3021. RespondTime string `json:"respond_time"`
  3022. Signtype interface{} `json:"signtype"`
  3023. WarnMsg interface{} `json:"warn_msg"`
  3024. }
  3025. type ResultEleven10265 struct {
  3026. Cainfo string `json:"cainfo"`
  3027. ErrMsg string `json:"err_msg"`
  3028. InfRefmsgid string `json:"inf_refmsgid"`
  3029. Infcode string `json:"infcode"`
  3030. Output struct {
  3031. Setlinfo struct {
  3032. SetlTime string `json:"setl_time"`
  3033. CvlservPay float64 `json:"cvlserv_pay"`
  3034. Year string `json:"year"`
  3035. MedType string `json:"med_type"`
  3036. PsnPay float64 `json:"psn_pay"`
  3037. OpterID string `json:"opter_id"`
  3038. Begndate string `json:"begndate"`
  3039. FlxempeFlag string `json:"flxempe_flag"`
  3040. HifmiPay float64 `json:"hifmi_pay"`
  3041. PsnNo string `json:"psn_no"`
  3042. ActPayDedc float64 `json:"act_pay_dedc"`
  3043. MedinsSetlID interface{} `json:"medins_setl_id"`
  3044. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3045. ClrWay string `json:"clr_way"`
  3046. OthPay float64 `json:"oth_pay"`
  3047. Gend string `json:"gend"`
  3048. MdtrtID string `json:"mdtrt_id"`
  3049. AcctPay float64 `json:"acct_pay"`
  3050. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3051. Insutype string `json:"insutype"`
  3052. Invono interface{} `json:"invono"`
  3053. Enddate string `json:"enddate"`
  3054. CashPayamt float64 `json:"cash_payamt"`
  3055. PsnType string `json:"psn_type"`
  3056. FixmedinsName string `json:"fixmedins_name"`
  3057. HifpPay float64 `json:"hifp_pay"`
  3058. NewFlag interface{} `json:"new_flag"`
  3059. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3060. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3061. PayLoc string `json:"pay_loc"`
  3062. ClrType string `json:"clr_type"`
  3063. RefdSetlFlag string `json:"refd_setl_flag"`
  3064. CvlservFlag string `json:"cvlserv_flag"`
  3065. EmpName string `json:"emp_name"`
  3066. Brdy string `json:"brdy"`
  3067. Naty string `json:"naty"`
  3068. Certno string `json:"certno"`
  3069. DiseCode string `json:"dise_code"`
  3070. FixmedinsCode string `json:"fixmedins_code"`
  3071. DedcHospLv string `json:"dedc_hosp_lv"`
  3072. OpterName string `json:"opter_name"`
  3073. Balc float64 `json:"balc"`
  3074. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3075. PsnCertType string `json:"psn_cert_type"`
  3076. HifobPay float64 `json:"hifob_pay"`
  3077. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3078. HifesPay float64 `json:"hifes_pay"`
  3079. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3080. OptTime string `json:"opt_time"`
  3081. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3082. SetlID string `json:"setl_id"`
  3083. MafPay float64 `json:"maf_pay"`
  3084. PsnName string `json:"psn_name"`
  3085. InsuOptins interface{} `json:"insu_optins"`
  3086. PrefFundPay interface{} `json:"pref_fund_pay"`
  3087. ClrOptins string `json:"clr_optins"`
  3088. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3089. DiseName string `json:"dise_name"`
  3090. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3091. Age float64 `json:"age"`
  3092. DtrtCertType string `json:"dtrt_cert_type"`
  3093. HospLv string `json:"hosp_lv"`
  3094. } `json:"setlinfo"`
  3095. } `json:"output"`
  3096. RefmsgTime string `json:"refmsg_time"`
  3097. RespondTime string `json:"respond_time"`
  3098. Signtype interface{} `json:"signtype"`
  3099. WarnMsg interface{} `json:"warn_msg"`
  3100. }
  3101. type ResultTwelve struct {
  3102. Cainfo string `json:"cainfo"`
  3103. ErrMsg string `json:"err_msg"`
  3104. InfRefmsgid string `json:"inf_refmsgid"`
  3105. Infcode int64 `json:"infcode"`
  3106. Output struct {
  3107. MdtrtId string `json:"mdtrt_id"`
  3108. ChrgBchno string `json:"chrg_bchno"`
  3109. PsnNo string `json:"psn_no"`
  3110. } `json:"output"`
  3111. RefmsgTime string `json:"refmsg_time"`
  3112. RespondTime string `json:"respond_time"`
  3113. Signtype interface{} `json:"signtype"`
  3114. WarnMsg interface{} `json:"warn_msg"`
  3115. }
  3116. type ResultThirteen struct {
  3117. ErrMsg string `json:"err_msg"`
  3118. InfRefmsgid string `json:"inf_refmsgid"`
  3119. Infcode int64 `json:"infcode"`
  3120. Output struct {
  3121. Result struct {
  3122. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3123. } `json:"result"`
  3124. } `json:"output"`
  3125. RefmsgTime string `json:"refmsg_time"`
  3126. RespondTime string `json:"respond_time"`
  3127. Signtype interface{} `json:"signtype"`
  3128. WarnInfo interface{} `json:"warn_info"`
  3129. }
  3130. type ResultThirteen10265 struct {
  3131. ErrMsg string `json:"err_msg"`
  3132. InfRefmsgid string `json:"inf_refmsgid"`
  3133. Infcode string `json:"infcode"`
  3134. Output struct {
  3135. Result struct {
  3136. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3137. } `json:"result"`
  3138. } `json:"output"`
  3139. RefmsgTime string `json:"refmsg_time"`
  3140. RespondTime string `json:"respond_time"`
  3141. Signtype interface{} `json:"signtype"`
  3142. WarnInfo interface{} `json:"warn_info"`
  3143. }
  3144. type ResultFourteen struct {
  3145. ErrMsg string `json:"err_msg"`
  3146. InfRefmsgid string `json:"inf_refmsgid"`
  3147. Infcode int64 `json:"infcode"`
  3148. Output struct {
  3149. } `json:"output"`
  3150. RefmsgTime string `json:"refmsg_time"`
  3151. RespondTime string `json:"respond_time"`
  3152. Signtype interface{} `json:"signtype"`
  3153. WarnInfo interface{} `json:"warn_info"`
  3154. }
  3155. type ResultFourteen10265 struct {
  3156. ErrMsg string `json:"err_msg"`
  3157. InfRefmsgid string `json:"inf_refmsgid"`
  3158. Infcode string `json:"infcode"`
  3159. Output struct {
  3160. } `json:"output"`
  3161. RefmsgTime string `json:"refmsg_time"`
  3162. RespondTime string `json:"respond_time"`
  3163. Signtype interface{} `json:"signtype"`
  3164. WarnInfo interface{} `json:"warn_info"`
  3165. }
  3166. type ResultSixteen struct {
  3167. Cainfo string `json:"cainfo"`
  3168. ErrMsg string `json:"err_msg"`
  3169. InfRefmsgid string `json:"inf_refmsgid"`
  3170. Infcode int64 `json:"infcode"`
  3171. Output struct {
  3172. Setldetail []interface{} `json:"setldetail"`
  3173. Setlinfo struct {
  3174. MdtrtID string `json:"mdtrt_id"`
  3175. SetlID string `json:"setl_id"`
  3176. ClrOptins string `json:"clr_optins"`
  3177. SetlTime string `json:"setl_time"`
  3178. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3179. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3180. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3181. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3182. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3183. ActPayDedc float64 `json:"act_pay_dedc"`
  3184. HifpPay float64 `json:"hifp_pay"`
  3185. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3186. Lfpay float64 `json:"selfpay"`
  3187. CvlservPay float64 `json:"cvlserv_pay"`
  3188. HifesPay float64 `json:"hifes_pay"`
  3189. HifmiPay float64 `json:"hifmi_pay"`
  3190. HifobPay float64 `json:"hifob_pay"`
  3191. MafPay float64 `json:"maf_pay"`
  3192. OthPay float64 `json:"oth_pay"`
  3193. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3194. PsnPartAmt float64 `json:"psn_part_amt"`
  3195. AcctPay float64 `json:"acct_pay"`
  3196. Balc float64 `json:"balc"`
  3197. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3198. HospPartAmt float64 `json:"hosp_part_amt"`
  3199. MedinsSetlID string `json:"medins_setl_id"`
  3200. PdnCashPay string `json:"pdn_cash_pay"`
  3201. } `json:"setlinfo"`
  3202. } `json:"output"`
  3203. RefmsgTime string `json:"refmsg_time"`
  3204. RespondTime string `json:"respond_time"`
  3205. Signtype interface{} `json:"signtype"`
  3206. WarnMsg interface{} `json:"warn_msg"`
  3207. }
  3208. type ResultSixteen10265 struct {
  3209. Cainfo string `json:"cainfo"`
  3210. ErrMsg string `json:"err_msg"`
  3211. InfRefmsgid string `json:"inf_refmsgid"`
  3212. Infcode string `json:"infcode"`
  3213. Output struct {
  3214. Setldetail []interface{} `json:"setldetail"`
  3215. Setlinfo struct {
  3216. MdtrtID string `json:"mdtrt_id"`
  3217. SetlID string `json:"setl_id"`
  3218. ClrOptins string `json:"clr_optins"`
  3219. SetlTime string `json:"setl_time"`
  3220. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3221. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3222. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3223. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3224. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3225. ActPayDedc float64 `json:"act_pay_dedc"`
  3226. HifpPay float64 `json:"hifp_pay"`
  3227. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3228. Lfpay float64 `json:"selfpay"`
  3229. CvlservPay float64 `json:"cvlserv_pay"`
  3230. HifesPay float64 `json:"hifes_pay"`
  3231. HifmiPay float64 `json:"hifmi_pay"`
  3232. HifobPay float64 `json:"hifob_pay"`
  3233. MafPay float64 `json:"maf_pay"`
  3234. OthPay float64 `json:"oth_pay"`
  3235. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3236. PsnPartAmt float64 `json:"psn_part_amt"`
  3237. AcctPay float64 `json:"acct_pay"`
  3238. Balc float64 `json:"balc"`
  3239. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3240. HospPartAmt float64 `json:"hosp_part_amt"`
  3241. MedinsSetlID string `json:"medins_setl_id"`
  3242. PdnCashPay string `json:"pdn_cash_pay"`
  3243. } `json:"setlinfo"`
  3244. } `json:"output"`
  3245. RefmsgTime string `json:"refmsg_time"`
  3246. RespondTime string `json:"respond_time"`
  3247. Signtype interface{} `json:"signtype"`
  3248. WarnMsg interface{} `json:"warn_msg"`
  3249. }
  3250. type ResultSeventeen struct {
  3251. ErrMsg string `json:"err_msg"`
  3252. InfRefmsgid string `json:"inf_refmsgid"`
  3253. Infcode int64 `json:"infcode"`
  3254. Output struct {
  3255. SetlListId string `json:"setl_list_id"`
  3256. } `json:"output"`
  3257. RefmsgTime string `json:"refmsg_time"`
  3258. RespondTime string `json:"respond_time"`
  3259. Signtype string `json:"signtype"`
  3260. WarnInfo string `json:"warn_info"`
  3261. }
  3262. type Result90991 struct {
  3263. ErrMsg string `json:"err_msg"`
  3264. InfRefmsgid string `json:"inf_refmsgid"`
  3265. Infcode int64 `json:"infcode"`
  3266. Output struct {
  3267. Result struct {
  3268. PsnNo string `json:"psn_no"`
  3269. CardStat string `json:"card_stat"`
  3270. Certno string `json:"certno"`
  3271. PsnName string `json:"psn_name"`
  3272. CheckStat string `json:"check_stat"`
  3273. } `json:"result"`
  3274. } `json:"output"`
  3275. RefmsgTime string `json:"refmsg_time"`
  3276. RespondTime string `json:"respond_time"`
  3277. Signtype interface{} `json:"signtype"`
  3278. WarnInfo interface{} `json:"warn_info"`
  3279. }
  3280. type Result90100 struct {
  3281. ErrMsg string `json:"err_msg"`
  3282. InfRefmsgid string `json:"inf_refmsgid"`
  3283. Infcode int64 `json:"infcode"`
  3284. Output struct {
  3285. PoolareaNo string `json:"poolarea_no"`
  3286. PoolareaNoName string `json:"poolarea_no_name"`
  3287. Insutype string `json:"insutype"`
  3288. InsutypeName string `json:"insutype_name"`
  3289. ClctType string `json:"clct_type"`
  3290. ClctTypeName string `json:"clct_type_name"`
  3291. ClctFlag string `json:"clct_flag"`
  3292. ClctFlagName string `json:"clct_flag_name"`
  3293. AccrymBegn string `json:"accrym_begn"`
  3294. AccrymEnd string `json:"accrym_end"`
  3295. ClctTime string `json:"clct_time"`
  3296. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3297. } `json:"output"`
  3298. RefmsgTime string `json:"refmsg_time"`
  3299. RespondTime string `json:"respond_time"`
  3300. Signtype interface{} `json:"signtype"`
  3301. WarnInfo interface{} `json:"warn_info"`
  3302. }
  3303. type Custom struct {
  3304. DetItemFeeSumamt string
  3305. Cut string
  3306. FeedetlSn string
  3307. Price string
  3308. MedListCodg string
  3309. Type int64
  3310. AdviceId int64
  3311. ProjectId int64
  3312. ItemId int64
  3313. }
  3314. type Result5301 struct {
  3315. ErrMsg string `json:"err_msg"`
  3316. InfRefmsgid string `json:"inf_refmsgid"`
  3317. Infcode int64 `json:"infcode"`
  3318. Output struct {
  3319. Result []struct {
  3320. OpspDiseCode string `json:"opsp_dise_code"`
  3321. OpspDiseName string `json:"opsp_dise_name"`
  3322. Begndate string `json:"begndate"`
  3323. Enddate string `json:"enddate"`
  3324. } `json:"feedetail"`
  3325. } `json:"output"`
  3326. RefmsgTime string `json:"refmsg_time"`
  3327. RespondTime string `json:"respond_time"`
  3328. Signtype interface{} `json:"signtype"`
  3329. WarnInfo interface{} `json:"warn_info"`
  3330. }
  3331. type Result5301For10265 struct {
  3332. ErrMsg string `json:"err_msg"`
  3333. InfRefmsgid string `json:"inf_refmsgid"`
  3334. Infcode string `json:"infcode"`
  3335. Output struct {
  3336. Result []struct {
  3337. OpspDiseCode string `json:"opsp_dise_code"`
  3338. OpspDiseName string `json:"opsp_dise_name"`
  3339. Begndate string `json:"begndate"`
  3340. Enddate string `json:"enddate"`
  3341. } `json:"feedetail"`
  3342. } `json:"output"`
  3343. RefmsgTime string `json:"refmsg_time"`
  3344. RespondTime string `json:"respond_time"`
  3345. Signtype interface{} `json:"signtype"`
  3346. WarnInfo interface{} `json:"warn_info"`
  3347. }
  3348. //获取个人信息----挂号-----上传就诊信息
  3349. func (c *HisApiController) GetRegisterInfo() {
  3350. id, _ := c.GetInt64("id")
  3351. record_time := c.GetString("record_time")
  3352. settlementValue, _ := c.GetInt64("settlement_value")
  3353. medical_insurance_card := c.GetString("medical_insurance_card")
  3354. name := c.GetString("name")
  3355. id_card_type, _ := c.GetInt64("id_card_type")
  3356. certificates, _ := c.GetInt64("certificates")
  3357. medical_care, _ := c.GetInt64("medical_care")
  3358. birthday := c.GetString("birthday")
  3359. id_card := c.GetString("id_card")
  3360. register_type, _ := c.GetInt64("register")
  3361. doctor, _ := c.GetInt64("doctor")
  3362. department, _ := c.GetInt64("department")
  3363. gender, _ := c.GetInt64("sex")
  3364. registration_fee, _ := c.GetFloat("registration_fee")
  3365. medical_expenses, _ := c.GetFloat("medical_expenses")
  3366. social_type, _ := c.GetInt64("social_type")
  3367. med_type := c.GetString("social_type")
  3368. admin_user_id, _ := c.GetInt64("admin_user_id")
  3369. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3370. timeLayout := "2006-01-02"
  3371. loc, _ := time.LoadLocation("Local")
  3372. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3373. birthUnix := birthdays.Unix()
  3374. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3375. if err != nil {
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3377. return
  3378. }
  3379. recordDateTime := theTime.Unix()
  3380. adminInfo := c.GetAdminUserInfo()
  3381. var patient service.Patients
  3382. if id == 0 {
  3383. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3384. } else {
  3385. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3386. }
  3387. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3388. if patientPrescription.ID == 0 {
  3389. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3390. }
  3391. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3392. if patient.ID == 0 {
  3393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3394. return
  3395. }
  3396. if len(patient.IdCardNo) == 0 {
  3397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3398. return
  3399. }
  3400. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3401. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3402. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3403. //就诊结算未完成,不能进行二次挂号
  3404. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3405. if len(his) >= 1 {
  3406. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3407. if len(his) >= 1 && order.ID == 0 {
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3409. return
  3410. }
  3411. }
  3412. //var register_log string
  3413. if config.IsOpen == 1 {
  3414. var res ResultTwo
  3415. var res10265 ResultTwo10265
  3416. var PsnNo string
  3417. var PsnCertType string
  3418. var Certno string
  3419. var PsnName string
  3420. var Gend string
  3421. var Naty string
  3422. var Brdy string
  3423. var Age float64
  3424. var infoStr string
  3425. var idetinfoStr string
  3426. var infocode int64
  3427. var verify_number string
  3428. fmt.Println(verify_number)
  3429. if miConfig.MdtrtareaAdmvs == "421300" {
  3430. psn_info, _ := service.GetPsnByPatientId(id)
  3431. PsnNo = psn_info.PsnNo
  3432. PsnCertType = psn_info.PsnCertType
  3433. Certno = psn_info.Certno
  3434. PsnName = psn_info.PsnName
  3435. Gend = psn_info.Gend
  3436. Naty = psn_info.Naty
  3437. Brdy = psn_info.Brdy
  3438. Age = psn_info.Age
  3439. infoStr = psn_info.Insuinfo
  3440. idetinfoStr = psn_info.Idetinfo
  3441. infocode = 0
  3442. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3443. psn_info, _ := service.GetPsnByPatientId(id)
  3444. PsnNo = psn_info.PsnNo
  3445. PsnCertType = psn_info.PsnCertType
  3446. Certno = psn_info.Certno
  3447. PsnName = psn_info.PsnName
  3448. Gend = psn_info.Gend
  3449. Naty = psn_info.Naty
  3450. Brdy = psn_info.Brdy
  3451. Age = psn_info.Age
  3452. infoStr = psn_info.Insuinfo
  3453. idetinfoStr = psn_info.Idetinfo
  3454. infocode = 0
  3455. verify_number = psn_info.VerifyNumber
  3456. } else {
  3457. var result string
  3458. var requestLog string
  3459. if miConfig.UserOrgId == 10138 {
  3460. 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)
  3461. } else {
  3462. 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)
  3463. }
  3464. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3465. if miConfig.Code == "H15049901371" {
  3466. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. res.ErrMsg = res10265.ErrMsg
  3472. res.Output = res10265.Output
  3473. res.InfRefmsgid = res10265.InfRefmsgid
  3474. } else {
  3475. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3476. utils.ErrorLog("解析失败:%v", err)
  3477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3478. return
  3479. }
  3480. }
  3481. PsnNo = res.Output.Baseinfo.PsnNo
  3482. PsnCertType = res.Output.Baseinfo.PsnCertType
  3483. Certno = res.Output.Baseinfo.Certno
  3484. PsnName = res.Output.Baseinfo.PsnName
  3485. Gend = res.Output.Baseinfo.Gend
  3486. Naty = res.Output.Baseinfo.Naty
  3487. Brdy = res.Output.Baseinfo.Brdy
  3488. Age = res.Output.Baseinfo.Age
  3489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3491. infoStr = string(Iinfos)
  3492. idetinfoStr = string(Idetinfos)
  3493. if miConfig.Code == "H15049901371" {
  3494. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3495. } else {
  3496. infocode = res.Infcode
  3497. }
  3498. }
  3499. if infocode == 0 {
  3500. his := models.VMHisPatient{
  3501. Name: name,
  3502. Gender: gender,
  3503. Birthday: birthUnix,
  3504. MedicalTreatmentType: medical_care,
  3505. IdType: certificates,
  3506. IdCardNo: id_card,
  3507. BalanceAccountsType: settlementValue,
  3508. SocialType: social_type,
  3509. MedicalInsuranceNumber: medical_insurance_card,
  3510. RegisterType: register_type,
  3511. RegisterCost: registration_fee,
  3512. TreatmentCost: medical_expenses,
  3513. Status: 1,
  3514. Ctime: time.Now().Unix(),
  3515. Mtime: time.Now().Unix(),
  3516. PsnNo: PsnNo,
  3517. PsnCertType: PsnCertType,
  3518. Certno: Certno,
  3519. PsnName: PsnName,
  3520. Gend: Gend,
  3521. Naty: Naty,
  3522. Brdy: Brdy,
  3523. Age: Age,
  3524. Iinfo: infoStr,
  3525. Idetinfo: idetinfoStr,
  3526. PatientId: patient.ID,
  3527. RecordDate: theTime.Unix(),
  3528. UserOrgId: adminInfo.CurrentOrgId,
  3529. AdminUserId: admin_user_id,
  3530. IsReturn: 1,
  3531. IdCardType: id_card_type,
  3532. Doctor: doctor,
  3533. Departments: department,
  3534. }
  3535. timestamp := time.Now().Unix()
  3536. tempTime := time.Unix(timestamp, 0)
  3537. timeFormat := tempTime.Format("20060102150405")
  3538. chrgBchno := rand.Intn(100000) + 10000
  3539. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3540. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3541. department, _ := service.GetDepartMentDetail(department)
  3542. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3543. IdCardNo := ""
  3544. if id_card_type == 1 {
  3545. // IdCardNo = medical_insurance_card
  3546. IdCardNo = patient.IdCardNo
  3547. } else {
  3548. IdCardNo = patient.IdCardNo
  3549. }
  3550. var rf []*ResultFive
  3551. json.Unmarshal([]byte(his.Iinfo), &rf)
  3552. var insutypes []*ResultFive
  3553. var insutype string
  3554. var insuplc_admdvs_temp string
  3555. var is390 int = 0
  3556. var is310 int = 0
  3557. for _, item := range rf {
  3558. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3559. insutypes = append(insutypes, item)
  3560. }
  3561. }
  3562. if len(insutypes) == 1 {
  3563. insutype = insutypes[0].Insutype
  3564. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3565. } else {
  3566. for _, i := range insutypes {
  3567. if i.Insutype == "390" {
  3568. is390 = 1
  3569. }
  3570. if i.Insutype == "310" {
  3571. is310 = 1
  3572. }
  3573. }
  3574. }
  3575. if is390 == 1 {
  3576. insutype = "390"
  3577. }
  3578. if is310 == 1 {
  3579. insutype = "310"
  3580. }
  3581. if len(insutypes) == 0 {
  3582. insutype = "310"
  3583. }
  3584. if len(insutypes) == 2 {
  3585. insutype = med_type
  3586. }
  3587. if len(med_type) > 0 {
  3588. insutype = med_type
  3589. }
  3590. //for _, item := range rf {
  3591. // if item.Insutype == insutype {
  3592. // insuplc_admdvs = item.InsuplcAdmdvs
  3593. // }
  3594. //}
  3595. var infocode int64
  3596. var resThree ResultThree
  3597. var resThree10265 ResultThree10265
  3598. if len(insuplc_admdvs) == 0 {
  3599. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3600. } else {
  3601. insuplc_admdvs_temp = insuplc_admdvs
  3602. }
  3603. if miConfig.MdtrtareaAdmvs == "421300" {
  3604. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3605. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3606. "&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
  3607. resp, requestErr := http.Get(api)
  3608. if requestErr != nil {
  3609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3610. return
  3611. }
  3612. body, ioErr := ioutil.ReadAll(resp.Body)
  3613. if ioErr != nil {
  3614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. var respJSON map[string]interface{}
  3619. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3622. return
  3623. }
  3624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3625. result, _ := json.Marshal(respJSON)
  3626. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3627. utils.ErrorLog("解析失败:%v", err)
  3628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3629. return
  3630. }
  3631. infocode = resThree.Infcode
  3632. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3633. psn_info, _ := service.GetPsnByPatientId(id)
  3634. bas := strings.Split(psn_info.CardInfo, "|")
  3635. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3636. var api string
  3637. if miConfig.MdtrtareaAdmvs == "320921" {
  3638. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3639. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3640. "&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
  3641. } else {
  3642. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3643. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3644. "&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
  3645. }
  3646. resp, requestErr := http.Get(api)
  3647. if requestErr != nil {
  3648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3649. return
  3650. }
  3651. body, ioErr := ioutil.ReadAll(resp.Body)
  3652. if ioErr != nil {
  3653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3655. return
  3656. }
  3657. var respJSON map[string]interface{}
  3658. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3661. return
  3662. }
  3663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3664. result, _ := json.Marshal(respJSON)
  3665. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3666. utils.ErrorLog("解析失败:%v", err)
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. resThree.ErrMsg = resThree10265.ErrMsg
  3671. resThree.Output = resThree10265.Output
  3672. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3673. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3674. } else {
  3675. 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)
  3676. saveLog(result, requestLog, "2201", "挂号")
  3677. if miConfig.Code == "H15049901371" {
  3678. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3679. utils.ErrorLog("解析失败:%v", err)
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. return
  3682. }
  3683. resThree.ErrMsg = resThree10265.ErrMsg
  3684. resThree.Output = resThree10265.Output
  3685. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3686. } else {
  3687. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3688. utils.ErrorLog("解析失败:%v", err)
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3690. return
  3691. }
  3692. }
  3693. if miConfig.Code == "H15049901371" {
  3694. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3695. } else {
  3696. infocode = resThree.Infcode
  3697. }
  3698. }
  3699. if infocode != 0 {
  3700. adminUser := c.GetAdminUserInfo()
  3701. errlog := &models.HisOrderError{
  3702. UserOrgId: adminUser.CurrentOrgId,
  3703. Ctime: time.Now().Unix(),
  3704. Mtime: time.Now().Unix(),
  3705. ErrMsg: resThree.ErrMsg,
  3706. Status: 1,
  3707. PatientId: id,
  3708. RecordTime: recordDateTime,
  3709. Stage: 2,
  3710. }
  3711. service.CreateErrMsgLog(errlog)
  3712. c.ServeSuccessJSON(map[string]interface{}{
  3713. "failed_code": -10,
  3714. "msg": resThree.ErrMsg,
  3715. })
  3716. return
  3717. }
  3718. his.Number = resThree.Output.Data.MdtrtID
  3719. his.PsnNo = resThree.Output.Data.PsnNo
  3720. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3721. his.IdCardNo = patient.IdCardNo
  3722. his.PhoneNumber = patient.Phone
  3723. his.UserOrgId = adminInfo.CurrentOrgId
  3724. his.Insutype = insutype
  3725. his.Ctime = time.Now().Unix()
  3726. his.Mtime = time.Now().Unix()
  3727. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3728. his.Status = 1
  3729. service.UpdateHisPatientStatus(&his)
  3730. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3731. c.ServeSuccessJSON(map[string]interface{}{
  3732. "his_info": his,
  3733. })
  3734. } else {
  3735. adminUser := c.GetAdminUserInfo()
  3736. errlog := &models.HisOrderError{
  3737. UserOrgId: adminUser.CurrentOrgId,
  3738. Ctime: time.Now().Unix(),
  3739. Mtime: time.Now().Unix(),
  3740. ErrMsg: res.ErrMsg,
  3741. Status: 1,
  3742. PatientId: id,
  3743. RecordTime: recordDateTime,
  3744. Stage: 1,
  3745. }
  3746. service.CreateErrMsgLog(errlog)
  3747. c.ServeSuccessJSON(map[string]interface{}{
  3748. "failed_code": -10,
  3749. "msg": res.ErrMsg,
  3750. })
  3751. return
  3752. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3753. }
  3754. }
  3755. }
  3756. //上传明细----预结算----确认订单
  3757. func (c *HisApiController) GetUploadInfo() {
  3758. id, _ := c.GetInt64("id")
  3759. record_time := c.GetString("record_time")
  3760. his_patient_id, _ := c.GetInt64("his_patient_id")
  3761. order_id, _ := c.GetInt64("order_id")
  3762. pay_way, _ := c.GetInt64("pay_way")
  3763. pay_price, _ := c.GetFloat("pay_price")
  3764. pay_card_no := c.GetString("pay_card_no")
  3765. discount_price, _ := c.GetFloat("discount_price")
  3766. preferential_price, _ := c.GetFloat("preferential_price")
  3767. reality_price, _ := c.GetFloat("reality_price")
  3768. found_price, _ := c.GetFloat("found_price")
  3769. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3770. private_price, _ := c.GetFloat("private_price")
  3771. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3772. admin_user_id, _ := c.GetInt64("admin_user_id")
  3773. fapiao_code := c.GetString("fapiao_code")
  3774. fapiao_number := c.GetString("fapiao_number")
  3775. diagnosis_id := c.GetString("diagnosis")
  3776. sick_type, _ := c.GetInt64("sick_type")
  3777. reg_type, _ := c.GetInt64("p_type")
  3778. begin_time := c.GetString("begin_time")
  3779. id_str := c.GetString("ids")
  3780. ids_arr := strings.Split(id_str, ",")
  3781. timeLayout := "2006-01-02"
  3782. loc, _ := time.LoadLocation("Local")
  3783. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3784. if err != nil {
  3785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3786. return
  3787. }
  3788. recordDateTime := theTime.Unix()
  3789. adminUser := c.GetAdminUserInfo()
  3790. var tempOrder models.HisOrder
  3791. tempOrder, _ = service.GetHisOrderByID(order_id)
  3792. var prescriptions []*models.HisPrescription
  3793. var start_time int64
  3794. var end_time int64
  3795. //if adminUser.CurrentOrgId == 10106{
  3796. // if len(fapiao_code) == 0{
  3797. // fapiao_code = "144072080589"
  3798. // }
  3799. // if len(fapiao_number) == 0{
  3800. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3801. // if order.ID == 0{
  3802. // fapiao_number = "00001520"
  3803. // }else{
  3804. // //fapiao_code = "00001520"
  3805. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3806. // var zero string
  3807. // if fpNumber >= 1000{
  3808. // zero = "0000" + strconv.Itoa(fpNumber)
  3809. // }else if fpNumber >= 10000{
  3810. // zero = "000" + strconv.Itoa(fpNumber)
  3811. // } else if fpNumber >= 100000{
  3812. // zero = "00" + strconv.Itoa(fpNumber)
  3813. // } else if fpNumber >= 1000000{
  3814. // zero = "0" + strconv.Itoa(fpNumber)
  3815. // }else {
  3816. // zero = strconv.Itoa(fpNumber)
  3817. // }
  3818. // fapiao_number = zero
  3819. // }
  3820. // }
  3821. //}
  3822. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3823. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3824. var patientPrescription models.HisPrescriptionInfo
  3825. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3826. if patientPrescription.ID == 0 {
  3827. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3828. }
  3829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3830. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3831. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3832. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3833. var config []*models.HisXtDiagnoseConfig
  3834. for _, item := range diagnosis_ids {
  3835. id, _ := strconv.ParseInt(item, 10, 64)
  3836. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3837. config = append(config, &diagnosisConfig)
  3838. }
  3839. sickConfig, _ := service.FindSickById(sick_type)
  3840. //if tempOrder.ID == 0 {
  3841. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3842. //}
  3843. if tempOrder.ID == 0 {
  3844. var result string
  3845. var requestLog string
  3846. var res2 ResultSix
  3847. var ressix10265 ResultSix10265
  3848. if miConfig.MdtrtareaAdmvs == "421300" {
  3849. data := make(map[string]interface{})
  3850. client := &http.Client{}
  3851. data["psn_no"] = his.PsnNo
  3852. data["mdtrt_id"] = his.Number
  3853. data["doctor"] = roles.UserName
  3854. data["department"] = department.Name
  3855. data["org_name"] = miConfig.OrgName
  3856. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3857. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3858. data["fixmedins_code"] = miConfig.Code
  3859. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3860. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3861. data["secret_key"] = miConfig.SecretKey
  3862. data["sick_code"] = sickConfig.CountryCode
  3863. data["sick_name"] = sickConfig.ClassName
  3864. data["dept"] = strconv.FormatInt(department.ID, 10)
  3865. data["config"] = config
  3866. data["begin_time"] = begin_time
  3867. bytesData, _ := json.Marshal(data)
  3868. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3869. resp, _ := client.Do(req)
  3870. defer resp.Body.Close()
  3871. body, ioErr := ioutil.ReadAll(resp.Body)
  3872. if ioErr != nil {
  3873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3875. return
  3876. }
  3877. var respJSON map[string]interface{}
  3878. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3881. return
  3882. }
  3883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3884. userJSONBytes, _ := json.Marshal(respJSON)
  3885. fmt.Println("log")
  3886. fmt.Println(string(userJSONBytes))
  3887. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3888. utils.ErrorLog("解析失败:%v", err)
  3889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. return
  3891. }
  3892. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3893. //江苏地区国家医保医疗类别
  3894. //职工透析:医疗类别选特殊情况门诊9933
  3895. //居民血透门慢: 医疗类别选门诊慢病1402
  3896. //var med_type string
  3897. //if his.Insutype == "310" {
  3898. // if reg_type == 14 {
  3899. // med_type = "9933"
  3900. // } else if reg_type == 11 {
  3901. // med_type = "11"
  3902. //
  3903. // }
  3904. //} else if his.Insutype == "390" {
  3905. // if reg_type == 14 {
  3906. // med_type = "1402"
  3907. // } else if reg_type == 11 {
  3908. // med_type = "11"
  3909. // }
  3910. //}
  3911. data := make(map[string]interface{})
  3912. client := &http.Client{}
  3913. data["psn_no"] = his.PsnNo
  3914. data["mdtrt_id"] = his.Number
  3915. data["doctor"] = roles.UserName
  3916. data["department"] = department.Name
  3917. data["org_name"] = miConfig.OrgName
  3918. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3919. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3920. data["fixmedins_code"] = miConfig.Code
  3921. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3922. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3923. data["secret_key"] = miConfig.SecretKey
  3924. data["sick_code"] = sickConfig.CountryCode
  3925. data["sick_name"] = sickConfig.ClassName
  3926. data["url"] = miConfig.Url
  3927. data["ak"] = miConfig.AccessKey
  3928. data["begin_time"] = begin_time
  3929. data["cainfo"] = miConfig.Cainfo
  3930. data["dept"] = strconv.FormatInt(department.ID, 10)
  3931. data["config"] = config
  3932. bytesData, _ := json.Marshal(data)
  3933. var req *http.Request
  3934. if miConfig.MdtrtareaAdmvs == "320921" {
  3935. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3936. //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 +
  3937. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3938. } else {
  3939. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3940. }
  3941. resp, _ := client.Do(req)
  3942. defer resp.Body.Close()
  3943. body, ioErr := ioutil.ReadAll(resp.Body)
  3944. if ioErr != nil {
  3945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. return
  3948. }
  3949. var respJSON map[string]interface{}
  3950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3956. userJSONBytes, _ := json.Marshal(respJSON)
  3957. fmt.Println("log")
  3958. fmt.Println(string(userJSONBytes))
  3959. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3960. utils.ErrorLog("解析失败:%v", err)
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. return
  3963. }
  3964. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3965. res2.Output = ressix10265.Output
  3966. res2.ErrMsg = ressix10265.ErrMsg
  3967. res2.Cainfo = ressix10265.Cainfo
  3968. res2.WarnMsg = ressix10265.WarnMsg
  3969. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3970. res2.Infcode = infocode
  3971. } else {
  3972. if miConfig.MdtrtareaAdmvs == "440781" { //
  3973. 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)
  3974. } else {
  3975. if miConfig.Code == "H15049901371" {
  3976. //赤峰地区国家医保医疗类别
  3977. //职工透析:医疗类别选特殊情况门诊990502
  3978. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3979. var med_type string
  3980. if his.Insutype == "390" {
  3981. if reg_type == 14 {
  3982. med_type = "9933"
  3983. } else if reg_type == 11 {
  3984. med_type = "11"
  3985. }
  3986. } else if his.Insutype == "310" {
  3987. if reg_type == 14 {
  3988. med_type = "990502"
  3989. } else if reg_type == 11 {
  3990. med_type = "11"
  3991. }
  3992. }
  3993. 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)
  3994. } else {
  3995. 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)
  3996. }
  3997. }
  3998. saveLog(result, requestLog, "2203", "上传就诊信息")
  3999. var respJSON2 map[string]interface{}
  4000. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4003. return
  4004. }
  4005. userJSONBytes2, _ := json.Marshal(respJSON2)
  4006. if miConfig.Code == "H15049901371" {
  4007. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4008. utils.ErrorLog("解析失败:%v", err)
  4009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4010. return
  4011. }
  4012. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4013. res2.Output = ressix10265.Output
  4014. res2.ErrMsg = ressix10265.ErrMsg
  4015. res2.Cainfo = ressix10265.Cainfo
  4016. res2.WarnMsg = ressix10265.WarnMsg
  4017. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4018. res2.Infcode = infocode
  4019. } else {
  4020. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4021. utils.ErrorLog("解析失败:%v", err)
  4022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4023. return
  4024. }
  4025. }
  4026. }
  4027. if res2.Infcode != 0 {
  4028. adminUser := c.GetAdminUserInfo()
  4029. errlog := &models.HisOrderError{
  4030. UserOrgId: adminUser.CurrentOrgId,
  4031. Ctime: time.Now().Unix(),
  4032. Mtime: time.Now().Unix(),
  4033. ErrMsg: res2.ErrMsg,
  4034. Status: 1,
  4035. PatientId: id,
  4036. RecordTime: recordDateTime,
  4037. Stage: 3,
  4038. }
  4039. service.CreateErrMsgLog(errlog)
  4040. c.ServeSuccessJSON(map[string]interface{}{
  4041. "failed_code": -10,
  4042. "msg": res2.ErrMsg,
  4043. })
  4044. return
  4045. } else {
  4046. his.Diagnosis = diagnosis_id
  4047. his.SickType = sickConfig.ID
  4048. var p_type int64
  4049. if reg_type == 1111 || reg_type == 1112 {
  4050. p_type = 11
  4051. }
  4052. his.PType = fmt.Sprintf("%d", p_type)
  4053. service.UpdateHisPatientThree(&his)
  4054. data := make(map[string]interface{})
  4055. if settle_accounts_type == 1 { //日结
  4056. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4057. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4058. } else {
  4059. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4060. }
  4061. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4062. data["pre"] = prescriptions
  4063. } else { //月结
  4064. start_time_str := c.GetString("start_time")
  4065. end_time_str := c.GetString("end_time")
  4066. timeLayout := "2006-01-02"
  4067. loc, _ := time.LoadLocation("Local")
  4068. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4069. if err != nil {
  4070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4071. return
  4072. }
  4073. recordStartTime := theStartTime.Unix()
  4074. start_time = recordStartTime
  4075. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4076. if err != nil {
  4077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4078. return
  4079. }
  4080. recordEndTime := theEndTime.Unix()
  4081. end_time = recordEndTime
  4082. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4083. data["pre"] = prescriptions
  4084. }
  4085. timestamp := time.Now().Unix()
  4086. tempTime := time.Unix(timestamp, 0)
  4087. timeFormat := tempTime.Format("20060102150405")
  4088. chrgBchno := rand.Intn(100000) + 10000
  4089. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4090. strconv.FormatInt(his.PatientId, 10)
  4091. client := &http.Client{}
  4092. data["psn_no"] = his.PsnNo
  4093. data["mdtrt_id"] = his.Number
  4094. data["chrg_bchno"] = chrg_bchno
  4095. data["org_name"] = miConfig.OrgName
  4096. data["doctor"] = roles.UserName
  4097. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4098. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4099. data["fixmedins_code"] = miConfig.Code
  4100. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4101. // data["dept_code"] = "15"
  4102. //} else {
  4103. data["dept_code"] = department.Number
  4104. //}
  4105. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4106. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4107. data["secret_key"] = miConfig.SecretKey
  4108. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4109. data["url"] = miConfig.Url
  4110. data["ak"] = miConfig.AccessKey
  4111. data["new_doctor_name"] = patientPrescription.Doctor
  4112. data["diag_code"] = sickConfig.CountryCode
  4113. data["cainfo"] = miConfig.Cainfo
  4114. var ids []int64
  4115. for _, item := range prescriptions {
  4116. ids = append(ids, item.ID)
  4117. }
  4118. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4119. if config.IsOpen == 1 { //对接了医保,走医保流程
  4120. var res ResultFour
  4121. var resFour10265 ResultFour10265
  4122. if miConfig.MdtrtareaAdmvs == "421300" {
  4123. bytesData, _ := json.Marshal(data)
  4124. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4125. resp, _ := client.Do(req)
  4126. defer resp.Body.Close()
  4127. body, ioErr := ioutil.ReadAll(resp.Body)
  4128. if ioErr != nil {
  4129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4131. return
  4132. }
  4133. var respJSON map[string]interface{}
  4134. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. return
  4138. }
  4139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4140. userJSONBytes, _ := json.Marshal(respJSON)
  4141. fmt.Println("log")
  4142. fmt.Println(string(userJSONBytes))
  4143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4144. utils.ErrorLog("解析失败:%v", err)
  4145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4146. return
  4147. }
  4148. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4149. bytesData, _ := json.Marshal(data)
  4150. var req *http.Request
  4151. if miConfig.MdtrtareaAdmvs == "320921" {
  4152. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4153. } else {
  4154. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4155. }
  4156. resp, _ := client.Do(req)
  4157. defer resp.Body.Close()
  4158. body, ioErr := ioutil.ReadAll(resp.Body)
  4159. if ioErr != nil {
  4160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4162. return
  4163. }
  4164. var respJSON map[string]interface{}
  4165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4171. userJSONBytes, _ := json.Marshal(respJSON)
  4172. fmt.Println("log")
  4173. fmt.Println(string(userJSONBytes))
  4174. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4175. utils.ErrorLog("解析失败:%v", err)
  4176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4177. return
  4178. }
  4179. res.InfRefmsgid = resFour10265.InfRefmsgid
  4180. res.Output = resFour10265.Output
  4181. res.ErrMsg = resFour10265.ErrMsg
  4182. res.Cainfo = resFour10265.Cainfo
  4183. res.WarnMsg = resFour10265.WarnMsg
  4184. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4185. res.Infcode = infocode
  4186. } else {
  4187. if miConfig.Code == "H15049901371" {
  4188. 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)
  4189. var dat map[string]interface{}
  4190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4191. fmt.Println(dat)
  4192. } else {
  4193. fmt.Println(err)
  4194. }
  4195. saveLog(result, request_log, "2204", "上传费用明细")
  4196. userJSONBytes, _ := json.Marshal(dat)
  4197. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. res.InfRefmsgid = resFour10265.InfRefmsgid
  4203. res.Output = resFour10265.Output
  4204. res.ErrMsg = resFour10265.ErrMsg
  4205. res.Cainfo = resFour10265.Cainfo
  4206. res.WarnMsg = resFour10265.WarnMsg
  4207. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4208. res.Infcode = infocode
  4209. } else {
  4210. 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)
  4211. var dat map[string]interface{}
  4212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4213. fmt.Println(dat)
  4214. } else {
  4215. fmt.Println(err)
  4216. }
  4217. saveLog(result, request_log, "2204", "上传费用明细")
  4218. userJSONBytes, _ := json.Marshal(dat)
  4219. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4220. utils.ErrorLog("解析失败:%v", err)
  4221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4222. return
  4223. }
  4224. }
  4225. }
  4226. if res.Infcode == 0 {
  4227. order := &models.HisOrder{
  4228. UserOrgId: adminUser.CurrentOrgId,
  4229. HisPatientId: his.ID,
  4230. PatientId: his.PatientId,
  4231. SettleAccountsDate: recordDateTime,
  4232. MdtrtId: his.Number,
  4233. PsnNo: his.PsnNo,
  4234. MedType: strconv.FormatInt(reg_type, 10),
  4235. Ctime: time.Now().Unix(),
  4236. Mtime: time.Now().Unix(),
  4237. Status: 1,
  4238. Number: chrg_bchno,
  4239. Infcode: res.Infcode,
  4240. WarnMsg: res.WarnMsg,
  4241. Cainfo: res.Cainfo,
  4242. ErrMsg: res.ErrMsg,
  4243. RespondTime: res.RefmsgTime,
  4244. InfRefmsgid: res.InfRefmsgid,
  4245. OrderStatus: 1,
  4246. PayWay: pay_way,
  4247. PayPrice: pay_price,
  4248. PayCardNo: pay_card_no,
  4249. DiscountPrice: discount_price,
  4250. PreferentialPrice: preferential_price,
  4251. RealityPrice: reality_price,
  4252. FoundPrice: found_price,
  4253. MedicalInsurancePrice: medical_insurance_price,
  4254. PrivatePrice: private_price,
  4255. IsMedicineInsurance: 1,
  4256. SettleType: settle_accounts_type,
  4257. SettleStartTime: start_time,
  4258. SettleEndTime: end_time,
  4259. Creator: roles.AdminUserId,
  4260. Modify: roles.AdminUserId,
  4261. FaPiaoNumber: fapiao_number,
  4262. FaPiaoCode: fapiao_code,
  4263. PType: 2,
  4264. Diagnosis: diagnosis_id,
  4265. }
  4266. err = service.CreateOrder(order)
  4267. if err != nil {
  4268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4269. return
  4270. }
  4271. for _, item := range res.Output.Result {
  4272. temp := strings.Split(item.FeedetlSn, "-")
  4273. var advice_id int64 = 0
  4274. var project_id int64 = 0
  4275. var types int64 = 0
  4276. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4277. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4278. if temp[1] == "1" {
  4279. advice_id = id
  4280. project_id = 0
  4281. } else if temp[1] == "2" {
  4282. advice_id = 0
  4283. project_id = id
  4284. }
  4285. info := &models.HisOrderInfo{
  4286. OrderNumber: order.Number,
  4287. FeedetlSn: item.FeedetlSn,
  4288. UploadDate: time.Now().Unix(),
  4289. AdviceId: advice_id,
  4290. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4291. Cnt: item.Cnt,
  4292. Pric: float64(item.Pric),
  4293. PatientId: his.PatientId,
  4294. PricUplmtAmt: item.PricUplmtAmt,
  4295. SelfpayProp: item.SelfpayProp,
  4296. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4297. OverlmtAmt: item.OverlmtAmt,
  4298. PreselfpayAmt: item.PreselfpayAmt,
  4299. BasMednFlag: item.BasMednFlag,
  4300. MedChrgitmType: item.MedChrgitmType,
  4301. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4302. Status: 1,
  4303. Memo: item.Memo,
  4304. Mtime: time.Now().Unix(),
  4305. InscpScpAmt: item.InscpScpAmt,
  4306. DrtReimFlag: item.DrtReimFlag,
  4307. Ctime: time.Now().Unix(),
  4308. ListSpItemFlag: item.ListSpItemFlag,
  4309. ChldMedcFlag: item.ChldMedcFlag,
  4310. LmtUsedFlag: item.LmtUsedFlag,
  4311. ChrgitmLv: item.ChrgitmLv,
  4312. UserOrgId: adminUser.CurrentOrgId,
  4313. HisPatientId: his.ID,
  4314. OrderId: order.ID,
  4315. ProjectId: project_id,
  4316. Type: types,
  4317. }
  4318. service.CreateOrderInfo(info)
  4319. }
  4320. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4321. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4322. var total float64
  4323. for _, item := range prescriptions {
  4324. if item.Type == 1 { //药品
  4325. for _, subItem := range item.HisDoctorAdviceInfo {
  4326. total = total + (subItem.Price * subItem.PrescribingNumber)
  4327. }
  4328. }
  4329. if item.Type == 2 { //项目
  4330. for _, subItem := range item.HisPrescriptionProject {
  4331. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4332. total = total + (subItem.Price * cnt)
  4333. }
  4334. }
  4335. }
  4336. for _, item := range prescriptions {
  4337. for _, subItem := range item.HisAdditionalCharge {
  4338. total = total + (subItem.Price * float64(subItem.Count))
  4339. }
  4340. }
  4341. var allTotal string
  4342. if adminUser.CurrentOrgId == 9919 {
  4343. allTotal = fmt.Sprintf("%.4f", total)
  4344. } else {
  4345. allTotal = fmt.Sprintf("%.4f", total)
  4346. }
  4347. if res.Infcode == 0 {
  4348. var rf []*ResultFive
  4349. json.Unmarshal([]byte(his.Iinfo), &rf)
  4350. chrg_bchno := chrg_bchno
  4351. cert_no := his.Certno
  4352. var insutypes []string
  4353. var insutype string
  4354. var is390 int = 0
  4355. var is310 int = 0
  4356. for _, item := range rf {
  4357. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4358. insutypes = append(insutypes, item.Insutype)
  4359. }
  4360. }
  4361. if len(insutypes) == 1 {
  4362. insutype = insutypes[0]
  4363. } else {
  4364. for _, i := range insutypes {
  4365. if i == "390" {
  4366. is390 = 1
  4367. }
  4368. if i == "310" {
  4369. is310 = 1
  4370. }
  4371. }
  4372. }
  4373. if is390 == 1 {
  4374. insutype = "390"
  4375. }
  4376. if is310 == 1 {
  4377. insutype = "310"
  4378. }
  4379. if len(insutypes) == 0 {
  4380. insutype = "310"
  4381. }
  4382. if len(insutypes) == 2 {
  4383. insutype = strconv.FormatInt(his.SocialType, 10)
  4384. }
  4385. insutype = strconv.FormatInt(his.SocialType, 10)
  4386. //insutype = "390"
  4387. if his.IdCardType == 1 {
  4388. // cert_no = his.MedicalInsuranceNumber
  4389. cert_no = his.Certno
  4390. } else {
  4391. cert_no = his.Certno
  4392. }
  4393. var res ResultSeven
  4394. var resSeven10265 ResultSeven10265
  4395. var src_resquest string
  4396. var result2 string
  4397. var acct_used_flag string
  4398. fmt.Println("pay_way")
  4399. fmt.Println(pay_way)
  4400. fmt.Println("pay_way")
  4401. if pay_way == 4 {
  4402. acct_used_flag = "1"
  4403. } else {
  4404. acct_used_flag = "0"
  4405. }
  4406. if miConfig.MdtrtareaAdmvs == "421300" {
  4407. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4408. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4409. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4410. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4411. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4412. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4413. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4414. resp, requestErr := http.Get(api)
  4415. if requestErr != nil {
  4416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4417. return
  4418. }
  4419. body, ioErr := ioutil.ReadAll(resp.Body)
  4420. if ioErr != nil {
  4421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4423. return
  4424. }
  4425. var respJSON map[string]interface{}
  4426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4429. return
  4430. }
  4431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4432. result, _ := json.Marshal(respJSON)
  4433. if miConfig.Code == "H15049901371" {
  4434. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4435. utils.ErrorLog("解析失败:%v", err)
  4436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4437. return
  4438. }
  4439. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4440. res.Output = resSeven10265.Output
  4441. res.ErrMsg = resSeven10265.ErrMsg
  4442. res.Cainfo = resSeven10265.Cainfo
  4443. res.WarnMsg = resSeven10265.WarnMsg
  4444. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4445. res.Infcode = infocode
  4446. } else {
  4447. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4448. utils.ErrorLog("解析失败:%v", err)
  4449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. return
  4451. }
  4452. }
  4453. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4454. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4455. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4456. //psn_info, _ := service.GetPsnByPatientId(id)
  4457. bas := strings.Split(psn_info.CardInfo, "|")
  4458. if his.IdCardType == 1 {
  4459. cert_no = bas[2]
  4460. } else {
  4461. cert_no = bas[1]
  4462. }
  4463. //江苏地区国家医保医疗类别
  4464. //职工透析:医疗类别选特殊情况门诊9933
  4465. //居民血透门慢: 医疗类别选门诊慢病1402
  4466. //var med_type string
  4467. //if his.Insutype == "310" {
  4468. // if reg_type == 14 {
  4469. // med_type = "9933"
  4470. // } else if reg_type == 11 {
  4471. // med_type = "11"
  4472. //
  4473. // }
  4474. //} else if his.Insutype == "390" {
  4475. // if reg_type == 14 {
  4476. // med_type = "1402"
  4477. // } else if reg_type == 11 {
  4478. // med_type = "11"
  4479. // }
  4480. //}
  4481. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4482. var api string
  4483. if miConfig.MdtrtareaAdmvs == "320921" {
  4484. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4485. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4486. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4488. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4489. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4490. "&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
  4491. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4492. } else {
  4493. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4494. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4495. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4496. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4497. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4498. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4499. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4500. "&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
  4501. }
  4502. resp, requestErr := http.Get(api)
  4503. if requestErr != nil {
  4504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4505. return
  4506. }
  4507. body, ioErr := ioutil.ReadAll(resp.Body)
  4508. if ioErr != nil {
  4509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4511. return
  4512. }
  4513. var respJSON map[string]interface{}
  4514. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4517. return
  4518. }
  4519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4520. result, _ := json.Marshal(respJSON)
  4521. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4522. utils.ErrorLog("解析失败:%v", err)
  4523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4524. return
  4525. }
  4526. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4527. res.Output = resSeven10265.Output
  4528. res.ErrMsg = resSeven10265.ErrMsg
  4529. res.Cainfo = resSeven10265.Cainfo
  4530. res.WarnMsg = resSeven10265.WarnMsg
  4531. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4532. res.Infcode = infocode
  4533. } else {
  4534. if miConfig.Code == "H15049901371" {
  4535. //赤峰地区国家医保医疗类别
  4536. //职工透析:医疗类别选特殊情况门诊990502
  4537. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4538. var med_type string
  4539. if his.Insutype == "390" {
  4540. if reg_type == 14 {
  4541. med_type = "9933"
  4542. } else if reg_type == 11 {
  4543. med_type = "11"
  4544. }
  4545. } else if his.Insutype == "310" {
  4546. if reg_type == 14 {
  4547. med_type = "990502"
  4548. } else if reg_type == 11 {
  4549. med_type = "11"
  4550. }
  4551. }
  4552. 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)
  4553. } else {
  4554. 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)
  4555. }
  4556. //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)
  4557. var dat map[string]interface{}
  4558. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4559. fmt.Println(dat)
  4560. } else {
  4561. fmt.Println(err)
  4562. }
  4563. saveLog(result2, src_resquest, "2207", "结算")
  4564. userJSONBytes, _ := json.Marshal(dat)
  4565. if miConfig.Code == "H15049901371" {
  4566. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4567. utils.ErrorLog("解析失败:%v", err)
  4568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. return
  4570. }
  4571. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4572. res.Output = resSeven10265.Output
  4573. res.ErrMsg = resSeven10265.ErrMsg
  4574. res.Cainfo = resSeven10265.Cainfo
  4575. res.WarnMsg = resSeven10265.WarnMsg
  4576. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4577. res.Infcode = infocode
  4578. } else {
  4579. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4580. utils.ErrorLog("解析失败:%v", err)
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4582. return
  4583. }
  4584. }
  4585. }
  4586. if res.Infcode != 0 {
  4587. errlog := &models.HisOrderError{
  4588. UserOrgId: adminUser.CurrentOrgId,
  4589. Ctime: time.Now().Unix(),
  4590. Mtime: time.Now().Unix(),
  4591. Number: chrg_bchno,
  4592. ErrMsg: res.ErrMsg,
  4593. Status: 1,
  4594. PatientId: id,
  4595. RecordTime: recordDateTime,
  4596. Stage: 6,
  4597. }
  4598. service.CreateErrMsgLog(errlog)
  4599. c.ServeSuccessJSON(map[string]interface{}{
  4600. "failed_code": -10,
  4601. "msg": res.ErrMsg,
  4602. })
  4603. return
  4604. } else {
  4605. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4606. order.OrderStatus = 2
  4607. order.Status = 1
  4608. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4609. order.SetlId = res.Output.Setlinfo.SetlID
  4610. order.PsnNo = res.Output.Setlinfo.PsnNo
  4611. order.PsnName = res.Output.Setlinfo.PsnName
  4612. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4613. order.Certno = res.Output.Setlinfo.Certno
  4614. order.Gend = res.Output.Setlinfo.Gend
  4615. order.Naty = res.Output.Setlinfo.Naty
  4616. order.Age = res.Output.Setlinfo.Age
  4617. order.Insutype = res.Output.Setlinfo.Insutype
  4618. order.PsnType = res.Output.Setlinfo.PsnType
  4619. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4620. order.SetlTime = res.Output.Setlinfo.SetlTime
  4621. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4622. if res.Output.Setlinfo.MedType == "140101" {
  4623. order.MedType = "14"
  4624. } else {
  4625. order.MedType = res.Output.Setlinfo.MedType
  4626. }
  4627. if reg_type == 1112 {
  4628. order.MedType = "1112"
  4629. }
  4630. if reg_type == 1111 {
  4631. order.MedType = "1111"
  4632. }
  4633. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4634. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4635. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4636. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4637. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4638. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4639. order.HifpPay = res.Output.Setlinfo.HifpPay
  4640. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4641. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4642. order.HifesPay = res.Output.Setlinfo.HifesPay
  4643. order.HifobPay = res.Output.Setlinfo.HifobPay
  4644. order.MafPay = res.Output.Setlinfo.MafPay
  4645. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4646. order.OthPay = res.Output.Setlinfo.OthPay
  4647. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4648. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4649. order.AcctPay = res.Output.Setlinfo.AcctPay
  4650. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4651. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4652. order.Balc = res.Output.Setlinfo.Balc
  4653. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4654. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4655. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4656. order.ClrType = res.Output.Setlinfo.ClrType
  4657. order.ClrWay = res.Output.Setlinfo.ClrWay
  4658. order.Creator = order.Creator
  4659. order.Modify = roles.AdminUserId
  4660. order.RequestLog = src_resquest
  4661. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4662. detailStr := string(setlDetail)
  4663. order.SetlDetail = detailStr
  4664. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4665. err = service.UpDateOrder(order)
  4666. if err == nil {
  4667. c.ServeSuccessJSON(map[string]interface{}{
  4668. "msg": "结算成功",
  4669. })
  4670. } else {
  4671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4672. return
  4673. }
  4674. }
  4675. } else {
  4676. adminUser := c.GetAdminUserInfo()
  4677. errlog := &models.HisOrderError{
  4678. UserOrgId: adminUser.CurrentOrgId,
  4679. Ctime: time.Now().Unix(),
  4680. Mtime: time.Now().Unix(),
  4681. ErrMsg: res.ErrMsg,
  4682. Status: 1,
  4683. PatientId: id,
  4684. RecordTime: recordDateTime,
  4685. Stage: 4,
  4686. }
  4687. service.CreateErrMsgLog(errlog)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4689. return
  4690. }
  4691. } else {
  4692. adminUser := c.GetAdminUserInfo()
  4693. errlog := &models.HisOrderError{
  4694. UserOrgId: adminUser.CurrentOrgId,
  4695. Ctime: time.Now().Unix(),
  4696. Mtime: time.Now().Unix(),
  4697. ErrMsg: res.ErrMsg,
  4698. Status: 1,
  4699. PatientId: id,
  4700. RecordTime: recordDateTime,
  4701. Stage: 4,
  4702. }
  4703. service.CreateErrMsgLog(errlog)
  4704. c.ServeSuccessJSON(map[string]interface{}{
  4705. "failed_code": -10,
  4706. "msg": res.ErrMsg,
  4707. })
  4708. return
  4709. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4710. //return
  4711. }
  4712. }
  4713. }
  4714. } else if tempOrder.ID > 0 {
  4715. if tempOrder.IsPre == 1 {
  4716. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4717. var rf []*ResultFive
  4718. json.Unmarshal([]byte(his.Iinfo), &rf)
  4719. chrg_bchno := tempOrder.Number
  4720. cert_no := his.Certno
  4721. var insutypes []string
  4722. var insutype string
  4723. var is390 int = 0
  4724. var is310 int = 0
  4725. for _, item := range rf {
  4726. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4727. insutypes = append(insutypes, item.Insutype)
  4728. }
  4729. }
  4730. if len(insutypes) == 1 {
  4731. insutype = insutypes[0]
  4732. } else {
  4733. for _, i := range insutypes {
  4734. if i == "390" {
  4735. is390 = 1
  4736. }
  4737. if i == "310" {
  4738. is310 = 1
  4739. }
  4740. }
  4741. }
  4742. if is390 == 1 {
  4743. insutype = "390"
  4744. }
  4745. if is310 == 1 {
  4746. insutype = "310"
  4747. }
  4748. if len(insutypes) == 0 {
  4749. insutype = "310"
  4750. }
  4751. if len(insutypes) == 2 {
  4752. insutype = strconv.FormatInt(his.SocialType, 64)
  4753. }
  4754. //insutype = "390"
  4755. if his.IdCardType == 1 {
  4756. // cert_no = his.MedicalInsuranceNumber
  4757. cert_no = his.Certno
  4758. } else {
  4759. cert_no = his.Certno
  4760. }
  4761. var res ResultSeven
  4762. var resSeven10265 ResultSeven10265
  4763. var src_resquest string
  4764. var result2 string
  4765. var acct_used_flag string
  4766. fmt.Println("pay_way")
  4767. fmt.Println(pay_way)
  4768. fmt.Println("pay_way")
  4769. if pay_way == 4 {
  4770. acct_used_flag = "1"
  4771. } else {
  4772. acct_used_flag = "0"
  4773. }
  4774. if miConfig.MdtrtareaAdmvs == "421300" {
  4775. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4776. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4777. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4779. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4780. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4781. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4782. resp, requestErr := http.Get(api)
  4783. if requestErr != nil {
  4784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4785. return
  4786. }
  4787. body, ioErr := ioutil.ReadAll(resp.Body)
  4788. if ioErr != nil {
  4789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4791. return
  4792. }
  4793. var respJSON map[string]interface{}
  4794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4800. result, _ := json.Marshal(respJSON)
  4801. fmt.Println("log")
  4802. fmt.Println(string(result))
  4803. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4804. utils.ErrorLog("解析失败:%v", err)
  4805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4806. return
  4807. }
  4808. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4809. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4810. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4811. //psn_info, _ := service.GetPsnByPatientId(id)
  4812. bas := strings.Split(psn_info.CardInfo, "|")
  4813. if his.IdCardType == 1 {
  4814. cert_no = bas[2]
  4815. } else {
  4816. cert_no = bas[1]
  4817. }
  4818. //江苏地区国家医保医疗类别
  4819. //职工透析:医疗类别选特殊情况门诊9933
  4820. //居民血透门慢: 医疗类别选门诊慢病1402
  4821. //var med_type string
  4822. //if his.Insutype == "310" {
  4823. // if reg_type == 14 {
  4824. // med_type = "9933"
  4825. // } else if reg_type == 11 {
  4826. // med_type = "11"
  4827. //
  4828. // }
  4829. //} else if his.Insutype == "390" {
  4830. // if reg_type == 14 {
  4831. // med_type = "1402"
  4832. // } else if reg_type == 11 {
  4833. // med_type = "11"
  4834. // }
  4835. //}
  4836. var api string
  4837. if miConfig.MdtrtareaAdmvs == "320921" {
  4838. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4839. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4840. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4841. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4842. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4843. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4844. "&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
  4845. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4846. } else {
  4847. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4848. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4849. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4850. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4852. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4853. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4854. "&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
  4855. }
  4856. resp, requestErr := http.Get(api)
  4857. if requestErr != nil {
  4858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4859. return
  4860. }
  4861. body, ioErr := ioutil.ReadAll(resp.Body)
  4862. if ioErr != nil {
  4863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4865. return
  4866. }
  4867. var respJSON map[string]interface{}
  4868. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4871. return
  4872. }
  4873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4874. result, _ := json.Marshal(respJSON)
  4875. fmt.Println("log")
  4876. fmt.Println(string(result))
  4877. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4878. utils.ErrorLog("解析失败:%v", err)
  4879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4880. return
  4881. }
  4882. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4883. res.Output = resSeven10265.Output
  4884. res.ErrMsg = resSeven10265.ErrMsg
  4885. res.Cainfo = resSeven10265.Cainfo
  4886. res.WarnMsg = resSeven10265.WarnMsg
  4887. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4888. res.Infcode = infocode
  4889. } else {
  4890. var src_resquest string
  4891. if miConfig.Code == "H15049901371" {
  4892. //赤峰地区国家医保医疗类别
  4893. //职工透析:医疗类别选特殊情况门诊990502
  4894. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4895. var med_type string
  4896. if his.Insutype == "390" {
  4897. if reg_type == 14 {
  4898. med_type = "9933"
  4899. } else if reg_type == 11 {
  4900. med_type = "11"
  4901. }
  4902. } else if his.Insutype == "310" {
  4903. if reg_type == 14 {
  4904. med_type = "990502"
  4905. } else if reg_type == 11 {
  4906. med_type = "11"
  4907. }
  4908. }
  4909. 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)
  4910. } else {
  4911. 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)
  4912. }
  4913. var dat map[string]interface{}
  4914. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4915. fmt.Println(dat)
  4916. } else {
  4917. fmt.Println(err)
  4918. }
  4919. saveLog(result2, src_resquest, "2207", "结算")
  4920. userJSONBytes, _ := json.Marshal(dat)
  4921. if miConfig.Code == "H15049901371" {
  4922. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4923. utils.ErrorLog("解析失败:%v", err)
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4925. return
  4926. }
  4927. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4928. res.Output = resSeven10265.Output
  4929. res.ErrMsg = resSeven10265.ErrMsg
  4930. res.Cainfo = resSeven10265.Cainfo
  4931. res.WarnMsg = resSeven10265.WarnMsg
  4932. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4933. res.Infcode = infocode
  4934. } else {
  4935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4936. utils.ErrorLog("解析失败:%v", err)
  4937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4938. return
  4939. }
  4940. }
  4941. }
  4942. if res.Infcode != 0 {
  4943. errlog := &models.HisOrderError{
  4944. UserOrgId: adminUser.CurrentOrgId,
  4945. Ctime: time.Now().Unix(),
  4946. Mtime: time.Now().Unix(),
  4947. Number: chrg_bchno,
  4948. ErrMsg: res.ErrMsg,
  4949. Status: 1,
  4950. PatientId: id,
  4951. RecordTime: recordDateTime,
  4952. Stage: 6,
  4953. }
  4954. service.CreateErrMsgLog(errlog)
  4955. c.ServeSuccessJSON(map[string]interface{}{
  4956. "failed_code": -10,
  4957. "msg": res.ErrMsg,
  4958. })
  4959. return
  4960. } else {
  4961. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4962. order.OrderStatus = 2
  4963. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4964. order.SetlId = res.Output.Setlinfo.SetlID
  4965. order.PsnNo = res.Output.Setlinfo.PsnNo
  4966. order.PsnName = res.Output.Setlinfo.PsnName
  4967. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4968. order.Certno = res.Output.Setlinfo.Certno
  4969. order.Gend = res.Output.Setlinfo.Gend
  4970. order.Naty = res.Output.Setlinfo.Naty
  4971. order.Age = res.Output.Setlinfo.Age
  4972. order.Insutype = res.Output.Setlinfo.Insutype
  4973. order.PsnType = res.Output.Setlinfo.PsnType
  4974. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4975. order.SetlTime = res.Output.Setlinfo.SetlTime
  4976. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4977. //order.MedType = res.Output.Setlinfo.MedType
  4978. if reg_type == 1112 {
  4979. order.MedType = "1112"
  4980. }
  4981. if reg_type == 1111 {
  4982. order.MedType = "1111"
  4983. }
  4984. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4985. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4986. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4987. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4988. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4989. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4990. order.HifpPay = res.Output.Setlinfo.HifpPay
  4991. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4992. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4993. order.HifesPay = res.Output.Setlinfo.HifesPay
  4994. order.HifobPay = res.Output.Setlinfo.HifobPay
  4995. order.MafPay = res.Output.Setlinfo.MafPay
  4996. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4997. order.OthPay = res.Output.Setlinfo.OthPay
  4998. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4999. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5000. order.AcctPay = res.Output.Setlinfo.AcctPay
  5001. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5002. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5003. order.Balc = res.Output.Setlinfo.Balc
  5004. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5005. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5006. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5007. order.ClrWay = res.Output.Setlinfo.ClrWay
  5008. order.Creator = order.Creator
  5009. order.Modify = roles.AdminUserId
  5010. order.RequestLog = src_resquest
  5011. order.Diagnosis = diagnosis_id
  5012. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5013. detailStr := string(setlDetail)
  5014. order.SetlDetail = detailStr
  5015. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5016. err = service.UpDateOrder(order)
  5017. if err == nil {
  5018. c.ServeSuccessJSON(map[string]interface{}{
  5019. "msg": "结算成功",
  5020. })
  5021. } else {
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5023. return
  5024. }
  5025. }
  5026. }
  5027. }
  5028. }
  5029. //func (c *HisApiController) GetPreUploadInfo() {
  5030. // id, _ := c.GetInt64("id")
  5031. // record_time := c.GetString("record_time")
  5032. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5033. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5034. //
  5035. // timeLayout := "2006-01-02"
  5036. // loc, _ := time.LoadLocation("Local")
  5037. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5038. // if err != nil {
  5039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5040. // return
  5041. // }
  5042. // recordDateTime := theTime.Unix()
  5043. // adminUser := c.GetAdminUserInfo()
  5044. //
  5045. // var prescriptions []*models.HisPrescription
  5046. //
  5047. // var start_time int64
  5048. // var end_time int64
  5049. //
  5050. // data := make(map[string]interface{})
  5051. // if settle_accounts_type == 1 { //日结
  5052. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5053. // data["pre"] = prescriptions
  5054. //
  5055. // } else { //月结
  5056. // start_time_str := c.GetString("start_time")
  5057. // end_time_str := c.GetString("end_time")
  5058. // timeLayout := "2006-01-02"
  5059. // loc, _ := time.LoadLocation("Local")
  5060. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5061. // if err != nil {
  5062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5063. // return
  5064. // }
  5065. // recordStartTime := theStartTime.Unix()
  5066. // start_time = recordStartTime
  5067. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5068. // if err != nil {
  5069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5070. // return
  5071. // }
  5072. // recordEndTime := theEndTime.Unix()
  5073. // end_time = recordEndTime
  5074. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5075. // data["pre"] = prescriptions
  5076. //
  5077. // }
  5078. //
  5079. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5080. //
  5081. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5082. // timestamp := time.Now().Unix()
  5083. // tempTime := time.Unix(timestamp, 0)
  5084. // timeFormat := tempTime.Format("20060102150405")
  5085. // chrgBchno := rand.Intn(100000) + 10000
  5086. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5087. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5088. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5089. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5090. // strconv.FormatInt(his.PatientId, 10)
  5091. // client := &http.Client{}
  5092. // data["psn_no"] = his.PsnNo
  5093. // data["mdtrt_id"] = his.Number
  5094. // data["chrg_bchno"] = chrg_bchno
  5095. // data["org_name"] = miConfig.OrgName
  5096. // data["doctor"] = roles.UserName
  5097. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5098. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5099. // data["fixmedins_code"] = miConfig.Code
  5100. // data["dept_code"] = department.Number
  5101. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5102. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5103. // data["secret_key"] = miConfig.SecretKey
  5104. // var ids []int64
  5105. //
  5106. // for _, item := range prescriptions {
  5107. // ids = append(ids, item.ID)
  5108. // }
  5109. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5110. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5111. // bytesData, _ := json.Marshal(data)
  5112. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5113. // resp, _ := client.Do(req)
  5114. // defer resp.Body.Close()
  5115. // body, ioErr := ioutil.ReadAll(resp.Body)
  5116. // if ioErr != nil {
  5117. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. // return
  5120. // }
  5121. // var respJSON map[string]interface{}
  5122. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5123. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5125. // return
  5126. // }
  5127. //
  5128. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5129. // userJSONBytes, _ := json.Marshal(respJSON)
  5130. // var res ResultFour
  5131. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5132. // utils.ErrorLog("解析失败:%v", err)
  5133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5134. // return
  5135. // }
  5136. //
  5137. // if res.Infcode == 0 {
  5138. // order := &models.HisOrder{
  5139. // UserOrgId: adminUser.CurrentOrgId,
  5140. // HisPatientId: his.ID,
  5141. // PatientId: his.PatientId,
  5142. // SettleAccountsDate: recordDateTime,
  5143. // Ctime: time.Now().Unix(),
  5144. // Mtime: time.Now().Unix(),
  5145. // Status: 1,
  5146. // Number: chrg_bchno,
  5147. // Infcode: res.Infcode,
  5148. // WarnMsg: res.WarnMsg,
  5149. // Cainfo: res.Cainfo,
  5150. // ErrMsg: res.ErrMsg,
  5151. // RespondTime: res.RefmsgTime,
  5152. // InfRefmsgid: res.InfRefmsgid,
  5153. // OrderStatus: 1,
  5154. // IsMedicineInsurance: 1,
  5155. // SettleType: settle_accounts_type,
  5156. // SettleStartTime: start_time,
  5157. // SettleEndTime: end_time,
  5158. // Creator: roles.ID,
  5159. // Modify: roles.ID,
  5160. // PType: 2,
  5161. // }
  5162. // err = service.CreateOrder(order)
  5163. // if err != nil {
  5164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5165. // return
  5166. // }
  5167. //
  5168. // for _, item := range res.Output.Result {
  5169. // temp := strings.Split(item.FeedetlSn, "-")
  5170. // var advice_id int64 = 0
  5171. // var project_id int64 = 0
  5172. // var types int64 = 0
  5173. //
  5174. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5175. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5176. //
  5177. // if temp[1] == "1" {
  5178. // advice_id = id
  5179. // project_id = 0
  5180. // } else if temp[1] == "2" {
  5181. // advice_id = 0
  5182. // project_id = id
  5183. // }
  5184. //
  5185. // info := &models.HisOrderInfo{
  5186. // OrderNumber: order.Number,
  5187. // FeedetlSn: item.FeedetlSn,
  5188. // UploadDate: time.Now().Unix(),
  5189. // AdviceId: advice_id,
  5190. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5191. // Cnt: item.Cnt,
  5192. // Pric: float64(item.Pric),
  5193. // PatientId: his.PatientId,
  5194. // PricUplmtAmt: item.PricUplmtAmt,
  5195. // SelfpayProp: item.SelfpayProp,
  5196. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5197. // OverlmtAmt: item.OverlmtAmt,
  5198. // PreselfpayAmt: item.PreselfpayAmt,
  5199. // BasMednFlag: item.BasMednFlag,
  5200. // MedChrgitmType: item.MedChrgitmType,
  5201. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5202. // Status: 1,
  5203. // Memo: item.Memo,
  5204. // Mtime: time.Now().Unix(),
  5205. // InscpScpAmt: item.InscpScpAmt,
  5206. // DrtReimFlag: item.DrtReimFlag,
  5207. // Ctime: time.Now().Unix(),
  5208. // ListSpItemFlag: item.ListSpItemFlag,
  5209. // ChldMedcFlag: item.ChldMedcFlag,
  5210. // LmtUsedFlag: item.LmtUsedFlag,
  5211. // ChrgitmLv: item.ChrgitmLv,
  5212. // UserOrgId: adminUser.CurrentOrgId,
  5213. // HisPatientId: his.ID,
  5214. // OrderId: order.ID,
  5215. // ProjectId: project_id,
  5216. // Type: types,
  5217. // }
  5218. // service.CreateOrderInfo(info)
  5219. //
  5220. // }
  5221. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5222. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5223. //
  5224. // var total float64
  5225. // for _, item := range prescriptions {
  5226. // if item.Type == 1 { //药品
  5227. // for _, subItem := range item.HisDoctorAdviceInfo {
  5228. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5229. // }
  5230. // }
  5231. // if item.Type == 2 { //项目
  5232. // for _, subItem := range item.HisPrescriptionProject {
  5233. // total = total + (subItem.Price * float64(subItem.Count))
  5234. // }
  5235. // }
  5236. // }
  5237. //
  5238. // for _, item := range prescriptions {
  5239. // for _, subItem := range item.HisAdditionalCharge {
  5240. // total = total + (subItem.Price * float64(subItem.Count))
  5241. // }
  5242. // }
  5243. //
  5244. // allTotal := fmt.Sprintf("%.2f", total)
  5245. // if res.Infcode == 0 {
  5246. // var rf []*ResultFive
  5247. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5248. // psn_no := his.PsnNo
  5249. // mdtrt_id := his.Number
  5250. // chrg_bchno := chrg_bchno
  5251. // cert_no := his.Certno
  5252. // insutype := rf[0].Insutype
  5253. //
  5254. // if his.IdCardType == 1 {
  5255. // cert_no = his.MedicalInsuranceNumber
  5256. //
  5257. // } else {
  5258. //
  5259. // cert_no = his.Certno
  5260. //
  5261. // }
  5262. //
  5263. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5264. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5265. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5266. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5267. // resp, requestErr := http.Get(api)
  5268. // if requestErr != nil {
  5269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. // return
  5271. // }
  5272. // defer resp.Body.Close()
  5273. // body, ioErr := ioutil.ReadAll(resp.Body)
  5274. // if ioErr != nil {
  5275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5277. // return
  5278. // }
  5279. // var respJSON map[string]interface{}
  5280. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5281. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. // return
  5284. // }
  5285. // fmt.Println(respJSON)
  5286. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5287. // userJSONBytes, _ := json.Marshal(respJSON)
  5288. // var res ResultSeven
  5289. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5290. // utils.ErrorLog("解析失败:%v", err)
  5291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5292. // return
  5293. // }
  5294. // if res.Infcode != 0 {
  5295. // errlog := &models.HisOrderError{
  5296. // UserOrgId: adminUser.CurrentOrgId,
  5297. // Ctime: time.Now().Unix(),
  5298. // Mtime: time.Now().Unix(),
  5299. // Number: chrg_bchno,
  5300. // ErrMsg: res.ErrMsg,
  5301. // Status: 1,
  5302. // PatientId: id,
  5303. // RecordTime: recordDateTime,
  5304. // Stage: 7,
  5305. // }
  5306. // service.CreateErrMsgLog(errlog)
  5307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5308. // return
  5309. // } else {
  5310. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5311. // order.OrderStatus = 1
  5312. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5313. // order.SetlId = res.Output.Setlinfo.SetlID
  5314. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5315. // order.PsnName = res.Output.Setlinfo.PsnName
  5316. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5317. // order.Certno = res.Output.Setlinfo.Certno
  5318. // order.Gend = res.Output.Setlinfo.Gend
  5319. // order.Naty = res.Output.Setlinfo.Naty
  5320. // order.Age = res.Output.Setlinfo.Age
  5321. // order.Insutype = res.Output.Setlinfo.Insutype
  5322. // order.PsnType = res.Output.Setlinfo.PsnType
  5323. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5324. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5325. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5326. // order.MedType = res.Output.Setlinfo.MedType
  5327. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5328. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5329. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5330. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5331. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5332. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5333. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5334. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5335. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5336. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5337. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5338. // order.MafPay = res.Output.Setlinfo.MafPay
  5339. // order.OthPay = res.Output.Setlinfo.OthPay
  5340. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5341. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5342. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5343. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5344. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5345. // order.Balc = res.Output.Setlinfo.Balc
  5346. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5347. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5348. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5349. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5350. // order.Creator = order.Creator
  5351. // order.Modify = roles.ID
  5352. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5353. // detailStr := string(setlDetail)
  5354. // order.SetlDetail = detailStr
  5355. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5356. // err = service.UpDateOrder(order)
  5357. // if err == nil {
  5358. // c.ServeSuccessJSON(map[string]interface{}{
  5359. // "msg": "预结算成功",
  5360. // })
  5361. // } else {
  5362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5363. // return
  5364. // }
  5365. // }
  5366. // } else {
  5367. // adminUser := c.GetAdminUserInfo()
  5368. // errlog := &models.HisOrderError{
  5369. // UserOrgId: adminUser.CurrentOrgId,
  5370. // Ctime: time.Now().Unix(),
  5371. // Mtime: time.Now().Unix(),
  5372. // ErrMsg: res.ErrMsg,
  5373. // Status: 1,
  5374. // PatientId: id,
  5375. // RecordTime: recordDateTime,
  5376. // Stage: 4,
  5377. // }
  5378. // service.CreateErrMsgLog(errlog)
  5379. //
  5380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5381. // return
  5382. // }
  5383. // } else {
  5384. // adminUser := c.GetAdminUserInfo()
  5385. // errlog := &models.HisOrderError{
  5386. // UserOrgId: adminUser.CurrentOrgId,
  5387. // Ctime: time.Now().Unix(),
  5388. // Mtime: time.Now().Unix(),
  5389. // ErrMsg: res.ErrMsg,
  5390. // Status: 1,
  5391. // PatientId: id,
  5392. // RecordTime: recordDateTime,
  5393. // Stage: 4,
  5394. // }
  5395. // service.CreateErrMsgLog(errlog)
  5396. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5397. // return
  5398. // }
  5399. //
  5400. // } else {
  5401. // var total float64
  5402. // for _, item := range prescriptions {
  5403. // if item.Type == 1 { //药品
  5404. // for _, subItem := range item.HisDoctorAdviceInfo {
  5405. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5406. // }
  5407. // }
  5408. // if item.Type == 2 { //项目
  5409. // for _, subItem := range item.HisPrescriptionProject {
  5410. // total = total + (subItem.Price * float64(subItem.Count))
  5411. // }
  5412. // }
  5413. //
  5414. // for _, subItem := range item.HisAdditionalCharge {
  5415. // total = total + (subItem.Price * float64(subItem.Count))
  5416. // }
  5417. // }
  5418. //
  5419. // allTotal := fmt.Sprintf("%.2f", total)
  5420. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5421. // order := &models.HisOrder{
  5422. // UserOrgId: adminUser.CurrentOrgId,
  5423. // HisPatientId: his.ID,
  5424. // PatientId: id,
  5425. // SettleAccountsDate: recordDateTime,
  5426. // Ctime: time.Now().Unix(),
  5427. // Mtime: time.Now().Unix(),
  5428. // Status: 1,
  5429. // OrderStatus: 2,
  5430. // Number: chrg_bchno,
  5431. // MedfeeSumamt: totals,
  5432. // }
  5433. // err = service.CreateOrder(order)
  5434. // if err != nil {
  5435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5436. // return
  5437. // }
  5438. //
  5439. // var customs []*Custom
  5440. // for _, item := range prescriptions {
  5441. //
  5442. // if item.Type == 1 { //药品
  5443. // for _, subItem := range item.HisDoctorAdviceInfo {
  5444. // cus := &Custom{
  5445. // AdviceId: subItem.ID,
  5446. // ProjectId: 0,
  5447. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5448. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5449. // FeedetlSn: subItem.FeedetlSn,
  5450. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5451. // MedListCodg: subItem.MedListCodg,
  5452. // Type: 1,
  5453. // }
  5454. // customs = append(customs, cus)
  5455. // }
  5456. // }
  5457. //
  5458. // if item.Type == 2 { //项目
  5459. // for _, subItem := range item.HisPrescriptionProject {
  5460. //
  5461. // cus := &Custom{
  5462. // AdviceId: 0,
  5463. // ProjectId: subItem.ID,
  5464. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5465. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5466. // FeedetlSn: subItem.FeedetlSn,
  5467. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5468. // MedListCodg: subItem.MedListCodg,
  5469. // Type: 2,
  5470. // }
  5471. //
  5472. // customs = append(customs, cus)
  5473. // }
  5474. // }
  5475. //
  5476. // for _, item := range item.HisAdditionalCharge {
  5477. // cus := &Custom{
  5478. // ItemId: item.ID,
  5479. // AdviceId: 0,
  5480. // ProjectId: 0,
  5481. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5482. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5483. // FeedetlSn: item.FeedetlSn,
  5484. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5485. // MedListCodg: item.XtHisAddtionConfig.Code,
  5486. // Type: 3,
  5487. // }
  5488. //
  5489. // customs = append(customs, cus)
  5490. // }
  5491. //
  5492. // }
  5493. //
  5494. // for _, item := range customs {
  5495. // var advice_id int64 = 0
  5496. // var project_id int64 = 0
  5497. // var item_id int64 = 0
  5498. //
  5499. // var types int64 = 0
  5500. //
  5501. // if item.Type == 1 {
  5502. // advice_id = item.AdviceId
  5503. // project_id = 0
  5504. // item_id = 0
  5505. // } else if item.Type == 2 {
  5506. // advice_id = 0
  5507. // item_id = 0
  5508. //
  5509. // project_id = item.ProjectId
  5510. // } else if item.Type == 3 {
  5511. // advice_id = 0
  5512. // item_id = item.ItemId
  5513. // project_id = 0
  5514. // }
  5515. //
  5516. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5517. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5518. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5519. //
  5520. // info := &models.HisOrderInfo{
  5521. // OrderNumber: order.Number,
  5522. // UploadDate: time.Now().Unix(),
  5523. // AdviceId: advice_id,
  5524. // DetItemFeeSumamt: detItemFeeSumamt,
  5525. // Cnt: cut,
  5526. // Pric: pric,
  5527. // PatientId: id,
  5528. // Status: 1,
  5529. // Mtime: time.Now().Unix(),
  5530. // Ctime: time.Now().Unix(),
  5531. // UserOrgId: adminUser.CurrentOrgId,
  5532. // HisPatientId: his.ID,
  5533. // OrderId: order.ID,
  5534. // ProjectId: project_id,
  5535. // Type: types,
  5536. // ItemId: item_id,
  5537. // }
  5538. // service.CreateOrderInfo(info)
  5539. // }
  5540. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5541. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5542. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5543. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5544. // if err == nil {
  5545. // c.ServeSuccessJSON(map[string]interface{}{
  5546. // "msg": "结算成功",
  5547. // })
  5548. // } else {
  5549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5550. // return
  5551. // }
  5552. // }
  5553. //}
  5554. //上传明细-预结算-
  5555. func (c *HisApiController) GetPreUploadInfo() {
  5556. id, _ := c.GetInt64("id")
  5557. record_time := c.GetString("record_time")
  5558. his_patient_id, _ := c.GetInt64("his_patient_id")
  5559. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5560. admin_user_id, _ := c.GetInt64("admin_user_id")
  5561. diagnosis_id := c.GetString("diagnosis")
  5562. sick_type, _ := c.GetInt64("sick_type")
  5563. reg_type, _ := c.GetInt64("p_type")
  5564. begin_time := c.GetString("begin_time")
  5565. id_str := c.GetString("ids")
  5566. ids_arr := strings.Split(id_str, ",")
  5567. timeLayout := "2006-01-02"
  5568. loc, _ := time.LoadLocation("Local")
  5569. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5570. if err != nil {
  5571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5572. return
  5573. }
  5574. recordDateTime := theTime.Unix()
  5575. adminUser := c.GetAdminUserInfo()
  5576. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5577. var config []*models.HisXtDiagnoseConfig
  5578. for _, item := range diagnosis_ids {
  5579. id, _ := strconv.ParseInt(item, 10, 64)
  5580. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5581. config = append(config, &diagnosisConfig)
  5582. }
  5583. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5584. sickConfig, _ := service.FindSickById(sick_type)
  5585. var prescriptions []*models.HisPrescription
  5586. var start_time int64
  5587. var end_time int64
  5588. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5589. fmt.Println(his_patient_id)
  5590. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5591. timestamp := time.Now().Unix()
  5592. tempTime := time.Unix(timestamp, 0)
  5593. timeFormat := tempTime.Format("20060102150405")
  5594. chrgBchno := rand.Intn(100000) + 10000
  5595. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5596. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5597. var patientPrescription models.HisPrescriptionInfo
  5598. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5599. if patientPrescription.ID == 0 {
  5600. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5601. }
  5602. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5603. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5604. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5605. strconv.FormatInt(his.PatientId, 10)
  5606. var res2 ResultSix
  5607. var resSix10265 ResultSix10265
  5608. var time_stamp string
  5609. if miConfig.MdtrtareaAdmvs == "421300" {
  5610. data := make(map[string]interface{})
  5611. client := &http.Client{}
  5612. data["psn_no"] = his.PsnNo
  5613. data["mdtrt_id"] = his.Number
  5614. data["doctor"] = roles.UserName
  5615. data["department"] = department.Name
  5616. data["org_name"] = miConfig.OrgName
  5617. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5618. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5619. data["fixmedins_code"] = miConfig.Code
  5620. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5621. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5622. data["secret_key"] = miConfig.SecretKey
  5623. data["sick_code"] = sickConfig.CountryCode
  5624. data["sick_name"] = sickConfig.ClassName
  5625. data["begin_time"] = begin_time
  5626. data["dept"] = strconv.FormatInt(department.ID, 10)
  5627. data["config"] = config
  5628. fmt.Println(data)
  5629. bytesData, _ := json.Marshal(data)
  5630. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5631. resp, _ := client.Do(req)
  5632. defer resp.Body.Close()
  5633. body, ioErr := ioutil.ReadAll(resp.Body)
  5634. if ioErr != nil {
  5635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5637. return
  5638. }
  5639. var respJSON map[string]interface{}
  5640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5643. return
  5644. }
  5645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5646. userJSONBytes, _ := json.Marshal(respJSON)
  5647. fmt.Println("log")
  5648. fmt.Println(string(userJSONBytes))
  5649. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5650. utils.ErrorLog("解析失败:%v", err)
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5652. return
  5653. }
  5654. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5655. //江苏地区国家医保医疗类别
  5656. //职工透析:医疗类别选特殊情况门诊9933
  5657. //居民血透门慢: 医疗类别选门诊慢病1402
  5658. //var med_type string
  5659. //if his.Insutype == "310" {
  5660. // if reg_type == 14 {
  5661. // med_type = "9933"
  5662. // } else if reg_type == 11 {
  5663. // med_type = "11"
  5664. //
  5665. // }
  5666. //} else if his.Insutype == "390" {
  5667. // if reg_type == 14 {
  5668. // med_type = "1402"
  5669. // } else if reg_type == 11 {
  5670. // med_type = "11"
  5671. // }
  5672. //}
  5673. data := make(map[string]interface{})
  5674. client := &http.Client{}
  5675. data["psn_no"] = his.PsnNo
  5676. data["mdtrt_id"] = his.Number
  5677. data["doctor"] = roles.UserName
  5678. data["department"] = department.Name
  5679. data["org_name"] = miConfig.OrgName
  5680. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5681. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5682. data["fixmedins_code"] = miConfig.Code
  5683. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5684. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5685. data["secret_key"] = miConfig.SecretKey
  5686. data["sick_code"] = sickConfig.CountryCode
  5687. data["sick_name"] = sickConfig.ClassName
  5688. data["begin_time"] = begin_time
  5689. data["dept"] = strconv.FormatInt(department.ID, 10)
  5690. data["config"] = config
  5691. data["url"] = miConfig.Url
  5692. data["ak"] = miConfig.AccessKey
  5693. data["cainfo"] = miConfig.Cainfo
  5694. bytesData, _ := json.Marshal(data)
  5695. var req *http.Request
  5696. if miConfig.MdtrtareaAdmvs == "320921" {
  5697. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5698. //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 +
  5699. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5700. } else {
  5701. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5702. }
  5703. resp, _ := client.Do(req)
  5704. defer resp.Body.Close()
  5705. body, ioErr := ioutil.ReadAll(resp.Body)
  5706. if ioErr != nil {
  5707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5709. return
  5710. }
  5711. var respJSON map[string]interface{}
  5712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5715. return
  5716. }
  5717. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5718. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5719. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5721. userJSONBytes, _ := json.Marshal(respJSON)
  5722. fmt.Println("log")
  5723. fmt.Println(string(userJSONBytes))
  5724. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5725. utils.ErrorLog("解析失败:%v", err)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5730. res2.Output = resSix10265.Output
  5731. res2.ErrMsg = resSix10265.ErrMsg
  5732. res2.Cainfo = resSix10265.Cainfo
  5733. res2.WarnMsg = resSix10265.WarnMsg
  5734. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5735. res2.Infcode = infocode
  5736. } else {
  5737. var result string
  5738. var requestLog string
  5739. if miConfig.MdtrtareaAdmvs == "440781" { //
  5740. 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)
  5741. } else {
  5742. if miConfig.Code == "H15049901371" {
  5743. //赤峰地区国家医保医疗类别
  5744. //职工透析:医疗类别选特殊情况门诊990502
  5745. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5746. var med_type string
  5747. if his.Insutype == "390" {
  5748. if reg_type == 14 {
  5749. med_type = "9933"
  5750. } else if reg_type == 11 {
  5751. med_type = "11"
  5752. }
  5753. } else if his.Insutype == "310" {
  5754. if reg_type == 14 {
  5755. med_type = "990502"
  5756. } else if reg_type == 11 {
  5757. med_type = "11"
  5758. }
  5759. }
  5760. 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)
  5761. } else {
  5762. 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)
  5763. }
  5764. saveLog(result, requestLog, "2203", "上传就诊信息")
  5765. var respJSON2 map[string]interface{}
  5766. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5769. return
  5770. }
  5771. userJSONBytes2, _ := json.Marshal(respJSON2)
  5772. if miConfig.Code == "H15049901371" {
  5773. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5774. utils.ErrorLog("解析失败:%v", err)
  5775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5776. return
  5777. }
  5778. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5779. res2.Output = resSix10265.Output
  5780. res2.ErrMsg = resSix10265.ErrMsg
  5781. res2.Cainfo = resSix10265.Cainfo
  5782. res2.WarnMsg = resSix10265.WarnMsg
  5783. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5784. res2.Infcode = infocode
  5785. } else {
  5786. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5787. utils.ErrorLog("解析失败:%v", err)
  5788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5789. return
  5790. }
  5791. }
  5792. }
  5793. }
  5794. if res2.Infcode != 0 {
  5795. adminUser := c.GetAdminUserInfo()
  5796. errlog := &models.HisOrderError{
  5797. UserOrgId: adminUser.CurrentOrgId,
  5798. Ctime: time.Now().Unix(),
  5799. Mtime: time.Now().Unix(),
  5800. ErrMsg: res2.ErrMsg,
  5801. Status: 1,
  5802. PatientId: id,
  5803. RecordTime: recordDateTime,
  5804. Stage: 3,
  5805. }
  5806. service.CreateErrMsgLog(errlog)
  5807. c.ServeSuccessJSON(map[string]interface{}{
  5808. "failed_code": -10,
  5809. "msg": res2.ErrMsg,
  5810. })
  5811. return
  5812. } else {
  5813. his.Diagnosis = diagnosis_id
  5814. his.SickType = sickConfig.ID
  5815. his.PType = fmt.Sprintf("%d", reg_type)
  5816. service.UpdateHisPatientThree(&his)
  5817. data := make(map[string]interface{})
  5818. if settle_accounts_type == 1 { //日结
  5819. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5820. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5821. } else {
  5822. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5823. }
  5824. data["pre"] = prescriptions
  5825. } else { //月结
  5826. start_time_str := c.GetString("start_time")
  5827. end_time_str := c.GetString("end_time")
  5828. timeLayout := "2006-01-02"
  5829. loc, _ := time.LoadLocation("Local")
  5830. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5831. if err != nil {
  5832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5833. return
  5834. }
  5835. recordStartTime := theStartTime.Unix()
  5836. start_time = recordStartTime
  5837. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5838. if err != nil {
  5839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5840. return
  5841. }
  5842. recordEndTime := theEndTime.Unix()
  5843. end_time = recordEndTime
  5844. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5845. data["pre"] = prescriptions
  5846. }
  5847. client := &http.Client{}
  5848. data["psn_no"] = his.PsnNo
  5849. data["mdtrt_id"] = his.Number
  5850. data["chrg_bchno"] = chrg_bchno
  5851. data["org_name"] = miConfig.OrgName
  5852. data["doctor"] = roles.UserName
  5853. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5854. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5855. data["fixmedins_code"] = miConfig.Code
  5856. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5857. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5858. data["dept_code"] = "15"
  5859. } else {
  5860. data["dept_code"] = department.Number
  5861. }
  5862. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5863. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5864. data["secret_key"] = miConfig.SecretKey
  5865. data["url"] = miConfig.Url
  5866. data["ak"] = miConfig.AccessKey
  5867. data["new_doctor_name"] = patientPrescription.Doctor
  5868. data["diag_code"] = sickConfig.CountryCode
  5869. data["time_stamp"] = time_stamp
  5870. data["cainfo"] = miConfig.Cainfo
  5871. var ids []int64
  5872. for _, item := range prescriptions {
  5873. ids = append(ids, item.ID)
  5874. }
  5875. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5876. if config.IsOpen == 1 { //对接了医保,走医保流程
  5877. var res ResultFour
  5878. var resFour10265 ResultFour10265
  5879. if miConfig.MdtrtareaAdmvs == "421300" {
  5880. bytesData, _ := json.Marshal(data)
  5881. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5882. resp, _ := client.Do(req)
  5883. defer resp.Body.Close()
  5884. body, ioErr := ioutil.ReadAll(resp.Body)
  5885. if ioErr != nil {
  5886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5888. return
  5889. }
  5890. var respJSON map[string]interface{}
  5891. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5894. return
  5895. }
  5896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5897. userJSONBytes, _ := json.Marshal(respJSON)
  5898. fmt.Println("log")
  5899. fmt.Println(string(userJSONBytes))
  5900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5901. utils.ErrorLog("解析失败:%v", err)
  5902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5903. return
  5904. }
  5905. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5906. bytesData, _ := json.Marshal(data)
  5907. var req *http.Request
  5908. if miConfig.MdtrtareaAdmvs == "320921" {
  5909. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5910. } else {
  5911. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5912. }
  5913. resp, _ := client.Do(req)
  5914. defer resp.Body.Close()
  5915. body, ioErr := ioutil.ReadAll(resp.Body)
  5916. if ioErr != nil {
  5917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5919. return
  5920. }
  5921. var respJSON map[string]interface{}
  5922. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5925. return
  5926. }
  5927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5928. userJSONBytes, _ := json.Marshal(respJSON)
  5929. fmt.Println("log")
  5930. fmt.Println(string(userJSONBytes))
  5931. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. res.InfRefmsgid = resFour10265.InfRefmsgid
  5937. res.Output = resFour10265.Output
  5938. res.ErrMsg = resFour10265.ErrMsg
  5939. res.Cainfo = resFour10265.Cainfo
  5940. res.WarnMsg = resFour10265.WarnMsg
  5941. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5942. res.Infcode = infocode
  5943. } else {
  5944. if miConfig.Code == "H15049901371" {
  5945. 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)
  5946. var dat map[string]interface{}
  5947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5948. fmt.Println(dat)
  5949. } else {
  5950. fmt.Println(err)
  5951. }
  5952. saveLog(result, request_log, "2204", "上传费用明细")
  5953. userJSONBytes, _ := json.Marshal(dat)
  5954. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5955. utils.ErrorLog("解析失败:%v", err)
  5956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5957. return
  5958. }
  5959. res.InfRefmsgid = resFour10265.InfRefmsgid
  5960. res.Output = resFour10265.Output
  5961. res.ErrMsg = resFour10265.ErrMsg
  5962. res.Cainfo = resFour10265.Cainfo
  5963. res.WarnMsg = resFour10265.WarnMsg
  5964. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5965. res.Infcode = infocode
  5966. } else {
  5967. 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)
  5968. var dat map[string]interface{}
  5969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5970. fmt.Println(dat)
  5971. } else {
  5972. fmt.Println(err)
  5973. }
  5974. saveLog(result, request_log, "2204", "上传费用明细")
  5975. userJSONBytes, _ := json.Marshal(dat)
  5976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5977. utils.ErrorLog("解析失败:%v", err)
  5978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5979. return
  5980. }
  5981. }
  5982. }
  5983. if res.Infcode == 0 {
  5984. order := &models.HisOrder{
  5985. UserOrgId: adminUser.CurrentOrgId,
  5986. HisPatientId: his.ID,
  5987. PatientId: his.PatientId,
  5988. SettleAccountsDate: recordDateTime,
  5989. Ctime: time.Now().Unix(),
  5990. Mtime: time.Now().Unix(),
  5991. MdtrtId: his.Number,
  5992. PsnNo: his.PsnNo,
  5993. MedType: strconv.FormatInt(reg_type, 10),
  5994. Status: 1,
  5995. Number: chrg_bchno,
  5996. Infcode: res.Infcode,
  5997. WarnMsg: res.WarnMsg,
  5998. Cainfo: res.Cainfo,
  5999. ErrMsg: res.ErrMsg,
  6000. RespondTime: res.RefmsgTime,
  6001. InfRefmsgid: res.InfRefmsgid,
  6002. OrderStatus: 1,
  6003. IsMedicineInsurance: 1,
  6004. SettleType: settle_accounts_type,
  6005. SettleStartTime: start_time,
  6006. SettleEndTime: end_time,
  6007. Creator: roles.AdminUserId,
  6008. Modify: roles.AdminUserId,
  6009. PType: 2,
  6010. Diagnosis: diagnosis_id,
  6011. }
  6012. err = service.CreateOrder(order)
  6013. if err != nil {
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6015. return
  6016. }
  6017. for _, item := range res.Output.Result {
  6018. temp := strings.Split(item.FeedetlSn, "-")
  6019. var advice_id int64 = 0
  6020. var project_id int64 = 0
  6021. var types int64 = 0
  6022. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6023. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6024. if temp[1] == "1" {
  6025. advice_id = id
  6026. project_id = 0
  6027. } else if temp[1] == "2" {
  6028. advice_id = 0
  6029. project_id = id
  6030. }
  6031. info := &models.HisOrderInfo{
  6032. OrderNumber: order.Number,
  6033. FeedetlSn: item.FeedetlSn,
  6034. UploadDate: time.Now().Unix(),
  6035. AdviceId: advice_id,
  6036. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6037. Cnt: item.Cnt,
  6038. Pric: float64(item.Pric),
  6039. PatientId: his.PatientId,
  6040. PricUplmtAmt: item.PricUplmtAmt,
  6041. SelfpayProp: item.SelfpayProp,
  6042. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6043. OverlmtAmt: item.OverlmtAmt,
  6044. PreselfpayAmt: item.PreselfpayAmt,
  6045. BasMednFlag: item.BasMednFlag,
  6046. MedChrgitmType: item.MedChrgitmType,
  6047. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6048. Status: 1,
  6049. Memo: item.Memo,
  6050. Mtime: time.Now().Unix(),
  6051. InscpScpAmt: item.InscpScpAmt,
  6052. DrtReimFlag: item.DrtReimFlag,
  6053. Ctime: time.Now().Unix(),
  6054. ListSpItemFlag: item.ListSpItemFlag,
  6055. ChldMedcFlag: item.ChldMedcFlag,
  6056. LmtUsedFlag: item.LmtUsedFlag,
  6057. ChrgitmLv: item.ChrgitmLv,
  6058. UserOrgId: adminUser.CurrentOrgId,
  6059. HisPatientId: his.ID,
  6060. OrderId: order.ID,
  6061. ProjectId: project_id,
  6062. Type: types,
  6063. }
  6064. service.CreateOrderInfo(info)
  6065. }
  6066. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6067. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6068. var total float64
  6069. for _, item := range prescriptions {
  6070. if item.Type == 1 { //药品
  6071. for _, subItem := range item.HisDoctorAdviceInfo {
  6072. total = total + (subItem.Price * subItem.PrescribingNumber)
  6073. }
  6074. }
  6075. if item.Type == 2 { //项目
  6076. for _, subItem := range item.HisPrescriptionProject {
  6077. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6078. total = total + (subItem.Price * cnt)
  6079. }
  6080. }
  6081. }
  6082. for _, item := range prescriptions {
  6083. for _, subItem := range item.HisAdditionalCharge {
  6084. total = total + (subItem.Price * float64(subItem.Count))
  6085. }
  6086. }
  6087. allTotal := fmt.Sprintf("%.4f", total)
  6088. if res.Infcode == 0 {
  6089. var rf []*ResultFive
  6090. json.Unmarshal([]byte(his.Iinfo), &rf)
  6091. chrg_bchno := chrg_bchno
  6092. cert_no := his.Certno
  6093. var insutypes []string
  6094. var insutype string
  6095. var is390 int = 0
  6096. var is310 int = 0
  6097. for _, item := range rf {
  6098. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6099. insutypes = append(insutypes, item.Insutype)
  6100. }
  6101. }
  6102. if len(insutypes) == 1 {
  6103. insutype = insutypes[0]
  6104. } else {
  6105. for _, i := range insutypes {
  6106. if i == "390" {
  6107. is390 = 1
  6108. }
  6109. if i == "310" {
  6110. is310 = 1
  6111. }
  6112. }
  6113. }
  6114. if is390 == 1 {
  6115. insutype = "390"
  6116. }
  6117. if is310 == 1 {
  6118. insutype = "310"
  6119. }
  6120. if len(insutypes) == 0 {
  6121. insutype = "310"
  6122. }
  6123. if len(insutypes) == 2 {
  6124. insutype = strconv.FormatInt(his.SocialType, 64)
  6125. }
  6126. //insutype = "390"
  6127. if his.IdCardType == 1 {
  6128. cert_no = his.MedicalInsuranceNumber
  6129. } else {
  6130. cert_no = his.Certno
  6131. }
  6132. var res ResultSeven
  6133. var resSeven10265 ResultSeven10265
  6134. if miConfig.MdtrtareaAdmvs == "421300" {
  6135. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6141. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6142. resp, requestErr := http.Get(api)
  6143. if requestErr != nil {
  6144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6145. return
  6146. }
  6147. body, ioErr := ioutil.ReadAll(resp.Body)
  6148. if ioErr != nil {
  6149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6151. return
  6152. }
  6153. var respJSON map[string]interface{}
  6154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6160. result, _ := json.Marshal(respJSON)
  6161. fmt.Println("log")
  6162. fmt.Println(string(result))
  6163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6164. utils.ErrorLog("解析失败:%v", err)
  6165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6166. return
  6167. }
  6168. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6169. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6170. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6171. bas := strings.Split(psn_info.CardInfo, "|")
  6172. if his.IdCardType == 1 {
  6173. cert_no = bas[2]
  6174. } else {
  6175. cert_no = bas[1]
  6176. }
  6177. //江苏地区国家医保医疗类别
  6178. //职工透析:医疗类别选特殊情况门诊9933
  6179. //居民血透门慢: 医疗类别选门诊慢病1402
  6180. //var med_type string
  6181. //if his.Insutype == "310" {
  6182. // if reg_type == 14 {
  6183. // med_type = "9933"
  6184. // } else if reg_type == 11 {
  6185. // med_type = "11"
  6186. //
  6187. // }
  6188. //} else if his.Insutype == "390" {
  6189. // if reg_type == 14 {
  6190. // med_type = "1402"
  6191. // } else if reg_type == 11 {
  6192. // med_type = "11"
  6193. // }
  6194. //}
  6195. var api string
  6196. if miConfig.MdtrtareaAdmvs == "320921" {
  6197. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6198. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6199. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6200. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6201. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6202. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6203. "&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
  6204. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6205. } else {
  6206. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6207. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6208. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6209. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6210. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6211. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6212. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6213. "&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
  6214. }
  6215. resp, requestErr := http.Get(api)
  6216. if requestErr != nil {
  6217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6218. return
  6219. }
  6220. body, ioErr := ioutil.ReadAll(resp.Body)
  6221. if ioErr != nil {
  6222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6224. return
  6225. }
  6226. var respJSON map[string]interface{}
  6227. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6230. return
  6231. }
  6232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6233. result, _ := json.Marshal(respJSON)
  6234. fmt.Println("log")
  6235. fmt.Println(string(result))
  6236. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6237. utils.ErrorLog("解析失败:%v", err)
  6238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6239. return
  6240. }
  6241. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6242. res.Output = resSeven10265.Output
  6243. res.ErrMsg = resSeven10265.ErrMsg
  6244. res.Cainfo = resSeven10265.Cainfo
  6245. res.WarnMsg = resSeven10265.WarnMsg
  6246. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6247. res.Infcode = infocode
  6248. } else {
  6249. var result string
  6250. var request_log string
  6251. if miConfig.Code == "H15049901371" {
  6252. //赤峰地区国家医保医疗类别
  6253. //职工透析:医疗类别选特殊情况门诊990502
  6254. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6255. var med_type string
  6256. if his.Insutype == "390" {
  6257. if reg_type == 14 {
  6258. med_type = "9933"
  6259. } else if reg_type == 11 {
  6260. med_type = "11"
  6261. }
  6262. } else if his.Insutype == "310" {
  6263. if reg_type == 14 {
  6264. med_type = "990502"
  6265. } else if reg_type == 11 {
  6266. med_type = "11"
  6267. }
  6268. }
  6269. 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)
  6270. } else {
  6271. 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)
  6272. }
  6273. var dat map[string]interface{}
  6274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6275. fmt.Println(dat)
  6276. } else {
  6277. fmt.Println(err)
  6278. }
  6279. saveLog(result, request_log, "2206", "预结算")
  6280. //userJSONBytes, _ := json.Marshal(dat)
  6281. //
  6282. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6283. // utils.ErrorLog("解析失败:%v", err)
  6284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6285. // return
  6286. //}
  6287. userJSONBytes, _ := json.Marshal(dat)
  6288. if miConfig.Code == "H15049901371" {
  6289. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6290. utils.ErrorLog("解析失败:%v", err)
  6291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6292. return
  6293. }
  6294. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6295. res.Output = resSeven10265.Output
  6296. res.ErrMsg = resSeven10265.ErrMsg
  6297. res.Cainfo = resSeven10265.Cainfo
  6298. res.WarnMsg = resSeven10265.WarnMsg
  6299. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6300. res.Infcode = infocode
  6301. } else {
  6302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6303. utils.ErrorLog("解析失败:%v", err)
  6304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6305. return
  6306. }
  6307. }
  6308. }
  6309. if res.Infcode != 0 {
  6310. errlog := &models.HisOrderError{
  6311. UserOrgId: adminUser.CurrentOrgId,
  6312. Ctime: time.Now().Unix(),
  6313. Mtime: time.Now().Unix(),
  6314. Number: chrg_bchno,
  6315. ErrMsg: res.ErrMsg,
  6316. Status: 1,
  6317. PatientId: id,
  6318. RecordTime: recordDateTime,
  6319. Stage: 20,
  6320. }
  6321. service.CreateErrMsgLog(errlog)
  6322. c.ServeSuccessJSON(map[string]interface{}{
  6323. "failed_code": -10,
  6324. "msg": res.ErrMsg,
  6325. })
  6326. return
  6327. } else {
  6328. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6329. order.OrderStatus = 1
  6330. order.IsPre = 1
  6331. order.Status = 1
  6332. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6333. order.SetlId = res.Output.Setlinfo.SetlID
  6334. order.PsnNo = res.Output.Setlinfo.PsnNo
  6335. order.PsnName = res.Output.Setlinfo.PsnName
  6336. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6337. order.Certno = res.Output.Setlinfo.Certno
  6338. order.Gend = res.Output.Setlinfo.Gend
  6339. order.Naty = res.Output.Setlinfo.Naty
  6340. order.Age = res.Output.Setlinfo.Age
  6341. order.Insutype = res.Output.Setlinfo.Insutype
  6342. order.PsnType = res.Output.Setlinfo.PsnType
  6343. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6344. order.SetlTime = res.Output.Setlinfo.SetlTime
  6345. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6346. if res.Output.Setlinfo.MedType == "140101" {
  6347. order.MedType = "14"
  6348. } else {
  6349. order.MedType = res.Output.Setlinfo.MedType
  6350. }
  6351. if reg_type == 1112 {
  6352. order.MedType = "1112"
  6353. }
  6354. if reg_type == 1111 {
  6355. order.MedType = "1111"
  6356. }
  6357. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6358. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6359. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6360. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6361. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6362. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6363. order.HifpPay = res.Output.Setlinfo.HifpPay
  6364. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6365. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6366. order.HifesPay = res.Output.Setlinfo.HifesPay
  6367. order.HifobPay = res.Output.Setlinfo.HifobPay
  6368. order.MafPay = res.Output.Setlinfo.MafPay
  6369. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6370. order.OthPay = res.Output.Setlinfo.OthPay
  6371. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6372. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6373. order.AcctPay = res.Output.Setlinfo.AcctPay
  6374. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6375. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6376. order.Balc = res.Output.Setlinfo.Balc
  6377. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6378. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6379. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6380. order.ClrWay = res.Output.Setlinfo.ClrWay
  6381. order.Creator = order.Creator
  6382. order.Modify = roles.AdminUserId
  6383. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6384. detailStr := string(setlDetail)
  6385. order.SetlDetail = detailStr
  6386. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6387. err = service.UpDateOrder(order)
  6388. if err == nil {
  6389. c.ServeSuccessJSON(map[string]interface{}{
  6390. "msg": "预结算成功",
  6391. })
  6392. } else {
  6393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6394. return
  6395. }
  6396. }
  6397. } else {
  6398. adminUser := c.GetAdminUserInfo()
  6399. errlog := &models.HisOrderError{
  6400. UserOrgId: adminUser.CurrentOrgId,
  6401. Ctime: time.Now().Unix(),
  6402. Mtime: time.Now().Unix(),
  6403. ErrMsg: res.ErrMsg,
  6404. Status: 1,
  6405. PatientId: id,
  6406. RecordTime: recordDateTime,
  6407. Stage: 4,
  6408. }
  6409. service.CreateErrMsgLog(errlog)
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6411. return
  6412. }
  6413. } else {
  6414. adminUser := c.GetAdminUserInfo()
  6415. errlog := &models.HisOrderError{
  6416. UserOrgId: adminUser.CurrentOrgId,
  6417. Ctime: time.Now().Unix(),
  6418. Mtime: time.Now().Unix(),
  6419. ErrMsg: res.ErrMsg,
  6420. Status: 1,
  6421. PatientId: id,
  6422. RecordTime: recordDateTime,
  6423. Stage: 4,
  6424. }
  6425. service.CreateErrMsgLog(errlog)
  6426. c.ServeSuccessJSON(map[string]interface{}{
  6427. "failed_code": -10,
  6428. "msg": res.ErrMsg,
  6429. })
  6430. return
  6431. }
  6432. }
  6433. }
  6434. }
  6435. //func (c *HisApiController) GetSettleInfo() {
  6436. // id, _ := c.GetInt64("id")
  6437. // order_id, _ := c.GetInt64("order_id")
  6438. //
  6439. // record_time := c.GetString("record_time")
  6440. // pay_way, _ := c.GetInt64("pay_way")
  6441. // pay_price, _ := c.GetFloat("pay_price")
  6442. // pay_card_no := c.GetString("pay_card_no")
  6443. // discount_price, _ := c.GetFloat("discount_price")
  6444. // preferential_price, _ := c.GetFloat("preferential_price")
  6445. // reality_price, _ := c.GetFloat("reality_price")
  6446. // found_price, _ := c.GetFloat("found_price")
  6447. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6448. // private_price, _ := c.GetFloat("private_price")
  6449. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6450. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6451. //
  6452. // timeLayout := "2006-01-02"
  6453. // loc, _ := time.LoadLocation("Local")
  6454. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6455. // if err != nil {
  6456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6457. // return
  6458. // }
  6459. // recordDateTime := theTime.Unix()
  6460. // adminUser := c.GetAdminUserInfo()
  6461. //
  6462. // var prescriptions []*models.HisPrescription
  6463. //
  6464. // data := make(map[string]interface{})
  6465. // if settle_accounts_type == 1 { //日结
  6466. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6467. // data["pre"] = prescriptions
  6468. //
  6469. // } else { //月结
  6470. // start_time_str := c.GetString("start_time")
  6471. // end_time_str := c.GetString("end_time")
  6472. // timeLayout := "2006-01-02"
  6473. // loc, _ := time.LoadLocation("Local")
  6474. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6475. // if err != nil {
  6476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6477. // return
  6478. // }
  6479. // recordStartTime := theStartTime.Unix()
  6480. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6481. // if err != nil {
  6482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6483. // return
  6484. // }
  6485. // recordEndTime := theEndTime.Unix()
  6486. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6487. // data["pre"] = prescriptions
  6488. //
  6489. // }
  6490. //
  6491. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6492. //
  6493. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6494. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6495. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6496. // strconv.FormatInt(his.PatientId, 10)
  6497. //
  6498. // order_src, _ := service.GetHisOrderByID(order_id)
  6499. //
  6500. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6501. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6502. //
  6503. // var total float64
  6504. // for _, item := range prescriptions {
  6505. // if item.Type == 1 { //药品
  6506. // for _, subItem := range item.HisDoctorAdviceInfo {
  6507. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6508. // }
  6509. // }
  6510. // if item.Type == 2 { //项目
  6511. // for _, subItem := range item.HisPrescriptionProject {
  6512. // total = total + (subItem.Price * float64(subItem.Count))
  6513. // }
  6514. // }
  6515. // }
  6516. //
  6517. // for _, item := range prescriptions {
  6518. // for _, subItem := range item.HisAdditionalCharge {
  6519. // total = total + (subItem.Price * float64(subItem.Count))
  6520. // }
  6521. // }
  6522. //
  6523. // allTotal := fmt.Sprintf("%.2f", total)
  6524. // var rf []*ResultFive
  6525. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6526. // psn_no := order_src.PsnNo
  6527. // mdtrt_id := order_src.MdtrtId
  6528. // chrg_bchno := order_src.Number
  6529. // cert_no := order_src.Certno
  6530. // insutype := rf[0].Insutype
  6531. //
  6532. // if his.IdCardType == 1 {
  6533. // cert_no = his.MedicalInsuranceNumber
  6534. // } else {
  6535. // cert_no = his.Certno
  6536. // }
  6537. //
  6538. // 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)
  6539. // var dat map[string]interface{}
  6540. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6541. // fmt.Println(dat)
  6542. // } else {
  6543. // fmt.Println(err)
  6544. // }
  6545. //
  6546. // userJSONBytes, _ := json.Marshal(dat)
  6547. //
  6548. //
  6549. //
  6550. // var res ResultSeven
  6551. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6552. // utils.ErrorLog("解析失败:%v", err)
  6553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. // return
  6555. // }
  6556. // if res.Infcode == -1 {
  6557. // errlog := &models.HisOrderError{
  6558. // UserOrgId: adminUser.CurrentOrgId,
  6559. // Ctime: time.Now().Unix(),
  6560. // Mtime: time.Now().Unix(),
  6561. // Number: chrg_bchno,
  6562. // ErrMsg: res.ErrMsg,
  6563. // Status: 1,
  6564. // PatientId: id,
  6565. // RecordTime: recordDateTime,
  6566. // Stage: 6,
  6567. // }
  6568. // service.CreateErrMsgLog(errlog)
  6569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6570. // return
  6571. // } else {
  6572. // order_src.OrderStatus = 2
  6573. // order_src.PayWay = pay_way
  6574. // order_src.PayPrice = pay_price
  6575. // order_src.PayCardNo = pay_card_no
  6576. // order_src.DiscountPrice = discount_price
  6577. // order_src.PreferentialPrice = preferential_price
  6578. // order_src.RealityPrice = reality_price
  6579. // order_src.FoundPrice = found_price
  6580. // order_src.MedicalInsurancePrice = medical_insurance_price
  6581. // order_src.PrivatePrice = private_price
  6582. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6583. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6584. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6585. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6586. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6587. // order_src.Certno = res.Output.Setlinfo.Certno
  6588. // order_src.Gend = res.Output.Setlinfo.Gend
  6589. // order_src.Naty = res.Output.Setlinfo.Naty
  6590. // order_src.Age = res.Output.Setlinfo.Age
  6591. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6592. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6593. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6594. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6595. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6596. // order_src.MedType = res.Output.Setlinfo.MedType
  6597. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6598. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6599. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6600. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6601. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6602. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6603. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6604. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6605. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6606. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6607. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6608. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6609. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6610. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6611. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6612. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6613. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6614. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6615. // order_src.Balc = res.Output.Setlinfo.Balc
  6616. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6617. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6618. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6619. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6620. // order_src.Creator = order_src.Creator
  6621. // order_src.Modify = roles.ID
  6622. // order_src.RequestLog = src_resquest
  6623. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6624. // detailStr := string(setlDetail)
  6625. // order_src.SetlDetail = detailStr
  6626. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6627. // err = service.UpDateOrder(order_src)
  6628. //
  6629. // if err == nil {
  6630. // c.ServeSuccessJSON(map[string]interface{}{
  6631. // "msg": "结算成功",
  6632. // })
  6633. // } else {
  6634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6635. // return
  6636. // }
  6637. // }
  6638. // }
  6639. //}
  6640. //退款
  6641. func (c *HisApiController) Refund() {
  6642. order_id, _ := c.GetInt64("order_id")
  6643. admin_user_id, _ := c.GetInt64("admin_user_id")
  6644. adminUser := c.GetAdminUserInfo()
  6645. var order models.HisOrder
  6646. order, _ = service.GetHisOrderByID(order_id)
  6647. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6648. if order.ID == 0 {
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6650. return
  6651. }
  6652. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6653. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6654. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6655. if config.IsOpen == 1 { //对接了医保,走医保流程
  6656. var res ResultSixteen
  6657. var resSixteen10265 ResultSixteen10265
  6658. var src_resquest string
  6659. var result string
  6660. if miConfig.MdtrtareaAdmvs == "421300" {
  6661. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6662. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6663. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6664. resp3, requestErr3 := http.Get(api3)
  6665. if requestErr3 != nil {
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6667. return
  6668. }
  6669. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6670. if ioErr3 != nil {
  6671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. return
  6674. }
  6675. var respJSON3 map[string]interface{}
  6676. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6682. userJSONBytes3, _ := json.Marshal(respJSON3)
  6683. fmt.Println("log")
  6684. fmt.Println(string(userJSONBytes3))
  6685. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6686. utils.ErrorLog("解析失败:%v", err)
  6687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6688. return
  6689. }
  6690. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6691. var api3 string
  6692. if miConfig.MdtrtareaAdmvs == "320921" {
  6693. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6694. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6695. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6696. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6697. } else {
  6698. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6699. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6700. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6701. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6702. }
  6703. resp3, requestErr3 := http.Get(api3)
  6704. if requestErr3 != nil {
  6705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6706. return
  6707. }
  6708. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6709. if ioErr3 != nil {
  6710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6712. return
  6713. }
  6714. var respJSON3 map[string]interface{}
  6715. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. return
  6719. }
  6720. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6721. userJSONBytes3, _ := json.Marshal(respJSON3)
  6722. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6723. utils.ErrorLog("解析失败:%v", err)
  6724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6725. return
  6726. }
  6727. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6728. res.Output = resSixteen10265.Output
  6729. res.ErrMsg = resSixteen10265.ErrMsg
  6730. res.Cainfo = resSixteen10265.Cainfo
  6731. res.WarnMsg = resSixteen10265.WarnMsg
  6732. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6733. res.Infcode = infocode
  6734. } else {
  6735. if miConfig.Code == "H15049901371" {
  6736. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6737. var dat map[string]interface{}
  6738. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6739. fmt.Println(dat)
  6740. } else {
  6741. fmt.Println(err)
  6742. }
  6743. saveLog(result, src_resquest, "2208", "退费")
  6744. userJSONBytes, _ := json.Marshal(dat)
  6745. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6746. utils.ErrorLog("解析失败:%v", err)
  6747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6748. return
  6749. }
  6750. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6751. res.Output = resSixteen10265.Output
  6752. res.ErrMsg = resSixteen10265.ErrMsg
  6753. res.Cainfo = resSixteen10265.Cainfo
  6754. res.WarnMsg = resSixteen10265.WarnMsg
  6755. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6756. res.Infcode = infocode
  6757. } else {
  6758. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6759. var dat map[string]interface{}
  6760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6761. fmt.Println(dat)
  6762. } else {
  6763. fmt.Println(err)
  6764. }
  6765. saveLog(result, src_resquest, "2208", "退费")
  6766. userJSONBytes, _ := json.Marshal(dat)
  6767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6768. utils.ErrorLog("解析失败:%v", err)
  6769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6770. return
  6771. }
  6772. }
  6773. }
  6774. if res.Infcode == 0 {
  6775. var res2 ResultSix
  6776. var resSix10265 ResultSix10265
  6777. if miConfig.MdtrtareaAdmvs == "421300" {
  6778. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6779. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6781. resp3, requestErr3 := http.Get(api3)
  6782. if requestErr3 != nil {
  6783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6784. return
  6785. }
  6786. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6787. if ioErr3 != nil {
  6788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6790. return
  6791. }
  6792. var respJSON3 map[string]interface{}
  6793. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6796. return
  6797. }
  6798. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6799. userJSONBytes3, _ := json.Marshal(respJSON3)
  6800. fmt.Println("log")
  6801. fmt.Println(string(userJSONBytes3))
  6802. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6803. utils.ErrorLog("解析失败:%v", err)
  6804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6805. return
  6806. }
  6807. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6808. var api3 string
  6809. if miConfig.MdtrtareaAdmvs == "320921" {
  6810. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6811. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6812. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6813. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6814. } else {
  6815. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6816. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6817. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6818. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6819. }
  6820. resp3, requestErr3 := http.Get(api3)
  6821. if requestErr3 != nil {
  6822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6823. return
  6824. }
  6825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6826. if ioErr3 != nil {
  6827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6829. return
  6830. }
  6831. var respJSON3 map[string]interface{}
  6832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6835. return
  6836. }
  6837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6838. userJSONBytes3, _ := json.Marshal(respJSON3)
  6839. fmt.Println("log")
  6840. fmt.Println(string(userJSONBytes3))
  6841. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6842. utils.ErrorLog("解析失败:%v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. return
  6845. }
  6846. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6847. res2.Output = resSix10265.Output
  6848. res2.ErrMsg = resSix10265.ErrMsg
  6849. res2.Cainfo = resSix10265.Cainfo
  6850. res2.WarnMsg = resSix10265.WarnMsg
  6851. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6852. res2.Infcode = infocode
  6853. } else {
  6854. if miConfig.Code == "H15049901371" {
  6855. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6856. var dat map[string]interface{}
  6857. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6858. fmt.Println(dat)
  6859. } else {
  6860. fmt.Println(err)
  6861. }
  6862. saveLog(result2, src_request, "2205", "撤销明细")
  6863. userJSONBytes, _ := json.Marshal(dat)
  6864. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6865. utils.ErrorLog("解析失败:%v", err)
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6867. return
  6868. }
  6869. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6870. res2.Output = resSix10265.Output
  6871. res2.ErrMsg = resSix10265.ErrMsg
  6872. res2.Cainfo = resSix10265.Cainfo
  6873. res2.WarnMsg = resSix10265.WarnMsg
  6874. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6875. res2.Infcode = infocode
  6876. } else {
  6877. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6878. var dat map[string]interface{}
  6879. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6880. fmt.Println(dat)
  6881. } else {
  6882. fmt.Println(err)
  6883. }
  6884. saveLog(result2, src_request, "2205", "撤销明细")
  6885. userJSONBytes, _ := json.Marshal(dat)
  6886. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6887. utils.ErrorLog("解析失败:%v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. }
  6892. }
  6893. if res2.Infcode == 0 {
  6894. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6895. if err == nil {
  6896. c.ServeSuccessJSON(map[string]interface{}{
  6897. "msg": "退费成功",
  6898. })
  6899. } else {
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. } else {
  6904. c.ServeSuccessJSON(map[string]interface{}{
  6905. "code": -10,
  6906. "msg": res2.ErrMsg,
  6907. })
  6908. }
  6909. } else {
  6910. c.ServeSuccessJSON(map[string]interface{}{
  6911. "code": -10,
  6912. "msg": res.ErrMsg,
  6913. })
  6914. }
  6915. }
  6916. }
  6917. func (c *HisApiController) RefundNumber() {
  6918. record_time := c.GetString("record_time")
  6919. //patient_id, _ := c.GetInt64("patient_id")
  6920. admin_user_id, _ := c.GetInt64("admin_user_id")
  6921. his_patient_id, _ := c.GetInt64("id")
  6922. timeLayout := "2006-01-02"
  6923. loc, _ := time.LoadLocation("Local")
  6924. adminUser := c.GetAdminUserInfo()
  6925. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6926. fmt.Println(err)
  6927. if err != nil {
  6928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6929. return
  6930. }
  6931. recordDateTime := theTime.Unix()
  6932. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6933. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6934. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6935. //order, _ := service.GetHisOrderByID(order_id)
  6936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6937. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6938. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6939. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6940. if count > 0 {
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6942. return
  6943. }
  6944. if config.IsOpen == 1 { //对接了医保,走医保流程
  6945. var res2 ResultSix
  6946. var resSix10265 ResultSix10265
  6947. if miConfig.MdtrtareaAdmvs == "421300" {
  6948. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6949. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6950. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6951. resp3, requestErr3 := http.Get(api3)
  6952. if requestErr3 != nil {
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6957. if ioErr3 != nil {
  6958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6960. return
  6961. }
  6962. var respJSON3 map[string]interface{}
  6963. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. return
  6967. }
  6968. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6969. userJSONBytes3, _ := json.Marshal(respJSON3)
  6970. fmt.Println("log")
  6971. fmt.Println(string(userJSONBytes3))
  6972. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6973. utils.ErrorLog("解析失败:%v", err)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. return
  6976. }
  6977. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6978. var api3 string
  6979. if miConfig.MdtrtareaAdmvs == "320921" {
  6980. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6981. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6983. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6984. } else {
  6985. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6986. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6987. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6988. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6989. }
  6990. resp3, requestErr3 := http.Get(api3)
  6991. if requestErr3 != nil {
  6992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6993. return
  6994. }
  6995. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6996. if ioErr3 != nil {
  6997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. var respJSON3 map[string]interface{}
  7002. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7008. userJSONBytes3, _ := json.Marshal(respJSON3)
  7009. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7010. utils.ErrorLog("解析失败:%v", err)
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7012. return
  7013. }
  7014. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7015. res2.Output = resSix10265.Output
  7016. res2.ErrMsg = resSix10265.ErrMsg
  7017. res2.Cainfo = resSix10265.Cainfo
  7018. res2.WarnMsg = resSix10265.WarnMsg
  7019. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7020. res2.Infcode = infocode
  7021. } else {
  7022. var api3 string
  7023. if miConfig.Code == "H15049901371" {
  7024. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7025. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7026. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7027. } else {
  7028. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7029. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7030. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7031. }
  7032. resp3, requestErr3 := http.Get(api3)
  7033. if requestErr3 != nil {
  7034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7035. return
  7036. }
  7037. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7038. if ioErr3 != nil {
  7039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. var respJSON3 map[string]interface{}
  7044. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7050. userJSONBytes3, _ := json.Marshal(respJSON3)
  7051. if miConfig.Code == "H15049901371" {
  7052. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7053. utils.ErrorLog("解析失败:%v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. return
  7056. }
  7057. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7058. res2.Output = resSix10265.Output
  7059. res2.ErrMsg = resSix10265.ErrMsg
  7060. res2.Cainfo = resSix10265.Cainfo
  7061. res2.WarnMsg = resSix10265.WarnMsg
  7062. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7063. res2.Infcode = infocode
  7064. } else {
  7065. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. }
  7071. }
  7072. if res2.Infcode == 0 {
  7073. if err == nil {
  7074. c.ServeSuccessJSON(map[string]interface{}{
  7075. "msg": "退号成功",
  7076. })
  7077. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7078. } else {
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. return
  7081. }
  7082. } else {
  7083. c.ServeSuccessJSON(map[string]interface{}{
  7084. "code": -10,
  7085. "msg": res2.ErrMsg,
  7086. })
  7087. }
  7088. } else {
  7089. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7090. //if err == nil {
  7091. // c.ServeSuccessJSON(map[string]interface{}{
  7092. // "msg": "退费成功",
  7093. // })
  7094. //} else {
  7095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. // return
  7097. //}
  7098. }
  7099. }
  7100. func (c *HisApiController) RefundDetail() {
  7101. order_id, _ := c.GetInt64("order_id")
  7102. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7103. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7104. number := c.GetString("number")
  7105. record_time := c.GetString("record_time")
  7106. patient_id, _ := c.GetInt64("patient_id")
  7107. //med_type, _ := c.GetInt64("med_type")
  7108. timeLayout := "2006-01-02"
  7109. loc, _ := time.LoadLocation("Local")
  7110. adminUser := c.GetAdminUserInfo()
  7111. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7112. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7113. fmt.Println(err)
  7114. if err != nil {
  7115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7116. return
  7117. }
  7118. recordDateTime := theTime.Unix()
  7119. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7120. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7121. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7122. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7123. var order models.HisOrder
  7124. order, _ = service.GetHisOrderByID(order_id)
  7125. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7126. if config.IsOpen == 1 { //对接了医保,走医保流程
  7127. var res2 ResultSix
  7128. if miConfig.MdtrtareaAdmvs == "421300" {
  7129. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7130. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7131. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7132. resp3, requestErr3 := http.Get(api3)
  7133. if requestErr3 != nil {
  7134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7135. return
  7136. }
  7137. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7138. if ioErr3 != nil {
  7139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7141. return
  7142. }
  7143. var respJSON3 map[string]interface{}
  7144. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. return
  7148. }
  7149. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7150. userJSONBytes3, _ := json.Marshal(respJSON3)
  7151. fmt.Println("log")
  7152. fmt.Println(string(userJSONBytes3))
  7153. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7154. utils.ErrorLog("解析失败:%v", err)
  7155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7156. return
  7157. }
  7158. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7159. if err == nil {
  7160. c.ServeSuccessJSON(map[string]interface{}{
  7161. "msg": "撤销明细成功",
  7162. })
  7163. return
  7164. } else {
  7165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7166. return
  7167. }
  7168. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7169. var resSix10265 ResultSix10265
  7170. var api3 string
  7171. if miConfig.MdtrtareaAdmvs == "320921" {
  7172. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7173. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7174. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7175. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7176. } else {
  7177. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7178. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7179. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7180. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7181. }
  7182. resp3, requestErr3 := http.Get(api3)
  7183. if requestErr3 != nil {
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7188. if ioErr3 != nil {
  7189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. var respJSON3 map[string]interface{}
  7194. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7200. userJSONBytes3, _ := json.Marshal(respJSON3)
  7201. fmt.Println("log")
  7202. fmt.Println(string(userJSONBytes3))
  7203. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7204. utils.ErrorLog("解析失败:%v", err)
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7209. res2.Output = resSix10265.Output
  7210. res2.ErrMsg = resSix10265.ErrMsg
  7211. res2.Cainfo = resSix10265.Cainfo
  7212. res2.WarnMsg = resSix10265.WarnMsg
  7213. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7214. res2.Infcode = infocode
  7215. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7216. if err == nil {
  7217. c.ServeSuccessJSON(map[string]interface{}{
  7218. "msg": "撤销明细成功",
  7219. })
  7220. return
  7221. } else {
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. return
  7224. }
  7225. } else {
  7226. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7227. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7228. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7229. resp2, requestErr2 := http.Get(api2)
  7230. if requestErr2 != nil {
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7232. return
  7233. }
  7234. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7235. if ioErr2 != nil {
  7236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7238. return
  7239. }
  7240. var respJSON2 map[string]interface{}
  7241. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7244. return
  7245. }
  7246. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7247. if err == nil {
  7248. c.ServeSuccessJSON(map[string]interface{}{
  7249. "msg": "撤销明细成功",
  7250. })
  7251. return
  7252. } else {
  7253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7254. return
  7255. }
  7256. }
  7257. } else {
  7258. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7259. if err == nil {
  7260. c.ServeSuccessJSON(map[string]interface{}{
  7261. "msg": "退费成功",
  7262. })
  7263. } else {
  7264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7265. return
  7266. }
  7267. }
  7268. }
  7269. //对账
  7270. func (c *HisApiController) GetCheckAccount() {
  7271. start_time := c.GetString("start_time")
  7272. end_time := c.GetString("end_time")
  7273. insutype := c.GetString("insutype")
  7274. clr_type := c.GetString("clr_type")
  7275. clr_org := c.GetString("clr_optins")
  7276. admin_user_id, _ := c.GetInt64("admin_user_id")
  7277. adminUser := c.GetAdminUserInfo()
  7278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7279. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7280. if len(clr_org) == 0 {
  7281. clr_org = miConfig.MdtrtareaAdmvs
  7282. }
  7283. timeLayout := "2006-01-02"
  7284. loc, _ := time.LoadLocation("Local")
  7285. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7286. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7287. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7288. fixmedins_setl_cnt := int64(len(orders))
  7289. var medfee_sumamt float64
  7290. var acct_pay float64
  7291. var fund_pay_sumamt float64
  7292. for _, item := range orders {
  7293. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7294. acct_pay = acct_pay + item.AcctPay
  7295. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7296. }
  7297. var user_name string
  7298. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7299. if role.ID == 0 {
  7300. user_name = "xxx"
  7301. } else {
  7302. user_name = role.UserName
  7303. }
  7304. var res ResultEight
  7305. var res10188 ResultEightFor10188
  7306. if config.IsOpen == 1 {
  7307. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7308. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7309. "insutype=" + insutype +
  7310. "&clr_type=" + "11" +
  7311. "&setl_optins=" + clr_org +
  7312. "&stmt_begndate=" + start_time +
  7313. "&stm_enddate=" + end_time +
  7314. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7315. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7316. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7317. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7318. "&fixmedins_code=" + miConfig.Code +
  7319. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7320. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7321. "&secret_key=" + miConfig.SecretKey +
  7322. "&org_name=" + miConfig.OrgName +
  7323. "&doctor=" + user_name +
  7324. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7325. fmt.Println(api)
  7326. resp, requestErr := http.Get(api)
  7327. if requestErr != nil {
  7328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7329. return
  7330. }
  7331. body, ioErr := ioutil.ReadAll(resp.Body)
  7332. fmt.Println(body)
  7333. if ioErr != nil {
  7334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7336. return
  7337. }
  7338. var respJSON map[string]interface{}
  7339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7342. return
  7343. }
  7344. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7345. userJSONBytes, _ := json.Marshal(respJSON)
  7346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7347. utils.ErrorLog("解析失败:%v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. res.InfRefmsgid = res10188.InfRefmsgid
  7352. res.Output = res10188.Output
  7353. res.ErrMsg = res10188.ErrMsg
  7354. res.Cainfo = res10188.Cainfo
  7355. res.WarnMsg = res10188.WarnMsg
  7356. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7357. res.Infcode = infocode
  7358. } else {
  7359. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7360. "insutype=" + insutype +
  7361. "&clr_type=" + clr_type +
  7362. "&setl_optins=" + clr_org +
  7363. "&stmt_begndate=" + start_time +
  7364. "&stm_enddate=" + end_time +
  7365. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7366. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7367. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7368. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7369. "&fixmedins_code=" + miConfig.Code +
  7370. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7371. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7372. "&secret_key=" + miConfig.SecretKey +
  7373. "&org_name=" + miConfig.OrgName +
  7374. "&doctor=" + user_name
  7375. fmt.Println(api)
  7376. resp, requestErr := http.Get(api)
  7377. if requestErr != nil {
  7378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7379. return
  7380. }
  7381. body, ioErr := ioutil.ReadAll(resp.Body)
  7382. fmt.Println(body)
  7383. if ioErr != nil {
  7384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. return
  7387. }
  7388. var respJSON map[string]interface{}
  7389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7395. userJSONBytes, _ := json.Marshal(respJSON)
  7396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7397. utils.ErrorLog("解析失败:%v", err)
  7398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7399. return
  7400. }
  7401. }
  7402. if res.Infcode == 0 {
  7403. if res.Output.Stmtinfo.StmtRslt == "0" {
  7404. micc := &models.MedicalInsuranceCostCompare{
  7405. StartTime: startime.Unix(),
  7406. EndTime: endtime.Unix(),
  7407. Insutype: insutype,
  7408. CheckType: 1,
  7409. Num: fixmedins_setl_cnt,
  7410. Mtime: time.Now().Unix(),
  7411. Status: 1,
  7412. UserOrgId: adminUser.CurrentOrgId,
  7413. CostTotal: medfee_sumamt,
  7414. FuncTotal: fund_pay_sumamt,
  7415. PsnPay: acct_pay,
  7416. Creator: admin_user_id,
  7417. Ctime: time.Now().Unix(),
  7418. ClrType: clr_type,
  7419. }
  7420. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7421. if err == nil {
  7422. c.ServeSuccessJSON(map[string]interface{}{
  7423. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7424. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7425. })
  7426. } else {
  7427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7428. }
  7429. } else {
  7430. c.ServeSuccessJSON(map[string]interface{}{
  7431. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7432. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7433. })
  7434. }
  7435. } else {
  7436. c.ServeSuccessJSON(map[string]interface{}{
  7437. "code": -10,
  7438. "msg": res.ErrMsg,
  7439. })
  7440. }
  7441. }
  7442. }
  7443. func (c *HisApiController) Check310() {
  7444. adminUser := c.GetAdminUserInfo()
  7445. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7446. var user_name string
  7447. user_name = "高慧裕"
  7448. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7449. "insutype=" + "310" +
  7450. "&clr_type=" + "" +
  7451. "&setl_optins=" + "441202" +
  7452. "&stmt_begndate=" + "2022-03-01" +
  7453. "&stm_enddate=" + "2022-03-31" +
  7454. "&medfee_sumamt=" + "194930.12" +
  7455. "&fund_pay_sumamt=" + "188741.46" +
  7456. "&acct_pay=" + "0" +
  7457. "&fixmedins_setl_cnt=" + "452" +
  7458. "&fixmedins_code=" + miConfig.Code +
  7459. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7460. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7461. "&secret_key=" + miConfig.SecretKey +
  7462. "&org_name=" + miConfig.OrgName +
  7463. "&doctor=" + user_name
  7464. fmt.Println(api)
  7465. resp, requestErr := http.Get(api)
  7466. if requestErr != nil {
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. body, ioErr := ioutil.ReadAll(resp.Body)
  7471. fmt.Println(body)
  7472. if ioErr != nil {
  7473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. var respJSON map[string]interface{}
  7478. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7481. return
  7482. }
  7483. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7484. userJSONBytes, _ := json.Marshal(respJSON)
  7485. var res ResultEight
  7486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7487. utils.ErrorLog("解析失败:%v", err)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. return
  7490. }
  7491. }
  7492. func (c *HisApiController) Check390() {
  7493. adminUser := c.GetAdminUserInfo()
  7494. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7495. var user_name string
  7496. user_name = "高慧裕"
  7497. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7498. "insutype=" + "390" +
  7499. "&clr_type=" + "" +
  7500. "&setl_optins=" + "441202" +
  7501. "&stmt_begndate=" + "2022-03-01" +
  7502. "&stm_enddate=" + "2022-03-31" +
  7503. "&medfee_sumamt=" + "1068448.89" +
  7504. "&fund_pay_sumamt=" + "1014677.62" +
  7505. "&acct_pay=" + "0" +
  7506. "&fixmedins_setl_cnt=" + "1950" +
  7507. "&fixmedins_code=" + miConfig.Code +
  7508. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7509. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7510. "&secret_key=" + miConfig.SecretKey +
  7511. "&org_name=" + miConfig.OrgName +
  7512. "&doctor=" + user_name
  7513. fmt.Println(api)
  7514. resp, requestErr := http.Get(api)
  7515. if requestErr != nil {
  7516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7517. return
  7518. }
  7519. body, ioErr := ioutil.ReadAll(resp.Body)
  7520. fmt.Println(body)
  7521. if ioErr != nil {
  7522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7524. return
  7525. }
  7526. var respJSON map[string]interface{}
  7527. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. return
  7531. }
  7532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7533. userJSONBytes, _ := json.Marshal(respJSON)
  7534. var res ResultEight
  7535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7536. utils.ErrorLog("解析失败:%v", err)
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. return
  7539. }
  7540. }
  7541. //对账明细
  7542. func (c *HisApiController) GetCheckDetailAccount() {
  7543. start_time := c.GetString("start_time")
  7544. end_time := c.GetString("end_time")
  7545. admin_user_id, _ := c.GetInt64("admin_user_id")
  7546. adminUser := c.GetAdminUserInfo()
  7547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7548. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7549. timeLayout := "2006-01-02"
  7550. loc, _ := time.LoadLocation("Local")
  7551. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7552. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7553. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7554. Mkdir(miConfig.OrgName)
  7555. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7556. file_name := file + ".txt"
  7557. zip_name := file + ".zip"
  7558. zip_path := miConfig.OrgName + "/" + zip_name
  7559. file_path := miConfig.OrgName + "/" + file_name
  7560. decimal.DivisionPrecision = 2
  7561. var medfee_sumamt float64
  7562. var psn_cash_pay float64
  7563. var fund_pay_sumamt float64
  7564. fixmedins_setl_cnt := int64(len(orders))
  7565. for _, item := range orders {
  7566. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7567. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7568. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7569. }
  7570. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7571. defer f.Close()
  7572. if err != nil {
  7573. fmt.Println(err.Error())
  7574. } else {
  7575. for _, item := range orders {
  7576. var refd_setl_flag string
  7577. if item.OrderStatus == 2 {
  7578. refd_setl_flag = "0"
  7579. var str string
  7580. str = item.SetlId + " " +
  7581. item.MdtrtId + " " +
  7582. item.PsnNo + " " +
  7583. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7584. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7585. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7586. _, err = f.Write([]byte(str))
  7587. }
  7588. if item.OrderStatus == 3 {
  7589. var str string
  7590. str = item.SetlId + " " +
  7591. item.MdtrtId + " " +
  7592. item.PsnNo + " " +
  7593. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7594. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7595. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7596. _, err = f.Write([]byte(str))
  7597. var str2 string
  7598. str2 = item.SetlId + " " +
  7599. item.MdtrtId + " " +
  7600. item.PsnNo + " " +
  7601. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7602. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7603. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7604. _, err = f.Write([]byte(str2))
  7605. }
  7606. }
  7607. }
  7608. Zip(file_path, zip_path)
  7609. fmt.Println(ReadFile(zip_path))
  7610. fmt.Println(string(ReadFile(zip_path)))
  7611. if config.IsOpen == 1 {
  7612. var user_name string
  7613. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7614. if role.ID == 0 {
  7615. user_name = "管理员"
  7616. } else {
  7617. user_name = role.UserName
  7618. }
  7619. baseParams := models.BaseParams{
  7620. SecretKey: miConfig.SecretKey,
  7621. FixmedinsCode: miConfig.Code,
  7622. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7623. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7624. OrgName: miConfig.OrgName,
  7625. Doctor: user_name,
  7626. }
  7627. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7628. var dat map[string]interface{}
  7629. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7630. fmt.Println(dat)
  7631. } else {
  7632. fmt.Println(err)
  7633. }
  7634. userJSONBytes, _ := json.Marshal(dat)
  7635. var res ResultNine
  7636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. return
  7640. }
  7641. if res.Infcode == 0 {
  7642. fileNo := res.Output.FileQuryNo
  7643. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7644. "file_qury_no=" + fileNo +
  7645. "&setl_optins=" + "定点医保中心" +
  7646. "&stmt_begndate=" + start_time +
  7647. "&stm_enddate=" + end_time +
  7648. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7649. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7650. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7651. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7652. "&fixmedins_code=" + miConfig.Code +
  7653. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7654. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7655. "&secret_key=" + miConfig.SecretKey +
  7656. "&org_name=" + miConfig.OrgName +
  7657. "&doctor=" + user_name
  7658. resp, requestErr := http.Get(api)
  7659. if requestErr != nil {
  7660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7661. return
  7662. }
  7663. body, ioErr := ioutil.ReadAll(resp.Body)
  7664. if ioErr != nil {
  7665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7667. return
  7668. }
  7669. var respJSON map[string]interface{}
  7670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. return
  7674. }
  7675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7676. userJSONBytes, _ := json.Marshal(respJSON)
  7677. var res ResultTen
  7678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7679. utils.ErrorLog("解析失败:%v", err)
  7680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7681. return
  7682. }
  7683. if res.Infcode == 0 {
  7684. service.Gdyb9102(baseParams, zip_name, fileNo)
  7685. micc := &models.MedicalInsuranceCostCompare{
  7686. StartTime: startime.Unix(),
  7687. EndTime: endtime.Unix(),
  7688. Insutype: "0",
  7689. CheckType: 2,
  7690. Num: fixmedins_setl_cnt,
  7691. Mtime: time.Now().Unix(),
  7692. Status: 1,
  7693. UserOrgId: adminUser.CurrentOrgId,
  7694. CostTotal: medfee_sumamt,
  7695. FuncTotal: fund_pay_sumamt,
  7696. PsnPay: psn_cash_pay,
  7697. Creator: admin_user_id,
  7698. Ctime: time.Now().Unix(),
  7699. }
  7700. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7701. c.ServeSuccessJSON(map[string]interface{}{
  7702. "msg": "明细对账成功",
  7703. })
  7704. }
  7705. } else {
  7706. }
  7707. }
  7708. }
  7709. type CustomOrderInfo struct {
  7710. Name string
  7711. Spec string
  7712. Unit string
  7713. Count float64
  7714. Price float64
  7715. Total float64
  7716. }
  7717. func (c *HisApiController) GetSettleAccounts() {
  7718. //id, _ := c.GetInt64("id")
  7719. //record_time := c.GetString("record_time")
  7720. order_id, _ := c.GetInt64("order_id")
  7721. admin_user_id, _ := c.GetInt64("admin_user_id")
  7722. //timeLayout := "2006-01-02"
  7723. //loc, _ := time.LoadLocation("Local")
  7724. //
  7725. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7726. //if err != nil {
  7727. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7728. // return
  7729. //}
  7730. //recordDateTime := theTime.Unix()
  7731. adminUser := c.GetAdminUserInfo()
  7732. order, _ := service.GetHisOrderByID(order_id)
  7733. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7734. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7735. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7736. orderInfos = append(orderInfos, orderInfos_two...)
  7737. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7738. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7739. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7740. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7741. //var config []*models.HisXtDiagnoseConfig
  7742. var name string
  7743. for _, item := range diagnosis_ids {
  7744. id, _ := strconv.ParseInt(item, 10, 64)
  7745. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7746. if len(name) == 0 {
  7747. name = diagnosisConfig.ClassName
  7748. } else {
  7749. name = name + "," + diagnosisConfig.ClassName
  7750. }
  7751. }
  7752. var bedCostTotal float64 = 0 //床位总费
  7753. var bedCostSelfTotal float64 = 0 //床位自费
  7754. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7755. var operationCostTotal float64 = 0 //手术费
  7756. var operationCostSelfTotal float64 = 0 //手术费
  7757. var operationCostPartSelfTotal float64 = 0 //手术费
  7758. var otherCostTotal float64 = 0 //其他费用
  7759. var otherCostSelfTotal float64 = 0 //其他费用
  7760. var otherCostPartSelfTotal float64 = 0 //其他费用
  7761. var materialCostTotal float64 = 0 //材料费
  7762. var materialCostSelfTotal float64 = 0 //材料费
  7763. var materialCostPartSelfTotal float64 = 0 //材料费
  7764. var westernMedicineCostTotal float64 = 0 //西药费
  7765. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7766. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7767. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7768. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7769. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7770. var checkCostTotal float64 = 0 //检查费
  7771. var checkCostSelfTotal float64 = 0 //检查费
  7772. var checkCostPartSelfTotal float64 = 0 //检查费
  7773. var laboratoryCostTotal float64 = 0 //化验费
  7774. var laboratoryCostSelfTotal float64 = 0 //化验费
  7775. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7776. var treatCostTotal float64 = 0 //治疗费用
  7777. var treatCostSelfTotal float64 = 0 //治疗费用
  7778. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7779. decimal.DivisionPrecision = 2
  7780. for _, item := range orderInfos {
  7781. if item.MedChrgitmType == "01" { //床位费
  7782. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7783. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7784. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7785. }
  7786. if item.MedChrgitmType == "03" { //检查费
  7787. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7788. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7789. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7790. }
  7791. if item.MedChrgitmType == "04" { //化验费
  7792. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7793. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7794. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7795. }
  7796. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7797. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7798. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7799. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7800. }
  7801. if item.MedChrgitmType == "06" { //手术费
  7802. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7803. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7804. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7805. }
  7806. if item.MedChrgitmType == "08" { //材料费
  7807. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7808. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7809. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7810. }
  7811. if item.MedChrgitmType == "09" { //西药费
  7812. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7813. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7814. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7815. }
  7816. if item.MedChrgitmType == "11" { //中成费
  7817. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7818. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7819. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7820. }
  7821. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7822. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7823. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7824. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7825. }
  7826. }
  7827. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7828. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7829. var user_name string
  7830. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7831. if role.ID == 0 {
  7832. user_name = "管理员"
  7833. } else {
  7834. user_name = role.UserName
  7835. }
  7836. baseParams := models.BaseParams{
  7837. SecretKey: miConfig.SecretKey,
  7838. FixmedinsCode: miConfig.Code,
  7839. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7840. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7841. OrgName: miConfig.OrgName,
  7842. Doctor: user_name,
  7843. }
  7844. businessParams := models.BusinessParams{
  7845. PsnNo: order.PsnNo,
  7846. MdtrtId: order.MdtrtId,
  7847. SetlId: order.SetlId,
  7848. }
  7849. var res ResultEleven
  7850. var resEleven10265 ResultEleven10265
  7851. if config.IsOpen == 1 {
  7852. if miConfig.MdtrtareaAdmvs == "421300" {
  7853. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7854. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7855. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7856. resp, requestErr := http.Get(api)
  7857. if requestErr != nil {
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. body, ioErr := ioutil.ReadAll(resp.Body)
  7862. if ioErr != nil {
  7863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7865. return
  7866. }
  7867. var respJSON map[string]interface{}
  7868. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7874. result, _ := json.Marshal(respJSON)
  7875. fmt.Println("log")
  7876. fmt.Println(string(result))
  7877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7878. utils.ErrorLog("解析失败:%v", err)
  7879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7880. return
  7881. }
  7882. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7883. var api string
  7884. if miConfig.MdtrtareaAdmvs == "320921" {
  7885. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7886. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7887. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7888. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7889. } else {
  7890. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7891. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7892. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7894. }
  7895. resp, requestErr := http.Get(api)
  7896. if requestErr != nil {
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. body, ioErr := ioutil.ReadAll(resp.Body)
  7901. if ioErr != nil {
  7902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. var respJSON map[string]interface{}
  7907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7910. return
  7911. }
  7912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7913. result, _ := json.Marshal(respJSON)
  7914. fmt.Println("log")
  7915. fmt.Println(string(result))
  7916. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7917. utils.ErrorLog("解析失败:%v", err)
  7918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7919. return
  7920. }
  7921. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7922. res.Output = resEleven10265.Output
  7923. res.ErrMsg = resEleven10265.ErrMsg
  7924. res.Cainfo = resEleven10265.Cainfo
  7925. res.WarnMsg = resEleven10265.WarnMsg
  7926. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7927. res.Infcode = infocode
  7928. } else {
  7929. //result2 := service.Gdyb1101()
  7930. result2 := service.Gdyb5204(baseParams, businessParams)
  7931. saveLog(result2, "", "5204", "查询")
  7932. result := service.Gdyb5203(baseParams, businessParams)
  7933. var dat map[string]interface{}
  7934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7935. fmt.Println(dat)
  7936. } else {
  7937. fmt.Println(err)
  7938. }
  7939. userJSONBytes, _ := json.Marshal(dat)
  7940. if miConfig.Code == "H15049901371" {
  7941. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7942. utils.ErrorLog("解析失败:%v", err)
  7943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7944. return
  7945. }
  7946. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7947. res.Output = resEleven10265.Output
  7948. res.ErrMsg = resEleven10265.ErrMsg
  7949. res.Cainfo = resEleven10265.Cainfo
  7950. res.WarnMsg = resEleven10265.WarnMsg
  7951. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7952. res.Infcode = infocode
  7953. } else {
  7954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7955. utils.ErrorLog("解析失败:%v", err)
  7956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7957. return
  7958. }
  7959. }
  7960. }
  7961. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7962. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7963. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7964. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7966. var doctor_name string
  7967. if roles.ID == 0 {
  7968. doctor_name = "管理员"
  7969. } else {
  7970. doctor_name = roles.UserName
  7971. }
  7972. yiliao_leibie := ""
  7973. switch order.MedType {
  7974. case "11":
  7975. yiliao_leibie = "普通门诊"
  7976. break
  7977. case "12":
  7978. yiliao_leibie = "门诊挂号"
  7979. break
  7980. case "13":
  7981. yiliao_leibie = "急诊"
  7982. break
  7983. case "14":
  7984. yiliao_leibie = "门诊特殊病"
  7985. break
  7986. case "15":
  7987. yiliao_leibie = "门诊统筹"
  7988. break
  7989. case "16":
  7990. yiliao_leibie = "门诊慢性病"
  7991. break
  7992. case "21":
  7993. yiliao_leibie = "普通住院"
  7994. break
  7995. }
  7996. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7997. if res.Infcode == 0 {
  7998. c.ServeSuccessJSON(map[string]interface{}{
  7999. "diagnosis": name,
  8000. "order_infos": orderInfos,
  8001. "number": order.MdtrtId,
  8002. "date": order.SettleAccountsDate,
  8003. "charge_admin": charge_admin,
  8004. "printor_admin": printor_admin,
  8005. "info": res.Output.Setlinfo,
  8006. "bedCostTotal": bedCostTotal,
  8007. "bedCostSelfTotal": bedCostSelfTotal,
  8008. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8009. "operationCostTotal": operationCostTotal,
  8010. "operationCostSelfTotal": operationCostSelfTotal,
  8011. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8012. "otherCostTotal": otherCostTotal,
  8013. "otherCostSelfTotal": otherCostSelfTotal,
  8014. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8015. "materialCostTotal": materialCostTotal,
  8016. "materialCostSelfTotal": materialCostSelfTotal,
  8017. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8018. "westernMedicineCostTotal": westernMedicineCostTotal,
  8019. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8020. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8021. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8022. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8023. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8024. "checkCostTotal": checkCostTotal,
  8025. "checkCostSelfTotal": checkCostSelfTotal,
  8026. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8027. "laboratoryCostTotal": laboratoryCostTotal,
  8028. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8029. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8030. "treatCostTotal": treatCostTotal,
  8031. "treatCostSelfTotal": treatCostSelfTotal,
  8032. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8033. "doctor_code": adminRole_two.DoctorCode,
  8034. "doctor_name": doctor_name,
  8035. "health_card_no": order.PsnNo,
  8036. "department": departments.Name,
  8037. "yiliao_leibie": yiliao_leibie,
  8038. "after_money": order.AccountPrice,
  8039. "patient": patient,
  8040. "org_name": miConfig.OrgName,
  8041. "org_code": miConfig.Code,
  8042. "order_number": order.Number,
  8043. "his_hospital": his_hospital,
  8044. "his": his,
  8045. //"check_order_info": cus_slice,
  8046. })
  8047. }
  8048. }
  8049. }
  8050. func (c *HisApiController) CheckTreatment() {
  8051. patient_id, _ := c.GetInt64("patient_id")
  8052. id_card_no := c.GetString("id_card_no")
  8053. insutype := c.GetString("insutype")
  8054. med_type := c.GetString("med_type")
  8055. admin_user_id, _ := c.GetInt64("admin_user_id")
  8056. adminUser := c.GetAdminUserInfo()
  8057. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8059. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8060. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8061. if miConfig.MdtrtareaAdmvs == "421300" {
  8062. var res ResultTwo
  8063. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8064. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8065. "&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)
  8066. resp, requestErr := http.Get(api)
  8067. if requestErr != nil {
  8068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. return
  8070. }
  8071. body, ioErr := ioutil.ReadAll(resp.Body)
  8072. if ioErr != nil {
  8073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. var respJSON map[string]interface{}
  8078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8084. result, _ := json.Marshal(respJSON)
  8085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8086. utils.ErrorLog("解析失败:%v", err)
  8087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8088. return
  8089. }
  8090. if res.Infcode == 0 {
  8091. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8092. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8093. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8094. resp, requestErr := http.Get(api)
  8095. if requestErr != nil {
  8096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8097. return
  8098. }
  8099. body, ioErr := ioutil.ReadAll(resp.Body)
  8100. if ioErr != nil {
  8101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. var respJSON map[string]interface{}
  8106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8109. return
  8110. }
  8111. var res Result2001
  8112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8113. result2, _ := json.Marshal(respJSON)
  8114. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8115. utils.ErrorLog("解析失败:%v", err)
  8116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8117. return
  8118. }
  8119. if res.Infcode == 0 {
  8120. c.ServeSuccessJSON(map[string]interface{}{
  8121. "msg": res.Output.Trtinfo,
  8122. })
  8123. }
  8124. } else {
  8125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8126. return
  8127. }
  8128. } else {
  8129. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8130. var dat map[string]interface{}
  8131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8132. fmt.Println(dat)
  8133. } else {
  8134. fmt.Println(err)
  8135. }
  8136. userJSONBytes, _ := json.Marshal(dat)
  8137. var res ResultTwo
  8138. var res10265 ResultTwo10265
  8139. if miConfig.Code == "H15049901371" {
  8140. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8141. utils.ErrorLog("解析失败:%v", err)
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. res.ErrMsg = res10265.ErrMsg
  8146. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8147. res.Infcode = infocode
  8148. res.Output = res10265.Output
  8149. res.InfRefmsgid = res10265.InfRefmsgid
  8150. } else {
  8151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8152. utils.ErrorLog("解析失败:%v", err)
  8153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. return
  8155. }
  8156. }
  8157. var user_name string
  8158. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8159. if role.ID == 0 {
  8160. user_name = "xxx"
  8161. } else {
  8162. user_name = role.UserName
  8163. }
  8164. baseParams := models.BaseParams{
  8165. SecretKey: miConfig.SecretKey,
  8166. FixmedinsCode: miConfig.Code,
  8167. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8168. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8169. OrgName: miConfig.OrgName,
  8170. Doctor: user_name,
  8171. }
  8172. if config.IsOpen == 1 {
  8173. if miConfig.Code == "H15049901371" {
  8174. if med_type == "14" {
  8175. if insutype == "390" {
  8176. med_type = "9933"
  8177. } else if insutype == "310" {
  8178. med_type = "990502"
  8179. }
  8180. } else if med_type == "11" {
  8181. med_type = "11"
  8182. }
  8183. }
  8184. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8185. var dat map[string]interface{}
  8186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8187. fmt.Println(dat)
  8188. } else {
  8189. fmt.Println(err)
  8190. }
  8191. var res Result2001
  8192. var res10265 Result2001Org10265
  8193. if miConfig.Code == "H15049901371" {
  8194. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8195. utils.ErrorLog("解析失败:%v", err)
  8196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. return
  8198. }
  8199. res.ErrMsg = res10265.ErrMsg
  8200. res.Output = res10265.Output
  8201. res.InfRefmsgid = res10265.InfRefmsgid
  8202. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8203. res.Infcode = infocode
  8204. } else {
  8205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8206. utils.ErrorLog("解析失败:%v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. }
  8211. if res.Infcode == 0 {
  8212. c.ServeSuccessJSON(map[string]interface{}{
  8213. "msg": res.Output.Trtinfo,
  8214. })
  8215. }
  8216. }
  8217. }
  8218. }
  8219. //func (c *HisApiController) PutRecord() {
  8220. // id, _ := c.GetInt64("id")
  8221. // record_time := c.GetString("record_time")
  8222. // timeLayout := "2006-01-02"
  8223. // loc, _ := time.LoadLocation("Local")
  8224. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8225. // if err != nil {
  8226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8227. // return
  8228. // }
  8229. // recordDateTime := theTime.Unix()
  8230. //
  8231. // adminInfo := c.GetAdminUserInfo()
  8232. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8233. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8234. //
  8235. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8236. //
  8237. // fmt.Println(miConfig.SecretKey)
  8238. //
  8239. // if patient == nil {
  8240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8241. // return
  8242. // }
  8243. // if len(patient.IdCardNo) == 0 {
  8244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8245. // return
  8246. // }
  8247. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8248. // if config.IsOpen == 1 {
  8249. // 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
  8250. // resp, requestErr := http.Get(api)
  8251. // if requestErr != nil {
  8252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8253. // return
  8254. // }
  8255. // defer resp.Body.Close()
  8256. // body, ioErr := ioutil.ReadAll(resp.Body)
  8257. // if ioErr != nil {
  8258. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8260. // return
  8261. // }
  8262. // var respJSON map[string]interface{}
  8263. //
  8264. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8265. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8267. // return
  8268. // }
  8269. //
  8270. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8271. // userJSONBytes, _ := json.Marshal(userJSON)
  8272. // var res ResultTwo
  8273. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8274. // utils.ErrorLog("解析失败:%v", err)
  8275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8276. // return
  8277. // }
  8278. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8279. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8280. // infoStr := string(Iinfos)
  8281. // idetinfoStr := string(Idetinfos)
  8282. //
  8283. // if res.Infcode == 0 {
  8284. // his := models.VMHisPatient{
  8285. // Status: 1,
  8286. // Ctime: time.Now().Unix(),
  8287. // Mtime: time.Now().Unix(),
  8288. // PsnNo: res.Output.Baseinfo.PsnNo,
  8289. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8290. // Certno: res.Output.Baseinfo.Certno,
  8291. // PsnName: res.Output.Baseinfo.PsnName,
  8292. // Gend: res.Output.Baseinfo.Gend,
  8293. // Naty: res.Output.Baseinfo.Naty,
  8294. // Brdy: res.Output.Baseinfo.Brdy,
  8295. // Age: res.Output.Baseinfo.Age,
  8296. // Iinfo: infoStr,
  8297. // Idetinfo: idetinfoStr,
  8298. // PatientId: patient.ID,
  8299. // RecordDate: theTime.Unix(),
  8300. // UserOrgId: adminInfo.CurrentOrgId,
  8301. // AdminUserId: adminInfo.AdminUser.Id,
  8302. // IsReturn: 1,
  8303. // }
  8304. //
  8305. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8306. // //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")
  8307. // //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")
  8308. //
  8309. // //var dat map[string]interface{}
  8310. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8311. // // fmt.Println(dat)
  8312. // //} else {
  8313. // // fmt.Println(err)
  8314. // //}
  8315. //
  8316. // var dat2 map[string]interface{}
  8317. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8318. // fmt.Println(dat2)
  8319. // } else {
  8320. // fmt.Println(err)
  8321. // }
  8322. //
  8323. // } else {
  8324. // adminUser := c.GetAdminUserInfo()
  8325. // errlog := &models.HisOrderError{
  8326. // UserOrgId: adminUser.CurrentOrgId,
  8327. // Ctime: time.Now().Unix(),
  8328. // Mtime: time.Now().Unix(),
  8329. // ErrMsg: res.ErrMsg,
  8330. // Status: 1,
  8331. // PatientId: id,
  8332. // RecordTime: recordDateTime,
  8333. // Stage: 1,
  8334. // }
  8335. // service.CreateErrMsgLog(errlog)
  8336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8337. // return
  8338. // }
  8339. // }
  8340. //
  8341. //}
  8342. //func (c *HisApiController) GetUploadDiag() {
  8343. // id, _ := c.GetInt64("id")
  8344. // record_time := c.GetString("record_time")
  8345. //
  8346. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8347. // sick_type, _ := c.GetInt64("sick_type")
  8348. // reg_type, _ := c.GetInt64("reg_type")
  8349. //
  8350. // timeLayout := "2006-01-02"
  8351. // loc, _ := time.LoadLocation("Local")
  8352. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8353. // if err != nil {
  8354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8355. // return
  8356. // }
  8357. //
  8358. // var patientPrescription models.HisPrescriptionInfo
  8359. // recordDateTime := theTime.Unix()
  8360. // adminInfo := c.GetAdminUserInfo()
  8361. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8362. //
  8363. // if patientPrescription.ID == 0 {
  8364. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8365. // }
  8366. //
  8367. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8368. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8369. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8370. // sickConfig, _ := service.FindSickById(sick_type)
  8371. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8372. //
  8373. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8374. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8375. // "&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 +
  8376. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8377. // resp2, requestErr2 := http.Get(api2)
  8378. // if requestErr2 != nil {
  8379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8380. // return
  8381. // }
  8382. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8383. // if ioErr2 != nil {
  8384. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8386. // return
  8387. // }
  8388. // var respJSON2 map[string]interface{}
  8389. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8390. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. // return
  8393. // }
  8394. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8395. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8396. //
  8397. // var res2 ResultSix
  8398. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8399. // utils.ErrorLog("解析失败:%v", err)
  8400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8401. // return
  8402. // }
  8403. // if res2.Infcode != 0 {
  8404. // adminUser := c.GetAdminUserInfo()
  8405. // errlog := &models.HisOrderError{
  8406. // UserOrgId: adminUser.CurrentOrgId,
  8407. // Ctime: time.Now().Unix(),
  8408. // Mtime: time.Now().Unix(),
  8409. // ErrMsg: res2.ErrMsg,
  8410. // Status: 1,
  8411. // PatientId: id,
  8412. // RecordTime: recordDateTime,
  8413. // Stage: 3,
  8414. // }
  8415. // service.CreateErrMsgLog(errlog)
  8416. //
  8417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8418. // return
  8419. // }
  8420. //
  8421. // c.ServeSuccessJSON(map[string]interface{}{
  8422. // "msg": "上传成功",
  8423. // })
  8424. //
  8425. //}
  8426. type QueryResult struct {
  8427. ID int64
  8428. Name string
  8429. Code string
  8430. List_type_code string
  8431. }
  8432. func (c *HisApiController) GetCheckCode() {
  8433. ids_str := c.GetString("ids")
  8434. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8435. ids_arr := strings.Split(ids_str, ",")
  8436. var queryResult []QueryResult
  8437. ids := make([]int64, 0)
  8438. for _, item := range ids_arr {
  8439. id, _ := strconv.ParseInt(item, 10, 64)
  8440. ids = append(ids, id)
  8441. }
  8442. if record_type == 1 {
  8443. drugs, _ := service.GetBatchDrugList(ids)
  8444. for _, item := range drugs {
  8445. result := QueryResult{
  8446. ID: item.ID,
  8447. Name: item.DrugName,
  8448. Code: item.MedicalInsuranceNumber,
  8449. List_type_code: "101",
  8450. }
  8451. queryResult = append(queryResult, result)
  8452. }
  8453. } else if record_type == 2 {
  8454. goods, _ := service.GetBatchGoodInformationList(ids)
  8455. for _, item := range goods {
  8456. result := QueryResult{
  8457. ID: item.ID,
  8458. Name: item.GoodName,
  8459. Code: item.MedicalInsuranceNumber,
  8460. List_type_code: "301",
  8461. }
  8462. queryResult = append(queryResult, result)
  8463. }
  8464. } else if record_type == 3 {
  8465. projects, _ := service.GetBathchMyPorjecgList(ids)
  8466. for _, item := range projects {
  8467. result := QueryResult{
  8468. ID: item.ID,
  8469. Name: item.ProjectName,
  8470. Code: item.MedicalCode,
  8471. List_type_code: "201",
  8472. }
  8473. queryResult = append(queryResult, result)
  8474. }
  8475. }
  8476. admin_user_id, _ := c.GetInt64("admin_user_id")
  8477. adminUser := c.GetAdminUserInfo()
  8478. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8479. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8480. var user_name string
  8481. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8482. if role.ID == 0 {
  8483. user_name = "xxx"
  8484. } else {
  8485. user_name = role.UserName
  8486. }
  8487. baseParams := &models.BaseParams{
  8488. SecretKey: miConfig.SecretKey,
  8489. FixmedinsCode: miConfig.Code,
  8490. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8491. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8492. OrgName: miConfig.OrgName,
  8493. Doctor: user_name,
  8494. }
  8495. if config.IsOpen == 1 {
  8496. for _, item := range queryResult {
  8497. var result string
  8498. if record_type == 1 {
  8499. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8500. } else if record_type == 2 {
  8501. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8502. } else if record_type == 3 {
  8503. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8504. }
  8505. var dat map[string]interface{}
  8506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8507. fmt.Println(dat)
  8508. } else {
  8509. fmt.Println(err)
  8510. }
  8511. userJSONBytes, _ := json.Marshal(dat)
  8512. var res ResultSix
  8513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8514. utils.ErrorLog("解析失败:%v", err)
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. if res.Infcode == 0 {
  8519. if record_type == 1 {
  8520. service.UpdateBaseDrugById(item.ID)
  8521. } else if record_type == 2 {
  8522. service.UpdateGoodInformaitonByDetail(item.ID)
  8523. } else if record_type == 3 {
  8524. service.UpdateProjectById(item.ID)
  8525. }
  8526. c.ServeSuccessJSON(map[string]interface{}{
  8527. "failed_code": 0,
  8528. "msg": "目录对照成功",
  8529. })
  8530. } else {
  8531. c.ServeSuccessJSON(map[string]interface{}{
  8532. "failed_code": -10,
  8533. "msg": res.ErrMsg,
  8534. })
  8535. }
  8536. }
  8537. }
  8538. }
  8539. func (c *HisApiController) UnCheckCode() {
  8540. ids_str := c.GetString("ids")
  8541. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8542. admin_user_id, _ := c.GetInt64("admin_user_id")
  8543. ids_arr := strings.Split(ids_str, ",")
  8544. var queryResult []QueryResult
  8545. ids := make([]int64, 0)
  8546. for _, item := range ids_arr {
  8547. id, _ := strconv.ParseInt(item, 10, 64)
  8548. ids = append(ids, id)
  8549. }
  8550. if record_type == 1 {
  8551. drugs, _ := service.GetBatchDrugList(ids)
  8552. for _, item := range drugs {
  8553. result := QueryResult{
  8554. ID: item.ID,
  8555. Name: item.DrugName,
  8556. Code: item.MedicalInsuranceNumber,
  8557. List_type_code: "101",
  8558. }
  8559. queryResult = append(queryResult, result)
  8560. }
  8561. } else if record_type == 2 {
  8562. goods, _ := service.GetBatchGoodInformationList(ids)
  8563. for _, item := range goods {
  8564. result := QueryResult{
  8565. ID: item.ID,
  8566. Name: item.GoodName,
  8567. Code: item.MedicalInsuranceNumber,
  8568. List_type_code: "301",
  8569. }
  8570. queryResult = append(queryResult, result)
  8571. }
  8572. } else if record_type == 3 {
  8573. projects, _ := service.GetBathchMyPorjecgList(ids)
  8574. for _, item := range projects {
  8575. result := QueryResult{
  8576. ID: item.ID,
  8577. Name: item.ProjectName,
  8578. Code: item.MedicalCode,
  8579. List_type_code: "201",
  8580. }
  8581. queryResult = append(queryResult, result)
  8582. }
  8583. }
  8584. adminUser := c.GetAdminUserInfo()
  8585. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8586. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8587. var user_name string
  8588. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8589. if role.ID == 0 {
  8590. user_name = "xxx"
  8591. } else {
  8592. user_name = role.UserName
  8593. }
  8594. baseParams := &models.BaseParams{
  8595. SecretKey: miConfig.SecretKey,
  8596. FixmedinsCode: miConfig.Code,
  8597. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8598. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8599. OrgName: miConfig.OrgName,
  8600. Doctor: user_name,
  8601. }
  8602. if config.IsOpen == 1 {
  8603. for _, item := range queryResult {
  8604. var result string
  8605. if record_type == 1 {
  8606. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8607. } else if record_type == 2 {
  8608. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8609. } else if record_type == 3 {
  8610. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8611. }
  8612. var dat2 map[string]interface{}
  8613. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8614. fmt.Println(dat2)
  8615. } else {
  8616. fmt.Println(err)
  8617. }
  8618. userJSONBytes, _ := json.Marshal(dat2)
  8619. var res ResultSix
  8620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8621. utils.ErrorLog("解析失败:%v", err)
  8622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8623. return
  8624. }
  8625. if res.Infcode == 0 {
  8626. if record_type == 1 {
  8627. service.UpdateDrugByIdDetail(item.ID)
  8628. } else if record_type == 2 {
  8629. service.UpdateGoodInfoById(item.ID)
  8630. } else if record_type == 3 {
  8631. service.UpdateMyProjectById(item.ID)
  8632. }
  8633. c.ServeSuccessJSON(map[string]interface{}{
  8634. "failed_code": 0,
  8635. "msg": "撤销目录对照成功",
  8636. })
  8637. } else {
  8638. c.ServeSuccessJSON(map[string]interface{}{
  8639. "failed_code": -10,
  8640. "msg": res.ErrMsg,
  8641. })
  8642. }
  8643. }
  8644. }
  8645. }
  8646. func (c *HisApiController) GetPatientInfo() {
  8647. id_card_no := c.GetString("id_card_no")
  8648. admin_user_id, _ := c.GetInt64("admin_user_id")
  8649. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8650. if patient.ID == 0 {
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8652. return
  8653. }
  8654. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8655. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8656. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8657. if config.IsOpen == 1 {
  8658. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8659. var dat map[string]interface{}
  8660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8661. fmt.Println(dat)
  8662. } else {
  8663. fmt.Println(err)
  8664. }
  8665. userJSONBytes, _ := json.Marshal(dat)
  8666. var res ResultTwo
  8667. var res10265 ResultTwo10265
  8668. if miConfig.Code == "H15049901371" {
  8669. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8670. utils.ErrorLog("解析失败:%v", err)
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. res.ErrMsg = res10265.ErrMsg
  8675. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8676. res.Infcode = infocode
  8677. res.Output = res10265.Output
  8678. res.InfRefmsgid = res10265.InfRefmsgid
  8679. } else {
  8680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8681. utils.ErrorLog("解析失败:%v", err)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. }
  8686. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8687. // utils.ErrorLog("解析失败:%v", err)
  8688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. // return
  8690. //}
  8691. if res.Infcode != 0 {
  8692. c.ServeSuccessJSON(map[string]interface{}{
  8693. "failed_code": -10,
  8694. "msg": res.ErrMsg,
  8695. })
  8696. } else {
  8697. c.ServeSuccessJSON(map[string]interface{}{
  8698. "failed_code": 0,
  8699. "info": res,
  8700. })
  8701. }
  8702. }
  8703. }
  8704. func (c *HisApiController) PsnPutOnRecord() {
  8705. record_type, _ := c.GetInt64("type")
  8706. patient_id, _ := c.GetInt64("patient_id")
  8707. admin_user_id, _ := c.GetInt64("admin_user_id")
  8708. start_time := c.GetString("start_time")
  8709. end_time := c.GetString("end_time")
  8710. adminUser := c.GetAdminUserInfo()
  8711. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8712. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8713. var patients []*models.Patients
  8714. if record_type == 1 { //全部备案
  8715. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8716. patients = append(patients, patient...)
  8717. } else { //单个备案
  8718. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8719. patients = append(patients, patient)
  8720. }
  8721. var user_name string
  8722. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8723. if role.ID == 0 {
  8724. user_name = "xxx"
  8725. } else {
  8726. user_name = role.UserName
  8727. }
  8728. if config.IsOpen == 1 {
  8729. for _, item := range patients {
  8730. 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
  8731. resp, requestErr := http.Get(api)
  8732. if requestErr != nil {
  8733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8734. return
  8735. }
  8736. defer resp.Body.Close()
  8737. body, ioErr := ioutil.ReadAll(resp.Body)
  8738. if ioErr != nil {
  8739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. var respJSON map[string]interface{}
  8744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8750. userJSONBytes, _ := json.Marshal(userJSON)
  8751. var res ResultTwo
  8752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8753. utils.ErrorLog("解析失败:%v", err)
  8754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. return
  8756. }
  8757. if res.Infcode == 0 {
  8758. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8759. var dat map[string]interface{}
  8760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8761. fmt.Println(dat)
  8762. } else {
  8763. fmt.Println(err)
  8764. }
  8765. userJSONBytes, _ := json.Marshal(dat)
  8766. var res2 ResultThirteen
  8767. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8768. utils.ErrorLog("解析失败:%v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. if res2.Infcode == 0 {
  8773. psnResult := &models.GdybPsnRecord{
  8774. UserOrgId: adminUser.CurrentOrgId,
  8775. PatientId: item.ID,
  8776. PsnNo: res.Output.Baseinfo.PsnNo,
  8777. Ctime: time.Now().Unix(),
  8778. Mtime: time.Now().Unix(),
  8779. Status: 1,
  8780. IsCancel: 1,
  8781. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8782. }
  8783. service.CreatePsnRecord(psnResult)
  8784. } else {
  8785. c.ServeSuccessJSON(map[string]interface{}{
  8786. "failed_code": -10,
  8787. "msg": res2.ErrMsg,
  8788. })
  8789. return
  8790. }
  8791. }
  8792. }
  8793. }
  8794. }
  8795. func (c *HisApiController) PsnUnPutOnRecord() {
  8796. id, _ := c.GetInt64("id")
  8797. //record_type, _ := c.GetInt64("type")
  8798. admin_user_id, _ := c.GetInt64("admin_user_id")
  8799. adminUser := c.GetAdminUserInfo()
  8800. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8801. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8802. var user_name string
  8803. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8804. if role.ID == 0 {
  8805. user_name = "xxx"
  8806. } else {
  8807. user_name = role.UserName
  8808. }
  8809. psn_record, _ := service.GetPsnRecordById(id)
  8810. if psn_record.ID == 0 {
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8812. return
  8813. }
  8814. if config.IsOpen == 1 {
  8815. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8816. var dat map[string]interface{}
  8817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8818. fmt.Println(dat)
  8819. } else {
  8820. fmt.Println(err)
  8821. }
  8822. userJSONBytes, _ := json.Marshal(dat)
  8823. var res ResultFourteen
  8824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. if res.Infcode == 0 {
  8830. psn_record.IsCancel = 2
  8831. service.CreatePsnRecord(&psn_record)
  8832. } else {
  8833. c.ServeSuccessJSON(map[string]interface{}{
  8834. "failed_code": -10,
  8835. "msg": res.ErrMsg,
  8836. })
  8837. return
  8838. }
  8839. }
  8840. }
  8841. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8842. patient_id, _ := c.GetInt64("patient_id")
  8843. insutype_two := c.GetString("insutype")
  8844. psn_no := c.GetString("psn_no")
  8845. doctor_id, _ := c.GetInt64("doctor_id")
  8846. sick_id, _ := c.GetInt64("sick_id")
  8847. department_id, _ := c.GetInt64("department_id")
  8848. start_time := c.GetString("start_time")
  8849. end_time := c.GetString("end_time")
  8850. check_time := c.GetString("check_time")
  8851. adminUser := c.GetAdminUserInfo()
  8852. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8853. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8854. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8855. sick, _ := service.FindSickById(sick_id)
  8856. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8857. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8858. var res ResultTwo
  8859. var res10265 ResultTwo10265
  8860. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8861. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8862. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8863. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8864. "&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
  8865. resp, requestErr := http.Get(api)
  8866. if requestErr != nil {
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. body, ioErr := ioutil.ReadAll(resp.Body)
  8871. if ioErr != nil {
  8872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8874. return
  8875. }
  8876. var respJSON map[string]interface{}
  8877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8883. result, _ := json.Marshal(respJSON)
  8884. fmt.Println("log")
  8885. fmt.Println(string(result))
  8886. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8887. utils.ErrorLog("解析失败:%v", err)
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. res.ErrMsg = res10265.ErrMsg
  8892. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8893. res.Infcode = infocode
  8894. res.Output = res10265.Output
  8895. res.InfRefmsgid = res10265.InfRefmsgid
  8896. } else {
  8897. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8898. if miConfig.Code == "H15049901371" {
  8899. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8900. utils.ErrorLog("解析失败:%v", err)
  8901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8902. return
  8903. }
  8904. res.ErrMsg = res10265.ErrMsg
  8905. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8906. res.Infcode = infocode
  8907. res.Output = res10265.Output
  8908. res.InfRefmsgid = res10265.InfRefmsgid
  8909. } else {
  8910. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8911. utils.ErrorLog("解析失败:%v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. }
  8916. }
  8917. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8918. infoStr := string(Iinfos)
  8919. var rf []*ResultFive
  8920. json.Unmarshal([]byte(infoStr), &rf)
  8921. var insuplc_admdvs string
  8922. var insutype string
  8923. var is390 int = 0
  8924. var is310 int = 0
  8925. var insutypes []*ResultFive
  8926. for _, item := range rf {
  8927. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8928. insutypes = append(insutypes, item)
  8929. }
  8930. }
  8931. if len(insutypes) == 1 {
  8932. insutype = insutypes[0].Insutype
  8933. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8934. } else {
  8935. for _, i := range insutypes {
  8936. if i.Insutype == "390" {
  8937. is390 = 1
  8938. }
  8939. if i.Insutype == "310" {
  8940. is310 = 1
  8941. }
  8942. }
  8943. }
  8944. if is390 == 1 {
  8945. insutype = "390"
  8946. }
  8947. if is310 == 1 {
  8948. insutype = "310"
  8949. }
  8950. if len(insutypes) == 2 {
  8951. insutype = insutype_two
  8952. }
  8953. if len(insutypes) == 0 {
  8954. insutype = "310"
  8955. }
  8956. insutype = insutype_two
  8957. fmt.Println(insutype)
  8958. for _, item := range rf {
  8959. fmt.Println(item.Insutype)
  8960. fmt.Println(insutype)
  8961. if item.Insutype == insutype {
  8962. fmt.Println(item.Insutype)
  8963. fmt.Println(insutype)
  8964. insuplc_admdvs = item.InsuplcAdmdvs
  8965. }
  8966. }
  8967. fmt.Println(insuplc_admdvs)
  8968. var res2 ResultThirteen
  8969. var res10265_2 ResultThirteen10265
  8970. if config.IsOpen == 1 {
  8971. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8972. } else {
  8973. 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)
  8974. var dat map[string]interface{}
  8975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8976. fmt.Println(dat)
  8977. } else {
  8978. fmt.Println(err)
  8979. }
  8980. userJSONBytes, _ := json.Marshal(dat)
  8981. if miConfig.Code == "H15049901371" {
  8982. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8983. utils.ErrorLog("解析失败:%v", err)
  8984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8985. return
  8986. }
  8987. res2.ErrMsg = res10265_2.ErrMsg
  8988. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8989. res2.Infcode = infocode
  8990. res2.Output = res10265_2.Output
  8991. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8992. } else {
  8993. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8994. utils.ErrorLog("解析失败:%v", err)
  8995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8996. return
  8997. }
  8998. }
  8999. }
  9000. if res2.Infcode == 0 {
  9001. psnResult := &models.GdybPsnNcdsRecord{
  9002. UserOrgId: adminUser.CurrentOrgId,
  9003. PatientId: patient.ID,
  9004. PsnNo: psn_no,
  9005. DoctorId: doctor.AdminUserId,
  9006. DepartmentId: department_id,
  9007. SickType: sick_id,
  9008. Insutype: insutype,
  9009. Ctime: time.Now().Unix(),
  9010. Mtime: time.Now().Unix(),
  9011. Status: 1,
  9012. IsCancel: 1,
  9013. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9014. }
  9015. service.CreatePsnNCDSRecord(psnResult)
  9016. c.ServeSuccessJSON(map[string]interface{}{
  9017. "failed_code": 0,
  9018. "msg": "备案成功",
  9019. "result": psnResult,
  9020. })
  9021. } else {
  9022. c.ServeSuccessJSON(map[string]interface{}{
  9023. "failed_code": -10,
  9024. "msg": res2.ErrMsg,
  9025. })
  9026. return
  9027. }
  9028. }
  9029. }
  9030. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9031. id, _ := c.GetInt64("id")
  9032. admin_user_id, _ := c.GetInt64("admin_user_id")
  9033. adminUser := c.GetAdminUserInfo()
  9034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9035. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9036. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9037. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9038. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9039. //var user_name string
  9040. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9041. //if role.ID == 0 {
  9042. // user_name = "xxx"
  9043. //} else {
  9044. // user_name = role.UserName
  9045. //}
  9046. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9047. if psn_record.ID == 0 {
  9048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9049. return
  9050. }
  9051. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9052. var res ResultTwo
  9053. var res10265 ResultTwo10265
  9054. if miConfig.Code == "H15049901371" {
  9055. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9056. utils.ErrorLog("解析失败:%v", err)
  9057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9058. return
  9059. }
  9060. res.ErrMsg = res10265.ErrMsg
  9061. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9062. res.Infcode = infocode
  9063. res.Output = res10265.Output
  9064. res.InfRefmsgid = res10265.InfRefmsgid
  9065. } else {
  9066. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9067. utils.ErrorLog("解析失败:%v", err)
  9068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9069. return
  9070. }
  9071. }
  9072. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9073. infoStr := string(Iinfos)
  9074. var rf []*ResultFive
  9075. json.Unmarshal([]byte(infoStr), &rf)
  9076. var insuplc_admdvs string
  9077. var insutype string
  9078. var is390 int = 0
  9079. var is310 int = 0
  9080. var insutypes []*ResultFive
  9081. for _, item := range rf {
  9082. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9083. insutypes = append(insutypes, item)
  9084. }
  9085. }
  9086. if len(insutypes) == 1 {
  9087. insutype = insutypes[0].Insutype
  9088. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9089. } else {
  9090. for _, i := range insutypes {
  9091. if i.Insutype == "390" {
  9092. is390 = 1
  9093. }
  9094. if i.Insutype == "310" {
  9095. is310 = 1
  9096. }
  9097. }
  9098. }
  9099. if is390 == 1 {
  9100. insutype = "390"
  9101. }
  9102. if is310 == 1 {
  9103. insutype = "310"
  9104. }
  9105. if len(insutypes) == 0 {
  9106. insutype = "310"
  9107. }
  9108. insutype = psn_record.Insutype
  9109. for _, item := range rf {
  9110. if item.Insutype == insutype {
  9111. insuplc_admdvs = item.InsuplcAdmdvs
  9112. }
  9113. }
  9114. if config.IsOpen == 1 {
  9115. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9116. var dat map[string]interface{}
  9117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9118. fmt.Println(dat)
  9119. } else {
  9120. fmt.Println(err)
  9121. }
  9122. userJSONBytes, _ := json.Marshal(dat)
  9123. var res ResultFourteen
  9124. var res10265 ResultFourteen10265
  9125. if miConfig.Code == "H15049901371" {
  9126. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9127. utils.ErrorLog("解析失败:%v", err)
  9128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9129. return
  9130. }
  9131. res.ErrMsg = res10265.ErrMsg
  9132. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9133. res.Infcode = infocode
  9134. res.Output = res10265.Output
  9135. res.InfRefmsgid = res10265.InfRefmsgid
  9136. } else {
  9137. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9138. utils.ErrorLog("解析失败:%v", err)
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9140. return
  9141. }
  9142. }
  9143. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9144. // utils.ErrorLog("解析失败:%v", err)
  9145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9146. // return
  9147. //}
  9148. if res.Infcode == 0 {
  9149. psn_record.IsCancel = 2
  9150. service.CreatePsnNCDSRecord(&psn_record)
  9151. c.ServeSuccessJSON(map[string]interface{}{
  9152. "failed_code": 0,
  9153. "msg": "撤销备案成功",
  9154. })
  9155. } else {
  9156. c.ServeSuccessJSON(map[string]interface{}{
  9157. "failed_code": -10,
  9158. "msg": res.ErrMsg,
  9159. })
  9160. return
  9161. }
  9162. }
  9163. }
  9164. func (c *HisApiController) TestTest() {
  9165. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9166. fmt.Println(patient.Iinfo)
  9167. }
  9168. type CustomData struct {
  9169. MsgId string
  9170. PsnNo string
  9171. Info string
  9172. }
  9173. func (c *HisApiController) ReversalData() {
  9174. var customData []*CustomData
  9175. custom := &CustomData{
  9176. MsgId: "H44022900158202103301714472004",
  9177. PsnNo: "44020000001101329945",
  9178. Info: "2207",
  9179. }
  9180. customData = append(customData, custom)
  9181. custom1 := &CustomData{
  9182. MsgId: "H4402290015820210330172057803",
  9183. PsnNo: "44020000001101161813",
  9184. Info: "2207",
  9185. }
  9186. customData = append(customData, custom1)
  9187. custom2 := &CustomData{
  9188. MsgId: "H44022900158202103301705198813",
  9189. PsnNo: "44190000133097375417",
  9190. Info: "2207",
  9191. }
  9192. customData = append(customData, custom2)
  9193. custom3 := &CustomData{
  9194. MsgId: "H44022900158202103301715524756",
  9195. PsnNo: "44020000001100187221",
  9196. Info: "2207",
  9197. }
  9198. customData = append(customData, custom3)
  9199. custom4 := &CustomData{
  9200. MsgId: "H44022900158202103301730376224",
  9201. PsnNo: "44020000001101959155",
  9202. Info: "2207",
  9203. }
  9204. customData = append(customData, custom4)
  9205. custom5 := &CustomData{
  9206. MsgId: "H44022900158202103301748008725",
  9207. PsnNo: "44020000001104246641",
  9208. Info: "2207",
  9209. }
  9210. customData = append(customData, custom5)
  9211. custom6 := &CustomData{
  9212. MsgId: "H44022900158202103301718096755",
  9213. PsnNo: "44020000001102211860",
  9214. Info: "2207",
  9215. }
  9216. customData = append(customData, custom6)
  9217. custom7 := &CustomData{
  9218. MsgId: "H44022900158202103301736551640",
  9219. PsnNo: "44020000001102687718",
  9220. Info: "2207",
  9221. }
  9222. customData = append(customData, custom7)
  9223. custom8 := &CustomData{
  9224. MsgId: "H44022900158202103301743097676",
  9225. PsnNo: "44020000001102127785",
  9226. Info: "2207",
  9227. }
  9228. customData = append(customData, custom8)
  9229. custom9 := &CustomData{
  9230. MsgId: "H44022900158202103301712304203",
  9231. PsnNo: "44020000001101518097",
  9232. Info: "2207",
  9233. }
  9234. customData = append(customData, custom9)
  9235. custom10 := &CustomData{
  9236. MsgId: "H44022900158202103301738448785",
  9237. PsnNo: "44020000001100500813",
  9238. Info: "2207",
  9239. }
  9240. customData = append(customData, custom10)
  9241. custom11 := &CustomData{
  9242. MsgId: "H44022900158202103301732455843",
  9243. PsnNo: "44020000001102690557",
  9244. Info: "2207",
  9245. }
  9246. customData = append(customData, custom11)
  9247. custom12 := &CustomData{
  9248. MsgId: "H44022900158202103301745421708",
  9249. PsnNo: "44020000001102211928",
  9250. Info: "2207",
  9251. }
  9252. customData = append(customData, custom12)
  9253. custom1212 := &CustomData{
  9254. MsgId: "H440229001582021033017351627",
  9255. PsnNo: "44020000001102481733",
  9256. Info: "2207",
  9257. }
  9258. customData = append(customData, custom1212)
  9259. custom13 := &CustomData{
  9260. MsgId: "H44022900158202103301740327951",
  9261. PsnNo: "44020000001103174866",
  9262. Info: "2207",
  9263. }
  9264. customData = append(customData, custom13)
  9265. custom14 := &CustomData{
  9266. MsgId: "H4402290015820210330174922668",
  9267. PsnNo: "44020000001102927272",
  9268. Info: "2207",
  9269. }
  9270. customData = append(customData, custom14)
  9271. custom15 := &CustomData{
  9272. MsgId: "H44022900158202103301752362273",
  9273. PsnNo: "44020000001102942890",
  9274. Info: "2207",
  9275. }
  9276. customData = append(customData, custom15)
  9277. custom16 := &CustomData{
  9278. MsgId: "H44022900158202103301751082917",
  9279. PsnNo: "44020000001101662162",
  9280. Info: "2207",
  9281. }
  9282. customData = append(customData, custom16)
  9283. custom17 := &CustomData{
  9284. MsgId: "H44022900158202103301754147728",
  9285. PsnNo: "44020000000229014511",
  9286. Info: "2207",
  9287. }
  9288. customData = append(customData, custom17)
  9289. adminUser := c.GetAdminUserInfo()
  9290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9291. for _, item := range customData {
  9292. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9293. fmt.Println(result)
  9294. }
  9295. }
  9296. func (c *HisApiController) GetAllopatry() {
  9297. year := c.GetString("year")
  9298. month := c.GetString("month")
  9299. admin_user_id, _ := c.GetInt64("admin_user_id")
  9300. adminUser := c.GetAdminUserInfo()
  9301. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9302. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9303. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9304. var dat map[string]interface{}
  9305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9306. fmt.Println(dat)
  9307. } else {
  9308. fmt.Println(err)
  9309. }
  9310. userJSONBytes, _ := json.Marshal(dat)
  9311. var res models.Result9001
  9312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9313. utils.ErrorLog("解析失败:%v", err)
  9314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9315. return
  9316. }
  9317. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9318. var dat2 map[string]interface{}
  9319. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9320. fmt.Println(dat)
  9321. } else {
  9322. fmt.Println(err)
  9323. }
  9324. userJSONBytes2, _ := json.Marshal(dat2)
  9325. var res2 models.Result3260
  9326. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9327. utils.ErrorLog("解析失败:%v", err)
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9329. return
  9330. }
  9331. if res2.Infcode == 0 {
  9332. c.ServeSuccessJSON(map[string]interface{}{
  9333. "list": res2.Output.Data,
  9334. })
  9335. return
  9336. } else {
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. }
  9341. func (c *HisApiController) ComfirmAllopatry() {
  9342. year := c.GetString("year")
  9343. month := c.GetString("month")
  9344. admin_user_id, _ := c.GetInt64("admin_user_id")
  9345. adminUser := c.GetAdminUserInfo()
  9346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9347. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9348. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9349. var dat map[string]interface{}
  9350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9351. fmt.Println(dat)
  9352. } else {
  9353. fmt.Println(err)
  9354. }
  9355. userJSONBytes, _ := json.Marshal(dat)
  9356. var res models.Result9001
  9357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9358. utils.ErrorLog("解析失败:%v", err)
  9359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9360. return
  9361. }
  9362. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9363. var dat2 map[string]interface{}
  9364. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9365. fmt.Println(dat)
  9366. } else {
  9367. fmt.Println(err)
  9368. }
  9369. userJSONBytes2, _ := json.Marshal(dat2)
  9370. var res2 models.Result3260
  9371. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9372. utils.ErrorLog("解析失败:%v", err)
  9373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9374. return
  9375. }
  9376. if res2.Infcode == 0 {
  9377. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9378. var dat map[string]interface{}
  9379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9380. fmt.Println(dat)
  9381. } else {
  9382. fmt.Println(err)
  9383. }
  9384. userJSONBytes, _ := json.Marshal(dat)
  9385. var res3 models.Result3261
  9386. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9387. utils.ErrorLog("解析失败:%v", err)
  9388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9389. return
  9390. }
  9391. if res3.Infcode == 0 {
  9392. record := &models.HisYidiClearRecord{
  9393. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9394. Ctime: time.Now().Unix(),
  9395. Mtime: time.Now().Unix(),
  9396. Status: 1,
  9397. MsgId: msgId,
  9398. }
  9399. service.SaveClearRecord(record)
  9400. c.ServeSuccessJSON(map[string]interface{}{
  9401. "msg": "提取成功",
  9402. })
  9403. }
  9404. }
  9405. }
  9406. func (c *HisApiController) RefundAllopatry() {
  9407. year := c.GetString("year")
  9408. month := c.GetString("month")
  9409. id, _ := c.GetInt64("id")
  9410. admin_user_id, _ := c.GetInt64("admin_user_id")
  9411. adminUser := c.GetAdminUserInfo()
  9412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9413. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9414. record, _ := service.GetClearRecordById(id)
  9415. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9416. var dat map[string]interface{}
  9417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9418. fmt.Println(dat)
  9419. } else {
  9420. fmt.Println(err)
  9421. }
  9422. userJSONBytes, _ := json.Marshal(dat)
  9423. var empty ResultFourteen
  9424. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9425. utils.ErrorLog("解析失败:%v", err)
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9427. return
  9428. }
  9429. if empty.Infcode == 0 {
  9430. c.ServeSuccessJSON(map[string]interface{}{
  9431. "msg": "撤销成功",
  9432. })
  9433. return
  9434. }
  9435. }
  9436. func (c *HisApiController) ReversalOtherData() {
  9437. var customData []*CustomData
  9438. custom := &CustomData{
  9439. MsgId: "H44022900158202103301714472004",
  9440. PsnNo: "44020000001101329945",
  9441. Info: "2208",
  9442. }
  9443. customData = append(customData, custom)
  9444. custom1 := &CustomData{
  9445. MsgId: "H4402290015820210330172057803",
  9446. PsnNo: "44020000001101161813",
  9447. Info: "2208",
  9448. }
  9449. customData = append(customData, custom1)
  9450. custom2 := &CustomData{
  9451. MsgId: "H44022900158202103301705198813",
  9452. PsnNo: "44190000133097375417",
  9453. Info: "2208",
  9454. }
  9455. customData = append(customData, custom2)
  9456. custom3 := &CustomData{
  9457. MsgId: "H44022900158202103301715524756",
  9458. PsnNo: "44020000001100187221",
  9459. Info: "2208",
  9460. }
  9461. customData = append(customData, custom3)
  9462. custom4 := &CustomData{
  9463. MsgId: "H44022900158202103301730376224",
  9464. PsnNo: "44020000001101959155",
  9465. Info: "2208",
  9466. }
  9467. customData = append(customData, custom4)
  9468. custom5 := &CustomData{
  9469. MsgId: "H44022900158202103301748008725",
  9470. PsnNo: "44020000001104246641",
  9471. Info: "2208",
  9472. }
  9473. customData = append(customData, custom5)
  9474. custom6 := &CustomData{
  9475. MsgId: "H44022900158202103301718096755",
  9476. PsnNo: "44020000001102211860",
  9477. Info: "2208",
  9478. }
  9479. customData = append(customData, custom6)
  9480. custom7 := &CustomData{
  9481. MsgId: "H44022900158202103301736551640",
  9482. PsnNo: "44020000001102687718",
  9483. Info: "2208",
  9484. }
  9485. customData = append(customData, custom7)
  9486. custom8 := &CustomData{
  9487. MsgId: "H44022900158202103301743097676",
  9488. PsnNo: "44020000001102127785",
  9489. Info: "2208",
  9490. }
  9491. customData = append(customData, custom8)
  9492. custom9 := &CustomData{
  9493. MsgId: "H44022900158202103301712304203",
  9494. PsnNo: "44020000001101518097",
  9495. Info: "2208",
  9496. }
  9497. customData = append(customData, custom9)
  9498. custom10 := &CustomData{
  9499. MsgId: "H44022900158202103301738448785",
  9500. PsnNo: "44020000001100500813",
  9501. Info: "2208",
  9502. }
  9503. customData = append(customData, custom10)
  9504. custom11 := &CustomData{
  9505. MsgId: "H44022900158202103301732455843",
  9506. PsnNo: "44020000001102690557",
  9507. Info: "2208",
  9508. }
  9509. customData = append(customData, custom11)
  9510. custom12 := &CustomData{
  9511. MsgId: "H44022900158202103301745421708",
  9512. PsnNo: "44020000001102211928",
  9513. Info: "2208",
  9514. }
  9515. customData = append(customData, custom12)
  9516. custom1212 := &CustomData{
  9517. MsgId: "H440229001582021033017351627",
  9518. PsnNo: "44020000001102481733",
  9519. Info: "2208",
  9520. }
  9521. customData = append(customData, custom1212)
  9522. custom13 := &CustomData{
  9523. MsgId: "H44022900158202103301740327951",
  9524. PsnNo: "44020000001103174866",
  9525. Info: "2208",
  9526. }
  9527. customData = append(customData, custom13)
  9528. custom14 := &CustomData{
  9529. MsgId: "H4402290015820210330174922668",
  9530. PsnNo: "44020000001102927272",
  9531. Info: "2208",
  9532. }
  9533. customData = append(customData, custom14)
  9534. custom15 := &CustomData{
  9535. MsgId: "H44022900158202103301752362273",
  9536. PsnNo: "44020000001102942890",
  9537. Info: "2208",
  9538. }
  9539. customData = append(customData, custom15)
  9540. custom16 := &CustomData{
  9541. MsgId: "H44022900158202103301751082917",
  9542. PsnNo: "44020000001101662162",
  9543. Info: "2208",
  9544. }
  9545. customData = append(customData, custom16)
  9546. custom17 := &CustomData{
  9547. MsgId: "H44022900158202103301754147728",
  9548. PsnNo: "44020000000229014511",
  9549. Info: "2208",
  9550. }
  9551. customData = append(customData, custom17)
  9552. adminUser := c.GetAdminUserInfo()
  9553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9554. for _, item := range customData {
  9555. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9556. fmt.Println(result)
  9557. }
  9558. }
  9559. func PathExists(path string) (bool, error) {
  9560. _, err := os.Stat(path)
  9561. if err == nil {
  9562. return true, nil
  9563. }
  9564. if os.IsNotExist(err) {
  9565. return false, nil
  9566. }
  9567. return false, err
  9568. }
  9569. //创建文件夹
  9570. func Mkdir(dir string) {
  9571. // 创建文件夹
  9572. exist, err := PathExists(dir)
  9573. if err != nil {
  9574. fmt.Println(err.Error())
  9575. } else {
  9576. if exist {
  9577. fmt.Println(dir + "文件夹已存在!")
  9578. } else {
  9579. // 文件夹名称,权限
  9580. err := os.Mkdir(dir, os.ModePerm)
  9581. if err != nil {
  9582. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9583. } else {
  9584. fmt.Println(dir + "文件夹创建成功!")
  9585. }
  9586. }
  9587. }
  9588. }
  9589. //压缩文件
  9590. func Zip(srcFile string, destZip string) error {
  9591. zipfile, err := os.Create(destZip)
  9592. if err != nil {
  9593. return err
  9594. }
  9595. defer zipfile.Close()
  9596. archive := zip.NewWriter(zipfile)
  9597. defer archive.Close()
  9598. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9599. if err != nil {
  9600. return err
  9601. }
  9602. header, err := zip.FileInfoHeader(info)
  9603. if err != nil {
  9604. return err
  9605. }
  9606. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9607. // header.Name = path
  9608. if info.IsDir() {
  9609. header.Name += "/"
  9610. } else {
  9611. header.Method = zip.Deflate
  9612. }
  9613. writer, err := archive.CreateHeader(header)
  9614. if err != nil {
  9615. return err
  9616. }
  9617. if !info.IsDir() {
  9618. file, err := os.Open(path)
  9619. if err != nil {
  9620. return err
  9621. }
  9622. defer file.Close()
  9623. _, err = io.Copy(writer, file)
  9624. }
  9625. return err
  9626. })
  9627. return err
  9628. }
  9629. func ReadFile(filePath string) []byte {
  9630. f, err := os.Open(filePath)
  9631. if err != nil {
  9632. fmt.Println("read file fail", err)
  9633. return nil
  9634. }
  9635. defer f.Close()
  9636. fd, err := ioutil.ReadAll(f)
  9637. if err != nil {
  9638. fmt.Println("read to fd fail", err)
  9639. return nil
  9640. }
  9641. return fd
  9642. }
  9643. func saveLog(result string, request string, infno string, desc string) {
  9644. org_id, _ := beego.AppConfig.Int64("org_id")
  9645. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9646. dir := miConfig.OrgName + "日志"
  9647. utils.Mkdir(dir)
  9648. month := time.Unix(1557042972, 0).Format("1")
  9649. year := time.Now().Format("2006")
  9650. month = time.Now().Format("01")
  9651. day := time.Now().Format("02")
  9652. hour := time.Now().Format("15")
  9653. min := time.Now().Format("04")
  9654. sec := time.Now().Format("05")
  9655. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9656. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9657. file_name := file + ".txt"
  9658. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9659. exist, _ := utils.PathExists(file_path)
  9660. if exist { //存在
  9661. fmt.Println("存在")
  9662. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9663. if err != nil {
  9664. fmt.Println("read fail")
  9665. }
  9666. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9667. n, _ := f.Seek(0, 2)
  9668. _, err = f.WriteAt([]byte(content), n)
  9669. } else { //不存在
  9670. fmt.Println("文件不存在,创建文件")
  9671. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9672. defer f.Close()
  9673. if err != nil {
  9674. } else {
  9675. _, err = f.Write([]byte("记录日志"))
  9676. }
  9677. }
  9678. }
  9679. type Charset string
  9680. const (
  9681. UTF8 = Charset("UTF-8")
  9682. GB18030 = Charset("GB18030")
  9683. )
  9684. func ConvertToString(src string, srcCode string, tagCode string) string {
  9685. srcCoder := mahonia.NewDecoder(srcCode)
  9686. srcResult := srcCoder.ConvertString(src)
  9687. tagCoder := mahonia.NewDecoder(tagCode)
  9688. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9689. result := string(cdata)
  9690. return result
  9691. }